From: Vasudev Kamath Date: Sun, 3 Dec 2017 06:28:47 +0000 (+0530) Subject: New upstream version 0.23.0 X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~6 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=253940f6a3527780733d14f261da2659dff29118;p=cargo.git New upstream version 0.23.0 --- 253940f6a3527780733d14f261da2659dff29118 diff --cc vendor/atty-0.2.3/.cargo-checksum.json index 000000000,000000000..a0885f188 new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860"} diff --cc vendor/atty-0.2.3/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/.cargo-ok diff --cc vendor/atty-0.2.3/.travis.yml index 000000000,000000000..a628724c9 new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/.travis.yml @@@ -1,0 -1,0 +1,73 @@@ ++sudo: false ++language: rust ++matrix: ++ fast_finish: true ++ include: ++ - rust: nightly ++ - rust: nightly ++ os: osx ++ - rust: beta ++ - rust: beta ++ os: osx ++ - rust: stable ++ - rust: stable ++ os: osx ++ allow_failures: ++ - rust: nightly ++ ++before_cache: ++ # Travis can't cache files that are not readable by "others" ++ - chmod -R a+r $HOME/.cargo ++ ++before_install: ++ # install kcov ++ - > ++ if [ ! -d "$HOME/.kcov/bin" ]; then ++ wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && ++ tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && ++ cmake -DCMAKE_INSTALL_PREFIX:PATH=$HOME/.kcov .. && make && make install && cd ../.. ++ fi ++ - export PATH=$HOME/.kcov/bin:$PATH ++ ++script: ++ - cargo build ++ ++cache: ++ cargo: true ++ apt: true ++ directories: ++ - target/debug/deps ++ - target/debug/build ++ ++addons: ++ apt: ++ packages: ++ - libcurl4-openssl-dev ++ - libelf-dev ++ - libdw-dev ++ - binutils-dev ++ - libiberty-dev ++ ++after_success: ++ - '[ $TRAVIS_RUST_VERSION = stable ] && ++ [ $TRAVIS_BRANCH = master ] && ++ [ $TRAVIS_PULL_REQUEST = false ] && ++ (ls target/debug && ++ RUSTFLAGS="-C link-dead-code" cargo test --no-run && ++ for file in target/debug/atty-*; do ++ if [[ "${file: -2}" != ".d" ]]; then ++ mkdir -p "target/cov/$(basename $file)"; ++ kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file"; ++ fi; ++ done && ++ kcov --coveralls-id=$COVERALLS_REPO_TOKEN --merge target/cov target/cov/* && ++ echo "covered") || true' ++ - '[ $TRAVIS_RUST_VERSION = stable ] && ++ [ $TRAVIS_BRANCH = master ] && ++ [ $TRAVIS_PULL_REQUEST = false ] ++ && cargo doc --no-deps && ++ echo "" > target/doc/index.html && ++ pip install --user ghp-import && ++ /home/travis/.local/bin/ghp-import -n target/doc && ++ git push -fq https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages && ++ echo "documented"' diff --cc vendor/atty-0.2.3/CHANGELOG.md index 000000000,000000000..9685db2df new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/CHANGELOG.md @@@ -1,0 -1,0 +1,29 @@@ ++# 0.2.3 ++ ++* added support for Redox OS [#14](https://github.com/softprops/atty/pull/14) ++ ++# 0.2.2 ++ ++* use target specific dependencies [#11](https://github.com/softprops/atty/pull/11) ++* Add tty detection for MSYS terminals [#12](https://github.com/softprops/atty/pull/12) ++ ++# 0.2.1 ++ ++* fix windows bug ++ ++# 0.2.0 ++ ++* support for various stream types ++ ++# 0.1.2 ++ ++* windows support (with automated testing) ++* automated code coverage ++ ++# 0.1.1 ++ ++* bumped libc dep from `0.1` to `0.2` ++ ++# 0.1.0 ++ ++* initial release diff --cc vendor/atty-0.2.3/Cargo.toml index 000000000,000000000..1c2f20adb new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/Cargo.toml @@@ -1,0 -1,0 +1,35 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "atty" ++version = "0.2.3" ++authors = ["softprops "] ++description = "A simple interface for querying atty" ++homepage = "https://github.com/softprops/atty" ++documentation = "http://softprops.github.io/atty" ++readme = "README.md" ++keywords = ["terminal", "tty"] ++license = "MIT" ++repository = "https://github.com/softprops/atty" ++[target."cfg(target_os = \"redox\")".dependencies.termion] ++version = "1.5" ++[target."cfg(windows)".dependencies.kernel32-sys] ++version = "0.2" ++ ++[target."cfg(windows)".dependencies.winapi] ++version = "0.2" ++[target."cfg(unix)".dependencies.libc] ++version = "0.2" ++default-features = false ++[badges.travis-ci] ++repository = "softprops/atty" diff --cc vendor/atty-0.2.3/LICENSE index 000000000,000000000..d1f01c829 new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/LICENSE @@@ -1,0 -1,0 +1,20 @@@ ++Copyright (c) 2015-2017 Doug Tangren ++ ++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 --cc vendor/atty-0.2.3/README.md index 000000000,000000000..2ee7df42d new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/README.md @@@ -1,0 -1,0 +1,78 @@@ ++# atty ++ ++[![Build Status](https://travis-ci.org/softprops/atty.svg?branch=master)](https://travis-ci.org/softprops/atty) [![Build status](https://ci.appveyor.com/api/projects/status/geggrsnsjsuse8cv?svg=true)](https://ci.appveyor.com/project/softprops/atty) [![Coverage Status](https://coveralls.io/repos/softprops/atty/badge.svg?branch=master&service=github)](https://coveralls.io/github/softprops/atty?branch=master) [![crates.io](http://meritbadge.herokuapp.com/atty)](https://crates.io/crates/atty) ++ ++> are you or are you not a tty? ++ ++ ++[Documentation](http://softprops.github.io/atty) ++ ++## install ++ ++Add the following to your `Cargo.toml` ++ ++```toml ++[dependencies] ++atty = "0.2" ++``` ++ ++## usage ++ ++```rust ++extern crate atty; ++ ++use atty::Stream; ++ ++fn main() { ++ if atty::is(Stream::Stdout) { ++ println!("I'm a terminal"); ++ } else { ++ println!("I'm not"); ++ } ++} ++``` ++ ++## testing ++ ++This library has been unit tested on both unix and windows platforms (via appveyor). ++ ++ ++A simple example program is provided in this repo to test various tty's. By default. ++ ++It prints ++ ++```bash ++$ cargo run --example atty ++stdout? true ++stderr? true ++stdin? true ++``` ++ ++To test std in, pipe some text to the program ++ ++```bash ++$ echo "test" | cargo run --example atty ++stdout? true ++stderr? true ++stdin? false ++``` ++ ++To test std out, pipe the program to something ++ ++```bash ++$ cargo run --example atty | grep std ++stdout? false ++stderr? true ++stdin? true ++``` ++ ++To test std err, pipe the program to something redirecting std err ++ ++```bash ++$ cargo run --example atty 2>&1 | grep std ++stdout? false ++stderr? false ++stdin? true ++``` ++ ++Doug Tangren (softprops) 2015-2017 diff --cc vendor/atty-0.2.3/appveyor.yml index 000000000,000000000..d7fb12794 new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/appveyor.yml @@@ -1,0 -1,0 +1,16 @@@ ++environment: ++ matrix: ++ - TARGET: nightly-x86_64-pc-windows-msvc ++ - TARGET: nightly-i686-pc-windows-msvc ++ - TARGET: nightly-x86_64-pc-windows-gnu ++ - TARGET: nightly-i686-pc-windows-gnu ++install: ++ - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:TARGET}.exe" -FileName "rust-install.exe" ++ - ps: .\rust-install.exe /VERYSILENT /NORESTART /DIR="C:\rust" | Out-Null ++ - ps: $env:PATH="$env:PATH;C:\rust\bin" ++ - call "%VCVARS%" || ver>nul ++ - rustc -vV ++ - cargo -vV ++build: false ++test_script: ++ - cargo build diff --cc vendor/atty-0.2.3/examples/atty.rs index 000000000,000000000..3b3635e59 new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/examples/atty.rs @@@ -1,0 -1,0 +1,9 @@@ ++extern crate atty; ++ ++use atty::{is, Stream}; ++ ++fn main() { ++ println!("stdout? {}", is(Stream::Stdout)); ++ println!("stderr? {}", is(Stream::Stderr)); ++ println!("stdin? {}", is(Stream::Stdin)); ++} diff --cc vendor/atty-0.2.3/rustfmt.toml index 000000000,000000000..d83987dca new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/rustfmt.toml @@@ -1,0 -1,0 +1,10 @@@ ++# keep imports tidy ++reorder_imported_names = true ++reorder_imports = true ++reorder_imports_in_group = true ++# there is no try! ++use_try_shorthand = true ++# don't create rustfmt artifacts ++write_mode = "Replace" ++# reduce wide load ++max_width = 80 diff --cc vendor/atty-0.2.3/src/lib.rs index 000000000,000000000..15d4cd20e new file mode 100644 --- /dev/null +++ b/vendor/atty-0.2.3/src/lib.rs @@@ -1,0 -1,0 +1,202 @@@ ++//! atty is a simple utility that answers one question ++//! > is this a tty? ++//! ++//! usage is just as simple ++//! ++//! ``` ++//! if atty::is(atty::Stream::Stdout) { ++//! println!("i'm a tty") ++//! } ++//! ``` ++//! ++//! ``` ++//! if atty::isnt(atty::Stream::Stdout) { ++//! println!("i'm not a tty") ++//! } ++//! ``` ++ ++#![cfg_attr(unix, no_std)] ++ ++#[cfg(windows)] ++extern crate kernel32; ++#[cfg(unix)] ++extern crate libc; ++#[cfg(windows)] ++extern crate winapi; ++#[cfg(target_os = "redox")] ++extern crate termion; ++ ++#[cfg(windows)] ++use winapi::minwindef::DWORD; ++ ++/// possible stream sources ++#[derive(Clone, Copy, Debug)] ++pub enum Stream { ++ Stdout, ++ Stderr, ++ Stdin, ++} ++ ++/// returns true if this is a tty ++#[cfg(unix)] ++pub fn is(stream: Stream) -> bool { ++ extern crate libc; ++ ++ let fd = match stream { ++ Stream::Stdout => libc::STDOUT_FILENO, ++ Stream::Stderr => libc::STDERR_FILENO, ++ Stream::Stdin => libc::STDIN_FILENO, ++ }; ++ unsafe { libc::isatty(fd) != 0 } ++} ++ ++/// returns true if this is a tty ++#[cfg(windows)] ++pub fn is(stream: Stream) -> bool { ++ use winapi::{STD_ERROR_HANDLE as STD_ERROR, STD_INPUT_HANDLE as STD_INPUT, ++ STD_OUTPUT_HANDLE as STD_OUTPUT}; ++ ++ let (fd, others) = match stream { ++ Stream::Stdin => (STD_INPUT, [STD_ERROR, STD_OUTPUT]), ++ Stream::Stderr => (STD_ERROR, [STD_INPUT, STD_OUTPUT]), ++ Stream::Stdout => (STD_OUTPUT, [STD_INPUT, STD_ERROR]), ++ }; ++ if unsafe { console_on_any(&[fd]) } { ++ // False positives aren't possible. If we got a console then ++ // we definitely have a tty on stdin. ++ return true; ++ } ++ ++ // At this point, we *could* have a false negative. We can determine that ++ // this is true negative if we can detect the presence of a console on ++ // any of the other streams. If another stream has a console, then we know ++ // we're in a Windows console and can therefore trust the negative. ++ if unsafe { console_on_any(&others) } { ++ return false; ++ } ++ ++ // Otherwise, we fall back to a very strange msys hack to see if we can ++ // sneakily detect the presence of a tty. ++ unsafe { msys_tty_on(fd) } ++} ++ ++/// returns true if this is _not_ a tty ++pub fn isnt(stream: Stream) -> bool { ++ !is(stream) ++} ++ ++/// Returns true if any of the given fds are on a console. ++#[cfg(windows)] ++unsafe fn console_on_any(fds: &[DWORD]) -> bool { ++ for &fd in fds { ++ let mut out = 0; ++ let handle = kernel32::GetStdHandle(fd); ++ if kernel32::GetConsoleMode(handle, &mut out) != 0 { ++ return true; ++ } ++ } ++ false ++} ++ ++/// Returns true if there is an MSYS tty on the given handle. ++#[cfg(windows)] ++unsafe fn msys_tty_on(fd: DWORD) -> bool { ++ use std::ffi::OsString; ++ use std::mem; ++ use std::os::raw::c_void; ++ use std::os::windows::ffi::OsStringExt; ++ use std::slice; ++ ++ use kernel32::GetFileInformationByHandleEx; ++ use winapi::fileapi::FILE_NAME_INFO; ++ use winapi::minwinbase::FileNameInfo; ++ use winapi::minwindef::MAX_PATH; ++ ++ let size = mem::size_of::(); ++ let mut name_info_bytes = vec![0u8; size + MAX_PATH]; ++ let res = GetFileInformationByHandleEx( ++ kernel32::GetStdHandle(fd), ++ FileNameInfo, ++ &mut *name_info_bytes as *mut _ as *mut c_void, ++ name_info_bytes.len() as u32, ++ ); ++ if res == 0 { ++ return true; ++ } ++ let name_info: FILE_NAME_INFO = *(name_info_bytes[0..size].as_ptr() as ++ *const FILE_NAME_INFO); ++ let name_bytes = ++ &name_info_bytes[size..size + name_info.FileNameLength as usize]; ++ let name_u16 = slice::from_raw_parts( ++ name_bytes.as_ptr() as *const u16, ++ name_bytes.len() / 2, ++ ); ++ let name = OsString::from_wide(name_u16) ++ .as_os_str() ++ .to_string_lossy() ++ .into_owned(); ++ name.contains("msys-") || name.contains("-pty") ++} ++ ++/// returns true if this is a tty ++#[cfg(target_os = "redox")] ++pub fn is(stream: Stream) -> bool { ++ use std::io; ++ use termion::is_tty; ++ ++ match stream { ++ Stream::Stdin => is_tty(&io::stdin()), ++ Stream::Stdout => is_tty(&io::stdout()), ++ Stream::Stderr => is_tty(&io::stderr()), ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use super::{Stream, is}; ++ ++ #[test] ++ #[cfg(windows)] ++ fn is_err() { ++ // appveyor pipes its output ++ assert!(!is(Stream::Stderr)) ++ } ++ ++ #[test] ++ #[cfg(windows)] ++ fn is_out() { ++ // appveyor pipes its output ++ assert!(!is(Stream::Stdout)) ++ } ++ ++ #[test] ++ #[cfg(windows)] ++ fn is_in() { ++ assert!(is(Stream::Stdin)) ++ } ++ ++ #[test] ++ #[cfg(unix)] ++ fn is_err() { ++ assert!(is(Stream::Stderr)) ++ } ++ ++ #[test] ++ #[cfg(unix)] ++ fn is_out() { ++ assert!(is(Stream::Stdout)) ++ } ++ ++ #[test] ++ #[cfg(target_os = "macos")] ++ fn is_in() { ++ // macos on travis seems to pipe its input ++ assert!(is(Stream::Stdin)) ++ } ++ ++ #[test] ++ #[cfg(all(not(target_os = "macos"), unix))] ++ fn is_in() { ++ assert!(is(Stream::Stdin)) ++ } ++} diff --cc vendor/backtrace-0.3.3/.cargo-checksum.json index 000000000,000000000..cddf9fb27 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"99f2ce94e22b8e664d95c57fff45b98a966c2252b60691d0b7aeeccd88d70983"} diff --cc vendor/backtrace-0.3.3/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/.cargo-ok diff --cc vendor/backtrace-0.3.3/.travis.yml index 000000000,000000000..a5a769d24 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/.travis.yml @@@ -1,0 -1,0 +1,61 @@@ ++language: rust ++ ++rust: ++ - stable ++ - beta ++ - nightly ++ ++sudo: false ++ ++dist: trusty ++ ++addons: ++ sources: ++ # Provides clang-3.9 ++ - llvm-toolchain-trusty-3.9 ++ apt: ++ packages: ++ # Required for `bindgen`, which is required by `findshlibs`, which is ++ # required by the `gimli` feature. ++ - clang-3.9 ++ ++before_script: ++ - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH ++ - export LIBCLANG_PATH=/usr/lib/llvm-3.9/lib ++ ++script: ++ - cargo test ++ - cargo test --no-default-features ++ - cargo test --no-default-features --features 'libunwind' ++ - cargo test --no-default-features --features 'libunwind dladdr' ++ - cargo test --no-default-features --features 'libunwind libbacktrace' ++ - cargo test --no-default-features --features 'unix-backtrace' ++ - cargo test --no-default-features --features 'unix-backtrace dladdr' ++ - cargo test --no-default-features --features 'unix-backtrace libbacktrace' ++ - cargo test --no-default-features --features 'serialize-serde' ++ - cargo test --no-default-features --features 'serialize-rustc' ++ - cargo test --no-default-features --features 'serialize-rustc serialize-serde' ++ - cargo test --no-default-features --features 'cpp_demangle' ++ - cargo test --no-default-features --features 'gimli-symbolize' ++ - cd ./cpp_smoke_test && cargo test && cd .. ++ - cargo clean && cargo build ++ - rustdoc --test README.md -L target/debug/deps -L target/debug ++ - cargo doc --no-deps ++ ++notifications: ++ email: ++ on_success: never ++ ++after_success: ++ - travis-cargo --only nightly doc-upload ++ ++env: ++ global: ++ # serde-codegen has historically needed a large stack to expand ++ - RUST_MIN_STACK=16777216 ++ - secure: "Kuf3j6gC3MhR+F7g8/5J4+3tu+FXJP/SqKjsUVVjs/qjniIVX3MwZPhtP/pVtdRvYjW0NzLw5Nufb4o1cyY4uKwR8BHHNuEUE/h3mPShjWHqzLyn5QiBumPozsFCa32H4gconRmp3+s0YrBT7nLoGvUZZS0dkldMkpvvrPL/yUKXLS8HEP4L1GO5iMQQYG6i3sbWTbHikE6ZQogW/iZommyqUkVB/s/SQvdH9SXu89ttNXlm/F+EIsgsgyzpbULp5sD34GRDPJe+H1m+sgA1kTRrzmuBGNmz9mx6GyIKaqACTm1gRcb06nFjTPVTQioJBNnoV7TEqZCvjuSsUjcGmP4Aeissafo93ADzV+bd0uoWIScE9ltSVS+RgCDV+sd0GHz5U6FjhgZp0amaVl3d6hPp8lbTfK/gfj1i9ktQfKZbG7rB4tfIU1KeQRkyE9vb/TaKp8nwBbc4SVQ4EKFOlRbE1S1FooaKZweW8w57d2u+sMMMVJbO28/Ap8tk9xDSOl4shPaT0iM0U9/heF8FmCZB1OKXLKn6TAaNFnaMTvdTHl+Tjrf6Vzd/oPXJ7GuaB6eLxXYjXvZHuKiLkSZriOzhL7PbijNILbSgZt7+Fa0vcnXP8zgD4dmupx/CoIHLN9NP4o9cGXuBcaJ/iFryJ4i5LKGFNEUHtXkavDrcgcA=" ++ ++ ++os: ++ - linux ++ - osx diff --cc vendor/backtrace-0.3.3/Cargo.toml index 000000000,000000000..63d14fefd new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/Cargo.toml @@@ -1,0 -1,0 +1,81 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "backtrace" ++version = "0.3.3" ++authors = ["Alex Crichton ", "The Rust Project Developers"] ++description = "A library to acquire a stack trace (backtrace) at runtime in a Rust program.\n" ++homepage = "https://github.com/alexcrichton/backtrace-rs" ++documentation = "http://alexcrichton.com/backtrace-rs" ++readme = "README.md" ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/backtrace-rs" ++[dependencies.cpp_demangle] ++version = "0.2.3" ++optional = true ++default-features = false ++ ++[dependencies.serde_derive] ++version = "1.0" ++optional = true ++ ++[dependencies.serde] ++version = "1.0" ++optional = true ++ ++[dependencies.rustc-demangle] ++version = "0.1.4" ++ ++[dependencies.cfg-if] ++version = "0.1" ++ ++[dependencies.findshlibs] ++version = "0.3.3" ++optional = true ++ ++[dependencies.rustc-serialize] ++version = "0.3" ++optional = true ++ ++[dependencies.addr2line] ++version = "0.5.0" ++optional = true ++ ++[features] ++gimli-symbolize = ["addr2line", "findshlibs"] ++coresymbolication = [] ++dladdr = [] ++kernel32 = [] ++unix-backtrace = [] ++dbghelp = ["kernel32-sys", "winapi", "dbghelp-sys"] ++default = ["libunwind", "libbacktrace", "coresymbolication", "dladdr", "dbghelp"] ++libunwind = [] ++serialize-rustc = ["rustc-serialize"] ++libbacktrace = ["backtrace-sys"] ++serialize-serde = ["serde", "serde_derive"] ++[target."cfg(windows)".dependencies.dbghelp-sys] ++version = "0.2" ++optional = true ++ ++[target."cfg(windows)".dependencies.winapi] ++version = "0.2.5" ++optional = true ++ ++[target."cfg(windows)".dependencies.kernel32-sys] ++version = "0.2" ++optional = true ++[target."cfg(all(unix, not(target_os = \"emscripten\"), not(target_os = \"macos\"), not(target_os = \"ios\")))".dependencies.backtrace-sys] ++version = "0.1.3" ++optional = true ++[target."cfg(unix)".dependencies.libc] ++version = "0.2" diff --cc vendor/backtrace-0.3.3/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/backtrace-0.3.3/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/backtrace-0.3.3/README.md index 000000000,000000000..1c96cd232 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/README.md @@@ -1,0 -1,0 +1,82 @@@ ++# backtrace-rs ++ ++[![Build Status](https://travis-ci.org/alexcrichton/backtrace-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/backtrace-rs) ++[![Build status](https://ci.appveyor.com/api/projects/status/v4l9oj4aqbbgyx44?svg=true)](https://ci.appveyor.com/project/alexcrichton/backtrace-rs) ++ ++[Documentation](http://alexcrichton.com/backtrace-rs) ++ ++A library for acquiring backtraces at runtime for Rust. This library aims to ++enhance the support given by the standard library at `std::rt` by providing a ++more stable and programmatic interface. ++ ++## Install ++ ++```toml ++[dependencies] ++backtrace = "0.3" ++``` ++ ++```rust ++extern crate backtrace; ++``` ++ ++Note that this crate requires `make`, `objcopy`, and `ar` to be present on Linux ++systems. ++ ++## Usage ++ ++To simply capture a backtrace and defer dealing with it until a later time, ++you can use the top-level `Backtrace` type. ++ ++```rust ++extern crate backtrace; ++ ++use backtrace::Backtrace; ++ ++fn main() { ++ let bt = Backtrace::new(); ++ ++ // do_some_work(); ++ ++ println!("{:?}", bt); ++} ++``` ++ ++If, however, you'd like more raw access to the actual tracing functionality, you ++can use the `trace` and `resolve` functions directly. ++ ++```rust ++extern crate backtrace; ++ ++fn main() { ++ backtrace::trace(|frame| { ++ let ip = frame.ip(); ++ let symbol_address = frame.symbol_address(); ++ ++ // Resolve this instruction pointer to a symbol name ++ backtrace::resolve(ip, |symbol| { ++ if let Some(name) = symbol.name() { ++ // ... ++ } ++ if let Some(filename) = symbol.filename() { ++ // ... ++ } ++ }); ++ ++ true // keep going to the next frame ++ }); ++} ++``` ++ ++## Platform Support ++ ++This library currently supports OSX, Linux, and Windows. Support for other ++platforms is always welcome! ++ ++## License ++ ++`backtrace-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 --cc vendor/backtrace-0.3.3/appveyor.yml index 000000000,000000000..43b83c769 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/appveyor.yml @@@ -1,0 -1,0 +1,20 @@@ ++environment: ++ matrix: ++ - TARGET: x86_64-pc-windows-gnu ++ MSYS_BITS: 64 ++ - TARGET: i686-pc-windows-gnu ++ MSYS_BITS: 32 ++ - TARGET: x86_64-pc-windows-msvc ++ - TARGET: i686-pc-windows-msvc ++install: ++ - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" ++ - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" ++ - set PATH=%PATH%;C:\Program Files (x86)\Rust\bin ++ - 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% diff --cc vendor/backtrace-0.3.3/examples/backtrace.rs index 000000000,000000000..7f9042ed7 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/examples/backtrace.rs @@@ -1,0 -1,0 +1,7 @@@ ++extern crate backtrace; ++ ++use backtrace::Backtrace; ++ ++fn main() { ++ println!("{:?}", Backtrace::new()); ++} diff --cc vendor/backtrace-0.3.3/examples/raw.rs index 000000000,000000000..40a6b120a new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/examples/raw.rs @@@ -1,0 -1,0 +1,48 @@@ ++extern crate backtrace; ++ ++fn main() { ++ foo(); ++} ++ ++fn foo() { bar() } ++fn bar() { baz() } ++fn baz() { print() } ++ ++#[cfg(target_pointer_width = "32")] const HEX_WIDTH: usize = 10; ++#[cfg(target_pointer_width = "64")] const HEX_WIDTH: usize = 20; ++ ++fn print() { ++ let mut cnt = 0; ++ backtrace::trace(|frame| { ++ let ip = frame.ip(); ++ print!("frame #{:<2} - {:#02$x}", cnt, ip as usize, HEX_WIDTH); ++ cnt += 1; ++ ++ let mut resolved = false; ++ backtrace::resolve(frame.ip(), |symbol| { ++ if !resolved { ++ resolved = true; ++ } else { ++ print!("{}", vec![" "; 7 + 2 + 3 + HEX_WIDTH].join("")); ++ } ++ ++ if let Some(name) = symbol.name() { ++ print!(" - {}", name); ++ } else { ++ print!(" - "); ++ } ++ if let Some(file) = symbol.filename() { ++ if let Some(l) = symbol.lineno() { ++ print!("\n{:13}{:4$}@ {}:{}", "", "", file.display(), l, ++ HEX_WIDTH); ++ } ++ } ++ println!(""); ++ ++ }); ++ if !resolved { ++ println!(" - "); ++ } ++ true // keep going ++ }); ++} diff --cc vendor/backtrace-0.3.3/src/backtrace/dbghelp.rs index 000000000,000000000..991207f21 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/backtrace/dbghelp.rs @@@ -1,0 -1,0 +1,99 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++#![allow(bad_style)] ++ ++use std::mem; ++use winapi::*; ++use kernel32; ++ ++pub struct Frame { ++ inner: STACKFRAME64, ++} ++ ++impl Frame { ++ pub fn ip(&self) -> *mut c_void { ++ self.inner.AddrPC.Offset as *mut _ ++ } ++ ++ pub fn symbol_address(&self) -> *mut c_void { ++ self.ip() ++ } ++} ++ ++#[inline(always)] ++pub fn trace(cb: &mut FnMut(&super::Frame) -> bool) { ++ // According to windows documentation, all dbghelp functions are ++ // single-threaded. ++ let _g = ::lock::lock(); ++ ++ unsafe { ++ // Allocate necessary structures for doing the stack walk ++ let process = kernel32::GetCurrentProcess(); ++ let thread = kernel32::GetCurrentThread(); ++ ++ // The CONTEXT structure needs to be aligned on a 16-byte boundary for ++ // 64-bit Windows, but currently we don't have a way to express that in ++ // Rust. Allocations are generally aligned to 16-bytes, though, so we ++ // box this up. ++ let mut context = Box::new(mem::zeroed::()); ++ kernel32::RtlCaptureContext(&mut *context); ++ let mut frame = super::Frame { ++ inner: Frame { inner: mem::zeroed() }, ++ }; ++ let image = init_frame(&mut frame.inner.inner, &context); ++ ++ // Initialize this process's symbols ++ let _c = ::dbghelp_init(); ++ ++ // And now that we're done with all the setup, do the stack walking! ++ while ::dbghelp::StackWalk64(image as DWORD, ++ process, ++ thread, ++ &mut frame.inner.inner, ++ &mut *context as *mut _ as *mut _, ++ None, ++ Some(::dbghelp::SymFunctionTableAccess64), ++ Some(::dbghelp::SymGetModuleBase64), ++ None) == TRUE { ++ if frame.inner.inner.AddrPC.Offset == frame.inner.inner.AddrReturn.Offset || ++ frame.inner.inner.AddrPC.Offset == 0 || ++ frame.inner.inner.AddrReturn.Offset == 0 { ++ break ++ } ++ ++ if !cb(&frame) { ++ break ++ } ++ } ++ } ++} ++ ++#[cfg(target_arch = "x86_64")] ++fn init_frame(frame: &mut STACKFRAME64, ctx: &CONTEXT) -> WORD { ++ frame.AddrPC.Offset = ctx.Rip as u64; ++ frame.AddrPC.Mode = AddrModeFlat; ++ frame.AddrStack.Offset = ctx.Rsp as u64; ++ frame.AddrStack.Mode = AddrModeFlat; ++ frame.AddrFrame.Offset = ctx.Rbp as u64; ++ frame.AddrFrame.Mode = AddrModeFlat; ++ IMAGE_FILE_MACHINE_AMD64 ++} ++ ++#[cfg(target_arch = "x86")] ++fn init_frame(frame: &mut STACKFRAME64, ctx: &CONTEXT) -> WORD { ++ frame.AddrPC.Offset = ctx.Eip as u64; ++ frame.AddrPC.Mode = AddrModeFlat; ++ frame.AddrStack.Offset = ctx.Esp as u64; ++ frame.AddrStack.Mode = AddrModeFlat; ++ frame.AddrFrame.Offset = ctx.Ebp as u64; ++ frame.AddrFrame.Mode = AddrModeFlat; ++ IMAGE_FILE_MACHINE_I386 ++} diff --cc vendor/backtrace-0.3.3/src/backtrace/libunwind.rs index 000000000,000000000..4d7aef248 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/backtrace/libunwind.rs @@@ -1,0 -1,0 +1,200 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::os::raw::c_void; ++ ++pub struct Frame { ++ ctx: *mut uw::_Unwind_Context, ++} ++ ++impl Frame { ++ pub fn ip(&self) -> *mut c_void { ++ let mut ip_before_insn = 0; ++ let mut ip = unsafe { ++ uw::_Unwind_GetIPInfo(self.ctx, &mut ip_before_insn) as *mut c_void ++ }; ++ if !ip.is_null() && ip_before_insn == 0 { ++ // this is a non-signaling frame, so `ip` refers to the address ++ // after the calling instruction. account for that. ++ ip = (ip as usize - 1) as *mut _; ++ } ++ return ip ++ } ++ ++ pub fn symbol_address(&self) -> *mut c_void { ++ // dladdr() on osx gets whiny when we use FindEnclosingFunction, and ++ // it appears to work fine without it, so we only use ++ // FindEnclosingFunction on non-osx platforms. In doing so, we get a ++ // slightly more accurate stack trace in the process. ++ // ++ // This is often because panic involves the last instruction of a ++ // function being "call std::rt::begin_unwind", with no ret ++ // instructions after it. This means that the return instruction ++ // pointer points *outside* of the calling function, and by ++ // unwinding it we go back to the original function. ++ if cfg!(target_os = "macos") || cfg!(target_os = "ios") { ++ self.ip() ++ } else { ++ unsafe { uw::_Unwind_FindEnclosingFunction(self.ip()) } ++ } ++ } ++} ++ ++#[inline(always)] ++pub fn trace(mut cb: &mut FnMut(&super::Frame) -> bool) { ++ unsafe { ++ uw::_Unwind_Backtrace(trace_fn, &mut cb as *mut _ as *mut _); ++ } ++ ++ extern fn trace_fn(ctx: *mut uw::_Unwind_Context, ++ arg: *mut c_void) -> uw::_Unwind_Reason_Code { ++ let cb = unsafe { &mut *(arg as *mut &mut FnMut(&super::Frame) -> bool) }; ++ let cx = super::Frame { ++ inner: Frame { ctx: ctx }, ++ }; ++ ++ let mut bomb = ::Bomb { enabled: true }; ++ let keep_going = cb(&cx); ++ bomb.enabled = false; ++ ++ if keep_going { ++ uw::_URC_NO_REASON ++ } else { ++ uw::_URC_FAILURE ++ } ++ } ++} ++ ++/// Unwind library interface used for backtraces ++/// ++/// Note that dead code is allowed as here are just bindings ++/// iOS doesn't use all of them it but adding more ++/// platform-specific configs pollutes the code too much ++#[allow(non_camel_case_types)] ++#[allow(non_snake_case)] ++#[allow(dead_code)] ++mod uw { ++ pub use self::_Unwind_Reason_Code::*; ++ ++ use libc; ++ use std::os::raw::{c_int, c_void}; ++ ++ #[repr(C)] ++ pub enum _Unwind_Reason_Code { ++ _URC_NO_REASON = 0, ++ _URC_FOREIGN_EXCEPTION_CAUGHT = 1, ++ _URC_FATAL_PHASE2_ERROR = 2, ++ _URC_FATAL_PHASE1_ERROR = 3, ++ _URC_NORMAL_STOP = 4, ++ _URC_END_OF_STACK = 5, ++ _URC_HANDLER_FOUND = 6, ++ _URC_INSTALL_CONTEXT = 7, ++ _URC_CONTINUE_UNWIND = 8, ++ _URC_FAILURE = 9, // used only by ARM EABI ++ } ++ ++ pub enum _Unwind_Context {} ++ ++ pub type _Unwind_Trace_Fn = ++ extern fn(ctx: *mut _Unwind_Context, ++ arg: *mut c_void) -> _Unwind_Reason_Code; ++ ++ extern { ++ // No native _Unwind_Backtrace on iOS ++ #[cfg(not(all(target_os = "ios", target_arch = "arm")))] ++ pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn, ++ trace_argument: *mut c_void) ++ -> _Unwind_Reason_Code; ++ ++ // available since GCC 4.2.0, should be fine for our purpose ++ #[cfg(all(not(all(target_os = "android", target_arch = "arm")), ++ not(all(target_os = "linux", target_arch = "arm"))))] ++ pub fn _Unwind_GetIPInfo(ctx: *mut _Unwind_Context, ++ ip_before_insn: *mut c_int) ++ -> libc::uintptr_t; ++ ++ #[cfg(all(not(target_os = "android"), ++ not(all(target_os = "linux", target_arch = "arm"))))] ++ pub fn _Unwind_FindEnclosingFunction(pc: *mut c_void) ++ -> *mut c_void; ++ } ++ ++ // On android, the function _Unwind_GetIP is a macro, and this is the ++ // expansion of the macro. This is all copy/pasted directly from the ++ // header file with the definition of _Unwind_GetIP. ++ #[cfg(any(all(target_os = "android", target_arch = "arm"), ++ all(target_os = "linux", target_arch = "arm")))] ++ pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> libc::uintptr_t { ++ #[repr(C)] ++ enum _Unwind_VRS_Result { ++ _UVRSR_OK = 0, ++ _UVRSR_NOT_IMPLEMENTED = 1, ++ _UVRSR_FAILED = 2, ++ } ++ #[repr(C)] ++ enum _Unwind_VRS_RegClass { ++ _UVRSC_CORE = 0, ++ _UVRSC_VFP = 1, ++ _UVRSC_FPA = 2, ++ _UVRSC_WMMXD = 3, ++ _UVRSC_WMMXC = 4, ++ } ++ #[repr(C)] ++ enum _Unwind_VRS_DataRepresentation { ++ _UVRSD_UINT32 = 0, ++ _UVRSD_VFPX = 1, ++ _UVRSD_FPAX = 2, ++ _UVRSD_UINT64 = 3, ++ _UVRSD_FLOAT = 4, ++ _UVRSD_DOUBLE = 5, ++ } ++ ++ type _Unwind_Word = libc::c_uint; ++ extern { ++ fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context, ++ klass: _Unwind_VRS_RegClass, ++ word: _Unwind_Word, ++ repr: _Unwind_VRS_DataRepresentation, ++ data: *mut c_void) ++ -> _Unwind_VRS_Result; ++ } ++ ++ let mut val: _Unwind_Word = 0; ++ let ptr = &mut val as *mut _Unwind_Word; ++ let _ = _Unwind_VRS_Get(ctx, _Unwind_VRS_RegClass::_UVRSC_CORE, 15, ++ _Unwind_VRS_DataRepresentation::_UVRSD_UINT32, ++ ptr as *mut c_void); ++ (val & !1) as libc::uintptr_t ++ } ++ ++ // This function doesn't exist on Android or ARM/Linux, so make it same ++ // to _Unwind_GetIP ++ #[cfg(any(all(target_os = "android", target_arch = "arm"), ++ all(target_os = "linux", target_arch = "arm")))] ++ pub unsafe fn _Unwind_GetIPInfo(ctx: *mut _Unwind_Context, ++ ip_before_insn: *mut c_int) ++ -> libc::uintptr_t ++ { ++ *ip_before_insn = 0; ++ _Unwind_GetIP(ctx) ++ } ++ ++ // This function also doesn't exist on Android or ARM/Linux, so make it ++ // a no-op ++ #[cfg(any(target_os = "android", ++ all(target_os = "linux", target_arch = "arm")))] ++ pub unsafe fn _Unwind_FindEnclosingFunction(pc: *mut c_void) ++ -> *mut c_void ++ { ++ pc ++ } ++} ++ ++ diff --cc vendor/backtrace-0.3.3/src/backtrace/mod.rs index 000000000,000000000..53fe5b416 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/backtrace/mod.rs @@@ -1,0 -1,0 +1,113 @@@ ++use std::fmt; ++ ++use std::os::raw::c_void; ++ ++/// Inspects the current call-stack, passing all active frames into the closure ++/// provided to calculate a stack trace. ++/// ++/// This function is the workhorse of this library in calculating the stack ++/// traces for a program. The given closure `cb` is yielded instances of a ++/// `Frame` which represent information about that call frame on the stack. The ++/// closure is yielded frames in a top-down fashion (most recently called ++/// functions first). ++/// ++/// The closure's return value is an indication of whether the backtrace should ++/// continue. A return value of `false` will terminate the backtrace and return ++/// immediately. ++/// ++/// Once a `Frame` is acquired you will likely want to call `backtrace::resolve` ++/// to convert the `ip` (instruction pointer) or symbol address to a `Symbol` ++/// through which the name and/or filename/line number can be learned. ++/// ++/// Note that this is a relatively low-level function and if you'd like to, for ++/// example, capture a backtrace to be inspected later, then the `Backtrace` ++/// type may be more appropriate. ++/// ++/// # Example ++/// ++/// ``` ++/// extern crate backtrace; ++/// ++/// fn main() { ++/// backtrace::trace(|frame| { ++/// // ... ++/// ++/// true // continue the backtrace ++/// }); ++/// } ++/// ``` ++#[inline(never)] // if this is never inlined then the first frame can be known ++ // to be skipped ++pub fn trace bool>(mut cb: F) { ++ trace_imp(&mut cb) ++} ++ ++/// A trait representing one frame of a backtrace, yielded to the `trace` ++/// function of this crate. ++/// ++/// The tracing function's closure will be yielded frames, and the frame is ++/// virtually dispatched as the underlying implementation is not always known ++/// until runtime. ++pub struct Frame { ++ inner: FrameImp, ++} ++ ++impl Frame { ++ /// Returns the current instruction pointer of this frame. ++ /// ++ /// This is normally the next instruction to execute in the frame, but not ++ /// all implementations list this with 100% accuracy (but it's generally ++ /// pretty close). ++ /// ++ /// It is recommended to pass this value to `backtrace::resolve` to turn it ++ /// into a symbol name. ++ pub fn ip(&self) -> *mut c_void { ++ self.inner.ip() ++ } ++ ++ /// Returns the starting symbol address of the frame of this function. ++ /// ++ /// This will attempt to rewind the instruction pointer returned by `ip` to ++ /// the start of the function, returning that value. In some cases, however, ++ /// backends will just return `ip` from this function. ++ /// ++ /// The returned value can sometimes be used if `backtrace::resolve` failed ++ /// on the `ip` given above. ++ pub fn symbol_address(&self) -> *mut c_void { ++ self.inner.symbol_address() ++ } ++} ++ ++impl fmt::Debug for Frame { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ f.debug_struct("Frame") ++ .field("ip", &self.ip()) ++ .field("symbol_address", &self.symbol_address()) ++ .finish() ++ } ++} ++ ++cfg_if! { ++ if #[cfg(all(unix, ++ not(target_os = "emscripten"), ++ not(all(target_os = "ios", target_arch = "arm")), ++ feature = "libunwind"))] { ++ mod libunwind; ++ use self::libunwind::trace as trace_imp; ++ use self::libunwind::Frame as FrameImp; ++ } else if #[cfg(all(unix, ++ not(target_os = "emscripten"), ++ feature = "unix-backtrace"))] { ++ mod unix_backtrace; ++ use self::unix_backtrace::trace as trace_imp; ++ use self::unix_backtrace::Frame as FrameImp; ++ } else if #[cfg(all(windows, feature = "dbghelp"))] { ++ mod dbghelp; ++ use self::dbghelp::trace as trace_imp; ++ use self::dbghelp::Frame as FrameImp; ++ } else { ++ mod noop; ++ use self::noop::trace as trace_imp; ++ use self::noop::Frame as FrameImp; ++ } ++} diff --cc vendor/backtrace-0.3.3/src/backtrace/noop.rs index 000000000,000000000..8b8f8766e new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/backtrace/noop.rs @@@ -1,0 -1,0 +1,16 @@@ ++use std::os::raw::c_void; ++ ++#[inline(always)] ++pub fn trace(_cb: &mut FnMut(&super::Frame) -> bool) {} ++ ++pub struct Frame; ++ ++impl Frame { ++ pub fn ip(&self) -> *mut c_void { ++ 0 as *mut _ ++ } ++ ++ pub fn symbol_address(&self) -> *mut c_void { ++ 0 as *mut _ ++ } ++} diff --cc vendor/backtrace-0.3.3/src/backtrace/unix_backtrace.rs index 000000000,000000000..061bba9ef new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/backtrace/unix_backtrace.rs @@@ -1,0 -1,0 +1,46 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::mem; ++use std::os::raw::{c_void, c_int}; ++ ++pub struct Frame { ++ addr: *mut c_void, ++} ++ ++impl Frame { ++ pub fn ip(&self) -> *mut c_void { self.addr } ++ pub fn symbol_address(&self) -> *mut c_void { self.addr } ++} ++ ++extern { ++ fn backtrace(buf: *mut *mut c_void, sz: c_int) -> c_int; ++} ++ ++#[inline(always)] ++pub fn trace(cb: &mut FnMut(&super::Frame) -> bool) { ++ const SIZE: usize = 100; ++ ++ let mut buf: [*mut c_void; SIZE]; ++ let cnt; ++ unsafe { ++ buf = mem::zeroed(); ++ cnt = backtrace(buf.as_mut_ptr(), SIZE as c_int); ++ } ++ ++ for addr in buf[..cnt as usize].iter() { ++ let cx = super::Frame { ++ inner: Frame { addr: *addr }, ++ }; ++ if !cb(&cx) { ++ return ++ } ++ } ++} diff --cc vendor/backtrace-0.3.3/src/capture.rs index 000000000,000000000..570b117b0 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/capture.rs @@@ -1,0 -1,0 +1,237 @@@ ++use std::fmt; ++use std::mem; ++use std::os::raw::c_void; ++use std::path::{Path, PathBuf}; ++ ++use {trace, resolve, SymbolName}; ++ ++/// Representation of an owned and self-contained backtrace. ++/// ++/// This structure can be used to capture a backtrace at various points in a ++/// program and later used to inspect what the backtrace was at that time. ++#[derive(Clone)] ++#[cfg_attr(feature = "serialize-rustc", derive(RustcDecodable, RustcEncodable))] ++#[cfg_attr(feature = "serialize-serde", derive(Deserialize, Serialize))] ++pub struct Backtrace { ++ frames: Vec, ++} ++ ++/// Captured version of a frame in a backtrace. ++/// ++/// This type is returned as a list from `Backtrace::frames` and represents one ++/// stack frame in a captured backtrace. ++#[derive(Clone)] ++#[cfg_attr(feature = "serialize-rustc", derive(RustcDecodable, RustcEncodable))] ++#[cfg_attr(feature = "serialize-serde", derive(Deserialize, Serialize))] ++pub struct BacktraceFrame { ++ ip: usize, ++ symbol_address: usize, ++ symbols: Option>, ++} ++ ++/// Captured version of a symbol in a backtrace. ++/// ++/// This type is returned as a list from `BacktraceFrame::symbols` and ++/// represents the metadata for a symbol in a backtrace. ++#[derive(Clone)] ++#[cfg_attr(feature = "serialize-rustc", derive(RustcDecodable, RustcEncodable))] ++#[cfg_attr(feature = "serialize-serde", derive(Deserialize, Serialize))] ++pub struct BacktraceSymbol { ++ name: Option>, ++ addr: Option, ++ filename: Option, ++ lineno: Option, ++} ++ ++impl Backtrace { ++ /// Captures a backtrace at the callsite of this function, returning an ++ /// owned representation. ++ /// ++ /// This function is useful for representing a backtrace as an object in ++ /// Rust. This returned value can be sent across threads and printed ++ /// elsewhere, and the purpose of this value is to be entirely self ++ /// contained. ++ /// ++ /// # Examples ++ /// ++ /// ``` ++ /// use backtrace::Backtrace; ++ /// ++ /// let current_backtrace = Backtrace::new(); ++ /// ``` ++ pub fn new() -> Backtrace { ++ let mut bt = Backtrace::new_unresolved(); ++ bt.resolve(); ++ return bt ++ } ++ ++ /// Similar to `new` except that this does not resolve any symbols, this ++ /// simply captures the backtrace as a list of addresses. ++ /// ++ /// At a later time the `resolve` function can be called to resolve this ++ /// backtrace's symbols into readable names. This function exists because ++ /// the resolution process can sometimes take a significant amount of time ++ /// whereas any one backtrace may only be rarely printed. ++ /// ++ /// # Examples ++ /// ++ /// ``` ++ /// use backtrace::Backtrace; ++ /// ++ /// let mut current_backtrace = Backtrace::new_unresolved(); ++ /// println!("{:?}", current_backtrace); // no symbol names ++ /// current_backtrace.resolve(); ++ /// println!("{:?}", current_backtrace); // symbol names now present ++ /// ``` ++ pub fn new_unresolved() -> Backtrace { ++ let mut frames = Vec::new(); ++ trace(|frame| { ++ frames.push(BacktraceFrame { ++ ip: frame.ip() as usize, ++ symbol_address: frame.symbol_address() as usize, ++ symbols: None, ++ }); ++ true ++ }); ++ ++ Backtrace { frames: frames } ++ } ++ ++ /// Returns the frames from when this backtrace was captured. ++ /// ++ /// The first entry of this slice is likely the function `Backtrace::new`, ++ /// and the last frame is likely something about how this thread or the main ++ /// function started. ++ pub fn frames(&self) -> &[BacktraceFrame] { ++ &self.frames ++ } ++ ++ /// If this backtrace was created from `new_unresolved` then this function ++ /// will resolve all addresses in the backtrace to their symbolic names. ++ /// ++ /// If this backtrace has been previously resolved or was created through ++ /// `new`, this function does nothing. ++ pub fn resolve(&mut self) { ++ for frame in self.frames.iter_mut().filter(|f| f.symbols.is_none()) { ++ let mut symbols = Vec::new(); ++ resolve(frame.ip as *mut _, |symbol| { ++ symbols.push(BacktraceSymbol { ++ name: symbol.name().map(|m| m.as_bytes().to_vec()), ++ addr: symbol.addr().map(|a| a as usize), ++ filename: symbol.filename().map(|m| m.to_path_buf()), ++ lineno: symbol.lineno(), ++ }); ++ }); ++ frame.symbols = Some(symbols); ++ } ++ } ++} ++ ++impl From> for Backtrace { ++ fn from(frames: Vec) -> Self { ++ Backtrace { ++ frames: frames ++ } ++ } ++} ++ ++impl Into> for Backtrace { ++ fn into(self) -> Vec { ++ self.frames ++ } ++} ++ ++impl BacktraceFrame { ++ /// Same as `Frame::ip` ++ pub fn ip(&self) -> *mut c_void { ++ self.ip as *mut c_void ++ } ++ ++ /// Same as `Frame::symbol_address` ++ pub fn symbol_address(&self) -> *mut c_void { ++ self.symbol_address as *mut c_void ++ } ++ ++ /// Returns the list of symbols that this frame corresponds to. ++ /// ++ /// Normally there is only one symbol per frame, but sometimes if a number ++ /// of functions are inlined into one frame then multiple symbols will be ++ /// returned. The first symbol listed is the "innermost function", whereas ++ /// the last symbol is the outermost (last caller). ++ /// ++ /// Note that if this frame came from an unresolved backtrace then this will ++ /// return an empty list. ++ pub fn symbols(&self) -> &[BacktraceSymbol] { ++ self.symbols.as_ref().map(|s| &s[..]).unwrap_or(&[]) ++ } ++} ++ ++impl BacktraceSymbol { ++ /// Same as `Symbol::name` ++ pub fn name(&self) -> Option { ++ self.name.as_ref().map(|s| SymbolName::new(s)) ++ } ++ ++ /// Same as `Symbol::addr` ++ pub fn addr(&self) -> Option<*mut c_void> { ++ self.addr.map(|s| s as *mut c_void) ++ } ++ ++ /// Same as `Symbol::filename` ++ pub fn filename(&self) -> Option<&Path> { ++ self.filename.as_ref().map(|p| &**p) ++ } ++ ++ /// Same as `Symbol::lineno` ++ pub fn lineno(&self) -> Option { ++ self.lineno ++ } ++} ++ ++impl fmt::Debug for Backtrace { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ let hex_width = mem::size_of::() * 2 + 2; ++ ++ try!(write!(fmt, "stack backtrace:")); ++ ++ for (idx, frame) in self.frames().iter().enumerate() { ++ let ip = frame.ip(); ++ try!(write!(fmt, "\n{:4}: {:2$?}", idx, ip, hex_width)); ++ ++ let symbols = match frame.symbols { ++ Some(ref s) => s, ++ None => { ++ try!(write!(fmt, " - ")); ++ continue ++ } ++ }; ++ if symbols.len() == 0 { ++ try!(write!(fmt, " - ")); ++ } ++ ++ for (idx, symbol) in symbols.iter().enumerate() { ++ if idx != 0 { ++ try!(write!(fmt, "\n {:1$}", "", hex_width)); ++ } ++ ++ if let Some(name) = symbol.name() { ++ try!(write!(fmt, " - {}", name)); ++ } else { ++ try!(write!(fmt, " - ")); ++ } ++ ++ if let (Some(file), Some(line)) = (symbol.filename(), symbol.lineno()) { ++ try!(write!(fmt, "\n {:3$}at {}:{}", "", file.display(), line, hex_width)); ++ } ++ } ++ } ++ ++ Ok(()) ++ } ++} ++ ++impl Default for Backtrace { ++ fn default() -> Backtrace { ++ Backtrace::new() ++ } ++} diff --cc vendor/backtrace-0.3.3/src/dylib.rs index 000000000,000000000..34fb0bf16 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/dylib.rs @@@ -1,0 -1,0 +1,70 @@@ ++use std::ffi::CString; ++use std::marker; ++use std::mem; ++use std::sync::atomic::{AtomicUsize, Ordering}; ++ ++use libc::{self, c_char, c_void}; ++ ++pub struct Dylib { ++ pub init: AtomicUsize, ++} ++ ++pub struct Symbol { ++ pub name: &'static str, ++ pub addr: AtomicUsize, ++ pub _marker: marker::PhantomData, ++} ++ ++impl Dylib { ++ pub unsafe fn get<'a, T>(&self, sym: &'a Symbol) -> Option<&'a T> { ++ self.load().and_then(|handle| { ++ sym.get(handle) ++ }) ++ } ++ ++ pub unsafe fn init(&self, path: &str) -> bool { ++ if self.init.load(Ordering::SeqCst) != 0 { ++ return true ++ } ++ let name = CString::new(path).unwrap(); ++ let ptr = libc::dlopen(name.as_ptr() as *const c_char, libc::RTLD_LAZY); ++ if ptr.is_null() { ++ return false ++ } ++ match self.init.compare_and_swap(0, ptr as usize, Ordering::SeqCst) { ++ 0 => {} ++ _ => { libc::dlclose(ptr); } ++ } ++ return true ++ } ++ ++ unsafe fn load(&self) -> Option<*mut c_void> { ++ match self.init.load(Ordering::SeqCst) { ++ 0 => None, ++ n => Some(n as *mut c_void), ++ } ++ } ++} ++ ++impl Symbol { ++ unsafe fn get(&self, handle: *mut c_void) -> Option<&T> { ++ assert_eq!(mem::size_of::(), mem::size_of_val(&self.addr)); ++ if self.addr.load(Ordering::SeqCst) == 0 { ++ self.addr.store(fetch(handle, self.name.as_ptr()), Ordering::SeqCst) ++ } ++ if self.addr.load(Ordering::SeqCst) == 1 { ++ None ++ } else { ++ mem::transmute::<&AtomicUsize, Option<&T>>(&self.addr) ++ } ++ } ++} ++ ++unsafe fn fetch(handle: *mut c_void, name: *const u8) -> usize { ++ let ptr = libc::dlsym(handle, name as *const _); ++ if ptr.is_null() { ++ 1 ++ } else { ++ ptr as usize ++ } ++} diff --cc vendor/backtrace-0.3.3/src/lib.rs index 000000000,000000000..78e7700e2 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/lib.rs @@@ -1,0 -1,0 +1,176 @@@ ++//! A library for acquiring a backtrace at runtime ++//! ++//! This library is meant to supplement the `RUST_BACKTRACE=1` support of the ++//! standard library by allowing an acquisition of a backtrace at runtime ++//! programmatically. The backtraces generated by this library do not need to be ++//! parsed, for example, and expose the functionality of multiple backend ++//! implementations. ++//! ++//! # Implementation ++//! ++//! This library makes use of a number of strategies for actually acquiring a ++//! backtrace. For example unix uses libgcc's libunwind bindings by default to ++//! acquire a backtrace, but coresymbolication or dladdr is used on OSX to ++//! acquire symbol names while linux uses gcc's libbacktrace. ++//! ++//! When using the default feature set of this library the "most reasonable" set ++//! of defaults is chosen for the current platform, but the features activated ++//! can also be controlled at a finer granularity. ++//! ++//! # Platform Support ++//! ++//! Currently this library is verified to work on Linux, OSX, and Windows, but ++//! it may work on other platforms as well. Note that the quality of the ++//! backtrace may vary across platforms. ++//! ++//! # API Principles ++//! ++//! This library attempts to be as flexible as possible to accommodate different ++//! backend implementations of acquiring a backtrace. Consequently the currently ++//! exported functions are closure-based as opposed to the likely expected ++//! iterator-based versions. This is done due to limitations of the underlying ++//! APIs used from the system. ++//! ++//! # Usage ++//! ++//! First, add this to your Cargo.toml ++//! ++//! ```toml ++//! [dependencies] ++//! backtrace = "0.2" ++//! ``` ++//! ++//! Next: ++//! ++//! ``` ++//! extern crate backtrace; ++//! ++//! fn main() { ++//! backtrace::trace(|frame| { ++//! let ip = frame.ip(); ++//! let symbol_address = frame.symbol_address(); ++//! ++//! // Resolve this instruction pointer to a symbol name ++//! backtrace::resolve(ip, |symbol| { ++//! if let Some(name) = symbol.name() { ++//! // ... ++//! } ++//! if let Some(filename) = symbol.filename() { ++//! // ... ++//! } ++//! }); ++//! ++//! true // keep going to the next frame ++//! }); ++//! } ++//! ``` ++ ++#![doc(html_root_url = "http://alexcrichton.com/backtrace-rs")] ++#![deny(missing_docs)] ++#![deny(warnings)] ++ ++#[cfg(unix)] ++extern crate libc; ++#[cfg(all(windows, feature = "kernel32-sys"))] extern crate kernel32; ++#[cfg(all(windows, feature = "winapi"))] extern crate winapi; ++#[cfg(all(windows, feature = "dbghelp"))] extern crate dbghelp; ++ ++#[cfg(feature = "serde_derive")] ++#[cfg_attr(feature = "serde_derive", macro_use)] ++extern crate serde_derive; ++ ++#[cfg(feature = "rustc-serialize")] ++extern crate rustc_serialize; ++ ++#[macro_use] ++extern crate cfg_if; ++ ++extern crate rustc_demangle; ++ ++#[cfg(feature = "cpp_demangle")] ++extern crate cpp_demangle; ++ ++#[cfg(all(feature = "gimli-symbolize", ++ unix, ++ target_os = "linux"))] ++extern crate addr2line; ++#[cfg(all(feature = "gimli-symbolize", ++ unix, ++ target_os = "linux"))] ++extern crate findshlibs; ++ ++#[allow(dead_code)] // not used everywhere ++#[cfg(unix)] ++#[macro_use] ++mod dylib; ++ ++pub use backtrace::{trace, Frame}; ++mod backtrace; ++ ++pub use symbolize::{resolve, Symbol, SymbolName}; ++mod symbolize; ++ ++pub use capture::{Backtrace, BacktraceFrame, BacktraceSymbol}; ++mod capture; ++ ++#[allow(dead_code)] ++struct Bomb { ++ enabled: bool, ++} ++ ++#[allow(dead_code)] ++impl Drop for Bomb { ++ fn drop(&mut self) { ++ if self.enabled { ++ panic!("cannot panic during the backtrace function"); ++ } ++ } ++} ++ ++#[allow(dead_code)] ++mod lock { ++ use std::cell::Cell; ++ use std::mem; ++ use std::sync::{Once, Mutex, MutexGuard, ONCE_INIT}; ++ ++ pub struct LockGuard(MutexGuard<'static, ()>); ++ ++ static mut LOCK: *mut Mutex<()> = 0 as *mut _; ++ static INIT: Once = ONCE_INIT; ++ thread_local!(static LOCK_HELD: Cell = Cell::new(false)); ++ ++ impl Drop for LockGuard { ++ fn drop(&mut self) { ++ LOCK_HELD.with(|slot| { ++ assert!(slot.get()); ++ slot.set(false); ++ }); ++ } ++ } ++ ++ pub fn lock() -> Option { ++ if LOCK_HELD.with(|l| l.get()) { ++ return None ++ } ++ LOCK_HELD.with(|s| s.set(true)); ++ unsafe { ++ INIT.call_once(|| { ++ LOCK = mem::transmute(Box::new(Mutex::new(()))); ++ }); ++ Some(LockGuard((*LOCK).lock().unwrap())) ++ } ++ } ++} ++ ++// requires external synchronization ++#[cfg(all(windows, feature = "dbghelp"))] ++unsafe fn dbghelp_init() { ++ static mut INITIALIZED: bool = false; ++ ++ if !INITIALIZED { ++ dbghelp::SymInitializeW(kernel32::GetCurrentProcess(), ++ 0 as *mut _, ++ winapi::TRUE); ++ INITIALIZED = true; ++ } ++} diff --cc vendor/backtrace-0.3.3/src/symbolize/coresymbolication.rs index 000000000,000000000..d26835d7f new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/symbolize/coresymbolication.rs @@@ -1,0 -1,0 +1,192 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++#![allow(bad_style)] ++ ++use std::ffi::{CStr, OsStr}; ++use std::mem; ++use std::os::raw::{c_void, c_char, c_int}; ++use std::os::unix::prelude::*; ++use std::path::Path; ++use std::ptr; ++use std::sync::atomic::ATOMIC_USIZE_INIT; ++ ++use libc::{self, Dl_info}; ++ ++use SymbolName; ++use dylib::Dylib; ++use dylib::Symbol as DylibSymbol; ++ ++#[repr(C)] ++#[derive(Copy, Clone, PartialEq)] ++pub struct CSTypeRef { ++ cpp_data: *const c_void, ++ cpp_obj: *const c_void ++} ++ ++const CS_NOW: u64 = 0x80000000; ++const CSREF_NULL: CSTypeRef = CSTypeRef { ++ cpp_data: 0 as *const c_void, ++ cpp_obj: 0 as *const c_void, ++}; ++ ++pub enum Symbol { ++ Core { ++ path: *const c_char, ++ lineno: u32, ++ name: *const c_char, ++ addr: *mut c_void, ++ }, ++ Dladdr(Dl_info), ++} ++ ++impl Symbol { ++ pub fn name(&self) -> Option { ++ let name = match *self { ++ Symbol::Core { name, .. } => name, ++ Symbol::Dladdr(ref info) => info.dli_sname, ++ }; ++ if name.is_null() { ++ None ++ } else { ++ Some(SymbolName::new(unsafe { ++ CStr::from_ptr(name).to_bytes() ++ })) ++ } ++ } ++ ++ pub fn addr(&self) -> Option<*mut c_void> { ++ match *self { ++ Symbol::Core { addr, .. } => Some(addr), ++ Symbol::Dladdr(ref info) => Some(info.dli_saddr as *mut _), ++ } ++ } ++ ++ pub fn filename(&self) -> Option<&Path> { ++ match *self { ++ Symbol::Core { path, .. } => { ++ if path.is_null() { ++ None ++ } else { ++ Some(Path::new(OsStr::from_bytes(unsafe { ++ CStr::from_ptr(path).to_bytes() ++ }))) ++ } ++ } ++ Symbol::Dladdr(_) => None, ++ } ++ } ++ ++ pub fn lineno(&self) -> Option { ++ match *self { ++ Symbol::Core { lineno: 0, .. } => None, ++ Symbol::Core { lineno, .. } => Some(lineno), ++ Symbol::Dladdr(_) => None, ++ } ++ } ++} ++ ++static CORESYMBOLICATION: Dylib = Dylib { init: ATOMIC_USIZE_INIT }; ++ ++macro_rules! dlsym { ++ (extern { ++ $(fn $name:ident($($arg:ident: $t:ty),*) -> $ret:ty;)* ++ }) => ($( ++ static $name: ::dylib::Symbol $ret> = ++ ::dylib::Symbol { ++ name: concat!(stringify!($name), "\0"), ++ addr: ::std::sync::atomic::ATOMIC_USIZE_INIT, ++ _marker: ::std::marker::PhantomData, ++ }; ++ )*) ++} ++ ++dlsym! { ++ extern { ++ fn CSSymbolicatorCreateWithPid(pid: c_int) -> CSTypeRef; ++ fn CSRelease(rf: CSTypeRef) -> c_void; ++ fn CSSymbolicatorGetSymbolWithAddressAtTime( ++ cs: CSTypeRef, addr: *const c_void, time: u64) -> CSTypeRef; ++ fn CSSymbolicatorGetSourceInfoWithAddressAtTime( ++ cs: CSTypeRef, addr: *const c_void, time: u64) -> CSTypeRef; ++ fn CSSourceInfoGetLineNumber(info: CSTypeRef) -> c_int; ++ fn CSSourceInfoGetPath(info: CSTypeRef) -> *const c_char; ++ fn CSSourceInfoGetSymbol(info: CSTypeRef) -> CSTypeRef; ++ fn CSSymbolGetName(sym: CSTypeRef) -> *const c_char; ++ fn CSSymbolGetSymbolOwner(sym: CSTypeRef) -> CSTypeRef; ++ fn CSSymbolOwnerGetBaseAddress(symowner: CSTypeRef) -> *mut c_void; ++ } ++} ++ ++unsafe fn get(sym: &DylibSymbol) -> &T { ++ CORESYMBOLICATION.get(sym).unwrap() ++} ++ ++unsafe fn try_resolve(addr: *mut c_void, cb: &mut FnMut(&super::Symbol)) -> bool { ++ let path = "/System/Library/PrivateFrameworks/CoreSymbolication.framework\ ++ /Versions/A/CoreSymbolication"; ++ if !CORESYMBOLICATION.init(path) { ++ return false; ++ } ++ ++ let cs = get(&CSSymbolicatorCreateWithPid)(libc::getpid()); ++ if cs == CSREF_NULL { ++ return false ++ } ++ ++ let info = get(&CSSymbolicatorGetSourceInfoWithAddressAtTime)( ++ cs, addr, CS_NOW); ++ let sym = if info == CSREF_NULL { ++ get(&CSSymbolicatorGetSymbolWithAddressAtTime)(cs, addr, CS_NOW) ++ } else { ++ get(&CSSourceInfoGetSymbol)(info) ++ }; ++ ++ let mut rv = false; ++ if sym != CSREF_NULL { ++ let owner = get(&CSSymbolGetSymbolOwner)(sym); ++ if owner != CSREF_NULL { ++ cb(&super::Symbol { ++ inner: Symbol::Core { ++ path: if info != CSREF_NULL { ++ get(&CSSourceInfoGetPath)(info) ++ } else { ++ ptr::null() ++ }, ++ lineno: if info != CSREF_NULL { ++ get(&CSSourceInfoGetLineNumber)(info) as u32 ++ } else { ++ 0 ++ }, ++ name: get(&CSSymbolGetName)(sym), ++ addr: get(&CSSymbolOwnerGetBaseAddress)(owner), ++ }, ++ }); ++ rv = true; ++ } ++ } ++ get(&CSRelease)(cs); ++ ++ rv ++} ++ ++pub fn resolve(addr: *mut c_void, cb: &mut FnMut(&super::Symbol)) { ++ unsafe { ++ if try_resolve(addr, cb) { ++ return ++ } ++ let mut info: Dl_info = mem::zeroed(); ++ if libc::dladdr(addr as *mut _, &mut info) != 0 { ++ cb(&super::Symbol { ++ inner: Symbol::Dladdr(info), ++ }); ++ } ++ } ++} diff --cc vendor/backtrace-0.3.3/src/symbolize/dbghelp.rs index 000000000,000000000..60a93b0c5 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/symbolize/dbghelp.rs @@@ -1,0 -1,0 +1,114 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++#![allow(bad_style)] ++ ++use std::ffi::OsString; ++use std::mem; ++use std::path::Path; ++use std::os::windows::prelude::*; ++use std::slice; ++use kernel32; ++use winapi::*; ++ ++use SymbolName; ++ ++pub struct Symbol { ++ name: OsString, ++ addr: *mut c_void, ++ line: Option, ++ filename: Option, ++} ++ ++impl Symbol { ++ pub fn name(&self) -> Option { ++ self.name.to_str().map(|s| SymbolName::new(s.as_bytes())) ++ } ++ ++ pub fn addr(&self) -> Option<*mut c_void> { ++ Some(self.addr as *mut _) ++ } ++ ++ pub fn filename(&self) -> Option<&Path> { ++ self.filename.as_ref().map(Path::new) ++ } ++ ++ pub fn lineno(&self) -> Option { ++ self.line ++ } ++} ++ ++pub fn resolve(addr: *mut c_void, cb: &mut FnMut(&super::Symbol)) { ++ // According to windows documentation, all dbghelp functions are ++ // single-threaded. ++ let _g = ::lock::lock(); ++ ++ unsafe { ++ let size = 2 * MAX_SYM_NAME + mem::size_of::(); ++ let mut data = vec![0u8; size]; ++ let info = &mut *(data.as_mut_ptr() as *mut SYMBOL_INFOW); ++ info.MaxNameLen = MAX_SYM_NAME as ULONG; ++ // the struct size in C. the value is different to ++ // `size_of::() - MAX_SYM_NAME + 1` (== 81) ++ // due to struct alignment. ++ info.SizeOfStruct = 88; ++ ++ let _c = ::dbghelp_init(); ++ ++ let mut displacement = 0u64; ++ let ret = ::dbghelp::SymFromAddrW(kernel32::GetCurrentProcess(), ++ addr as DWORD64, ++ &mut displacement, ++ info); ++ if ret != TRUE { ++ return ++ } ++ ++ // If the symbol name is greater than MaxNameLen, SymFromAddrW will ++ // give a buffer of (MaxNameLen - 1) characters and set NameLen to ++ // the real value. ++ let name_len = ::std::cmp::min(info.NameLen as usize, ++ info.MaxNameLen as usize - 1); ++ ++ let name = slice::from_raw_parts(info.Name.as_ptr() as *const u16, ++ name_len); ++ let name = OsString::from_wide(name); ++ ++ let mut line = mem::zeroed::(); ++ line.SizeOfStruct = mem::size_of::() as DWORD; ++ let mut displacement = 0; ++ let ret = ::dbghelp::SymGetLineFromAddrW64(kernel32::GetCurrentProcess(), ++ addr as DWORD64, ++ &mut displacement, ++ &mut line); ++ let mut filename = None; ++ let mut lineno = None; ++ if ret == TRUE { ++ lineno = Some(line.LineNumber as u32); ++ ++ let base = line.FileName; ++ let mut len = 0; ++ while *base.offset(len) != 0 { ++ len += 1; ++ } ++ let name = slice::from_raw_parts(base, len as usize); ++ filename = Some(OsString::from_wide(name)); ++ } ++ ++ cb(&super::Symbol { ++ inner: Symbol { ++ name: name, ++ addr: info.Address as *mut _, ++ line: lineno, ++ filename: filename, ++ }, ++ }) ++ } ++} diff --cc vendor/backtrace-0.3.3/src/symbolize/dladdr.rs index 000000000,000000000..d7cdfbb8b new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/symbolize/dladdr.rs @@@ -1,0 -1,0 +1,59 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::ffi::CStr; ++use std::mem; ++use std::os::raw::c_void; ++use std::path::Path; ++ ++use libc::{self, Dl_info}; ++ ++use SymbolName; ++ ++pub struct Symbol { ++ inner: Dl_info, ++} ++ ++impl Symbol { ++ pub fn name(&self) -> Option { ++ if self.inner.dli_sname.is_null() { ++ None ++ } else { ++ Some(SymbolName::new(unsafe { ++ CStr::from_ptr(self.inner.dli_sname).to_bytes() ++ })) ++ } ++ } ++ ++ pub fn addr(&self) -> Option<*mut c_void> { ++ Some(self.inner.dli_saddr as *mut _) ++ } ++ ++ pub fn filename(&self) -> Option<&Path> { ++ None ++ } ++ ++ pub fn lineno(&self) -> Option { ++ None ++ } ++} ++ ++pub fn resolve(addr: *mut c_void, cb: &mut FnMut(&super::Symbol)) { ++ unsafe { ++ let mut info: super::Symbol = super::Symbol { ++ inner: Symbol { ++ inner: mem::zeroed(), ++ }, ++ }; ++ if libc::dladdr(addr as *mut _, &mut info.inner.inner) != 0 { ++ cb(&info) ++ } ++ } ++} diff --cc vendor/backtrace-0.3.3/src/symbolize/gimli.rs index 000000000,000000000..5ee715053 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/symbolize/gimli.rs @@@ -1,0 -1,0 +1,170 @@@ ++use addr2line; ++use findshlibs::{self, Segment, SharedLibrary}; ++use std::cell::RefCell; ++use std::env; ++use std::os::raw::c_void; ++use std::path::{Path, PathBuf}; ++use std::u32; ++ ++use SymbolName; ++ ++const MAPPINGS_CACHE_SIZE: usize = 4; ++ ++thread_local! { ++ // A very small, very simple LRU cache for debug info mappings. ++ // ++ // The hit rate should be very high, since the typical stack doesn't cross ++ // between many shared libraries. ++ // ++ // The `addr2line::Mapping` structures are pretty expensive to create. Its ++ // cost is expected to be amortized by subsequent `locate` queries, which ++ // leverage the structures built when constructing `addr2line::Mapping`s to ++ // get nice speedups. If we didn't have this cache, that amortization would ++ // never happen, and symbolicating backtraces would be ssssllllooooowwww. ++ static MAPPINGS_CACHE: RefCell> ++ = RefCell::new(Vec::with_capacity(MAPPINGS_CACHE_SIZE)); ++} ++ ++fn with_mapping_for_path(path: PathBuf, mut f: F) ++where ++ F: FnMut(&mut addr2line::Mapping) ++{ ++ MAPPINGS_CACHE.with(|cache| { ++ let mut cache = cache.borrow_mut(); ++ ++ let idx = cache.iter().position(|&(ref p, _)| p == &path); ++ ++ // Invariant: after this conditional completes without early returning ++ // from an error, the cache entry for this path is at index 0. ++ ++ if let Some(idx) = idx { ++ // When the mapping is already in the cache, move it to the front. ++ if idx != 0 { ++ let entry = cache.remove(idx); ++ cache.insert(0, entry); ++ } ++ } else { ++ // When the mapping is not in the cache, create a new mapping, ++ // insert it into the front of the cache, and evict the oldest cache ++ // entry if necessary. ++ let opts = addr2line::Options::default() ++ .with_functions(); ++ ++ let mapping = match opts.build(&path) { ++ Err(_) => return, ++ Ok(m) => m, ++ }; ++ ++ if cache.len() == MAPPINGS_CACHE_SIZE { ++ cache.pop(); ++ } ++ ++ cache.insert(0, (path, mapping)); ++ } ++ ++ f(&mut cache[0].1); ++ }); ++} ++ ++pub fn resolve(addr: *mut c_void, cb: &mut FnMut(&super::Symbol)) { ++ // First, find the file containing the segment that the given AVMA (after ++ // relocation) address falls within. Use the containing segment to compute ++ // the SVMA (before relocation) address. ++ // ++ // Note that the OS APIs that `SharedLibrary::each` is implemented with hold ++ // a lock for the duration of the `each` call, so we want to keep this ++ // section as short as possible to avoid contention with other threads ++ // capturing backtraces. ++ let addr = findshlibs::Avma(addr as *mut u8 as *const u8); ++ let mut so_info = None; ++ findshlibs::TargetSharedLibrary::each(|so| { ++ use findshlibs::IterationControl::*; ++ ++ for segment in so.segments() { ++ if segment.contains_avma(so, addr) { ++ let addr = so.avma_to_svma(addr); ++ let path = so.name().to_string_lossy(); ++ so_info = Some((addr, path.to_string())); ++ return Break; ++ } ++ } ++ ++ Continue ++ }); ++ let (addr, path) = match so_info { ++ None => return, ++ Some((a, p)) => (a, p), ++ }; ++ ++ // Second, fixup the path. Empty path means that this address falls within ++ // the main executable, not a shared library. ++ let path = if path.is_empty() { ++ match env::current_exe() { ++ Err(_) => return, ++ Ok(p) => p, ++ } ++ } else { ++ PathBuf::from(path) ++ }; ++ ++ // Finally, get a cached mapping or create a new mapping for this file, and ++ // evaluate the DWARF info to find the file/line/name for this address. ++ with_mapping_for_path(path, |mapping| { ++ let (file, line, func) = match mapping.locate(addr.0 as u64) { ++ Ok(None) | Err(_) => return, ++ Ok(Some((file, line, func))) => (file, line, func), ++ }; ++ ++ let sym = super::Symbol { ++ inner: Symbol::new(addr.0 as usize, ++ file, ++ line, ++ func.map(|f| f.to_string())) ++ }; ++ ++ cb(&sym); ++ }); ++} ++ ++pub struct Symbol { ++ addr: usize, ++ file: PathBuf, ++ line: Option, ++ name: Option, ++} ++ ++impl Symbol { ++ fn new(addr: usize, ++ file: PathBuf, ++ line: Option, ++ name: Option) ++ -> Symbol { ++ Symbol { ++ addr, ++ file, ++ line, ++ name, ++ } ++ } ++ ++ pub fn name(&self) -> Option { ++ self.name.as_ref().map(|s| SymbolName::new(s.as_bytes())) ++ } ++ ++ pub fn addr(&self) -> Option<*mut c_void> { ++ Some(self.addr as *mut c_void) ++ } ++ ++ pub fn filename(&self) -> Option<&Path> { ++ Some(self.file.as_ref()) ++ } ++ ++ pub fn lineno(&self) -> Option { ++ self.line ++ .and_then(|l| if l > (u32::MAX as u64) { ++ None ++ } else { ++ Some(l as u32) ++ }) ++ } ++} diff --cc vendor/backtrace-0.3.3/src/symbolize/libbacktrace.rs index 000000000,000000000..865f69181 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/symbolize/libbacktrace.rs @@@ -1,0 -1,0 +1,180 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++#![allow(bad_style)] ++ ++extern crate backtrace_sys as bt; ++ ++use libc::uintptr_t; ++use std::ffi::{CStr, OsStr}; ++use std::os::raw::{c_void, c_char, c_int}; ++use std::os::unix::prelude::*; ++use std::path::Path; ++use std::ptr; ++use std::sync::{ONCE_INIT, Once}; ++ ++use SymbolName; ++ ++pub enum Symbol { ++ Syminfo { ++ pc: uintptr_t, ++ symname: *const c_char, ++ }, ++ Pcinfo { ++ pc: uintptr_t, ++ filename: *const c_char, ++ lineno: c_int, ++ function: *const c_char, ++ }, ++} ++ ++impl Symbol { ++ pub fn name(&self) -> Option { ++ let ptr = match *self { ++ Symbol::Syminfo { symname, .. } => symname, ++ Symbol::Pcinfo { function, .. } => function, ++ }; ++ if ptr.is_null() { ++ None ++ } else { ++ Some(SymbolName::new(unsafe { CStr::from_ptr(ptr).to_bytes() })) ++ } ++ } ++ ++ pub fn addr(&self) -> Option<*mut c_void> { ++ let pc = match *self { ++ Symbol::Syminfo { pc, .. } => pc, ++ Symbol::Pcinfo { pc, .. } => pc, ++ }; ++ if pc == 0 {None} else {Some(pc as *mut _)} ++ } ++ ++ pub fn filename(&self) -> Option<&Path> { ++ match *self { ++ Symbol::Syminfo { .. } => None, ++ Symbol::Pcinfo { filename, .. } => { ++ Some(Path::new(OsStr::from_bytes(unsafe { ++ CStr::from_ptr(filename).to_bytes() ++ }))) ++ } ++ } ++ } ++ ++ pub fn lineno(&self) -> Option { ++ match *self { ++ Symbol::Syminfo { .. } => None, ++ Symbol::Pcinfo { lineno, .. } => Some(lineno as u32), ++ } ++ } ++} ++ ++extern fn error_cb(_data: *mut c_void, _msg: *const c_char, ++ _errnum: c_int) { ++ // do nothing for now ++} ++ ++extern fn syminfo_cb(data: *mut c_void, ++ pc: uintptr_t, ++ symname: *const c_char, ++ _symval: uintptr_t, ++ _symsize: uintptr_t) { ++ unsafe { ++ call(data, &super::Symbol { ++ inner: Symbol::Syminfo { ++ pc: pc, ++ symname: symname, ++ }, ++ }); ++ } ++} ++ ++extern fn pcinfo_cb(data: *mut c_void, ++ pc: uintptr_t, ++ filename: *const c_char, ++ lineno: c_int, ++ function: *const c_char) -> c_int { ++ unsafe { ++ if filename.is_null() || function.is_null() { ++ return -1 ++ } ++ call(data, &super::Symbol { ++ inner: Symbol::Pcinfo { ++ pc: pc, ++ filename: filename, ++ lineno: lineno, ++ function: function, ++ }, ++ }); ++ return 0 ++ } ++} ++ ++unsafe fn call(data: *mut c_void, sym: &super::Symbol) { ++ let cb = data as *mut &mut FnMut(&super::Symbol); ++ let mut bomb = ::Bomb { enabled: true }; ++ (*cb)(sym); ++ bomb.enabled = false; ++} ++ ++// The libbacktrace API supports creating a state, but it does not ++// support destroying a state. I personally take this to mean that a ++// state is meant to be created and then live forever. ++// ++// I would love to register an at_exit() handler which cleans up this ++// state, but libbacktrace provides no way to do so. ++// ++// With these constraints, this function has a statically cached state ++// that is calculated the first time this is requested. Remember that ++// backtracing all happens serially (one global lock). ++// ++// Things don't work so well on not-Linux since libbacktrace can't track down ++// that executable this is. We at one point used env::current_exe but it turns ++// out that there are some serious security issues with that approach. ++// ++// Specifically, on certain platforms like BSDs, a malicious actor can cause an ++// arbitrary file to be placed at the path returned by current_exe. libbacktrace ++// does not behave defensively in the presence of ill-formed DWARF information, ++// and has been demonstrated to segfault in at least one case. There is no ++// evidence at the moment to suggest that a more carefully constructed file ++// can't cause arbitrary code execution. As a result of all of this, we don't ++// hint libbacktrace with the path to the current process. ++unsafe fn init_state() -> *mut bt::backtrace_state { ++ static mut STATE: *mut bt::backtrace_state = 0 as *mut _; ++ static INIT: Once = ONCE_INIT; ++ INIT.call_once(|| { ++ // Our libbacktrace may not have multithreading support, so ++ // set `threaded = 0` and synchronize ourselves. ++ STATE = bt::backtrace_create_state(ptr::null(), 0, error_cb, ++ ptr::null_mut()); ++ }); ++ ++ STATE ++} ++ ++pub fn resolve(symaddr: *mut c_void, mut cb: &mut FnMut(&super::Symbol)) { ++ let _guard = ::lock::lock(); ++ ++ // backtrace errors are currently swept under the rug ++ unsafe { ++ let state = init_state(); ++ if state.is_null() { ++ return ++ } ++ ++ let ret = bt::backtrace_pcinfo(state, symaddr as uintptr_t, ++ pcinfo_cb, error_cb, ++ &mut cb as *mut _ as *mut _); ++ if ret != 0 { ++ bt::backtrace_syminfo(state, symaddr as uintptr_t, ++ syminfo_cb, error_cb, ++ &mut cb as *mut _ as *mut _); ++ } ++ } ++} diff --cc vendor/backtrace-0.3.3/src/symbolize/mod.rs index 000000000,000000000..7ed65479f new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/symbolize/mod.rs @@@ -1,0 -1,0 +1,289 @@@ ++use std::fmt; ++#[cfg(not(feature = "cpp_demangle"))] ++use std::marker::PhantomData; ++use std::os::raw::c_void; ++use std::path::Path; ++use std::str; ++use rustc_demangle::{try_demangle, Demangle}; ++ ++/// Resolve an address to a symbol, passing the symbol to the specified ++/// closure. ++/// ++/// This function will look up the given address in areas such as the local ++/// symbol table, dynamic symbol table, or DWARF debug info (depending on the ++/// activated implementation) to find symbols to yield. ++/// ++/// The closure may not be called if resolution could not be performed, and it ++/// also may be called more than once in the case of inlined functions. ++/// ++/// Symbols yielded represent the execution at the specified `addr`, returning ++/// file/line pairs for that address (if available). ++/// ++/// # Example ++/// ++/// ``` ++/// extern crate backtrace; ++/// ++/// fn main() { ++/// backtrace::trace(|frame| { ++/// let ip = frame.ip(); ++/// ++/// backtrace::resolve(ip, |symbol| { ++/// // ... ++/// }); ++/// ++/// false // only look at the top frame ++/// }); ++/// } ++/// ``` ++pub fn resolve(addr: *mut c_void, mut cb: F) { ++ resolve_imp(addr, &mut cb) ++} ++ ++/// A trait representing the resolution of a symbol in a file. ++/// ++/// This trait is yielded as a trait object to the closure given to the ++/// `backtrace::resolve` function, and it is virtually dispatched as it's ++/// unknown which implementation is behind it. ++/// ++/// A symbol can give contextual information about a function, for example the ++/// name, filename, line number, precise address, etc. Not all information is ++/// always available in a symbol, however, so all methods return an `Option`. ++pub struct Symbol { ++ inner: SymbolImp, ++} ++ ++impl Symbol { ++ /// Returns the name of this function. ++ /// ++ /// The returned structure can be used to query various properties about the ++ /// symbol name: ++ /// ++ /// * The `Display` implementation will print out the demangled symbol. ++ /// * The raw `str` value of the symbol can be accessed (if it's valid ++ /// utf-8). ++ /// * The raw bytes for the symbol name can be accessed. ++ pub fn name(&self) -> Option { ++ self.inner.name() ++ } ++ ++ /// Returns the starting address of this function. ++ pub fn addr(&self) -> Option<*mut c_void> { ++ self.inner.addr() ++ } ++ ++ /// Returns the file name where this function was defined. ++ /// ++ /// This is currently only available when libbacktrace is being used (e.g. ++ /// unix platforms other than OSX) and when a binary is compiled with ++ /// debuginfo. If neither of these conditions is met then this will likely ++ /// return `None`. ++ pub fn filename(&self) -> Option<&Path> { ++ self.inner.filename() ++ } ++ ++ /// Returns the line number for where this symbol is currently executing. ++ /// ++ /// This return value is typically `Some` if `filename` returns `Some`, and ++ /// is consequently subject to similar caveats. ++ pub fn lineno(&self) -> Option { ++ self.inner.lineno() ++ } ++} ++ ++impl fmt::Debug for Symbol { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ let mut d = f.debug_struct("Symbol"); ++ if let Some(name) = self.name() { ++ d.field("name", &name); ++ } ++ if let Some(addr) = self.addr() { ++ d.field("addr", &addr); ++ } ++ if let Some(filename) = self.filename() { ++ d.field("filename", &filename); ++ } ++ if let Some(lineno) = self.lineno() { ++ d.field("lineno", &lineno); ++ } ++ d.finish() ++ } ++} ++ ++ ++cfg_if! { ++ if #[cfg(feature = "cpp_demangle")] { ++ // Maybe a parsed C++ symbol, if parsing the mangled symbol as Rust ++ // failed. ++ struct OptionCppSymbol<'a>(Option<::cpp_demangle::BorrowedSymbol<'a>>); ++ ++ impl<'a> OptionCppSymbol<'a> { ++ fn parse(input: &'a [u8]) -> OptionCppSymbol<'a> { ++ OptionCppSymbol(::cpp_demangle::BorrowedSymbol::new(input).ok()) ++ } ++ ++ fn none() -> OptionCppSymbol<'a> { ++ OptionCppSymbol(None) ++ } ++ } ++ } else { ++ // Make sure to keep this zero-sized, so that the `cpp_demangle` feature ++ // has no cost when disabled. ++ struct OptionCppSymbol<'a>(PhantomData<&'a ()>); ++ ++ impl<'a> OptionCppSymbol<'a> { ++ fn parse(_: &'a [u8]) -> OptionCppSymbol<'a> { ++ OptionCppSymbol(PhantomData) ++ } ++ ++ fn none() -> OptionCppSymbol<'a> { ++ OptionCppSymbol(PhantomData) ++ } ++ } ++ } ++} ++ ++/// A wrapper around a symbol name to provide ergonomic accessors to the ++/// demangled name, the raw bytes, the raw string, etc. ++// Allow dead code for when the `cpp_demangle` feature is not enabled. ++#[allow(dead_code)] ++pub struct SymbolName<'a> { ++ bytes: &'a [u8], ++ demangled: Option>, ++ cpp_demangled: OptionCppSymbol<'a>, ++} ++ ++impl<'a> SymbolName<'a> { ++ /// Creates a new symbol name from the raw underlying bytes. ++ pub fn new(bytes: &'a [u8]) -> SymbolName<'a> { ++ let str_bytes = str::from_utf8(bytes).ok(); ++ let demangled = str_bytes.and_then(|s| try_demangle(s).ok()); ++ ++ let cpp = if demangled.is_none() { ++ OptionCppSymbol::parse(bytes) ++ } else { ++ OptionCppSymbol::none() ++ }; ++ ++ SymbolName { ++ bytes: bytes, ++ demangled: demangled, ++ cpp_demangled: cpp, ++ } ++ } ++ ++ /// Returns the raw symbol name as a `str` if the symbols is valid utf-8. ++ pub fn as_str(&self) -> Option<&'a str> { ++ self.demangled ++ .as_ref() ++ .map(|s| s.as_str()) ++ .or_else(|| { ++ str::from_utf8(self.bytes).ok() ++ }) ++ } ++ ++ /// Returns the raw symbol name as a list of bytes ++ pub fn as_bytes(&self) -> &'a [u8] { ++ self.bytes ++ } ++} ++ ++cfg_if! { ++ if #[cfg(feature = "cpp_demangle")] { ++ impl<'a> fmt::Display for SymbolName<'a> { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ if let Some(ref s) = self.demangled { ++ s.fmt(f) ++ } else if let Some(ref cpp) = self.cpp_demangled.0 { ++ cpp.fmt(f) ++ } else { ++ String::from_utf8_lossy(self.bytes).fmt(f) ++ } ++ } ++ } ++ } else { ++ impl<'a> fmt::Display for SymbolName<'a> { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ if let Some(ref s) = self.demangled { ++ s.fmt(f) ++ } else { ++ String::from_utf8_lossy(self.bytes).fmt(f) ++ } ++ } ++ } ++ } ++} ++ ++cfg_if! { ++ if #[cfg(feature = "cpp_demangle")] { ++ impl<'a> fmt::Debug for SymbolName<'a> { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ use std::fmt::Write; ++ ++ if let Some(ref s) = self.demangled { ++ return s.fmt(f) ++ } ++ ++ // This may to print if the demangled symbol isn't actually ++ // valid, so handle the error here gracefully by not propagating ++ // it outwards. ++ if let Some(ref cpp) = self.cpp_demangled.0 { ++ let mut s = String::new(); ++ if write!(s, "{}", cpp).is_ok() { ++ return s.fmt(f) ++ } ++ } ++ ++ String::from_utf8_lossy(self.bytes).fmt(f) ++ } ++ } ++ } else { ++ impl<'a> fmt::Debug for SymbolName<'a> { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ if let Some(ref s) = self.demangled { ++ s.fmt(f) ++ } else { ++ String::from_utf8_lossy(self.bytes).fmt(f) ++ } ++ } ++ } ++ } ++} ++ ++cfg_if! { ++ if #[cfg(all(windows, feature = "dbghelp"))] { ++ mod dbghelp; ++ use self::dbghelp::resolve as resolve_imp; ++ use self::dbghelp::Symbol as SymbolImp; ++ } else if #[cfg(all(feature = "gimli-symbolize", ++ unix, ++ target_os = "linux"))] { ++ mod gimli; ++ use self::gimli::resolve as resolve_imp; ++ use self::gimli::Symbol as SymbolImp; ++ } else if #[cfg(all(feature = "libbacktrace", ++ unix, ++ not(target_os = "emscripten"), ++ not(target_os = "macos"), ++ not(target_os = "ios")))] { ++ mod libbacktrace; ++ use self::libbacktrace::resolve as resolve_imp; ++ use self::libbacktrace::Symbol as SymbolImp; ++ } else if #[cfg(all(feature = "coresymbolication", ++ any(target_os = "macos", ++ target_os = "ios")))] { ++ mod coresymbolication; ++ use self::coresymbolication::resolve as resolve_imp; ++ use self::coresymbolication::Symbol as SymbolImp; ++ } else if #[cfg(all(unix, ++ not(target_os = "emscripten"), ++ feature = "dladdr"))] { ++ mod dladdr; ++ use self::dladdr::resolve as resolve_imp; ++ use self::dladdr::Symbol as SymbolImp; ++ } else { ++ mod noop; ++ use self::noop::resolve as resolve_imp; ++ use self::noop::Symbol as SymbolImp; ++ } ++} diff --cc vendor/backtrace-0.3.3/src/symbolize/noop.rs index 000000000,000000000..78b2a63f8 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/src/symbolize/noop.rs @@@ -1,0 -1,0 +1,27 @@@ ++use std::path::Path; ++use std::os::raw::c_void; ++ ++use SymbolName; ++ ++pub fn resolve(_addr: *mut c_void, _cb: &mut FnMut(&super::Symbol)) { ++} ++ ++pub struct Symbol; ++ ++impl Symbol { ++ pub fn name(&self) -> Option { ++ None ++ } ++ ++ pub fn addr(&self) -> Option<*mut c_void> { ++ None ++ } ++ ++ pub fn filename(&self) -> Option<&Path> { ++ None ++ } ++ ++ pub fn lineno(&self) -> Option { ++ None ++ } ++} diff --cc vendor/backtrace-0.3.3/tests/long_fn_name.rs index 000000000,000000000..90750c1fe new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/tests/long_fn_name.rs @@@ -1,0 -1,0 +1,56 @@@ ++extern crate backtrace; ++ ++#[cfg(all(windows, feature = "dbghelp"))] ++extern crate winapi; ++ ++use backtrace::Backtrace; ++ ++// 50-character module name ++mod _234567890_234567890_234567890_234567890_234567890 { ++ // 50-character struct name ++ #[allow(non_camel_case_types)] ++ pub struct _234567890_234567890_234567890_234567890_234567890(T); ++ impl _234567890_234567890_234567890_234567890_234567890 { ++ #[allow(dead_code)] ++ pub fn new() -> ::Backtrace { ++ ::Backtrace::new() ++ } ++ } ++} ++ ++// Long function names must be truncated to (MAX_SYM_NAME - 1) characters. ++// Only run this test for msvc, since gnu prints "" for all frames. ++#[test] ++#[cfg(all(windows, feature = "dbghelp", target_env = "msvc"))] ++fn test_long_fn_name() { ++ use _234567890_234567890_234567890_234567890_234567890:: ++ _234567890_234567890_234567890_234567890_234567890 as S; ++ ++ // 10 repetitions of struct name, so fully qualified function name is ++ // atleast 10 * (50 + 50) * 2 = 2000 characters long. ++ // It's actually longer since it also includes `::`, `<>` and the ++ // name of the current module ++ let bt = S::>>>>>>>>>::new(); ++ println!("{:?}", bt); ++ ++ let mut found_long_name_frame = false; ++ ++ for frame in bt.frames() { ++ let symbols = frame.symbols(); ++ if symbols.is_empty() { ++ continue; ++ } ++ ++ if let Some(function_name) = symbols[0].name() { ++ let function_name = function_name.as_str().unwrap(); ++ if function_name.contains( ++ "::_234567890_234567890_234567890_234567890_234567890") ++ { ++ found_long_name_frame = true; ++ assert_eq!(function_name.len(), winapi::MAX_SYM_NAME - 1); ++ } ++ } ++ } ++ ++ assert!(found_long_name_frame); ++} diff --cc vendor/backtrace-0.3.3/tests/smoke.rs index 000000000,000000000..1ec6f2b17 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-0.3.3/tests/smoke.rs @@@ -1,0 -1,0 +1,170 @@@ ++extern crate backtrace; ++ ++use std::os::raw::c_void; ++use std::thread; ++ ++static LIBUNWIND: bool = cfg!(all(unix, feature = "libunwind")); ++static UNIX_BACKTRACE: bool = cfg!(all(unix, feature = "unix-backtrace")); ++static LIBBACKTRACE: bool = cfg!(all(unix, feature = "libbacktrace")) && ++ !cfg!(target_os = "macos") && !cfg!(target_os = "ios"); ++static CORESYMBOLICATION: bool = cfg!(all(any(target_os = "macos", target_os = "ios"), ++ feature = "coresymbolication")); ++static DLADDR: bool = cfg!(all(unix, feature = "dladdr")); ++static DBGHELP: bool = cfg!(all(windows, feature = "dbghelp")); ++static MSVC: bool = cfg!(target_env = "msvc"); ++static GIMLI_SYMBOLIZE: bool = cfg!(all(feature = "gimli-symbolize", ++ unix, ++ target_os = "linux")); ++ ++#[test] ++fn smoke_test_frames() { ++ frame_1(line!()); ++ #[inline(never)] fn frame_1(start_line: u32) { frame_2(start_line) } ++ #[inline(never)] fn frame_2(start_line: u32) { frame_3(start_line) } ++ #[inline(never)] fn frame_3(start_line: u32) { frame_4(start_line) } ++ #[inline(never)] fn frame_4(start_line: u32) { ++ let mut v = Vec::new(); ++ backtrace::trace(|cx| { ++ v.push((cx.ip(), cx.symbol_address())); ++ true ++ }); ++ ++ if v.len() < 5 { ++ assert!(!LIBUNWIND); ++ assert!(!UNIX_BACKTRACE); ++ assert!(!DBGHELP); ++ return ++ } ++ ++ // On 32-bit windows apparently the first frame isn't our backtrace ++ // frame but it's actually this frame. I'm not entirely sure why, but at ++ // least it seems consistent? ++ let o = if cfg!(all(windows, target_pointer_width = "32")) {1} else {0}; ++ // frame offset 0 is the `backtrace::trace` function, but that's generic ++ assert_frame(&v, o, 1, frame_4 as usize, "frame_4", ++ "tests/smoke.rs", start_line + 6); ++ assert_frame(&v, o, 2, frame_3 as usize, "frame_3", "tests/smoke.rs", ++ start_line + 3); ++ assert_frame(&v, o, 3, frame_2 as usize, "frame_2", "tests/smoke.rs", ++ start_line + 2); ++ assert_frame(&v, o, 4, frame_1 as usize, "frame_1", "tests/smoke.rs", ++ start_line + 1); ++ assert_frame(&v, o, 5, smoke_test_frames as usize, ++ "smoke_test_frames", "", 0); ++ } ++ ++ fn assert_frame(syms: &[(*mut c_void, *mut c_void)], ++ offset: usize, ++ idx: usize, ++ actual_fn_pointer: usize, ++ expected_name: &str, ++ expected_file: &str, ++ expected_line: u32) { ++ if offset > idx { return } ++ let (ip, sym) = syms[idx - offset]; ++ let ip = ip as usize; ++ let sym = sym as usize; ++ assert!(ip >= sym); ++ assert!(sym >= actual_fn_pointer); ++ ++ // windows dbghelp is *quite* liberal (and wrong) in many of its reports ++ // right now... ++ if !DBGHELP { ++ assert!(sym - actual_fn_pointer < 1024); ++ } ++ ++ let mut resolved = 0; ++ let can_resolve = DLADDR || LIBBACKTRACE || CORESYMBOLICATION || DBGHELP || GIMLI_SYMBOLIZE; ++ ++ let mut name = None; ++ let mut addr = None; ++ let mut line = None; ++ let mut file = None; ++ backtrace::resolve(ip as *mut c_void, |sym| { ++ resolved += 1; ++ name = sym.name().map(|v| v.to_string()); ++ addr = sym.addr(); ++ line = sym.lineno(); ++ file = sym.filename().map(|v| v.to_path_buf()); ++ }); ++ ++ // dbghelp doesn't always resolve symbols right now ++ match resolved { ++ 0 => return assert!(!can_resolve || DBGHELP), ++ _ => {} ++ } ++ ++ // * linux dladdr doesn't work (only consults local symbol table) ++ // * windows dbghelp isn't great for GNU ++ if can_resolve && ++ !(cfg!(target_os = "linux") && DLADDR) && ++ !(DBGHELP && !MSVC) ++ { ++ let name = name.expect("didn't find a name"); ++ assert!(name.contains(expected_name), ++ "didn't find `{}` in `{}`", expected_name, name); ++ } ++ ++ if can_resolve { ++ addr.expect("didn't find a symbol"); ++ } ++ ++ if (LIBBACKTRACE || CORESYMBOLICATION || (DBGHELP && MSVC)) && cfg!(debug_assertions) { ++ let line = line.expect("didn't find a line number"); ++ let file = file.expect("didn't find a line number"); ++ if !expected_file.is_empty() { ++ assert!(file.ends_with(expected_file), ++ "{:?} didn't end with {:?}", file, expected_file); ++ } ++ if expected_line != 0 { ++ assert!(line == expected_line, ++ "bad line number on frame for `{}`: {} != {}", ++ expected_name, line, expected_line); ++ } ++ } ++ } ++} ++ ++#[test] ++fn many_threads() { ++ let threads = (0..16).map(|_| { ++ thread::spawn(|| { ++ for _ in 0..16 { ++ backtrace::trace(|frame| { ++ backtrace::resolve(frame.ip(), |symbol| { ++ let _s = symbol.name().map(|s| s.to_string()); ++ }); ++ true ++ }); ++ } ++ }) ++ }).collect::>(); ++ ++ for t in threads { ++ t.join().unwrap() ++ } ++} ++ ++#[test] ++#[cfg(feature = "rustc-serialize")] ++fn is_rustc_serialize() { ++ extern crate rustc_serialize; ++ ++ fn is_encode() {} ++ fn is_decode() {} ++ ++ is_encode::(); ++ is_decode::(); ++} ++ ++#[test] ++#[cfg(feature = "serde")] ++fn is_serde() { ++ extern crate serde; ++ ++ fn is_serialize() {} ++ fn is_deserialize() {} ++ ++ is_serialize::(); ++ is_deserialize::(); ++} diff --cc vendor/backtrace-sys-0.1.14/.cargo-checksum.json index 000000000,000000000..87669e9e8 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"c63ea141ef8fdb10409d0f5daf30ac51f84ef43bff66f16627773d2a292cd189"} diff --cc vendor/backtrace-sys-0.1.14/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/.cargo-ok diff --cc vendor/backtrace-sys-0.1.14/Cargo.toml index 000000000,000000000..a12525766 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/Cargo.toml @@@ -1,0 -1,0 +1,26 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "backtrace-sys" ++version = "0.1.14" ++authors = ["Alex Crichton "] ++build = "build.rs" ++description = "Bindings to the libbacktrace gcc library\n" ++homepage = "https://github.com/alexcrichton/backtrace-rs" ++documentation = "http://alexcrichton.com/backtrace-rs" ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/backtrace-rs" ++[dependencies.libc] ++version = "0.2" ++[build-dependencies.cc] ++version = "1.0" diff --cc vendor/backtrace-sys-0.1.14/build.rs index 000000000,000000000..28b10970a new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/build.rs @@@ -1,0 -1,0 +1,173 @@@ ++extern crate cc; ++ ++use std::env; ++use std::ffi::OsString; ++use std::fs; ++use std::io; ++use std::path::PathBuf; ++use std::process::Command; ++ ++macro_rules! t { ++ ($e:expr) => (match $e { ++ Ok(e) => e, ++ Err(e) => panic!("{} failed with {}", stringify!($e), e), ++ }) ++} ++ ++fn try_tool(compiler: &cc::Tool, cc: &str, compiler_suffix: &str, tool_suffix: &str) ++ -> Option { ++ if !cc.ends_with(compiler_suffix) { ++ return None ++ } ++ let cc = cc.replace(compiler_suffix, tool_suffix); ++ let candidate = compiler.path().parent().unwrap().join(cc); ++ if Command::new(&candidate).output().is_ok() { ++ Some(candidate) ++ } else { ++ None ++ } ++} ++ ++fn find_tool(compiler: &cc::Tool, cc: &str, tool: &str) -> PathBuf { ++ // Allow overrides via env var ++ if let Some(s) = env::var_os(tool.to_uppercase()) { ++ return s.into() ++ } ++ let tool_suffix = format!("-{}", tool); ++ try_tool(compiler, cc, "-gcc", &tool_suffix) ++ .or_else(|| try_tool(compiler, cc, "-clang", &tool_suffix)) ++ .or_else(|| try_tool(compiler, cc, "-cc", &tool_suffix)) ++ .unwrap_or_else(|| PathBuf::from(tool)) ++} ++ ++fn main() { ++ let src = env::current_dir().unwrap(); ++ let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); ++ let target = env::var("TARGET").unwrap(); ++ let host = env::var("HOST").unwrap(); ++ ++ // libbacktrace doesn't currently support Mach-O files ++ if target.contains("darwin") { ++ return ++ } ++ ++ // libbacktrace isn't used on windows ++ if target.contains("windows") { ++ return ++ } ++ ++ // no way this will ever compile for emscripten ++ if target.contains("emscripten") { ++ return ++ } ++ ++ let mut make = "make"; ++ ++ // host BSDs has GNU-make as gmake ++ if host.contains("bitrig") || host.contains("dragonfly") || ++ host.contains("freebsd") || host.contains("netbsd") || ++ host.contains("openbsd") { ++ ++ make = "gmake" ++ } ++ ++ let configure = src.join("src/libbacktrace/configure").into_os_string(); ++ ++ // When cross-compiling on Windows, this path will contain backslashes, ++ // but configure doesn't like that. Replace them with forward slashes. ++ #[cfg(windows)] ++ let configure = { ++ use std::os::windows::ffi::{OsStrExt, OsStringExt}; ++ let mut chars: Vec = configure.encode_wide().collect(); ++ for c in chars.iter_mut() { ++ if *c == '\\' as u16 { ++ *c = '/' as u16; ++ } ++ } ++ OsString::from_wide(&chars) ++ }; ++ ++ let cfg = cc::Build::new(); ++ let compiler = cfg.get_compiler(); ++ let cc = compiler.path().file_name().unwrap().to_str().unwrap(); ++ let mut flags = OsString::new(); ++ for (i, flag) in compiler.args().iter().enumerate() { ++ if i > 0 { ++ flags.push(" "); ++ } ++ flags.push(flag); ++ } ++ let ar = find_tool(&compiler, cc, "ar"); ++ let ranlib = find_tool(&compiler, cc, "ranlib"); ++ let mut cmd = Command::new("sh"); ++ ++ cmd.arg(configure) ++ .current_dir(&dst) ++ .env("AR", &ar) ++ .env("RANLIB", &ranlib) ++ .env("CC", compiler.path()) ++ .env("CFLAGS", flags) ++ .arg("--with-pic") ++ .arg("--disable-multilib") ++ .arg("--disable-shared") ++ .arg("--disable-host-shared") ++ .arg(format!("--host={}", target)); ++ ++ // Apparently passing this flag causes problems on Windows ++ if !host.contains("windows") { ++ cmd.arg(format!("--build={}", host)); ++ } ++ ++ run(&mut cmd, "sh"); ++ run(Command::new(make) ++ .current_dir(&dst) ++ .arg(format!("INCDIR={}", ++ src.join("src/libbacktrace").display())), ++ "make"); ++ println!("cargo:rustc-link-search=native={}/.libs", dst.display()); ++ println!("cargo:rustc-link-lib=static=backtrace"); ++ ++ // The standard library currently bundles in libbacktrace, but it's ++ // compiled with hidden visibility (naturally) so we can't use it. ++ // ++ // To prevent conflicts with a second statically linked copy we rename all ++ // symbols with a '__rbt_' prefix manually here through `objcopy`. ++ let lib = dst.join(".libs/libbacktrace.a"); ++ let tmpdir = dst.join("__tmp"); ++ drop(fs::remove_dir_all(&tmpdir)); ++ t!(fs::create_dir_all(&tmpdir)); ++ run(Command::new(&ar).arg("x").arg(&lib).current_dir(&tmpdir), ++ ar.to_str().unwrap()); ++ ++ t!(fs::remove_file(&lib)); ++ let mut objs = Vec::new(); ++ let objcopy = find_tool(&compiler, cc, "objcopy"); ++ for obj in t!(tmpdir.read_dir()) { ++ let obj = t!(obj); ++ run(Command::new(&objcopy) ++ .arg("--redefine-syms=symbol-map") ++ .arg(obj.path()), ++ objcopy.to_str().unwrap()); ++ objs.push(obj.path()); ++ } ++ ++ run(Command::new(&ar).arg("crus").arg(&lib).args(&objs), ++ ar.to_str().unwrap()); ++} ++ ++fn run(cmd: &mut Command, program: &str) { ++ println!("running: {:?}", cmd); ++ let status = match cmd.status() { ++ Ok(s) => s, ++ Err(ref e) if e.kind() == io::ErrorKind::NotFound => { ++ panic!("\n\nfailed to execute command: {}\nIs `{}` \ ++ not installed?\n\n", ++ e, ++ program); ++ } ++ Err(e) => panic!("failed to get status: {}", e), ++ }; ++ if !status.success() { ++ panic!("failed with: {}", status); ++ } ++} diff --cc vendor/backtrace-sys-0.1.14/src/lib.rs index 000000000,000000000..0edc2674c new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/lib.rs @@@ -1,0 -1,0 +1,44 @@@ ++#![allow(bad_style)] ++ ++extern crate libc; ++ ++use libc::uintptr_t; ++use std::os::raw::{c_void, c_char, c_int}; ++ ++pub type backtrace_syminfo_callback = ++ extern fn(data: *mut c_void, ++ pc: uintptr_t, ++ symname: *const c_char, ++ symval: uintptr_t, ++ symsize: uintptr_t); ++pub type backtrace_full_callback = ++ extern fn(data: *mut c_void, ++ pc: uintptr_t, ++ filename: *const c_char, ++ lineno: c_int, ++ function: *const c_char) -> c_int; ++pub type backtrace_error_callback = ++ extern fn(data: *mut c_void, ++ msg: *const c_char, ++ errnum: c_int); ++pub enum backtrace_state {} ++ ++extern { ++ #[link_name = "__rbt_backtrace_create_state"] ++ pub fn backtrace_create_state(filename: *const c_char, ++ threaded: c_int, ++ error: backtrace_error_callback, ++ data: *mut c_void) -> *mut backtrace_state; ++ #[link_name = "__rbt_backtrace_syminfo"] ++ pub fn backtrace_syminfo(state: *mut backtrace_state, ++ addr: uintptr_t, ++ cb: backtrace_syminfo_callback, ++ error: backtrace_error_callback, ++ data: *mut c_void) -> c_int; ++ #[link_name = "__rbt_backtrace_pcinfo"] ++ pub fn backtrace_pcinfo(state: *mut backtrace_state, ++ addr: uintptr_t, ++ cb: backtrace_full_callback, ++ error: backtrace_error_callback, ++ data: *mut c_void) -> c_int; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/ChangeLog index 000000000,000000000..88005dfb0 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/ChangeLog @@@ -1,0 -1,0 +1,598 @@@ ++2016-11-15 Matthias Klose ++ ++ * configure: Regenerate. ++ ++2016-09-11 Carlos Liam ++ ++ * all: Remove meaningless trailing whitespace. ++ ++2016-05-18 Uros Bizjak ++ ++ PR target/71161 ++ * elf.c (phdr_callback) [__i386__]: Add ++ __attribute__((__force_align_arg_pointer__)). ++ ++2016-03-02 Maxim Ostapenko ++ ++ * elf.c (backtrace_initialize): Properly initialize elf_fileline_fn to ++ avoid possible crash. ++ (elf_add): Don't set *fileline_fn to elf_nodebug value in case of ++ missing debug info anymore. ++ ++2016-02-06 John David Anglin ++ ++ * mmap.c (MAP_FAILED): Define if not defined. ++ ++2016-01-04 Jakub Jelinek ++ ++ Update copyright years. ++ ++2015-12-18 Andris Pavenis ++ ++ * configure.ac: Specify that DJGPP do not have mmap ++ even when sys/mman.h exists. ++ * configure: Regenerate ++ ++2015-12-09 John David Anglin ++ ++ PR libgfortran/68115 ++ * configure.ac: Set libbacktrace_cv_sys_sync to no on hppa*-*-hpux*. ++ * configure: Regenerate. ++ * elf.c (backtrace_initialize): Cast __sync_bool_compare_and_swap call ++ to void. ++ ++2015-09-17 Ian Lance Taylor ++ ++ * posix.c (backtrace_open): Cast second argument of open() to int. ++ ++2015-09-11 Ian Lance Taylor ++ ++ * Makefile.am (backtrace.lo): Depend on internal.h. ++ (sort.lo, stest.lo): Add explicit dependencies. ++ * Makefile.in: Rebuild. ++ ++2015-09-09 Hans-Peter Nilsson ++ ++ * backtrace.c: #include . ++ ++2015-09-08 Ian Lance Taylor ++ ++ PR other/67457 ++ * backtrace.c: #include "internal.h". ++ (struct backtrace_data): Add can_alloc field. ++ (unwind): If can_alloc is false, don't try to get file/line ++ information. ++ (backtrace_full): Set can_alloc field in bdata. ++ * alloc.c (backtrace_alloc): Don't call error_callback if it is ++ NULL. ++ * mmap.c (backtrace_alloc): Likewise. ++ * internal.h: Update comments for backtrace_alloc and ++ backtrace_free. ++ ++2015-09-08 Ian Lance Taylor ++ ++ PR other/67457 ++ * mmap.c (backtrace_alloc): Correct test for mmap failure. ++ ++2015-08-31 Ulrich Weigand ++ ++ * configure.ac: For spu-*-* targets, set have_fcntl to no. ++ * configure: Regenerate. ++ ++2015-08-27 Ulrich Weigand ++ ++ * configure.ac: Remove [disable-shared] argument to LT_INIT. ++ Remove setting PIC_FLAG when building as target library. ++ * configure: Regenerate. ++ ++2015-08-26 Hans-Peter Nilsson ++ ++ * configure.ac: Only compile with -fPIC if the target ++ supports it. ++ * configure: Regenerate. ++ ++2015-08-24 Ulrich Weigand ++ ++ * configure.ac: Set have_mmap to no on spu-*-* targets. ++ * configure: Regenerate. ++ ++2015-08-13 Ian Lance Taylor ++ ++ * dwarf.c (read_function_entry): Add vec_inlined parameter. ++ Change all callers. ++ ++2015-06-11 Martin Sebor ++ ++ PR sanitizer/65479 ++ * dwarf.c (struct line): Add new field idx. ++ (line_compare): Use it. ++ (add_line): Set it. ++ (read_line_info): Reset it. ++ ++2015-05-29 Tristan Gingold ++ ++ * pecoff.c: New file. ++ * Makefile.am (FORMAT_FILES): Add pecoff.c and dependencies. ++ * Makefile.in: Regenerate. ++ * filetype.awk: Detect pecoff. ++ * configure.ac: Define BACKTRACE_SUPPORTS_DATA on elf platforms. ++ Add pecoff. ++ * btest.c (test5): Test enabled only if BACKTRACE_SUPPORTS_DATA is ++ true. ++ * backtrace-supported.h.in (BACKTRACE_SUPPORTS_DATA): Define. ++ * configure: Regenerate. ++ * pecoff.c: New file. ++ ++2015-05-13 Michael Haubenwallner ++ ++ * Makefile.in: Regenerated with automake-1.11.6. ++ * aclocal.m4: Likewise. ++ * configure: Likewise. ++ ++2015-01-24 Matthias Klose ++ ++ * configure.ac: Move AM_ENABLE_MULTILIB before AC_PROG_CC. ++ * configure: Regenerate. ++ ++2015-01-05 Jakub Jelinek ++ ++ Update copyright years. ++ ++2014-11-21 H.J. Lu ++ ++ PR bootstrap/63784 ++ * configure: Regenerated. ++ ++2014-11-11 David Malcolm ++ ++ * ChangeLog.jit: New. ++ ++2014-11-11 Francois-Xavier Coudert ++ ++ PR target/63610 ++ * configure: Regenerate. ++ ++2014-10-23 Ian Lance Taylor ++ ++ * internal.h (backtrace_atomic_load_pointer) [no atomic or sync]: ++ Fix to return void *. ++ ++2014-05-08 Ian Lance Taylor ++ ++ * mmap.c (backtrace_free): If freeing a large aligned block of ++ memory, call munmap rather than holding onto it. ++ (backtrace_vector_grow): When growing a vector, double the number ++ of pages requested. When releasing the old version of a grown ++ vector, pass the correct size to backtrace_free. ++ ++2014-03-07 Ian Lance Taylor ++ ++ * sort.c (backtrace_qsort): Use middle element as pivot. ++ ++2014-03-06 Ian Lance Taylor ++ ++ * sort.c: New file. ++ * stest.c: New file. ++ * internal.h (backtrace_qsort): Declare. ++ * dwarf.c (read_abbrevs): Call backtrace_qsort instead of qsort. ++ (read_line_info, read_function_entry): Likewise. ++ (read_function_info, build_dwarf_data): Likewise. ++ * elf.c (elf_initialize_syminfo): Likewise. ++ * Makefile.am (libbacktrace_la_SOURCES): Add sort.c. ++ (stest_SOURCES, stest_LDADD): Define. ++ (check_PROGRAMS): Add stest. ++ ++2014-02-07 Misty De Meo ++ ++ PR target/58710 ++ * configure.ac: Use AC_LINK_IFELSE in check for ++ _Unwind_GetIPInfo. ++ * configure: Regenerate. ++ ++2014-01-02 Richard Sandiford ++ ++ Update copyright years ++ ++2013-12-06 Jakub Jelinek ++ ++ * elf.c (ET_DYN): Undefine and define again. ++ (elf_add): Add exe argument, if true and ehdr.e_type is ET_DYN, ++ return early -1 without closing the descriptor. ++ (struct phdr_data): Add exe_descriptor. ++ (phdr_callback): If pd->exe_descriptor is not -1, for very first ++ call if dlpi_name is NULL just call elf_add with the exe_descriptor, ++ otherwise backtrace_close the exe_descriptor if not -1. Adjust ++ call to elf_add. ++ (backtrace_initialize): Adjust call to elf_add. If it returns ++ -1, set pd.exe_descriptor to descriptor, otherwise set it to -1. ++ ++2013-12-05 Ian Lance Taylor ++ ++ * alloc.c (backtrace_vector_finish): Add error_callback and data ++ parameters. Call backtrace_vector_release. Return address base. ++ * mmap.c (backtrace_vector_finish): Add error_callback and data ++ parameters. Return address base. ++ * dwarf.c (read_function_info): Get new address base from ++ backtrace_vector_finish. ++ * internal.h (backtrace_vector_finish): Update declaration. ++ ++2013-11-27 Ian Lance Taylor ++ ++ * dwarf.c (find_address_ranges): New static function, broken out ++ of build_address_map. ++ (build_address_map): Call it. ++ * btest.c (check): Check for missing filename or function, rather ++ than crashing. ++ (f3): Check that enough frames were returned. ++ ++2013-11-19 Jakub Jelinek ++ ++ * backtrace.h (backtrace_syminfo_callback): Add symsize argument. ++ * elf.c (elf_syminfo): Pass 0 or sym->size to the callback as ++ last argument. ++ * btest.c (struct symdata): Add size field. ++ (callback_three): Add symsize argument. Copy it to the data->size ++ field. ++ (f23): Set symdata.size to 0. ++ (test5): Likewise. If sizeof (int) > 1, lookup address of ++ ((uintptr_t) &global) + 1. Verify symdata.val and symdata.size ++ values. ++ ++ * atomic.c: Include sys/types.h. ++ ++2013-11-18 Ian Lance Taylor ++ ++ * configure.ac: Check for support of __atomic extensions. ++ * internal.h: Declare or #define atomic functions for use in ++ backtrace code. ++ * atomic.c: New file. ++ * dwarf.c (dwarf_lookup_pc): Use atomic functions. ++ (dwarf_fileline, backtrace_dwarf_add): Likewise. ++ * elf.c (elf_add_syminfo_data, elf_syminfo): Likewise. ++ (backtrace_initialize): Likewise. ++ * fileline.c (fileline_initialize): Likewise. ++ * Makefile.am (libbacktrace_la_SOURCES): Add atomic.c. ++ * configure, config.h.in, Makefile.in: Rebuild. ++ ++2013-11-18 Jakub Jelinek ++ ++ * elf.c (SHN_UNDEF): Define. ++ (elf_initialize_syminfo): Add base_address argument. Ignore symbols ++ with st_shndx == SHN_UNDEF. Add base_address to address fields. ++ (elf_add): Adjust caller. ++ ++ * elf.c (phdr_callback): Process info->dlpi_addr == 0 normally. ++ ++2013-11-16 Ian Lance Taylor ++ ++ * backtrace.h (backtrace_create_state): Correct comment about ++ threading. ++ ++2013-11-15 Ian Lance Taylor ++ ++ * backtrace.h (backtrace_syminfo): Update comment and parameter ++ name to take any address, not just a PC value. ++ * elf.c (STT_OBJECT): Define. ++ (elf_nosyms): Rename parameter pc to addr. ++ (elf_symbol_search): Rename local variable pc to addr. ++ (elf_initialize_syminfo): Add STT_OBJECT symbols to elf_symbols. ++ (elf_syminfo): Rename parameter pc to addr. ++ * btest.c (global): New global variable. ++ (test5): New test. ++ (main): Call test5. ++ ++2013-10-17 Ian Lance Taylor ++ ++ * elf.c (elf_add): Don't get the wrong offsets if a debug section ++ is missing. ++ ++2013-10-15 David Malcolm ++ ++ * configure.ac: Add --enable-host-shared, setting up ++ pre-existing PIC_FLAG variable within Makefile.am et al. ++ * configure: Regenerate. ++ ++2013-09-20 Alan Modra ++ ++ * configure: Regenerate. ++ ++2013-07-23 Alexander Monakov ++ ++ * elf.c (elf_syminfo): Loop over the elf_syminfo_data chain. ++ ++2013-07-23 Alexander Monakov ++ ++ * elf.c (backtrace_initialize): Pass elf_fileline_fn to ++ dl_iterate_phdr callbacks. ++ ++2013-03-25 Ian Lance Taylor ++ ++ * alloc.c: #include . ++ * mmap.c: Likewise. ++ ++2013-01-31 Ian Lance Taylor ++ ++ * dwarf.c (read_function_info): Permit fvec parameter to be NULL. ++ (dwarf_lookup_pc): Don't use ddata->fvec if threaded. ++ ++2013-01-25 Jakub Jelinek ++ ++ PR other/56076 ++ * dwarf.c (read_line_header): Don't crash if DW_AT_comp_dir ++ attribute was not seen. ++ ++2013-01-16 Ian Lance Taylor ++ ++ * dwarf.c (struct unit): Add filename and abs_filename fields. ++ (build_address_map): Set new fields when reading unit. ++ (dwarf_lookup_pc): If we don't find an entry in the line table, ++ just return the main file name. ++ ++2013-01-14 Richard Sandiford ++ ++ Update copyright years. ++ ++2013-01-01 Ian Lance Taylor ++ ++ PR bootstrap/54834 ++ * Makefile.am (AM_CPPFLAGS): Remove -I ../gcc/include and -I ++ $(MULTIBUILDTOP)/../../gcc/include. ++ * Makefile.in: Rebuild. ++ ++2013-01-01 Ian Lance Taylor ++ ++ PR other/55536 ++ * mmap.c (backtrace_alloc): Don't call sync functions if not ++ threaded. ++ (backtrace_free): Likewise. ++ ++2012-12-12 John David Anglin ++ ++ * mmapio.c: Define MAP_FAILED if not defined. ++ ++2012-12-11 Jakub Jelinek ++ ++ PR bootstrap/54926 ++ * Makefile.am (AM_CFLAGS): Remove -frandom-seed=$@. ++ * configure.ac: If --with-target-subdir, add -frandom-seed=$@ ++ to EXTRA_FLAGS unconditionally, otherwise check whether the compiler ++ accepts it. ++ * Makefile.in: Regenerated. ++ * configure: Regenerated. ++ ++2012-12-07 Jakub Jelinek ++ ++ PR bootstrap/54926 ++ * Makefile.am (AM_CFLAGS): Add -frandom-seed=$@. ++ * Makefile.in: Regenerated. ++ ++2012-11-20 Ian Lance Taylor ++ ++ * dwarf.c (read_attribute): Always clear val. ++ ++2012-11-13 Ian Lance Taylor ++ ++ PR other/55312 ++ * configure.ac: Only add -Werror if building a target library. ++ * configure: Rebuild. ++ ++2012-11-12 Ian Lance Taylor ++ Rainer Orth ++ Gerald Pfeifer ++ ++ * configure.ac: Check for getexecname. ++ * fileline.c: #include . Define getexecname if not ++ available. ++ (fileline_initialize): Try to find the executable in a few ++ different ways. ++ * print.c (error_callback): Only print the filename if it came ++ from the backtrace state. ++ * configure, config.h.in: Rebuild. ++ ++2012-10-29 Ian Lance Taylor ++ ++ * mmap.c (backtrace_vector_release): Correct last patch: add ++ aligned, not size. ++ ++2012-10-29 Ian Lance Taylor ++ ++ * mmap.c (backtrace_vector_release): Make sure freed block is ++ aligned on 8-byte boundary. ++ ++2012-10-26 Ian Lance Taylor ++ ++ PR other/55087 ++ * posix.c (backtrace_open): Add does_not_exist parameter. ++ * elf.c (phdr_callback): Do not warn if shared library could not ++ be opened. ++ * fileline.c (fileline_initialize): Update calls to ++ backtrace_open. ++ * internal.h (backtrace_open): Update declaration. ++ ++2012-10-26 Jack Howarth ++ ++ PR target/55061 ++ * configure.ac: Check for _Unwind_GetIPInfo function declaration. ++ * configure: Regenerate. ++ ++2012-10-24 Ian Lance Taylor ++ ++ PR target/55061 ++ * configure.ac: Check whether -funwind-tables option works. ++ * configure: Rebuild. ++ ++2012-10-11 Ian Lance Taylor ++ ++ * configure.ac: Do not use dl_iterate_phdr on Solaris 10. ++ * configure: Rebuild. ++ ++2012-10-10 Ian Lance Taylor ++ ++ * elf.c: Rename all Elf typedefs to start with b_elf, and be all ++ lower case. ++ ++2012-10-10 Hans-Peter Nilsson ++ ++ * elf.c (elf_add_syminfo_data): Add casts to avoid warning. ++ ++2012-10-09 Ian Lance Taylor ++ ++ * dwarf.c (dwarf_fileline): Add cast to avoid warning. ++ (backtrace_dwarf_add): Likewise. ++ ++2012-10-09 Ian Lance Taylor ++ ++ Add support for tracing through shared libraries. ++ * configure.ac: Check for link.h and dl_iterate_phdr. ++ * elf.c: #include if system has dl_iterate_phdr. #undef ++ ELF macros before #defining them. ++ (dl_phdr_info, dl_iterate_phdr): Define if system does not have ++ dl_iterate_phdr. ++ (struct elf_syminfo_data): Add next field. ++ (elf_initialize_syminfo): Initialize next field. ++ (elf_add_syminfo_data): New static function. ++ (elf_add): New static function, broken out of ++ backtrace_initialize. Call backtrace_dwarf_add instead of ++ backtrace_dwarf_initialize. ++ (struct phdr_data): Define. ++ (phdr_callback): New static function. ++ (backtrace_initialize): Call elf_add. ++ * dwarf.c (struct dwarf_data): Add next and base_address fields. ++ (add_unit_addr): Add base_address parameter. Change all callers. ++ (add_unit_ranges, build_address_map): Likewise. ++ (add_line): Add ddata parameter. Change all callers. ++ (read_line_program, add_function_range): Likewise. ++ (dwarf_lookup_pc): New static function, broken out of ++ dwarf_fileline. ++ (dwarf_fileline): Call dwarf_lookup_pc. ++ (build_dwarf_data): New static function. ++ (backtrace_dwarf_add): New function. ++ (backtrace_dwarf_initialize): Remove. ++ * internal.h (backtrace_dwarf_initialize): Don't declare. ++ (backtrace_dwarf_add): Declare. ++ * configure, config.h.in: Rebuild. ++ ++2012-10-04 Gerald Pfeifer ++ ++ * btest.c (f23): Avoid uninitialized variable warning. ++ ++2012-10-04 Ian Lance Taylor ++ ++ * dwarf.c: If the system header files do not declare strnlen, ++ provide our own version. ++ ++2012-10-03 Ian Lance Taylor ++ ++ * dwarf.c (read_uleb128): Fix overflow test. ++ (read_sleb128): Likewise. ++ (build_address_map): Don't change unit_buf.start. ++ ++2012-10-02 Uros Bizjak ++ ++ PR other/54761 ++ * configure.ac (EXTRA_FLAGS): New. ++ * Makefile.am (AM_FLAGS): Add $(EXTRA_FLAGS). ++ * configure, Makefile.in: Regenerate. ++ ++2012-09-29 Ian Lance Taylor ++ ++ PR other/54749 ++ * fileline.c (fileline_initialize): Pass errnum as -1 when ++ reporting that we could not read executable information after a ++ previous failure. ++ ++2012-09-27 Ian Lance Taylor ++ ++ PR bootstrap/54732 ++ * configure.ac: Add no-dependencies to AM_INIT_AUTOMAKE. ++ * Makefile.am: Add dependencies for all objects. ++ * configure, aclocal.m4, Makefile.in: Rebuild. ++ ++2012-09-27 Ian Lance Taylor ++ ++ PR other/54726 ++ * elf.c (backtrace_initialize): Set *fileln_fn, not ++ state->fileln_fn. ++ ++2012-09-19 Ian Lance Taylor ++ ++ * configure.ac: Only use GCC_CHECK_UNWIND_GETIPINFO when compiled ++ as a target library. ++ * configure: Rebuild. ++ ++2012-09-19 Rainer Orth ++ Ian Lance Taylor ++ ++ * configure.ac (GCC_HEADER_STDINT): Invoke. ++ * backtrace.h: If we can't find , use "gstdint.h". ++ * btest.c: Don't include . ++ * dwarf.c: Likewise. ++ * configure, aclocal.m4, Makefile.in, config.h.in: Rebuild. ++ ++2012-09-18 Ian Lance Taylor ++ ++ PR bootstrap/54623 ++ * Makefile.am (AM_CPPFLAGS): Define. ++ (AM_CFLAGS): Remove -I options. ++ * Makefile.in: Rebuild. ++ ++2012-09-18 Ian Lance Taylor ++ ++ * posix.c (O_BINARY): Define if not defined. ++ (backtrace_open): Pass O_BINARY to open. Only call fcntl if ++ HAVE_FCNTL is defined. ++ * configure.ac: Test for the fcntl function. ++ * configure, config.h.in: Rebuild. ++ ++2012-09-18 Ian Lance Taylor ++ ++ * btest.c (test1, test2, test3, test4): Add the unused attribute. ++ ++2012-09-18 Ian Lance Taylor ++ ++ * dwarf.c: Correct test of HAVE_DECL_STRNLEN. ++ ++2012-09-18 Ian Lance Taylor ++ ++ * configure.ac: Add AC_USE_SYSTEM_EXTENSIONS. ++ * mmapio.c: Don't define _GNU_SOURCE. ++ * configure, config.h.in: Rebuild. ++ ++2012-09-18 Ian Lance Taylor ++ ++ * configure.ac: Check whether strnlen is declared. ++ * dwarf.c: Declare strnlen if not declared. ++ * configure, config.h.in: Rebuild. ++ ++2012-09-18 Rainer Orth ++ ++ * fileline.c: Include . ++ * mmap.c: Likewise. ++ ++2012-09-17 Ian Lance Taylor ++ ++ PR bootstrap/54611 ++ * nounwind.c (backtrace_full): Rename from backtrace. Add state ++ parameter. ++ ++2012-09-17 Gerald Pfeifer ++ ++ PR bootstrap/54611 ++ * nounwind.c (backtrace_simple): Add state parameter. ++ ++2012-09-17 Ian Lance Taylor ++ ++ PR bootstrap/54609 ++ * unknown.c (unknown_fileline): Add state parameter, remove ++ fileline_data parameter, name error_callback parameter. ++ (backtrace_initialize): Add state parameter. ++ ++2012-09-17 Ian Lance Taylor ++ ++ * Initial implementation. ++ ++Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ ++Copying and distribution of this file, with or without modification, ++are permitted in any medium without royalty provided the copyright ++notice and this notice are preserved. diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/ChangeLog.jit index 000000000,000000000..6b60e3b3b new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/ChangeLog.jit @@@ -1,0 -1,0 +1,14 @@@ ++2014-09-24 David Malcolm ++ ++ * ChangeLog.jit: Add copyright footer. ++ ++2013-10-03 David Malcolm ++ ++ * configure.ac: Add --enable-host-shared. ++ * configure: Regenerate. ++ ++Copyright (C) 2013-2014 Free Software Foundation, Inc. ++ ++Copying and distribution of this file, with or without modification, ++are permitted in any medium without royalty provided the copyright ++notice and this notice are preserved. diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/Makefile.am index 000000000,000000000..61aec4474 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/Makefile.am @@@ -1,0 -1,0 +1,136 @@@ ++# Makefile.am -- Backtrace Makefile. ++# Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ ++# Redistribution and use in source and binary forms, with or without ++# modification, are permitted provided that the following conditions are ++# met: ++ ++# (1) Redistributions of source code must retain the above copyright ++# notice, this list of conditions and the following disclaimer. ++ ++# (2) Redistributions in binary form must reproduce the above copyright ++# notice, this list of conditions and the following disclaimer in ++# the documentation and/or other materials provided with the ++# distribution. ++ ++# (3) The name of the author may not be used to ++# endorse or promote products derived from this software without ++# specific prior written permission. ++ ++# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++# POSSIBILITY OF SUCH DAMAGE. ++ ++ACLOCAL_AMFLAGS = -I .. -I ../config ++ ++AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \ ++ -I ../libgcc ++ ++AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG) ++ ++noinst_LTLIBRARIES = libbacktrace.la ++ ++libbacktrace_la_SOURCES = \ ++ backtrace.h \ ++ atomic.c \ ++ dwarf.c \ ++ fileline.c \ ++ internal.h \ ++ posix.c \ ++ print.c \ ++ sort.c \ ++ state.c ++ ++BACKTRACE_FILES = \ ++ backtrace.c \ ++ simple.c \ ++ nounwind.c ++ ++FORMAT_FILES = \ ++ elf.c \ ++ pecoff.c \ ++ unknown.c ++ ++VIEW_FILES = \ ++ read.c \ ++ mmapio.c ++ ++ALLOC_FILES = \ ++ alloc.c \ ++ mmap.c ++ ++EXTRA_libbacktrace_la_SOURCES = \ ++ $(BACKTRACE_FILES) \ ++ $(FORMAT_FILES) \ ++ $(VIEW_FILES) \ ++ $(ALLOC_FILES) ++ ++libbacktrace_la_LIBADD = \ ++ $(BACKTRACE_FILE) \ ++ $(FORMAT_FILE) \ ++ $(VIEW_FILE) \ ++ $(ALLOC_FILE) ++ ++libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD) ++ ++# Testsuite. ++ ++check_PROGRAMS = ++ ++TESTS = $(check_PROGRAMS) ++ ++if NATIVE ++ ++btest_SOURCES = btest.c ++btest_CFLAGS = $(AM_CFLAGS) -g -O ++btest_LDADD = libbacktrace.la ++ ++check_PROGRAMS += btest ++ ++stest_SOURCES = stest.c ++stest_LDADD = libbacktrace.la ++ ++check_PROGRAMS += stest ++ ++endif NATIVE ++ ++# We can't use automake's automatic dependency tracking, because it ++# breaks when using bootstrap-lean. Automatic dependency tracking ++# with GCC bootstrap will cause some of the objects to depend on ++# header files in prev-gcc/include, e.g., stddef.h and stdarg.h. When ++# using bootstrap-lean, prev-gcc is removed after each stage. When ++# running "make install", those header files will be gone, causing the ++# library to be rebuilt at install time. That may not succeed. ++ ++# These manual dependencies do not include dependencies on unwind.h, ++# even though that is part of GCC, because where to find it depends on ++# whether we are being built as a host library or a target library. ++ ++INCDIR = $(top_srcdir)/../include ++alloc.lo: config.h backtrace.h internal.h ++backtrace.lo: config.h backtrace.h internal.h ++btest.lo: (INCDIR)/filenames.h backtrace.h backtrace-supported.h ++dwarf.lo: config.h $(INCDIR)/dwarf2.h $(INCDIR)/dwarf2.def \ ++ $(INCDIR)/filenames.h backtrace.h internal.h ++elf.lo: config.h backtrace.h internal.h ++fileline.lo: config.h backtrace.h internal.h ++mmap.lo: config.h backtrace.h internal.h ++mmapio.lo: config.h backtrace.h internal.h ++nounwind.lo: config.h internal.h ++pecoff.lo: config.h backtrace.h internal.h ++posix.lo: config.h backtrace.h internal.h ++print.lo: config.h backtrace.h internal.h ++read.lo: config.h backtrace.h internal.h ++simple.lo: config.h backtrace.h internal.h ++sort.lo: config.h backtrace.h internal.h ++stest.lo: config.h backtrace.h internal.h ++state.lo: config.h backtrace.h backtrace-supported.h internal.h ++unknown.lo: config.h backtrace.h internal.h diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/Makefile.in index 000000000,000000000..de74b5d09 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/Makefile.in @@@ -1,0 -1,0 +1,770 @@@ ++# Makefile.in generated by automake 1.11.6 from Makefile.am. ++# @configure_input@ ++ ++# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, ++# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software ++# Foundation, Inc. ++# This Makefile.in is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without ++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A ++# PARTICULAR PURPOSE. ++ ++@SET_MAKE@ ++ ++# Makefile.am -- Backtrace Makefile. ++# Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ ++# Redistribution and use in source and binary forms, with or without ++# modification, are permitted provided that the following conditions are ++# met: ++ ++# (1) Redistributions of source code must retain the above copyright ++# notice, this list of conditions and the following disclaimer. ++ ++# (2) Redistributions in binary form must reproduce the above copyright ++# notice, this list of conditions and the following disclaimer in ++# the documentation and/or other materials provided with the ++# distribution. ++ ++# (3) The name of the author may not be used to ++# endorse or promote products derived from this software without ++# specific prior written permission. ++ ++# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++# POSSIBILITY OF SUCH DAMAGE. ++ ++VPATH = @srcdir@ ++am__make_dryrun = \ ++ { \ ++ am__dry=no; \ ++ case $$MAKEFLAGS in \ ++ *\\[\ \ ]*) \ ++ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ ++ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ ++ *) \ ++ for am__flg in $$MAKEFLAGS; do \ ++ case $$am__flg in \ ++ *=*|--*) ;; \ ++ *n*) am__dry=yes; break;; \ ++ esac; \ ++ done;; \ ++ esac; \ ++ test $$am__dry = yes; \ ++ } ++pkgdatadir = $(datadir)/@PACKAGE@ ++pkgincludedir = $(includedir)/@PACKAGE@ ++pkglibdir = $(libdir)/@PACKAGE@ ++pkglibexecdir = $(libexecdir)/@PACKAGE@ ++am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd ++install_sh_DATA = $(install_sh) -c -m 644 ++install_sh_PROGRAM = $(install_sh) -c ++install_sh_SCRIPT = $(install_sh) -c ++INSTALL_HEADER = $(INSTALL_DATA) ++transform = $(program_transform_name) ++NORMAL_INSTALL = : ++PRE_INSTALL = : ++POST_INSTALL = : ++NORMAL_UNINSTALL = : ++PRE_UNINSTALL = : ++POST_UNINSTALL = : ++build_triplet = @build@ ++host_triplet = @host@ ++target_triplet = @target@ ++check_PROGRAMS = $(am__EXEEXT_1) ++@NATIVE_TRUE@am__append_1 = btest stest ++subdir = . ++DIST_COMMON = README ChangeLog $(srcdir)/Makefile.in \ ++ $(srcdir)/Makefile.am $(top_srcdir)/configure \ ++ $(am__configure_deps) $(srcdir)/config.h.in \ ++ $(srcdir)/../mkinstalldirs $(srcdir)/backtrace-supported.h.in ++ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ++am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ ++ $(top_srcdir)/../config/multi.m4 \ ++ $(top_srcdir)/../config/override.m4 \ ++ $(top_srcdir)/../config/stdint.m4 \ ++ $(top_srcdir)/../config/unwind_ipinfo.m4 \ ++ $(top_srcdir)/../config/warnings.m4 \ ++ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ ++ $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \ ++ $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac ++am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ ++ $(ACLOCAL_M4) ++am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ ++ configure.lineno config.status.lineno ++mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs ++CONFIG_HEADER = config.h ++CONFIG_CLEAN_FILES = backtrace-supported.h ++CONFIG_CLEAN_VPATH_FILES = ++LTLIBRARIES = $(noinst_LTLIBRARIES) ++am__DEPENDENCIES_1 = ++am_libbacktrace_la_OBJECTS = atomic.lo dwarf.lo fileline.lo posix.lo \ ++ print.lo sort.lo state.lo ++libbacktrace_la_OBJECTS = $(am_libbacktrace_la_OBJECTS) ++@NATIVE_TRUE@am__EXEEXT_1 = btest$(EXEEXT) stest$(EXEEXT) ++@NATIVE_TRUE@am_btest_OBJECTS = btest-btest.$(OBJEXT) ++btest_OBJECTS = $(am_btest_OBJECTS) ++@NATIVE_TRUE@btest_DEPENDENCIES = libbacktrace.la ++btest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ ++ --mode=link $(CCLD) $(btest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ ++ $(LDFLAGS) -o $@ ++@NATIVE_TRUE@am_stest_OBJECTS = stest.$(OBJEXT) ++stest_OBJECTS = $(am_stest_OBJECTS) ++@NATIVE_TRUE@stest_DEPENDENCIES = libbacktrace.la ++DEFAULT_INCLUDES = -I.@am__isrc@ ++depcomp = ++am__depfiles_maybe = ++COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ ++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) ++LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ ++ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ ++ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) ++CCLD = $(CC) ++LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ ++ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ ++ $(LDFLAGS) -o $@ ++SOURCES = $(libbacktrace_la_SOURCES) $(EXTRA_libbacktrace_la_SOURCES) \ ++ $(btest_SOURCES) $(stest_SOURCES) ++MULTISRCTOP = ++MULTIBUILDTOP = ++MULTIDIRS = ++MULTISUBDIR = ++MULTIDO = true ++MULTICLEAN = true ++am__can_run_installinfo = \ ++ case $$AM_UPDATE_INFO_DIR in \ ++ n|no|NO) false;; \ ++ *) (install-info --version) >/dev/null 2>&1;; \ ++ esac ++ETAGS = etags ++CTAGS = ctags ++am__tty_colors = \ ++red=; grn=; lgn=; blu=; std= ++ACLOCAL = @ACLOCAL@ ++ALLOC_FILE = @ALLOC_FILE@ ++AMTAR = @AMTAR@ ++AR = @AR@ ++AUTOCONF = @AUTOCONF@ ++AUTOHEADER = @AUTOHEADER@ ++AUTOMAKE = @AUTOMAKE@ ++AWK = @AWK@ ++BACKTRACE_FILE = @BACKTRACE_FILE@ ++BACKTRACE_SUPPORTED = @BACKTRACE_SUPPORTED@ ++BACKTRACE_SUPPORTS_DATA = @BACKTRACE_SUPPORTS_DATA@ ++BACKTRACE_SUPPORTS_THREADS = @BACKTRACE_SUPPORTS_THREADS@ ++BACKTRACE_USES_MALLOC = @BACKTRACE_USES_MALLOC@ ++CC = @CC@ ++CFLAGS = @CFLAGS@ ++CPP = @CPP@ ++CPPFLAGS = @CPPFLAGS@ ++CYGPATH_W = @CYGPATH_W@ ++DEFS = @DEFS@ ++DSYMUTIL = @DSYMUTIL@ ++DUMPBIN = @DUMPBIN@ ++ECHO_C = @ECHO_C@ ++ECHO_N = @ECHO_N@ ++ECHO_T = @ECHO_T@ ++EGREP = @EGREP@ ++EXEEXT = @EXEEXT@ ++EXTRA_FLAGS = @EXTRA_FLAGS@ ++FGREP = @FGREP@ ++FORMAT_FILE = @FORMAT_FILE@ ++GREP = @GREP@ ++INSTALL = @INSTALL@ ++INSTALL_DATA = @INSTALL_DATA@ ++INSTALL_PROGRAM = @INSTALL_PROGRAM@ ++INSTALL_SCRIPT = @INSTALL_SCRIPT@ ++INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ ++LD = @LD@ ++LDFLAGS = @LDFLAGS@ ++LIBOBJS = @LIBOBJS@ ++LIBS = @LIBS@ ++LIBTOOL = @LIBTOOL@ ++LIPO = @LIPO@ ++LN_S = @LN_S@ ++LTLIBOBJS = @LTLIBOBJS@ ++MAINT = @MAINT@ ++MAKEINFO = @MAKEINFO@ ++MKDIR_P = @MKDIR_P@ ++NM = @NM@ ++NMEDIT = @NMEDIT@ ++OBJDUMP = @OBJDUMP@ ++OBJEXT = @OBJEXT@ ++OTOOL = @OTOOL@ ++OTOOL64 = @OTOOL64@ ++PACKAGE = @PACKAGE@ ++PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ ++PACKAGE_NAME = @PACKAGE_NAME@ ++PACKAGE_STRING = @PACKAGE_STRING@ ++PACKAGE_TARNAME = @PACKAGE_TARNAME@ ++PACKAGE_URL = @PACKAGE_URL@ ++PACKAGE_VERSION = @PACKAGE_VERSION@ ++PATH_SEPARATOR = @PATH_SEPARATOR@ ++PIC_FLAG = @PIC_FLAG@ ++RANLIB = @RANLIB@ ++SED = @SED@ ++SET_MAKE = @SET_MAKE@ ++SHELL = @SHELL@ ++STRIP = @STRIP@ ++VERSION = @VERSION@ ++VIEW_FILE = @VIEW_FILE@ ++WARN_FLAGS = @WARN_FLAGS@ ++abs_builddir = @abs_builddir@ ++abs_srcdir = @abs_srcdir@ ++abs_top_builddir = @abs_top_builddir@ ++abs_top_srcdir = @abs_top_srcdir@ ++ac_ct_CC = @ac_ct_CC@ ++ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ ++am__leading_dot = @am__leading_dot@ ++am__tar = @am__tar@ ++am__untar = @am__untar@ ++bindir = @bindir@ ++build = @build@ ++build_alias = @build_alias@ ++build_cpu = @build_cpu@ ++build_os = @build_os@ ++build_vendor = @build_vendor@ ++builddir = @builddir@ ++datadir = @datadir@ ++datarootdir = @datarootdir@ ++docdir = @docdir@ ++dvidir = @dvidir@ ++exec_prefix = @exec_prefix@ ++host = @host@ ++host_alias = @host_alias@ ++host_cpu = @host_cpu@ ++host_os = @host_os@ ++host_vendor = @host_vendor@ ++htmldir = @htmldir@ ++includedir = @includedir@ ++infodir = @infodir@ ++install_sh = @install_sh@ ++libdir = @libdir@ ++libexecdir = @libexecdir@ ++libtool_VERSION = @libtool_VERSION@ ++localedir = @localedir@ ++localstatedir = @localstatedir@ ++mandir = @mandir@ ++mkdir_p = @mkdir_p@ ++multi_basedir = @multi_basedir@ ++oldincludedir = @oldincludedir@ ++pdfdir = @pdfdir@ ++prefix = @prefix@ ++program_transform_name = @program_transform_name@ ++psdir = @psdir@ ++sbindir = @sbindir@ ++sharedstatedir = @sharedstatedir@ ++srcdir = @srcdir@ ++sysconfdir = @sysconfdir@ ++target = @target@ ++target_alias = @target_alias@ ++target_cpu = @target_cpu@ ++target_os = @target_os@ ++target_vendor = @target_vendor@ ++top_build_prefix = @top_build_prefix@ ++top_builddir = @top_builddir@ ++top_srcdir = @top_srcdir@ ++ACLOCAL_AMFLAGS = -I .. -I ../config ++AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \ ++ -I ../libgcc ++ ++AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG) ++noinst_LTLIBRARIES = libbacktrace.la ++libbacktrace_la_SOURCES = \ ++ backtrace.h \ ++ atomic.c \ ++ dwarf.c \ ++ fileline.c \ ++ internal.h \ ++ posix.c \ ++ print.c \ ++ sort.c \ ++ state.c ++ ++BACKTRACE_FILES = \ ++ backtrace.c \ ++ simple.c \ ++ nounwind.c ++ ++FORMAT_FILES = \ ++ elf.c \ ++ pecoff.c \ ++ unknown.c ++ ++VIEW_FILES = \ ++ read.c \ ++ mmapio.c ++ ++ALLOC_FILES = \ ++ alloc.c \ ++ mmap.c ++ ++EXTRA_libbacktrace_la_SOURCES = \ ++ $(BACKTRACE_FILES) \ ++ $(FORMAT_FILES) \ ++ $(VIEW_FILES) \ ++ $(ALLOC_FILES) ++ ++libbacktrace_la_LIBADD = \ ++ $(BACKTRACE_FILE) \ ++ $(FORMAT_FILE) \ ++ $(VIEW_FILE) \ ++ $(ALLOC_FILE) ++ ++libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD) ++TESTS = $(check_PROGRAMS) ++@NATIVE_TRUE@btest_SOURCES = btest.c ++@NATIVE_TRUE@btest_CFLAGS = $(AM_CFLAGS) -g -O ++@NATIVE_TRUE@btest_LDADD = libbacktrace.la ++@NATIVE_TRUE@stest_SOURCES = stest.c ++@NATIVE_TRUE@stest_LDADD = libbacktrace.la ++ ++# We can't use automake's automatic dependency tracking, because it ++# breaks when using bootstrap-lean. Automatic dependency tracking ++# with GCC bootstrap will cause some of the objects to depend on ++# header files in prev-gcc/include, e.g., stddef.h and stdarg.h. When ++# using bootstrap-lean, prev-gcc is removed after each stage. When ++# running "make install", those header files will be gone, causing the ++# library to be rebuilt at install time. That may not succeed. ++ ++# These manual dependencies do not include dependencies on unwind.h, ++# even though that is part of GCC, because where to find it depends on ++# whether we are being built as a host library or a target library. ++INCDIR = $(top_srcdir)/../include ++all: config.h ++ $(MAKE) $(AM_MAKEFLAGS) all-am ++ ++.SUFFIXES: ++.SUFFIXES: .c .lo .o .obj ++am--refresh: Makefile ++ @: ++$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) ++ @for dep in $?; do \ ++ case '$(am__configure_deps)' in \ ++ *$$dep*) \ ++ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign --ignore-deps'; \ ++ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign --ignore-deps \ ++ && exit 0; \ ++ exit 1;; \ ++ esac; \ ++ done; \ ++ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign --ignore-deps Makefile'; \ ++ $(am__cd) $(top_srcdir) && \ ++ $(AUTOMAKE) --foreign --ignore-deps Makefile ++.PRECIOUS: Makefile ++Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status ++ @case '$?' in \ ++ *config.status*) \ ++ echo ' $(SHELL) ./config.status'; \ ++ $(SHELL) ./config.status;; \ ++ *) \ ++ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ ++ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ ++ esac; ++ ++$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) ++ $(SHELL) ./config.status --recheck ++ ++$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ++ $(am__cd) $(srcdir) && $(AUTOCONF) ++$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) ++ $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) ++$(am__aclocal_m4_deps): ++ ++config.h: stamp-h1 ++ @if test ! -f $@; then rm -f stamp-h1; else :; fi ++ @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi ++ ++stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status ++ @rm -f stamp-h1 ++ cd $(top_builddir) && $(SHELL) ./config.status config.h ++$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ++ ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) ++ rm -f stamp-h1 ++ touch $@ ++ ++distclean-hdr: ++ -rm -f config.h stamp-h1 ++backtrace-supported.h: $(top_builddir)/config.status $(srcdir)/backtrace-supported.h.in ++ cd $(top_builddir) && $(SHELL) ./config.status $@ ++ ++clean-noinstLTLIBRARIES: ++ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) ++ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ ++ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ ++ test "$$dir" != "$$p" || dir=.; \ ++ echo "rm -f \"$${dir}/so_locations\""; \ ++ rm -f "$${dir}/so_locations"; \ ++ done ++libbacktrace.la: $(libbacktrace_la_OBJECTS) $(libbacktrace_la_DEPENDENCIES) $(EXTRA_libbacktrace_la_DEPENDENCIES) ++ $(LINK) $(libbacktrace_la_OBJECTS) $(libbacktrace_la_LIBADD) $(LIBS) ++ ++clean-checkPROGRAMS: ++ @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ ++ echo " rm -f" $$list; \ ++ rm -f $$list || exit $$?; \ ++ test -n "$(EXEEXT)" || exit 0; \ ++ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ ++ echo " rm -f" $$list; \ ++ rm -f $$list ++btest$(EXEEXT): $(btest_OBJECTS) $(btest_DEPENDENCIES) $(EXTRA_btest_DEPENDENCIES) ++ @rm -f btest$(EXEEXT) ++ $(btest_LINK) $(btest_OBJECTS) $(btest_LDADD) $(LIBS) ++stest$(EXEEXT): $(stest_OBJECTS) $(stest_DEPENDENCIES) $(EXTRA_stest_DEPENDENCIES) ++ @rm -f stest$(EXEEXT) ++ $(LINK) $(stest_OBJECTS) $(stest_LDADD) $(LIBS) ++ ++mostlyclean-compile: ++ -rm -f *.$(OBJEXT) ++ ++distclean-compile: ++ -rm -f *.tab.c ++ ++.c.o: ++ $(COMPILE) -c $< ++ ++.c.obj: ++ $(COMPILE) -c `$(CYGPATH_W) '$<'` ++ ++.c.lo: ++ $(LTCOMPILE) -c -o $@ $< ++ ++btest-btest.o: btest.c ++ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_CFLAGS) $(CFLAGS) -c -o btest-btest.o `test -f 'btest.c' || echo '$(srcdir)/'`btest.c ++ ++btest-btest.obj: btest.c ++ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(btest_CFLAGS) $(CFLAGS) -c -o btest-btest.obj `if test -f 'btest.c'; then $(CYGPATH_W) 'btest.c'; else $(CYGPATH_W) '$(srcdir)/btest.c'; fi` ++ ++mostlyclean-libtool: ++ -rm -f *.lo ++ ++clean-libtool: ++ -rm -rf .libs _libs ++ ++distclean-libtool: ++ -rm -f libtool config.lt ++ ++# GNU Make needs to see an explicit $(MAKE) variable in the command it ++# runs to enable its job server during parallel builds. Hence the ++# comments below. ++all-multi: ++ $(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do # $(MAKE) ++install-multi: ++ $(MULTIDO) $(AM_MAKEFLAGS) DO=install multi-do # $(MAKE) ++ ++mostlyclean-multi: ++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=mostlyclean multi-clean # $(MAKE) ++clean-multi: ++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=clean multi-clean # $(MAKE) ++distclean-multi: ++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean # $(MAKE) ++maintainer-clean-multi: ++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=maintainer-clean multi-clean # $(MAKE) ++ ++ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) ++ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ ++ unique=`for i in $$list; do \ ++ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ ++ done | \ ++ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ ++ END { if (nonempty) { for (i in files) print i; }; }'`; \ ++ mkid -fID $$unique ++tags: TAGS ++ ++TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ ++ $(TAGS_FILES) $(LISP) ++ set x; \ ++ here=`pwd`; \ ++ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ ++ unique=`for i in $$list; do \ ++ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ ++ done | \ ++ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ ++ END { if (nonempty) { for (i in files) print i; }; }'`; \ ++ shift; \ ++ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ ++ test -n "$$unique" || unique=$$empty_fix; \ ++ if test $$# -gt 0; then \ ++ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ ++ "$$@" $$unique; \ ++ else \ ++ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ ++ $$unique; \ ++ fi; \ ++ fi ++ctags: CTAGS ++CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ ++ $(TAGS_FILES) $(LISP) ++ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ ++ unique=`for i in $$list; do \ ++ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ ++ done | \ ++ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ ++ END { if (nonempty) { for (i in files) print i; }; }'`; \ ++ test -z "$(CTAGS_ARGS)$$unique" \ ++ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ ++ $$unique ++ ++GTAGS: ++ here=`$(am__cd) $(top_builddir) && pwd` \ ++ && $(am__cd) $(top_srcdir) \ ++ && gtags -i $(GTAGS_ARGS) "$$here" ++ ++distclean-tags: ++ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags ++ ++check-TESTS: $(TESTS) ++ @failed=0; all=0; xfail=0; xpass=0; skip=0; \ ++ srcdir=$(srcdir); export srcdir; \ ++ list=' $(TESTS) '; \ ++ $(am__tty_colors); \ ++ if test -n "$$list"; then \ ++ for tst in $$list; do \ ++ if test -f ./$$tst; then dir=./; \ ++ elif test -f $$tst; then dir=; \ ++ else dir="$(srcdir)/"; fi; \ ++ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ ++ all=`expr $$all + 1`; \ ++ case " $(XFAIL_TESTS) " in \ ++ *[\ \ ]$$tst[\ \ ]*) \ ++ xpass=`expr $$xpass + 1`; \ ++ failed=`expr $$failed + 1`; \ ++ col=$$red; res=XPASS; \ ++ ;; \ ++ *) \ ++ col=$$grn; res=PASS; \ ++ ;; \ ++ esac; \ ++ elif test $$? -ne 77; then \ ++ all=`expr $$all + 1`; \ ++ case " $(XFAIL_TESTS) " in \ ++ *[\ \ ]$$tst[\ \ ]*) \ ++ xfail=`expr $$xfail + 1`; \ ++ col=$$lgn; res=XFAIL; \ ++ ;; \ ++ *) \ ++ failed=`expr $$failed + 1`; \ ++ col=$$red; res=FAIL; \ ++ ;; \ ++ esac; \ ++ else \ ++ skip=`expr $$skip + 1`; \ ++ col=$$blu; res=SKIP; \ ++ fi; \ ++ echo "$${col}$$res$${std}: $$tst"; \ ++ done; \ ++ if test "$$all" -eq 1; then \ ++ tests="test"; \ ++ All=""; \ ++ else \ ++ tests="tests"; \ ++ All="All "; \ ++ fi; \ ++ if test "$$failed" -eq 0; then \ ++ if test "$$xfail" -eq 0; then \ ++ banner="$$All$$all $$tests passed"; \ ++ else \ ++ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ ++ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ ++ fi; \ ++ else \ ++ if test "$$xpass" -eq 0; then \ ++ banner="$$failed of $$all $$tests failed"; \ ++ else \ ++ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ ++ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ ++ fi; \ ++ fi; \ ++ dashes="$$banner"; \ ++ skipped=""; \ ++ if test "$$skip" -ne 0; then \ ++ if test "$$skip" -eq 1; then \ ++ skipped="($$skip test was not run)"; \ ++ else \ ++ skipped="($$skip tests were not run)"; \ ++ fi; \ ++ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ ++ dashes="$$skipped"; \ ++ fi; \ ++ report=""; \ ++ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ ++ report="Please report to $(PACKAGE_BUGREPORT)"; \ ++ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ ++ dashes="$$report"; \ ++ fi; \ ++ dashes=`echo "$$dashes" | sed s/./=/g`; \ ++ if test "$$failed" -eq 0; then \ ++ col="$$grn"; \ ++ else \ ++ col="$$red"; \ ++ fi; \ ++ echo "$${col}$$dashes$${std}"; \ ++ echo "$${col}$$banner$${std}"; \ ++ test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ ++ test -z "$$report" || echo "$${col}$$report$${std}"; \ ++ echo "$${col}$$dashes$${std}"; \ ++ test "$$failed" -eq 0; \ ++ else :; fi ++check-am: all-am ++ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) ++ $(MAKE) $(AM_MAKEFLAGS) check-TESTS ++check: check-am ++all-am: Makefile $(LTLIBRARIES) all-multi config.h ++installdirs: ++install: install-am ++install-exec: install-exec-am ++install-data: install-data-am ++uninstall: uninstall-am ++ ++install-am: all-am ++ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am ++ ++installcheck: installcheck-am ++install-strip: ++ if test -z '$(STRIP)'; then \ ++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ ++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ ++ install; \ ++ else \ ++ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ ++ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ ++ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ ++ fi ++mostlyclean-generic: ++ ++clean-generic: ++ ++distclean-generic: ++ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) ++ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) ++ ++maintainer-clean-generic: ++ @echo "This command is intended for maintainers to use" ++ @echo "it deletes files that may require special tools to rebuild." ++clean: clean-am clean-multi ++ ++clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ ++ clean-noinstLTLIBRARIES mostlyclean-am ++ ++distclean: distclean-am distclean-multi ++ -rm -f $(am__CONFIG_DISTCLEAN_FILES) ++ -rm -f Makefile ++distclean-am: clean-am distclean-compile distclean-generic \ ++ distclean-hdr distclean-libtool distclean-tags ++ ++dvi: dvi-am ++ ++dvi-am: ++ ++html: html-am ++ ++html-am: ++ ++info: info-am ++ ++info-am: ++ ++install-data-am: ++ ++install-dvi: install-dvi-am ++ ++install-dvi-am: ++ ++install-exec-am: install-multi ++ ++install-html: install-html-am ++ ++install-html-am: ++ ++install-info: install-info-am ++ ++install-info-am: ++ ++install-man: ++ ++install-pdf: install-pdf-am ++ ++install-pdf-am: ++ ++install-ps: install-ps-am ++ ++install-ps-am: ++ ++installcheck-am: ++ ++maintainer-clean: maintainer-clean-am maintainer-clean-multi ++ -rm -f $(am__CONFIG_DISTCLEAN_FILES) ++ -rm -rf $(top_srcdir)/autom4te.cache ++ -rm -f Makefile ++maintainer-clean-am: distclean-am maintainer-clean-generic ++ ++mostlyclean: mostlyclean-am mostlyclean-multi ++ ++mostlyclean-am: mostlyclean-compile mostlyclean-generic \ ++ mostlyclean-libtool ++ ++pdf: pdf-am ++ ++pdf-am: ++ ++ps: ps-am ++ ++ps-am: ++ ++uninstall-am: ++ ++.MAKE: all all-multi check-am clean-multi distclean-multi install-am \ ++ install-multi install-strip maintainer-clean-multi \ ++ mostlyclean-multi ++ ++.PHONY: CTAGS GTAGS all all-am all-multi am--refresh check check-TESTS \ ++ check-am clean clean-checkPROGRAMS clean-generic clean-libtool \ ++ clean-multi clean-noinstLTLIBRARIES ctags distclean \ ++ distclean-compile distclean-generic distclean-hdr \ ++ distclean-libtool distclean-multi distclean-tags dvi dvi-am \ ++ html html-am info info-am install install-am install-data \ ++ install-data-am install-dvi install-dvi-am install-exec \ ++ install-exec-am install-html install-html-am install-info \ ++ install-info-am install-man install-multi install-pdf \ ++ install-pdf-am install-ps install-ps-am install-strip \ ++ installcheck installcheck-am installdirs maintainer-clean \ ++ maintainer-clean-generic maintainer-clean-multi mostlyclean \ ++ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ ++ mostlyclean-multi pdf pdf-am ps ps-am tags uninstall \ ++ uninstall-am ++ ++alloc.lo: config.h backtrace.h internal.h ++backtrace.lo: config.h backtrace.h internal.h ++btest.lo: (INCDIR)/filenames.h backtrace.h backtrace-supported.h ++dwarf.lo: config.h $(INCDIR)/dwarf2.h $(INCDIR)/dwarf2.def \ ++ $(INCDIR)/filenames.h backtrace.h internal.h ++elf.lo: config.h backtrace.h internal.h ++fileline.lo: config.h backtrace.h internal.h ++mmap.lo: config.h backtrace.h internal.h ++mmapio.lo: config.h backtrace.h internal.h ++nounwind.lo: config.h internal.h ++pecoff.lo: config.h backtrace.h internal.h ++posix.lo: config.h backtrace.h internal.h ++print.lo: config.h backtrace.h internal.h ++read.lo: config.h backtrace.h internal.h ++simple.lo: config.h backtrace.h internal.h ++sort.lo: config.h backtrace.h internal.h ++stest.lo: config.h backtrace.h internal.h ++state.lo: config.h backtrace.h backtrace-supported.h internal.h ++unknown.lo: config.h backtrace.h internal.h ++ ++# Tell versions [3.59,3.63) of GNU make to not export all variables. ++# Otherwise a system limit (for SysV at least) may be exceeded. ++.NOEXPORT: diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/README index 000000000,000000000..e8b225745 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/README @@@ -1,0 -1,0 +1,23 @@@ ++The libbacktrace library ++Initially written by Ian Lance Taylor ++ ++The libbacktrace library may be linked into a program or library and ++used to produce symbolic backtraces. Sample uses would be to print a ++detailed backtrace when an error occurs or to gather detailed ++profiling information. ++ ++The libbacktrace library is provided under a BSD license. See the ++source files for the exact license text. ++ ++The public functions are declared and documented in the header file ++backtrace.h, which should be #include'd by a user of the library. ++ ++Building libbacktrace will generate a file backtrace-supported.h, ++which a user of the library may use to determine whether backtraces ++will work. See the source file backtrace-supported.h.in for the ++macros that it defines. ++ ++As of September 2012, libbacktrace only supports ELF executables with ++DWARF debugging information. The library is written to make it ++straightforward to add support for other object file and debugging ++formats. diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/aclocal.m4 index 000000000,000000000..8e84ddd1f new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/aclocal.m4 @@@ -1,0 -1,0 +1,683 @@@ ++# generated automatically by aclocal 1.11.6 -*- Autoconf -*- ++ ++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, ++# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, ++# Inc. ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY, to the extent permitted by law; without ++# even the implied warranty of MERCHANTABILITY or FITNESS FOR A ++# PARTICULAR PURPOSE. ++ ++m4_ifndef([AC_AUTOCONF_VERSION], ++ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl ++m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.64],, ++[m4_warning([this file was generated for autoconf 2.64. ++You have another version of autoconf. It may work, but is not guaranteed to. ++If you have problems, you may need to regenerate the build system entirely. ++To do so, use the procedure documented by the package, typically `autoreconf'.])]) ++ ++# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software ++# Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 1 ++ ++# AM_AUTOMAKE_VERSION(VERSION) ++# ---------------------------- ++# Automake X.Y traces this macro to ensure aclocal.m4 has been ++# generated from the m4 files accompanying Automake X.Y. ++# (This private macro should not be called outside this file.) ++AC_DEFUN([AM_AUTOMAKE_VERSION], ++[am__api_version='1.11' ++dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to ++dnl require some minimum version. Point them to the right macro. ++m4_if([$1], [1.11.6], [], ++ [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ++]) ++ ++# _AM_AUTOCONF_VERSION(VERSION) ++# ----------------------------- ++# aclocal traces this macro to find the Autoconf version. ++# This is a private macro too. Using m4_define simplifies ++# the logic in aclocal, which can simply ignore this definition. ++m4_define([_AM_AUTOCONF_VERSION], []) ++ ++# AM_SET_CURRENT_AUTOMAKE_VERSION ++# ------------------------------- ++# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. ++# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. ++AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], ++[AM_AUTOMAKE_VERSION([1.11.6])dnl ++m4_ifndef([AC_AUTOCONF_VERSION], ++ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl ++_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) ++ ++# AM_AUX_DIR_EXPAND -*- Autoconf -*- ++ ++# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 1 ++ ++# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets ++# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to ++# `$srcdir', `$srcdir/..', or `$srcdir/../..'. ++# ++# Of course, Automake must honor this variable whenever it calls a ++# tool from the auxiliary directory. The problem is that $srcdir (and ++# therefore $ac_aux_dir as well) can be either absolute or relative, ++# depending on how configure is run. This is pretty annoying, since ++# it makes $ac_aux_dir quite unusable in subdirectories: in the top ++# source directory, any form will work fine, but in subdirectories a ++# relative path needs to be adjusted first. ++# ++# $ac_aux_dir/missing ++# fails when called from a subdirectory if $ac_aux_dir is relative ++# $top_srcdir/$ac_aux_dir/missing ++# fails if $ac_aux_dir is absolute, ++# fails when called from a subdirectory in a VPATH build with ++# a relative $ac_aux_dir ++# ++# The reason of the latter failure is that $top_srcdir and $ac_aux_dir ++# are both prefixed by $srcdir. In an in-source build this is usually ++# harmless because $srcdir is `.', but things will broke when you ++# start a VPATH build or use an absolute $srcdir. ++# ++# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, ++# iff we strip the leading $srcdir from $ac_aux_dir. That would be: ++# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` ++# and then we would define $MISSING as ++# MISSING="\${SHELL} $am_aux_dir/missing" ++# This will work as long as MISSING is not called from configure, because ++# unfortunately $(top_srcdir) has no meaning in configure. ++# However there are other variables, like CC, which are often used in ++# configure, and could therefore not use this "fixed" $ac_aux_dir. ++# ++# Another solution, used here, is to always expand $ac_aux_dir to an ++# absolute PATH. The drawback is that using absolute paths prevent a ++# configured tree to be moved without reconfiguration. ++ ++AC_DEFUN([AM_AUX_DIR_EXPAND], ++[dnl Rely on autoconf to set up CDPATH properly. ++AC_PREREQ([2.50])dnl ++# expand $ac_aux_dir to an absolute path ++am_aux_dir=`cd $ac_aux_dir && pwd` ++]) ++ ++# AM_CONDITIONAL -*- Autoconf -*- ++ ++# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 ++# Free Software Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 9 ++ ++# AM_CONDITIONAL(NAME, SHELL-CONDITION) ++# ------------------------------------- ++# Define a conditional. ++AC_DEFUN([AM_CONDITIONAL], ++[AC_PREREQ(2.52)dnl ++ ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], ++ [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl ++AC_SUBST([$1_TRUE])dnl ++AC_SUBST([$1_FALSE])dnl ++_AM_SUBST_NOTMAKE([$1_TRUE])dnl ++_AM_SUBST_NOTMAKE([$1_FALSE])dnl ++m4_define([_AM_COND_VALUE_$1], [$2])dnl ++if $2; then ++ $1_TRUE= ++ $1_FALSE='#' ++else ++ $1_TRUE='#' ++ $1_FALSE= ++fi ++AC_CONFIG_COMMANDS_PRE( ++[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then ++ AC_MSG_ERROR([[conditional "$1" was never defined. ++Usually this means the macro was only invoked conditionally.]]) ++fi])]) ++ ++# Do all the work for Automake. -*- Autoconf -*- ++ ++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, ++# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 16 ++ ++# This macro actually does too much. Some checks are only needed if ++# your package does certain things. But this isn't really a big deal. ++ ++# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) ++# AM_INIT_AUTOMAKE([OPTIONS]) ++# ----------------------------------------------- ++# The call with PACKAGE and VERSION arguments is the old style ++# call (pre autoconf-2.50), which is being phased out. PACKAGE ++# and VERSION should now be passed to AC_INIT and removed from ++# the call to AM_INIT_AUTOMAKE. ++# We support both call styles for the transition. After ++# the next Automake release, Autoconf can make the AC_INIT ++# arguments mandatory, and then we can depend on a new Autoconf ++# release and drop the old call support. ++AC_DEFUN([AM_INIT_AUTOMAKE], ++[AC_PREREQ([2.62])dnl ++dnl Autoconf wants to disallow AM_ names. We explicitly allow ++dnl the ones we care about. ++m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl ++AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl ++AC_REQUIRE([AC_PROG_INSTALL])dnl ++if test "`cd $srcdir && pwd`" != "`pwd`"; then ++ # Use -I$(srcdir) only when $(srcdir) != ., so that make's output ++ # is not polluted with repeated "-I." ++ AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl ++ # test to see if srcdir already configured ++ if test -f $srcdir/config.status; then ++ AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) ++ fi ++fi ++ ++# test whether we have cygpath ++if test -z "$CYGPATH_W"; then ++ if (cygpath --version) >/dev/null 2>/dev/null; then ++ CYGPATH_W='cygpath -w' ++ else ++ CYGPATH_W=echo ++ fi ++fi ++AC_SUBST([CYGPATH_W]) ++ ++# Define the identity of the package. ++dnl Distinguish between old-style and new-style calls. ++m4_ifval([$2], ++[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl ++ AC_SUBST([PACKAGE], [$1])dnl ++ AC_SUBST([VERSION], [$2])], ++[_AM_SET_OPTIONS([$1])dnl ++dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. ++m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, ++ [m4_fatal([AC_INIT should be called with package and version arguments])])dnl ++ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl ++ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl ++ ++_AM_IF_OPTION([no-define],, ++[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) ++ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl ++ ++# Some tools Automake needs. ++AC_REQUIRE([AM_SANITY_CHECK])dnl ++AC_REQUIRE([AC_ARG_PROGRAM])dnl ++AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) ++AM_MISSING_PROG(AUTOCONF, autoconf) ++AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) ++AM_MISSING_PROG(AUTOHEADER, autoheader) ++AM_MISSING_PROG(MAKEINFO, makeinfo) ++AC_REQUIRE([AM_PROG_INSTALL_SH])dnl ++AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl ++AC_REQUIRE([AM_PROG_MKDIR_P])dnl ++# We need awk for the "check" target. The system "awk" is bad on ++# some platforms. ++AC_REQUIRE([AC_PROG_AWK])dnl ++AC_REQUIRE([AC_PROG_MAKE_SET])dnl ++AC_REQUIRE([AM_SET_LEADING_DOT])dnl ++_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], ++ [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], ++ [_AM_PROG_TAR([v7])])]) ++_AM_IF_OPTION([no-dependencies],, ++[AC_PROVIDE_IFELSE([AC_PROG_CC], ++ [_AM_DEPENDENCIES(CC)], ++ [define([AC_PROG_CC], ++ defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl ++AC_PROVIDE_IFELSE([AC_PROG_CXX], ++ [_AM_DEPENDENCIES(CXX)], ++ [define([AC_PROG_CXX], ++ defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl ++AC_PROVIDE_IFELSE([AC_PROG_OBJC], ++ [_AM_DEPENDENCIES(OBJC)], ++ [define([AC_PROG_OBJC], ++ defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ++]) ++_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl ++dnl The `parallel-tests' driver may need to know about EXEEXT, so add the ++dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro ++dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. ++AC_CONFIG_COMMANDS_PRE(dnl ++[m4_provide_if([_AM_COMPILER_EXEEXT], ++ [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ++]) ++ ++dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not ++dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further ++dnl mangled by Autoconf and run in a shell conditional statement. ++m4_define([_AC_COMPILER_EXEEXT], ++m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) ++ ++ ++# When config.status generates a header, we must update the stamp-h file. ++# This file resides in the same directory as the config header ++# that is generated. The stamp files are numbered to have different names. ++ ++# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the ++# loop where config.status creates the headers, so we can generate ++# our stamp files there. ++AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], ++[# Compute $1's index in $config_headers. ++_am_arg=$1 ++_am_stamp_count=1 ++for _am_header in $config_headers :; do ++ case $_am_header in ++ $_am_arg | $_am_arg:* ) ++ break ;; ++ * ) ++ _am_stamp_count=`expr $_am_stamp_count + 1` ;; ++ esac ++done ++echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) ++ ++# Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, ++# Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 1 ++ ++# AM_PROG_INSTALL_SH ++# ------------------ ++# Define $install_sh. ++AC_DEFUN([AM_PROG_INSTALL_SH], ++[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl ++if test x"${install_sh}" != xset; then ++ case $am_aux_dir in ++ *\ * | *\ *) ++ install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; ++ *) ++ install_sh="\${SHELL} $am_aux_dir/install-sh" ++ esac ++fi ++AC_SUBST(install_sh)]) ++ ++# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- ++# From Jim Meyering ++ ++# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008, ++# 2011 Free Software Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 5 ++ ++# AM_MAINTAINER_MODE([DEFAULT-MODE]) ++# ---------------------------------- ++# Control maintainer-specific portions of Makefiles. ++# Default is to disable them, unless `enable' is passed literally. ++# For symmetry, `disable' may be passed as well. Anyway, the user ++# can override the default with the --enable/--disable switch. ++AC_DEFUN([AM_MAINTAINER_MODE], ++[m4_case(m4_default([$1], [disable]), ++ [enable], [m4_define([am_maintainer_other], [disable])], ++ [disable], [m4_define([am_maintainer_other], [enable])], ++ [m4_define([am_maintainer_other], [enable]) ++ m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) ++AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) ++ dnl maintainer-mode's default is 'disable' unless 'enable' is passed ++ AC_ARG_ENABLE([maintainer-mode], ++[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful ++ (and sometimes confusing) to the casual installer], ++ [USE_MAINTAINER_MODE=$enableval], ++ [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) ++ AC_MSG_RESULT([$USE_MAINTAINER_MODE]) ++ AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) ++ MAINT=$MAINTAINER_MODE_TRUE ++ AC_SUBST([MAINT])dnl ++] ++) ++ ++AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) ++ ++# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- ++ ++# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 ++# Free Software Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 6 ++ ++# AM_MISSING_PROG(NAME, PROGRAM) ++# ------------------------------ ++AC_DEFUN([AM_MISSING_PROG], ++[AC_REQUIRE([AM_MISSING_HAS_RUN]) ++$1=${$1-"${am_missing_run}$2"} ++AC_SUBST($1)]) ++ ++ ++# AM_MISSING_HAS_RUN ++# ------------------ ++# Define MISSING if not defined so far and test if it supports --run. ++# If it does, set am_missing_run to use it, otherwise, to nothing. ++AC_DEFUN([AM_MISSING_HAS_RUN], ++[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl ++AC_REQUIRE_AUX_FILE([missing])dnl ++if test x"${MISSING+set}" != xset; then ++ case $am_aux_dir in ++ *\ * | *\ *) ++ MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; ++ *) ++ MISSING="\${SHELL} $am_aux_dir/missing" ;; ++ esac ++fi ++# Use eval to expand $SHELL ++if eval "$MISSING --run true"; then ++ am_missing_run="$MISSING --run " ++else ++ am_missing_run= ++ AC_MSG_WARN([`missing' script is too old or missing]) ++fi ++]) ++ ++# Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, ++# Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 1 ++ ++# AM_PROG_MKDIR_P ++# --------------- ++# Check for `mkdir -p'. ++AC_DEFUN([AM_PROG_MKDIR_P], ++[AC_PREREQ([2.60])dnl ++AC_REQUIRE([AC_PROG_MKDIR_P])dnl ++dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, ++dnl while keeping a definition of mkdir_p for backward compatibility. ++dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. ++dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of ++dnl Makefile.ins that do not define MKDIR_P, so we do our own ++dnl adjustment using top_builddir (which is defined more often than ++dnl MKDIR_P). ++AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl ++case $mkdir_p in ++ [[\\/$]]* | ?:[[\\/]]*) ;; ++ */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; ++esac ++]) ++ ++# Helper functions for option handling. -*- Autoconf -*- ++ ++# Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software ++# Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 5 ++ ++# _AM_MANGLE_OPTION(NAME) ++# ----------------------- ++AC_DEFUN([_AM_MANGLE_OPTION], ++[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) ++ ++# _AM_SET_OPTION(NAME) ++# -------------------- ++# Set option NAME. Presently that only means defining a flag for this option. ++AC_DEFUN([_AM_SET_OPTION], ++[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) ++ ++# _AM_SET_OPTIONS(OPTIONS) ++# ------------------------ ++# OPTIONS is a space-separated list of Automake options. ++AC_DEFUN([_AM_SET_OPTIONS], ++[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) ++ ++# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) ++# ------------------------------------------- ++# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. ++AC_DEFUN([_AM_IF_OPTION], ++[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) ++ ++# Check to make sure that the build environment is sane. -*- Autoconf -*- ++ ++# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 ++# Free Software Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 5 ++ ++# AM_SANITY_CHECK ++# --------------- ++AC_DEFUN([AM_SANITY_CHECK], ++[AC_MSG_CHECKING([whether build environment is sane]) ++# Just in case ++sleep 1 ++echo timestamp > conftest.file ++# Reject unsafe characters in $srcdir or the absolute working directory ++# name. Accept space and tab only in the latter. ++am_lf=' ++' ++case `pwd` in ++ *[[\\\"\#\$\&\'\`$am_lf]]*) ++ AC_MSG_ERROR([unsafe absolute working directory name]);; ++esac ++case $srcdir in ++ *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) ++ AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; ++esac ++ ++# Do `set' in a subshell so we don't clobber the current shell's ++# arguments. Must try -L first in case configure is actually a ++# symlink; some systems play weird games with the mod time of symlinks ++# (eg FreeBSD returns the mod time of the symlink's containing ++# directory). ++if ( ++ set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` ++ if test "$[*]" = "X"; then ++ # -L didn't work. ++ set X `ls -t "$srcdir/configure" conftest.file` ++ fi ++ rm -f conftest.file ++ if test "$[*]" != "X $srcdir/configure conftest.file" \ ++ && test "$[*]" != "X conftest.file $srcdir/configure"; then ++ ++ # If neither matched, then we have a broken ls. This can happen ++ # if, for instance, CONFIG_SHELL is bash and it inherits a ++ # broken ls alias from the environment. This has actually ++ # happened. Such a system could not be considered "sane". ++ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken ++alias in your environment]) ++ fi ++ ++ test "$[2]" = conftest.file ++ ) ++then ++ # Ok. ++ : ++else ++ AC_MSG_ERROR([newly created file is older than distributed files! ++Check your system clock]) ++fi ++AC_MSG_RESULT(yes)]) ++ ++# Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 1 ++ ++# AM_PROG_INSTALL_STRIP ++# --------------------- ++# One issue with vendor `install' (even GNU) is that you can't ++# specify the program used to strip binaries. This is especially ++# annoying in cross-compiling environments, where the build's strip ++# is unlikely to handle the host's binaries. ++# Fortunately install-sh will honor a STRIPPROG variable, so we ++# always use install-sh in `make install-strip', and initialize ++# STRIPPROG with the value of the STRIP variable (set by the user). ++AC_DEFUN([AM_PROG_INSTALL_STRIP], ++[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl ++# Installed binaries are usually stripped using `strip' when the user ++# run `make install-strip'. However `strip' might not be the right ++# tool to use in cross-compilation environments, therefore Automake ++# will honor the `STRIP' environment variable to overrule this program. ++dnl Don't test for $cross_compiling = yes, because it might be `maybe'. ++if test "$cross_compiling" != no; then ++ AC_CHECK_TOOL([STRIP], [strip], :) ++fi ++INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" ++AC_SUBST([INSTALL_STRIP_PROGRAM])]) ++ ++# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 3 ++ ++# _AM_SUBST_NOTMAKE(VARIABLE) ++# --------------------------- ++# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. ++# This macro is traced by Automake. ++AC_DEFUN([_AM_SUBST_NOTMAKE]) ++ ++# AM_SUBST_NOTMAKE(VARIABLE) ++# -------------------------- ++# Public sister of _AM_SUBST_NOTMAKE. ++AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) ++ ++# Check how to create a tarball. -*- Autoconf -*- ++ ++# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. ++# ++# This file is free software; the Free Software Foundation ++# gives unlimited permission to copy and/or distribute it, ++# with or without modifications, as long as this notice is preserved. ++ ++# serial 2 ++ ++# _AM_PROG_TAR(FORMAT) ++# -------------------- ++# Check how to create a tarball in format FORMAT. ++# FORMAT should be one of `v7', `ustar', or `pax'. ++# ++# Substitute a variable $(am__tar) that is a command ++# writing to stdout a FORMAT-tarball containing the directory ++# $tardir. ++# tardir=directory && $(am__tar) > result.tar ++# ++# Substitute a variable $(am__untar) that extract such ++# a tarball read from stdin. ++# $(am__untar) < result.tar ++AC_DEFUN([_AM_PROG_TAR], ++[# Always define AMTAR for backward compatibility. Yes, it's still used ++# in the wild :-( We should find a proper way to deprecate it ... ++AC_SUBST([AMTAR], ['$${TAR-tar}']) ++m4_if([$1], [v7], ++ [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], ++ [m4_case([$1], [ustar],, [pax],, ++ [m4_fatal([Unknown tar format])]) ++AC_MSG_CHECKING([how to create a $1 tar archive]) ++# Loop over all known methods to create a tar archive until one works. ++_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' ++_am_tools=${am_cv_prog_tar_$1-$_am_tools} ++# Do not fold the above two line into one, because Tru64 sh and ++# Solaris sh will not grok spaces in the rhs of `-'. ++for _am_tool in $_am_tools ++do ++ case $_am_tool in ++ gnutar) ++ for _am_tar in tar gnutar gtar; ++ do ++ AM_RUN_LOG([$_am_tar --version]) && break ++ done ++ am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' ++ am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' ++ am__untar="$_am_tar -xf -" ++ ;; ++ plaintar) ++ # Must skip GNU tar: if it does not support --format= it doesn't create ++ # ustar tarball either. ++ (tar --version) >/dev/null 2>&1 && continue ++ am__tar='tar chf - "$$tardir"' ++ am__tar_='tar chf - "$tardir"' ++ am__untar='tar xf -' ++ ;; ++ pax) ++ am__tar='pax -L -x $1 -w "$$tardir"' ++ am__tar_='pax -L -x $1 -w "$tardir"' ++ am__untar='pax -r' ++ ;; ++ cpio) ++ am__tar='find "$$tardir" -print | cpio -o -H $1 -L' ++ am__tar_='find "$tardir" -print | cpio -o -H $1 -L' ++ am__untar='cpio -i -H $1 -d' ++ ;; ++ none) ++ am__tar=false ++ am__tar_=false ++ am__untar=false ++ ;; ++ esac ++ ++ # If the value was cached, stop now. We just wanted to have am__tar ++ # and am__untar set. ++ test -n "${am_cv_prog_tar_$1}" && break ++ ++ # tar/untar a dummy directory, and stop if the command works ++ rm -rf conftest.dir ++ mkdir conftest.dir ++ echo GrepMe > conftest.dir/file ++ AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) ++ rm -rf conftest.dir ++ if test -s conftest.tar; then ++ AM_RUN_LOG([$am__untar /dev/null 2>&1 && break ++ fi ++done ++rm -rf conftest.dir ++ ++AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) ++AC_MSG_RESULT([$am_cv_prog_tar_$1])]) ++AC_SUBST([am__tar]) ++AC_SUBST([am__untar]) ++]) # _AM_PROG_TAR ++ ++m4_include([../config/lead-dot.m4]) ++m4_include([../config/multi.m4]) ++m4_include([../config/override.m4]) ++m4_include([../config/stdint.m4]) ++m4_include([../config/unwind_ipinfo.m4]) ++m4_include([../config/warnings.m4]) ++m4_include([../libtool.m4]) ++m4_include([../ltoptions.m4]) ++m4_include([../ltsugar.m4]) ++m4_include([../ltversion.m4]) ++m4_include([../lt~obsolete.m4]) diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/alloc.c index 000000000,000000000..3333624a2 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/alloc.c @@@ -1,0 -1,0 +1,156 @@@ ++/* alloc.c -- Memory allocation without mmap. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++/* Allocation routines to use on systems that do not support anonymous ++ mmap. This implementation just uses malloc, which means that the ++ backtrace functions may not be safely invoked from a signal ++ handler. */ ++ ++/* Allocate memory like malloc. If ERROR_CALLBACK is NULL, don't ++ report an error. */ ++ ++void * ++backtrace_alloc (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ size_t size, backtrace_error_callback error_callback, ++ void *data) ++{ ++ void *ret; ++ ++ ret = malloc (size); ++ if (ret == NULL) ++ { ++ if (error_callback) ++ error_callback (data, "malloc", errno); ++ } ++ return ret; ++} ++ ++/* Free memory. */ ++ ++void ++backtrace_free (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ void *p, size_t size ATTRIBUTE_UNUSED, ++ backtrace_error_callback error_callback ATTRIBUTE_UNUSED, ++ void *data ATTRIBUTE_UNUSED) ++{ ++ free (p); ++} ++ ++/* Grow VEC by SIZE bytes. */ ++ ++void * ++backtrace_vector_grow (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ size_t size, backtrace_error_callback error_callback, ++ void *data, struct backtrace_vector *vec) ++{ ++ void *ret; ++ ++ if (size > vec->alc) ++ { ++ size_t alc; ++ void *base; ++ ++ if (vec->size == 0) ++ alc = 32 * size; ++ else if (vec->size >= 4096) ++ alc = vec->size + 4096; ++ else ++ alc = 2 * vec->size; ++ ++ if (alc < vec->size + size) ++ alc = vec->size + size; ++ ++ base = realloc (vec->base, alc); ++ if (base == NULL) ++ { ++ error_callback (data, "realloc", errno); ++ return NULL; ++ } ++ ++ vec->base = base; ++ vec->alc = alc - vec->size; ++ } ++ ++ ret = (char *) vec->base + vec->size; ++ vec->size += size; ++ vec->alc -= size; ++ return ret; ++} ++ ++/* Finish the current allocation on VEC. */ ++ ++void * ++backtrace_vector_finish (struct backtrace_state *state, ++ struct backtrace_vector *vec, ++ backtrace_error_callback error_callback, ++ void *data) ++{ ++ void *ret; ++ ++ /* With this allocator we call realloc in backtrace_vector_grow, ++ which means we can't easily reuse the memory here. So just ++ release it. */ ++ if (!backtrace_vector_release (state, vec, error_callback, data)) ++ return NULL; ++ ret = vec->base; ++ vec->base = NULL; ++ vec->size = 0; ++ vec->alc = 0; ++ return ret; ++} ++ ++/* Release any extra space allocated for VEC. */ ++ ++int ++backtrace_vector_release (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ struct backtrace_vector *vec, ++ backtrace_error_callback error_callback, ++ void *data) ++{ ++ vec->base = realloc (vec->base, vec->size); ++ if (vec->base == NULL) ++ { ++ error_callback (data, "realloc", errno); ++ return 0; ++ } ++ vec->alc = 0; ++ return 1; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/ansidecl.h index 000000000,000000000..08aeb1eeb new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/ansidecl.h @@@ -1,0 -1,0 +1,355 @@@ ++/* ANSI and traditional C compatability macros ++ Copyright (C) 1991-2015 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++This program is free software; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation; either version 2 of the License, or ++(at your option) any later version. ++ ++This program is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++You should have received a copy of the GNU General Public License ++along with this program; if not, write to the Free Software ++Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ ++ ++/* ANSI and traditional C compatibility macros ++ ++ ANSI C is assumed if __STDC__ is #defined. ++ ++ Macro ANSI C definition Traditional C definition ++ ----- ---- - ---------- ----------- - ---------- ++ PTR `void *' `char *' ++ const not defined `' ++ volatile not defined `' ++ signed not defined `' ++ ++ For ease of writing code which uses GCC extensions but needs to be ++ portable to other compilers, we provide the GCC_VERSION macro that ++ simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various ++ wrappers around __attribute__. Also, __extension__ will be #defined ++ to nothing if it doesn't work. See below. */ ++ ++#ifndef _ANSIDECL_H ++#define _ANSIDECL_H 1 ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/* Every source file includes this file, ++ so they will all get the switch for lint. */ ++/* LINTLIBRARY */ ++ ++/* Using MACRO(x,y) in cpp #if conditionals does not work with some ++ older preprocessors. Thus we can't define something like this: ++ ++#define HAVE_GCC_VERSION(MAJOR, MINOR) \ ++ (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR))) ++ ++and then test "#if HAVE_GCC_VERSION(2,7)". ++ ++So instead we use the macro below and test it against specific values. */ ++ ++/* This macro simplifies testing whether we are using gcc, and if it ++ is of a particular minimum version. (Both major & minor numbers are ++ significant.) This macro will evaluate to 0 if we are not using ++ gcc at all. */ ++#ifndef GCC_VERSION ++#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) ++#endif /* GCC_VERSION */ ++ ++#if defined (__STDC__) || defined(__cplusplus) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) ++/* All known AIX compilers implement these things (but don't always ++ define __STDC__). The RISC/OS MIPS compiler defines these things ++ in SVR4 mode, but does not define __STDC__. */ ++/* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other ++ C++ compilers, does not define __STDC__, though it acts as if this ++ was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */ ++ ++#define PTR void * ++ ++#undef const ++#undef volatile ++#undef signed ++ ++/* inline requires special treatment; it's in C99, and GCC >=2.7 supports ++ it too, but it's not in C89. */ ++#undef inline ++#if __STDC_VERSION__ >= 199901L || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__)) ++/* it's a keyword */ ++#else ++# if GCC_VERSION >= 2007 ++# define inline __inline__ /* __inline__ prevents -pedantic warnings */ ++# else ++# define inline /* nothing */ ++# endif ++#endif ++ ++#else /* Not ANSI C. */ ++ ++#define PTR char * ++ ++/* some systems define these in header files for non-ansi mode */ ++#undef const ++#undef volatile ++#undef signed ++#undef inline ++#define const ++#define volatile ++#define signed ++#define inline ++ ++#endif /* ANSI C. */ ++ ++/* Define macros for some gcc attributes. This permits us to use the ++ macros freely, and know that they will come into play for the ++ version of gcc in which they are supported. */ ++ ++#if (GCC_VERSION < 2007) ++# define __attribute__(x) ++#endif ++ ++/* Attribute __malloc__ on functions was valid as of gcc 2.96. */ ++#ifndef ATTRIBUTE_MALLOC ++# if (GCC_VERSION >= 2096) ++# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) ++# else ++# define ATTRIBUTE_MALLOC ++# endif /* GNUC >= 2.96 */ ++#endif /* ATTRIBUTE_MALLOC */ ++ ++/* Attributes on labels were valid as of gcc 2.93 and g++ 4.5. For ++ g++ an attribute on a label must be followed by a semicolon. */ ++#ifndef ATTRIBUTE_UNUSED_LABEL ++# ifndef __cplusplus ++# if GCC_VERSION >= 2093 ++# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED ++# else ++# define ATTRIBUTE_UNUSED_LABEL ++# endif ++# else ++# if GCC_VERSION >= 4005 ++# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED ; ++# else ++# define ATTRIBUTE_UNUSED_LABEL ++# endif ++# endif ++#endif ++ ++/* Similarly to ARG_UNUSED below. Prior to GCC 3.4, the C++ frontend ++ couldn't parse attributes placed after the identifier name, and now ++ the entire compiler is built with C++. */ ++#ifndef ATTRIBUTE_UNUSED ++#if GCC_VERSION >= 3004 ++# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) ++#else ++#define ATTRIBUTE_UNUSED ++#endif ++#endif /* ATTRIBUTE_UNUSED */ ++ ++/* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the ++ identifier name. */ ++#if ! defined(__cplusplus) || (GCC_VERSION >= 3004) ++# define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED ++#else /* !__cplusplus || GNUC >= 3.4 */ ++# define ARG_UNUSED(NAME) NAME ++#endif /* !__cplusplus || GNUC >= 3.4 */ ++ ++#ifndef ATTRIBUTE_NORETURN ++#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) ++#endif /* ATTRIBUTE_NORETURN */ ++ ++/* Attribute `nonnull' was valid as of gcc 3.3. */ ++#ifndef ATTRIBUTE_NONNULL ++# if (GCC_VERSION >= 3003) ++# define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m))) ++# else ++# define ATTRIBUTE_NONNULL(m) ++# endif /* GNUC >= 3.3 */ ++#endif /* ATTRIBUTE_NONNULL */ ++ ++/* Attribute `returns_nonnull' was valid as of gcc 4.9. */ ++#ifndef ATTRIBUTE_RETURNS_NONNULL ++# if (GCC_VERSION >= 4009) ++# define ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__)) ++# else ++# define ATTRIBUTE_RETURNS_NONNULL ++# endif /* GNUC >= 4.9 */ ++#endif /* ATTRIBUTE_RETURNS_NONNULL */ ++ ++/* Attribute `pure' was valid as of gcc 3.0. */ ++#ifndef ATTRIBUTE_PURE ++# if (GCC_VERSION >= 3000) ++# define ATTRIBUTE_PURE __attribute__ ((__pure__)) ++# else ++# define ATTRIBUTE_PURE ++# endif /* GNUC >= 3.0 */ ++#endif /* ATTRIBUTE_PURE */ ++ ++/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL. ++ This was the case for the `printf' format attribute by itself ++ before GCC 3.3, but as of 3.3 we need to add the `nonnull' ++ attribute to retain this behavior. */ ++#ifndef ATTRIBUTE_PRINTF ++#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m) ++#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2) ++#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3) ++#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4) ++#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5) ++#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6) ++#endif /* ATTRIBUTE_PRINTF */ ++ ++/* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on ++ a function pointer. Format attributes were allowed on function ++ pointers as of gcc 3.1. */ ++#ifndef ATTRIBUTE_FPTR_PRINTF ++# if (GCC_VERSION >= 3001) ++# define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n) ++# else ++# define ATTRIBUTE_FPTR_PRINTF(m, n) ++# endif /* GNUC >= 3.1 */ ++# define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2) ++# define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3) ++# define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4) ++# define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5) ++# define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6) ++#endif /* ATTRIBUTE_FPTR_PRINTF */ ++ ++/* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL. A ++ NULL format specifier was allowed as of gcc 3.3. */ ++#ifndef ATTRIBUTE_NULL_PRINTF ++# if (GCC_VERSION >= 3003) ++# define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ++# else ++# define ATTRIBUTE_NULL_PRINTF(m, n) ++# endif /* GNUC >= 3.3 */ ++# define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2) ++# define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3) ++# define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4) ++# define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5) ++# define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6) ++#endif /* ATTRIBUTE_NULL_PRINTF */ ++ ++/* Attribute `sentinel' was valid as of gcc 3.5. */ ++#ifndef ATTRIBUTE_SENTINEL ++# if (GCC_VERSION >= 3005) ++# define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__)) ++# else ++# define ATTRIBUTE_SENTINEL ++# endif /* GNUC >= 3.5 */ ++#endif /* ATTRIBUTE_SENTINEL */ ++ ++ ++#ifndef ATTRIBUTE_ALIGNED_ALIGNOF ++# if (GCC_VERSION >= 3000) ++# define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m)))) ++# else ++# define ATTRIBUTE_ALIGNED_ALIGNOF(m) ++# endif /* GNUC >= 3.0 */ ++#endif /* ATTRIBUTE_ALIGNED_ALIGNOF */ ++ ++/* Useful for structures whose layout must much some binary specification ++ regardless of the alignment and padding qualities of the compiler. */ ++#ifndef ATTRIBUTE_PACKED ++# define ATTRIBUTE_PACKED __attribute__ ((packed)) ++#endif ++ ++/* Attribute `hot' and `cold' was valid as of gcc 4.3. */ ++#ifndef ATTRIBUTE_COLD ++# if (GCC_VERSION >= 4003) ++# define ATTRIBUTE_COLD __attribute__ ((__cold__)) ++# else ++# define ATTRIBUTE_COLD ++# endif /* GNUC >= 4.3 */ ++#endif /* ATTRIBUTE_COLD */ ++#ifndef ATTRIBUTE_HOT ++# if (GCC_VERSION >= 4003) ++# define ATTRIBUTE_HOT __attribute__ ((__hot__)) ++# else ++# define ATTRIBUTE_HOT ++# endif /* GNUC >= 4.3 */ ++#endif /* ATTRIBUTE_HOT */ ++ ++/* Attribute 'no_sanitize_undefined' was valid as of gcc 4.9. */ ++#ifndef ATTRIBUTE_NO_SANITIZE_UNDEFINED ++# if (GCC_VERSION >= 4009) ++# define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__ ((no_sanitize_undefined)) ++# else ++# define ATTRIBUTE_NO_SANITIZE_UNDEFINED ++# endif /* GNUC >= 4.9 */ ++#endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */ ++ ++/* We use __extension__ in some places to suppress -pedantic warnings ++ about GCC extensions. This feature didn't work properly before ++ gcc 2.8. */ ++#if GCC_VERSION < 2008 ++#define __extension__ ++#endif ++ ++/* This is used to declare a const variable which should be visible ++ outside of the current compilation unit. Use it as ++ EXPORTED_CONST int i = 1; ++ This is because the semantics of const are different in C and C++. ++ "extern const" is permitted in C but it looks strange, and gcc ++ warns about it when -Wc++-compat is not used. */ ++#ifdef __cplusplus ++#define EXPORTED_CONST extern const ++#else ++#define EXPORTED_CONST const ++#endif ++ ++/* Be conservative and only use enum bitfields with C++ or GCC. ++ FIXME: provide a complete autoconf test for buggy enum bitfields. */ ++ ++#ifdef __cplusplus ++#define ENUM_BITFIELD(TYPE) enum TYPE ++#elif (GCC_VERSION > 2000) ++#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE ++#else ++#define ENUM_BITFIELD(TYPE) unsigned int ++#endif ++ ++/* C++11 adds the ability to add "override" after an implementation of a ++ virtual function in a subclass, to: ++ (A) document that this is an override of a virtual function ++ (B) allow the compiler to issue a warning if it isn't (e.g. a mismatch ++ of the type signature). ++ ++ Similarly, it allows us to add a "final" to indicate that no subclass ++ may subsequently override the vfunc. ++ ++ Provide OVERRIDE and FINAL as macros, allowing us to get these benefits ++ when compiling with C++11 support, but without requiring C++11. ++ ++ For gcc, use "-std=c++11" to enable C++11 support; gcc 6 onwards enables ++ this by default (actually GNU++14). */ ++ ++#if __cplusplus >= 201103 ++/* C++11 claims to be available: use it. final/override were only ++ implemented in 4.7, though. */ ++# if GCC_VERSION < 4007 ++# define OVERRIDE ++# define FINAL ++# else ++# define OVERRIDE override ++# define FINAL final ++# endif ++#elif GCC_VERSION >= 4007 ++/* G++ 4.7 supports __final in C++98. */ ++# define OVERRIDE ++# define FINAL __final ++#else ++/* No C++11 support; leave the macros empty: */ ++# define OVERRIDE ++# define FINAL ++#endif ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* ansidecl.h */ diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/atomic.c index 000000000,000000000..4f31ff36f new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/atomic.c @@@ -1,0 -1,0 +1,113 @@@ ++/* atomic.c -- Support for atomic functions if not present. ++ Copyright (C) 2013-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++ ++#include "backtrace.h" ++#include "backtrace-supported.h" ++#include "internal.h" ++ ++/* This file holds implementations of the atomic functions that are ++ used if the host compiler has the sync functions but not the atomic ++ functions, as is true of versions of GCC before 4.7. */ ++ ++#if !defined (HAVE_ATOMIC_FUNCTIONS) && defined (HAVE_SYNC_FUNCTIONS) ++ ++/* Do an atomic load of a pointer. */ ++ ++void * ++backtrace_atomic_load_pointer (void *arg) ++{ ++ void **pp; ++ void *p; ++ ++ pp = (void **) arg; ++ p = *pp; ++ while (!__sync_bool_compare_and_swap (pp, p, p)) ++ p = *pp; ++ return p; ++} ++ ++/* Do an atomic load of an int. */ ++ ++int ++backtrace_atomic_load_int (int *p) ++{ ++ int i; ++ ++ i = *p; ++ while (!__sync_bool_compare_and_swap (p, i, i)) ++ i = *p; ++ return i; ++} ++ ++/* Do an atomic store of a pointer. */ ++ ++void ++backtrace_atomic_store_pointer (void *arg, void *p) ++{ ++ void **pp; ++ void *old; ++ ++ pp = (void **) arg; ++ old = *pp; ++ while (!__sync_bool_compare_and_swap (pp, old, p)) ++ old = *pp; ++} ++ ++/* Do an atomic store of a size_t value. */ ++ ++void ++backtrace_atomic_store_size_t (size_t *p, size_t v) ++{ ++ size_t old; ++ ++ old = *p; ++ while (!__sync_bool_compare_and_swap (p, old, v)) ++ old = *p; ++} ++ ++/* Do an atomic store of a int value. */ ++ ++void ++backtrace_atomic_store_int (int *p, int v) ++{ ++ size_t old; ++ ++ old = *p; ++ while (!__sync_bool_compare_and_swap (p, old, v)) ++ old = *p; ++} ++ ++#endif diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/backtrace-supported.h.in index 000000000,000000000..c2d03d241 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/backtrace-supported.h.in @@@ -1,0 -1,0 +1,66 @@@ ++/* backtrace-supported.h.in -- Whether stack backtrace is supported. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++/* The file backtrace-supported.h.in is used by configure to generate ++ the file backtrace-supported.h. The file backtrace-supported.h may ++ be #include'd to see whether the backtrace library will be able to ++ get a backtrace and produce symbolic information. */ ++ ++ ++/* BACKTRACE_SUPPORTED will be #define'd as 1 if the backtrace library ++ should work, 0 if it will not. Libraries may #include this to make ++ other arrangements. */ ++ ++#define BACKTRACE_SUPPORTED @BACKTRACE_SUPPORTED@ ++ ++/* BACKTRACE_USES_MALLOC will be #define'd as 1 if the backtrace ++ library will call malloc as it works, 0 if it will call mmap ++ instead. This may be used to determine whether it is safe to call ++ the backtrace functions from a signal handler. In general this ++ only applies to calls like backtrace and backtrace_pcinfo. It does ++ not apply to backtrace_simple, which never calls malloc. It does ++ not apply to backtrace_print, which always calls fprintf and ++ therefore malloc. */ ++ ++#define BACKTRACE_USES_MALLOC @BACKTRACE_USES_MALLOC@ ++ ++/* BACKTRACE_SUPPORTS_THREADS will be #define'd as 1 if the backtrace ++ library is configured with threading support, 0 if not. If this is ++ 0, the threaded parameter to backtrace_create_state must be passed ++ as 0. */ ++ ++#define BACKTRACE_SUPPORTS_THREADS @BACKTRACE_SUPPORTS_THREADS@ ++ ++/* BACKTRACE_SUPPORTS_DATA will be #defined'd as 1 if the backtrace_syminfo ++ will work for variables. It will always work for functions. */ ++ ++#define BACKTRACE_SUPPORTS_DATA @BACKTRACE_SUPPORTS_DATA@ diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/backtrace.c index 000000000,000000000..7372a27f1 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/backtrace.c @@@ -1,0 -1,0 +1,129 @@@ ++/* backtrace.c -- Entry point for stack backtrace library. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++ ++#include "unwind.h" ++#include "backtrace.h" ++#include "internal.h" ++ ++/* The main backtrace_full routine. */ ++ ++/* Data passed through _Unwind_Backtrace. */ ++ ++struct backtrace_data ++{ ++ /* Number of frames to skip. */ ++ int skip; ++ /* Library state. */ ++ struct backtrace_state *state; ++ /* Callback routine. */ ++ backtrace_full_callback callback; ++ /* Error callback routine. */ ++ backtrace_error_callback error_callback; ++ /* Data to pass to callback routines. */ ++ void *data; ++ /* Value to return from backtrace_full. */ ++ int ret; ++ /* Whether there is any memory available. */ ++ int can_alloc; ++}; ++ ++/* Unwind library callback routine. This is passed to ++ _Unwind_Backtrace. */ ++ ++static _Unwind_Reason_Code ++unwind (struct _Unwind_Context *context, void *vdata) ++{ ++ struct backtrace_data *bdata = (struct backtrace_data *) vdata; ++ uintptr_t pc; ++ int ip_before_insn = 0; ++ ++#ifdef HAVE_GETIPINFO ++ pc = _Unwind_GetIPInfo (context, &ip_before_insn); ++#else ++ pc = _Unwind_GetIP (context); ++#endif ++ ++ if (bdata->skip > 0) ++ { ++ --bdata->skip; ++ return _URC_NO_REASON; ++ } ++ ++ if (!ip_before_insn) ++ --pc; ++ ++ if (!bdata->can_alloc) ++ bdata->ret = bdata->callback (bdata->data, pc, NULL, 0, NULL); ++ else ++ bdata->ret = backtrace_pcinfo (bdata->state, pc, bdata->callback, ++ bdata->error_callback, bdata->data); ++ if (bdata->ret != 0) ++ return _URC_END_OF_STACK; ++ ++ return _URC_NO_REASON; ++} ++ ++/* Get a stack backtrace. */ ++ ++int ++backtrace_full (struct backtrace_state *state, int skip, ++ backtrace_full_callback callback, ++ backtrace_error_callback error_callback, void *data) ++{ ++ struct backtrace_data bdata; ++ void *p; ++ ++ bdata.skip = skip + 1; ++ bdata.state = state; ++ bdata.callback = callback; ++ bdata.error_callback = error_callback; ++ bdata.data = data; ++ bdata.ret = 0; ++ ++ /* If we can't allocate any memory at all, don't try to produce ++ file/line information. */ ++ p = backtrace_alloc (state, 4096, NULL, NULL); ++ if (p == NULL) ++ bdata.can_alloc = 0; ++ else ++ { ++ backtrace_free (state, p, 4096, NULL, NULL); ++ bdata.can_alloc = 1; ++ } ++ ++ _Unwind_Backtrace (unwind, &bdata); ++ return bdata.ret; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/backtrace.h index 000000000,000000000..0e6e29f39 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/backtrace.h @@@ -1,0 -1,0 +1,199 @@@ ++/* backtrace.h -- Public header file for stack backtrace library. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#ifndef BACKTRACE_H ++#define BACKTRACE_H ++ ++#include ++#include ++ ++/* We want to get a definition for uintptr_t, but we still care about ++ systems that don't have . */ ++#if defined(__GLIBC__) && __GLIBC__ >= 2 ++ ++#include ++ ++#elif defined(HAVE_STDINT_H) ++ ++#include ++ ++#else ++ ++/* Systems that don't have must provide gstdint.h, e.g., ++ from GCC_HEADER_STDINT in configure.ac. */ ++#include "gstdint.h" ++ ++#endif ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/* The backtrace state. This struct is intentionally not defined in ++ the public interface. */ ++ ++struct backtrace_state; ++ ++/* The type of the error callback argument to backtrace functions. ++ This function, if not NULL, will be called for certain error cases. ++ The DATA argument is passed to the function that calls this one. ++ The MSG argument is an error message. The ERRNUM argument, if ++ greater than 0, holds an errno value. The MSG buffer may become ++ invalid after this function returns. ++ ++ As a special case, the ERRNUM argument will be passed as -1 if no ++ debug info can be found for the executable, but the function ++ requires debug info (e.g., backtrace_full, backtrace_pcinfo). The ++ MSG in this case will be something along the lines of "no debug ++ info". Similarly, ERRNUM will be passed as -1 if there is no ++ symbol table, but the function requires a symbol table (e.g., ++ backtrace_syminfo). This may be used as a signal that some other ++ approach should be tried. */ ++ ++typedef void (*backtrace_error_callback) (void *data, const char *msg, ++ int errnum); ++ ++/* Create state information for the backtrace routines. This must be ++ called before any of the other routines, and its return value must ++ be passed to all of the other routines. FILENAME is the path name ++ of the executable file; if it is NULL the library will try ++ system-specific path names. If not NULL, FILENAME must point to a ++ permanent buffer. If THREADED is non-zero the state may be ++ accessed by multiple threads simultaneously, and the library will ++ use appropriate atomic operations. If THREADED is zero the state ++ may only be accessed by one thread at a time. This returns a state ++ pointer on success, NULL on error. If an error occurs, this will ++ call the ERROR_CALLBACK routine. */ ++ ++extern struct backtrace_state *backtrace_create_state ( ++ const char *filename, int threaded, ++ backtrace_error_callback error_callback, void *data); ++ ++/* The type of the callback argument to the backtrace_full function. ++ DATA is the argument passed to backtrace_full. PC is the program ++ counter. FILENAME is the name of the file containing PC, or NULL ++ if not available. LINENO is the line number in FILENAME containing ++ PC, or 0 if not available. FUNCTION is the name of the function ++ containing PC, or NULL if not available. This should return 0 to ++ continuing tracing. The FILENAME and FUNCTION buffers may become ++ invalid after this function returns. */ ++ ++typedef int (*backtrace_full_callback) (void *data, uintptr_t pc, ++ const char *filename, int lineno, ++ const char *function); ++ ++/* Get a full stack backtrace. SKIP is the number of frames to skip; ++ passing 0 will start the trace with the function calling ++ backtrace_full. DATA is passed to the callback routine. If any ++ call to CALLBACK returns a non-zero value, the stack backtrace ++ stops, and backtrace returns that value; this may be used to limit ++ the number of stack frames desired. If all calls to CALLBACK ++ return 0, backtrace returns 0. The backtrace_full function will ++ make at least one call to either CALLBACK or ERROR_CALLBACK. This ++ function requires debug info for the executable. */ ++ ++extern int backtrace_full (struct backtrace_state *state, int skip, ++ backtrace_full_callback callback, ++ backtrace_error_callback error_callback, ++ void *data); ++ ++/* The type of the callback argument to the backtrace_simple function. ++ DATA is the argument passed to simple_backtrace. PC is the program ++ counter. This should return 0 to continue tracing. */ ++ ++typedef int (*backtrace_simple_callback) (void *data, uintptr_t pc); ++ ++/* Get a simple backtrace. SKIP is the number of frames to skip, as ++ in backtrace. DATA is passed to the callback routine. If any call ++ to CALLBACK returns a non-zero value, the stack backtrace stops, ++ and backtrace_simple returns that value. Otherwise ++ backtrace_simple returns 0. The backtrace_simple function will ++ make at least one call to either CALLBACK or ERROR_CALLBACK. This ++ function does not require any debug info for the executable. */ ++ ++extern int backtrace_simple (struct backtrace_state *state, int skip, ++ backtrace_simple_callback callback, ++ backtrace_error_callback error_callback, ++ void *data); ++ ++/* Print the current backtrace in a user readable format to a FILE. ++ SKIP is the number of frames to skip, as in backtrace_full. Any ++ error messages are printed to stderr. This function requires debug ++ info for the executable. */ ++ ++extern void backtrace_print (struct backtrace_state *state, int skip, FILE *); ++ ++/* Given PC, a program counter in the current program, call the ++ callback function with filename, line number, and function name ++ information. This will normally call the callback function exactly ++ once. However, if the PC happens to describe an inlined call, and ++ the debugging information contains the necessary information, then ++ this may call the callback function multiple times. This will make ++ at least one call to either CALLBACK or ERROR_CALLBACK. This ++ returns the first non-zero value returned by CALLBACK, or 0. */ ++ ++extern int backtrace_pcinfo (struct backtrace_state *state, uintptr_t pc, ++ backtrace_full_callback callback, ++ backtrace_error_callback error_callback, ++ void *data); ++ ++/* The type of the callback argument to backtrace_syminfo. DATA and ++ PC are the arguments passed to backtrace_syminfo. SYMNAME is the ++ name of the symbol for the corresponding code. SYMVAL is the ++ value and SYMSIZE is the size of the symbol. SYMNAME will be NULL ++ if no error occurred but the symbol could not be found. */ ++ ++typedef void (*backtrace_syminfo_callback) (void *data, uintptr_t pc, ++ const char *symname, ++ uintptr_t symval, ++ uintptr_t symsize); ++ ++/* Given ADDR, an address or program counter in the current program, ++ call the callback information with the symbol name and value ++ describing the function or variable in which ADDR may be found. ++ This will call either CALLBACK or ERROR_CALLBACK exactly once. ++ This returns 1 on success, 0 on failure. This function requires ++ the symbol table but does not require the debug info. Note that if ++ the symbol table is present but ADDR could not be found in the ++ table, CALLBACK will be called with a NULL SYMNAME argument. ++ Returns 1 on success, 0 on error. */ ++ ++extern int backtrace_syminfo (struct backtrace_state *state, uintptr_t addr, ++ backtrace_syminfo_callback callback, ++ backtrace_error_callback error_callback, ++ void *data); ++ ++#ifdef __cplusplus ++} /* End extern "C". */ ++#endif ++ ++#endif diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/btest.c index 000000000,000000000..8c69b1b87 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/btest.c @@@ -1,0 -1,0 +1,721 @@@ ++/* btest.c -- Test for libbacktrace library ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++/* This program tests the externally visible interfaces of the ++ libbacktrace library. */ ++ ++#include ++#include ++#include ++#include ++ ++#include "filenames.h" ++ ++#include "backtrace.h" ++#include "backtrace-supported.h" ++ ++/* Portable attribute syntax. Actually some of these tests probably ++ won't work if the attributes are not recognized. */ ++ ++#ifndef GCC_VERSION ++# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) ++#endif ++ ++#if (GCC_VERSION < 2007) ++# define __attribute__(x) ++#endif ++ ++#ifndef ATTRIBUTE_UNUSED ++# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) ++#endif ++ ++/* Used to collect backtrace info. */ ++ ++struct info ++{ ++ char *filename; ++ int lineno; ++ char *function; ++}; ++ ++/* Passed to backtrace callback function. */ ++ ++struct bdata ++{ ++ struct info *all; ++ size_t index; ++ size_t max; ++ int failed; ++}; ++ ++/* Passed to backtrace_simple callback function. */ ++ ++struct sdata ++{ ++ uintptr_t *addrs; ++ size_t index; ++ size_t max; ++ int failed; ++}; ++ ++/* Passed to backtrace_syminfo callback function. */ ++ ++struct symdata ++{ ++ const char *name; ++ uintptr_t val, size; ++ int failed; ++}; ++ ++/* The backtrace state. */ ++ ++static void *state; ++ ++/* The number of failures. */ ++ ++static int failures; ++ ++/* Return the base name in a path. */ ++ ++static const char * ++base (const char *p) ++{ ++ const char *last; ++ const char *s; ++ ++ last = NULL; ++ for (s = p; *s != '\0'; ++s) ++ { ++ if (IS_DIR_SEPARATOR (*s)) ++ last = s + 1; ++ } ++ return last != NULL ? last : p; ++} ++ ++/* Check an entry in a struct info array. */ ++ ++static void ++check (const char *name, int index, const struct info *all, int want_lineno, ++ const char *want_function, int *failed) ++{ ++ if (*failed) ++ return; ++ if (all[index].filename == NULL || all[index].function == NULL) ++ { ++ fprintf (stderr, "%s: [%d]: missing file name or function name\n", ++ name, index); ++ *failed = 1; ++ return; ++ } ++ if (strcmp (base (all[index].filename), "btest.c") != 0) ++ { ++ fprintf (stderr, "%s: [%d]: got %s expected test.c\n", name, index, ++ all[index].filename); ++ *failed = 1; ++ } ++ if (all[index].lineno != want_lineno) ++ { ++ fprintf (stderr, "%s: [%d]: got %d expected %d\n", name, index, ++ all[index].lineno, want_lineno); ++ *failed = 1; ++ } ++ if (strcmp (all[index].function, want_function) != 0) ++ { ++ fprintf (stderr, "%s: [%d]: got %s expected %s\n", name, index, ++ all[index].function, want_function); ++ *failed = 1; ++ } ++} ++ ++/* The backtrace callback function. */ ++ ++static int ++callback_one (void *vdata, uintptr_t pc ATTRIBUTE_UNUSED, ++ const char *filename, int lineno, const char *function) ++{ ++ struct bdata *data = (struct bdata *) vdata; ++ struct info *p; ++ ++ if (data->index >= data->max) ++ { ++ fprintf (stderr, "callback_one: callback called too many times\n"); ++ data->failed = 1; ++ return 1; ++ } ++ ++ p = &data->all[data->index]; ++ if (filename == NULL) ++ p->filename = NULL; ++ else ++ { ++ p->filename = strdup (filename); ++ assert (p->filename != NULL); ++ } ++ p->lineno = lineno; ++ if (function == NULL) ++ p->function = NULL; ++ else ++ { ++ p->function = strdup (function); ++ assert (p->function != NULL); ++ } ++ ++data->index; ++ ++ return 0; ++} ++ ++/* An error callback passed to backtrace. */ ++ ++static void ++error_callback_one (void *vdata, const char *msg, int errnum) ++{ ++ struct bdata *data = (struct bdata *) vdata; ++ ++ fprintf (stderr, "%s", msg); ++ if (errnum > 0) ++ fprintf (stderr, ": %s", strerror (errnum)); ++ fprintf (stderr, "\n"); ++ data->failed = 1; ++} ++ ++/* The backtrace_simple callback function. */ ++ ++static int ++callback_two (void *vdata, uintptr_t pc) ++{ ++ struct sdata *data = (struct sdata *) vdata; ++ ++ if (data->index >= data->max) ++ { ++ fprintf (stderr, "callback_two: callback called too many times\n"); ++ data->failed = 1; ++ return 1; ++ } ++ ++ data->addrs[data->index] = pc; ++ ++data->index; ++ ++ return 0; ++} ++ ++/* An error callback passed to backtrace_simple. */ ++ ++static void ++error_callback_two (void *vdata, const char *msg, int errnum) ++{ ++ struct sdata *data = (struct sdata *) vdata; ++ ++ fprintf (stderr, "%s", msg); ++ if (errnum > 0) ++ fprintf (stderr, ": %s", strerror (errnum)); ++ fprintf (stderr, "\n"); ++ data->failed = 1; ++} ++ ++/* The backtrace_syminfo callback function. */ ++ ++static void ++callback_three (void *vdata, uintptr_t pc ATTRIBUTE_UNUSED, ++ const char *symname, uintptr_t symval, ++ uintptr_t symsize) ++{ ++ struct symdata *data = (struct symdata *) vdata; ++ ++ if (symname == NULL) ++ data->name = NULL; ++ else ++ { ++ data->name = strdup (symname); ++ assert (data->name != NULL); ++ } ++ data->val = symval; ++ data->size = symsize; ++} ++ ++/* The backtrace_syminfo error callback function. */ ++ ++static void ++error_callback_three (void *vdata, const char *msg, int errnum) ++{ ++ struct symdata *data = (struct symdata *) vdata; ++ ++ fprintf (stderr, "%s", msg); ++ if (errnum > 0) ++ fprintf (stderr, ": %s", strerror (errnum)); ++ fprintf (stderr, "\n"); ++ data->failed = 1; ++} ++ ++/* Test the backtrace function with non-inlined functions. */ ++ ++static int test1 (void) __attribute__ ((noinline, unused)); ++static int f2 (int) __attribute__ ((noinline)); ++static int f3 (int, int) __attribute__ ((noinline)); ++ ++static int ++test1 (void) ++{ ++ /* Returning a value here and elsewhere avoids a tailcall which ++ would mess up the backtrace. */ ++ return f2 (__LINE__) + 1; ++} ++ ++static int ++f2 (int f1line) ++{ ++ return f3 (f1line, __LINE__) + 2; ++} ++ ++static int ++f3 (int f1line, int f2line) ++{ ++ struct info all[20]; ++ struct bdata data; ++ int f3line; ++ int i; ++ ++ data.all = &all[0]; ++ data.index = 0; ++ data.max = 20; ++ data.failed = 0; ++ ++ f3line = __LINE__ + 1; ++ i = backtrace_full (state, 0, callback_one, error_callback_one, &data); ++ ++ if (i != 0) ++ { ++ fprintf (stderr, "test1: unexpected return value %d\n", i); ++ data.failed = 1; ++ } ++ ++ if (data.index < 3) ++ { ++ fprintf (stderr, ++ "test1: not enough frames; got %zu, expected at least 3\n", ++ data.index); ++ data.failed = 1; ++ } ++ ++ check ("test1", 0, all, f3line, "f3", &data.failed); ++ check ("test1", 1, all, f2line, "f2", &data.failed); ++ check ("test1", 2, all, f1line, "test1", &data.failed); ++ ++ printf ("%s: backtrace_full noinline\n", data.failed ? "FAIL" : "PASS"); ++ ++ if (data.failed) ++ ++failures; ++ ++ return failures; ++} ++ ++/* Test the backtrace function with inlined functions. */ ++ ++static inline int test2 (void) __attribute__ ((always_inline, unused)); ++static inline int f12 (int) __attribute__ ((always_inline)); ++static inline int f13 (int, int) __attribute__ ((always_inline)); ++ ++static inline int ++test2 (void) ++{ ++ return f12 (__LINE__) + 1; ++} ++ ++static inline int ++f12 (int f1line) ++{ ++ return f13 (f1line, __LINE__) + 2; ++} ++ ++static inline int ++f13 (int f1line, int f2line) ++{ ++ struct info all[20]; ++ struct bdata data; ++ int f3line; ++ int i; ++ ++ data.all = &all[0]; ++ data.index = 0; ++ data.max = 20; ++ data.failed = 0; ++ ++ f3line = __LINE__ + 1; ++ i = backtrace_full (state, 0, callback_one, error_callback_one, &data); ++ ++ if (i != 0) ++ { ++ fprintf (stderr, "test2: unexpected return value %d\n", i); ++ data.failed = 1; ++ } ++ ++ check ("test2", 0, all, f3line, "f13", &data.failed); ++ check ("test2", 1, all, f2line, "f12", &data.failed); ++ check ("test2", 2, all, f1line, "test2", &data.failed); ++ ++ printf ("%s: backtrace_full inline\n", data.failed ? "FAIL" : "PASS"); ++ ++ if (data.failed) ++ ++failures; ++ ++ return failures; ++} ++ ++/* Test the backtrace_simple function with non-inlined functions. */ ++ ++static int test3 (void) __attribute__ ((noinline, unused)); ++static int f22 (int) __attribute__ ((noinline)); ++static int f23 (int, int) __attribute__ ((noinline)); ++ ++static int ++test3 (void) ++{ ++ return f22 (__LINE__) + 1; ++} ++ ++static int ++f22 (int f1line) ++{ ++ return f23 (f1line, __LINE__) + 2; ++} ++ ++static int ++f23 (int f1line, int f2line) ++{ ++ uintptr_t addrs[20]; ++ struct sdata data; ++ int f3line; ++ int i; ++ ++ data.addrs = &addrs[0]; ++ data.index = 0; ++ data.max = 20; ++ data.failed = 0; ++ ++ f3line = __LINE__ + 1; ++ i = backtrace_simple (state, 0, callback_two, error_callback_two, &data); ++ ++ if (i != 0) ++ { ++ fprintf (stderr, "test3: unexpected return value %d\n", i); ++ data.failed = 1; ++ } ++ ++ if (!data.failed) ++ { ++ struct info all[20]; ++ struct bdata bdata; ++ int j; ++ ++ bdata.all = &all[0]; ++ bdata.index = 0; ++ bdata.max = 20; ++ bdata.failed = 0; ++ ++ for (j = 0; j < 3; ++j) ++ { ++ i = backtrace_pcinfo (state, addrs[j], callback_one, ++ error_callback_one, &bdata); ++ if (i != 0) ++ { ++ fprintf (stderr, ++ ("test3: unexpected return value " ++ "from backtrace_pcinfo %d\n"), ++ i); ++ bdata.failed = 1; ++ } ++ if (!bdata.failed && bdata.index != (size_t) (j + 1)) ++ { ++ fprintf (stderr, ++ ("wrong number of calls from backtrace_pcinfo " ++ "got %u expected %d\n"), ++ (unsigned int) bdata.index, j + 1); ++ bdata.failed = 1; ++ } ++ } ++ ++ check ("test3", 0, all, f3line, "f23", &bdata.failed); ++ check ("test3", 1, all, f2line, "f22", &bdata.failed); ++ check ("test3", 2, all, f1line, "test3", &bdata.failed); ++ ++ if (bdata.failed) ++ data.failed = 1; ++ ++ for (j = 0; j < 3; ++j) ++ { ++ struct symdata symdata; ++ ++ symdata.name = NULL; ++ symdata.val = 0; ++ symdata.size = 0; ++ symdata.failed = 0; ++ ++ i = backtrace_syminfo (state, addrs[j], callback_three, ++ error_callback_three, &symdata); ++ if (i == 0) ++ { ++ fprintf (stderr, ++ ("test3: [%d]: unexpected return value " ++ "from backtrace_syminfo %d\n"), ++ j, i); ++ symdata.failed = 1; ++ } ++ ++ if (!symdata.failed) ++ { ++ const char *expected; ++ ++ switch (j) ++ { ++ case 0: ++ expected = "f23"; ++ break; ++ case 1: ++ expected = "f22"; ++ break; ++ case 2: ++ expected = "test3"; ++ break; ++ default: ++ assert (0); ++ } ++ ++ if (symdata.name == NULL) ++ { ++ fprintf (stderr, "test3: [%d]: NULL syminfo name\n", j); ++ symdata.failed = 1; ++ } ++ /* Use strncmp, not strcmp, because GCC might create a ++ clone. */ ++ else if (strncmp (symdata.name, expected, strlen (expected)) ++ != 0) ++ { ++ fprintf (stderr, ++ ("test3: [%d]: unexpected syminfo name " ++ "got %s expected %s\n"), ++ j, symdata.name, expected); ++ symdata.failed = 1; ++ } ++ } ++ ++ if (symdata.failed) ++ data.failed = 1; ++ } ++ } ++ ++ printf ("%s: backtrace_simple noinline\n", data.failed ? "FAIL" : "PASS"); ++ ++ if (data.failed) ++ ++failures; ++ ++ return failures; ++} ++ ++/* Test the backtrace_simple function with inlined functions. */ ++ ++static inline int test4 (void) __attribute__ ((always_inline, unused)); ++static inline int f32 (int) __attribute__ ((always_inline)); ++static inline int f33 (int, int) __attribute__ ((always_inline)); ++ ++static inline int ++test4 (void) ++{ ++ return f32 (__LINE__) + 1; ++} ++ ++static inline int ++f32 (int f1line) ++{ ++ return f33 (f1line, __LINE__) + 2; ++} ++ ++static inline int ++f33 (int f1line, int f2line) ++{ ++ uintptr_t addrs[20]; ++ struct sdata data; ++ int f3line; ++ int i; ++ ++ data.addrs = &addrs[0]; ++ data.index = 0; ++ data.max = 20; ++ data.failed = 0; ++ ++ f3line = __LINE__ + 1; ++ i = backtrace_simple (state, 0, callback_two, error_callback_two, &data); ++ ++ if (i != 0) ++ { ++ fprintf (stderr, "test3: unexpected return value %d\n", i); ++ data.failed = 1; ++ } ++ ++ if (!data.failed) ++ { ++ struct info all[20]; ++ struct bdata bdata; ++ ++ bdata.all = &all[0]; ++ bdata.index = 0; ++ bdata.max = 20; ++ bdata.failed = 0; ++ ++ i = backtrace_pcinfo (state, addrs[0], callback_one, error_callback_one, ++ &bdata); ++ if (i != 0) ++ { ++ fprintf (stderr, ++ ("test4: unexpected return value " ++ "from backtrace_pcinfo %d\n"), ++ i); ++ bdata.failed = 1; ++ } ++ ++ check ("test4", 0, all, f3line, "f33", &bdata.failed); ++ check ("test4", 1, all, f2line, "f32", &bdata.failed); ++ check ("test4", 2, all, f1line, "test4", &bdata.failed); ++ ++ if (bdata.failed) ++ data.failed = 1; ++ } ++ ++ printf ("%s: backtrace_simple inline\n", data.failed ? "FAIL" : "PASS"); ++ ++ if (data.failed) ++ ++failures; ++ ++ return failures; ++} ++ ++#if BACKTRACE_SUPPORTS_DATA ++ ++int global = 1; ++ ++static int ++test5 (void) ++{ ++ struct symdata symdata; ++ int i; ++ uintptr_t addr = (uintptr_t) &global; ++ ++ if (sizeof (global) > 1) ++ addr += 1; ++ ++ symdata.name = NULL; ++ symdata.val = 0; ++ symdata.size = 0; ++ symdata.failed = 0; ++ ++ i = backtrace_syminfo (state, addr, callback_three, ++ error_callback_three, &symdata); ++ if (i == 0) ++ { ++ fprintf (stderr, ++ "test5: unexpected return value from backtrace_syminfo %d\n", ++ i); ++ symdata.failed = 1; ++ } ++ ++ if (!symdata.failed) ++ { ++ if (symdata.name == NULL) ++ { ++ fprintf (stderr, "test5: NULL syminfo name\n"); ++ symdata.failed = 1; ++ } ++ else if (strcmp (symdata.name, "global") != 0) ++ { ++ fprintf (stderr, ++ "test5: unexpected syminfo name got %s expected %s\n", ++ symdata.name, "global"); ++ symdata.failed = 1; ++ } ++ else if (symdata.val != (uintptr_t) &global) ++ { ++ fprintf (stderr, ++ "test5: unexpected syminfo value got %lx expected %lx\n", ++ (unsigned long) symdata.val, ++ (unsigned long) (uintptr_t) &global); ++ symdata.failed = 1; ++ } ++ else if (symdata.size != sizeof (global)) ++ { ++ fprintf (stderr, ++ "test5: unexpected syminfo size got %lx expected %lx\n", ++ (unsigned long) symdata.size, ++ (unsigned long) sizeof (global)); ++ symdata.failed = 1; ++ } ++ } ++ ++ printf ("%s: backtrace_syminfo variable\n", ++ symdata.failed ? "FAIL" : "PASS"); ++ ++ if (symdata.failed) ++ ++failures; ++ ++ return failures; ++} ++ ++#endif /* BACKTRACE_SUPPORTS_DATA */ ++ ++static void ++error_callback_create (void *data ATTRIBUTE_UNUSED, const char *msg, ++ int errnum) ++{ ++ fprintf (stderr, "%s", msg); ++ if (errnum > 0) ++ fprintf (stderr, ": %s", strerror (errnum)); ++ fprintf (stderr, "\n"); ++ exit (EXIT_FAILURE); ++} ++ ++/* Run all the tests. */ ++ ++int ++main (int argc ATTRIBUTE_UNUSED, char **argv) ++{ ++ state = backtrace_create_state (argv[0], BACKTRACE_SUPPORTS_THREADS, ++ error_callback_create, NULL); ++ ++#if BACKTRACE_SUPPORTED ++ test1 (); ++ test2 (); ++ test3 (); ++ test4 (); ++#if BACKTRACE_SUPPORTS_DATA ++ test5 (); ++#endif ++#endif ++ ++ exit (failures ? EXIT_FAILURE : EXIT_SUCCESS); ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/config.guess index 000000000,000000000..2e9ad7fe8 new file mode 100755 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/config.guess @@@ -1,0 -1,0 +1,1462 @@@ ++#! /bin/sh ++# Attempt to guess a canonical system name. ++# Copyright 1992-2016 Free Software Foundation, Inc. ++ ++timestamp='2016-10-02' ++ ++# This file is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, see . ++# ++# As a special exception to the GNU General Public License, if you ++# distribute this file as part of a program that contains a ++# configuration script generated by Autoconf, you may include it under ++# the same distribution terms that you use for the rest of that ++# program. This Exception is an additional permission under section 7 ++# of the GNU General Public License, version 3 ("GPLv3"). ++# ++# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. ++# ++# You can get the latest version of this script from: ++# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess ++# ++# Please send patches to . ++ ++ ++me=`echo "$0" | sed -e 's,.*/,,'` ++ ++usage="\ ++Usage: $0 [OPTION] ++ ++Output the configuration name of the system \`$me' is run on. ++ ++Operation modes: ++ -h, --help print this help, then exit ++ -t, --time-stamp print date of last modification, then exit ++ -v, --version print version number, then exit ++ ++Report bugs and patches to ." ++ ++version="\ ++GNU config.guess ($timestamp) ++ ++Originally written by Per Bothner. ++Copyright 1992-2016 Free Software Foundation, Inc. ++ ++This is free software; see the source for copying conditions. There is NO ++warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." ++ ++help=" ++Try \`$me --help' for more information." ++ ++# Parse command line ++while test $# -gt 0 ; do ++ case $1 in ++ --time-stamp | --time* | -t ) ++ echo "$timestamp" ; exit ;; ++ --version | -v ) ++ echo "$version" ; exit ;; ++ --help | --h* | -h ) ++ echo "$usage"; exit ;; ++ -- ) # Stop option processing ++ shift; break ;; ++ - ) # Use stdin as input. ++ break ;; ++ -* ) ++ echo "$me: invalid option $1$help" >&2 ++ exit 1 ;; ++ * ) ++ break ;; ++ esac ++done ++ ++if test $# != 0; then ++ echo "$me: too many arguments$help" >&2 ++ exit 1 ++fi ++ ++trap 'exit 1' 1 2 15 ++ ++# CC_FOR_BUILD -- compiler used by this script. Note that the use of a ++# compiler to aid in system detection is discouraged as it requires ++# temporary files to be created and, as you can see below, it is a ++# headache to deal with in a portable fashion. ++ ++# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still ++# use `HOST_CC' if defined, but it is deprecated. ++ ++# Portable tmp directory creation inspired by the Autoconf team. ++ ++set_cc_for_build=' ++trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; ++trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; ++: ${TMPDIR=/tmp} ; ++ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || ++ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || ++ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || ++ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; ++dummy=$tmp/dummy ; ++tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; ++case $CC_FOR_BUILD,$HOST_CC,$CC in ++ ,,) echo "int x;" > $dummy.c ; ++ for c in cc gcc c89 c99 ; do ++ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then ++ CC_FOR_BUILD="$c"; break ; ++ fi ; ++ done ; ++ if test x"$CC_FOR_BUILD" = x ; then ++ CC_FOR_BUILD=no_compiler_found ; ++ fi ++ ;; ++ ,,*) CC_FOR_BUILD=$CC ;; ++ ,*,*) CC_FOR_BUILD=$HOST_CC ;; ++esac ; set_cc_for_build= ;' ++ ++# This is needed to find uname on a Pyramid OSx when run in the BSD universe. ++# (ghazi@noc.rutgers.edu 1994-08-24) ++if (test -f /.attbin/uname) >/dev/null 2>&1 ; then ++ PATH=$PATH:/.attbin ; export PATH ++fi ++ ++UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown ++UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown ++UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown ++UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown ++ ++case "${UNAME_SYSTEM}" in ++Linux|GNU|GNU/*) ++ # If the system lacks a compiler, then just pick glibc. ++ # We could probably try harder. ++ LIBC=gnu ++ ++ eval $set_cc_for_build ++ cat <<-EOF > $dummy.c ++ #include ++ #if defined(__UCLIBC__) ++ LIBC=uclibc ++ #elif defined(__dietlibc__) ++ LIBC=dietlibc ++ #else ++ LIBC=gnu ++ #endif ++ EOF ++ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ++ ;; ++esac ++ ++# Note: order is significant - the case branches are not exclusive. ++ ++case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ++ *:NetBSD:*:*) ++ # NetBSD (nbsd) targets should (where applicable) match one or ++ # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, ++ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently ++ # switched to ELF, *-*-netbsd* would select the old ++ # object file format. This provides both forward ++ # compatibility and a consistent mechanism for selecting the ++ # object file format. ++ # ++ # Note: NetBSD doesn't particularly care about the vendor ++ # portion of the name. We always set it to "unknown". ++ sysctl="sysctl -n hw.machine_arch" ++ UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ ++ /sbin/$sysctl 2>/dev/null || \ ++ /usr/sbin/$sysctl 2>/dev/null || \ ++ echo unknown)` ++ case "${UNAME_MACHINE_ARCH}" in ++ armeb) machine=armeb-unknown ;; ++ arm*) machine=arm-unknown ;; ++ sh3el) machine=shl-unknown ;; ++ sh3eb) machine=sh-unknown ;; ++ sh5el) machine=sh5le-unknown ;; ++ earmv*) ++ arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` ++ endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` ++ machine=${arch}${endian}-unknown ++ ;; ++ *) machine=${UNAME_MACHINE_ARCH}-unknown ;; ++ esac ++ # The Operating System including object format, if it has switched ++ # to ELF recently (or will in the future) and ABI. ++ case "${UNAME_MACHINE_ARCH}" in ++ earm*) ++ os=netbsdelf ++ ;; ++ arm*|i386|m68k|ns32k|sh3*|sparc|vax) ++ eval $set_cc_for_build ++ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ ++ | grep -q __ELF__ ++ then ++ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). ++ # Return netbsd for either. FIX? ++ os=netbsd ++ else ++ os=netbsdelf ++ fi ++ ;; ++ *) ++ os=netbsd ++ ;; ++ esac ++ # Determine ABI tags. ++ case "${UNAME_MACHINE_ARCH}" in ++ earm*) ++ expr='s/^earmv[0-9]/-eabi/;s/eb$//' ++ abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` ++ ;; ++ esac ++ # The OS release ++ # Debian GNU/NetBSD machines have a different userland, and ++ # thus, need a distinct triplet. However, they do not need ++ # kernel version information, so it can be replaced with a ++ # suitable tag, in the style of linux-gnu. ++ case "${UNAME_VERSION}" in ++ Debian*) ++ release='-gnu' ++ ;; ++ *) ++ release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ++ ;; ++ esac ++ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: ++ # contains redundant information, the shorter form: ++ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. ++ echo "${machine}-${os}${release}${abi}" ++ exit ;; ++ *:Bitrig:*:*) ++ UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` ++ echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} ++ exit ;; ++ *:OpenBSD:*:*) ++ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` ++ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} ++ exit ;; ++ *:LibertyBSD:*:*) ++ UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` ++ echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} ++ exit ;; ++ *:ekkoBSD:*:*) ++ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} ++ exit ;; ++ *:SolidBSD:*:*) ++ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} ++ exit ;; ++ macppc:MirBSD:*:*) ++ echo powerpc-unknown-mirbsd${UNAME_RELEASE} ++ exit ;; ++ *:MirBSD:*:*) ++ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} ++ exit ;; ++ *:Sortix:*:*) ++ echo ${UNAME_MACHINE}-unknown-sortix ++ exit ;; ++ alpha:OSF1:*:*) ++ case $UNAME_RELEASE in ++ *4.0) ++ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ++ ;; ++ *5.*) ++ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ++ ;; ++ esac ++ # According to Compaq, /usr/sbin/psrinfo has been available on ++ # OSF/1 and Tru64 systems produced since 1995. I hope that ++ # covers most systems running today. This code pipes the CPU ++ # types through head -n 1, so we only detect the type of CPU 0. ++ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` ++ case "$ALPHA_CPU_TYPE" in ++ "EV4 (21064)") ++ UNAME_MACHINE=alpha ;; ++ "EV4.5 (21064)") ++ UNAME_MACHINE=alpha ;; ++ "LCA4 (21066/21068)") ++ UNAME_MACHINE=alpha ;; ++ "EV5 (21164)") ++ UNAME_MACHINE=alphaev5 ;; ++ "EV5.6 (21164A)") ++ UNAME_MACHINE=alphaev56 ;; ++ "EV5.6 (21164PC)") ++ UNAME_MACHINE=alphapca56 ;; ++ "EV5.7 (21164PC)") ++ UNAME_MACHINE=alphapca57 ;; ++ "EV6 (21264)") ++ UNAME_MACHINE=alphaev6 ;; ++ "EV6.7 (21264A)") ++ UNAME_MACHINE=alphaev67 ;; ++ "EV6.8CB (21264C)") ++ UNAME_MACHINE=alphaev68 ;; ++ "EV6.8AL (21264B)") ++ UNAME_MACHINE=alphaev68 ;; ++ "EV6.8CX (21264D)") ++ UNAME_MACHINE=alphaev68 ;; ++ "EV6.9A (21264/EV69A)") ++ UNAME_MACHINE=alphaev69 ;; ++ "EV7 (21364)") ++ UNAME_MACHINE=alphaev7 ;; ++ "EV7.9 (21364A)") ++ UNAME_MACHINE=alphaev79 ;; ++ esac ++ # A Pn.n version is a patched version. ++ # A Vn.n version is a released version. ++ # A Tn.n version is a released field test version. ++ # A Xn.n version is an unreleased experimental baselevel. ++ # 1.2 uses "1.2" for uname -r. ++ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` ++ # Reset EXIT trap before exiting to avoid spurious non-zero exit code. ++ exitcode=$? ++ trap '' 0 ++ exit $exitcode ;; ++ Alpha\ *:Windows_NT*:*) ++ # How do we know it's Interix rather than the generic POSIX subsystem? ++ # Should we change UNAME_MACHINE based on the output of uname instead ++ # of the specific Alpha model? ++ echo alpha-pc-interix ++ exit ;; ++ 21064:Windows_NT:50:3) ++ echo alpha-dec-winnt3.5 ++ exit ;; ++ Amiga*:UNIX_System_V:4.0:*) ++ echo m68k-unknown-sysv4 ++ exit ;; ++ *:[Aa]miga[Oo][Ss]:*:*) ++ echo ${UNAME_MACHINE}-unknown-amigaos ++ exit ;; ++ *:[Mm]orph[Oo][Ss]:*:*) ++ echo ${UNAME_MACHINE}-unknown-morphos ++ exit ;; ++ *:OS/390:*:*) ++ echo i370-ibm-openedition ++ exit ;; ++ *:z/VM:*:*) ++ echo s390-ibm-zvmoe ++ exit ;; ++ *:OS400:*:*) ++ echo powerpc-ibm-os400 ++ exit ;; ++ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) ++ echo arm-acorn-riscix${UNAME_RELEASE} ++ exit ;; ++ arm*:riscos:*:*|arm*:RISCOS:*:*) ++ echo arm-unknown-riscos ++ exit ;; ++ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) ++ echo hppa1.1-hitachi-hiuxmpp ++ exit ;; ++ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) ++ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. ++ if test "`(/bin/universe) 2>/dev/null`" = att ; then ++ echo pyramid-pyramid-sysv3 ++ else ++ echo pyramid-pyramid-bsd ++ fi ++ exit ;; ++ NILE*:*:*:dcosx) ++ echo pyramid-pyramid-svr4 ++ exit ;; ++ DRS?6000:unix:4.0:6*) ++ echo sparc-icl-nx6 ++ exit ;; ++ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) ++ case `/usr/bin/uname -p` in ++ sparc) echo sparc-icl-nx7; exit ;; ++ esac ;; ++ s390x:SunOS:*:*) ++ echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` ++ exit ;; ++ sun4H:SunOS:5.*:*) ++ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` ++ exit ;; ++ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) ++ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` ++ exit ;; ++ i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) ++ echo i386-pc-auroraux${UNAME_RELEASE} ++ exit ;; ++ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) ++ eval $set_cc_for_build ++ SUN_ARCH=i386 ++ # If there is a compiler, see if it is configured for 64-bit objects. ++ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. ++ # This test works for both compilers. ++ if [ "$CC_FOR_BUILD" != no_compiler_found ]; then ++ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ ++ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ ++ grep IS_64BIT_ARCH >/dev/null ++ then ++ SUN_ARCH=x86_64 ++ fi ++ fi ++ echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` ++ exit ;; ++ sun4*:SunOS:6*:*) ++ # According to config.sub, this is the proper way to canonicalize ++ # SunOS6. Hard to guess exactly what SunOS6 will be like, but ++ # it's likely to be more like Solaris than SunOS4. ++ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` ++ exit ;; ++ sun4*:SunOS:*:*) ++ case "`/usr/bin/arch -k`" in ++ Series*|S4*) ++ UNAME_RELEASE=`uname -v` ++ ;; ++ esac ++ # Japanese Language versions have a version number like `4.1.3-JL'. ++ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` ++ exit ;; ++ sun3*:SunOS:*:*) ++ echo m68k-sun-sunos${UNAME_RELEASE} ++ exit ;; ++ sun*:*:4.2BSD:*) ++ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` ++ test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 ++ case "`/bin/arch`" in ++ sun3) ++ echo m68k-sun-sunos${UNAME_RELEASE} ++ ;; ++ sun4) ++ echo sparc-sun-sunos${UNAME_RELEASE} ++ ;; ++ esac ++ exit ;; ++ aushp:SunOS:*:*) ++ echo sparc-auspex-sunos${UNAME_RELEASE} ++ exit ;; ++ # The situation for MiNT is a little confusing. The machine name ++ # can be virtually everything (everything which is not ++ # "atarist" or "atariste" at least should have a processor ++ # > m68000). The system name ranges from "MiNT" over "FreeMiNT" ++ # to the lowercase version "mint" (or "freemint"). Finally ++ # the system name "TOS" denotes a system which is actually not ++ # MiNT. But MiNT is downward compatible to TOS, so this should ++ # be no problem. ++ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) ++ echo m68k-atari-mint${UNAME_RELEASE} ++ exit ;; ++ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) ++ echo m68k-atari-mint${UNAME_RELEASE} ++ exit ;; ++ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) ++ echo m68k-atari-mint${UNAME_RELEASE} ++ exit ;; ++ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) ++ echo m68k-milan-mint${UNAME_RELEASE} ++ exit ;; ++ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) ++ echo m68k-hades-mint${UNAME_RELEASE} ++ exit ;; ++ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) ++ echo m68k-unknown-mint${UNAME_RELEASE} ++ exit ;; ++ m68k:machten:*:*) ++ echo m68k-apple-machten${UNAME_RELEASE} ++ exit ;; ++ powerpc:machten:*:*) ++ echo powerpc-apple-machten${UNAME_RELEASE} ++ exit ;; ++ RISC*:Mach:*:*) ++ echo mips-dec-mach_bsd4.3 ++ exit ;; ++ RISC*:ULTRIX:*:*) ++ echo mips-dec-ultrix${UNAME_RELEASE} ++ exit ;; ++ VAX*:ULTRIX*:*:*) ++ echo vax-dec-ultrix${UNAME_RELEASE} ++ exit ;; ++ 2020:CLIX:*:* | 2430:CLIX:*:*) ++ echo clipper-intergraph-clix${UNAME_RELEASE} ++ exit ;; ++ mips:*:*:UMIPS | mips:*:*:RISCos) ++ eval $set_cc_for_build ++ sed 's/^ //' << EOF >$dummy.c ++#ifdef __cplusplus ++#include /* for printf() prototype */ ++ int main (int argc, char *argv[]) { ++#else ++ int main (argc, argv) int argc; char *argv[]; { ++#endif ++ #if defined (host_mips) && defined (MIPSEB) ++ #if defined (SYSTYPE_SYSV) ++ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); ++ #endif ++ #if defined (SYSTYPE_SVR4) ++ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); ++ #endif ++ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) ++ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); ++ #endif ++ #endif ++ exit (-1); ++ } ++EOF ++ $CC_FOR_BUILD -o $dummy $dummy.c && ++ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && ++ SYSTEM_NAME=`$dummy $dummyarg` && ++ { echo "$SYSTEM_NAME"; exit; } ++ echo mips-mips-riscos${UNAME_RELEASE} ++ exit ;; ++ Motorola:PowerMAX_OS:*:*) ++ echo powerpc-motorola-powermax ++ exit ;; ++ Motorola:*:4.3:PL8-*) ++ echo powerpc-harris-powermax ++ exit ;; ++ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) ++ echo powerpc-harris-powermax ++ exit ;; ++ Night_Hawk:Power_UNIX:*:*) ++ echo powerpc-harris-powerunix ++ exit ;; ++ m88k:CX/UX:7*:*) ++ echo m88k-harris-cxux7 ++ exit ;; ++ m88k:*:4*:R4*) ++ echo m88k-motorola-sysv4 ++ exit ;; ++ m88k:*:3*:R3*) ++ echo m88k-motorola-sysv3 ++ exit ;; ++ AViiON:dgux:*:*) ++ # DG/UX returns AViiON for all architectures ++ UNAME_PROCESSOR=`/usr/bin/uname -p` ++ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] ++ then ++ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ ++ [ ${TARGET_BINARY_INTERFACE}x = x ] ++ then ++ echo m88k-dg-dgux${UNAME_RELEASE} ++ else ++ echo m88k-dg-dguxbcs${UNAME_RELEASE} ++ fi ++ else ++ echo i586-dg-dgux${UNAME_RELEASE} ++ fi ++ exit ;; ++ M88*:DolphinOS:*:*) # DolphinOS (SVR3) ++ echo m88k-dolphin-sysv3 ++ exit ;; ++ M88*:*:R3*:*) ++ # Delta 88k system running SVR3 ++ echo m88k-motorola-sysv3 ++ exit ;; ++ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) ++ echo m88k-tektronix-sysv3 ++ exit ;; ++ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) ++ echo m68k-tektronix-bsd ++ exit ;; ++ *:IRIX*:*:*) ++ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` ++ exit ;; ++ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. ++ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id ++ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' ++ i*86:AIX:*:*) ++ echo i386-ibm-aix ++ exit ;; ++ ia64:AIX:*:*) ++ if [ -x /usr/bin/oslevel ] ; then ++ IBM_REV=`/usr/bin/oslevel` ++ else ++ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} ++ fi ++ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} ++ exit ;; ++ *:AIX:2:3) ++ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then ++ eval $set_cc_for_build ++ sed 's/^ //' << EOF >$dummy.c ++ #include ++ ++ main() ++ { ++ if (!__power_pc()) ++ exit(1); ++ puts("powerpc-ibm-aix3.2.5"); ++ exit(0); ++ } ++EOF ++ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` ++ then ++ echo "$SYSTEM_NAME" ++ else ++ echo rs6000-ibm-aix3.2.5 ++ fi ++ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then ++ echo rs6000-ibm-aix3.2.4 ++ else ++ echo rs6000-ibm-aix3.2 ++ fi ++ exit ;; ++ *:AIX:*:[4567]) ++ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` ++ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then ++ IBM_ARCH=rs6000 ++ else ++ IBM_ARCH=powerpc ++ fi ++ if [ -x /usr/bin/lslpp ] ; then ++ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | ++ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` ++ else ++ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} ++ fi ++ echo ${IBM_ARCH}-ibm-aix${IBM_REV} ++ exit ;; ++ *:AIX:*:*) ++ echo rs6000-ibm-aix ++ exit ;; ++ ibmrt:4.4BSD:*|romp-ibm:BSD:*) ++ echo romp-ibm-bsd4.4 ++ exit ;; ++ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and ++ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to ++ exit ;; # report: romp-ibm BSD 4.3 ++ *:BOSX:*:*) ++ echo rs6000-bull-bosx ++ exit ;; ++ DPX/2?00:B.O.S.:*:*) ++ echo m68k-bull-sysv3 ++ exit ;; ++ 9000/[34]??:4.3bsd:1.*:*) ++ echo m68k-hp-bsd ++ exit ;; ++ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) ++ echo m68k-hp-bsd4.4 ++ exit ;; ++ 9000/[34678]??:HP-UX:*:*) ++ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` ++ case "${UNAME_MACHINE}" in ++ 9000/31? ) HP_ARCH=m68000 ;; ++ 9000/[34]?? ) HP_ARCH=m68k ;; ++ 9000/[678][0-9][0-9]) ++ if [ -x /usr/bin/getconf ]; then ++ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` ++ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` ++ case "${sc_cpu_version}" in ++ 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 ++ 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 ++ 532) # CPU_PA_RISC2_0 ++ case "${sc_kernel_bits}" in ++ 32) HP_ARCH=hppa2.0n ;; ++ 64) HP_ARCH=hppa2.0w ;; ++ '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 ++ esac ;; ++ esac ++ fi ++ if [ "${HP_ARCH}" = "" ]; then ++ eval $set_cc_for_build ++ sed 's/^ //' << EOF >$dummy.c ++ ++ #define _HPUX_SOURCE ++ #include ++ #include ++ ++ int main () ++ { ++ #if defined(_SC_KERNEL_BITS) ++ long bits = sysconf(_SC_KERNEL_BITS); ++ #endif ++ long cpu = sysconf (_SC_CPU_VERSION); ++ ++ switch (cpu) ++ { ++ case CPU_PA_RISC1_0: puts ("hppa1.0"); break; ++ case CPU_PA_RISC1_1: puts ("hppa1.1"); break; ++ case CPU_PA_RISC2_0: ++ #if defined(_SC_KERNEL_BITS) ++ switch (bits) ++ { ++ case 64: puts ("hppa2.0w"); break; ++ case 32: puts ("hppa2.0n"); break; ++ default: puts ("hppa2.0"); break; ++ } break; ++ #else /* !defined(_SC_KERNEL_BITS) */ ++ puts ("hppa2.0"); break; ++ #endif ++ default: puts ("hppa1.0"); break; ++ } ++ exit (0); ++ } ++EOF ++ (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` ++ test -z "$HP_ARCH" && HP_ARCH=hppa ++ fi ;; ++ esac ++ if [ ${HP_ARCH} = hppa2.0w ] ++ then ++ eval $set_cc_for_build ++ ++ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating ++ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler ++ # generating 64-bit code. GNU and HP use different nomenclature: ++ # ++ # $ CC_FOR_BUILD=cc ./config.guess ++ # => hppa2.0w-hp-hpux11.23 ++ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess ++ # => hppa64-hp-hpux11.23 ++ ++ if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | ++ grep -q __LP64__ ++ then ++ HP_ARCH=hppa2.0w ++ else ++ HP_ARCH=hppa64 ++ fi ++ fi ++ echo ${HP_ARCH}-hp-hpux${HPUX_REV} ++ exit ;; ++ ia64:HP-UX:*:*) ++ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` ++ echo ia64-hp-hpux${HPUX_REV} ++ exit ;; ++ 3050*:HI-UX:*:*) ++ eval $set_cc_for_build ++ sed 's/^ //' << EOF >$dummy.c ++ #include ++ int ++ main () ++ { ++ long cpu = sysconf (_SC_CPU_VERSION); ++ /* The order matters, because CPU_IS_HP_MC68K erroneously returns ++ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct ++ results, however. */ ++ if (CPU_IS_PA_RISC (cpu)) ++ { ++ switch (cpu) ++ { ++ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; ++ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; ++ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; ++ default: puts ("hppa-hitachi-hiuxwe2"); break; ++ } ++ } ++ else if (CPU_IS_HP_MC68K (cpu)) ++ puts ("m68k-hitachi-hiuxwe2"); ++ else puts ("unknown-hitachi-hiuxwe2"); ++ exit (0); ++ } ++EOF ++ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && ++ { echo "$SYSTEM_NAME"; exit; } ++ echo unknown-hitachi-hiuxwe2 ++ exit ;; ++ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) ++ echo hppa1.1-hp-bsd ++ exit ;; ++ 9000/8??:4.3bsd:*:*) ++ echo hppa1.0-hp-bsd ++ exit ;; ++ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) ++ echo hppa1.0-hp-mpeix ++ exit ;; ++ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) ++ echo hppa1.1-hp-osf ++ exit ;; ++ hp8??:OSF1:*:*) ++ echo hppa1.0-hp-osf ++ exit ;; ++ i*86:OSF1:*:*) ++ if [ -x /usr/sbin/sysversion ] ; then ++ echo ${UNAME_MACHINE}-unknown-osf1mk ++ else ++ echo ${UNAME_MACHINE}-unknown-osf1 ++ fi ++ exit ;; ++ parisc*:Lites*:*:*) ++ echo hppa1.1-hp-lites ++ exit ;; ++ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) ++ echo c1-convex-bsd ++ exit ;; ++ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) ++ if getsysinfo -f scalar_acc ++ then echo c32-convex-bsd ++ else echo c2-convex-bsd ++ fi ++ exit ;; ++ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) ++ echo c34-convex-bsd ++ exit ;; ++ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) ++ echo c38-convex-bsd ++ exit ;; ++ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) ++ echo c4-convex-bsd ++ exit ;; ++ CRAY*Y-MP:*:*:*) ++ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' ++ exit ;; ++ CRAY*[A-Z]90:*:*:*) ++ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ ++ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ ++ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ ++ -e 's/\.[^.]*$/.X/' ++ exit ;; ++ CRAY*TS:*:*:*) ++ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' ++ exit ;; ++ CRAY*T3E:*:*:*) ++ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' ++ exit ;; ++ CRAY*SV1:*:*:*) ++ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' ++ exit ;; ++ *:UNICOS/mp:*:*) ++ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' ++ exit ;; ++ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) ++ FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` ++ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` ++ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` ++ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" ++ exit ;; ++ 5000:UNIX_System_V:4.*:*) ++ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` ++ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` ++ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" ++ exit ;; ++ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) ++ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} ++ exit ;; ++ sparc*:BSD/OS:*:*) ++ echo sparc-unknown-bsdi${UNAME_RELEASE} ++ exit ;; ++ *:BSD/OS:*:*) ++ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} ++ exit ;; ++ *:FreeBSD:*:*) ++ UNAME_PROCESSOR=`/usr/bin/uname -p` ++ case ${UNAME_PROCESSOR} in ++ amd64) ++ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; ++ *) ++ echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; ++ esac ++ exit ;; ++ i*:CYGWIN*:*) ++ echo ${UNAME_MACHINE}-pc-cygwin ++ exit ;; ++ *:MINGW64*:*) ++ echo ${UNAME_MACHINE}-pc-mingw64 ++ exit ;; ++ *:MINGW*:*) ++ echo ${UNAME_MACHINE}-pc-mingw32 ++ exit ;; ++ *:MSYS*:*) ++ echo ${UNAME_MACHINE}-pc-msys ++ exit ;; ++ i*:windows32*:*) ++ # uname -m includes "-pc" on this system. ++ echo ${UNAME_MACHINE}-mingw32 ++ exit ;; ++ i*:PW*:*) ++ echo ${UNAME_MACHINE}-pc-pw32 ++ exit ;; ++ *:Interix*:*) ++ case ${UNAME_MACHINE} in ++ x86) ++ echo i586-pc-interix${UNAME_RELEASE} ++ exit ;; ++ authenticamd | genuineintel | EM64T) ++ echo x86_64-unknown-interix${UNAME_RELEASE} ++ exit ;; ++ IA64) ++ echo ia64-unknown-interix${UNAME_RELEASE} ++ exit ;; ++ esac ;; ++ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) ++ echo i${UNAME_MACHINE}-pc-mks ++ exit ;; ++ 8664:Windows_NT:*) ++ echo x86_64-pc-mks ++ exit ;; ++ i*:Windows_NT*:* | Pentium*:Windows_NT*:*) ++ # How do we know it's Interix rather than the generic POSIX subsystem? ++ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we ++ # UNAME_MACHINE based on the output of uname instead of i386? ++ echo i586-pc-interix ++ exit ;; ++ i*:UWIN*:*) ++ echo ${UNAME_MACHINE}-pc-uwin ++ exit ;; ++ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) ++ echo x86_64-unknown-cygwin ++ exit ;; ++ p*:CYGWIN*:*) ++ echo powerpcle-unknown-cygwin ++ exit ;; ++ prep*:SunOS:5.*:*) ++ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` ++ exit ;; ++ *:GNU:*:*) ++ # the GNU system ++ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` ++ exit ;; ++ *:GNU/*:*:*) ++ # other systems with GNU libc and userland ++ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} ++ exit ;; ++ i*86:Minix:*:*) ++ echo ${UNAME_MACHINE}-pc-minix ++ exit ;; ++ aarch64:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ aarch64_be:Linux:*:*) ++ UNAME_MACHINE=aarch64_be ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ alpha:Linux:*:*) ++ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in ++ EV5) UNAME_MACHINE=alphaev5 ;; ++ EV56) UNAME_MACHINE=alphaev56 ;; ++ PCA56) UNAME_MACHINE=alphapca56 ;; ++ PCA57) UNAME_MACHINE=alphapca56 ;; ++ EV6) UNAME_MACHINE=alphaev6 ;; ++ EV67) UNAME_MACHINE=alphaev67 ;; ++ EV68*) UNAME_MACHINE=alphaev68 ;; ++ esac ++ objdump --private-headers /bin/sh | grep -q ld.so.1 ++ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ arc:Linux:*:* | arceb:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ arm*:Linux:*:*) ++ eval $set_cc_for_build ++ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ ++ | grep -q __ARM_EABI__ ++ then ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ else ++ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ ++ | grep -q __ARM_PCS_VFP ++ then ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi ++ else ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf ++ fi ++ fi ++ exit ;; ++ avr32*:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ cris:Linux:*:*) ++ echo ${UNAME_MACHINE}-axis-linux-${LIBC} ++ exit ;; ++ crisv32:Linux:*:*) ++ echo ${UNAME_MACHINE}-axis-linux-${LIBC} ++ exit ;; ++ e2k:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ frv:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ hexagon:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ i*86:Linux:*:*) ++ echo ${UNAME_MACHINE}-pc-linux-${LIBC} ++ exit ;; ++ ia64:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ k1om:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ m32r*:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ m68*:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ mips:Linux:*:* | mips64:Linux:*:*) ++ eval $set_cc_for_build ++ sed 's/^ //' << EOF >$dummy.c ++ #undef CPU ++ #undef ${UNAME_MACHINE} ++ #undef ${UNAME_MACHINE}el ++ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) ++ CPU=${UNAME_MACHINE}el ++ #else ++ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) ++ CPU=${UNAME_MACHINE} ++ #else ++ CPU= ++ #endif ++ #endif ++EOF ++ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` ++ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ++ ;; ++ mips64el:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ openrisc*:Linux:*:*) ++ echo or1k-unknown-linux-${LIBC} ++ exit ;; ++ or32:Linux:*:* | or1k*:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ padre:Linux:*:*) ++ echo sparc-unknown-linux-${LIBC} ++ exit ;; ++ parisc64:Linux:*:* | hppa64:Linux:*:*) ++ echo hppa64-unknown-linux-${LIBC} ++ exit ;; ++ parisc:Linux:*:* | hppa:Linux:*:*) ++ # Look for CPU level ++ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in ++ PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; ++ PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; ++ *) echo hppa-unknown-linux-${LIBC} ;; ++ esac ++ exit ;; ++ ppc64:Linux:*:*) ++ echo powerpc64-unknown-linux-${LIBC} ++ exit ;; ++ ppc:Linux:*:*) ++ echo powerpc-unknown-linux-${LIBC} ++ exit ;; ++ ppc64le:Linux:*:*) ++ echo powerpc64le-unknown-linux-${LIBC} ++ exit ;; ++ ppcle:Linux:*:*) ++ echo powerpcle-unknown-linux-${LIBC} ++ exit ;; ++ riscv32:Linux:*:* | riscv64:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ s390:Linux:*:* | s390x:Linux:*:*) ++ echo ${UNAME_MACHINE}-ibm-linux-${LIBC} ++ exit ;; ++ sh64*:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ sh*:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ sparc:Linux:*:* | sparc64:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ tile*:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ vax:Linux:*:*) ++ echo ${UNAME_MACHINE}-dec-linux-${LIBC} ++ exit ;; ++ x86_64:Linux:*:*) ++ echo ${UNAME_MACHINE}-pc-linux-${LIBC} ++ exit ;; ++ xtensa*:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ i*86:DYNIX/ptx:4*:*) ++ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. ++ # earlier versions are messed up and put the nodename in both ++ # sysname and nodename. ++ echo i386-sequent-sysv4 ++ exit ;; ++ i*86:UNIX_SV:4.2MP:2.*) ++ # Unixware is an offshoot of SVR4, but it has its own version ++ # number series starting with 2... ++ # I am not positive that other SVR4 systems won't match this, ++ # I just have to hope. -- rms. ++ # Use sysv4.2uw... so that sysv4* matches it. ++ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} ++ exit ;; ++ i*86:OS/2:*:*) ++ # If we were able to find `uname', then EMX Unix compatibility ++ # is probably installed. ++ echo ${UNAME_MACHINE}-pc-os2-emx ++ exit ;; ++ i*86:XTS-300:*:STOP) ++ echo ${UNAME_MACHINE}-unknown-stop ++ exit ;; ++ i*86:atheos:*:*) ++ echo ${UNAME_MACHINE}-unknown-atheos ++ exit ;; ++ i*86:syllable:*:*) ++ echo ${UNAME_MACHINE}-pc-syllable ++ exit ;; ++ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) ++ echo i386-unknown-lynxos${UNAME_RELEASE} ++ exit ;; ++ i*86:*DOS:*:*) ++ echo ${UNAME_MACHINE}-pc-msdosdjgpp ++ exit ;; ++ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) ++ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` ++ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then ++ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} ++ else ++ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} ++ fi ++ exit ;; ++ i*86:*:5:[678]*) ++ # UnixWare 7.x, OpenUNIX and OpenServer 6. ++ case `/bin/uname -X | grep "^Machine"` in ++ *486*) UNAME_MACHINE=i486 ;; ++ *Pentium) UNAME_MACHINE=i586 ;; ++ *Pent*|*Celeron) UNAME_MACHINE=i686 ;; ++ esac ++ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} ++ exit ;; ++ i*86:*:3.2:*) ++ if test -f /usr/options/cb.name; then ++ UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then ++ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` ++ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 ++ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ ++ && UNAME_MACHINE=i586 ++ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ ++ && UNAME_MACHINE=i686 ++ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ ++ && UNAME_MACHINE=i686 ++ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL ++ else ++ echo ${UNAME_MACHINE}-pc-sysv32 ++ fi ++ exit ;; ++ pc:*:*:*) ++ # Left here for compatibility: ++ # uname -m prints for DJGPP always 'pc', but it prints nothing about ++ # the processor, so we play safe by assuming i586. ++ # Note: whatever this is, it MUST be the same as what config.sub ++ # prints for the "djgpp" host, or else GDB configure will decide that ++ # this is a cross-build. ++ echo i586-pc-msdosdjgpp ++ exit ;; ++ Intel:Mach:3*:*) ++ echo i386-pc-mach3 ++ exit ;; ++ paragon:*:*:*) ++ echo i860-intel-osf1 ++ exit ;; ++ i860:*:4.*:*) # i860-SVR4 ++ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then ++ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 ++ else # Add other i860-SVR4 vendors below as they are discovered. ++ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 ++ fi ++ exit ;; ++ mini*:CTIX:SYS*5:*) ++ # "miniframe" ++ echo m68010-convergent-sysv ++ exit ;; ++ mc68k:UNIX:SYSTEM5:3.51m) ++ echo m68k-convergent-sysv ++ exit ;; ++ M680?0:D-NIX:5.3:*) ++ echo m68k-diab-dnix ++ exit ;; ++ M68*:*:R3V[5678]*:*) ++ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; ++ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) ++ OS_REL='' ++ test -r /etc/.relid \ ++ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` ++ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ ++ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } ++ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ ++ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; ++ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) ++ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ ++ && { echo i486-ncr-sysv4; exit; } ;; ++ NCR*:*:4.2:* | MPRAS*:*:4.2:*) ++ OS_REL='.3' ++ test -r /etc/.relid \ ++ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` ++ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ ++ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } ++ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ ++ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ++ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ ++ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; ++ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) ++ echo m68k-unknown-lynxos${UNAME_RELEASE} ++ exit ;; ++ mc68030:UNIX_System_V:4.*:*) ++ echo m68k-atari-sysv4 ++ exit ;; ++ TSUNAMI:LynxOS:2.*:*) ++ echo sparc-unknown-lynxos${UNAME_RELEASE} ++ exit ;; ++ rs6000:LynxOS:2.*:*) ++ echo rs6000-unknown-lynxos${UNAME_RELEASE} ++ exit ;; ++ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) ++ echo powerpc-unknown-lynxos${UNAME_RELEASE} ++ exit ;; ++ SM[BE]S:UNIX_SV:*:*) ++ echo mips-dde-sysv${UNAME_RELEASE} ++ exit ;; ++ RM*:ReliantUNIX-*:*:*) ++ echo mips-sni-sysv4 ++ exit ;; ++ RM*:SINIX-*:*:*) ++ echo mips-sni-sysv4 ++ exit ;; ++ *:SINIX-*:*:*) ++ if uname -p 2>/dev/null >/dev/null ; then ++ UNAME_MACHINE=`(uname -p) 2>/dev/null` ++ echo ${UNAME_MACHINE}-sni-sysv4 ++ else ++ echo ns32k-sni-sysv ++ fi ++ exit ;; ++ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort ++ # says ++ echo i586-unisys-sysv4 ++ exit ;; ++ *:UNIX_System_V:4*:FTX*) ++ # From Gerald Hewes . ++ # How about differentiating between stratus architectures? -djm ++ echo hppa1.1-stratus-sysv4 ++ exit ;; ++ *:*:*:FTX*) ++ # From seanf@swdc.stratus.com. ++ echo i860-stratus-sysv4 ++ exit ;; ++ i*86:VOS:*:*) ++ # From Paul.Green@stratus.com. ++ echo ${UNAME_MACHINE}-stratus-vos ++ exit ;; ++ *:VOS:*:*) ++ # From Paul.Green@stratus.com. ++ echo hppa1.1-stratus-vos ++ exit ;; ++ mc68*:A/UX:*:*) ++ echo m68k-apple-aux${UNAME_RELEASE} ++ exit ;; ++ news*:NEWS-OS:6*:*) ++ echo mips-sony-newsos6 ++ exit ;; ++ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) ++ if [ -d /usr/nec ]; then ++ echo mips-nec-sysv${UNAME_RELEASE} ++ else ++ echo mips-unknown-sysv${UNAME_RELEASE} ++ fi ++ exit ;; ++ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. ++ echo powerpc-be-beos ++ exit ;; ++ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. ++ echo powerpc-apple-beos ++ exit ;; ++ BePC:BeOS:*:*) # BeOS running on Intel PC compatible. ++ echo i586-pc-beos ++ exit ;; ++ BePC:Haiku:*:*) # Haiku running on Intel PC compatible. ++ echo i586-pc-haiku ++ exit ;; ++ x86_64:Haiku:*:*) ++ echo x86_64-unknown-haiku ++ exit ;; ++ SX-4:SUPER-UX:*:*) ++ echo sx4-nec-superux${UNAME_RELEASE} ++ exit ;; ++ SX-5:SUPER-UX:*:*) ++ echo sx5-nec-superux${UNAME_RELEASE} ++ exit ;; ++ SX-6:SUPER-UX:*:*) ++ echo sx6-nec-superux${UNAME_RELEASE} ++ exit ;; ++ SX-7:SUPER-UX:*:*) ++ echo sx7-nec-superux${UNAME_RELEASE} ++ exit ;; ++ SX-8:SUPER-UX:*:*) ++ echo sx8-nec-superux${UNAME_RELEASE} ++ exit ;; ++ SX-8R:SUPER-UX:*:*) ++ echo sx8r-nec-superux${UNAME_RELEASE} ++ exit ;; ++ SX-ACE:SUPER-UX:*:*) ++ echo sxace-nec-superux${UNAME_RELEASE} ++ exit ;; ++ Power*:Rhapsody:*:*) ++ echo powerpc-apple-rhapsody${UNAME_RELEASE} ++ exit ;; ++ *:Rhapsody:*:*) ++ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} ++ exit ;; ++ *:Darwin:*:*) ++ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown ++ eval $set_cc_for_build ++ if test "$UNAME_PROCESSOR" = unknown ; then ++ UNAME_PROCESSOR=powerpc ++ fi ++ if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then ++ if [ "$CC_FOR_BUILD" != no_compiler_found ]; then ++ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ ++ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ ++ grep IS_64BIT_ARCH >/dev/null ++ then ++ case $UNAME_PROCESSOR in ++ i386) UNAME_PROCESSOR=x86_64 ;; ++ powerpc) UNAME_PROCESSOR=powerpc64 ;; ++ esac ++ fi ++ fi ++ elif test "$UNAME_PROCESSOR" = i386 ; then ++ # Avoid executing cc on OS X 10.9, as it ships with a stub ++ # that puts up a graphical alert prompting to install ++ # developer tools. Any system running Mac OS X 10.7 or ++ # later (Darwin 11 and later) is required to have a 64-bit ++ # processor. This is not true of the ARM version of Darwin ++ # that Apple uses in portable devices. ++ UNAME_PROCESSOR=x86_64 ++ fi ++ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} ++ exit ;; ++ *:procnto*:*:* | *:QNX:[0123456789]*:*) ++ UNAME_PROCESSOR=`uname -p` ++ if test "$UNAME_PROCESSOR" = x86; then ++ UNAME_PROCESSOR=i386 ++ UNAME_MACHINE=pc ++ fi ++ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} ++ exit ;; ++ *:QNX:*:4*) ++ echo i386-pc-qnx ++ exit ;; ++ NEO-?:NONSTOP_KERNEL:*:*) ++ echo neo-tandem-nsk${UNAME_RELEASE} ++ exit ;; ++ NSE-*:NONSTOP_KERNEL:*:*) ++ echo nse-tandem-nsk${UNAME_RELEASE} ++ exit ;; ++ NSR-?:NONSTOP_KERNEL:*:*) ++ echo nsr-tandem-nsk${UNAME_RELEASE} ++ exit ;; ++ *:NonStop-UX:*:*) ++ echo mips-compaq-nonstopux ++ exit ;; ++ BS2000:POSIX*:*:*) ++ echo bs2000-siemens-sysv ++ exit ;; ++ DS/*:UNIX_System_V:*:*) ++ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} ++ exit ;; ++ *:Plan9:*:*) ++ # "uname -m" is not consistent, so use $cputype instead. 386 ++ # is converted to i386 for consistency with other x86 ++ # operating systems. ++ if test "$cputype" = 386; then ++ UNAME_MACHINE=i386 ++ else ++ UNAME_MACHINE="$cputype" ++ fi ++ echo ${UNAME_MACHINE}-unknown-plan9 ++ exit ;; ++ *:TOPS-10:*:*) ++ echo pdp10-unknown-tops10 ++ exit ;; ++ *:TENEX:*:*) ++ echo pdp10-unknown-tenex ++ exit ;; ++ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) ++ echo pdp10-dec-tops20 ++ exit ;; ++ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) ++ echo pdp10-xkl-tops20 ++ exit ;; ++ *:TOPS-20:*:*) ++ echo pdp10-unknown-tops20 ++ exit ;; ++ *:ITS:*:*) ++ echo pdp10-unknown-its ++ exit ;; ++ SEI:*:*:SEIUX) ++ echo mips-sei-seiux${UNAME_RELEASE} ++ exit ;; ++ *:DragonFly:*:*) ++ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ++ exit ;; ++ *:*VMS:*:*) ++ UNAME_MACHINE=`(uname -p) 2>/dev/null` ++ case "${UNAME_MACHINE}" in ++ A*) echo alpha-dec-vms ; exit ;; ++ I*) echo ia64-dec-vms ; exit ;; ++ V*) echo vax-dec-vms ; exit ;; ++ esac ;; ++ *:XENIX:*:SysV) ++ echo i386-pc-xenix ++ exit ;; ++ i*86:skyos:*:*) ++ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` ++ exit ;; ++ i*86:rdos:*:*) ++ echo ${UNAME_MACHINE}-pc-rdos ++ exit ;; ++ i*86:AROS:*:*) ++ echo ${UNAME_MACHINE}-pc-aros ++ exit ;; ++ x86_64:VMkernel:*:*) ++ echo ${UNAME_MACHINE}-unknown-esx ++ exit ;; ++ amd64:Isilon\ OneFS:*:*) ++ echo x86_64-unknown-onefs ++ exit ;; ++esac ++ ++cat >&2 </dev/null || echo unknown` ++uname -r = `(uname -r) 2>/dev/null || echo unknown` ++uname -s = `(uname -s) 2>/dev/null || echo unknown` ++uname -v = `(uname -v) 2>/dev/null || echo unknown` ++ ++/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` ++/bin/uname -X = `(/bin/uname -X) 2>/dev/null` ++ ++hostinfo = `(hostinfo) 2>/dev/null` ++/bin/universe = `(/bin/universe) 2>/dev/null` ++/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` ++/bin/arch = `(/bin/arch) 2>/dev/null` ++/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` ++/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` ++ ++UNAME_MACHINE = ${UNAME_MACHINE} ++UNAME_RELEASE = ${UNAME_RELEASE} ++UNAME_SYSTEM = ${UNAME_SYSTEM} ++UNAME_VERSION = ${UNAME_VERSION} ++EOF ++ ++exit 1 ++ ++# Local variables: ++# eval: (add-hook 'write-file-hooks 'time-stamp) ++# time-stamp-start: "timestamp='" ++# time-stamp-format: "%:y-%02m-%02d" ++# time-stamp-end: "'" ++# End: diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/config.h.in index 000000000,000000000..87cb80598 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/config.h.in @@@ -1,0 -1,0 +1,134 @@@ ++/* config.h.in. Generated from configure.ac by autoheader. */ ++ ++/* ELF size: 32 or 64 */ ++#undef BACKTRACE_ELF_SIZE ++ ++/* Define to 1 if you have the __atomic functions */ ++#undef HAVE_ATOMIC_FUNCTIONS ++ ++/* Define to 1 if you have the declaration of `strnlen', and to 0 if you ++ don't. */ ++#undef HAVE_DECL_STRNLEN ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_DLFCN_H ++ ++/* Define if dl_iterate_phdr is available. */ ++#undef HAVE_DL_ITERATE_PHDR ++ ++/* Define to 1 if you have the fcntl function */ ++#undef HAVE_FCNTL ++ ++/* Define if getexecname is available. */ ++#undef HAVE_GETEXECNAME ++ ++/* Define if _Unwind_GetIPInfo is available. */ ++#undef HAVE_GETIPINFO ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_INTTYPES_H ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_LINK_H ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_MEMORY_H ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_STDINT_H ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_STDLIB_H ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_STRINGS_H ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_STRING_H ++ ++/* Define to 1 if you have the __sync functions */ ++#undef HAVE_SYNC_FUNCTIONS ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SYS_MMAN_H ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SYS_STAT_H ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SYS_TYPES_H ++ ++/* Define to 1 if you have the header file. */ ++#undef HAVE_UNISTD_H ++ ++/* Define to the sub-directory in which libtool stores uninstalled libraries. ++ */ ++#undef LT_OBJDIR ++ ++/* Define to the address where bug reports for this package should be sent. */ ++#undef PACKAGE_BUGREPORT ++ ++/* Define to the full name of this package. */ ++#undef PACKAGE_NAME ++ ++/* Define to the full name and version of this package. */ ++#undef PACKAGE_STRING ++ ++/* Define to the one symbol short name of this package. */ ++#undef PACKAGE_TARNAME ++ ++/* Define to the home page for this package. */ ++#undef PACKAGE_URL ++ ++/* Define to the version of this package. */ ++#undef PACKAGE_VERSION ++ ++/* The size of `char', as computed by sizeof. */ ++#undef SIZEOF_CHAR ++ ++/* The size of `int', as computed by sizeof. */ ++#undef SIZEOF_INT ++ ++/* The size of `long', as computed by sizeof. */ ++#undef SIZEOF_LONG ++ ++/* The size of `short', as computed by sizeof. */ ++#undef SIZEOF_SHORT ++ ++/* The size of `void *', as computed by sizeof. */ ++#undef SIZEOF_VOID_P ++ ++/* Define to 1 if you have the ANSI C header files. */ ++#undef STDC_HEADERS ++ ++/* Enable extensions on AIX 3, Interix. */ ++#ifndef _ALL_SOURCE ++# undef _ALL_SOURCE ++#endif ++/* Enable GNU extensions on systems that have them. */ ++#ifndef _GNU_SOURCE ++# undef _GNU_SOURCE ++#endif ++/* Enable threading extensions on Solaris. */ ++#ifndef _POSIX_PTHREAD_SEMANTICS ++# undef _POSIX_PTHREAD_SEMANTICS ++#endif ++/* Enable extensions on HP NonStop. */ ++#ifndef _TANDEM_SOURCE ++# undef _TANDEM_SOURCE ++#endif ++/* Enable general extensions on Solaris. */ ++#ifndef __EXTENSIONS__ ++# undef __EXTENSIONS__ ++#endif ++ ++ ++/* Define to 1 if on MINIX. */ ++#undef _MINIX ++ ++/* Define to 2 if the system does not provide POSIX.1 features except with ++ this defined. */ ++#undef _POSIX_1_SOURCE ++ ++/* Define to 1 if you need to in order for `stat' and other things to work. */ ++#undef _POSIX_SOURCE diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/config.sub index 000000000,000000000..3478c1fd0 new file mode 100755 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/config.sub @@@ -1,0 -1,0 +1,1825 @@@ ++#! /bin/sh ++# Configuration validation subroutine script. ++# Copyright 1992-2016 Free Software Foundation, Inc. ++ ++timestamp='2016-11-19' ++ ++# This file is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, see . ++# ++# As a special exception to the GNU General Public License, if you ++# distribute this file as part of a program that contains a ++# configuration script generated by Autoconf, you may include it under ++# the same distribution terms that you use for the rest of that ++# program. This Exception is an additional permission under section 7 ++# of the GNU General Public License, version 3 ("GPLv3"). ++ ++ ++# Please send patches to . ++# ++# Configuration subroutine to validate and canonicalize a configuration type. ++# Supply the specified configuration type as an argument. ++# If it is invalid, we print an error message on stderr and exit with code 1. ++# Otherwise, we print the canonical config type on stdout and succeed. ++ ++# You can get the latest version of this script from: ++# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub ++ ++# This file is supposed to be the same for all GNU packages ++# and recognize all the CPU types, system types and aliases ++# that are meaningful with *any* GNU software. ++# Each package is responsible for reporting which valid configurations ++# it does not support. The user should be able to distinguish ++# a failure to support a valid configuration from a meaningless ++# configuration. ++ ++# The goal of this file is to map all the various variations of a given ++# machine specification into a single specification in the form: ++# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM ++# or in some cases, the newer four-part form: ++# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM ++# It is wrong to echo any other type of specification. ++ ++me=`echo "$0" | sed -e 's,.*/,,'` ++ ++usage="\ ++Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS ++ ++Canonicalize a configuration name. ++ ++Operation modes: ++ -h, --help print this help, then exit ++ -t, --time-stamp print date of last modification, then exit ++ -v, --version print version number, then exit ++ ++Report bugs and patches to ." ++ ++version="\ ++GNU config.sub ($timestamp) ++ ++Copyright 1992-2016 Free Software Foundation, Inc. ++ ++This is free software; see the source for copying conditions. There is NO ++warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." ++ ++help=" ++Try \`$me --help' for more information." ++ ++# Parse command line ++while test $# -gt 0 ; do ++ case $1 in ++ --time-stamp | --time* | -t ) ++ echo "$timestamp" ; exit ;; ++ --version | -v ) ++ echo "$version" ; exit ;; ++ --help | --h* | -h ) ++ echo "$usage"; exit ;; ++ -- ) # Stop option processing ++ shift; break ;; ++ - ) # Use stdin as input. ++ break ;; ++ -* ) ++ echo "$me: invalid option $1$help" ++ exit 1 ;; ++ ++ *local*) ++ # First pass through any local machine types. ++ echo $1 ++ exit ;; ++ ++ * ) ++ break ;; ++ esac ++done ++ ++case $# in ++ 0) echo "$me: missing argument$help" >&2 ++ exit 1;; ++ 1) ;; ++ *) echo "$me: too many arguments$help" >&2 ++ exit 1;; ++esac ++ ++# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). ++# Here we must recognize all the valid KERNEL-OS combinations. ++maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` ++case $maybe_os in ++ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ ++ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ ++ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ ++ kopensolaris*-gnu* | cloudabi*-eabi* | \ ++ storm-chaos* | os2-emx* | rtmk-nova*) ++ os=-$maybe_os ++ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ++ ;; ++ android-linux) ++ os=-linux-android ++ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ++ ;; ++ *) ++ basic_machine=`echo $1 | sed 's/-[^-]*$//'` ++ if [ $basic_machine != $1 ] ++ then os=`echo $1 | sed 's/.*-/-/'` ++ else os=; fi ++ ;; ++esac ++ ++### Let's recognize common machines as not being operating systems so ++### that things like config.sub decstation-3100 work. We also ++### recognize some manufacturers as not being operating systems, so we ++### can provide default operating systems below. ++case $os in ++ -sun*os*) ++ # Prevent following clause from handling this invalid input. ++ ;; ++ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ ++ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ ++ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ ++ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ ++ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ ++ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ ++ -apple | -axis | -knuth | -cray | -microblaze*) ++ os= ++ basic_machine=$1 ++ ;; ++ -bluegene*) ++ os=-cnk ++ ;; ++ -sim | -cisco | -oki | -wec | -winbond) ++ os= ++ basic_machine=$1 ++ ;; ++ -scout) ++ ;; ++ -wrs) ++ os=-vxworks ++ basic_machine=$1 ++ ;; ++ -chorusos*) ++ os=-chorusos ++ basic_machine=$1 ++ ;; ++ -chorusrdb) ++ os=-chorusrdb ++ basic_machine=$1 ++ ;; ++ -hiux*) ++ os=-hiuxwe2 ++ ;; ++ -sco6) ++ os=-sco5v6 ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ++ ;; ++ -sco5) ++ os=-sco3.2v5 ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ++ ;; ++ -sco4) ++ os=-sco3.2v4 ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ++ ;; ++ -sco3.2.[4-9]*) ++ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ++ ;; ++ -sco3.2v[4-9]*) ++ # Don't forget version if it is 3.2v4 or newer. ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ++ ;; ++ -sco5v6*) ++ # Don't forget version if it is 3.2v4 or newer. ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ++ ;; ++ -sco*) ++ os=-sco3.2v2 ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ++ ;; ++ -udk*) ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ++ ;; ++ -isc) ++ os=-isc2.2 ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ++ ;; ++ -clix*) ++ basic_machine=clipper-intergraph ++ ;; ++ -isc*) ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ++ ;; ++ -lynx*178) ++ os=-lynxos178 ++ ;; ++ -lynx*5) ++ os=-lynxos5 ++ ;; ++ -lynx*) ++ os=-lynxos ++ ;; ++ -ptx*) ++ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ++ ;; ++ -windowsnt*) ++ os=`echo $os | sed -e 's/windowsnt/winnt/'` ++ ;; ++ -psos*) ++ os=-psos ++ ;; ++ -mint | -mint[0-9]*) ++ basic_machine=m68k-atari ++ os=-mint ++ ;; ++esac ++ ++# Decode aliases for certain CPU-COMPANY combinations. ++case $basic_machine in ++ # Recognize the basic CPU types without company name. ++ # Some are omitted here because they have special meanings below. ++ 1750a | 580 \ ++ | a29k \ ++ | aarch64 | aarch64_be \ ++ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ ++ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ ++ | am33_2.0 \ ++ | arc | arceb \ ++ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ ++ | avr | avr32 \ ++ | ba \ ++ | be32 | be64 \ ++ | bfin \ ++ | c4x | c8051 | clipper \ ++ | d10v | d30v | dlx | dsp16xx \ ++ | e2k | epiphany \ ++ | fido | fr30 | frv | ft32 \ ++ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ ++ | hexagon \ ++ | i370 | i860 | i960 | ia64 \ ++ | ip2k | iq2000 \ ++ | k1om \ ++ | le32 | le64 \ ++ | lm32 \ ++ | m32c | m32r | m32rle | m68000 | m68k | m88k \ ++ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ ++ | mips | mipsbe | mipseb | mipsel | mipsle \ ++ | mips16 \ ++ | mips64 | mips64el \ ++ | mips64octeon | mips64octeonel \ ++ | mips64orion | mips64orionel \ ++ | mips64r5900 | mips64r5900el \ ++ | mips64vr | mips64vrel \ ++ | mips64vr4100 | mips64vr4100el \ ++ | mips64vr4300 | mips64vr4300el \ ++ | mips64vr5000 | mips64vr5000el \ ++ | mips64vr5900 | mips64vr5900el \ ++ | mipsisa32 | mipsisa32el \ ++ | mipsisa32r2 | mipsisa32r2el \ ++ | mipsisa32r6 | mipsisa32r6el \ ++ | mipsisa64 | mipsisa64el \ ++ | mipsisa64r2 | mipsisa64r2el \ ++ | mipsisa64r6 | mipsisa64r6el \ ++ | mipsisa64sb1 | mipsisa64sb1el \ ++ | mipsisa64sr71k | mipsisa64sr71kel \ ++ | mipsr5900 | mipsr5900el \ ++ | mipstx39 | mipstx39el \ ++ | mn10200 | mn10300 \ ++ | moxie \ ++ | mt \ ++ | msp430 \ ++ | nds32 | nds32le | nds32be \ ++ | nios | nios2 | nios2eb | nios2el \ ++ | ns16k | ns32k \ ++ | open8 | or1k | or1knd | or32 \ ++ | pdp10 | pdp11 | pj | pjl \ ++ | powerpc | powerpc64 | powerpc64le | powerpcle \ ++ | pru \ ++ | pyramid \ ++ | riscv32 | riscv64 \ ++ | rl78 | rx \ ++ | score \ ++ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ ++ | sh64 | sh64le \ ++ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ ++ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ ++ | spu \ ++ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ ++ | ubicom32 \ ++ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ ++ | visium \ ++ | we32k \ ++ | x86 | xc16x | xstormy16 | xtensa \ ++ | z8k | z80) ++ basic_machine=$basic_machine-unknown ++ ;; ++ c54x) ++ basic_machine=tic54x-unknown ++ ;; ++ c55x) ++ basic_machine=tic55x-unknown ++ ;; ++ c6x) ++ basic_machine=tic6x-unknown ++ ;; ++ leon|leon[3-9]) ++ basic_machine=sparc-$basic_machine ++ ;; ++ m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) ++ basic_machine=$basic_machine-unknown ++ os=-none ++ ;; ++ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ++ ;; ++ ms1) ++ basic_machine=mt-unknown ++ ;; ++ ++ strongarm | thumb | xscale) ++ basic_machine=arm-unknown ++ ;; ++ xgate) ++ basic_machine=$basic_machine-unknown ++ os=-none ++ ;; ++ xscaleeb) ++ basic_machine=armeb-unknown ++ ;; ++ ++ xscaleel) ++ basic_machine=armel-unknown ++ ;; ++ ++ # We use `pc' rather than `unknown' ++ # because (1) that's what they normally are, and ++ # (2) the word "unknown" tends to confuse beginning users. ++ i*86 | x86_64) ++ basic_machine=$basic_machine-pc ++ ;; ++ # Object if more than one company name word. ++ *-*-*) ++ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 ++ exit 1 ++ ;; ++ # Recognize the basic CPU types with company name. ++ 580-* \ ++ | a29k-* \ ++ | aarch64-* | aarch64_be-* \ ++ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ ++ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ ++ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ ++ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ ++ | avr-* | avr32-* \ ++ | ba-* \ ++ | be32-* | be64-* \ ++ | bfin-* | bs2000-* \ ++ | c[123]* | c30-* | [cjt]90-* | c4x-* \ ++ | c8051-* | clipper-* | craynv-* | cydra-* \ ++ | d10v-* | d30v-* | dlx-* \ ++ | e2k-* | elxsi-* \ ++ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ ++ | h8300-* | h8500-* \ ++ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ ++ | hexagon-* \ ++ | i*86-* | i860-* | i960-* | ia64-* \ ++ | ip2k-* | iq2000-* \ ++ | k1om-* \ ++ | le32-* | le64-* \ ++ | lm32-* \ ++ | m32c-* | m32r-* | m32rle-* \ ++ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ ++ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ ++ | microblaze-* | microblazeel-* \ ++ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ ++ | mips16-* \ ++ | mips64-* | mips64el-* \ ++ | mips64octeon-* | mips64octeonel-* \ ++ | mips64orion-* | mips64orionel-* \ ++ | mips64r5900-* | mips64r5900el-* \ ++ | mips64vr-* | mips64vrel-* \ ++ | mips64vr4100-* | mips64vr4100el-* \ ++ | mips64vr4300-* | mips64vr4300el-* \ ++ | mips64vr5000-* | mips64vr5000el-* \ ++ | mips64vr5900-* | mips64vr5900el-* \ ++ | mipsisa32-* | mipsisa32el-* \ ++ | mipsisa32r2-* | mipsisa32r2el-* \ ++ | mipsisa32r6-* | mipsisa32r6el-* \ ++ | mipsisa64-* | mipsisa64el-* \ ++ | mipsisa64r2-* | mipsisa64r2el-* \ ++ | mipsisa64r6-* | mipsisa64r6el-* \ ++ | mipsisa64sb1-* | mipsisa64sb1el-* \ ++ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ ++ | mipsr5900-* | mipsr5900el-* \ ++ | mipstx39-* | mipstx39el-* \ ++ | mmix-* \ ++ | mt-* \ ++ | msp430-* \ ++ | nds32-* | nds32le-* | nds32be-* \ ++ | nios-* | nios2-* | nios2eb-* | nios2el-* \ ++ | none-* | np1-* | ns16k-* | ns32k-* \ ++ | open8-* \ ++ | or1k*-* \ ++ | orion-* \ ++ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ ++ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ ++ | pru-* \ ++ | pyramid-* \ ++ | riscv32-* | riscv64-* \ ++ | rl78-* | romp-* | rs6000-* | rx-* \ ++ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ ++ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ ++ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ ++ | sparclite-* \ ++ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ ++ | tahoe-* \ ++ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ ++ | tile*-* \ ++ | tron-* \ ++ | ubicom32-* \ ++ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ ++ | vax-* \ ++ | visium-* \ ++ | we32k-* \ ++ | x86-* | x86_64-* | xc16x-* | xps100-* \ ++ | xstormy16-* | xtensa*-* \ ++ | ymp-* \ ++ | z8k-* | z80-*) ++ ;; ++ # Recognize the basic CPU types without company name, with glob match. ++ xtensa*) ++ basic_machine=$basic_machine-unknown ++ ;; ++ # Recognize the various machine names and aliases which stand ++ # for a CPU type and a company and sometimes even an OS. ++ 386bsd) ++ basic_machine=i386-unknown ++ os=-bsd ++ ;; ++ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) ++ basic_machine=m68000-att ++ ;; ++ 3b*) ++ basic_machine=we32k-att ++ ;; ++ a29khif) ++ basic_machine=a29k-amd ++ os=-udi ++ ;; ++ abacus) ++ basic_machine=abacus-unknown ++ ;; ++ adobe68k) ++ basic_machine=m68010-adobe ++ os=-scout ++ ;; ++ alliant | fx80) ++ basic_machine=fx80-alliant ++ ;; ++ altos | altos3068) ++ basic_machine=m68k-altos ++ ;; ++ am29k) ++ basic_machine=a29k-none ++ os=-bsd ++ ;; ++ amd64) ++ basic_machine=x86_64-pc ++ ;; ++ amd64-*) ++ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ amdahl) ++ basic_machine=580-amdahl ++ os=-sysv ++ ;; ++ amiga | amiga-*) ++ basic_machine=m68k-unknown ++ ;; ++ amigaos | amigados) ++ basic_machine=m68k-unknown ++ os=-amigaos ++ ;; ++ amigaunix | amix) ++ basic_machine=m68k-unknown ++ os=-sysv4 ++ ;; ++ apollo68) ++ basic_machine=m68k-apollo ++ os=-sysv ++ ;; ++ apollo68bsd) ++ basic_machine=m68k-apollo ++ os=-bsd ++ ;; ++ aros) ++ basic_machine=i386-pc ++ os=-aros ++ ;; ++ asmjs) ++ basic_machine=asmjs-unknown ++ ;; ++ aux) ++ basic_machine=m68k-apple ++ os=-aux ++ ;; ++ balance) ++ basic_machine=ns32k-sequent ++ os=-dynix ++ ;; ++ blackfin) ++ basic_machine=bfin-unknown ++ os=-linux ++ ;; ++ blackfin-*) ++ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` ++ os=-linux ++ ;; ++ bluegene*) ++ basic_machine=powerpc-ibm ++ os=-cnk ++ ;; ++ c54x-*) ++ basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ c55x-*) ++ basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ c6x-*) ++ basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ c90) ++ basic_machine=c90-cray ++ os=-unicos ++ ;; ++ cegcc) ++ basic_machine=arm-unknown ++ os=-cegcc ++ ;; ++ convex-c1) ++ basic_machine=c1-convex ++ os=-bsd ++ ;; ++ convex-c2) ++ basic_machine=c2-convex ++ os=-bsd ++ ;; ++ convex-c32) ++ basic_machine=c32-convex ++ os=-bsd ++ ;; ++ convex-c34) ++ basic_machine=c34-convex ++ os=-bsd ++ ;; ++ convex-c38) ++ basic_machine=c38-convex ++ os=-bsd ++ ;; ++ cray | j90) ++ basic_machine=j90-cray ++ os=-unicos ++ ;; ++ craynv) ++ basic_machine=craynv-cray ++ os=-unicosmp ++ ;; ++ cr16 | cr16-*) ++ basic_machine=cr16-unknown ++ os=-elf ++ ;; ++ crds | unos) ++ basic_machine=m68k-crds ++ ;; ++ crisv32 | crisv32-* | etraxfs*) ++ basic_machine=crisv32-axis ++ ;; ++ cris | cris-* | etrax*) ++ basic_machine=cris-axis ++ ;; ++ crx) ++ basic_machine=crx-unknown ++ os=-elf ++ ;; ++ da30 | da30-*) ++ basic_machine=m68k-da30 ++ ;; ++ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) ++ basic_machine=mips-dec ++ ;; ++ decsystem10* | dec10*) ++ basic_machine=pdp10-dec ++ os=-tops10 ++ ;; ++ decsystem20* | dec20*) ++ basic_machine=pdp10-dec ++ os=-tops20 ++ ;; ++ delta | 3300 | motorola-3300 | motorola-delta \ ++ | 3300-motorola | delta-motorola) ++ basic_machine=m68k-motorola ++ ;; ++ delta88) ++ basic_machine=m88k-motorola ++ os=-sysv3 ++ ;; ++ dicos) ++ basic_machine=i686-pc ++ os=-dicos ++ ;; ++ djgpp) ++ basic_machine=i586-pc ++ os=-msdosdjgpp ++ ;; ++ dpx20 | dpx20-*) ++ basic_machine=rs6000-bull ++ os=-bosx ++ ;; ++ dpx2* | dpx2*-bull) ++ basic_machine=m68k-bull ++ os=-sysv3 ++ ;; ++ e500v[12]) ++ basic_machine=powerpc-unknown ++ os=$os"spe" ++ ;; ++ e500v[12]-*) ++ basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ++ os=$os"spe" ++ ;; ++ ebmon29k) ++ basic_machine=a29k-amd ++ os=-ebmon ++ ;; ++ elxsi) ++ basic_machine=elxsi-elxsi ++ os=-bsd ++ ;; ++ encore | umax | mmax) ++ basic_machine=ns32k-encore ++ ;; ++ es1800 | OSE68k | ose68k | ose | OSE) ++ basic_machine=m68k-ericsson ++ os=-ose ++ ;; ++ fx2800) ++ basic_machine=i860-alliant ++ ;; ++ genix) ++ basic_machine=ns32k-ns ++ ;; ++ gmicro) ++ basic_machine=tron-gmicro ++ os=-sysv ++ ;; ++ go32) ++ basic_machine=i386-pc ++ os=-go32 ++ ;; ++ h3050r* | hiux*) ++ basic_machine=hppa1.1-hitachi ++ os=-hiuxwe2 ++ ;; ++ h8300hms) ++ basic_machine=h8300-hitachi ++ os=-hms ++ ;; ++ h8300xray) ++ basic_machine=h8300-hitachi ++ os=-xray ++ ;; ++ h8500hms) ++ basic_machine=h8500-hitachi ++ os=-hms ++ ;; ++ harris) ++ basic_machine=m88k-harris ++ os=-sysv3 ++ ;; ++ hp300-*) ++ basic_machine=m68k-hp ++ ;; ++ hp300bsd) ++ basic_machine=m68k-hp ++ os=-bsd ++ ;; ++ hp300hpux) ++ basic_machine=m68k-hp ++ os=-hpux ++ ;; ++ hp3k9[0-9][0-9] | hp9[0-9][0-9]) ++ basic_machine=hppa1.0-hp ++ ;; ++ hp9k2[0-9][0-9] | hp9k31[0-9]) ++ basic_machine=m68000-hp ++ ;; ++ hp9k3[2-9][0-9]) ++ basic_machine=m68k-hp ++ ;; ++ hp9k6[0-9][0-9] | hp6[0-9][0-9]) ++ basic_machine=hppa1.0-hp ++ ;; ++ hp9k7[0-79][0-9] | hp7[0-79][0-9]) ++ basic_machine=hppa1.1-hp ++ ;; ++ hp9k78[0-9] | hp78[0-9]) ++ # FIXME: really hppa2.0-hp ++ basic_machine=hppa1.1-hp ++ ;; ++ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) ++ # FIXME: really hppa2.0-hp ++ basic_machine=hppa1.1-hp ++ ;; ++ hp9k8[0-9][13679] | hp8[0-9][13679]) ++ basic_machine=hppa1.1-hp ++ ;; ++ hp9k8[0-9][0-9] | hp8[0-9][0-9]) ++ basic_machine=hppa1.0-hp ++ ;; ++ hppa-next) ++ os=-nextstep3 ++ ;; ++ hppaosf) ++ basic_machine=hppa1.1-hp ++ os=-osf ++ ;; ++ hppro) ++ basic_machine=hppa1.1-hp ++ os=-proelf ++ ;; ++ i370-ibm* | ibm*) ++ basic_machine=i370-ibm ++ ;; ++ i*86v32) ++ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` ++ os=-sysv32 ++ ;; ++ i*86v4*) ++ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` ++ os=-sysv4 ++ ;; ++ i*86v) ++ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` ++ os=-sysv ++ ;; ++ i*86sol2) ++ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` ++ os=-solaris2 ++ ;; ++ i386mach) ++ basic_machine=i386-mach ++ os=-mach ++ ;; ++ i386-vsta | vsta) ++ basic_machine=i386-unknown ++ os=-vsta ++ ;; ++ iris | iris4d) ++ basic_machine=mips-sgi ++ case $os in ++ -irix*) ++ ;; ++ *) ++ os=-irix4 ++ ;; ++ esac ++ ;; ++ isi68 | isi) ++ basic_machine=m68k-isi ++ os=-sysv ++ ;; ++ leon-*|leon[3-9]-*) ++ basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ++ ;; ++ m68knommu) ++ basic_machine=m68k-unknown ++ os=-linux ++ ;; ++ m68knommu-*) ++ basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` ++ os=-linux ++ ;; ++ m88k-omron*) ++ basic_machine=m88k-omron ++ ;; ++ magnum | m3230) ++ basic_machine=mips-mips ++ os=-sysv ++ ;; ++ merlin) ++ basic_machine=ns32k-utek ++ os=-sysv ++ ;; ++ microblaze*) ++ basic_machine=microblaze-xilinx ++ ;; ++ mingw64) ++ basic_machine=x86_64-pc ++ os=-mingw64 ++ ;; ++ mingw32) ++ basic_machine=i686-pc ++ os=-mingw32 ++ ;; ++ mingw32ce) ++ basic_machine=arm-unknown ++ os=-mingw32ce ++ ;; ++ miniframe) ++ basic_machine=m68000-convergent ++ ;; ++ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) ++ basic_machine=m68k-atari ++ os=-mint ++ ;; ++ mips3*-*) ++ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ++ ;; ++ mips3*) ++ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ++ ;; ++ monitor) ++ basic_machine=m68k-rom68k ++ os=-coff ++ ;; ++ morphos) ++ basic_machine=powerpc-unknown ++ os=-morphos ++ ;; ++ moxiebox) ++ basic_machine=moxie-unknown ++ os=-moxiebox ++ ;; ++ msdos) ++ basic_machine=i386-pc ++ os=-msdos ++ ;; ++ ms1-*) ++ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ++ ;; ++ msys) ++ basic_machine=i686-pc ++ os=-msys ++ ;; ++ mvs) ++ basic_machine=i370-ibm ++ os=-mvs ++ ;; ++ nacl) ++ basic_machine=le32-unknown ++ os=-nacl ++ ;; ++ ncr3000) ++ basic_machine=i486-ncr ++ os=-sysv4 ++ ;; ++ netbsd386) ++ basic_machine=i386-unknown ++ os=-netbsd ++ ;; ++ netwinder) ++ basic_machine=armv4l-rebel ++ os=-linux ++ ;; ++ news | news700 | news800 | news900) ++ basic_machine=m68k-sony ++ os=-newsos ++ ;; ++ news1000) ++ basic_machine=m68030-sony ++ os=-newsos ++ ;; ++ news-3600 | risc-news) ++ basic_machine=mips-sony ++ os=-newsos ++ ;; ++ necv70) ++ basic_machine=v70-nec ++ os=-sysv ++ ;; ++ next | m*-next ) ++ basic_machine=m68k-next ++ case $os in ++ -nextstep* ) ++ ;; ++ -ns2*) ++ os=-nextstep2 ++ ;; ++ *) ++ os=-nextstep3 ++ ;; ++ esac ++ ;; ++ nh3000) ++ basic_machine=m68k-harris ++ os=-cxux ++ ;; ++ nh[45]000) ++ basic_machine=m88k-harris ++ os=-cxux ++ ;; ++ nindy960) ++ basic_machine=i960-intel ++ os=-nindy ++ ;; ++ mon960) ++ basic_machine=i960-intel ++ os=-mon960 ++ ;; ++ nonstopux) ++ basic_machine=mips-compaq ++ os=-nonstopux ++ ;; ++ np1) ++ basic_machine=np1-gould ++ ;; ++ neo-tandem) ++ basic_machine=neo-tandem ++ ;; ++ nse-tandem) ++ basic_machine=nse-tandem ++ ;; ++ nsr-tandem) ++ basic_machine=nsr-tandem ++ ;; ++ op50n-* | op60c-*) ++ basic_machine=hppa1.1-oki ++ os=-proelf ++ ;; ++ openrisc | openrisc-*) ++ basic_machine=or32-unknown ++ ;; ++ os400) ++ basic_machine=powerpc-ibm ++ os=-os400 ++ ;; ++ OSE68000 | ose68000) ++ basic_machine=m68000-ericsson ++ os=-ose ++ ;; ++ os68k) ++ basic_machine=m68k-none ++ os=-os68k ++ ;; ++ pa-hitachi) ++ basic_machine=hppa1.1-hitachi ++ os=-hiuxwe2 ++ ;; ++ paragon) ++ basic_machine=i860-intel ++ os=-osf ++ ;; ++ parisc) ++ basic_machine=hppa-unknown ++ os=-linux ++ ;; ++ parisc-*) ++ basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` ++ os=-linux ++ ;; ++ pbd) ++ basic_machine=sparc-tti ++ ;; ++ pbb) ++ basic_machine=m68k-tti ++ ;; ++ pc532 | pc532-*) ++ basic_machine=ns32k-pc532 ++ ;; ++ pc98) ++ basic_machine=i386-pc ++ ;; ++ pc98-*) ++ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ pentium | p5 | k5 | k6 | nexgen | viac3) ++ basic_machine=i586-pc ++ ;; ++ pentiumpro | p6 | 6x86 | athlon | athlon_*) ++ basic_machine=i686-pc ++ ;; ++ pentiumii | pentium2 | pentiumiii | pentium3) ++ basic_machine=i686-pc ++ ;; ++ pentium4) ++ basic_machine=i786-pc ++ ;; ++ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) ++ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ pentiumpro-* | p6-* | 6x86-* | athlon-*) ++ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) ++ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ pentium4-*) ++ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ pn) ++ basic_machine=pn-gould ++ ;; ++ power) basic_machine=power-ibm ++ ;; ++ ppc | ppcbe) basic_machine=powerpc-unknown ++ ;; ++ ppc-* | ppcbe-*) ++ basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ ppcle | powerpclittle) ++ basic_machine=powerpcle-unknown ++ ;; ++ ppcle-* | powerpclittle-*) ++ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ ppc64) basic_machine=powerpc64-unknown ++ ;; ++ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ ppc64le | powerpc64little) ++ basic_machine=powerpc64le-unknown ++ ;; ++ ppc64le-* | powerpc64little-*) ++ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ ps2) ++ basic_machine=i386-ibm ++ ;; ++ pw32) ++ basic_machine=i586-unknown ++ os=-pw32 ++ ;; ++ rdos | rdos64) ++ basic_machine=x86_64-pc ++ os=-rdos ++ ;; ++ rdos32) ++ basic_machine=i386-pc ++ os=-rdos ++ ;; ++ rom68k) ++ basic_machine=m68k-rom68k ++ os=-coff ++ ;; ++ rm[46]00) ++ basic_machine=mips-siemens ++ ;; ++ rtpc | rtpc-*) ++ basic_machine=romp-ibm ++ ;; ++ s390 | s390-*) ++ basic_machine=s390-ibm ++ ;; ++ s390x | s390x-*) ++ basic_machine=s390x-ibm ++ ;; ++ sa29200) ++ basic_machine=a29k-amd ++ os=-udi ++ ;; ++ sb1) ++ basic_machine=mipsisa64sb1-unknown ++ ;; ++ sb1el) ++ basic_machine=mipsisa64sb1el-unknown ++ ;; ++ sde) ++ basic_machine=mipsisa32-sde ++ os=-elf ++ ;; ++ sei) ++ basic_machine=mips-sei ++ os=-seiux ++ ;; ++ sequent) ++ basic_machine=i386-sequent ++ ;; ++ sh) ++ basic_machine=sh-hitachi ++ os=-hms ++ ;; ++ sh5el) ++ basic_machine=sh5le-unknown ++ ;; ++ sh64) ++ basic_machine=sh64-unknown ++ ;; ++ sparclite-wrs | simso-wrs) ++ basic_machine=sparclite-wrs ++ os=-vxworks ++ ;; ++ sps7) ++ basic_machine=m68k-bull ++ os=-sysv2 ++ ;; ++ spur) ++ basic_machine=spur-unknown ++ ;; ++ st2000) ++ basic_machine=m68k-tandem ++ ;; ++ stratus) ++ basic_machine=i860-stratus ++ os=-sysv4 ++ ;; ++ strongarm-* | thumb-*) ++ basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ++ ;; ++ sun2) ++ basic_machine=m68000-sun ++ ;; ++ sun2os3) ++ basic_machine=m68000-sun ++ os=-sunos3 ++ ;; ++ sun2os4) ++ basic_machine=m68000-sun ++ os=-sunos4 ++ ;; ++ sun3os3) ++ basic_machine=m68k-sun ++ os=-sunos3 ++ ;; ++ sun3os4) ++ basic_machine=m68k-sun ++ os=-sunos4 ++ ;; ++ sun4os3) ++ basic_machine=sparc-sun ++ os=-sunos3 ++ ;; ++ sun4os4) ++ basic_machine=sparc-sun ++ os=-sunos4 ++ ;; ++ sun4sol2) ++ basic_machine=sparc-sun ++ os=-solaris2 ++ ;; ++ sun3 | sun3-*) ++ basic_machine=m68k-sun ++ ;; ++ sun4) ++ basic_machine=sparc-sun ++ ;; ++ sun386 | sun386i | roadrunner) ++ basic_machine=i386-sun ++ ;; ++ sv1) ++ basic_machine=sv1-cray ++ os=-unicos ++ ;; ++ symmetry) ++ basic_machine=i386-sequent ++ os=-dynix ++ ;; ++ t3e) ++ basic_machine=alphaev5-cray ++ os=-unicos ++ ;; ++ t90) ++ basic_machine=t90-cray ++ os=-unicos ++ ;; ++ tile*) ++ basic_machine=$basic_machine-unknown ++ os=-linux-gnu ++ ;; ++ tx39) ++ basic_machine=mipstx39-unknown ++ ;; ++ tx39el) ++ basic_machine=mipstx39el-unknown ++ ;; ++ toad1) ++ basic_machine=pdp10-xkl ++ os=-tops20 ++ ;; ++ tower | tower-32) ++ basic_machine=m68k-ncr ++ ;; ++ tpf) ++ basic_machine=s390x-ibm ++ os=-tpf ++ ;; ++ udi29k) ++ basic_machine=a29k-amd ++ os=-udi ++ ;; ++ ultra3) ++ basic_machine=a29k-nyu ++ os=-sym1 ++ ;; ++ v810 | necv810) ++ basic_machine=v810-nec ++ os=-none ++ ;; ++ vaxv) ++ basic_machine=vax-dec ++ os=-sysv ++ ;; ++ vms) ++ basic_machine=vax-dec ++ os=-vms ++ ;; ++ vpp*|vx|vx-*) ++ basic_machine=f301-fujitsu ++ ;; ++ vxworks960) ++ basic_machine=i960-wrs ++ os=-vxworks ++ ;; ++ vxworks68) ++ basic_machine=m68k-wrs ++ os=-vxworks ++ ;; ++ vxworks29k) ++ basic_machine=a29k-wrs ++ os=-vxworks ++ ;; ++ w65*) ++ basic_machine=w65-wdc ++ os=-none ++ ;; ++ w89k-*) ++ basic_machine=hppa1.1-winbond ++ os=-proelf ++ ;; ++ xbox) ++ basic_machine=i686-pc ++ os=-mingw32 ++ ;; ++ xps | xps100) ++ basic_machine=xps100-honeywell ++ ;; ++ xscale-* | xscalee[bl]-*) ++ basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ++ ;; ++ ymp) ++ basic_machine=ymp-cray ++ os=-unicos ++ ;; ++ z8k-*-coff) ++ basic_machine=z8k-unknown ++ os=-sim ++ ;; ++ z80-*-coff) ++ basic_machine=z80-unknown ++ os=-sim ++ ;; ++ none) ++ basic_machine=none-none ++ os=-none ++ ;; ++ ++# Here we handle the default manufacturer of certain CPU types. It is in ++# some cases the only manufacturer, in others, it is the most popular. ++ w89k) ++ basic_machine=hppa1.1-winbond ++ ;; ++ op50n) ++ basic_machine=hppa1.1-oki ++ ;; ++ op60c) ++ basic_machine=hppa1.1-oki ++ ;; ++ romp) ++ basic_machine=romp-ibm ++ ;; ++ mmix) ++ basic_machine=mmix-knuth ++ ;; ++ rs6000) ++ basic_machine=rs6000-ibm ++ ;; ++ vax) ++ basic_machine=vax-dec ++ ;; ++ pdp10) ++ # there are many clones, so DEC is not a safe bet ++ basic_machine=pdp10-unknown ++ ;; ++ pdp11) ++ basic_machine=pdp11-dec ++ ;; ++ we32k) ++ basic_machine=we32k-att ++ ;; ++ sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) ++ basic_machine=sh-unknown ++ ;; ++ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) ++ basic_machine=sparc-sun ++ ;; ++ cydra) ++ basic_machine=cydra-cydrome ++ ;; ++ orion) ++ basic_machine=orion-highlevel ++ ;; ++ orion105) ++ basic_machine=clipper-highlevel ++ ;; ++ mac | mpw | mac-mpw) ++ basic_machine=m68k-apple ++ ;; ++ pmac | pmac-mpw) ++ basic_machine=powerpc-apple ++ ;; ++ *-unknown) ++ # Make sure to match an already-canonicalized machine name. ++ ;; ++ *) ++ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 ++ exit 1 ++ ;; ++esac ++ ++# Here we canonicalize certain aliases for manufacturers. ++case $basic_machine in ++ *-digital*) ++ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ++ ;; ++ *-commodore*) ++ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ++ ;; ++ *) ++ ;; ++esac ++ ++# Decode manufacturer-specific aliases for certain operating systems. ++ ++if [ x"$os" != x"" ] ++then ++case $os in ++ # First match some system type aliases ++ # that might get confused with valid system types. ++ # -solaris* is a basic system type, with this one exception. ++ -auroraux) ++ os=-auroraux ++ ;; ++ -solaris1 | -solaris1.*) ++ os=`echo $os | sed -e 's|solaris1|sunos4|'` ++ ;; ++ -solaris) ++ os=-solaris2 ++ ;; ++ -svr4*) ++ os=-sysv4 ++ ;; ++ -unixware*) ++ os=-sysv4.2uw ++ ;; ++ -gnu/linux*) ++ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ++ ;; ++ # First accept the basic system types. ++ # The portable systems comes first. ++ # Each alternative MUST END IN A *, to match a version number. ++ # -sysv* is not here because it comes later, after sysvr4. ++ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ ++ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ ++ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ ++ | -sym* | -kopensolaris* | -plan9* \ ++ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ ++ | -aos* | -aros* | -cloudabi* | -sortix* \ ++ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ ++ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ ++ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ ++ | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ ++ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ ++ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ ++ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ ++ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ ++ | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ ++ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ ++ | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ ++ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ ++ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ ++ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ ++ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ ++ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ ++ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ ++ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ ++ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ ++ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ ++ | -onefs* | -tirtos* | -phoenix* | -fuchsia*) ++ # Remember, each alternative MUST END IN *, to match a version number. ++ ;; ++ -qnx*) ++ case $basic_machine in ++ x86-* | i*86-*) ++ ;; ++ *) ++ os=-nto$os ++ ;; ++ esac ++ ;; ++ -nto-qnx*) ++ ;; ++ -nto*) ++ os=`echo $os | sed -e 's|nto|nto-qnx|'` ++ ;; ++ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ ++ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ ++ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ++ ;; ++ -mac*) ++ os=`echo $os | sed -e 's|mac|macos|'` ++ ;; ++ -linux-dietlibc) ++ os=-linux-dietlibc ++ ;; ++ -linux*) ++ os=`echo $os | sed -e 's|linux|linux-gnu|'` ++ ;; ++ -sunos5*) ++ os=`echo $os | sed -e 's|sunos5|solaris2|'` ++ ;; ++ -sunos6*) ++ os=`echo $os | sed -e 's|sunos6|solaris3|'` ++ ;; ++ -opened*) ++ os=-openedition ++ ;; ++ -os400*) ++ os=-os400 ++ ;; ++ -wince*) ++ os=-wince ++ ;; ++ -osfrose*) ++ os=-osfrose ++ ;; ++ -osf*) ++ os=-osf ++ ;; ++ -utek*) ++ os=-bsd ++ ;; ++ -dynix*) ++ os=-bsd ++ ;; ++ -acis*) ++ os=-aos ++ ;; ++ -atheos*) ++ os=-atheos ++ ;; ++ -syllable*) ++ os=-syllable ++ ;; ++ -386bsd) ++ os=-bsd ++ ;; ++ -ctix* | -uts*) ++ os=-sysv ++ ;; ++ -nova*) ++ os=-rtmk-nova ++ ;; ++ -ns2 ) ++ os=-nextstep2 ++ ;; ++ -nsk*) ++ os=-nsk ++ ;; ++ # Preserve the version number of sinix5. ++ -sinix5.*) ++ os=`echo $os | sed -e 's|sinix|sysv|'` ++ ;; ++ -sinix*) ++ os=-sysv4 ++ ;; ++ -tpf*) ++ os=-tpf ++ ;; ++ -triton*) ++ os=-sysv3 ++ ;; ++ -oss*) ++ os=-sysv3 ++ ;; ++ -svr4) ++ os=-sysv4 ++ ;; ++ -svr3) ++ os=-sysv3 ++ ;; ++ -sysvr4) ++ os=-sysv4 ++ ;; ++ # This must come after -sysvr4. ++ -sysv*) ++ ;; ++ -ose*) ++ os=-ose ++ ;; ++ -es1800*) ++ os=-ose ++ ;; ++ -xenix) ++ os=-xenix ++ ;; ++ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) ++ os=-mint ++ ;; ++ -aros*) ++ os=-aros ++ ;; ++ -zvmoe) ++ os=-zvmoe ++ ;; ++ -dicos*) ++ os=-dicos ++ ;; ++ -nacl*) ++ ;; ++ -ios) ++ ;; ++ -none) ++ ;; ++ *) ++ # Get rid of the `-' at the beginning of $os. ++ os=`echo $os | sed 's/[^-]*-//'` ++ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 ++ exit 1 ++ ;; ++esac ++else ++ ++# Here we handle the default operating systems that come with various machines. ++# The value should be what the vendor currently ships out the door with their ++# machine or put another way, the most popular os provided with the machine. ++ ++# Note that if you're going to try to match "-MANUFACTURER" here (say, ++# "-sun"), then you have to tell the case statement up towards the top ++# that MANUFACTURER isn't an operating system. Otherwise, code above ++# will signal an error saying that MANUFACTURER isn't an operating ++# system, and we'll never get to this point. ++ ++case $basic_machine in ++ score-*) ++ os=-elf ++ ;; ++ spu-*) ++ os=-elf ++ ;; ++ *-acorn) ++ os=-riscix1.2 ++ ;; ++ arm*-rebel) ++ os=-linux ++ ;; ++ arm*-semi) ++ os=-aout ++ ;; ++ c4x-* | tic4x-*) ++ os=-coff ++ ;; ++ c8051-*) ++ os=-elf ++ ;; ++ hexagon-*) ++ os=-elf ++ ;; ++ tic54x-*) ++ os=-coff ++ ;; ++ tic55x-*) ++ os=-coff ++ ;; ++ tic6x-*) ++ os=-coff ++ ;; ++ # This must come before the *-dec entry. ++ pdp10-*) ++ os=-tops20 ++ ;; ++ pdp11-*) ++ os=-none ++ ;; ++ *-dec | vax-*) ++ os=-ultrix4.2 ++ ;; ++ m68*-apollo) ++ os=-domain ++ ;; ++ i386-sun) ++ os=-sunos4.0.2 ++ ;; ++ m68000-sun) ++ os=-sunos3 ++ ;; ++ m68*-cisco) ++ os=-aout ++ ;; ++ mep-*) ++ os=-elf ++ ;; ++ mips*-cisco) ++ os=-elf ++ ;; ++ mips*-*) ++ os=-elf ++ ;; ++ or32-*) ++ os=-coff ++ ;; ++ *-tti) # must be before sparc entry or we get the wrong os. ++ os=-sysv3 ++ ;; ++ sparc-* | *-sun) ++ os=-sunos4.1.1 ++ ;; ++ *-be) ++ os=-beos ++ ;; ++ *-haiku) ++ os=-haiku ++ ;; ++ *-ibm) ++ os=-aix ++ ;; ++ *-knuth) ++ os=-mmixware ++ ;; ++ *-wec) ++ os=-proelf ++ ;; ++ *-winbond) ++ os=-proelf ++ ;; ++ *-oki) ++ os=-proelf ++ ;; ++ *-hp) ++ os=-hpux ++ ;; ++ *-hitachi) ++ os=-hiux ++ ;; ++ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) ++ os=-sysv ++ ;; ++ *-cbm) ++ os=-amigaos ++ ;; ++ *-dg) ++ os=-dgux ++ ;; ++ *-dolphin) ++ os=-sysv3 ++ ;; ++ m68k-ccur) ++ os=-rtu ++ ;; ++ m88k-omron*) ++ os=-luna ++ ;; ++ *-next ) ++ os=-nextstep ++ ;; ++ *-sequent) ++ os=-ptx ++ ;; ++ *-crds) ++ os=-unos ++ ;; ++ *-ns) ++ os=-genix ++ ;; ++ i370-*) ++ os=-mvs ++ ;; ++ *-next) ++ os=-nextstep3 ++ ;; ++ *-gould) ++ os=-sysv ++ ;; ++ *-highlevel) ++ os=-bsd ++ ;; ++ *-encore) ++ os=-bsd ++ ;; ++ *-sgi) ++ os=-irix ++ ;; ++ *-siemens) ++ os=-sysv4 ++ ;; ++ *-masscomp) ++ os=-rtu ++ ;; ++ f30[01]-fujitsu | f700-fujitsu) ++ os=-uxpv ++ ;; ++ *-rom68k) ++ os=-coff ++ ;; ++ *-*bug) ++ os=-coff ++ ;; ++ *-apple) ++ os=-macos ++ ;; ++ *-atari*) ++ os=-mint ++ ;; ++ *) ++ os=-none ++ ;; ++esac ++fi ++ ++# Here we handle the case where we know the os, and the CPU type, but not the ++# manufacturer. We pick the logical manufacturer. ++vendor=unknown ++case $basic_machine in ++ *-unknown) ++ case $os in ++ -riscix*) ++ vendor=acorn ++ ;; ++ -sunos*) ++ vendor=sun ++ ;; ++ -cnk*|-aix*) ++ vendor=ibm ++ ;; ++ -beos*) ++ vendor=be ++ ;; ++ -hpux*) ++ vendor=hp ++ ;; ++ -mpeix*) ++ vendor=hp ++ ;; ++ -hiux*) ++ vendor=hitachi ++ ;; ++ -unos*) ++ vendor=crds ++ ;; ++ -dgux*) ++ vendor=dg ++ ;; ++ -luna*) ++ vendor=omron ++ ;; ++ -genix*) ++ vendor=ns ++ ;; ++ -mvs* | -opened*) ++ vendor=ibm ++ ;; ++ -os400*) ++ vendor=ibm ++ ;; ++ -ptx*) ++ vendor=sequent ++ ;; ++ -tpf*) ++ vendor=ibm ++ ;; ++ -vxsim* | -vxworks* | -windiss*) ++ vendor=wrs ++ ;; ++ -aux*) ++ vendor=apple ++ ;; ++ -hms*) ++ vendor=hitachi ++ ;; ++ -mpw* | -macos*) ++ vendor=apple ++ ;; ++ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) ++ vendor=atari ++ ;; ++ -vos*) ++ vendor=stratus ++ ;; ++ esac ++ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ++ ;; ++esac ++ ++echo $basic_machine$os ++exit ++ ++# Local variables: ++# eval: (add-hook 'write-file-hooks 'time-stamp) ++# time-stamp-start: "timestamp='" ++# time-stamp-format: "%:y-%02m-%02d" ++# time-stamp-end: "'" ++# End: diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/configure index 000000000,000000000..ee90bc6de new file mode 100755 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/configure @@@ -1,0 -1,0 +1,15189 @@@ ++#! /bin/sh ++# Guess values for system-dependent variables and create Makefiles. ++# Generated by GNU Autoconf 2.64 for package-unused version-unused. ++# ++# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, ++# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software ++# Foundation, Inc. ++# ++# This configure script is free software; the Free Software Foundation ++# gives unlimited permission to copy, distribute and modify it. ++## -------------------- ## ++## M4sh Initialization. ## ++## -------------------- ## ++ ++# Be more Bourne compatible ++DUALCASE=1; export DUALCASE # for MKS sh ++if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : ++ emulate sh ++ NULLCMD=: ++ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which ++ # is contrary to our usage. Disable this feature. ++ alias -g '${1+"$@"}'='"$@"' ++ setopt NO_GLOB_SUBST ++else ++ case `(set -o) 2>/dev/null` in #( ++ *posix*) : ++ set -o posix ;; #( ++ *) : ++ ;; ++esac ++fi ++ ++ ++as_nl=' ++' ++export as_nl ++# Printing a long string crashes Solaris 7 /usr/bin/printf. ++as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ++as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo ++as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo ++# Prefer a ksh shell builtin over an external printf program on Solaris, ++# but without wasting forks for bash or zsh. ++if test -z "$BASH_VERSION$ZSH_VERSION" \ ++ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then ++ as_echo='print -r --' ++ as_echo_n='print -rn --' ++elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then ++ as_echo='printf %s\n' ++ as_echo_n='printf %s' ++else ++ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then ++ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' ++ as_echo_n='/usr/ucb/echo -n' ++ else ++ as_echo_body='eval expr "X$1" : "X\\(.*\\)"' ++ as_echo_n_body='eval ++ arg=$1; ++ case $arg in #( ++ *"$as_nl"*) ++ expr "X$arg" : "X\\(.*\\)$as_nl"; ++ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; ++ esac; ++ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ++ ' ++ export as_echo_n_body ++ as_echo_n='sh -c $as_echo_n_body as_echo' ++ fi ++ export as_echo_body ++ as_echo='sh -c $as_echo_body as_echo' ++fi ++ ++# The user is always right. ++if test "${PATH_SEPARATOR+set}" != set; then ++ PATH_SEPARATOR=: ++ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { ++ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || ++ PATH_SEPARATOR=';' ++ } ++fi ++ ++ ++# IFS ++# We need space, tab and new line, in precisely that order. Quoting is ++# there to prevent editors from complaining about space-tab. ++# (If _AS_PATH_WALK were called with IFS unset, it would disable word ++# splitting by setting IFS to empty value.) ++IFS=" "" $as_nl" ++ ++# Find who we are. Look in the path if we contain no directory separator. ++case $0 in #(( ++ *[\\/]* ) as_myself=$0 ;; ++ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break ++ done ++IFS=$as_save_IFS ++ ++ ;; ++esac ++# We did not find ourselves, most probably we were run as `sh COMMAND' ++# in which case we are not to be found in the path. ++if test "x$as_myself" = x; then ++ as_myself=$0 ++fi ++if test ! -f "$as_myself"; then ++ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 ++ exit 1 ++fi ++ ++# Unset variables that we do not need and which cause bugs (e.g. in ++# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" ++# suppresses any "Segmentation fault" message there. '((' could ++# trigger a bug in pdksh 5.2.14. ++for as_var in BASH_ENV ENV MAIL MAILPATH ++do eval test x\${$as_var+set} = xset \ ++ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : ++done ++PS1='$ ' ++PS2='> ' ++PS4='+ ' ++ ++# NLS nuisances. ++LC_ALL=C ++export LC_ALL ++LANGUAGE=C ++export LANGUAGE ++ ++# CDPATH. ++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH ++ ++if test "x$CONFIG_SHELL" = x; then ++ as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : ++ emulate sh ++ NULLCMD=: ++ # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which ++ # is contrary to our usage. Disable this feature. ++ alias -g '\${1+\"\$@\"}'='\"\$@\"' ++ setopt NO_GLOB_SUBST ++else ++ case \`(set -o) 2>/dev/null\` in #( ++ *posix*) : ++ set -o posix ;; #( ++ *) : ++ ;; ++esac ++fi ++" ++ as_required="as_fn_return () { (exit \$1); } ++as_fn_success () { as_fn_return 0; } ++as_fn_failure () { as_fn_return 1; } ++as_fn_ret_success () { return 0; } ++as_fn_ret_failure () { return 1; } ++ ++exitcode=0 ++as_fn_success || { exitcode=1; echo as_fn_success failed.; } ++as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } ++as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } ++as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } ++if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : ++ ++else ++ exitcode=1; echo positional parameters were not saved. ++fi ++test x\$exitcode = x0 || exit 1" ++ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO ++ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO ++ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && ++ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 ++test \$(( 1 + 1 )) = 2 || exit 1 ++ ++ test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ++ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ++ ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ++ ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ++ PATH=/empty FPATH=/empty; export PATH FPATH ++ test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ ++ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" ++ if (eval "$as_required") 2>/dev/null; then : ++ as_have_required=yes ++else ++ as_have_required=no ++fi ++ if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : ++ ++else ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++as_found=false ++for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ as_found=: ++ case $as_dir in #( ++ /*) ++ for as_base in sh bash ksh sh5; do ++ # Try only shells that exist, to save several forks. ++ as_shell=$as_dir/$as_base ++ if { test -f "$as_shell" || test -f "$as_shell.exe"; } && ++ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : ++ CONFIG_SHELL=$as_shell as_have_required=yes ++ if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : ++ break 2 ++fi ++fi ++ done;; ++ esac ++ as_found=false ++done ++$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && ++ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : ++ CONFIG_SHELL=$SHELL as_have_required=yes ++fi; } ++IFS=$as_save_IFS ++ ++ ++ if test "x$CONFIG_SHELL" != x; then : ++ # We cannot yet assume a decent shell, so we have to provide a ++ # neutralization value for shells without unset; and this also ++ # works around shells that cannot unset nonexistent variables. ++ BASH_ENV=/dev/null ++ ENV=/dev/null ++ (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV ++ export CONFIG_SHELL ++ exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} ++fi ++ ++ if test x$as_have_required = xno; then : ++ $as_echo "$0: This script requires a shell more modern than all" ++ $as_echo "$0: the shells that I found on your system." ++ if test x${ZSH_VERSION+set} = xset ; then ++ $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" ++ $as_echo "$0: be upgraded to zsh 4.3.4 or later." ++ else ++ $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, ++$0: including any error possibly output before this ++$0: message. Then install a modern shell, or manually run ++$0: the script under such a shell if you do have one." ++ fi ++ exit 1 ++fi ++fi ++fi ++SHELL=${CONFIG_SHELL-/bin/sh} ++export SHELL ++# Unset more variables known to interfere with behavior of common tools. ++CLICOLOR_FORCE= GREP_OPTIONS= ++unset CLICOLOR_FORCE GREP_OPTIONS ++ ++## --------------------- ## ++## M4sh Shell Functions. ## ++## --------------------- ## ++# as_fn_unset VAR ++# --------------- ++# Portably unset VAR. ++as_fn_unset () ++{ ++ { eval $1=; unset $1;} ++} ++as_unset=as_fn_unset ++ ++# as_fn_set_status STATUS ++# ----------------------- ++# Set $? to STATUS, without forking. ++as_fn_set_status () ++{ ++ return $1 ++} # as_fn_set_status ++ ++# as_fn_exit STATUS ++# ----------------- ++# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. ++as_fn_exit () ++{ ++ set +e ++ as_fn_set_status $1 ++ exit $1 ++} # as_fn_exit ++ ++# as_fn_mkdir_p ++# ------------- ++# Create "$as_dir" as a directory, including parents if necessary. ++as_fn_mkdir_p () ++{ ++ ++ case $as_dir in #( ++ -*) as_dir=./$as_dir;; ++ esac ++ test -d "$as_dir" || eval $as_mkdir_p || { ++ as_dirs= ++ while :; do ++ case $as_dir in #( ++ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( ++ *) as_qdir=$as_dir;; ++ esac ++ as_dirs="'$as_qdir' $as_dirs" ++ as_dir=`$as_dirname -- "$as_dir" || ++$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ++ X"$as_dir" : 'X\(//\)[^/]' \| \ ++ X"$as_dir" : 'X\(//\)$' \| \ ++ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || ++$as_echo X"$as_dir" | ++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\/\)[^/].*/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\/\)$/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\).*/{ ++ s//\1/ ++ q ++ } ++ s/.*/./; q'` ++ test -d "$as_dir" && break ++ done ++ test -z "$as_dirs" || eval "mkdir $as_dirs" ++ } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" ++ ++ ++} # as_fn_mkdir_p ++# as_fn_append VAR VALUE ++# ---------------------- ++# Append the text in VALUE to the end of the definition contained in VAR. Take ++# advantage of any shell optimizations that allow amortized linear growth over ++# repeated appends, instead of the typical quadratic growth present in naive ++# implementations. ++if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : ++ eval 'as_fn_append () ++ { ++ eval $1+=\$2 ++ }' ++else ++ as_fn_append () ++ { ++ eval $1=\$$1\$2 ++ } ++fi # as_fn_append ++ ++# as_fn_arith ARG... ++# ------------------ ++# Perform arithmetic evaluation on the ARGs, and store the result in the ++# global $as_val. Take advantage of shells that can avoid forks. The arguments ++# must be portable across $(()) and expr. ++if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : ++ eval 'as_fn_arith () ++ { ++ as_val=$(( $* )) ++ }' ++else ++ as_fn_arith () ++ { ++ as_val=`expr "$@" || test $? -eq 1` ++ } ++fi # as_fn_arith ++ ++ ++# as_fn_error ERROR [LINENO LOG_FD] ++# --------------------------------- ++# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are ++# provided, also output the error to LOG_FD, referencing LINENO. Then exit the ++# script with status $?, using 1 if that was 0. ++as_fn_error () ++{ ++ as_status=$?; test $as_status -eq 0 && as_status=1 ++ if test "$3"; then ++ as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 ++ fi ++ $as_echo "$as_me: error: $1" >&2 ++ as_fn_exit $as_status ++} # as_fn_error ++ ++if expr a : '\(a\)' >/dev/null 2>&1 && ++ test "X`expr 00001 : '.*\(...\)'`" = X001; then ++ as_expr=expr ++else ++ as_expr=false ++fi ++ ++if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then ++ as_basename=basename ++else ++ as_basename=false ++fi ++ ++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then ++ as_dirname=dirname ++else ++ as_dirname=false ++fi ++ ++as_me=`$as_basename -- "$0" || ++$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ ++ X"$0" : 'X\(//\)$' \| \ ++ X"$0" : 'X\(/\)' \| . 2>/dev/null || ++$as_echo X/"$0" | ++ sed '/^.*\/\([^/][^/]*\)\/*$/{ ++ s//\1/ ++ q ++ } ++ /^X\/\(\/\/\)$/{ ++ s//\1/ ++ q ++ } ++ /^X\/\(\/\).*/{ ++ s//\1/ ++ q ++ } ++ s/.*/./; q'` ++ ++# Avoid depending upon Character Ranges. ++as_cr_letters='abcdefghijklmnopqrstuvwxyz' ++as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' ++as_cr_Letters=$as_cr_letters$as_cr_LETTERS ++as_cr_digits='0123456789' ++as_cr_alnum=$as_cr_Letters$as_cr_digits ++ ++ ++ as_lineno_1=$LINENO as_lineno_1a=$LINENO ++ as_lineno_2=$LINENO as_lineno_2a=$LINENO ++ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && ++ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { ++ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) ++ sed -n ' ++ p ++ /[$]LINENO/= ++ ' <$as_myself | ++ sed ' ++ s/[$]LINENO.*/&-/ ++ t lineno ++ b ++ :lineno ++ N ++ :loop ++ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ ++ t loop ++ s/-\n.*// ++ ' >$as_me.lineno && ++ chmod +x "$as_me.lineno" || ++ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } ++ ++ # Don't try to exec as it changes $[0], causing all sort of problems ++ # (the dirname of $[0] is not the place where we might find the ++ # original and so on. Autoconf is especially sensitive to this). ++ . "./$as_me.lineno" ++ # Exit status is that of the last command. ++ exit ++} ++ ++ECHO_C= ECHO_N= ECHO_T= ++case `echo -n x` in #((((( ++-n*) ++ case `echo 'xy\c'` in ++ *c*) ECHO_T=' ';; # ECHO_T is single tab character. ++ xy) ECHO_C='\c';; ++ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ++ ECHO_T=' ';; ++ esac;; ++*) ++ ECHO_N='-n';; ++esac ++ ++rm -f conf$$ conf$$.exe conf$$.file ++if test -d conf$$.dir; then ++ rm -f conf$$.dir/conf$$.file ++else ++ rm -f conf$$.dir ++ mkdir conf$$.dir 2>/dev/null ++fi ++if (echo >conf$$.file) 2>/dev/null; then ++ if ln -s conf$$.file conf$$ 2>/dev/null; then ++ as_ln_s='ln -s' ++ # ... but there are two gotchas: ++ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. ++ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. ++ # In both cases, we have to default to `cp -p'. ++ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || ++ as_ln_s='cp -p' ++ elif ln conf$$.file conf$$ 2>/dev/null; then ++ as_ln_s=ln ++ else ++ as_ln_s='cp -p' ++ fi ++else ++ as_ln_s='cp -p' ++fi ++rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file ++rmdir conf$$.dir 2>/dev/null ++ ++if mkdir -p . 2>/dev/null; then ++ as_mkdir_p='mkdir -p "$as_dir"' ++else ++ test -d ./-p && rmdir ./-p ++ as_mkdir_p=false ++fi ++ ++if test -x / >/dev/null 2>&1; then ++ as_test_x='test -x' ++else ++ if ls -dL / >/dev/null 2>&1; then ++ as_ls_L_option=L ++ else ++ as_ls_L_option= ++ fi ++ as_test_x=' ++ eval sh -c '\'' ++ if test -d "$1"; then ++ test -d "$1/."; ++ else ++ case $1 in #( ++ -*)set "./$1";; ++ esac; ++ case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ++ ???[sx]*):;;*)false;;esac;fi ++ '\'' sh ++ ' ++fi ++as_executable_p=$as_test_x ++ ++# Sed expression to map a string onto a valid CPP name. ++as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" ++ ++# Sed expression to map a string onto a valid variable name. ++as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" ++ ++SHELL=${CONFIG_SHELL-/bin/sh} ++ ++ ++exec 7<&0 &1 ++ ++# Name of the host. ++# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, ++# so uname gets run too. ++ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` ++ ++# ++# Initializations. ++# ++ac_default_prefix=/usr/local ++ac_clean_files= ++ac_config_libobj_dir=. ++LIBOBJS= ++cross_compiling=no ++subdirs= ++MFLAGS= ++MAKEFLAGS= ++ ++# Identity of this package. ++PACKAGE_NAME='package-unused' ++PACKAGE_TARNAME='libbacktrace' ++PACKAGE_VERSION='version-unused' ++PACKAGE_STRING='package-unused version-unused' ++PACKAGE_BUGREPORT='' ++PACKAGE_URL='' ++ ++ac_unique_file="backtrace.h" ++# Factoring default headers for most tests. ++ac_includes_default="\ ++#include ++#ifdef HAVE_SYS_TYPES_H ++# include ++#endif ++#ifdef HAVE_SYS_STAT_H ++# include ++#endif ++#ifdef STDC_HEADERS ++# include ++# include ++#else ++# ifdef HAVE_STDLIB_H ++# include ++# endif ++#endif ++#ifdef HAVE_STRING_H ++# if !defined STDC_HEADERS && defined HAVE_MEMORY_H ++# include ++# endif ++# include ++#endif ++#ifdef HAVE_STRINGS_H ++# include ++#endif ++#ifdef HAVE_INTTYPES_H ++# include ++#endif ++#ifdef HAVE_STDINT_H ++# include ++#endif ++#ifdef HAVE_UNISTD_H ++# include ++#endif" ++ ++ac_subst_vars='am__EXEEXT_FALSE ++am__EXEEXT_TRUE ++LTLIBOBJS ++LIBOBJS ++NATIVE_FALSE ++NATIVE_TRUE ++BACKTRACE_USES_MALLOC ++ALLOC_FILE ++VIEW_FILE ++BACKTRACE_SUPPORTS_DATA ++BACKTRACE_SUPPORTED ++FORMAT_FILE ++BACKTRACE_SUPPORTS_THREADS ++PIC_FLAG ++WARN_FLAGS ++EXTRA_FLAGS ++BACKTRACE_FILE ++OTOOL64 ++OTOOL ++LIPO ++NMEDIT ++DSYMUTIL ++AR ++OBJDUMP ++LN_S ++NM ++ac_ct_DUMPBIN ++DUMPBIN ++LD ++FGREP ++SED ++LIBTOOL ++RANLIB ++MAINT ++MAINTAINER_MODE_FALSE ++MAINTAINER_MODE_TRUE ++am__untar ++am__tar ++AMTAR ++am__leading_dot ++SET_MAKE ++AWK ++mkdir_p ++MKDIR_P ++INSTALL_STRIP_PROGRAM ++STRIP ++install_sh ++MAKEINFO ++AUTOHEADER ++AUTOMAKE ++AUTOCONF ++ACLOCAL ++VERSION ++PACKAGE ++CYGPATH_W ++am__isrc ++INSTALL_DATA ++INSTALL_SCRIPT ++INSTALL_PROGRAM ++libtool_VERSION ++EGREP ++GREP ++CPP ++OBJEXT ++EXEEXT ++ac_ct_CC ++CPPFLAGS ++LDFLAGS ++CFLAGS ++CC ++target_os ++target_vendor ++target_cpu ++target ++host_os ++host_vendor ++host_cpu ++host ++build_os ++build_vendor ++build_cpu ++build ++multi_basedir ++target_alias ++host_alias ++build_alias ++LIBS ++ECHO_T ++ECHO_N ++ECHO_C ++DEFS ++mandir ++localedir ++libdir ++psdir ++pdfdir ++dvidir ++htmldir ++infodir ++docdir ++oldincludedir ++includedir ++localstatedir ++sharedstatedir ++sysconfdir ++datadir ++datarootdir ++libexecdir ++sbindir ++bindir ++program_transform_name ++prefix ++exec_prefix ++PACKAGE_URL ++PACKAGE_BUGREPORT ++PACKAGE_STRING ++PACKAGE_VERSION ++PACKAGE_TARNAME ++PACKAGE_NAME ++PATH_SEPARATOR ++SHELL' ++ac_subst_files='' ++ac_user_opts=' ++enable_option_checking ++enable_multilib ++enable_maintainer_mode ++with_target_subdir ++enable_shared ++enable_static ++with_pic ++enable_fast_install ++with_gnu_ld ++enable_libtool_lock ++with_system_libunwind ++enable_host_shared ++' ++ ac_precious_vars='build_alias ++host_alias ++target_alias ++CC ++CFLAGS ++LDFLAGS ++LIBS ++CPPFLAGS ++CPP' ++ ++ ++# Initialize some variables set by options. ++ac_init_help= ++ac_init_version=false ++ac_unrecognized_opts= ++ac_unrecognized_sep= ++# The variables have the same names as the options, with ++# dashes changed to underlines. ++cache_file=/dev/null ++exec_prefix=NONE ++no_create= ++no_recursion= ++prefix=NONE ++program_prefix=NONE ++program_suffix=NONE ++program_transform_name=s,x,x, ++silent= ++site= ++srcdir= ++verbose= ++x_includes=NONE ++x_libraries=NONE ++ ++# Installation directory options. ++# These are left unexpanded so users can "make install exec_prefix=/foo" ++# and all the variables that are supposed to be based on exec_prefix ++# by default will actually change. ++# Use braces instead of parens because sh, perl, etc. also accept them. ++# (The list follows the same order as the GNU Coding Standards.) ++bindir='${exec_prefix}/bin' ++sbindir='${exec_prefix}/sbin' ++libexecdir='${exec_prefix}/libexec' ++datarootdir='${prefix}/share' ++datadir='${datarootdir}' ++sysconfdir='${prefix}/etc' ++sharedstatedir='${prefix}/com' ++localstatedir='${prefix}/var' ++includedir='${prefix}/include' ++oldincludedir='/usr/include' ++docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' ++infodir='${datarootdir}/info' ++htmldir='${docdir}' ++dvidir='${docdir}' ++pdfdir='${docdir}' ++psdir='${docdir}' ++libdir='${exec_prefix}/lib' ++localedir='${datarootdir}/locale' ++mandir='${datarootdir}/man' ++ ++ac_prev= ++ac_dashdash= ++for ac_option ++do ++ # If the previous option needs an argument, assign it. ++ if test -n "$ac_prev"; then ++ eval $ac_prev=\$ac_option ++ ac_prev= ++ continue ++ fi ++ ++ case $ac_option in ++ *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; ++ *) ac_optarg=yes ;; ++ esac ++ ++ # Accept the important Cygnus configure options, so we can diagnose typos. ++ ++ case $ac_dashdash$ac_option in ++ --) ++ ac_dashdash=yes ;; ++ ++ -bindir | --bindir | --bindi | --bind | --bin | --bi) ++ ac_prev=bindir ;; ++ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) ++ bindir=$ac_optarg ;; ++ ++ -build | --build | --buil | --bui | --bu) ++ ac_prev=build_alias ;; ++ -build=* | --build=* | --buil=* | --bui=* | --bu=*) ++ build_alias=$ac_optarg ;; ++ ++ -cache-file | --cache-file | --cache-fil | --cache-fi \ ++ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ++ ac_prev=cache_file ;; ++ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ ++ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) ++ cache_file=$ac_optarg ;; ++ ++ --config-cache | -C) ++ cache_file=config.cache ;; ++ ++ -datadir | --datadir | --datadi | --datad) ++ ac_prev=datadir ;; ++ -datadir=* | --datadir=* | --datadi=* | --datad=*) ++ datadir=$ac_optarg ;; ++ ++ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ ++ | --dataroo | --dataro | --datar) ++ ac_prev=datarootdir ;; ++ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ ++ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) ++ datarootdir=$ac_optarg ;; ++ ++ -disable-* | --disable-*) ++ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` ++ # Reject names that are not valid shell variable names. ++ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && ++ as_fn_error "invalid feature name: $ac_useropt" ++ ac_useropt_orig=$ac_useropt ++ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` ++ case $ac_user_opts in ++ *" ++"enable_$ac_useropt" ++"*) ;; ++ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ++ ac_unrecognized_sep=', ';; ++ esac ++ eval enable_$ac_useropt=no ;; ++ ++ -docdir | --docdir | --docdi | --doc | --do) ++ ac_prev=docdir ;; ++ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) ++ docdir=$ac_optarg ;; ++ ++ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ++ ac_prev=dvidir ;; ++ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) ++ dvidir=$ac_optarg ;; ++ ++ -enable-* | --enable-*) ++ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` ++ # Reject names that are not valid shell variable names. ++ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && ++ as_fn_error "invalid feature name: $ac_useropt" ++ ac_useropt_orig=$ac_useropt ++ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` ++ case $ac_user_opts in ++ *" ++"enable_$ac_useropt" ++"*) ;; ++ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ++ ac_unrecognized_sep=', ';; ++ esac ++ eval enable_$ac_useropt=\$ac_optarg ;; ++ ++ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ ++ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ ++ | --exec | --exe | --ex) ++ ac_prev=exec_prefix ;; ++ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ ++ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ ++ | --exec=* | --exe=* | --ex=*) ++ exec_prefix=$ac_optarg ;; ++ ++ -gas | --gas | --ga | --g) ++ # Obsolete; use --with-gas. ++ with_gas=yes ;; ++ ++ -help | --help | --hel | --he | -h) ++ ac_init_help=long ;; ++ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ++ ac_init_help=recursive ;; ++ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ++ ac_init_help=short ;; ++ ++ -host | --host | --hos | --ho) ++ ac_prev=host_alias ;; ++ -host=* | --host=* | --hos=* | --ho=*) ++ host_alias=$ac_optarg ;; ++ ++ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ++ ac_prev=htmldir ;; ++ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ ++ | --ht=*) ++ htmldir=$ac_optarg ;; ++ ++ -includedir | --includedir | --includedi | --included | --include \ ++ | --includ | --inclu | --incl | --inc) ++ ac_prev=includedir ;; ++ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ ++ | --includ=* | --inclu=* | --incl=* | --inc=*) ++ includedir=$ac_optarg ;; ++ ++ -infodir | --infodir | --infodi | --infod | --info | --inf) ++ ac_prev=infodir ;; ++ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) ++ infodir=$ac_optarg ;; ++ ++ -libdir | --libdir | --libdi | --libd) ++ ac_prev=libdir ;; ++ -libdir=* | --libdir=* | --libdi=* | --libd=*) ++ libdir=$ac_optarg ;; ++ ++ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ ++ | --libexe | --libex | --libe) ++ ac_prev=libexecdir ;; ++ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ ++ | --libexe=* | --libex=* | --libe=*) ++ libexecdir=$ac_optarg ;; ++ ++ -localedir | --localedir | --localedi | --localed | --locale) ++ ac_prev=localedir ;; ++ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) ++ localedir=$ac_optarg ;; ++ ++ -localstatedir | --localstatedir | --localstatedi | --localstated \ ++ | --localstate | --localstat | --localsta | --localst | --locals) ++ ac_prev=localstatedir ;; ++ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ ++ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) ++ localstatedir=$ac_optarg ;; ++ ++ -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ++ ac_prev=mandir ;; ++ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) ++ mandir=$ac_optarg ;; ++ ++ -nfp | --nfp | --nf) ++ # Obsolete; use --without-fp. ++ with_fp=no ;; ++ ++ -no-create | --no-create | --no-creat | --no-crea | --no-cre \ ++ | --no-cr | --no-c | -n) ++ no_create=yes ;; ++ ++ -no-recursion | --no-recursion | --no-recursio | --no-recursi \ ++ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ++ no_recursion=yes ;; ++ ++ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ ++ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ ++ | --oldin | --oldi | --old | --ol | --o) ++ ac_prev=oldincludedir ;; ++ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ ++ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ ++ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) ++ oldincludedir=$ac_optarg ;; ++ ++ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ++ ac_prev=prefix ;; ++ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) ++ prefix=$ac_optarg ;; ++ ++ -program-prefix | --program-prefix | --program-prefi | --program-pref \ ++ | --program-pre | --program-pr | --program-p) ++ ac_prev=program_prefix ;; ++ -program-prefix=* | --program-prefix=* | --program-prefi=* \ ++ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) ++ program_prefix=$ac_optarg ;; ++ ++ -program-suffix | --program-suffix | --program-suffi | --program-suff \ ++ | --program-suf | --program-su | --program-s) ++ ac_prev=program_suffix ;; ++ -program-suffix=* | --program-suffix=* | --program-suffi=* \ ++ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) ++ program_suffix=$ac_optarg ;; ++ ++ -program-transform-name | --program-transform-name \ ++ | --program-transform-nam | --program-transform-na \ ++ | --program-transform-n | --program-transform- \ ++ | --program-transform | --program-transfor \ ++ | --program-transfo | --program-transf \ ++ | --program-trans | --program-tran \ ++ | --progr-tra | --program-tr | --program-t) ++ ac_prev=program_transform_name ;; ++ -program-transform-name=* | --program-transform-name=* \ ++ | --program-transform-nam=* | --program-transform-na=* \ ++ | --program-transform-n=* | --program-transform-=* \ ++ | --program-transform=* | --program-transfor=* \ ++ | --program-transfo=* | --program-transf=* \ ++ | --program-trans=* | --program-tran=* \ ++ | --progr-tra=* | --program-tr=* | --program-t=*) ++ program_transform_name=$ac_optarg ;; ++ ++ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ++ ac_prev=pdfdir ;; ++ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) ++ pdfdir=$ac_optarg ;; ++ ++ -psdir | --psdir | --psdi | --psd | --ps) ++ ac_prev=psdir ;; ++ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) ++ psdir=$ac_optarg ;; ++ ++ -q | -quiet | --quiet | --quie | --qui | --qu | --q \ ++ | -silent | --silent | --silen | --sile | --sil) ++ silent=yes ;; ++ ++ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ++ ac_prev=sbindir ;; ++ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ ++ | --sbi=* | --sb=*) ++ sbindir=$ac_optarg ;; ++ ++ -sharedstatedir | --sharedstatedir | --sharedstatedi \ ++ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ ++ | --sharedst | --shareds | --shared | --share | --shar \ ++ | --sha | --sh) ++ ac_prev=sharedstatedir ;; ++ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ ++ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ ++ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ ++ | --sha=* | --sh=*) ++ sharedstatedir=$ac_optarg ;; ++ ++ -site | --site | --sit) ++ ac_prev=site ;; ++ -site=* | --site=* | --sit=*) ++ site=$ac_optarg ;; ++ ++ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ++ ac_prev=srcdir ;; ++ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) ++ srcdir=$ac_optarg ;; ++ ++ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ ++ | --syscon | --sysco | --sysc | --sys | --sy) ++ ac_prev=sysconfdir ;; ++ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ ++ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) ++ sysconfdir=$ac_optarg ;; ++ ++ -target | --target | --targe | --targ | --tar | --ta | --t) ++ ac_prev=target_alias ;; ++ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) ++ target_alias=$ac_optarg ;; ++ ++ -v | -verbose | --verbose | --verbos | --verbo | --verb) ++ verbose=yes ;; ++ ++ -version | --version | --versio | --versi | --vers | -V) ++ ac_init_version=: ;; ++ ++ -with-* | --with-*) ++ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` ++ # Reject names that are not valid shell variable names. ++ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && ++ as_fn_error "invalid package name: $ac_useropt" ++ ac_useropt_orig=$ac_useropt ++ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` ++ case $ac_user_opts in ++ *" ++"with_$ac_useropt" ++"*) ;; ++ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ++ ac_unrecognized_sep=', ';; ++ esac ++ eval with_$ac_useropt=\$ac_optarg ;; ++ ++ -without-* | --without-*) ++ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` ++ # Reject names that are not valid shell variable names. ++ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && ++ as_fn_error "invalid package name: $ac_useropt" ++ ac_useropt_orig=$ac_useropt ++ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` ++ case $ac_user_opts in ++ *" ++"with_$ac_useropt" ++"*) ;; ++ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ++ ac_unrecognized_sep=', ';; ++ esac ++ eval with_$ac_useropt=no ;; ++ ++ --x) ++ # Obsolete; use --with-x. ++ with_x=yes ;; ++ ++ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ ++ | --x-incl | --x-inc | --x-in | --x-i) ++ ac_prev=x_includes ;; ++ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ ++ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) ++ x_includes=$ac_optarg ;; ++ ++ -x-libraries | --x-libraries | --x-librarie | --x-librari \ ++ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ++ ac_prev=x_libraries ;; ++ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ ++ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) ++ x_libraries=$ac_optarg ;; ++ ++ -*) as_fn_error "unrecognized option: \`$ac_option' ++Try \`$0 --help' for more information." ++ ;; ++ ++ *=*) ++ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` ++ # Reject names that are not valid shell variable names. ++ case $ac_envvar in #( ++ '' | [0-9]* | *[!_$as_cr_alnum]* ) ++ as_fn_error "invalid variable name: \`$ac_envvar'" ;; ++ esac ++ eval $ac_envvar=\$ac_optarg ++ export $ac_envvar ;; ++ ++ *) ++ # FIXME: should be removed in autoconf 3.0. ++ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 ++ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && ++ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 ++ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ++ ;; ++ ++ esac ++done ++ ++if test -n "$ac_prev"; then ++ ac_option=--`echo $ac_prev | sed 's/_/-/g'` ++ as_fn_error "missing argument to $ac_option" ++fi ++ ++if test -n "$ac_unrecognized_opts"; then ++ case $enable_option_checking in ++ no) ;; ++ fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; ++ *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; ++ esac ++fi ++ ++# Check all directory arguments for consistency. ++for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ ++ datadir sysconfdir sharedstatedir localstatedir includedir \ ++ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ ++ libdir localedir mandir ++do ++ eval ac_val=\$$ac_var ++ # Remove trailing slashes. ++ case $ac_val in ++ */ ) ++ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` ++ eval $ac_var=\$ac_val;; ++ esac ++ # Be sure to have absolute directory names. ++ case $ac_val in ++ [\\/$]* | ?:[\\/]* ) continue;; ++ NONE | '' ) case $ac_var in *prefix ) continue;; esac;; ++ esac ++ as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" ++done ++ ++# There might be people who depend on the old broken behavior: `$host' ++# used to hold the argument of --host etc. ++# FIXME: To remove some day. ++build=$build_alias ++host=$host_alias ++target=$target_alias ++ ++# FIXME: To remove some day. ++if test "x$host_alias" != x; then ++ if test "x$build_alias" = x; then ++ cross_compiling=maybe ++ $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. ++ If a cross compiler is detected then cross compile mode will be used." >&2 ++ elif test "x$build_alias" != "x$host_alias"; then ++ cross_compiling=yes ++ fi ++fi ++ ++ac_tool_prefix= ++test -n "$host_alias" && ac_tool_prefix=$host_alias- ++ ++test "$silent" = yes && exec 6>/dev/null ++ ++ ++ac_pwd=`pwd` && test -n "$ac_pwd" && ++ac_ls_di=`ls -di .` && ++ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || ++ as_fn_error "working directory cannot be determined" ++test "X$ac_ls_di" = "X$ac_pwd_ls_di" || ++ as_fn_error "pwd does not report name of working directory" ++ ++ ++# Find the source files, if location was not specified. ++if test -z "$srcdir"; then ++ ac_srcdir_defaulted=yes ++ # Try the directory containing this script, then the parent directory. ++ ac_confdir=`$as_dirname -- "$as_myself" || ++$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ++ X"$as_myself" : 'X\(//\)[^/]' \| \ ++ X"$as_myself" : 'X\(//\)$' \| \ ++ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || ++$as_echo X"$as_myself" | ++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\/\)[^/].*/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\/\)$/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\).*/{ ++ s//\1/ ++ q ++ } ++ s/.*/./; q'` ++ srcdir=$ac_confdir ++ if test ! -r "$srcdir/$ac_unique_file"; then ++ srcdir=.. ++ fi ++else ++ ac_srcdir_defaulted=no ++fi ++if test ! -r "$srcdir/$ac_unique_file"; then ++ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." ++ as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" ++fi ++ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ++ac_abs_confdir=`( ++ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" ++ pwd)` ++# When building in place, set srcdir=. ++if test "$ac_abs_confdir" = "$ac_pwd"; then ++ srcdir=. ++fi ++# Remove unnecessary trailing slashes from srcdir. ++# Double slashes in file names in object file debugging info ++# mess up M-x gdb in Emacs. ++case $srcdir in ++*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; ++esac ++for ac_var in $ac_precious_vars; do ++ eval ac_env_${ac_var}_set=\${${ac_var}+set} ++ eval ac_env_${ac_var}_value=\$${ac_var} ++ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} ++ eval ac_cv_env_${ac_var}_value=\$${ac_var} ++done ++ ++# ++# Report the --help message. ++# ++if test "$ac_init_help" = "long"; then ++ # Omit some internal or obsolete options to make the list less imposing. ++ # This message is too long to be a string in the A/UX 3.1 sh. ++ cat <<_ACEOF ++\`configure' configures package-unused version-unused to adapt to many kinds of systems. ++ ++Usage: $0 [OPTION]... [VAR=VALUE]... ++ ++To assign environment variables (e.g., CC, CFLAGS...), specify them as ++VAR=VALUE. See below for descriptions of some of the useful variables. ++ ++Defaults for the options are specified in brackets. ++ ++Configuration: ++ -h, --help display this help and exit ++ --help=short display options specific to this package ++ --help=recursive display the short help of all the included packages ++ -V, --version display version information and exit ++ -q, --quiet, --silent do not print \`checking...' messages ++ --cache-file=FILE cache test results in FILE [disabled] ++ -C, --config-cache alias for \`--cache-file=config.cache' ++ -n, --no-create do not create output files ++ --srcdir=DIR find the sources in DIR [configure dir or \`..'] ++ ++Installation directories: ++ --prefix=PREFIX install architecture-independent files in PREFIX ++ [$ac_default_prefix] ++ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX ++ [PREFIX] ++ ++By default, \`make install' will install all the files in ++\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify ++an installation prefix other than \`$ac_default_prefix' using \`--prefix', ++for instance \`--prefix=\$HOME'. ++ ++For better control, use the options below. ++ ++Fine tuning of the installation directories: ++ --bindir=DIR user executables [EPREFIX/bin] ++ --sbindir=DIR system admin executables [EPREFIX/sbin] ++ --libexecdir=DIR program executables [EPREFIX/libexec] ++ --sysconfdir=DIR read-only single-machine data [PREFIX/etc] ++ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] ++ --localstatedir=DIR modifiable single-machine data [PREFIX/var] ++ --libdir=DIR object code libraries [EPREFIX/lib] ++ --includedir=DIR C header files [PREFIX/include] ++ --oldincludedir=DIR C header files for non-gcc [/usr/include] ++ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] ++ --datadir=DIR read-only architecture-independent data [DATAROOTDIR] ++ --infodir=DIR info documentation [DATAROOTDIR/info] ++ --localedir=DIR locale-dependent data [DATAROOTDIR/locale] ++ --mandir=DIR man documentation [DATAROOTDIR/man] ++ --docdir=DIR documentation root [DATAROOTDIR/doc/libbacktrace] ++ --htmldir=DIR html documentation [DOCDIR] ++ --dvidir=DIR dvi documentation [DOCDIR] ++ --pdfdir=DIR pdf documentation [DOCDIR] ++ --psdir=DIR ps documentation [DOCDIR] ++_ACEOF ++ ++ cat <<\_ACEOF ++ ++Program names: ++ --program-prefix=PREFIX prepend PREFIX to installed program names ++ --program-suffix=SUFFIX append SUFFIX to installed program names ++ --program-transform-name=PROGRAM run sed PROGRAM on installed program names ++ ++System types: ++ --build=BUILD configure for building on BUILD [guessed] ++ --host=HOST cross-compile to build programs to run on HOST [BUILD] ++ --target=TARGET configure for building compilers for TARGET [HOST] ++_ACEOF ++fi ++ ++if test -n "$ac_init_help"; then ++ case $ac_init_help in ++ short | recursive ) echo "Configuration of package-unused version-unused:";; ++ esac ++ cat <<\_ACEOF ++ ++Optional Features: ++ --disable-option-checking ignore unrecognized --enable/--with options ++ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) ++ --enable-FEATURE[=ARG] include FEATURE [ARG=yes] ++ --enable-multilib build many library versions (default) ++ --enable-maintainer-mode enable make rules and dependencies not useful ++ (and sometimes confusing) to the casual installer ++ --enable-shared[=PKGS] build shared libraries [default=yes] ++ --enable-static[=PKGS] build static libraries [default=yes] ++ --enable-fast-install[=PKGS] ++ optimize for fast installation [default=yes] ++ --disable-libtool-lock avoid locking (might break parallel builds) ++ --enable-host-shared build host code as shared libraries ++ ++Optional Packages: ++ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] ++ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) ++ --with-target-subdir=SUBDIR Configuring in a subdirectory for target ++ --with-pic try to use only PIC/non-PIC objects [default=use ++ both] ++ --with-gnu-ld assume the C compiler uses GNU ld [default=no] ++ --with-system-libunwind use installed libunwind ++ ++Some influential environment variables: ++ CC C compiler command ++ CFLAGS C compiler flags ++ LDFLAGS linker flags, e.g. -L if you have libraries in a ++ nonstandard directory ++ LIBS libraries to pass to the linker, e.g. -l ++ CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if ++ you have headers in a nonstandard directory ++ CPP C preprocessor ++ ++Use these variables to override the choices made by `configure' or to help ++it to find libraries and programs with nonstandard names/locations. ++ ++Report bugs to the package provider. ++_ACEOF ++ac_status=$? ++fi ++ ++if test "$ac_init_help" = "recursive"; then ++ # If there are subdirs, report their specific --help. ++ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue ++ test -d "$ac_dir" || ++ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || ++ continue ++ ac_builddir=. ++ ++case "$ac_dir" in ++.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; ++*) ++ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` ++ # A ".." for each directory in $ac_dir_suffix. ++ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` ++ case $ac_top_builddir_sub in ++ "") ac_top_builddir_sub=. ac_top_build_prefix= ;; ++ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; ++ esac ;; ++esac ++ac_abs_top_builddir=$ac_pwd ++ac_abs_builddir=$ac_pwd$ac_dir_suffix ++# for backward compatibility: ++ac_top_builddir=$ac_top_build_prefix ++ ++case $srcdir in ++ .) # We are building in place. ++ ac_srcdir=. ++ ac_top_srcdir=$ac_top_builddir_sub ++ ac_abs_top_srcdir=$ac_pwd ;; ++ [\\/]* | ?:[\\/]* ) # Absolute name. ++ ac_srcdir=$srcdir$ac_dir_suffix; ++ ac_top_srcdir=$srcdir ++ ac_abs_top_srcdir=$srcdir ;; ++ *) # Relative name. ++ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ++ ac_top_srcdir=$ac_top_build_prefix$srcdir ++ ac_abs_top_srcdir=$ac_pwd/$srcdir ;; ++esac ++ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix ++ ++ cd "$ac_dir" || { ac_status=$?; continue; } ++ # Check for guested configure. ++ if test -f "$ac_srcdir/configure.gnu"; then ++ echo && ++ $SHELL "$ac_srcdir/configure.gnu" --help=recursive ++ elif test -f "$ac_srcdir/configure"; then ++ echo && ++ $SHELL "$ac_srcdir/configure" --help=recursive ++ else ++ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 ++ fi || ac_status=$? ++ cd "$ac_pwd" || { ac_status=$?; break; } ++ done ++fi ++ ++test -n "$ac_init_help" && exit $ac_status ++if $ac_init_version; then ++ cat <<\_ACEOF ++package-unused configure version-unused ++generated by GNU Autoconf 2.64 ++ ++Copyright (C) 2009 Free Software Foundation, Inc. ++This configure script is free software; the Free Software Foundation ++gives unlimited permission to copy, distribute and modify it. ++_ACEOF ++ exit ++fi ++ ++## ------------------------ ## ++## Autoconf initialization. ## ++## ------------------------ ## ++ ++# ac_fn_c_try_compile LINENO ++# -------------------------- ++# Try to compile conftest.$ac_ext, and return whether this succeeded. ++ac_fn_c_try_compile () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ rm -f conftest.$ac_objext ++ if { { ac_try="$ac_compile" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_compile") 2>conftest.err ++ ac_status=$? ++ if test -s conftest.err; then ++ grep -v '^ *+' conftest.err >conftest.er1 ++ cat conftest.er1 >&5 ++ mv -f conftest.er1 conftest.err ++ fi ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } && { ++ test -z "$ac_c_werror_flag" || ++ test ! -s conftest.err ++ } && test -s conftest.$ac_objext; then : ++ ac_retval=0 ++else ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_retval=1 ++fi ++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ return $ac_retval ++ ++} # ac_fn_c_try_compile ++ ++# ac_fn_c_try_cpp LINENO ++# ---------------------- ++# Try to preprocess conftest.$ac_ext, and return whether this succeeded. ++ac_fn_c_try_cpp () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ if { { ac_try="$ac_cpp conftest.$ac_ext" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ++ ac_status=$? ++ if test -s conftest.err; then ++ grep -v '^ *+' conftest.err >conftest.er1 ++ cat conftest.er1 >&5 ++ mv -f conftest.er1 conftest.err ++ fi ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } >/dev/null && { ++ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || ++ test ! -s conftest.err ++ }; then : ++ ac_retval=0 ++else ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_retval=1 ++fi ++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ return $ac_retval ++ ++} # ac_fn_c_try_cpp ++ ++# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES ++# ------------------------------------------------------- ++# Tests whether HEADER exists, giving a warning if it cannot be compiled using ++# the include files in INCLUDES and setting the cache variable VAR ++# accordingly. ++ac_fn_c_check_header_mongrel () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 ++$as_echo_n "checking for $2... " >&6; } ++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++ $as_echo_n "(cached) " >&6 ++fi ++eval ac_res=\$$3 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++else ++ # Is the header compilable? ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 ++$as_echo_n "checking $2 usability... " >&6; } ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++#include <$2> ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_header_compiler=yes ++else ++ ac_header_compiler=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 ++$as_echo "$ac_header_compiler" >&6; } ++ ++# Is the header present? ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 ++$as_echo_n "checking $2 presence... " >&6; } ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include <$2> ++_ACEOF ++if ac_fn_c_try_cpp "$LINENO"; then : ++ ac_header_preproc=yes ++else ++ ac_header_preproc=no ++fi ++rm -f conftest.err conftest.$ac_ext ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 ++$as_echo "$ac_header_preproc" >&6; } ++ ++# So? What about this header? ++case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( ++ yes:no: ) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 ++$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 ++$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ++ ;; ++ no:yes:* ) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 ++$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 ++$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 ++$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 ++$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 ++$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ++ ;; ++esac ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 ++$as_echo_n "checking for $2... " >&6; } ++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++ $as_echo_n "(cached) " >&6 ++else ++ eval "$3=\$ac_header_compiler" ++fi ++eval ac_res=\$$3 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++fi ++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ ++} # ac_fn_c_check_header_mongrel ++ ++# ac_fn_c_try_run LINENO ++# ---------------------- ++# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes ++# that executables *can* be run. ++ac_fn_c_try_run () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ if { { ac_try="$ac_link" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_link") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' ++ { { case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_try") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; }; then : ++ ac_retval=0 ++else ++ $as_echo "$as_me: program exited with status $ac_status" >&5 ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_retval=$ac_status ++fi ++ rm -rf conftest.dSYM conftest_ipa8_conftest.oo ++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ return $ac_retval ++ ++} # ac_fn_c_try_run ++ ++# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES ++# ------------------------------------------------------- ++# Tests whether HEADER exists and can be compiled using the include files in ++# INCLUDES, setting the cache variable VAR accordingly. ++ac_fn_c_check_header_compile () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 ++$as_echo_n "checking for $2... " >&6; } ++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++#include <$2> ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ eval "$3=yes" ++else ++ eval "$3=no" ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++eval ac_res=\$$3 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ ++} # ac_fn_c_check_header_compile ++ ++# ac_fn_c_try_link LINENO ++# ----------------------- ++# Try to link conftest.$ac_ext, and return whether this succeeded. ++ac_fn_c_try_link () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ rm -f conftest.$ac_objext conftest$ac_exeext ++ if { { ac_try="$ac_link" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_link") 2>conftest.err ++ ac_status=$? ++ if test -s conftest.err; then ++ grep -v '^ *+' conftest.err >conftest.er1 ++ cat conftest.er1 >&5 ++ mv -f conftest.er1 conftest.err ++ fi ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } && { ++ test -z "$ac_c_werror_flag" || ++ test ! -s conftest.err ++ } && test -s conftest$ac_exeext && { ++ test "$cross_compiling" = yes || ++ $as_test_x conftest$ac_exeext ++ }; then : ++ ac_retval=0 ++else ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++ ac_retval=1 ++fi ++ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information ++ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would ++ # interfere with the next link command; also delete a directory that is ++ # left behind by Apple's compiler. We do this before executing the actions. ++ rm -rf conftest.dSYM conftest_ipa8_conftest.oo ++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ return $ac_retval ++ ++} # ac_fn_c_try_link ++ ++# ac_fn_c_check_func LINENO FUNC VAR ++# ---------------------------------- ++# Tests whether FUNC exists, setting the cache variable VAR accordingly ++ac_fn_c_check_func () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 ++$as_echo_n "checking for $2... " >&6; } ++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++/* Define $2 to an innocuous variant, in case declares $2. ++ For example, HP-UX 11i declares gettimeofday. */ ++#define $2 innocuous_$2 ++ ++/* System header to define __stub macros and hopefully few prototypes, ++ which can conflict with char $2 (); below. ++ Prefer to if __STDC__ is defined, since ++ exists even on freestanding compilers. */ ++ ++#ifdef __STDC__ ++# include ++#else ++# include ++#endif ++ ++#undef $2 ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char $2 (); ++/* The GNU C library defines this for functions which it implements ++ to always fail with ENOSYS. Some functions are actually named ++ something starting with __ and the normal name is an alias. */ ++#if defined __stub_$2 || defined __stub___$2 ++choke me ++#endif ++ ++int ++main () ++{ ++return $2 (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ eval "$3=yes" ++else ++ eval "$3=no" ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++fi ++eval ac_res=\$$3 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ ++} # ac_fn_c_check_func ++ ++# ac_fn_c_check_type LINENO TYPE VAR INCLUDES ++# ------------------------------------------- ++# Tests whether TYPE exists after having included INCLUDES, setting cache ++# variable VAR accordingly. ++ac_fn_c_check_type () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 ++$as_echo_n "checking for $2... " >&6; } ++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++ $as_echo_n "(cached) " >&6 ++else ++ eval "$3=no" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++if (sizeof ($2)) ++ return 0; ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++if (sizeof (($2))) ++ return 0; ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ++else ++ eval "$3=yes" ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++eval ac_res=\$$3 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ ++} # ac_fn_c_check_type ++ ++# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES ++# -------------------------------------------- ++# Tries to find the compile-time value of EXPR in a program that includes ++# INCLUDES, setting VAR accordingly. Returns whether the value could be ++# computed ++ac_fn_c_compute_int () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ if test "$cross_compiling" = yes; then ++ # Depending upon the size, compute the lo and hi bounds. ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++static int test_array [1 - 2 * !(($2) >= 0)]; ++test_array [0] = 0 ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_lo=0 ac_mid=0 ++ while :; do ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++static int test_array [1 - 2 * !(($2) <= $ac_mid)]; ++test_array [0] = 0 ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_hi=$ac_mid; break ++else ++ as_fn_arith $ac_mid + 1 && ac_lo=$as_val ++ if test $ac_lo -le $ac_mid; then ++ ac_lo= ac_hi= ++ break ++ fi ++ as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ done ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++static int test_array [1 - 2 * !(($2) < 0)]; ++test_array [0] = 0 ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_hi=-1 ac_mid=-1 ++ while :; do ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++static int test_array [1 - 2 * !(($2) >= $ac_mid)]; ++test_array [0] = 0 ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_lo=$ac_mid; break ++else ++ as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val ++ if test $ac_mid -le $ac_hi; then ++ ac_lo= ac_hi= ++ break ++ fi ++ as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ done ++else ++ ac_lo= ac_hi= ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++# Binary search between lo and hi bounds. ++while test "x$ac_lo" != "x$ac_hi"; do ++ as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++static int test_array [1 - 2 * !(($2) <= $ac_mid)]; ++test_array [0] = 0 ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_hi=$ac_mid ++else ++ as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++done ++case $ac_lo in #(( ++?*) eval "$3=\$ac_lo"; ac_retval=0 ;; ++'') ac_retval=1 ;; ++esac ++ else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++static long int longval () { return $2; } ++static unsigned long int ulongval () { return $2; } ++#include ++#include ++int ++main () ++{ ++ ++ FILE *f = fopen ("conftest.val", "w"); ++ if (! f) ++ return 1; ++ if (($2) < 0) ++ { ++ long int i = longval (); ++ if (i != ($2)) ++ return 1; ++ fprintf (f, "%ld", i); ++ } ++ else ++ { ++ unsigned long int i = ulongval (); ++ if (i != ($2)) ++ return 1; ++ fprintf (f, "%lu", i); ++ } ++ /* Do not output a trailing newline, as this causes \r\n confusion ++ on some platforms. */ ++ return ferror (f) || fclose (f) != 0; ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_run "$LINENO"; then : ++ echo >>conftest.val; read $3 &5 ++$as_echo_n "checking whether $as_decl_name is declared... " >&6; } ++if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++#ifndef $as_decl_name ++#ifdef __cplusplus ++ (void) $as_decl_use; ++#else ++ (void) $as_decl_name; ++#endif ++#endif ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ eval "$3=yes" ++else ++ eval "$3=no" ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++eval ac_res=\$$3 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ ++} # ac_fn_c_check_decl ++cat >config.log <<_ACEOF ++This file contains any messages produced by compilers while ++running configure, to aid debugging if configure makes a mistake. ++ ++It was created by package-unused $as_me version-unused, which was ++generated by GNU Autoconf 2.64. Invocation command line was ++ ++ $ $0 $@ ++ ++_ACEOF ++exec 5>>config.log ++{ ++cat <<_ASUNAME ++## --------- ## ++## Platform. ## ++## --------- ## ++ ++hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` ++uname -m = `(uname -m) 2>/dev/null || echo unknown` ++uname -r = `(uname -r) 2>/dev/null || echo unknown` ++uname -s = `(uname -s) 2>/dev/null || echo unknown` ++uname -v = `(uname -v) 2>/dev/null || echo unknown` ++ ++/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` ++/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` ++ ++/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` ++/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` ++/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` ++/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` ++/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` ++/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` ++/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` ++ ++_ASUNAME ++ ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ $as_echo "PATH: $as_dir" ++ done ++IFS=$as_save_IFS ++ ++} >&5 ++ ++cat >&5 <<_ACEOF ++ ++ ++## ----------- ## ++## Core tests. ## ++## ----------- ## ++ ++_ACEOF ++ ++ ++# Keep a trace of the command line. ++# Strip out --no-create and --no-recursion so they do not pile up. ++# Strip out --silent because we don't want to record it for future runs. ++# Also quote any args containing shell meta-characters. ++# Make two passes to allow for proper duplicate-argument suppression. ++ac_configure_args= ++ac_configure_args0= ++ac_configure_args1= ++ac_must_keep_next=false ++for ac_pass in 1 2 ++do ++ for ac_arg ++ do ++ case $ac_arg in ++ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; ++ -q | -quiet | --quiet | --quie | --qui | --qu | --q \ ++ | -silent | --silent | --silen | --sile | --sil) ++ continue ;; ++ *\'*) ++ ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; ++ esac ++ case $ac_pass in ++ 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; ++ 2) ++ as_fn_append ac_configure_args1 " '$ac_arg'" ++ if test $ac_must_keep_next = true; then ++ ac_must_keep_next=false # Got value, back to normal. ++ else ++ case $ac_arg in ++ *=* | --config-cache | -C | -disable-* | --disable-* \ ++ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ ++ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ ++ | -with-* | --with-* | -without-* | --without-* | --x) ++ case "$ac_configure_args0 " in ++ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; ++ esac ++ ;; ++ -* ) ac_must_keep_next=true ;; ++ esac ++ fi ++ as_fn_append ac_configure_args " '$ac_arg'" ++ ;; ++ esac ++ done ++done ++{ ac_configure_args0=; unset ac_configure_args0;} ++{ ac_configure_args1=; unset ac_configure_args1;} ++ ++# When interrupted or exit'd, cleanup temporary files, and complete ++# config.log. We remove comments because anyway the quotes in there ++# would cause problems or look ugly. ++# WARNING: Use '\'' to represent an apostrophe within the trap. ++# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. ++trap 'exit_status=$? ++ # Save into config.log some information that might help in debugging. ++ { ++ echo ++ ++ cat <<\_ASBOX ++## ---------------- ## ++## Cache variables. ## ++## ---------------- ## ++_ASBOX ++ echo ++ # The following way of writing the cache mishandles newlines in values, ++( ++ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do ++ eval ac_val=\$$ac_var ++ case $ac_val in #( ++ *${as_nl}*) ++ case $ac_var in #( ++ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 ++$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ++ esac ++ case $ac_var in #( ++ _ | IFS | as_nl) ;; #( ++ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( ++ *) { eval $ac_var=; unset $ac_var;} ;; ++ esac ;; ++ esac ++ done ++ (set) 2>&1 | ++ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( ++ *${as_nl}ac_space=\ *) ++ sed -n \ ++ "s/'\''/'\''\\\\'\'''\''/g; ++ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ++ ;; #( ++ *) ++ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ++ ;; ++ esac | ++ sort ++) ++ echo ++ ++ cat <<\_ASBOX ++## ----------------- ## ++## Output variables. ## ++## ----------------- ## ++_ASBOX ++ echo ++ for ac_var in $ac_subst_vars ++ do ++ eval ac_val=\$$ac_var ++ case $ac_val in ++ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; ++ esac ++ $as_echo "$ac_var='\''$ac_val'\''" ++ done | sort ++ echo ++ ++ if test -n "$ac_subst_files"; then ++ cat <<\_ASBOX ++## ------------------- ## ++## File substitutions. ## ++## ------------------- ## ++_ASBOX ++ echo ++ for ac_var in $ac_subst_files ++ do ++ eval ac_val=\$$ac_var ++ case $ac_val in ++ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; ++ esac ++ $as_echo "$ac_var='\''$ac_val'\''" ++ done | sort ++ echo ++ fi ++ ++ if test -s confdefs.h; then ++ cat <<\_ASBOX ++## ----------- ## ++## confdefs.h. ## ++## ----------- ## ++_ASBOX ++ echo ++ cat confdefs.h ++ echo ++ fi ++ test "$ac_signal" != 0 && ++ $as_echo "$as_me: caught signal $ac_signal" ++ $as_echo "$as_me: exit $exit_status" ++ } >&5 ++ rm -f core *.core core.conftest.* && ++ rm -f -r conftest* confdefs* conf$$* $ac_clean_files && ++ exit $exit_status ++' 0 ++for ac_signal in 1 2 13 15; do ++ trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal ++done ++ac_signal=0 ++ ++# confdefs.h avoids OS command line length limits that DEFS can exceed. ++rm -f -r conftest* confdefs.h ++ ++$as_echo "/* confdefs.h */" > confdefs.h ++ ++# Predefined preprocessor variables. ++ ++cat >>confdefs.h <<_ACEOF ++#define PACKAGE_NAME "$PACKAGE_NAME" ++_ACEOF ++ ++cat >>confdefs.h <<_ACEOF ++#define PACKAGE_TARNAME "$PACKAGE_TARNAME" ++_ACEOF ++ ++cat >>confdefs.h <<_ACEOF ++#define PACKAGE_VERSION "$PACKAGE_VERSION" ++_ACEOF ++ ++cat >>confdefs.h <<_ACEOF ++#define PACKAGE_STRING "$PACKAGE_STRING" ++_ACEOF ++ ++cat >>confdefs.h <<_ACEOF ++#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" ++_ACEOF ++ ++cat >>confdefs.h <<_ACEOF ++#define PACKAGE_URL "$PACKAGE_URL" ++_ACEOF ++ ++ ++# Let the site file select an alternate cache file if it wants to. ++# Prefer an explicitly selected file to automatically selected ones. ++ac_site_file1=NONE ++ac_site_file2=NONE ++if test -n "$CONFIG_SITE"; then ++ ac_site_file1=$CONFIG_SITE ++elif test "x$prefix" != xNONE; then ++ ac_site_file1=$prefix/share/config.site ++ ac_site_file2=$prefix/etc/config.site ++else ++ ac_site_file1=$ac_default_prefix/share/config.site ++ ac_site_file2=$ac_default_prefix/etc/config.site ++fi ++for ac_site_file in "$ac_site_file1" "$ac_site_file2" ++do ++ test "x$ac_site_file" = xNONE && continue ++ if test -r "$ac_site_file"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 ++$as_echo "$as_me: loading site script $ac_site_file" >&6;} ++ sed 's/^/| /' "$ac_site_file" >&5 ++ . "$ac_site_file" ++ fi ++done ++ ++if test -r "$cache_file"; then ++ # Some versions of bash will fail to source /dev/null (special ++ # files actually), so we avoid doing that. ++ if test -f "$cache_file"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 ++$as_echo "$as_me: loading cache $cache_file" >&6;} ++ case $cache_file in ++ [\\/]* | ?:[\\/]* ) . "$cache_file";; ++ *) . "./$cache_file";; ++ esac ++ fi ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 ++$as_echo "$as_me: creating cache $cache_file" >&6;} ++ >$cache_file ++fi ++ ++# Check that the precious variables saved in the cache have kept the same ++# value. ++ac_cache_corrupted=false ++for ac_var in $ac_precious_vars; do ++ eval ac_old_set=\$ac_cv_env_${ac_var}_set ++ eval ac_new_set=\$ac_env_${ac_var}_set ++ eval ac_old_val=\$ac_cv_env_${ac_var}_value ++ eval ac_new_val=\$ac_env_${ac_var}_value ++ case $ac_old_set,$ac_new_set in ++ set,) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 ++$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ++ ac_cache_corrupted=: ;; ++ ,set) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 ++$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ++ ac_cache_corrupted=: ;; ++ ,);; ++ *) ++ if test "x$ac_old_val" != "x$ac_new_val"; then ++ # differences in whitespace do not lead to failure. ++ ac_old_val_w=`echo x $ac_old_val` ++ ac_new_val_w=`echo x $ac_new_val` ++ if test "$ac_old_val_w" != "$ac_new_val_w"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 ++$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ++ ac_cache_corrupted=: ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 ++$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} ++ eval $ac_var=\$ac_old_val ++ fi ++ { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 ++$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} ++ { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 ++$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} ++ fi;; ++ esac ++ # Pass precious variables to config.status. ++ if test "$ac_new_set" = set; then ++ case $ac_new_val in ++ *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; ++ *) ac_arg=$ac_var=$ac_new_val ;; ++ esac ++ case " $ac_configure_args " in ++ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. ++ *) as_fn_append ac_configure_args " '$ac_arg'" ;; ++ esac ++ fi ++done ++if $ac_cache_corrupted; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++ { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 ++$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} ++ as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 ++fi ++## -------------------- ## ++## Main body of script. ## ++## -------------------- ## ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++ ++ ++ ++ ++ ++ac_config_headers="$ac_config_headers config.h" ++ ++ ++if test -n "${with_target_subdir}"; then ++ # Default to --enable-multilib ++# Check whether --enable-multilib was given. ++if test "${enable_multilib+set}" = set; then : ++ enableval=$enable_multilib; case "$enableval" in ++ yes) multilib=yes ;; ++ no) multilib=no ;; ++ *) as_fn_error "bad value $enableval for multilib option" "$LINENO" 5 ;; ++ esac ++else ++ multilib=yes ++fi ++ ++ ++# We may get other options which we leave undocumented: ++# --with-target-subdir, --with-multisrctop, --with-multisubdir ++# See config-ml.in if you want the gory details. ++ ++if test "$srcdir" = "."; then ++ if test "$with_target_subdir" != "."; then ++ multi_basedir="$srcdir/$with_multisrctop../.." ++ else ++ multi_basedir="$srcdir/$with_multisrctop.." ++ fi ++else ++ multi_basedir="$srcdir/.." ++fi ++ ++ ++# Even if the default multilib is not a cross compilation, ++# it may be that some of the other multilibs are. ++if test $cross_compiling = no && test $multilib = yes \ ++ && test "x${with_multisubdir}" != x ; then ++ cross_compiling=maybe ++fi ++ ++ac_config_commands="$ac_config_commands default-1" ++ ++fi ++ ++ac_aux_dir= ++for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do ++ for ac_t in install-sh install.sh shtool; do ++ if test -f "$ac_dir/$ac_t"; then ++ ac_aux_dir=$ac_dir ++ ac_install_sh="$ac_aux_dir/$ac_t -c" ++ break 2 ++ fi ++ done ++done ++if test -z "$ac_aux_dir"; then ++ as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 ++fi ++ ++# These three variables are undocumented and unsupported, ++# and are intended to be withdrawn in a future Autoconf release. ++# They can cause serious problems if a builder's source tree is in a directory ++# whose full name contains unusual characters. ++ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ++ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ++ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. ++ ++ ++# Make sure we can run config.sub. ++$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || ++ as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 ++$as_echo_n "checking build system type... " >&6; } ++if test "${ac_cv_build+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_build_alias=$build_alias ++test "x$ac_build_alias" = x && ++ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` ++test "x$ac_build_alias" = x && ++ as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 ++ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || ++ as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 ++$as_echo "$ac_cv_build" >&6; } ++case $ac_cv_build in ++*-*-*) ;; ++*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; ++esac ++build=$ac_cv_build ++ac_save_IFS=$IFS; IFS='-' ++set x $ac_cv_build ++shift ++build_cpu=$1 ++build_vendor=$2 ++shift; shift ++# Remember, the first character of IFS is used to create $*, ++# except with old shells: ++build_os=$* ++IFS=$ac_save_IFS ++case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 ++$as_echo_n "checking host system type... " >&6; } ++if test "${ac_cv_host+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test "x$host_alias" = x; then ++ ac_cv_host=$ac_cv_build ++else ++ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || ++ as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 ++$as_echo "$ac_cv_host" >&6; } ++case $ac_cv_host in ++*-*-*) ;; ++*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; ++esac ++host=$ac_cv_host ++ac_save_IFS=$IFS; IFS='-' ++set x $ac_cv_host ++shift ++host_cpu=$1 ++host_vendor=$2 ++shift; shift ++# Remember, the first character of IFS is used to create $*, ++# except with old shells: ++host_os=$* ++IFS=$ac_save_IFS ++case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 ++$as_echo_n "checking target system type... " >&6; } ++if test "${ac_cv_target+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test "x$target_alias" = x; then ++ ac_cv_target=$ac_cv_host ++else ++ ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || ++ as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 ++$as_echo "$ac_cv_target" >&6; } ++case $ac_cv_target in ++*-*-*) ;; ++*) as_fn_error "invalid value of canonical target" "$LINENO" 5;; ++esac ++target=$ac_cv_target ++ac_save_IFS=$IFS; IFS='-' ++set x $ac_cv_target ++shift ++target_cpu=$1 ++target_vendor=$2 ++shift; shift ++# Remember, the first character of IFS is used to create $*, ++# except with old shells: ++target_os=$* ++IFS=$ac_save_IFS ++case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac ++ ++ ++# The aliases save the names the user supplied, while $host etc. ++# will get canonicalized. ++test -n "$target_alias" && ++ test "$program_prefix$program_suffix$program_transform_name" = \ ++ NONENONEs,x,x, && ++ program_prefix=${target_alias}- ++ ++target_alias=${target_alias-$host_alias} ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. ++set dummy ${ac_tool_prefix}gcc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_CC="${ac_tool_prefix}gcc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_CC"; then ++ ac_ct_CC=$CC ++ # Extract the first word of "gcc", so it can be a program name with args. ++set dummy gcc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_CC"; then ++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_CC="gcc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_CC=$ac_cv_prog_ac_ct_CC ++if test -n "$ac_ct_CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 ++$as_echo "$ac_ct_CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_CC" = x; then ++ CC="" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ CC=$ac_ct_CC ++ fi ++else ++ CC="$ac_cv_prog_CC" ++fi ++ ++if test -z "$CC"; then ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. ++set dummy ${ac_tool_prefix}cc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_CC="${ac_tool_prefix}cc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ fi ++fi ++if test -z "$CC"; then ++ # Extract the first word of "cc", so it can be a program name with args. ++set dummy cc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++ ac_prog_rejected=no ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ++ ac_prog_rejected=yes ++ continue ++ fi ++ ac_cv_prog_CC="cc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++if test $ac_prog_rejected = yes; then ++ # We found a bogon in the path, so make sure we never use it. ++ set dummy $ac_cv_prog_CC ++ shift ++ if test $# != 0; then ++ # We chose a different compiler from the bogus one. ++ # However, it has the same basename, so the bogon will be chosen ++ # first if we set CC to just the basename; use the full file name. ++ shift ++ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" ++ fi ++fi ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$CC"; then ++ if test -n "$ac_tool_prefix"; then ++ for ac_prog in cl.exe ++ do ++ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. ++set dummy $ac_tool_prefix$ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_CC="$ac_tool_prefix$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$CC" && break ++ done ++fi ++if test -z "$CC"; then ++ ac_ct_CC=$CC ++ for ac_prog in cl.exe ++do ++ # Extract the first word of "$ac_prog", so it can be a program name with args. ++set dummy $ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_CC"; then ++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_CC="$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_CC=$ac_cv_prog_ac_ct_CC ++if test -n "$ac_ct_CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 ++$as_echo "$ac_ct_CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$ac_ct_CC" && break ++done ++ ++ if test "x$ac_ct_CC" = x; then ++ CC="" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ CC=$ac_ct_CC ++ fi ++fi ++ ++fi ++ ++ ++test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error "no acceptable C compiler found in \$PATH ++See \`config.log' for more details." "$LINENO" 5; } ++ ++# Provide some information about the compiler. ++$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 ++set X $ac_compile ++ac_compiler=$2 ++for ac_option in --version -v -V -qversion; do ++ { { ac_try="$ac_compiler $ac_option >&5" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_compiler $ac_option >&5") 2>conftest.err ++ ac_status=$? ++ if test -s conftest.err; then ++ sed '10a\ ++... rest of stderr output deleted ... ++ 10q' conftest.err >conftest.er1 ++ cat conftest.er1 >&5 ++ rm -f conftest.er1 conftest.err ++ fi ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } ++done ++ ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++ac_clean_files_save=$ac_clean_files ++ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out" ++# Try to create an executable without -o first, disregard a.out. ++# It will help us diagnose broken compilers, and finding out an intuition ++# of exeext. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 ++$as_echo_n "checking for C compiler default output file name... " >&6; } ++ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` ++ ++# The possible output files: ++ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ++ ++ac_rmfiles= ++for ac_file in $ac_files ++do ++ case $ac_file in ++ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; ++ * ) ac_rmfiles="$ac_rmfiles $ac_file";; ++ esac ++done ++rm -f $ac_rmfiles ++ ++if { { ac_try="$ac_link_default" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_link_default") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then : ++ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. ++# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' ++# in a Makefile. We should not override ac_cv_exeext if it was cached, ++# so that the user can short-circuit this test for compilers unknown to ++# Autoconf. ++for ac_file in $ac_files '' ++do ++ test -f "$ac_file" || continue ++ case $ac_file in ++ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ++ ;; ++ [ab].out ) ++ # We found the default executable, but exeext='' is most ++ # certainly right. ++ break;; ++ *.* ) ++ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; ++ then :; else ++ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` ++ fi ++ # We set ac_cv_exeext here because the later test for it is not ++ # safe: cross compilers may not add the suffix if given an `-o' ++ # argument, so we may need to know it at that point already. ++ # Even if this section looks crufty: it has the advantage of ++ # actually working. ++ break;; ++ * ) ++ break;; ++ esac ++done ++test "$ac_cv_exeext" = no && ac_cv_exeext= ++ ++else ++ ac_file='' ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 ++$as_echo "$ac_file" >&6; } ++if test -z "$ac_file"; then : ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++{ as_fn_set_status 77 ++as_fn_error "C compiler cannot create executables ++See \`config.log' for more details." "$LINENO" 5; }; } ++fi ++ac_exeext=$ac_cv_exeext ++ ++# Check that the compiler produces executables we can run. If not, either ++# the compiler is broken, or we cross compile. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 ++$as_echo_n "checking whether the C compiler works... " >&6; } ++# If not cross compiling, check that we can run a simple program. ++if test "$cross_compiling" != yes; then ++ if { ac_try='./$ac_file' ++ { { case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_try") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; }; then ++ cross_compiling=no ++ else ++ if test "$cross_compiling" = maybe; then ++ cross_compiling=yes ++ else ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error "cannot run C compiled programs. ++If you meant to cross compile, use \`--host'. ++See \`config.log' for more details." "$LINENO" 5; } ++ fi ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ ++rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out ++ac_clean_files=$ac_clean_files_save ++# Check that the compiler produces executables we can run. If not, either ++# the compiler is broken, or we cross compile. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 ++$as_echo_n "checking whether we are cross compiling... " >&6; } ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 ++$as_echo "$cross_compiling" >&6; } ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 ++$as_echo_n "checking for suffix of executables... " >&6; } ++if { { ac_try="$ac_link" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_link") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then : ++ # If both `conftest.exe' and `conftest' are `present' (well, observable) ++# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will ++# work properly (i.e., refer to `conftest.exe'), while it won't with ++# `rm'. ++for ac_file in conftest.exe conftest conftest.*; do ++ test -f "$ac_file" || continue ++ case $ac_file in ++ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; ++ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` ++ break;; ++ * ) break;; ++ esac ++done ++else ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error "cannot compute suffix of executables: cannot compile and link ++See \`config.log' for more details." "$LINENO" 5; } ++fi ++rm -f conftest$ac_cv_exeext ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 ++$as_echo "$ac_cv_exeext" >&6; } ++ ++rm -f conftest.$ac_ext ++EXEEXT=$ac_cv_exeext ++ac_exeext=$EXEEXT ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 ++$as_echo_n "checking for suffix of object files... " >&6; } ++if test "${ac_cv_objext+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++rm -f conftest.o conftest.obj ++if { { ac_try="$ac_compile" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_compile") 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then : ++ for ac_file in conftest.o conftest.obj conftest.*; do ++ test -f "$ac_file" || continue; ++ case $ac_file in ++ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; ++ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` ++ break;; ++ esac ++done ++else ++ $as_echo "$as_me: failed program was:" >&5 ++sed 's/^/| /' conftest.$ac_ext >&5 ++ ++{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error "cannot compute suffix of object files: cannot compile ++See \`config.log' for more details." "$LINENO" 5; } ++fi ++rm -f conftest.$ac_cv_objext conftest.$ac_ext ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 ++$as_echo "$ac_cv_objext" >&6; } ++OBJEXT=$ac_cv_objext ++ac_objext=$OBJEXT ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 ++$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } ++if test "${ac_cv_c_compiler_gnu+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++#ifndef __GNUC__ ++ choke me ++#endif ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_compiler_gnu=yes ++else ++ ac_compiler_gnu=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ac_cv_c_compiler_gnu=$ac_compiler_gnu ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 ++$as_echo "$ac_cv_c_compiler_gnu" >&6; } ++if test $ac_compiler_gnu = yes; then ++ GCC=yes ++else ++ GCC= ++fi ++ac_test_CFLAGS=${CFLAGS+set} ++ac_save_CFLAGS=$CFLAGS ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 ++$as_echo_n "checking whether $CC accepts -g... " >&6; } ++if test "${ac_cv_prog_cc_g+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_save_c_werror_flag=$ac_c_werror_flag ++ ac_c_werror_flag=yes ++ ac_cv_prog_cc_g=no ++ CFLAGS="-g" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_g=yes ++else ++ CFLAGS="" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ++else ++ ac_c_werror_flag=$ac_save_c_werror_flag ++ CFLAGS="-g" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_g=yes ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ ac_c_werror_flag=$ac_save_c_werror_flag ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 ++$as_echo "$ac_cv_prog_cc_g" >&6; } ++if test "$ac_test_CFLAGS" = set; then ++ CFLAGS=$ac_save_CFLAGS ++elif test $ac_cv_prog_cc_g = yes; then ++ if test "$GCC" = yes; then ++ CFLAGS="-g -O2" ++ else ++ CFLAGS="-g" ++ fi ++else ++ if test "$GCC" = yes; then ++ CFLAGS="-O2" ++ else ++ CFLAGS= ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 ++$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } ++if test "${ac_cv_prog_cc_c89+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_cv_prog_cc_c89=no ++ac_save_CC=$CC ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++#include ++#include ++#include ++/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ ++struct buf { int x; }; ++FILE * (*rcsopen) (struct buf *, struct stat *, int); ++static char *e (p, i) ++ char **p; ++ int i; ++{ ++ return p[i]; ++} ++static char *f (char * (*g) (char **, int), char **p, ...) ++{ ++ char *s; ++ va_list v; ++ va_start (v,p); ++ s = g (p, va_arg (v,int)); ++ va_end (v); ++ return s; ++} ++ ++/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has ++ function prototypes and stuff, but not '\xHH' hex character constants. ++ These don't provoke an error unfortunately, instead are silently treated ++ as 'x'. The following induces an error, until -std is added to get ++ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an ++ array size at least. It's necessary to write '\x00'==0 to get something ++ that's true only with -std. */ ++int osf4_cc_array ['\x00' == 0 ? 1 : -1]; ++ ++/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters ++ inside strings and character constants. */ ++#define FOO(x) 'x' ++int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; ++ ++int test (int i, double x); ++struct s1 {int (*f) (int a);}; ++struct s2 {int (*f) (double a);}; ++int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); ++int argc; ++char **argv; ++int ++main () ++{ ++return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ++ ; ++ return 0; ++} ++_ACEOF ++for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ ++ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" ++do ++ CC="$ac_save_CC $ac_arg" ++ if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_c89=$ac_arg ++fi ++rm -f core conftest.err conftest.$ac_objext ++ test "x$ac_cv_prog_cc_c89" != "xno" && break ++done ++rm -f conftest.$ac_ext ++CC=$ac_save_CC ++ ++fi ++# AC_CACHE_VAL ++case "x$ac_cv_prog_cc_c89" in ++ x) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 ++$as_echo "none needed" >&6; } ;; ++ xno) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 ++$as_echo "unsupported" >&6; } ;; ++ *) ++ CC="$CC $ac_cv_prog_cc_c89" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 ++$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; ++esac ++if test "x$ac_cv_prog_cc_c89" != xno; then : ++ ++fi ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 ++$as_echo_n "checking how to run the C preprocessor... " >&6; } ++# On Suns, sometimes $CPP names a directory. ++if test -n "$CPP" && test -d "$CPP"; then ++ CPP= ++fi ++if test -z "$CPP"; then ++ if test "${ac_cv_prog_CPP+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ # Double quotes because CPP needs to be expanded ++ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" ++ do ++ ac_preproc_ok=false ++for ac_c_preproc_warn_flag in '' yes ++do ++ # Use a header file that comes with gcc, so configuring glibc ++ # with a fresh cross-compiler works. ++ # Prefer to if __STDC__ is defined, since ++ # exists even on freestanding compilers. ++ # On the NeXT, cc -E runs the code through the compiler's parser, ++ # not just through cpp. "Syntax error" is here to catch this case. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#ifdef __STDC__ ++# include ++#else ++# include ++#endif ++ Syntax error ++_ACEOF ++if ac_fn_c_try_cpp "$LINENO"; then : ++ ++else ++ # Broken: fails on valid input. ++continue ++fi ++rm -f conftest.err conftest.$ac_ext ++ ++ # OK, works on sane cases. Now check whether nonexistent headers ++ # can be detected and how. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++_ACEOF ++if ac_fn_c_try_cpp "$LINENO"; then : ++ # Broken: success on invalid input. ++continue ++else ++ # Passes both tests. ++ac_preproc_ok=: ++break ++fi ++rm -f conftest.err conftest.$ac_ext ++ ++done ++# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. ++rm -f conftest.err conftest.$ac_ext ++if $ac_preproc_ok; then : ++ break ++fi ++ ++ done ++ ac_cv_prog_CPP=$CPP ++ ++fi ++ CPP=$ac_cv_prog_CPP ++else ++ ac_cv_prog_CPP=$CPP ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 ++$as_echo "$CPP" >&6; } ++ac_preproc_ok=false ++for ac_c_preproc_warn_flag in '' yes ++do ++ # Use a header file that comes with gcc, so configuring glibc ++ # with a fresh cross-compiler works. ++ # Prefer to if __STDC__ is defined, since ++ # exists even on freestanding compilers. ++ # On the NeXT, cc -E runs the code through the compiler's parser, ++ # not just through cpp. "Syntax error" is here to catch this case. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#ifdef __STDC__ ++# include ++#else ++# include ++#endif ++ Syntax error ++_ACEOF ++if ac_fn_c_try_cpp "$LINENO"; then : ++ ++else ++ # Broken: fails on valid input. ++continue ++fi ++rm -f conftest.err conftest.$ac_ext ++ ++ # OK, works on sane cases. Now check whether nonexistent headers ++ # can be detected and how. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++_ACEOF ++if ac_fn_c_try_cpp "$LINENO"; then : ++ # Broken: success on invalid input. ++continue ++else ++ # Passes both tests. ++ac_preproc_ok=: ++break ++fi ++rm -f conftest.err conftest.$ac_ext ++ ++done ++# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. ++rm -f conftest.err conftest.$ac_ext ++if $ac_preproc_ok; then : ++ ++else ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error "C preprocessor \"$CPP\" fails sanity check ++See \`config.log' for more details." "$LINENO" 5; } ++fi ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 ++$as_echo_n "checking for grep that handles long lines and -e... " >&6; } ++if test "${ac_cv_path_GREP+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -z "$GREP"; then ++ ac_path_GREP_found=false ++ # Loop through the user's path and test for each of PROGNAME-LIST ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_prog in grep ggrep; do ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" ++ { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue ++# Check for GNU ac_path_GREP and select it if it is found. ++ # Check for GNU $ac_path_GREP ++case `"$ac_path_GREP" --version 2>&1` in ++*GNU*) ++ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; ++*) ++ ac_count=0 ++ $as_echo_n 0123456789 >"conftest.in" ++ while : ++ do ++ cat "conftest.in" "conftest.in" >"conftest.tmp" ++ mv "conftest.tmp" "conftest.in" ++ cp "conftest.in" "conftest.nl" ++ $as_echo 'GREP' >> "conftest.nl" ++ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break ++ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ++ as_fn_arith $ac_count + 1 && ac_count=$as_val ++ if test $ac_count -gt ${ac_path_GREP_max-0}; then ++ # Best one so far, save it but keep looking for a better one ++ ac_cv_path_GREP="$ac_path_GREP" ++ ac_path_GREP_max=$ac_count ++ fi ++ # 10*(2^10) chars as input seems more than enough ++ test $ac_count -gt 10 && break ++ done ++ rm -f conftest.in conftest.tmp conftest.nl conftest.out;; ++esac ++ ++ $ac_path_GREP_found && break 3 ++ done ++ done ++ done ++IFS=$as_save_IFS ++ if test -z "$ac_cv_path_GREP"; then ++ as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 ++ fi ++else ++ ac_cv_path_GREP=$GREP ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 ++$as_echo "$ac_cv_path_GREP" >&6; } ++ GREP="$ac_cv_path_GREP" ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 ++$as_echo_n "checking for egrep... " >&6; } ++if test "${ac_cv_path_EGREP+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 ++ then ac_cv_path_EGREP="$GREP -E" ++ else ++ if test -z "$EGREP"; then ++ ac_path_EGREP_found=false ++ # Loop through the user's path and test for each of PROGNAME-LIST ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_prog in egrep; do ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" ++ { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue ++# Check for GNU ac_path_EGREP and select it if it is found. ++ # Check for GNU $ac_path_EGREP ++case `"$ac_path_EGREP" --version 2>&1` in ++*GNU*) ++ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; ++*) ++ ac_count=0 ++ $as_echo_n 0123456789 >"conftest.in" ++ while : ++ do ++ cat "conftest.in" "conftest.in" >"conftest.tmp" ++ mv "conftest.tmp" "conftest.in" ++ cp "conftest.in" "conftest.nl" ++ $as_echo 'EGREP' >> "conftest.nl" ++ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break ++ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ++ as_fn_arith $ac_count + 1 && ac_count=$as_val ++ if test $ac_count -gt ${ac_path_EGREP_max-0}; then ++ # Best one so far, save it but keep looking for a better one ++ ac_cv_path_EGREP="$ac_path_EGREP" ++ ac_path_EGREP_max=$ac_count ++ fi ++ # 10*(2^10) chars as input seems more than enough ++ test $ac_count -gt 10 && break ++ done ++ rm -f conftest.in conftest.tmp conftest.nl conftest.out;; ++esac ++ ++ $ac_path_EGREP_found && break 3 ++ done ++ done ++ done ++IFS=$as_save_IFS ++ if test -z "$ac_cv_path_EGREP"; then ++ as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 ++ fi ++else ++ ac_cv_path_EGREP=$EGREP ++fi ++ ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 ++$as_echo "$ac_cv_path_EGREP" >&6; } ++ EGREP="$ac_cv_path_EGREP" ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 ++$as_echo_n "checking for ANSI C header files... " >&6; } ++if test "${ac_cv_header_stdc+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++#include ++#include ++#include ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_header_stdc=yes ++else ++ ac_cv_header_stdc=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ ++if test $ac_cv_header_stdc = yes; then ++ # SunOS 4.x string.h does not declare mem*, contrary to ANSI. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++ ++_ACEOF ++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | ++ $EGREP "memchr" >/dev/null 2>&1; then : ++ ++else ++ ac_cv_header_stdc=no ++fi ++rm -f conftest* ++ ++fi ++ ++if test $ac_cv_header_stdc = yes; then ++ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++ ++_ACEOF ++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | ++ $EGREP "free" >/dev/null 2>&1; then : ++ ++else ++ ac_cv_header_stdc=no ++fi ++rm -f conftest* ++ ++fi ++ ++if test $ac_cv_header_stdc = yes; then ++ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. ++ if test "$cross_compiling" = yes; then : ++ : ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++#include ++#if ((' ' & 0x0FF) == 0x020) ++# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') ++# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) ++#else ++# define ISLOWER(c) \ ++ (('a' <= (c) && (c) <= 'i') \ ++ || ('j' <= (c) && (c) <= 'r') \ ++ || ('s' <= (c) && (c) <= 'z')) ++# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) ++#endif ++ ++#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) ++int ++main () ++{ ++ int i; ++ for (i = 0; i < 256; i++) ++ if (XOR (islower (i), ISLOWER (i)) ++ || toupper (i) != TOUPPER (i)) ++ return 2; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_run "$LINENO"; then : ++ ++else ++ ac_cv_header_stdc=no ++fi ++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ ++ conftest.$ac_objext conftest.beam conftest.$ac_ext ++fi ++ ++fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 ++$as_echo "$ac_cv_header_stdc" >&6; } ++if test $ac_cv_header_stdc = yes; then ++ ++$as_echo "#define STDC_HEADERS 1" >>confdefs.h ++ ++fi ++ ++# On IRIX 5.3, sys/types and inttypes.h are conflicting. ++for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ ++ inttypes.h stdint.h unistd.h ++do : ++ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ++ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default ++" ++eval as_val=\$$as_ac_Header ++ if test "x$as_val" = x""yes; then : ++ cat >>confdefs.h <<_ACEOF ++#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 ++_ACEOF ++ ++fi ++ ++done ++ ++ ++ ++ ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" ++if test "x$ac_cv_header_minix_config_h" = x""yes; then : ++ MINIX=yes ++else ++ MINIX= ++fi ++ ++ ++ if test "$MINIX" = yes; then ++ ++$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h ++ ++ ++$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h ++ ++ ++$as_echo "#define _MINIX 1" >>confdefs.h ++ ++ fi ++ ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 ++$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } ++if test "${ac_cv_safe_to_define___extensions__+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++# define __EXTENSIONS__ 1 ++ $ac_includes_default ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_safe_to_define___extensions__=yes ++else ++ ac_cv_safe_to_define___extensions__=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 ++$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } ++ test $ac_cv_safe_to_define___extensions__ = yes && ++ $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h ++ ++ $as_echo "#define _ALL_SOURCE 1" >>confdefs.h ++ ++ $as_echo "#define _GNU_SOURCE 1" >>confdefs.h ++ ++ $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h ++ ++ $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h ++ ++ ++ ++libtool_VERSION=1:0:0 ++ ++ ++# 1.11.1: Require that version of automake. ++# foreign: Don't require README, INSTALL, NEWS, etc. ++# no-define: Don't define PACKAGE and VERSION. ++# no-dependencies: Don't generate automatic dependencies. ++# (because it breaks when using bootstrap-lean, since some of the ++# headers are gone at "make install" time). ++# -Wall: Issue all automake warnings. ++# -Wno-portability: Don't warn about constructs supported by GNU make. ++# (because GCC requires GNU make anyhow). ++am__api_version='1.11' ++ ++# Find a good install program. We prefer a C program (faster), ++# so one script is as good as another. But avoid the broken or ++# incompatible versions: ++# SysV /etc/install, /usr/sbin/install ++# SunOS /usr/etc/install ++# IRIX /sbin/install ++# AIX /bin/install ++# AmigaOS /C/install, which installs bootblocks on floppy discs ++# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag ++# AFS /usr/afsws/bin/install, which mishandles nonexistent args ++# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" ++# OS/2's system install, which has a completely different semantic ++# ./install, which can be erroneously created by make from ./install.sh. ++# Reject install programs that cannot install multiple files. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 ++$as_echo_n "checking for a BSD-compatible install... " >&6; } ++if test -z "$INSTALL"; then ++if test "${ac_cv_path_install+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ # Account for people who put trailing slashes in PATH elements. ++case $as_dir/ in #(( ++ ./ | .// | /[cC]/* | \ ++ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ++ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ ++ /usr/ucb/* ) ;; ++ *) ++ # OSF1 and SCO ODT 3.0 have their own names for install. ++ # Don't use installbsd from OSF since it installs stuff as root ++ # by default. ++ for ac_prog in ginstall scoinst install; do ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then ++ if test $ac_prog = install && ++ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then ++ # AIX install. It has an incompatible calling convention. ++ : ++ elif test $ac_prog = install && ++ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then ++ # program-specific install script used by HP pwplus--don't use. ++ : ++ else ++ rm -rf conftest.one conftest.two conftest.dir ++ echo one > conftest.one ++ echo two > conftest.two ++ mkdir conftest.dir ++ if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && ++ test -s conftest.one && test -s conftest.two && ++ test -s conftest.dir/conftest.one && ++ test -s conftest.dir/conftest.two ++ then ++ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" ++ break 3 ++ fi ++ fi ++ fi ++ done ++ done ++ ;; ++esac ++ ++ done ++IFS=$as_save_IFS ++ ++rm -rf conftest.one conftest.two conftest.dir ++ ++fi ++ if test "${ac_cv_path_install+set}" = set; then ++ INSTALL=$ac_cv_path_install ++ else ++ # As a last resort, use the slow shell script. Don't cache a ++ # value for INSTALL within a source directory, because that will ++ # break other packages using the cache if that directory is ++ # removed, or if the value is a relative name. ++ INSTALL=$ac_install_sh ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 ++$as_echo "$INSTALL" >&6; } ++ ++# Use test -z because SunOS4 sh mishandles braces in ${var-val}. ++# It thinks the first close brace ends the variable substitution. ++test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' ++ ++test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' ++ ++test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 ++$as_echo_n "checking whether build environment is sane... " >&6; } ++# Just in case ++sleep 1 ++echo timestamp > conftest.file ++# Reject unsafe characters in $srcdir or the absolute working directory ++# name. Accept space and tab only in the latter. ++am_lf=' ++' ++case `pwd` in ++ *[\\\"\#\$\&\'\`$am_lf]*) ++ as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; ++esac ++case $srcdir in ++ *[\\\"\#\$\&\'\`$am_lf\ \ ]*) ++ as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; ++esac ++ ++# Do `set' in a subshell so we don't clobber the current shell's ++# arguments. Must try -L first in case configure is actually a ++# symlink; some systems play weird games with the mod time of symlinks ++# (eg FreeBSD returns the mod time of the symlink's containing ++# directory). ++if ( ++ set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` ++ if test "$*" = "X"; then ++ # -L didn't work. ++ set X `ls -t "$srcdir/configure" conftest.file` ++ fi ++ rm -f conftest.file ++ if test "$*" != "X $srcdir/configure conftest.file" \ ++ && test "$*" != "X conftest.file $srcdir/configure"; then ++ ++ # If neither matched, then we have a broken ls. This can happen ++ # if, for instance, CONFIG_SHELL is bash and it inherits a ++ # broken ls alias from the environment. This has actually ++ # happened. Such a system could not be considered "sane". ++ as_fn_error "ls -t appears to fail. Make sure there is not a broken ++alias in your environment" "$LINENO" 5 ++ fi ++ ++ test "$2" = conftest.file ++ ) ++then ++ # Ok. ++ : ++else ++ as_fn_error "newly created file is older than distributed files! ++Check your system clock" "$LINENO" 5 ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++test "$program_prefix" != NONE && ++ program_transform_name="s&^&$program_prefix&;$program_transform_name" ++# Use a double $ so make ignores it. ++test "$program_suffix" != NONE && ++ program_transform_name="s&\$&$program_suffix&;$program_transform_name" ++# Double any \ or $. ++# By default was `s,x,x', remove it if useless. ++ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' ++program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` ++ ++# expand $ac_aux_dir to an absolute path ++am_aux_dir=`cd $ac_aux_dir && pwd` ++ ++if test x"${MISSING+set}" != xset; then ++ case $am_aux_dir in ++ *\ * | *\ *) ++ MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; ++ *) ++ MISSING="\${SHELL} $am_aux_dir/missing" ;; ++ esac ++fi ++# Use eval to expand $SHELL ++if eval "$MISSING --run true"; then ++ am_missing_run="$MISSING --run " ++else ++ am_missing_run= ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 ++$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} ++fi ++ ++if test x"${install_sh}" != xset; then ++ case $am_aux_dir in ++ *\ * | *\ *) ++ install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; ++ *) ++ install_sh="\${SHELL} $am_aux_dir/install-sh" ++ esac ++fi ++ ++# Installed binaries are usually stripped using `strip' when the user ++# run `make install-strip'. However `strip' might not be the right ++# tool to use in cross-compilation environments, therefore Automake ++# will honor the `STRIP' environment variable to overrule this program. ++if test "$cross_compiling" != no; then ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. ++set dummy ${ac_tool_prefix}strip; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_STRIP+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$STRIP"; then ++ ac_cv_prog_STRIP="$STRIP" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_STRIP="${ac_tool_prefix}strip" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++STRIP=$ac_cv_prog_STRIP ++if test -n "$STRIP"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 ++$as_echo "$STRIP" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_STRIP"; then ++ ac_ct_STRIP=$STRIP ++ # Extract the first word of "strip", so it can be a program name with args. ++set dummy strip; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_STRIP"; then ++ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_STRIP="strip" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP ++if test -n "$ac_ct_STRIP"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 ++$as_echo "$ac_ct_STRIP" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_STRIP" = x; then ++ STRIP=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ STRIP=$ac_ct_STRIP ++ fi ++else ++ STRIP="$ac_cv_prog_STRIP" ++fi ++ ++fi ++INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 ++$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } ++if test -z "$MKDIR_P"; then ++ if test "${ac_cv_path_mkdir+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_prog in mkdir gmkdir; do ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue ++ case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( ++ 'mkdir (GNU coreutils) '* | \ ++ 'mkdir (coreutils) '* | \ ++ 'mkdir (fileutils) '4.1*) ++ ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext ++ break 3;; ++ esac ++ done ++ done ++ done ++IFS=$as_save_IFS ++ ++fi ++ ++ if test "${ac_cv_path_mkdir+set}" = set; then ++ MKDIR_P="$ac_cv_path_mkdir -p" ++ else ++ # As a last resort, use the slow shell script. Don't cache a ++ # value for MKDIR_P within a source directory, because that will ++ # break other packages using the cache if that directory is ++ # removed, or if the value is a relative name. ++ test -d ./--version && rmdir ./--version ++ MKDIR_P="$ac_install_sh -d" ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 ++$as_echo "$MKDIR_P" >&6; } ++ ++mkdir_p="$MKDIR_P" ++case $mkdir_p in ++ [\\/$]* | ?:[\\/]*) ;; ++ */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; ++esac ++ ++for ac_prog in gawk mawk nawk awk ++do ++ # Extract the first word of "$ac_prog", so it can be a program name with args. ++set dummy $ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_AWK+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$AWK"; then ++ ac_cv_prog_AWK="$AWK" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_AWK="$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++AWK=$ac_cv_prog_AWK ++if test -n "$AWK"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 ++$as_echo "$AWK" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$AWK" && break ++done ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 ++$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } ++set x ${MAKE-make} ++ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` ++if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat >conftest.make <<\_ACEOF ++SHELL = /bin/sh ++all: ++ @echo '@@@%%%=$(MAKE)=@@@%%%' ++_ACEOF ++# GNU make sometimes prints "make[1]: Entering...", which would confuse us. ++case `${MAKE-make} -f conftest.make 2>/dev/null` in ++ *@@@%%%=?*=@@@%%%*) ++ eval ac_cv_prog_make_${ac_make}_set=yes;; ++ *) ++ eval ac_cv_prog_make_${ac_make}_set=no;; ++esac ++rm -f conftest.make ++fi ++if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ SET_MAKE= ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ SET_MAKE="MAKE=${MAKE-make}" ++fi ++ ++rm -rf .tst 2>/dev/null ++mkdir .tst 2>/dev/null ++if test -d .tst; then ++ am__leading_dot=. ++else ++ am__leading_dot=_ ++fi ++rmdir .tst 2>/dev/null ++ ++if test "`cd $srcdir && pwd`" != "`pwd`"; then ++ # Use -I$(srcdir) only when $(srcdir) != ., so that make's output ++ # is not polluted with repeated "-I." ++ am__isrc=' -I$(srcdir)' ++ # test to see if srcdir already configured ++ if test -f $srcdir/config.status; then ++ as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 ++ fi ++fi ++ ++# test whether we have cygpath ++if test -z "$CYGPATH_W"; then ++ if (cygpath --version) >/dev/null 2>/dev/null; then ++ CYGPATH_W='cygpath -w' ++ else ++ CYGPATH_W=echo ++ fi ++fi ++ ++ ++# Define the identity of the package. ++ PACKAGE='libbacktrace' ++ VERSION='version-unused' ++ ++ ++# Some tools Automake needs. ++ ++ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} ++ ++ ++AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} ++ ++ ++AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} ++ ++ ++AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} ++ ++ ++MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} ++ ++# We need awk for the "check" target. The system "awk" is bad on ++# some platforms. ++# Always define AMTAR for backward compatibility. Yes, it's still used ++# in the wild :-( We should find a proper way to deprecate it ... ++AMTAR='$${TAR-tar}' ++ ++am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' ++ ++ ++ ++ ++ ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 ++$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } ++ # Check whether --enable-maintainer-mode was given. ++if test "${enable_maintainer_mode+set}" = set; then : ++ enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval ++else ++ USE_MAINTAINER_MODE=no ++fi ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 ++$as_echo "$USE_MAINTAINER_MODE" >&6; } ++ if test $USE_MAINTAINER_MODE = yes; then ++ MAINTAINER_MODE_TRUE= ++ MAINTAINER_MODE_FALSE='#' ++else ++ MAINTAINER_MODE_TRUE='#' ++ MAINTAINER_MODE_FALSE= ++fi ++ ++ MAINT=$MAINTAINER_MODE_TRUE ++ ++ ++ ++ ++# Check whether --with-target-subdir was given. ++if test "${with_target_subdir+set}" = set; then : ++ withval=$with_target_subdir; ++fi ++ ++ ++# We must force CC to /not/ be precious variables; otherwise ++# the wrong, non-multilib-adjusted value will be used in multilibs. ++# As a side effect, we have to subst CFLAGS ourselves. ++ ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. ++set dummy ${ac_tool_prefix}gcc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_CC="${ac_tool_prefix}gcc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_CC"; then ++ ac_ct_CC=$CC ++ # Extract the first word of "gcc", so it can be a program name with args. ++set dummy gcc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_CC"; then ++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_CC="gcc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_CC=$ac_cv_prog_ac_ct_CC ++if test -n "$ac_ct_CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 ++$as_echo "$ac_ct_CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_CC" = x; then ++ CC="" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ CC=$ac_ct_CC ++ fi ++else ++ CC="$ac_cv_prog_CC" ++fi ++ ++if test -z "$CC"; then ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. ++set dummy ${ac_tool_prefix}cc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_CC="${ac_tool_prefix}cc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ fi ++fi ++if test -z "$CC"; then ++ # Extract the first word of "cc", so it can be a program name with args. ++set dummy cc; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++ ac_prog_rejected=no ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ++ ac_prog_rejected=yes ++ continue ++ fi ++ ac_cv_prog_CC="cc" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++if test $ac_prog_rejected = yes; then ++ # We found a bogon in the path, so make sure we never use it. ++ set dummy $ac_cv_prog_CC ++ shift ++ if test $# != 0; then ++ # We chose a different compiler from the bogus one. ++ # However, it has the same basename, so the bogon will be chosen ++ # first if we set CC to just the basename; use the full file name. ++ shift ++ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" ++ fi ++fi ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$CC"; then ++ if test -n "$ac_tool_prefix"; then ++ for ac_prog in cl.exe ++ do ++ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. ++set dummy $ac_tool_prefix$ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$CC"; then ++ ac_cv_prog_CC="$CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_CC="$ac_tool_prefix$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++CC=$ac_cv_prog_CC ++if test -n "$CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 ++$as_echo "$CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$CC" && break ++ done ++fi ++if test -z "$CC"; then ++ ac_ct_CC=$CC ++ for ac_prog in cl.exe ++do ++ # Extract the first word of "$ac_prog", so it can be a program name with args. ++set dummy $ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_CC"; then ++ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_CC="$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_CC=$ac_cv_prog_ac_ct_CC ++if test -n "$ac_ct_CC"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 ++$as_echo "$ac_ct_CC" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$ac_ct_CC" && break ++done ++ ++ if test "x$ac_ct_CC" = x; then ++ CC="" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ CC=$ac_ct_CC ++ fi ++fi ++ ++fi ++ ++ ++test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error "no acceptable C compiler found in \$PATH ++See \`config.log' for more details." "$LINENO" 5; } ++ ++# Provide some information about the compiler. ++$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 ++set X $ac_compile ++ac_compiler=$2 ++for ac_option in --version -v -V -qversion; do ++ { { ac_try="$ac_compiler $ac_option >&5" ++case "(($ac_try" in ++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; ++ *) ac_try_echo=$ac_try;; ++esac ++eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" ++$as_echo "$ac_try_echo"; } >&5 ++ (eval "$ac_compiler $ac_option >&5") 2>conftest.err ++ ac_status=$? ++ if test -s conftest.err; then ++ sed '10a\ ++... rest of stderr output deleted ... ++ 10q' conftest.err >conftest.er1 ++ cat conftest.er1 >&5 ++ rm -f conftest.er1 conftest.err ++ fi ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } ++done ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 ++$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } ++if test "${ac_cv_c_compiler_gnu+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++#ifndef __GNUC__ ++ choke me ++#endif ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_compiler_gnu=yes ++else ++ ac_compiler_gnu=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ac_cv_c_compiler_gnu=$ac_compiler_gnu ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 ++$as_echo "$ac_cv_c_compiler_gnu" >&6; } ++if test $ac_compiler_gnu = yes; then ++ GCC=yes ++else ++ GCC= ++fi ++ac_test_CFLAGS=${CFLAGS+set} ++ac_save_CFLAGS=$CFLAGS ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 ++$as_echo_n "checking whether $CC accepts -g... " >&6; } ++if test "${ac_cv_prog_cc_g+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_save_c_werror_flag=$ac_c_werror_flag ++ ac_c_werror_flag=yes ++ ac_cv_prog_cc_g=no ++ CFLAGS="-g" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_g=yes ++else ++ CFLAGS="" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ++else ++ ac_c_werror_flag=$ac_save_c_werror_flag ++ CFLAGS="-g" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_g=yes ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ ac_c_werror_flag=$ac_save_c_werror_flag ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 ++$as_echo "$ac_cv_prog_cc_g" >&6; } ++if test "$ac_test_CFLAGS" = set; then ++ CFLAGS=$ac_save_CFLAGS ++elif test $ac_cv_prog_cc_g = yes; then ++ if test "$GCC" = yes; then ++ CFLAGS="-g -O2" ++ else ++ CFLAGS="-g" ++ fi ++else ++ if test "$GCC" = yes; then ++ CFLAGS="-O2" ++ else ++ CFLAGS= ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 ++$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } ++if test "${ac_cv_prog_cc_c89+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_cv_prog_cc_c89=no ++ac_save_CC=$CC ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++#include ++#include ++#include ++/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ ++struct buf { int x; }; ++FILE * (*rcsopen) (struct buf *, struct stat *, int); ++static char *e (p, i) ++ char **p; ++ int i; ++{ ++ return p[i]; ++} ++static char *f (char * (*g) (char **, int), char **p, ...) ++{ ++ char *s; ++ va_list v; ++ va_start (v,p); ++ s = g (p, va_arg (v,int)); ++ va_end (v); ++ return s; ++} ++ ++/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has ++ function prototypes and stuff, but not '\xHH' hex character constants. ++ These don't provoke an error unfortunately, instead are silently treated ++ as 'x'. The following induces an error, until -std is added to get ++ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an ++ array size at least. It's necessary to write '\x00'==0 to get something ++ that's true only with -std. */ ++int osf4_cc_array ['\x00' == 0 ? 1 : -1]; ++ ++/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters ++ inside strings and character constants. */ ++#define FOO(x) 'x' ++int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; ++ ++int test (int i, double x); ++struct s1 {int (*f) (int a);}; ++struct s2 {int (*f) (double a);}; ++int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); ++int argc; ++char **argv; ++int ++main () ++{ ++return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ++ ; ++ return 0; ++} ++_ACEOF ++for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ ++ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" ++do ++ CC="$ac_save_CC $ac_arg" ++ if ac_fn_c_try_compile "$LINENO"; then : ++ ac_cv_prog_cc_c89=$ac_arg ++fi ++rm -f core conftest.err conftest.$ac_objext ++ test "x$ac_cv_prog_cc_c89" != "xno" && break ++done ++rm -f conftest.$ac_ext ++CC=$ac_save_CC ++ ++fi ++# AC_CACHE_VAL ++case "x$ac_cv_prog_cc_c89" in ++ x) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 ++$as_echo "none needed" >&6; } ;; ++ xno) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 ++$as_echo "unsupported" >&6; } ;; ++ *) ++ CC="$CC $ac_cv_prog_cc_c89" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 ++$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; ++esac ++if test "x$ac_cv_prog_cc_c89" != xno; then : ++ ++fi ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++ ++ ++ ++ ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. ++set dummy ${ac_tool_prefix}ranlib; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_RANLIB+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$RANLIB"; then ++ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++RANLIB=$ac_cv_prog_RANLIB ++if test -n "$RANLIB"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 ++$as_echo "$RANLIB" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_RANLIB"; then ++ ac_ct_RANLIB=$RANLIB ++ # Extract the first word of "ranlib", so it can be a program name with args. ++set dummy ranlib; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_RANLIB"; then ++ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_RANLIB="ranlib" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB ++if test -n "$ac_ct_RANLIB"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 ++$as_echo "$ac_ct_RANLIB" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_RANLIB" = x; then ++ RANLIB=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ RANLIB=$ac_ct_RANLIB ++ fi ++else ++ RANLIB="$ac_cv_prog_RANLIB" ++fi ++ ++ ++for ac_prog in gawk mawk nawk awk ++do ++ # Extract the first word of "$ac_prog", so it can be a program name with args. ++set dummy $ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_AWK+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$AWK"; then ++ ac_cv_prog_AWK="$AWK" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_AWK="$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++AWK=$ac_cv_prog_AWK ++if test -n "$AWK"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 ++$as_echo "$AWK" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$AWK" && break ++done ++ ++case "$AWK" in ++"") as_fn_error "can't build without awk" "$LINENO" 5 ;; ++esac ++ ++case `pwd` in ++ *\ * | *\ *) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 ++$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; ++esac ++ ++ ++ ++macro_version='2.2.7a' ++macro_revision='1.3134' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ltmain="$ac_aux_dir/ltmain.sh" ++ ++# Backslashify metacharacters that are still active within ++# double-quoted strings. ++sed_quote_subst='s/\(["`$\\]\)/\\\1/g' ++ ++# Same as above, but do not quote variable references. ++double_quote_subst='s/\(["`\\]\)/\\\1/g' ++ ++# Sed substitution to delay expansion of an escaped shell variable in a ++# double_quote_subst'ed string. ++delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' ++ ++# Sed substitution to delay expansion of an escaped single quote. ++delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' ++ ++# Sed substitution to avoid accidental globbing in evaled expressions ++no_glob_subst='s/\*/\\\*/g' ++ ++ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ++ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ++ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 ++$as_echo_n "checking how to print strings... " >&6; } ++# Test print first, because it will be a builtin if present. ++if test "X`print -r -- -n 2>/dev/null`" = X-n && \ ++ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ++ ECHO='print -r --' ++elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ++ ECHO='printf %s\n' ++else ++ # Use this function as a fallback that always works. ++ func_fallback_echo () ++ { ++ eval 'cat <<_LTECHO_EOF ++$1 ++_LTECHO_EOF' ++ } ++ ECHO='func_fallback_echo' ++fi ++ ++# func_echo_all arg... ++# Invoke $ECHO with all args, space-separated. ++func_echo_all () ++{ ++ $ECHO "" ++} ++ ++case "$ECHO" in ++ printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 ++$as_echo "printf" >&6; } ;; ++ print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 ++$as_echo "print -r" >&6; } ;; ++ *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 ++$as_echo "cat" >&6; } ;; ++esac ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 ++$as_echo_n "checking for a sed that does not truncate output... " >&6; } ++if test "${ac_cv_path_SED+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ ++ for ac_i in 1 2 3 4 5 6 7; do ++ ac_script="$ac_script$as_nl$ac_script" ++ done ++ echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed ++ { ac_script=; unset ac_script;} ++ if test -z "$SED"; then ++ ac_path_SED_found=false ++ # Loop through the user's path and test for each of PROGNAME-LIST ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_prog in sed gsed; do ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" ++ { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue ++# Check for GNU ac_path_SED and select it if it is found. ++ # Check for GNU $ac_path_SED ++case `"$ac_path_SED" --version 2>&1` in ++*GNU*) ++ ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; ++*) ++ ac_count=0 ++ $as_echo_n 0123456789 >"conftest.in" ++ while : ++ do ++ cat "conftest.in" "conftest.in" >"conftest.tmp" ++ mv "conftest.tmp" "conftest.in" ++ cp "conftest.in" "conftest.nl" ++ $as_echo '' >> "conftest.nl" ++ "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break ++ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ++ as_fn_arith $ac_count + 1 && ac_count=$as_val ++ if test $ac_count -gt ${ac_path_SED_max-0}; then ++ # Best one so far, save it but keep looking for a better one ++ ac_cv_path_SED="$ac_path_SED" ++ ac_path_SED_max=$ac_count ++ fi ++ # 10*(2^10) chars as input seems more than enough ++ test $ac_count -gt 10 && break ++ done ++ rm -f conftest.in conftest.tmp conftest.nl conftest.out;; ++esac ++ ++ $ac_path_SED_found && break 3 ++ done ++ done ++ done ++IFS=$as_save_IFS ++ if test -z "$ac_cv_path_SED"; then ++ as_fn_error "no acceptable sed could be found in \$PATH" "$LINENO" 5 ++ fi ++else ++ ac_cv_path_SED=$SED ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 ++$as_echo "$ac_cv_path_SED" >&6; } ++ SED="$ac_cv_path_SED" ++ rm -f conftest.sed ++ ++test -z "$SED" && SED=sed ++Xsed="$SED -e 1s/^X//" ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 ++$as_echo_n "checking for fgrep... " >&6; } ++if test "${ac_cv_path_FGREP+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 ++ then ac_cv_path_FGREP="$GREP -F" ++ else ++ if test -z "$FGREP"; then ++ ac_path_FGREP_found=false ++ # Loop through the user's path and test for each of PROGNAME-LIST ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_prog in fgrep; do ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" ++ { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue ++# Check for GNU ac_path_FGREP and select it if it is found. ++ # Check for GNU $ac_path_FGREP ++case `"$ac_path_FGREP" --version 2>&1` in ++*GNU*) ++ ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; ++*) ++ ac_count=0 ++ $as_echo_n 0123456789 >"conftest.in" ++ while : ++ do ++ cat "conftest.in" "conftest.in" >"conftest.tmp" ++ mv "conftest.tmp" "conftest.in" ++ cp "conftest.in" "conftest.nl" ++ $as_echo 'FGREP' >> "conftest.nl" ++ "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break ++ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ++ as_fn_arith $ac_count + 1 && ac_count=$as_val ++ if test $ac_count -gt ${ac_path_FGREP_max-0}; then ++ # Best one so far, save it but keep looking for a better one ++ ac_cv_path_FGREP="$ac_path_FGREP" ++ ac_path_FGREP_max=$ac_count ++ fi ++ # 10*(2^10) chars as input seems more than enough ++ test $ac_count -gt 10 && break ++ done ++ rm -f conftest.in conftest.tmp conftest.nl conftest.out;; ++esac ++ ++ $ac_path_FGREP_found && break 3 ++ done ++ done ++ done ++IFS=$as_save_IFS ++ if test -z "$ac_cv_path_FGREP"; then ++ as_fn_error "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 ++ fi ++else ++ ac_cv_path_FGREP=$FGREP ++fi ++ ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 ++$as_echo "$ac_cv_path_FGREP" >&6; } ++ FGREP="$ac_cv_path_FGREP" ++ ++ ++test -z "$GREP" && GREP=grep ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++# Check whether --with-gnu-ld was given. ++if test "${with_gnu_ld+set}" = set; then : ++ withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes ++else ++ with_gnu_ld=no ++fi ++ ++ac_prog=ld ++if test "$GCC" = yes; then ++ # Check if gcc -print-prog-name=ld gives a path. ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 ++$as_echo_n "checking for ld used by $CC... " >&6; } ++ case $host in ++ *-*-mingw*) ++ # gcc leaves a trailing carriage return which upsets mingw ++ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; ++ *) ++ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; ++ esac ++ case $ac_prog in ++ # Accept absolute paths. ++ [\\/]* | ?:[\\/]*) ++ re_direlt='/[^/][^/]*/\.\./' ++ # Canonicalize the pathname of ld ++ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` ++ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ++ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` ++ done ++ test -z "$LD" && LD="$ac_prog" ++ ;; ++ "") ++ # If it fails, then pretend we aren't using GCC. ++ ac_prog=ld ++ ;; ++ *) ++ # If it is relative, then search for the first ld in PATH. ++ with_gnu_ld=unknown ++ ;; ++ esac ++elif test "$with_gnu_ld" = yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 ++$as_echo_n "checking for GNU ld... " >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 ++$as_echo_n "checking for non-GNU ld... " >&6; } ++fi ++if test "${lt_cv_path_LD+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -z "$LD"; then ++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ++ for ac_dir in $PATH; do ++ IFS="$lt_save_ifs" ++ test -z "$ac_dir" && ac_dir=. ++ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then ++ lt_cv_path_LD="$ac_dir/$ac_prog" ++ # Check to see if the program is GNU ld. I'd rather use --version, ++ # but apparently some variants of GNU ld only accept -v. ++ # Break only if it was the GNU/non-GNU ld that we prefer. ++ case `"$lt_cv_path_LD" -v 2>&1 &5 ++$as_echo "$LD" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 ++$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } ++if test "${lt_cv_prog_gnu_ld+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ # I'd rather use --version here, but apparently some GNU lds only accept -v. ++case `$LD -v 2>&1 &5 ++$as_echo "$lt_cv_prog_gnu_ld" >&6; } ++with_gnu_ld=$lt_cv_prog_gnu_ld ++ ++ ++ ++ ++ ++ ++ ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 ++$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } ++if test "${lt_cv_path_NM+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$NM"; then ++ # Let the user override the test. ++ lt_cv_path_NM="$NM" ++else ++ lt_nm_to_check="${ac_tool_prefix}nm" ++ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then ++ lt_nm_to_check="$lt_nm_to_check nm" ++ fi ++ for lt_tmp_nm in $lt_nm_to_check; do ++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ++ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do ++ IFS="$lt_save_ifs" ++ test -z "$ac_dir" && ac_dir=. ++ tmp_nm="$ac_dir/$lt_tmp_nm" ++ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then ++ # Check to see if the nm accepts a BSD-compat flag. ++ # Adding the `sed 1q' prevents false positives on HP-UX, which says: ++ # nm: unknown option "B" ignored ++ # Tru64's nm complains that /dev/null is an invalid object file ++ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in ++ */dev/null* | *'Invalid file or object type'*) ++ lt_cv_path_NM="$tmp_nm -B" ++ break ++ ;; ++ *) ++ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in ++ */dev/null*) ++ lt_cv_path_NM="$tmp_nm -p" ++ break ++ ;; ++ *) ++ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but ++ continue # so that we can try to find one that supports BSD flags ++ ;; ++ esac ++ ;; ++ esac ++ fi ++ done ++ IFS="$lt_save_ifs" ++ done ++ : ${lt_cv_path_NM=no} ++fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 ++$as_echo "$lt_cv_path_NM" >&6; } ++if test "$lt_cv_path_NM" != "no"; then ++ NM="$lt_cv_path_NM" ++else ++ # Didn't find any BSD compatible name lister, look for dumpbin. ++ if test -n "$DUMPBIN"; then : ++ # Let the user override the test. ++ else ++ if test -n "$ac_tool_prefix"; then ++ for ac_prog in dumpbin "link -dump" ++ do ++ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. ++set dummy $ac_tool_prefix$ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_DUMPBIN+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$DUMPBIN"; then ++ ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++DUMPBIN=$ac_cv_prog_DUMPBIN ++if test -n "$DUMPBIN"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 ++$as_echo "$DUMPBIN" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$DUMPBIN" && break ++ done ++fi ++if test -z "$DUMPBIN"; then ++ ac_ct_DUMPBIN=$DUMPBIN ++ for ac_prog in dumpbin "link -dump" ++do ++ # Extract the first word of "$ac_prog", so it can be a program name with args. ++set dummy $ac_prog; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_DUMPBIN"; then ++ ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN ++if test -n "$ac_ct_DUMPBIN"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 ++$as_echo "$ac_ct_DUMPBIN" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ test -n "$ac_ct_DUMPBIN" && break ++done ++ ++ if test "x$ac_ct_DUMPBIN" = x; then ++ DUMPBIN=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ DUMPBIN=$ac_ct_DUMPBIN ++ fi ++fi ++ ++ case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in ++ *COFF*) ++ DUMPBIN="$DUMPBIN -symbols" ++ ;; ++ *) ++ DUMPBIN=: ++ ;; ++ esac ++ fi ++ ++ if test "$DUMPBIN" != ":"; then ++ NM="$DUMPBIN" ++ fi ++fi ++test -z "$NM" && NM=nm ++ ++ ++ ++ ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 ++$as_echo_n "checking the name lister ($NM) interface... " >&6; } ++if test "${lt_cv_nm_interface+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_nm_interface="BSD nm" ++ echo "int some_variable = 0;" > conftest.$ac_ext ++ (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) ++ (eval "$ac_compile" 2>conftest.err) ++ cat conftest.err >&5 ++ (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) ++ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) ++ cat conftest.err >&5 ++ (eval echo "\"\$as_me:$LINENO: output\"" >&5) ++ cat conftest.out >&5 ++ if $GREP 'External.*some_variable' conftest.out > /dev/null; then ++ lt_cv_nm_interface="MS dumpbin" ++ fi ++ rm -f conftest* ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 ++$as_echo "$lt_cv_nm_interface" >&6; } ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 ++$as_echo_n "checking whether ln -s works... " >&6; } ++LN_S=$as_ln_s ++if test "$LN_S" = "ln -s"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 ++$as_echo "no, using $LN_S" >&6; } ++fi ++ ++# find the maximum length of command line arguments ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 ++$as_echo_n "checking the maximum length of command line arguments... " >&6; } ++if test "${lt_cv_sys_max_cmd_len+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ i=0 ++ teststring="ABCD" ++ ++ case $build_os in ++ msdosdjgpp*) ++ # On DJGPP, this test can blow up pretty badly due to problems in libc ++ # (any single argument exceeding 2000 bytes causes a buffer overrun ++ # during glob expansion). Even if it were fixed, the result of this ++ # check would be larger than it should be. ++ lt_cv_sys_max_cmd_len=12288; # 12K is about right ++ ;; ++ ++ gnu*) ++ # Under GNU Hurd, this test is not required because there is ++ # no limit to the length of command line arguments. ++ # Libtool will interpret -1 as no limit whatsoever ++ lt_cv_sys_max_cmd_len=-1; ++ ;; ++ ++ cygwin* | mingw* | cegcc*) ++ # On Win9x/ME, this test blows up -- it succeeds, but takes ++ # about 5 minutes as the teststring grows exponentially. ++ # Worse, since 9x/ME are not pre-emptively multitasking, ++ # you end up with a "frozen" computer, even though with patience ++ # the test eventually succeeds (with a max line length of 256k). ++ # Instead, let's just punt: use the minimum linelength reported by ++ # all of the supported platforms: 8192 (on NT/2K/XP). ++ lt_cv_sys_max_cmd_len=8192; ++ ;; ++ ++ mint*) ++ # On MiNT this can take a long time and run out of memory. ++ lt_cv_sys_max_cmd_len=8192; ++ ;; ++ ++ amigaos*) ++ # On AmigaOS with pdksh, this test takes hours, literally. ++ # So we just punt and use a minimum line length of 8192. ++ lt_cv_sys_max_cmd_len=8192; ++ ;; ++ ++ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) ++ # This has been around since 386BSD, at least. Likely further. ++ if test -x /sbin/sysctl; then ++ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` ++ elif test -x /usr/sbin/sysctl; then ++ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` ++ else ++ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs ++ fi ++ # And add a safety zone ++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` ++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ++ ;; ++ ++ interix*) ++ # We know the value 262144 and hardcode it with a safety zone (like BSD) ++ lt_cv_sys_max_cmd_len=196608 ++ ;; ++ ++ osf*) ++ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure ++ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not ++ # nice to cause kernel panics so lets avoid the loop below. ++ # First set a reasonable default. ++ lt_cv_sys_max_cmd_len=16384 ++ # ++ if test -x /sbin/sysconfig; then ++ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in ++ *1*) lt_cv_sys_max_cmd_len=-1 ;; ++ esac ++ fi ++ ;; ++ sco3.2v5*) ++ lt_cv_sys_max_cmd_len=102400 ++ ;; ++ sysv5* | sco5v6* | sysv4.2uw2*) ++ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` ++ if test -n "$kargmax"; then ++ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` ++ else ++ lt_cv_sys_max_cmd_len=32768 ++ fi ++ ;; ++ *) ++ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` ++ if test -n "$lt_cv_sys_max_cmd_len"; then ++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` ++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ++ else ++ # Make teststring a little bigger before we do anything with it. ++ # a 1K string should be a reasonable start. ++ for i in 1 2 3 4 5 6 7 8 ; do ++ teststring=$teststring$teststring ++ done ++ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} ++ # If test is not a shell built-in, we'll probably end up computing a ++ # maximum length that is only half of the actual maximum length, but ++ # we can't tell. ++ while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ ++ = "X$teststring$teststring"; } >/dev/null 2>&1 && ++ test $i != 17 # 1/2 MB should be enough ++ do ++ i=`expr $i + 1` ++ teststring=$teststring$teststring ++ done ++ # Only check the string length outside the loop. ++ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` ++ teststring= ++ # Add a significant safety factor because C++ compilers can tack on ++ # massive amounts of additional arguments before passing them to the ++ # linker. It appears as though 1/2 is a usable value. ++ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` ++ fi ++ ;; ++ esac ++ ++fi ++ ++if test -n $lt_cv_sys_max_cmd_len ; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 ++$as_echo "$lt_cv_sys_max_cmd_len" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 ++$as_echo "none" >&6; } ++fi ++max_cmd_len=$lt_cv_sys_max_cmd_len ++ ++ ++ ++ ++ ++ ++: ${CP="cp -f"} ++: ${MV="mv -f"} ++: ${RM="rm -f"} ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 ++$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } ++# Try some XSI features ++xsi_shell=no ++( _lt_dummy="a/b/c" ++ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ ++ = c,a/b,, \ ++ && eval 'test $(( 1 + 1 )) -eq 2 \ ++ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ ++ && xsi_shell=yes ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 ++$as_echo "$xsi_shell" >&6; } ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 ++$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } ++lt_shell_append=no ++( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ ++ >/dev/null 2>&1 \ ++ && lt_shell_append=yes ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 ++$as_echo "$lt_shell_append" >&6; } ++ ++ ++if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then ++ lt_unset=unset ++else ++ lt_unset=false ++fi ++ ++ ++ ++ ++ ++# test EBCDIC or ASCII ++case `echo X|tr X '\101'` in ++ A) # ASCII based system ++ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr ++ lt_SP2NL='tr \040 \012' ++ lt_NL2SP='tr \015\012 \040\040' ++ ;; ++ *) # EBCDIC based system ++ lt_SP2NL='tr \100 \n' ++ lt_NL2SP='tr \r\n \100\100' ++ ;; ++esac ++ ++ ++ ++ ++ ++ ++ ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 ++$as_echo_n "checking for $LD option to reload object files... " >&6; } ++if test "${lt_cv_ld_reload_flag+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_ld_reload_flag='-r' ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 ++$as_echo "$lt_cv_ld_reload_flag" >&6; } ++reload_flag=$lt_cv_ld_reload_flag ++case $reload_flag in ++"" | " "*) ;; ++*) reload_flag=" $reload_flag" ;; ++esac ++reload_cmds='$LD$reload_flag -o $output$reload_objs' ++case $host_os in ++ darwin*) ++ if test "$GCC" = yes; then ++ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' ++ else ++ reload_cmds='$LD$reload_flag -o $output$reload_objs' ++ fi ++ ;; ++esac ++ ++ ++ ++ ++ ++ ++ ++ ++ ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. ++set dummy ${ac_tool_prefix}objdump; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_OBJDUMP+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$OBJDUMP"; then ++ ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++OBJDUMP=$ac_cv_prog_OBJDUMP ++if test -n "$OBJDUMP"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 ++$as_echo "$OBJDUMP" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_OBJDUMP"; then ++ ac_ct_OBJDUMP=$OBJDUMP ++ # Extract the first word of "objdump", so it can be a program name with args. ++set dummy objdump; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_OBJDUMP"; then ++ ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_OBJDUMP="objdump" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP ++if test -n "$ac_ct_OBJDUMP"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 ++$as_echo "$ac_ct_OBJDUMP" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_OBJDUMP" = x; then ++ OBJDUMP="false" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ OBJDUMP=$ac_ct_OBJDUMP ++ fi ++else ++ OBJDUMP="$ac_cv_prog_OBJDUMP" ++fi ++ ++test -z "$OBJDUMP" && OBJDUMP=objdump ++ ++ ++ ++ ++ ++ ++ ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 ++$as_echo_n "checking how to recognize dependent libraries... " >&6; } ++if test "${lt_cv_deplibs_check_method+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_file_magic_cmd='$MAGIC_CMD' ++lt_cv_file_magic_test_file= ++lt_cv_deplibs_check_method='unknown' ++# Need to set the preceding variable on all platforms that support ++# interlibrary dependencies. ++# 'none' -- dependencies not supported. ++# `unknown' -- same as none, but documents that we really don't know. ++# 'pass_all' -- all dependencies passed with no checks. ++# 'test_compile' -- check by making test program. ++# 'file_magic [[regex]]' -- check by looking for files in library path ++# which responds to the $file_magic_cmd with a given extended regex. ++# If you have `file' or equivalent on your system and you're not sure ++# whether `pass_all' will *always* work, you probably want this one. ++ ++case $host_os in ++aix[4-9]*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++beos*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++bsdi[45]*) ++ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' ++ lt_cv_file_magic_cmd='/usr/bin/file -L' ++ lt_cv_file_magic_test_file=/shlib/libc.so ++ ;; ++ ++cygwin*) ++ # func_win32_libid is a shell function defined in ltmain.sh ++ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' ++ lt_cv_file_magic_cmd='func_win32_libid' ++ ;; ++ ++mingw* | pw32*) ++ # Base MSYS/MinGW do not provide the 'file' command needed by ++ # func_win32_libid shell function, so use a weaker test based on 'objdump', ++ # unless we find 'file', for example because we are cross-compiling. ++ # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. ++ if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then ++ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' ++ lt_cv_file_magic_cmd='func_win32_libid' ++ else ++ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' ++ lt_cv_file_magic_cmd='$OBJDUMP -f' ++ fi ++ ;; ++ ++cegcc*) ++ # use the weaker test based on 'objdump'. See mingw*. ++ lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' ++ lt_cv_file_magic_cmd='$OBJDUMP -f' ++ ;; ++ ++darwin* | rhapsody*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++freebsd* | dragonfly*) ++ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then ++ case $host_cpu in ++ i*86 ) ++ # Not sure whether the presence of OpenBSD here was a mistake. ++ # Let's accept both of them until this is cleared up. ++ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' ++ lt_cv_file_magic_cmd=/usr/bin/file ++ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ++ ;; ++ esac ++ else ++ lt_cv_deplibs_check_method=pass_all ++ fi ++ ;; ++ ++gnu*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++haiku*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++hpux10.20* | hpux11*) ++ lt_cv_file_magic_cmd=/usr/bin/file ++ case $host_cpu in ++ ia64*) ++ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' ++ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ++ ;; ++ hppa*64*) ++ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' ++ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ++ ;; ++ *) ++ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' ++ lt_cv_file_magic_test_file=/usr/lib/libc.sl ++ ;; ++ esac ++ ;; ++ ++interix[3-9]*) ++ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here ++ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ++ ;; ++ ++irix5* | irix6* | nonstopux*) ++ case $LD in ++ *-32|*"-32 ") libmagic=32-bit;; ++ *-n32|*"-n32 ") libmagic=N32;; ++ *-64|*"-64 ") libmagic=64-bit;; ++ *) libmagic=never-match;; ++ esac ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++# This must be Linux ELF. ++linux* | k*bsd*-gnu | kopensolaris*-gnu) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++netbsd*) ++ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then ++ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' ++ else ++ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' ++ fi ++ ;; ++ ++newos6*) ++ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' ++ lt_cv_file_magic_cmd=/usr/bin/file ++ lt_cv_file_magic_test_file=/usr/lib/libnls.so ++ ;; ++ ++*nto* | *qnx*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++openbsd*) ++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then ++ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' ++ else ++ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' ++ fi ++ ;; ++ ++osf3* | osf4* | osf5*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++rdos*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++solaris*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ ++sysv4 | sysv4.3*) ++ case $host_vendor in ++ motorola) ++ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' ++ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ++ ;; ++ ncr) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ sequent) ++ lt_cv_file_magic_cmd='/bin/file' ++ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ++ ;; ++ sni) ++ lt_cv_file_magic_cmd='/bin/file' ++ lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" ++ lt_cv_file_magic_test_file=/lib/libc.so ++ ;; ++ siemens) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ pc) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ esac ++ ;; ++ ++tpf*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++esac ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 ++$as_echo "$lt_cv_deplibs_check_method" >&6; } ++file_magic_cmd=$lt_cv_file_magic_cmd ++deplibs_check_method=$lt_cv_deplibs_check_method ++test -z "$deplibs_check_method" && deplibs_check_method=unknown ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. ++set dummy ${ac_tool_prefix}ar; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_AR+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$AR"; then ++ ac_cv_prog_AR="$AR" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_AR="${ac_tool_prefix}ar" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++AR=$ac_cv_prog_AR ++if test -n "$AR"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 ++$as_echo "$AR" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_AR"; then ++ ac_ct_AR=$AR ++ # Extract the first word of "ar", so it can be a program name with args. ++set dummy ar; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_AR"; then ++ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_AR="ar" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_AR=$ac_cv_prog_ac_ct_AR ++if test -n "$ac_ct_AR"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 ++$as_echo "$ac_ct_AR" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_AR" = x; then ++ AR="false" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ AR=$ac_ct_AR ++ fi ++else ++ AR="$ac_cv_prog_AR" ++fi ++ ++test -z "$AR" && AR=ar ++test -z "$AR_FLAGS" && AR_FLAGS=cru ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. ++set dummy ${ac_tool_prefix}strip; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_STRIP+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$STRIP"; then ++ ac_cv_prog_STRIP="$STRIP" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_STRIP="${ac_tool_prefix}strip" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++STRIP=$ac_cv_prog_STRIP ++if test -n "$STRIP"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 ++$as_echo "$STRIP" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_STRIP"; then ++ ac_ct_STRIP=$STRIP ++ # Extract the first word of "strip", so it can be a program name with args. ++set dummy strip; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_STRIP"; then ++ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_STRIP="strip" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP ++if test -n "$ac_ct_STRIP"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 ++$as_echo "$ac_ct_STRIP" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_STRIP" = x; then ++ STRIP=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ STRIP=$ac_ct_STRIP ++ fi ++else ++ STRIP="$ac_cv_prog_STRIP" ++fi ++ ++test -z "$STRIP" && STRIP=: ++ ++ ++ ++ ++ ++ ++if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. ++set dummy ${ac_tool_prefix}ranlib; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_RANLIB+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$RANLIB"; then ++ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++RANLIB=$ac_cv_prog_RANLIB ++if test -n "$RANLIB"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 ++$as_echo "$RANLIB" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_RANLIB"; then ++ ac_ct_RANLIB=$RANLIB ++ # Extract the first word of "ranlib", so it can be a program name with args. ++set dummy ranlib; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_RANLIB"; then ++ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_RANLIB="ranlib" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB ++if test -n "$ac_ct_RANLIB"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 ++$as_echo "$ac_ct_RANLIB" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_RANLIB" = x; then ++ RANLIB=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ RANLIB=$ac_ct_RANLIB ++ fi ++else ++ RANLIB="$ac_cv_prog_RANLIB" ++fi ++ ++test -z "$RANLIB" && RANLIB=: ++ ++ ++ ++ ++ ++ ++# Determine commands to create old-style static archives. ++old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' ++old_postinstall_cmds='chmod 644 $oldlib' ++old_postuninstall_cmds= ++ ++if test -n "$RANLIB"; then ++ case $host_os in ++ openbsd*) ++ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ++ ;; ++ *) ++ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ++ ;; ++ esac ++ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" ++fi ++ ++case $host_os in ++ darwin*) ++ lock_old_archive_extraction=yes ;; ++ *) ++ lock_old_archive_extraction=no ;; ++esac ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++# If no C compiler was specified, use CC. ++LTCC=${LTCC-"$CC"} ++ ++# If no C compiler flags were specified, use CFLAGS. ++LTCFLAGS=${LTCFLAGS-"$CFLAGS"} ++ ++# Allow CC to be a program name with arguments. ++compiler=$CC ++ ++ ++# Check for command to grab the raw symbol name followed by C symbol from nm. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 ++$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } ++if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ++# These are sane defaults that work on at least a few old systems. ++# [They come from Ultrix. What could be older than Ultrix?!! ;)] ++ ++# Character class describing NM global symbol codes. ++symcode='[BCDEGRST]' ++ ++# Regexp to match symbols that can be accessed directly from C. ++sympat='\([_A-Za-z][_A-Za-z0-9]*\)' ++ ++# Define system-specific variables. ++case $host_os in ++aix*) ++ symcode='[BCDT]' ++ ;; ++cygwin* | mingw* | pw32* | cegcc*) ++ symcode='[ABCDGISTW]' ++ ;; ++hpux*) ++ if test "$host_cpu" = ia64; then ++ symcode='[ABCDEGRST]' ++ fi ++ ;; ++irix* | nonstopux*) ++ symcode='[BCDEGRST]' ++ ;; ++osf*) ++ symcode='[BCDEGQRST]' ++ ;; ++solaris*) ++ symcode='[BDRT]' ++ ;; ++sco3.2v5*) ++ symcode='[DT]' ++ ;; ++sysv4.2uw2*) ++ symcode='[DT]' ++ ;; ++sysv5* | sco5v6* | unixware* | OpenUNIX*) ++ symcode='[ABDT]' ++ ;; ++sysv4) ++ symcode='[DFNSTU]' ++ ;; ++esac ++ ++# If we're using GNU nm, then use its standard symbol codes. ++case `$NM -V 2>&1` in ++*GNU* | *'with BFD'*) ++ symcode='[ABCDGIRSTW]' ;; ++esac ++ ++# Transform an extracted symbol line into a proper C declaration. ++# Some systems (esp. on ia64) link data and code symbols differently, ++# so use this general approach. ++lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" ++ ++# Transform an extracted symbol line into symbol name and symbol address ++lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" ++lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" ++ ++# Handle CRLF in mingw tool chain ++opt_cr= ++case $build_os in ++mingw*) ++ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ++ ;; ++esac ++ ++# Try without a prefix underscore, then with it. ++for ac_symprfx in "" "_"; do ++ ++ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. ++ symxfrm="\\1 $ac_symprfx\\2 \\2" ++ ++ # Write the raw and C identifiers. ++ if test "$lt_cv_nm_interface" = "MS dumpbin"; then ++ # Fake it for dumpbin and say T for any non-static function ++ # and D for any global variable. ++ # Also find C++ and __fastcall symbols from MSVC++, ++ # which start with @ or ?. ++ lt_cv_sys_global_symbol_pipe="$AWK '"\ ++" {last_section=section; section=\$ 3};"\ ++" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ ++" \$ 0!~/External *\|/{next};"\ ++" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ ++" {if(hide[section]) next};"\ ++" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ ++" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ ++" s[1]~/^[@?]/{print s[1], s[1]; next};"\ ++" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ ++" ' prfx=^$ac_symprfx" ++ else ++ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" ++ fi ++ ++ # Check to see that the pipe works correctly. ++ pipe_works=no ++ ++ rm -f conftest* ++ cat > conftest.$ac_ext <<_LT_EOF ++#ifdef __cplusplus ++extern "C" { ++#endif ++char nm_test_var; ++void nm_test_func(void); ++void nm_test_func(void){} ++#ifdef __cplusplus ++} ++#endif ++int main(){nm_test_var='a';nm_test_func();return(0);} ++_LT_EOF ++ ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ # Now try to grab the symbols. ++ nlist=conftest.nm ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 ++ (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } && test -s "$nlist"; then ++ # Try sorting and uniquifying the output. ++ if sort "$nlist" | uniq > "$nlist"T; then ++ mv -f "$nlist"T "$nlist" ++ else ++ rm -f "$nlist"T ++ fi ++ ++ # Make sure that we snagged all the symbols we need. ++ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then ++ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then ++ cat <<_LT_EOF > conftest.$ac_ext ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++_LT_EOF ++ # Now generate the symbol file. ++ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' ++ ++ cat <<_LT_EOF >> conftest.$ac_ext ++ ++/* The mapping between symbol names and symbols. */ ++const struct { ++ const char *name; ++ void *address; ++} ++lt__PROGRAM__LTX_preloaded_symbols[] = ++{ ++ { "@PROGRAM@", (void *) 0 }, ++_LT_EOF ++ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext ++ cat <<\_LT_EOF >> conftest.$ac_ext ++ {0, (void *) 0} ++}; ++ ++/* This works around a problem in FreeBSD linker */ ++#ifdef FREEBSD_WORKAROUND ++static const void *lt_preloaded_setup() { ++ return lt__PROGRAM__LTX_preloaded_symbols; ++} ++#endif ++ ++#ifdef __cplusplus ++} ++#endif ++_LT_EOF ++ # Now try linking the two files. ++ mv conftest.$ac_objext conftstm.$ac_objext ++ lt_save_LIBS="$LIBS" ++ lt_save_CFLAGS="$CFLAGS" ++ LIBS="conftstm.$ac_objext" ++ CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 ++ (eval $ac_link) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } && test -s conftest${ac_exeext}; then ++ pipe_works=yes ++ fi ++ LIBS="$lt_save_LIBS" ++ CFLAGS="$lt_save_CFLAGS" ++ else ++ echo "cannot find nm_test_func in $nlist" >&5 ++ fi ++ else ++ echo "cannot find nm_test_var in $nlist" >&5 ++ fi ++ else ++ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 ++ fi ++ else ++ echo "$progname: failed program was:" >&5 ++ cat conftest.$ac_ext >&5 ++ fi ++ rm -rf conftest* conftst* ++ ++ # Do not use the global_symbol_pipe unless it works. ++ if test "$pipe_works" = yes; then ++ break ++ else ++ lt_cv_sys_global_symbol_pipe= ++ fi ++done ++ ++fi ++ ++if test -z "$lt_cv_sys_global_symbol_pipe"; then ++ lt_cv_sys_global_symbol_to_cdecl= ++fi ++if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 ++$as_echo "failed" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 ++$as_echo "ok" >&6; } ++fi ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++# Check whether --enable-libtool-lock was given. ++if test "${enable_libtool_lock+set}" = set; then : ++ enableval=$enable_libtool_lock; ++fi ++ ++test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes ++ ++# Some flags need to be propagated to the compiler or linker for good ++# libtool support. ++case $host in ++ia64-*-hpux*) ++ # Find out which ABI we are using. ++ echo 'int i;' > conftest.$ac_ext ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ case `/usr/bin/file conftest.$ac_objext` in ++ *ELF-32*) ++ HPUX_IA64_MODE="32" ++ ;; ++ *ELF-64*) ++ HPUX_IA64_MODE="64" ++ ;; ++ esac ++ fi ++ rm -rf conftest* ++ ;; ++*-*-irix6*) ++ # Find out which ABI we are using. ++ echo '#line '$LINENO' "configure"' > conftest.$ac_ext ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ if test "$lt_cv_prog_gnu_ld" = yes; then ++ case `/usr/bin/file conftest.$ac_objext` in ++ *32-bit*) ++ LD="${LD-ld} -melf32bsmip" ++ ;; ++ *N32*) ++ LD="${LD-ld} -melf32bmipn32" ++ ;; ++ *64-bit*) ++ LD="${LD-ld} -melf64bmip" ++ ;; ++ esac ++ else ++ case `/usr/bin/file conftest.$ac_objext` in ++ *32-bit*) ++ LD="${LD-ld} -32" ++ ;; ++ *N32*) ++ LD="${LD-ld} -n32" ++ ;; ++ *64-bit*) ++ LD="${LD-ld} -64" ++ ;; ++ esac ++ fi ++ fi ++ rm -rf conftest* ++ ;; ++ ++x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ ++s390*-*linux*|s390*-*tpf*|sparc*-*linux*) ++ # Find out which ABI we are using. ++ echo 'int i;' > conftest.$ac_ext ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ case `/usr/bin/file conftest.o` in ++ *32-bit*) ++ case $host in ++ x86_64-*kfreebsd*-gnu) ++ LD="${LD-ld} -m elf_i386_fbsd" ++ ;; ++ x86_64-*linux*) ++ case `/usr/bin/file conftest.o` in ++ *x86-64*) ++ LD="${LD-ld} -m elf32_x86_64" ++ ;; ++ *) ++ LD="${LD-ld} -m elf_i386" ++ ;; ++ esac ++ ;; ++ powerpc64le-*linux*) ++ LD="${LD-ld} -m elf32lppclinux" ++ ;; ++ powerpc64-*linux*) ++ LD="${LD-ld} -m elf32ppclinux" ++ ;; ++ s390x-*linux*) ++ LD="${LD-ld} -m elf_s390" ++ ;; ++ sparc64-*linux*) ++ LD="${LD-ld} -m elf32_sparc" ++ ;; ++ esac ++ ;; ++ *64-bit*) ++ case $host in ++ x86_64-*kfreebsd*-gnu) ++ LD="${LD-ld} -m elf_x86_64_fbsd" ++ ;; ++ x86_64-*linux*) ++ LD="${LD-ld} -m elf_x86_64" ++ ;; ++ powerpcle-*linux*) ++ LD="${LD-ld} -m elf64lppc" ++ ;; ++ powerpc-*linux*) ++ LD="${LD-ld} -m elf64ppc" ++ ;; ++ s390*-*linux*|s390*-*tpf*) ++ LD="${LD-ld} -m elf64_s390" ++ ;; ++ sparc*-*linux*) ++ LD="${LD-ld} -m elf64_sparc" ++ ;; ++ esac ++ ;; ++ esac ++ fi ++ rm -rf conftest* ++ ;; ++ ++*-*-sco3.2v5*) ++ # On SCO OpenServer 5, we need -belf to get full-featured binaries. ++ SAVE_CFLAGS="$CFLAGS" ++ CFLAGS="$CFLAGS -belf" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 ++$as_echo_n "checking whether the C compiler needs -belf... " >&6; } ++if test "${lt_cv_cc_needs_belf+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ lt_cv_cc_needs_belf=yes ++else ++ lt_cv_cc_needs_belf=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++ ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 ++$as_echo "$lt_cv_cc_needs_belf" >&6; } ++ if test x"$lt_cv_cc_needs_belf" != x"yes"; then ++ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf ++ CFLAGS="$SAVE_CFLAGS" ++ fi ++ ;; ++sparc*-*solaris*) ++ # Find out which ABI we are using. ++ echo 'int i;' > conftest.$ac_ext ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; then ++ case `/usr/bin/file conftest.o` in ++ *64-bit*) ++ case $lt_cv_prog_gnu_ld in ++ yes*) LD="${LD-ld} -m elf64_sparc" ;; ++ *) ++ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then ++ LD="${LD-ld} -64" ++ fi ++ ;; ++ esac ++ ;; ++ esac ++ fi ++ rm -rf conftest* ++ ;; ++esac ++ ++need_locks="$enable_libtool_lock" ++ ++ ++ case $host_os in ++ rhapsody* | darwin*) ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. ++set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_DSYMUTIL+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$DSYMUTIL"; then ++ ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++DSYMUTIL=$ac_cv_prog_DSYMUTIL ++if test -n "$DSYMUTIL"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 ++$as_echo "$DSYMUTIL" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_DSYMUTIL"; then ++ ac_ct_DSYMUTIL=$DSYMUTIL ++ # Extract the first word of "dsymutil", so it can be a program name with args. ++set dummy dsymutil; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_DSYMUTIL"; then ++ ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL ++if test -n "$ac_ct_DSYMUTIL"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 ++$as_echo "$ac_ct_DSYMUTIL" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_DSYMUTIL" = x; then ++ DSYMUTIL=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ DSYMUTIL=$ac_ct_DSYMUTIL ++ fi ++else ++ DSYMUTIL="$ac_cv_prog_DSYMUTIL" ++fi ++ ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. ++set dummy ${ac_tool_prefix}nmedit; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_NMEDIT+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$NMEDIT"; then ++ ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++NMEDIT=$ac_cv_prog_NMEDIT ++if test -n "$NMEDIT"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 ++$as_echo "$NMEDIT" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_NMEDIT"; then ++ ac_ct_NMEDIT=$NMEDIT ++ # Extract the first word of "nmedit", so it can be a program name with args. ++set dummy nmedit; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_NMEDIT"; then ++ ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_NMEDIT="nmedit" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT ++if test -n "$ac_ct_NMEDIT"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 ++$as_echo "$ac_ct_NMEDIT" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_NMEDIT" = x; then ++ NMEDIT=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ NMEDIT=$ac_ct_NMEDIT ++ fi ++else ++ NMEDIT="$ac_cv_prog_NMEDIT" ++fi ++ ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. ++set dummy ${ac_tool_prefix}lipo; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_LIPO+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$LIPO"; then ++ ac_cv_prog_LIPO="$LIPO" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_LIPO="${ac_tool_prefix}lipo" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++LIPO=$ac_cv_prog_LIPO ++if test -n "$LIPO"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 ++$as_echo "$LIPO" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_LIPO"; then ++ ac_ct_LIPO=$LIPO ++ # Extract the first word of "lipo", so it can be a program name with args. ++set dummy lipo; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_LIPO"; then ++ ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_LIPO="lipo" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO ++if test -n "$ac_ct_LIPO"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 ++$as_echo "$ac_ct_LIPO" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_LIPO" = x; then ++ LIPO=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ LIPO=$ac_ct_LIPO ++ fi ++else ++ LIPO="$ac_cv_prog_LIPO" ++fi ++ ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. ++set dummy ${ac_tool_prefix}otool; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_OTOOL+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$OTOOL"; then ++ ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_OTOOL="${ac_tool_prefix}otool" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++OTOOL=$ac_cv_prog_OTOOL ++if test -n "$OTOOL"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 ++$as_echo "$OTOOL" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_OTOOL"; then ++ ac_ct_OTOOL=$OTOOL ++ # Extract the first word of "otool", so it can be a program name with args. ++set dummy otool; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_OTOOL"; then ++ ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_OTOOL="otool" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL ++if test -n "$ac_ct_OTOOL"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 ++$as_echo "$ac_ct_OTOOL" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_OTOOL" = x; then ++ OTOOL=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ OTOOL=$ac_ct_OTOOL ++ fi ++else ++ OTOOL="$ac_cv_prog_OTOOL" ++fi ++ ++ if test -n "$ac_tool_prefix"; then ++ # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. ++set dummy ${ac_tool_prefix}otool64; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_OTOOL64+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$OTOOL64"; then ++ ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++OTOOL64=$ac_cv_prog_OTOOL64 ++if test -n "$OTOOL64"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 ++$as_echo "$OTOOL64" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++fi ++if test -z "$ac_cv_prog_OTOOL64"; then ++ ac_ct_OTOOL64=$OTOOL64 ++ # Extract the first word of "otool64", so it can be a program name with args. ++set dummy otool64; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "$ac_ct_OTOOL64"; then ++ ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. ++else ++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ++ ac_cv_prog_ac_ct_OTOOL64="otool64" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++fi ++fi ++ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 ++if test -n "$ac_ct_OTOOL64"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 ++$as_echo "$ac_ct_OTOOL64" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ if test "x$ac_ct_OTOOL64" = x; then ++ OTOOL64=":" ++ else ++ case $cross_compiling:$ac_tool_warned in ++yes:) ++{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 ++$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ++ac_tool_warned=yes ;; ++esac ++ OTOOL64=$ac_ct_OTOOL64 ++ fi ++else ++ OTOOL64="$ac_cv_prog_OTOOL64" ++fi ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 ++$as_echo_n "checking for -single_module linker flag... " >&6; } ++if test "${lt_cv_apple_cc_single_mod+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_apple_cc_single_mod=no ++ if test -z "${LT_MULTI_MODULE}"; then ++ # By default we will add the -single_module flag. You can override ++ # by either setting the environment variable LT_MULTI_MODULE ++ # non-empty at configure time, or by adding -multi_module to the ++ # link flags. ++ rm -rf libconftest.dylib* ++ echo "int foo(void){return 1;}" > conftest.c ++ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ ++-dynamiclib -Wl,-single_module conftest.c" >&5 ++ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ ++ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err ++ _lt_result=$? ++ if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then ++ lt_cv_apple_cc_single_mod=yes ++ else ++ cat conftest.err >&5 ++ fi ++ rm -rf libconftest.dylib* ++ rm -f conftest.* ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 ++$as_echo "$lt_cv_apple_cc_single_mod" >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 ++$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } ++if test "${lt_cv_ld_exported_symbols_list+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_ld_exported_symbols_list=no ++ save_LDFLAGS=$LDFLAGS ++ echo "_main" > conftest.sym ++ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ lt_cv_ld_exported_symbols_list=yes ++else ++ lt_cv_ld_exported_symbols_list=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++ LDFLAGS="$save_LDFLAGS" ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 ++$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 ++$as_echo_n "checking for -force_load linker flag... " >&6; } ++if test "${lt_cv_ld_force_load+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_ld_force_load=no ++ cat > conftest.c << _LT_EOF ++int forced_loaded() { return 2;} ++_LT_EOF ++ echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 ++ $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 ++ echo "$AR cru libconftest.a conftest.o" >&5 ++ $AR cru libconftest.a conftest.o 2>&5 ++ cat > conftest.c << _LT_EOF ++int main() { return 0;} ++_LT_EOF ++ echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 ++ $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err ++ _lt_result=$? ++ if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then ++ lt_cv_ld_force_load=yes ++ else ++ cat conftest.err >&5 ++ fi ++ rm -f conftest.err libconftest.a conftest conftest.c ++ rm -rf conftest.dSYM ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 ++$as_echo "$lt_cv_ld_force_load" >&6; } ++ case $host_os in ++ rhapsody* | darwin1.[012]) ++ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; ++ darwin1.*) ++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; ++ darwin*) # darwin 5.x on ++ # if running on 10.5 or later, the deployment target defaults ++ # to the OS version, if on x86, and 10.4, the deployment ++ # target defaults to 10.4. Don't you love it? ++ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in ++ 10.0,*86*-darwin8*|10.0,*-darwin[91]*) ++ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; ++ 10.[012][,.]*) ++ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; ++ 10.*) ++ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; ++ esac ++ ;; ++ esac ++ if test "$lt_cv_apple_cc_single_mod" = "yes"; then ++ _lt_dar_single_mod='$single_module' ++ fi ++ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then ++ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' ++ else ++ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' ++ fi ++ if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then ++ _lt_dsymutil='~$DSYMUTIL $lib || :' ++ else ++ _lt_dsymutil= ++ fi ++ ;; ++ esac ++ ++for ac_header in dlfcn.h ++do : ++ ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default ++" ++if test "x$ac_cv_header_dlfcn_h" = x""yes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_DLFCN_H 1 ++_ACEOF ++ ++fi ++ ++done ++ ++ ++ ++ ++ ++# Set options ++ ++ ++ ++ enable_dlopen=no ++ ++ ++ enable_win32_dll=no ++ ++ ++ # Check whether --enable-shared was given. ++if test "${enable_shared+set}" = set; then : ++ enableval=$enable_shared; p=${PACKAGE-default} ++ case $enableval in ++ yes) enable_shared=yes ;; ++ no) enable_shared=no ;; ++ *) ++ enable_shared=no ++ # Look at the argument we got. We use all the common list separators. ++ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," ++ for pkg in $enableval; do ++ IFS="$lt_save_ifs" ++ if test "X$pkg" = "X$p"; then ++ enable_shared=yes ++ fi ++ done ++ IFS="$lt_save_ifs" ++ ;; ++ esac ++else ++ enable_shared=yes ++fi ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ # Check whether --enable-static was given. ++if test "${enable_static+set}" = set; then : ++ enableval=$enable_static; p=${PACKAGE-default} ++ case $enableval in ++ yes) enable_static=yes ;; ++ no) enable_static=no ;; ++ *) ++ enable_static=no ++ # Look at the argument we got. We use all the common list separators. ++ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," ++ for pkg in $enableval; do ++ IFS="$lt_save_ifs" ++ if test "X$pkg" = "X$p"; then ++ enable_static=yes ++ fi ++ done ++ IFS="$lt_save_ifs" ++ ;; ++ esac ++else ++ enable_static=yes ++fi ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++# Check whether --with-pic was given. ++if test "${with_pic+set}" = set; then : ++ withval=$with_pic; pic_mode="$withval" ++else ++ pic_mode=default ++fi ++ ++ ++test -z "$pic_mode" && pic_mode=default ++ ++ ++ ++ ++ ++ ++ ++ # Check whether --enable-fast-install was given. ++if test "${enable_fast_install+set}" = set; then : ++ enableval=$enable_fast_install; p=${PACKAGE-default} ++ case $enableval in ++ yes) enable_fast_install=yes ;; ++ no) enable_fast_install=no ;; ++ *) ++ enable_fast_install=no ++ # Look at the argument we got. We use all the common list separators. ++ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," ++ for pkg in $enableval; do ++ IFS="$lt_save_ifs" ++ if test "X$pkg" = "X$p"; then ++ enable_fast_install=yes ++ fi ++ done ++ IFS="$lt_save_ifs" ++ ;; ++ esac ++else ++ enable_fast_install=yes ++fi ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++# This can be used to rebuild libtool when needed ++LIBTOOL_DEPS="$ltmain" ++ ++# Always use our own libtool. ++LIBTOOL='$(SHELL) $(top_builddir)/libtool' ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++test -z "$LN_S" && LN_S="ln -s" ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++if test -n "${ZSH_VERSION+set}" ; then ++ setopt NO_GLOB_SUBST ++fi ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 ++$as_echo_n "checking for objdir... " >&6; } ++if test "${lt_cv_objdir+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ rm -f .libs 2>/dev/null ++mkdir .libs 2>/dev/null ++if test -d .libs; then ++ lt_cv_objdir=.libs ++else ++ # MS-DOS does not allow filenames that begin with a dot. ++ lt_cv_objdir=_libs ++fi ++rmdir .libs 2>/dev/null ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 ++$as_echo "$lt_cv_objdir" >&6; } ++objdir=$lt_cv_objdir ++ ++ ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define LT_OBJDIR "$lt_cv_objdir/" ++_ACEOF ++ ++ ++ ++ ++case $host_os in ++aix3*) ++ # AIX sometimes has problems with the GCC collect2 program. For some ++ # reason, if we set the COLLECT_NAMES environment variable, the problems ++ # vanish in a puff of smoke. ++ if test "X${COLLECT_NAMES+set}" != Xset; then ++ COLLECT_NAMES= ++ export COLLECT_NAMES ++ fi ++ ;; ++esac ++ ++# Global variables: ++ofile=libtool ++can_build_shared=yes ++ ++# All known linkers require a `.a' archive for static linking (except MSVC, ++# which needs '.lib'). ++libext=a ++ ++with_gnu_ld="$lt_cv_prog_gnu_ld" ++ ++old_CC="$CC" ++old_CFLAGS="$CFLAGS" ++ ++# Set sane defaults for various variables ++test -z "$CC" && CC=cc ++test -z "$LTCC" && LTCC=$CC ++test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS ++test -z "$LD" && LD=ld ++test -z "$ac_objext" && ac_objext=o ++ ++for cc_temp in $compiler""; do ++ case $cc_temp in ++ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; ++ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; ++ \-*) ;; ++ *) break;; ++ esac ++done ++cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ++ ++ ++# Only perform the check for file, if the check method requires it ++test -z "$MAGIC_CMD" && MAGIC_CMD=file ++case $deplibs_check_method in ++file_magic*) ++ if test "$file_magic_cmd" = '$MAGIC_CMD'; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 ++$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } ++if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ case $MAGIC_CMD in ++[\\/*] | ?:[\\/]*) ++ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ++ ;; ++*) ++ lt_save_MAGIC_CMD="$MAGIC_CMD" ++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ++ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" ++ for ac_dir in $ac_dummy; do ++ IFS="$lt_save_ifs" ++ test -z "$ac_dir" && ac_dir=. ++ if test -f $ac_dir/${ac_tool_prefix}file; then ++ lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" ++ if test -n "$file_magic_test_file"; then ++ case $deplibs_check_method in ++ "file_magic "*) ++ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` ++ MAGIC_CMD="$lt_cv_path_MAGIC_CMD" ++ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | ++ $EGREP "$file_magic_regex" > /dev/null; then ++ : ++ else ++ cat <<_LT_EOF 1>&2 ++ ++*** Warning: the command libtool uses to detect shared libraries, ++*** $file_magic_cmd, produces output that libtool cannot recognize. ++*** The result is that libtool may fail to recognize shared libraries ++*** as such. This will affect the creation of libtool libraries that ++*** depend on shared libraries, but programs linked with such libtool ++*** libraries will work regardless of this problem. Nevertheless, you ++*** may want to report the problem to your system manager and/or to ++*** bug-libtool@gnu.org ++ ++_LT_EOF ++ fi ;; ++ esac ++ fi ++ break ++ fi ++ done ++ IFS="$lt_save_ifs" ++ MAGIC_CMD="$lt_save_MAGIC_CMD" ++ ;; ++esac ++fi ++ ++MAGIC_CMD="$lt_cv_path_MAGIC_CMD" ++if test -n "$MAGIC_CMD"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 ++$as_echo "$MAGIC_CMD" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ ++ ++ ++if test -z "$lt_cv_path_MAGIC_CMD"; then ++ if test -n "$ac_tool_prefix"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 ++$as_echo_n "checking for file... " >&6; } ++if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ case $MAGIC_CMD in ++[\\/*] | ?:[\\/]*) ++ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ++ ;; ++*) ++ lt_save_MAGIC_CMD="$MAGIC_CMD" ++ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ++ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" ++ for ac_dir in $ac_dummy; do ++ IFS="$lt_save_ifs" ++ test -z "$ac_dir" && ac_dir=. ++ if test -f $ac_dir/file; then ++ lt_cv_path_MAGIC_CMD="$ac_dir/file" ++ if test -n "$file_magic_test_file"; then ++ case $deplibs_check_method in ++ "file_magic "*) ++ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` ++ MAGIC_CMD="$lt_cv_path_MAGIC_CMD" ++ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | ++ $EGREP "$file_magic_regex" > /dev/null; then ++ : ++ else ++ cat <<_LT_EOF 1>&2 ++ ++*** Warning: the command libtool uses to detect shared libraries, ++*** $file_magic_cmd, produces output that libtool cannot recognize. ++*** The result is that libtool may fail to recognize shared libraries ++*** as such. This will affect the creation of libtool libraries that ++*** depend on shared libraries, but programs linked with such libtool ++*** libraries will work regardless of this problem. Nevertheless, you ++*** may want to report the problem to your system manager and/or to ++*** bug-libtool@gnu.org ++ ++_LT_EOF ++ fi ;; ++ esac ++ fi ++ break ++ fi ++ done ++ IFS="$lt_save_ifs" ++ MAGIC_CMD="$lt_save_MAGIC_CMD" ++ ;; ++esac ++fi ++ ++MAGIC_CMD="$lt_cv_path_MAGIC_CMD" ++if test -n "$MAGIC_CMD"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 ++$as_echo "$MAGIC_CMD" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ else ++ MAGIC_CMD=: ++ fi ++fi ++ ++ fi ++ ;; ++esac ++ ++# Use C for the default configuration in the libtool script ++ ++lt_save_CC="$CC" ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++ ++# Source file extension for C test sources. ++ac_ext=c ++ ++# Object file extension for compiled C test sources. ++objext=o ++objext=$objext ++ ++# Code to be used in simple compile tests ++lt_simple_compile_test_code="int some_variable = 0;" ++ ++# Code to be used in simple link tests ++lt_simple_link_test_code='int main(){return(0);}' ++ ++ ++ ++ ++ ++ ++ ++# If no C compiler was specified, use CC. ++LTCC=${LTCC-"$CC"} ++ ++# If no C compiler flags were specified, use CFLAGS. ++LTCFLAGS=${LTCFLAGS-"$CFLAGS"} ++ ++# Allow CC to be a program name with arguments. ++compiler=$CC ++ ++# Save the default compiler, since it gets overwritten when the other ++# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. ++compiler_DEFAULT=$CC ++ ++# save warnings/boilerplate of simple test code ++ac_outfile=conftest.$ac_objext ++echo "$lt_simple_compile_test_code" >conftest.$ac_ext ++eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err ++_lt_compiler_boilerplate=`cat conftest.err` ++$RM conftest* ++ ++ac_outfile=conftest.$ac_objext ++echo "$lt_simple_link_test_code" >conftest.$ac_ext ++eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err ++_lt_linker_boilerplate=`cat conftest.err` ++$RM -r conftest* ++ ++ ++## CAVEAT EMPTOR: ++## There is no encapsulation within the following macros, do not change ++## the running order or otherwise move them around unless you know exactly ++## what you are doing... ++if test -n "$compiler"; then ++ ++lt_prog_compiler_no_builtin_flag= ++ ++if test "$GCC" = yes; then ++ case $cc_basename in ++ nvcc*) ++ lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; ++ *) ++ lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; ++ esac ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 ++$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } ++if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_prog_compiler_rtti_exceptions=no ++ ac_outfile=conftest.$ac_objext ++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext ++ lt_compiler_flag="-fno-rtti -fno-exceptions" ++ # Insert the option either (1) after the last *FLAGS variable, or ++ # (2) before a word containing "conftest.", or (3) at the end. ++ # Note that $ac_compile itself does not contain backslashes and begins ++ # with a dollar sign (not a hyphen), so the echo should work correctly. ++ # The option is referenced via a variable to avoid confusing sed. ++ lt_compile=`echo "$ac_compile" | $SED \ ++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ ++ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ ++ -e 's:$: $lt_compiler_flag:'` ++ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) ++ (eval "$lt_compile" 2>conftest.err) ++ ac_status=$? ++ cat conftest.err >&5 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ if (exit $ac_status) && test -s "$ac_outfile"; then ++ # The compiler can only warn and ignore the option if not recognized ++ # So say no if there are warnings other than the usual output. ++ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp ++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 ++ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then ++ lt_cv_prog_compiler_rtti_exceptions=yes ++ fi ++ fi ++ $RM conftest* ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 ++$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } ++ ++if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then ++ lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" ++else ++ : ++fi ++ ++fi ++ ++ ++ ++ ++ ++ ++ lt_prog_compiler_wl= ++lt_prog_compiler_pic= ++lt_prog_compiler_static= ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 ++$as_echo_n "checking for $compiler option to produce PIC... " >&6; } ++ ++ if test "$GCC" = yes; then ++ lt_prog_compiler_wl='-Wl,' ++ lt_prog_compiler_static='-static' ++ ++ case $host_os in ++ aix*) ++ # All AIX code is PIC. ++ if test "$host_cpu" = ia64; then ++ # AIX 5 now supports IA64 processor ++ lt_prog_compiler_static='-Bstatic' ++ fi ++ lt_prog_compiler_pic='-fPIC' ++ ;; ++ ++ amigaos*) ++ case $host_cpu in ++ powerpc) ++ # see comment about AmigaOS4 .so support ++ lt_prog_compiler_pic='-fPIC' ++ ;; ++ m68k) ++ # FIXME: we need at least 68020 code to build shared libraries, but ++ # adding the `-m68020' flag to GCC prevents building anything better, ++ # like `-m68040'. ++ lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ++ ;; ++ esac ++ ;; ++ ++ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) ++ # PIC is the default for these OSes. ++ ;; ++ ++ mingw* | cygwin* | pw32* | os2* | cegcc*) ++ # This hack is so that the source file can tell whether it is being ++ # built for inclusion in a dll (and should export symbols for example). ++ # Although the cygwin gcc ignores -fPIC, still need this for old-style ++ # (--disable-auto-import) libraries ++ lt_prog_compiler_pic='-DDLL_EXPORT' ++ ;; ++ ++ darwin* | rhapsody*) ++ # PIC is the default on this platform ++ # Common symbols not allowed in MH_DYLIB files ++ lt_prog_compiler_pic='-fno-common' ++ ;; ++ ++ haiku*) ++ # PIC is the default for Haiku. ++ # The "-static" flag exists, but is broken. ++ lt_prog_compiler_static= ++ ;; ++ ++ hpux*) ++ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit ++ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag ++ # sets the default TLS model and affects inlining. ++ case $host_cpu in ++ hppa*64*) ++ # +Z the default ++ ;; ++ *) ++ lt_prog_compiler_pic='-fPIC' ++ ;; ++ esac ++ ;; ++ ++ interix[3-9]*) ++ # Interix 3.x gcc -fpic/-fPIC options generate broken code. ++ # Instead, we relocate shared libraries at runtime. ++ ;; ++ ++ msdosdjgpp*) ++ # Just because we use GCC doesn't mean we suddenly get shared libraries ++ # on systems that don't support them. ++ lt_prog_compiler_can_build_shared=no ++ enable_shared=no ++ ;; ++ ++ *nto* | *qnx*) ++ # QNX uses GNU C++, but need to define -shared option too, otherwise ++ # it will coredump. ++ lt_prog_compiler_pic='-fPIC -shared' ++ ;; ++ ++ sysv4*MP*) ++ if test -d /usr/nec; then ++ lt_prog_compiler_pic=-Kconform_pic ++ fi ++ ;; ++ ++ *) ++ lt_prog_compiler_pic='-fPIC' ++ ;; ++ esac ++ ++ case $cc_basename in ++ nvcc*) # Cuda Compiler Driver 2.2 ++ lt_prog_compiler_wl='-Xlinker ' ++ lt_prog_compiler_pic='-Xcompiler -fPIC' ++ ;; ++ esac ++ else ++ # PORTME Check for flag to pass linker flags through the system compiler. ++ case $host_os in ++ aix*) ++ lt_prog_compiler_wl='-Wl,' ++ if test "$host_cpu" = ia64; then ++ # AIX 5 now supports IA64 processor ++ lt_prog_compiler_static='-Bstatic' ++ else ++ lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' ++ fi ++ ;; ++ ++ mingw* | cygwin* | pw32* | os2* | cegcc*) ++ # This hack is so that the source file can tell whether it is being ++ # built for inclusion in a dll (and should export symbols for example). ++ lt_prog_compiler_pic='-DDLL_EXPORT' ++ ;; ++ ++ hpux9* | hpux10* | hpux11*) ++ lt_prog_compiler_wl='-Wl,' ++ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but ++ # not for PA HP-UX. ++ case $host_cpu in ++ hppa*64*|ia64*) ++ # +Z the default ++ ;; ++ *) ++ lt_prog_compiler_pic='+Z' ++ ;; ++ esac ++ # Is there a better lt_prog_compiler_static that works with the bundled CC? ++ lt_prog_compiler_static='${wl}-a ${wl}archive' ++ ;; ++ ++ irix5* | irix6* | nonstopux*) ++ lt_prog_compiler_wl='-Wl,' ++ # PIC (with -KPIC) is the default. ++ lt_prog_compiler_static='-non_shared' ++ ;; ++ ++ linux* | k*bsd*-gnu | kopensolaris*-gnu) ++ case $cc_basename in ++ # old Intel for x86_64 which still supported -KPIC. ++ ecc*) ++ lt_prog_compiler_wl='-Wl,' ++ lt_prog_compiler_pic='-KPIC' ++ lt_prog_compiler_static='-static' ++ ;; ++ # icc used to be incompatible with GCC. ++ # ICC 10 doesn't accept -KPIC any more. ++ icc* | ifort*) ++ lt_prog_compiler_wl='-Wl,' ++ lt_prog_compiler_pic='-fPIC' ++ lt_prog_compiler_static='-static' ++ ;; ++ # Lahey Fortran 8.1. ++ lf95*) ++ lt_prog_compiler_wl='-Wl,' ++ lt_prog_compiler_pic='--shared' ++ lt_prog_compiler_static='--static' ++ ;; ++ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) ++ # Portland Group compilers (*not* the Pentium gcc compiler, ++ # which looks to be a dead project) ++ lt_prog_compiler_wl='-Wl,' ++ lt_prog_compiler_pic='-fpic' ++ lt_prog_compiler_static='-Bstatic' ++ ;; ++ ccc*) ++ lt_prog_compiler_wl='-Wl,' ++ # All Alpha code is PIC. ++ lt_prog_compiler_static='-non_shared' ++ ;; ++ xl* | bgxl* | bgf* | mpixl*) ++ # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene ++ lt_prog_compiler_wl='-Wl,' ++ lt_prog_compiler_pic='-qpic' ++ lt_prog_compiler_static='-qstaticlink' ++ ;; ++ *) ++ case `$CC -V 2>&1 | sed 5q` in ++ *Sun\ F* | *Sun*Fortran*) ++ # Sun Fortran 8.3 passes all unrecognized flags to the linker ++ lt_prog_compiler_pic='-KPIC' ++ lt_prog_compiler_static='-Bstatic' ++ lt_prog_compiler_wl='' ++ ;; ++ *Sun\ C*) ++ # Sun C 5.9 ++ lt_prog_compiler_pic='-KPIC' ++ lt_prog_compiler_static='-Bstatic' ++ lt_prog_compiler_wl='-Wl,' ++ ;; ++ esac ++ ;; ++ esac ++ ;; ++ ++ newsos6) ++ lt_prog_compiler_pic='-KPIC' ++ lt_prog_compiler_static='-Bstatic' ++ ;; ++ ++ *nto* | *qnx*) ++ # QNX uses GNU C++, but need to define -shared option too, otherwise ++ # it will coredump. ++ lt_prog_compiler_pic='-fPIC -shared' ++ ;; ++ ++ osf3* | osf4* | osf5*) ++ lt_prog_compiler_wl='-Wl,' ++ # All OSF/1 code is PIC. ++ lt_prog_compiler_static='-non_shared' ++ ;; ++ ++ rdos*) ++ lt_prog_compiler_static='-non_shared' ++ ;; ++ ++ solaris*) ++ lt_prog_compiler_pic='-KPIC' ++ lt_prog_compiler_static='-Bstatic' ++ case $cc_basename in ++ f77* | f90* | f95*) ++ lt_prog_compiler_wl='-Qoption ld ';; ++ *) ++ lt_prog_compiler_wl='-Wl,';; ++ esac ++ ;; ++ ++ sunos4*) ++ lt_prog_compiler_wl='-Qoption ld ' ++ lt_prog_compiler_pic='-PIC' ++ lt_prog_compiler_static='-Bstatic' ++ ;; ++ ++ sysv4 | sysv4.2uw2* | sysv4.3*) ++ lt_prog_compiler_wl='-Wl,' ++ lt_prog_compiler_pic='-KPIC' ++ lt_prog_compiler_static='-Bstatic' ++ ;; ++ ++ sysv4*MP*) ++ if test -d /usr/nec ;then ++ lt_prog_compiler_pic='-Kconform_pic' ++ lt_prog_compiler_static='-Bstatic' ++ fi ++ ;; ++ ++ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) ++ lt_prog_compiler_wl='-Wl,' ++ lt_prog_compiler_pic='-KPIC' ++ lt_prog_compiler_static='-Bstatic' ++ ;; ++ ++ unicos*) ++ lt_prog_compiler_wl='-Wl,' ++ lt_prog_compiler_can_build_shared=no ++ ;; ++ ++ uts4*) ++ lt_prog_compiler_pic='-pic' ++ lt_prog_compiler_static='-Bstatic' ++ ;; ++ ++ *) ++ lt_prog_compiler_can_build_shared=no ++ ;; ++ esac ++ fi ++ ++case $host_os in ++ # For platforms which do not support PIC, -DPIC is meaningless: ++ *djgpp*) ++ lt_prog_compiler_pic= ++ ;; ++ *) ++ lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ++ ;; ++esac ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5 ++$as_echo "$lt_prog_compiler_pic" >&6; } ++ ++ ++ ++ ++ ++ ++# ++# Check to make sure the PIC flag actually works. ++# ++if test -n "$lt_prog_compiler_pic"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 ++$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } ++if test "${lt_cv_prog_compiler_pic_works+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_prog_compiler_pic_works=no ++ ac_outfile=conftest.$ac_objext ++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext ++ lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ++ # Insert the option either (1) after the last *FLAGS variable, or ++ # (2) before a word containing "conftest.", or (3) at the end. ++ # Note that $ac_compile itself does not contain backslashes and begins ++ # with a dollar sign (not a hyphen), so the echo should work correctly. ++ # The option is referenced via a variable to avoid confusing sed. ++ lt_compile=`echo "$ac_compile" | $SED \ ++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ ++ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ ++ -e 's:$: $lt_compiler_flag:'` ++ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) ++ (eval "$lt_compile" 2>conftest.err) ++ ac_status=$? ++ cat conftest.err >&5 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ if (exit $ac_status) && test -s "$ac_outfile"; then ++ # The compiler can only warn and ignore the option if not recognized ++ # So say no if there are warnings other than the usual output. ++ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp ++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 ++ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then ++ lt_cv_prog_compiler_pic_works=yes ++ fi ++ fi ++ $RM conftest* ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 ++$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } ++ ++if test x"$lt_cv_prog_compiler_pic_works" = xyes; then ++ case $lt_prog_compiler_pic in ++ "" | " "*) ;; ++ *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; ++ esac ++else ++ lt_prog_compiler_pic= ++ lt_prog_compiler_can_build_shared=no ++fi ++ ++fi ++ ++ ++ ++ ++ ++ ++# ++# Check to make sure the static flag actually works. ++# ++wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 ++$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } ++if test "${lt_cv_prog_compiler_static_works+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_prog_compiler_static_works=no ++ save_LDFLAGS="$LDFLAGS" ++ LDFLAGS="$LDFLAGS $lt_tmp_static_flag" ++ echo "$lt_simple_link_test_code" > conftest.$ac_ext ++ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then ++ # The linker can only warn and ignore the option if not recognized ++ # So say no if there are warnings ++ if test -s conftest.err; then ++ # Append any errors to the config.log. ++ cat conftest.err 1>&5 ++ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp ++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 ++ if diff conftest.exp conftest.er2 >/dev/null; then ++ lt_cv_prog_compiler_static_works=yes ++ fi ++ else ++ lt_cv_prog_compiler_static_works=yes ++ fi ++ fi ++ $RM -r conftest* ++ LDFLAGS="$save_LDFLAGS" ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 ++$as_echo "$lt_cv_prog_compiler_static_works" >&6; } ++ ++if test x"$lt_cv_prog_compiler_static_works" = xyes; then ++ : ++else ++ lt_prog_compiler_static= ++fi ++ ++ ++ ++ ++ ++ ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 ++$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } ++if test "${lt_cv_prog_compiler_c_o+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_prog_compiler_c_o=no ++ $RM -r conftest 2>/dev/null ++ mkdir conftest ++ cd conftest ++ mkdir out ++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext ++ ++ lt_compiler_flag="-o out/conftest2.$ac_objext" ++ # Insert the option either (1) after the last *FLAGS variable, or ++ # (2) before a word containing "conftest.", or (3) at the end. ++ # Note that $ac_compile itself does not contain backslashes and begins ++ # with a dollar sign (not a hyphen), so the echo should work correctly. ++ lt_compile=`echo "$ac_compile" | $SED \ ++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ ++ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ ++ -e 's:$: $lt_compiler_flag:'` ++ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) ++ (eval "$lt_compile" 2>out/conftest.err) ++ ac_status=$? ++ cat out/conftest.err >&5 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ if (exit $ac_status) && test -s out/conftest2.$ac_objext ++ then ++ # The compiler can only warn and ignore the option if not recognized ++ # So say no if there are warnings ++ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp ++ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 ++ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then ++ lt_cv_prog_compiler_c_o=yes ++ fi ++ fi ++ chmod u+w . 2>&5 ++ $RM conftest* ++ # SGI C++ compiler will create directory out/ii_files/ for ++ # template instantiation ++ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files ++ $RM out/* && rmdir out ++ cd .. ++ $RM -r conftest ++ $RM conftest* ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 ++$as_echo "$lt_cv_prog_compiler_c_o" >&6; } ++ ++ ++ ++ ++ ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 ++$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } ++if test "${lt_cv_prog_compiler_c_o+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_prog_compiler_c_o=no ++ $RM -r conftest 2>/dev/null ++ mkdir conftest ++ cd conftest ++ mkdir out ++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext ++ ++ lt_compiler_flag="-o out/conftest2.$ac_objext" ++ # Insert the option either (1) after the last *FLAGS variable, or ++ # (2) before a word containing "conftest.", or (3) at the end. ++ # Note that $ac_compile itself does not contain backslashes and begins ++ # with a dollar sign (not a hyphen), so the echo should work correctly. ++ lt_compile=`echo "$ac_compile" | $SED \ ++ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ ++ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ ++ -e 's:$: $lt_compiler_flag:'` ++ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) ++ (eval "$lt_compile" 2>out/conftest.err) ++ ac_status=$? ++ cat out/conftest.err >&5 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 ++ if (exit $ac_status) && test -s out/conftest2.$ac_objext ++ then ++ # The compiler can only warn and ignore the option if not recognized ++ # So say no if there are warnings ++ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp ++ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 ++ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then ++ lt_cv_prog_compiler_c_o=yes ++ fi ++ fi ++ chmod u+w . 2>&5 ++ $RM conftest* ++ # SGI C++ compiler will create directory out/ii_files/ for ++ # template instantiation ++ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files ++ $RM out/* && rmdir out ++ cd .. ++ $RM -r conftest ++ $RM conftest* ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 ++$as_echo "$lt_cv_prog_compiler_c_o" >&6; } ++ ++ ++ ++ ++hard_links="nottested" ++if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then ++ # do not overwrite the value of need_locks provided by the user ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 ++$as_echo_n "checking if we can lock with hard links... " >&6; } ++ hard_links=yes ++ $RM conftest* ++ ln conftest.a conftest.b 2>/dev/null && hard_links=no ++ touch conftest.a ++ ln conftest.a conftest.b 2>&5 || hard_links=no ++ ln conftest.a conftest.b 2>/dev/null && hard_links=no ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 ++$as_echo "$hard_links" >&6; } ++ if test "$hard_links" = no; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 ++$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} ++ need_locks=warn ++ fi ++else ++ need_locks=no ++fi ++ ++ ++ ++ ++ ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 ++$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } ++ ++ runpath_var= ++ allow_undefined_flag= ++ always_export_symbols=no ++ archive_cmds= ++ archive_expsym_cmds= ++ compiler_needs_object=no ++ enable_shared_with_static_runtimes=no ++ export_dynamic_flag_spec= ++ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ++ hardcode_automatic=no ++ hardcode_direct=no ++ hardcode_direct_absolute=no ++ hardcode_libdir_flag_spec= ++ hardcode_libdir_flag_spec_ld= ++ hardcode_libdir_separator= ++ hardcode_minus_L=no ++ hardcode_shlibpath_var=unsupported ++ inherit_rpath=no ++ link_all_deplibs=unknown ++ module_cmds= ++ module_expsym_cmds= ++ old_archive_from_new_cmds= ++ old_archive_from_expsyms_cmds= ++ thread_safe_flag_spec= ++ whole_archive_flag_spec= ++ # include_expsyms should be a list of space-separated symbols to be *always* ++ # included in the symbol list ++ include_expsyms= ++ # exclude_expsyms can be an extended regexp of symbols to exclude ++ # it will be wrapped by ` (' and `)$', so one must not match beginning or ++ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', ++ # as well as any symbol that contains `d'. ++ exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' ++ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out ++ # platforms (ab)use it in PIC code, but their linkers get confused if ++ # the symbol is explicitly referenced. Since portable code cannot ++ # rely on this symbol name, it's probably fine to never include it in ++ # preloaded symbol tables. ++ # Exclude shared library initialization/finalization symbols. ++ extract_expsyms_cmds= ++ ++ case $host_os in ++ cygwin* | mingw* | pw32* | cegcc*) ++ # FIXME: the MSVC++ port hasn't been tested in a loooong time ++ # When not using gcc, we currently assume that we are using ++ # Microsoft Visual C++. ++ if test "$GCC" != yes; then ++ with_gnu_ld=no ++ fi ++ ;; ++ interix*) ++ # we just hope/assume this is gcc and not c89 (= MSVC++) ++ with_gnu_ld=yes ++ ;; ++ openbsd*) ++ with_gnu_ld=no ++ ;; ++ esac ++ ++ ld_shlibs=yes ++ ++ # On some targets, GNU ld is compatible enough with the native linker ++ # that we're better off using the native interface for both. ++ lt_use_gnu_ld_interface=no ++ if test "$with_gnu_ld" = yes; then ++ case $host_os in ++ aix*) ++ # The AIX port of GNU ld has always aspired to compatibility ++ # with the native linker. However, as the warning in the GNU ld ++ # block says, versions before 2.19.5* couldn't really create working ++ # shared libraries, regardless of the interface used. ++ case `$LD -v 2>&1` in ++ *\ \(GNU\ Binutils\)\ 2.19.5*) ;; ++ *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; ++ *\ \(GNU\ Binutils\)\ [3-9]*) ;; ++ *) ++ lt_use_gnu_ld_interface=yes ++ ;; ++ esac ++ ;; ++ *) ++ lt_use_gnu_ld_interface=yes ++ ;; ++ esac ++ fi ++ ++ if test "$lt_use_gnu_ld_interface" = yes; then ++ # If archive_cmds runs LD, not CC, wlarc should be empty ++ wlarc='${wl}' ++ ++ # Set some defaults for GNU ld with shared library support. These ++ # are reset later if shared libraries are not supported. Putting them ++ # here allows them to be overridden if necessary. ++ runpath_var=LD_RUN_PATH ++ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' ++ export_dynamic_flag_spec='${wl}--export-dynamic' ++ # ancient GNU ld didn't support --whole-archive et. al. ++ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then ++ whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' ++ else ++ whole_archive_flag_spec= ++ fi ++ supports_anon_versioning=no ++ case `$LD -v 2>&1` in ++ *GNU\ gold*) supports_anon_versioning=yes ;; ++ *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 ++ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... ++ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... ++ *\ 2.11.*) ;; # other 2.11 versions ++ *) supports_anon_versioning=yes ;; ++ esac ++ ++ # See if GNU ld supports shared libraries. ++ case $host_os in ++ aix[3-9]*) ++ # On AIX/PPC, the GNU linker is very broken ++ if test "$host_cpu" != ia64; then ++ ld_shlibs=no ++ cat <<_LT_EOF 1>&2 ++ ++*** Warning: the GNU linker, at least up to release 2.19, is reported ++*** to be unable to reliably create shared libraries on AIX. ++*** Therefore, libtool is disabling shared libraries support. If you ++*** really care for shared libraries, you may want to install binutils ++*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. ++*** You will then need to restart the configuration process. ++ ++_LT_EOF ++ fi ++ ;; ++ ++ amigaos*) ++ case $host_cpu in ++ powerpc) ++ # see comment about AmigaOS4 .so support ++ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' ++ archive_expsym_cmds='' ++ ;; ++ m68k) ++ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' ++ hardcode_libdir_flag_spec='-L$libdir' ++ hardcode_minus_L=yes ++ ;; ++ esac ++ ;; ++ ++ beos*) ++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then ++ allow_undefined_flag=unsupported ++ # Joseph Beckenbach says some releases of gcc ++ # support --undefined. This deserves some investigation. FIXME ++ archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' ++ else ++ ld_shlibs=no ++ fi ++ ;; ++ ++ cygwin* | mingw* | pw32* | cegcc*) ++ # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, ++ # as there is no search path for DLLs. ++ hardcode_libdir_flag_spec='-L$libdir' ++ export_dynamic_flag_spec='${wl}--export-all-symbols' ++ allow_undefined_flag=unsupported ++ always_export_symbols=no ++ enable_shared_with_static_runtimes=yes ++ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' ++ ++ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then ++ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' ++ # If the export-symbols file already is a .def file (1st line ++ # is EXPORTS), use it as is; otherwise, prepend... ++ archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then ++ cp $export_symbols $output_objdir/$soname.def; ++ else ++ echo EXPORTS > $output_objdir/$soname.def; ++ cat $export_symbols >> $output_objdir/$soname.def; ++ fi~ ++ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' ++ else ++ ld_shlibs=no ++ fi ++ ;; ++ ++ haiku*) ++ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' ++ link_all_deplibs=yes ++ ;; ++ ++ interix[3-9]*) ++ hardcode_direct=no ++ hardcode_shlibpath_var=no ++ hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ++ export_dynamic_flag_spec='${wl}-E' ++ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. ++ # Instead, shared libraries are loaded at an image base (0x10000000 by ++ # default) and relocated if they conflict, which is a slow very memory ++ # consuming and fragmenting process. To avoid this, we pick a random, ++ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link ++ # time. Moving up from 0x10000000 also allows more sbrk(2) space. ++ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ++ archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ++ ;; ++ ++ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) ++ tmp_diet=no ++ if test "$host_os" = linux-dietlibc; then ++ case $cc_basename in ++ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) ++ esac ++ fi ++ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ ++ && test "$tmp_diet" = no ++ then ++ tmp_addflag=' $pic_flag' ++ tmp_sharedflag='-shared' ++ case $cc_basename,$host_cpu in ++ pgcc*) # Portland Group C compiler ++ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ++ tmp_addflag=' $pic_flag' ++ ;; ++ pgf77* | pgf90* | pgf95* | pgfortran*) ++ # Portland Group f77 and f90 compilers ++ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ++ tmp_addflag=' $pic_flag -Mnomain' ;; ++ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 ++ tmp_addflag=' -i_dynamic' ;; ++ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 ++ tmp_addflag=' -i_dynamic -nofor_main' ;; ++ ifc* | ifort*) # Intel Fortran compiler ++ tmp_addflag=' -nofor_main' ;; ++ lf95*) # Lahey Fortran 8.1 ++ whole_archive_flag_spec= ++ tmp_sharedflag='--shared' ;; ++ xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) ++ tmp_sharedflag='-qmkshrobj' ++ tmp_addflag= ;; ++ nvcc*) # Cuda Compiler Driver 2.2 ++ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ++ compiler_needs_object=yes ++ ;; ++ esac ++ case `$CC -V 2>&1 | sed 5q` in ++ *Sun\ C*) # Sun C 5.9 ++ whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ++ compiler_needs_object=yes ++ tmp_sharedflag='-G' ;; ++ *Sun\ F*) # Sun Fortran 8.3 ++ tmp_sharedflag='-G' ;; ++ esac ++ archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' ++ ++ if test "x$supports_anon_versioning" = xyes; then ++ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ ++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ ++ echo "local: *; };" >> $output_objdir/$libname.ver~ ++ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' ++ fi ++ ++ case $cc_basename in ++ xlf* | bgf* | bgxlf* | mpixlf*) ++ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself ++ whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' ++ hardcode_libdir_flag_spec= ++ hardcode_libdir_flag_spec_ld='-rpath $libdir' ++ archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' ++ if test "x$supports_anon_versioning" = xyes; then ++ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ ++ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ ++ echo "local: *; };" >> $output_objdir/$libname.ver~ ++ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' ++ fi ++ ;; ++ esac ++ else ++ ld_shlibs=no ++ fi ++ ;; ++ ++ netbsd*) ++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then ++ archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' ++ wlarc= ++ else ++ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' ++ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ++ fi ++ ;; ++ ++ solaris*) ++ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ++ ld_shlibs=no ++ cat <<_LT_EOF 1>&2 ++ ++*** Warning: The releases 2.8.* of the GNU linker cannot reliably ++*** create shared libraries on Solaris systems. Therefore, libtool ++*** is disabling shared libraries support. We urge you to upgrade GNU ++*** binutils to release 2.9.1 or newer. Another option is to modify ++*** your PATH or compiler configuration so that the native linker is ++*** used, and then restart. ++ ++_LT_EOF ++ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then ++ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' ++ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ++ else ++ ld_shlibs=no ++ fi ++ ;; ++ ++ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) ++ case `$LD -v 2>&1` in ++ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ++ ld_shlibs=no ++ cat <<_LT_EOF 1>&2 ++ ++*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not ++*** reliably create shared libraries on SCO systems. Therefore, libtool ++*** is disabling shared libraries support. We urge you to upgrade GNU ++*** binutils to release 2.16.91.0.3 or newer. Another option is to modify ++*** your PATH or compiler configuration so that the native linker is ++*** used, and then restart. ++ ++_LT_EOF ++ ;; ++ *) ++ # For security reasons, it is highly recommended that you always ++ # use absolute paths for naming shared libraries, and exclude the ++ # DT_RUNPATH tag from executables and libraries. But doing so ++ # requires that you compile everything twice, which is a pain. ++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then ++ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' ++ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' ++ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ++ else ++ ld_shlibs=no ++ fi ++ ;; ++ esac ++ ;; ++ ++ sunos4*) ++ archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' ++ wlarc= ++ hardcode_direct=yes ++ hardcode_shlibpath_var=no ++ ;; ++ ++ *) ++ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then ++ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' ++ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ++ else ++ ld_shlibs=no ++ fi ++ ;; ++ esac ++ ++ if test "$ld_shlibs" = no; then ++ runpath_var= ++ hardcode_libdir_flag_spec= ++ export_dynamic_flag_spec= ++ whole_archive_flag_spec= ++ fi ++ else ++ # PORTME fill in a description of your system's linker (not GNU ld) ++ case $host_os in ++ aix3*) ++ allow_undefined_flag=unsupported ++ always_export_symbols=yes ++ archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' ++ # Note: this linker hardcodes the directories in LIBPATH if there ++ # are no directories specified by -L. ++ hardcode_minus_L=yes ++ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then ++ # Neither direct hardcoding nor static linking is supported with a ++ # broken collect2. ++ hardcode_direct=unsupported ++ fi ++ ;; ++ ++ aix[4-9]*) ++ if test "$host_cpu" = ia64; then ++ # On IA64, the linker does run time linking by default, so we don't ++ # have to do anything special. ++ aix_use_runtimelinking=no ++ exp_sym_flag='-Bexport' ++ no_entry_flag="" ++ else ++ # If we're using GNU nm, then we don't want the "-C" option. ++ # -C means demangle to AIX nm, but means don't demangle with GNU nm ++ # Also, AIX nm treats weak defined symbols like other global ++ # defined symbols, whereas GNU nm marks them as "W". ++ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then ++ export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' ++ else ++ export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' ++ fi ++ aix_use_runtimelinking=no ++ ++ # Test if we are trying to use run time linking or normal ++ # AIX style linking. If -brtl is somewhere in LDFLAGS, we ++ # need to do runtime linking. ++ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) ++ for ld_flag in $LDFLAGS; do ++ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then ++ aix_use_runtimelinking=yes ++ break ++ fi ++ done ++ ;; ++ esac ++ ++ exp_sym_flag='-bexport' ++ no_entry_flag='-bnoentry' ++ fi ++ ++ # When large executables or shared objects are built, AIX ld can ++ # have problems creating the table of contents. If linking a library ++ # or program results in "error TOC overflow" add -mminimal-toc to ++ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not ++ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. ++ ++ archive_cmds='' ++ hardcode_direct=yes ++ hardcode_direct_absolute=yes ++ hardcode_libdir_separator=':' ++ link_all_deplibs=yes ++ file_list_spec='${wl}-f,' ++ ++ if test "$GCC" = yes; then ++ case $host_os in aix4.[012]|aix4.[012].*) ++ # We only want to do this on AIX 4.2 and lower, the check ++ # below for broken collect2 doesn't work under 4.3+ ++ collect2name=`${CC} -print-prog-name=collect2` ++ if test -f "$collect2name" && ++ strings "$collect2name" | $GREP resolve_lib_name >/dev/null ++ then ++ # We have reworked collect2 ++ : ++ else ++ # We have old collect2 ++ hardcode_direct=unsupported ++ # It fails to find uninstalled libraries when the uninstalled ++ # path is not listed in the libpath. Setting hardcode_minus_L ++ # to unsupported forces relinking ++ hardcode_minus_L=yes ++ hardcode_libdir_flag_spec='-L$libdir' ++ hardcode_libdir_separator= ++ fi ++ ;; ++ esac ++ shared_flag='-shared' ++ if test "$aix_use_runtimelinking" = yes; then ++ shared_flag="$shared_flag "'${wl}-G' ++ fi ++ else ++ # not using gcc ++ if test "$host_cpu" = ia64; then ++ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release ++ # chokes on -Wl,-G. The following line is correct: ++ shared_flag='-G' ++ else ++ if test "$aix_use_runtimelinking" = yes; then ++ shared_flag='${wl}-G' ++ else ++ shared_flag='${wl}-bM:SRE' ++ fi ++ fi ++ fi ++ ++ export_dynamic_flag_spec='${wl}-bexpall' ++ # It seems that -bexpall does not export symbols beginning with ++ # underscore (_), so it is better to generate a list of symbols to export. ++ always_export_symbols=yes ++ if test "$aix_use_runtimelinking" = yes; then ++ # Warning - without using the other runtime loading flags (-brtl), ++ # -berok will link without error, but may produce a broken library. ++ allow_undefined_flag='-berok' ++ # Determine the default libpath from the value encoded in an ++ # empty executable. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ++lt_aix_libpath_sed=' ++ /Import File Strings/,/^$/ { ++ /^0/ { ++ s/^0 *\(.*\)$/\1/ ++ p ++ } ++ }' ++aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` ++# Check for a 64-bit object if we didn't find anything. ++if test -z "$aix_libpath"; then ++ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` ++fi ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ++ ++ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" ++ archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" ++ else ++ if test "$host_cpu" = ia64; then ++ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' ++ allow_undefined_flag="-z nodefs" ++ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" ++ else ++ # Determine the default libpath from the value encoded in an ++ # empty executable. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ++lt_aix_libpath_sed=' ++ /Import File Strings/,/^$/ { ++ /^0/ { ++ s/^0 *\(.*\)$/\1/ ++ p ++ } ++ }' ++aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` ++# Check for a 64-bit object if we didn't find anything. ++if test -z "$aix_libpath"; then ++ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` ++fi ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ++ ++ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" ++ # Warning - without using the other run time loading flags, ++ # -berok will link without error, but may produce a broken library. ++ no_undefined_flag=' ${wl}-bernotok' ++ allow_undefined_flag=' ${wl}-berok' ++ if test "$with_gnu_ld" = yes; then ++ # We only use this code for GNU lds that support --whole-archive. ++ whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ++ else ++ # Exported symbols can be pulled into shared objects from archives ++ whole_archive_flag_spec='$convenience' ++ fi ++ archive_cmds_need_lc=yes ++ # This is similar to how AIX traditionally builds its shared libraries. ++ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' ++ fi ++ fi ++ ;; ++ ++ amigaos*) ++ case $host_cpu in ++ powerpc) ++ # see comment about AmigaOS4 .so support ++ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' ++ archive_expsym_cmds='' ++ ;; ++ m68k) ++ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' ++ hardcode_libdir_flag_spec='-L$libdir' ++ hardcode_minus_L=yes ++ ;; ++ esac ++ ;; ++ ++ bsdi[45]*) ++ export_dynamic_flag_spec=-rdynamic ++ ;; ++ ++ cygwin* | mingw* | pw32* | cegcc*) ++ # When not using gcc, we currently assume that we are using ++ # Microsoft Visual C++. ++ # hardcode_libdir_flag_spec is actually meaningless, as there is ++ # no search path for DLLs. ++ hardcode_libdir_flag_spec=' ' ++ allow_undefined_flag=unsupported ++ # Tell ltmain to make .lib files, not .a files. ++ libext=lib ++ # Tell ltmain to make .dll files, not .so files. ++ shrext_cmds=".dll" ++ # FIXME: Setting linknames here is a bad hack. ++ archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' ++ # The linker will automatically build a .lib file if we build a DLL. ++ old_archive_from_new_cmds='true' ++ # FIXME: Should let the user specify the lib program. ++ old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' ++ fix_srcfile_path='`cygpath -w "$srcfile"`' ++ enable_shared_with_static_runtimes=yes ++ ;; ++ ++ darwin* | rhapsody*) ++ ++ ++ archive_cmds_need_lc=no ++ hardcode_direct=no ++ hardcode_automatic=yes ++ hardcode_shlibpath_var=unsupported ++ if test "$lt_cv_ld_force_load" = "yes"; then ++ whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' ++ else ++ whole_archive_flag_spec='' ++ fi ++ link_all_deplibs=yes ++ allow_undefined_flag="$_lt_dar_allow_undefined" ++ case $cc_basename in ++ ifort*) _lt_dar_can_shared=yes ;; ++ *) _lt_dar_can_shared=$GCC ;; ++ esac ++ if test "$_lt_dar_can_shared" = "yes"; then ++ output_verbose_link_cmd=func_echo_all ++ archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" ++ module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" ++ archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" ++ module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" ++ ++ else ++ ld_shlibs=no ++ fi ++ ++ ;; ++ ++ dgux*) ++ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' ++ hardcode_libdir_flag_spec='-L$libdir' ++ hardcode_shlibpath_var=no ++ ;; ++ ++ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor ++ # support. Future versions do this automatically, but an explicit c++rt0.o ++ # does not break anything, and helps significantly (at the cost of a little ++ # extra space). ++ freebsd2.2*) ++ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' ++ hardcode_libdir_flag_spec='-R$libdir' ++ hardcode_direct=yes ++ hardcode_shlibpath_var=no ++ ;; ++ ++ # Unfortunately, older versions of FreeBSD 2 do not have this feature. ++ freebsd2.*) ++ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' ++ hardcode_direct=yes ++ hardcode_minus_L=yes ++ hardcode_shlibpath_var=no ++ ;; ++ ++ # FreeBSD 3 and greater uses gcc -shared to do shared libraries. ++ freebsd* | dragonfly*) ++ archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' ++ hardcode_libdir_flag_spec='-R$libdir' ++ hardcode_direct=yes ++ hardcode_shlibpath_var=no ++ ;; ++ ++ hpux9*) ++ if test "$GCC" = yes; then ++ archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ++ else ++ archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ++ fi ++ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' ++ hardcode_libdir_separator=: ++ hardcode_direct=yes ++ ++ # hardcode_minus_L: Not really in the search PATH, ++ # but as the default location of the library. ++ hardcode_minus_L=yes ++ export_dynamic_flag_spec='${wl}-E' ++ ;; ++ ++ hpux10*) ++ if test "$GCC" = yes && test "$with_gnu_ld" = no; then ++ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ++ else ++ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ++ fi ++ if test "$with_gnu_ld" = no; then ++ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' ++ hardcode_libdir_flag_spec_ld='+b $libdir' ++ hardcode_libdir_separator=: ++ hardcode_direct=yes ++ hardcode_direct_absolute=yes ++ export_dynamic_flag_spec='${wl}-E' ++ # hardcode_minus_L: Not really in the search PATH, ++ # but as the default location of the library. ++ hardcode_minus_L=yes ++ fi ++ ;; ++ ++ hpux11*) ++ if test "$GCC" = yes && test "$with_gnu_ld" = no; then ++ case $host_cpu in ++ hppa*64*) ++ archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ++ ;; ++ ia64*) ++ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ++ ;; ++ *) ++ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ++ ;; ++ esac ++ else ++ case $host_cpu in ++ hppa*64*) ++ archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ++ ;; ++ ia64*) ++ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ++ ;; ++ *) ++ ++ # Older versions of the 11.00 compiler do not understand -b yet ++ # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 ++$as_echo_n "checking if $CC understands -b... " >&6; } ++if test "${lt_cv_prog_compiler__b+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_prog_compiler__b=no ++ save_LDFLAGS="$LDFLAGS" ++ LDFLAGS="$LDFLAGS -b" ++ echo "$lt_simple_link_test_code" > conftest.$ac_ext ++ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then ++ # The linker can only warn and ignore the option if not recognized ++ # So say no if there are warnings ++ if test -s conftest.err; then ++ # Append any errors to the config.log. ++ cat conftest.err 1>&5 ++ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp ++ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 ++ if diff conftest.exp conftest.er2 >/dev/null; then ++ lt_cv_prog_compiler__b=yes ++ fi ++ else ++ lt_cv_prog_compiler__b=yes ++ fi ++ fi ++ $RM -r conftest* ++ LDFLAGS="$save_LDFLAGS" ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 ++$as_echo "$lt_cv_prog_compiler__b" >&6; } ++ ++if test x"$lt_cv_prog_compiler__b" = xyes; then ++ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ++else ++ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ++fi ++ ++ ;; ++ esac ++ fi ++ if test "$with_gnu_ld" = no; then ++ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' ++ hardcode_libdir_separator=: ++ ++ case $host_cpu in ++ hppa*64*|ia64*) ++ hardcode_direct=no ++ hardcode_shlibpath_var=no ++ ;; ++ *) ++ hardcode_direct=yes ++ hardcode_direct_absolute=yes ++ export_dynamic_flag_spec='${wl}-E' ++ ++ # hardcode_minus_L: Not really in the search PATH, ++ # but as the default location of the library. ++ hardcode_minus_L=yes ++ ;; ++ esac ++ fi ++ ;; ++ ++ irix5* | irix6* | nonstopux*) ++ if test "$GCC" = yes; then ++ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ++ # Try to use the -exported_symbol ld option, if it does not ++ # work, assume that -exports_file does not work either and ++ # implicitly export all symbols. ++ save_LDFLAGS="$LDFLAGS" ++ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++int foo(void) {} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' ++ ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++ LDFLAGS="$save_LDFLAGS" ++ else ++ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' ++ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' ++ fi ++ archive_cmds_need_lc='no' ++ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' ++ hardcode_libdir_separator=: ++ inherit_rpath=yes ++ link_all_deplibs=yes ++ ;; ++ ++ netbsd*) ++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then ++ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out ++ else ++ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF ++ fi ++ hardcode_libdir_flag_spec='-R$libdir' ++ hardcode_direct=yes ++ hardcode_shlibpath_var=no ++ ;; ++ ++ newsos6) ++ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' ++ hardcode_direct=yes ++ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' ++ hardcode_libdir_separator=: ++ hardcode_shlibpath_var=no ++ ;; ++ ++ *nto* | *qnx*) ++ ;; ++ ++ openbsd*) ++ if test -f /usr/libexec/ld.so; then ++ hardcode_direct=yes ++ hardcode_shlibpath_var=no ++ hardcode_direct_absolute=yes ++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then ++ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ++ archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' ++ hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ++ export_dynamic_flag_spec='${wl}-E' ++ else ++ case $host_os in ++ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) ++ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' ++ hardcode_libdir_flag_spec='-R$libdir' ++ ;; ++ *) ++ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ++ hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ++ ;; ++ esac ++ fi ++ else ++ ld_shlibs=no ++ fi ++ ;; ++ ++ os2*) ++ hardcode_libdir_flag_spec='-L$libdir' ++ hardcode_minus_L=yes ++ allow_undefined_flag=unsupported ++ archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' ++ old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ++ ;; ++ ++ osf3*) ++ if test "$GCC" = yes; then ++ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' ++ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ++ else ++ allow_undefined_flag=' -expect_unresolved \*' ++ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' ++ fi ++ archive_cmds_need_lc='no' ++ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' ++ hardcode_libdir_separator=: ++ ;; ++ ++ osf4* | osf5*) # as osf3* with the addition of -msym flag ++ if test "$GCC" = yes; then ++ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' ++ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ++ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' ++ else ++ allow_undefined_flag=' -expect_unresolved \*' ++ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' ++ archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ ++ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' ++ ++ # Both c and cxx compiler support -rpath directly ++ hardcode_libdir_flag_spec='-rpath $libdir' ++ fi ++ archive_cmds_need_lc='no' ++ hardcode_libdir_separator=: ++ ;; ++ ++ solaris*) ++ no_undefined_flag=' -z defs' ++ if test "$GCC" = yes; then ++ wlarc='${wl}' ++ archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ++ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ ++ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ++ else ++ case `$CC -V 2>&1` in ++ *"Compilers 5.0"*) ++ wlarc='' ++ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' ++ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ ++ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ++ ;; ++ *) ++ wlarc='${wl}' ++ archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' ++ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ ++ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ++ ;; ++ esac ++ fi ++ hardcode_libdir_flag_spec='-R$libdir' ++ hardcode_shlibpath_var=no ++ case $host_os in ++ solaris2.[0-5] | solaris2.[0-5].*) ;; ++ *) ++ # The compiler driver will combine and reorder linker options, ++ # but understands `-z linker_flag'. GCC discards it without `$wl', ++ # but is careful enough not to reorder. ++ # Supported since Solaris 2.6 (maybe 2.5.1?) ++ if test "$GCC" = yes; then ++ whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ++ else ++ whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ++ fi ++ ;; ++ esac ++ link_all_deplibs=yes ++ ;; ++ ++ sunos4*) ++ if test "x$host_vendor" = xsequent; then ++ # Use $CC to link under sequent, because it throws in some extra .o ++ # files that make .init and .fini sections work. ++ archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' ++ else ++ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' ++ fi ++ hardcode_libdir_flag_spec='-L$libdir' ++ hardcode_direct=yes ++ hardcode_minus_L=yes ++ hardcode_shlibpath_var=no ++ ;; ++ ++ sysv4) ++ case $host_vendor in ++ sni) ++ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' ++ hardcode_direct=yes # is this really true??? ++ ;; ++ siemens) ++ ## LD is ld it makes a PLAMLIB ++ ## CC just makes a GrossModule. ++ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' ++ reload_cmds='$CC -r -o $output$reload_objs' ++ hardcode_direct=no ++ ;; ++ motorola) ++ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' ++ hardcode_direct=no #Motorola manual says yes, but my tests say they lie ++ ;; ++ esac ++ runpath_var='LD_RUN_PATH' ++ hardcode_shlibpath_var=no ++ ;; ++ ++ sysv4.3*) ++ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' ++ hardcode_shlibpath_var=no ++ export_dynamic_flag_spec='-Bexport' ++ ;; ++ ++ sysv4*MP*) ++ if test -d /usr/nec; then ++ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' ++ hardcode_shlibpath_var=no ++ runpath_var=LD_RUN_PATH ++ hardcode_runpath_var=yes ++ ld_shlibs=yes ++ fi ++ ;; ++ ++ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) ++ no_undefined_flag='${wl}-z,text' ++ archive_cmds_need_lc=no ++ hardcode_shlibpath_var=no ++ runpath_var='LD_RUN_PATH' ++ ++ if test "$GCC" = yes; then ++ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ++ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ++ else ++ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ++ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ++ fi ++ ;; ++ ++ sysv5* | sco3.2v5* | sco5v6*) ++ # Note: We can NOT use -z defs as we might desire, because we do not ++ # link with -lc, and that would cause any symbols used from libc to ++ # always be unresolved, which means just about no library would ++ # ever link correctly. If we're not using GNU ld we use -z text ++ # though, which does catch some bad symbols but isn't as heavy-handed ++ # as -z defs. ++ no_undefined_flag='${wl}-z,text' ++ allow_undefined_flag='${wl}-z,nodefs' ++ archive_cmds_need_lc=no ++ hardcode_shlibpath_var=no ++ hardcode_libdir_flag_spec='${wl}-R,$libdir' ++ hardcode_libdir_separator=':' ++ link_all_deplibs=yes ++ export_dynamic_flag_spec='${wl}-Bexport' ++ runpath_var='LD_RUN_PATH' ++ ++ if test "$GCC" = yes; then ++ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ++ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ++ else ++ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ++ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ++ fi ++ ;; ++ ++ uts4*) ++ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' ++ hardcode_libdir_flag_spec='-L$libdir' ++ hardcode_shlibpath_var=no ++ ;; ++ ++ *) ++ ld_shlibs=no ++ ;; ++ esac ++ ++ if test x$host_vendor = xsni; then ++ case $host in ++ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) ++ export_dynamic_flag_spec='${wl}-Blargedynsym' ++ ;; ++ esac ++ fi ++ fi ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 ++$as_echo "$ld_shlibs" >&6; } ++test "$ld_shlibs" = no && can_build_shared=no ++ ++with_gnu_ld=$with_gnu_ld ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++# ++# Do we need to explicitly link libc? ++# ++case "x$archive_cmds_need_lc" in ++x|xyes) ++ # Assume -lc should be added ++ archive_cmds_need_lc=yes ++ ++ if test "$enable_shared" = yes && test "$GCC" = yes; then ++ case $archive_cmds in ++ *'~'*) ++ # FIXME: we may have to deal with multi-command sequences. ++ ;; ++ '$CC '*) ++ # Test whether the compiler implicitly links with -lc since on some ++ # systems, -lgcc has to come before -lc. If gcc already passes -lc ++ # to ld, don't add -lc before -lgcc. ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 ++$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } ++if test "${lt_cv_archive_cmds_need_lc+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ $RM conftest* ++ echo "$lt_simple_compile_test_code" > conftest.$ac_ext ++ ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 ++ (eval $ac_compile) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } 2>conftest.err; then ++ soname=conftest ++ lib=conftest ++ libobjs=conftest.$ac_objext ++ deplibs= ++ wl=$lt_prog_compiler_wl ++ pic_flag=$lt_prog_compiler_pic ++ compiler_flags=-v ++ linker_flags=-v ++ verstring= ++ output_objdir=. ++ libname=conftest ++ lt_save_allow_undefined_flag=$allow_undefined_flag ++ allow_undefined_flag= ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 ++ (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } ++ then ++ lt_cv_archive_cmds_need_lc=no ++ else ++ lt_cv_archive_cmds_need_lc=yes ++ fi ++ allow_undefined_flag=$lt_save_allow_undefined_flag ++ else ++ cat conftest.err 1>&5 ++ fi ++ $RM conftest* ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 ++$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } ++ archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ++ ;; ++ esac ++ fi ++ ;; ++esac ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 ++$as_echo_n "checking dynamic linker characteristics... " >&6; } ++ ++if test "$GCC" = yes; then ++ case $host_os in ++ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; ++ *) lt_awk_arg="/^libraries:/" ;; ++ esac ++ case $host_os in ++ mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; ++ *) lt_sed_strip_eq="s,=/,/,g" ;; ++ esac ++ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` ++ case $lt_search_path_spec in ++ *\;*) ++ # if the path contains ";" then we assume it to be the separator ++ # otherwise default to the standard path separator (i.e. ":") - it is ++ # assumed that no part of a normal pathname contains ";" but that should ++ # okay in the real world where ";" in dirpaths is itself problematic. ++ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ++ ;; ++ *) ++ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ++ ;; ++ esac ++ # Ok, now we have the path, separated by spaces, we can step through it ++ # and add multilib dir if necessary. ++ lt_tmp_lt_search_path_spec= ++ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` ++ for lt_sys_path in $lt_search_path_spec; do ++ if test -d "$lt_sys_path/$lt_multi_os_dir"; then ++ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" ++ else ++ test -d "$lt_sys_path" && \ ++ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" ++ fi ++ done ++ lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' ++BEGIN {RS=" "; FS="/|\n";} { ++ lt_foo=""; ++ lt_count=0; ++ for (lt_i = NF; lt_i > 0; lt_i--) { ++ if ($lt_i != "" && $lt_i != ".") { ++ if ($lt_i == "..") { ++ lt_count++; ++ } else { ++ if (lt_count == 0) { ++ lt_foo="/" $lt_i lt_foo; ++ } else { ++ lt_count--; ++ } ++ } ++ } ++ } ++ if (lt_foo != "") { lt_freq[lt_foo]++; } ++ if (lt_freq[lt_foo] == 1) { print lt_foo; } ++}'` ++ # AWK program above erroneously prepends '/' to C:/dos/paths ++ # for these hosts. ++ case $host_os in ++ mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ ++ $SED 's,/\([A-Za-z]:\),\1,g'` ;; ++ esac ++ sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` ++else ++ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" ++fi ++library_names_spec= ++libname_spec='lib$name' ++soname_spec= ++shrext_cmds=".so" ++postinstall_cmds= ++postuninstall_cmds= ++finish_cmds= ++finish_eval= ++shlibpath_var= ++shlibpath_overrides_runpath=unknown ++version_type=none ++dynamic_linker="$host_os ld.so" ++sys_lib_dlsearch_path_spec="/lib /usr/lib" ++need_lib_prefix=unknown ++hardcode_into_libs=no ++ ++# when you set need_version to no, make sure it does not cause -set_version ++# flags to be left without arguments ++need_version=unknown ++ ++case $host_os in ++aix3*) ++ version_type=linux ++ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' ++ shlibpath_var=LIBPATH ++ ++ # AIX 3 has no versioning support, so we append a major version to the name. ++ soname_spec='${libname}${release}${shared_ext}$major' ++ ;; ++ ++aix[4-9]*) ++ version_type=linux ++ need_lib_prefix=no ++ need_version=no ++ hardcode_into_libs=yes ++ if test "$host_cpu" = ia64; then ++ # AIX 5 supports IA64 ++ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' ++ shlibpath_var=LD_LIBRARY_PATH ++ else ++ # With GCC up to 2.95.x, collect2 would create an import file ++ # for dependence libraries. The import file would start with ++ # the line `#! .'. This would cause the generated library to ++ # depend on `.', always an invalid library. This was fixed in ++ # development snapshots of GCC prior to 3.0. ++ case $host_os in ++ aix4 | aix4.[01] | aix4.[01].*) ++ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' ++ echo ' yes ' ++ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then ++ : ++ else ++ can_build_shared=no ++ fi ++ ;; ++ esac ++ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct ++ # soname into executable. Probably we can add versioning support to ++ # collect2, so additional links can be useful in future. ++ if test "$aix_use_runtimelinking" = yes; then ++ # If using run time linking (on AIX 4.2 or later) use lib.so ++ # instead of lib.a to let people know that these are not ++ # typical AIX shared libraries. ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ else ++ # We preserve .a as extension for shared libraries through AIX4.2 ++ # and later when we are not doing run time linking. ++ library_names_spec='${libname}${release}.a $libname.a' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ fi ++ shlibpath_var=LIBPATH ++ fi ++ ;; ++ ++amigaos*) ++ case $host_cpu in ++ powerpc) ++ # Since July 2007 AmigaOS4 officially supports .so libraries. ++ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ ;; ++ m68k) ++ library_names_spec='$libname.ixlibrary $libname.a' ++ # Create ${libname}_ixlibrary.a entries in /sys/libs. ++ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ++ ;; ++ esac ++ ;; ++ ++beos*) ++ library_names_spec='${libname}${shared_ext}' ++ dynamic_linker="$host_os ld.so" ++ shlibpath_var=LIBRARY_PATH ++ ;; ++ ++bsdi[45]*) ++ version_type=linux ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' ++ shlibpath_var=LD_LIBRARY_PATH ++ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" ++ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" ++ # the default ld.so.conf also contains /usr/contrib/lib and ++ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow ++ # libtool to hard-code these into programs ++ ;; ++ ++cygwin* | mingw* | pw32* | cegcc*) ++ version_type=windows ++ shrext_cmds=".dll" ++ need_version=no ++ need_lib_prefix=no ++ ++ case $GCC,$host_os in ++ yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) ++ library_names_spec='$libname.dll.a' ++ # DLL is installed to $(libdir)/../bin by postinstall_cmds ++ postinstall_cmds='base_file=`basename \${file}`~ ++ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ ++ dldir=$destdir/`dirname \$dlpath`~ ++ test -d \$dldir || mkdir -p \$dldir~ ++ $install_prog $dir/$dlname \$dldir/$dlname~ ++ chmod a+x \$dldir/$dlname~ ++ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then ++ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; ++ fi' ++ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ ++ dlpath=$dir/\$dldll~ ++ $RM \$dlpath' ++ shlibpath_overrides_runpath=yes ++ ++ case $host_os in ++ cygwin*) ++ # Cygwin DLLs use 'cyg' prefix rather than 'lib' ++ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ++ ++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ++ ;; ++ mingw* | cegcc*) ++ # MinGW DLLs use traditional 'lib' prefix ++ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ++ ;; ++ pw32*) ++ # pw32 DLLs use 'pw' prefix rather than 'lib' ++ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ++ ;; ++ esac ++ ;; ++ ++ *) ++ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' ++ ;; ++ esac ++ dynamic_linker='Win32 ld.exe' ++ # FIXME: first we should search . and the directory the executable is in ++ shlibpath_var=PATH ++ ;; ++ ++darwin* | rhapsody*) ++ dynamic_linker="$host_os dyld" ++ version_type=darwin ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' ++ soname_spec='${libname}${release}${major}$shared_ext' ++ shlibpath_overrides_runpath=yes ++ shlibpath_var=DYLD_LIBRARY_PATH ++ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' ++ ++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" ++ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ++ ;; ++ ++dgux*) ++ version_type=linux ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ shlibpath_var=LD_LIBRARY_PATH ++ ;; ++ ++freebsd* | dragonfly*) ++ # DragonFly does not have aout. When/if they implement a new ++ # versioning mechanism, adjust this. ++ if test -x /usr/bin/objformat; then ++ objformat=`/usr/bin/objformat` ++ else ++ case $host_os in ++ freebsd[23].*) objformat=aout ;; ++ *) objformat=elf ;; ++ esac ++ fi ++ version_type=freebsd-$objformat ++ case $version_type in ++ freebsd-elf*) ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' ++ need_version=no ++ need_lib_prefix=no ++ ;; ++ freebsd-*) ++ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' ++ need_version=yes ++ ;; ++ esac ++ shlibpath_var=LD_LIBRARY_PATH ++ case $host_os in ++ freebsd2.*) ++ shlibpath_overrides_runpath=yes ++ ;; ++ freebsd3.[01]* | freebsdelf3.[01]*) ++ shlibpath_overrides_runpath=yes ++ hardcode_into_libs=yes ++ ;; ++ freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ ++ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) ++ shlibpath_overrides_runpath=no ++ hardcode_into_libs=yes ++ ;; ++ *) # from 4.6 on, and DragonFly ++ shlibpath_overrides_runpath=yes ++ hardcode_into_libs=yes ++ ;; ++ esac ++ ;; ++ ++gnu*) ++ version_type=linux ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ shlibpath_var=LD_LIBRARY_PATH ++ hardcode_into_libs=yes ++ ;; ++ ++haiku*) ++ version_type=linux ++ need_lib_prefix=no ++ need_version=no ++ dynamic_linker="$host_os runtime_loader" ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ shlibpath_var=LIBRARY_PATH ++ shlibpath_overrides_runpath=yes ++ sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib' ++ hardcode_into_libs=yes ++ ;; ++ ++hpux9* | hpux10* | hpux11*) ++ # Give a soname corresponding to the major version so that dld.sl refuses to ++ # link against other versions. ++ version_type=sunos ++ need_lib_prefix=no ++ need_version=no ++ case $host_cpu in ++ ia64*) ++ shrext_cmds='.so' ++ hardcode_into_libs=yes ++ dynamic_linker="$host_os dld.so" ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ if test "X$HPUX_IA64_MODE" = X32; then ++ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" ++ else ++ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" ++ fi ++ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ++ ;; ++ hppa*64*) ++ shrext_cmds='.sl' ++ hardcode_into_libs=yes ++ dynamic_linker="$host_os dld.sl" ++ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH ++ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" ++ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ++ ;; ++ *) ++ shrext_cmds='.sl' ++ dynamic_linker="$host_os dld.sl" ++ shlibpath_var=SHLIB_PATH ++ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ ;; ++ esac ++ # HP-UX runs *really* slowly unless shared libraries are mode 555, ... ++ postinstall_cmds='chmod 555 $lib' ++ # or fails outright, so override atomically: ++ install_override_mode=555 ++ ;; ++ ++interix[3-9]*) ++ version_type=linux ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=no ++ hardcode_into_libs=yes ++ ;; ++ ++irix5* | irix6* | nonstopux*) ++ case $host_os in ++ nonstopux*) version_type=nonstopux ;; ++ *) ++ if test "$lt_cv_prog_gnu_ld" = yes; then ++ version_type=linux ++ else ++ version_type=irix ++ fi ;; ++ esac ++ need_lib_prefix=no ++ need_version=no ++ soname_spec='${libname}${release}${shared_ext}$major' ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' ++ case $host_os in ++ irix5* | nonstopux*) ++ libsuff= shlibsuff= ++ ;; ++ *) ++ case $LD in # libtool.m4 will add one of these switches to LD ++ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") ++ libsuff= shlibsuff= libmagic=32-bit;; ++ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") ++ libsuff=32 shlibsuff=N32 libmagic=N32;; ++ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") ++ libsuff=64 shlibsuff=64 libmagic=64-bit;; ++ *) libsuff= shlibsuff= libmagic=never-match;; ++ esac ++ ;; ++ esac ++ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH ++ shlibpath_overrides_runpath=no ++ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" ++ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" ++ hardcode_into_libs=yes ++ ;; ++ ++# No shared lib support for Linux oldld, aout, or coff. ++linux*oldld* | linux*aout* | linux*coff*) ++ dynamic_linker=no ++ ;; ++ ++# This must be Linux ELF. ++linux* | k*bsd*-gnu | kopensolaris*-gnu) ++ version_type=linux ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=no ++ ++ # Some binutils ld are patched to set DT_RUNPATH ++ if test "${lt_cv_shlibpath_overrides_runpath+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ lt_cv_shlibpath_overrides_runpath=no ++ save_LDFLAGS=$LDFLAGS ++ save_libdir=$libdir ++ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ ++ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : ++ lt_cv_shlibpath_overrides_runpath=yes ++fi ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++ LDFLAGS=$save_LDFLAGS ++ libdir=$save_libdir ++ ++fi ++ ++ shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath ++ ++ # This implies no fast_install, which is unacceptable. ++ # Some rework will be needed to allow for fast_install ++ # before this can be enabled. ++ hardcode_into_libs=yes ++ ++ # Append ld.so.conf contents to the search path ++ if test -f /etc/ld.so.conf; then ++ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` ++ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" ++ fi ++ ++ # We used to test for /lib/ld.so.1 and disable shared libraries on ++ # powerpc, because MkLinux only supported shared libraries with the ++ # GNU dynamic linker. Since this was broken with cross compilers, ++ # most powerpc-linux boxes support dynamic linking these days and ++ # people can always --disable-shared, the test was removed, and we ++ # assume the GNU/Linux dynamic linker is in use. ++ dynamic_linker='GNU/Linux ld.so' ++ ;; ++ ++netbsd*) ++ version_type=sunos ++ need_lib_prefix=no ++ need_version=no ++ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' ++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' ++ dynamic_linker='NetBSD (a.out) ld.so' ++ else ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ dynamic_linker='NetBSD ld.elf_so' ++ fi ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=yes ++ hardcode_into_libs=yes ++ ;; ++ ++newsos6) ++ version_type=linux ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=yes ++ ;; ++ ++*nto* | *qnx*) ++ version_type=qnx ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=no ++ hardcode_into_libs=yes ++ dynamic_linker='ldqnx.so' ++ ;; ++ ++openbsd*) ++ version_type=sunos ++ sys_lib_dlsearch_path_spec="/usr/lib" ++ need_lib_prefix=no ++ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. ++ case $host_os in ++ openbsd3.3 | openbsd3.3.*) need_version=yes ;; ++ *) need_version=no ;; ++ esac ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' ++ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' ++ shlibpath_var=LD_LIBRARY_PATH ++ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then ++ case $host_os in ++ openbsd2.[89] | openbsd2.[89].*) ++ shlibpath_overrides_runpath=no ++ ;; ++ *) ++ shlibpath_overrides_runpath=yes ++ ;; ++ esac ++ else ++ shlibpath_overrides_runpath=yes ++ fi ++ ;; ++ ++os2*) ++ libname_spec='$name' ++ shrext_cmds=".dll" ++ need_lib_prefix=no ++ library_names_spec='$libname${shared_ext} $libname.a' ++ dynamic_linker='OS/2 ld.exe' ++ shlibpath_var=LIBPATH ++ ;; ++ ++osf3* | osf4* | osf5*) ++ version_type=osf ++ need_lib_prefix=no ++ need_version=no ++ soname_spec='${libname}${release}${shared_ext}$major' ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ shlibpath_var=LD_LIBRARY_PATH ++ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" ++ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ++ ;; ++ ++rdos*) ++ dynamic_linker=no ++ ;; ++ ++solaris*) ++ version_type=linux ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=yes ++ hardcode_into_libs=yes ++ # ldd complains unless libraries are executable ++ postinstall_cmds='chmod +x $lib' ++ ;; ++ ++sunos4*) ++ version_type=sunos ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' ++ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=yes ++ if test "$with_gnu_ld" = yes; then ++ need_lib_prefix=no ++ fi ++ need_version=yes ++ ;; ++ ++sysv4 | sysv4.3*) ++ version_type=linux ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ shlibpath_var=LD_LIBRARY_PATH ++ case $host_vendor in ++ sni) ++ shlibpath_overrides_runpath=no ++ need_lib_prefix=no ++ runpath_var=LD_RUN_PATH ++ ;; ++ siemens) ++ need_lib_prefix=no ++ ;; ++ motorola) ++ need_lib_prefix=no ++ need_version=no ++ shlibpath_overrides_runpath=no ++ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ++ ;; ++ esac ++ ;; ++ ++sysv4*MP*) ++ if test -d /usr/nec ;then ++ version_type=linux ++ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' ++ soname_spec='$libname${shared_ext}.$major' ++ shlibpath_var=LD_LIBRARY_PATH ++ fi ++ ;; ++ ++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) ++ version_type=freebsd-elf ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=yes ++ hardcode_into_libs=yes ++ if test "$with_gnu_ld" = yes; then ++ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' ++ else ++ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' ++ case $host_os in ++ sco3.2v5*) ++ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ++ ;; ++ esac ++ fi ++ sys_lib_dlsearch_path_spec='/usr/lib' ++ ;; ++ ++tpf*) ++ # TPF is a cross-target only. Preferred cross-host = GNU/Linux. ++ version_type=linux ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=no ++ hardcode_into_libs=yes ++ ;; ++ ++uts4*) ++ version_type=linux ++ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ++ soname_spec='${libname}${release}${shared_ext}$major' ++ shlibpath_var=LD_LIBRARY_PATH ++ ;; ++ ++*) ++ dynamic_linker=no ++ ;; ++esac ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 ++$as_echo "$dynamic_linker" >&6; } ++test "$dynamic_linker" = no && can_build_shared=no ++ ++variables_saved_for_relink="PATH $shlibpath_var $runpath_var" ++if test "$GCC" = yes; then ++ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" ++fi ++ ++if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then ++ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" ++fi ++if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then ++ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" ++fi ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 ++$as_echo_n "checking how to hardcode library paths into programs... " >&6; } ++hardcode_action= ++if test -n "$hardcode_libdir_flag_spec" || ++ test -n "$runpath_var" || ++ test "X$hardcode_automatic" = "Xyes" ; then ++ ++ # We can hardcode non-existent directories. ++ if test "$hardcode_direct" != no && ++ # If the only mechanism to avoid hardcoding is shlibpath_var, we ++ # have to relink, otherwise we might link with an installed library ++ # when we should be linking with a yet-to-be-installed one ++ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && ++ test "$hardcode_minus_L" != no; then ++ # Linking always hardcodes the temporary library directory. ++ hardcode_action=relink ++ else ++ # We can link without hardcoding, and we can hardcode nonexisting dirs. ++ hardcode_action=immediate ++ fi ++else ++ # We cannot hardcode anything, or else we can only hardcode existing ++ # directories. ++ hardcode_action=unsupported ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 ++$as_echo "$hardcode_action" >&6; } ++ ++if test "$hardcode_action" = relink || ++ test "$inherit_rpath" = yes; then ++ # Fast installation is not supported ++ enable_fast_install=no ++elif test "$shlibpath_overrides_runpath" = yes || ++ test "$enable_shared" = no; then ++ # Fast installation is not necessary ++ enable_fast_install=needless ++fi ++ ++ ++ ++ ++ ++ ++ if test "x$enable_dlopen" != xyes; then ++ enable_dlopen=unknown ++ enable_dlopen_self=unknown ++ enable_dlopen_self_static=unknown ++else ++ lt_cv_dlopen=no ++ lt_cv_dlopen_libs= ++ ++ case $host_os in ++ beos*) ++ lt_cv_dlopen="load_add_on" ++ lt_cv_dlopen_libs= ++ lt_cv_dlopen_self=yes ++ ;; ++ ++ mingw* | pw32* | cegcc*) ++ lt_cv_dlopen="LoadLibrary" ++ lt_cv_dlopen_libs= ++ ;; ++ ++ cygwin*) ++ lt_cv_dlopen="dlopen" ++ lt_cv_dlopen_libs= ++ ;; ++ ++ darwin*) ++ # if libdl is installed we need to link against it ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 ++$as_echo_n "checking for dlopen in -ldl... " >&6; } ++if test "${ac_cv_lib_dl_dlopen+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-ldl $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char dlopen (); ++int ++main () ++{ ++return dlopen (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_dl_dlopen=yes ++else ++ ac_cv_lib_dl_dlopen=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 ++$as_echo "$ac_cv_lib_dl_dlopen" >&6; } ++if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : ++ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" ++else ++ ++ lt_cv_dlopen="dyld" ++ lt_cv_dlopen_libs= ++ lt_cv_dlopen_self=yes ++ ++fi ++ ++ ;; ++ ++ *) ++ ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" ++if test "x$ac_cv_func_shl_load" = x""yes; then : ++ lt_cv_dlopen="shl_load" ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 ++$as_echo_n "checking for shl_load in -ldld... " >&6; } ++if test "${ac_cv_lib_dld_shl_load+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-ldld $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char shl_load (); ++int ++main () ++{ ++return shl_load (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_dld_shl_load=yes ++else ++ ac_cv_lib_dld_shl_load=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 ++$as_echo "$ac_cv_lib_dld_shl_load" >&6; } ++if test "x$ac_cv_lib_dld_shl_load" = x""yes; then : ++ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" ++else ++ ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" ++if test "x$ac_cv_func_dlopen" = x""yes; then : ++ lt_cv_dlopen="dlopen" ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 ++$as_echo_n "checking for dlopen in -ldl... " >&6; } ++if test "${ac_cv_lib_dl_dlopen+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-ldl $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char dlopen (); ++int ++main () ++{ ++return dlopen (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_dl_dlopen=yes ++else ++ ac_cv_lib_dl_dlopen=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 ++$as_echo "$ac_cv_lib_dl_dlopen" >&6; } ++if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : ++ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 ++$as_echo_n "checking for dlopen in -lsvld... " >&6; } ++if test "${ac_cv_lib_svld_dlopen+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-lsvld $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char dlopen (); ++int ++main () ++{ ++return dlopen (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_svld_dlopen=yes ++else ++ ac_cv_lib_svld_dlopen=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 ++$as_echo "$ac_cv_lib_svld_dlopen" >&6; } ++if test "x$ac_cv_lib_svld_dlopen" = x""yes; then : ++ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 ++$as_echo_n "checking for dld_link in -ldld... " >&6; } ++if test "${ac_cv_lib_dld_dld_link+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ac_check_lib_save_LIBS=$LIBS ++LIBS="-ldld $LIBS" ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++/* Override any GCC internal prototype to avoid an error. ++ Use char because int might match the return type of a GCC ++ builtin and then its argument prototype would still apply. */ ++#ifdef __cplusplus ++extern "C" ++#endif ++char dld_link (); ++int ++main () ++{ ++return dld_link (); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ ac_cv_lib_dld_dld_link=yes ++else ++ ac_cv_lib_dld_dld_link=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++LIBS=$ac_check_lib_save_LIBS ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 ++$as_echo "$ac_cv_lib_dld_dld_link" >&6; } ++if test "x$ac_cv_lib_dld_dld_link" = x""yes; then : ++ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" ++fi ++ ++ ++fi ++ ++ ++fi ++ ++ ++fi ++ ++ ++fi ++ ++ ++fi ++ ++ ;; ++ esac ++ ++ if test "x$lt_cv_dlopen" != xno; then ++ enable_dlopen=yes ++ else ++ enable_dlopen=no ++ fi ++ ++ case $lt_cv_dlopen in ++ dlopen) ++ save_CPPFLAGS="$CPPFLAGS" ++ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" ++ ++ save_LDFLAGS="$LDFLAGS" ++ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" ++ ++ save_LIBS="$LIBS" ++ LIBS="$lt_cv_dlopen_libs $LIBS" ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 ++$as_echo_n "checking whether a program can dlopen itself... " >&6; } ++if test "${lt_cv_dlopen_self+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test "$cross_compiling" = yes; then : ++ lt_cv_dlopen_self=cross ++else ++ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 ++ lt_status=$lt_dlunknown ++ cat > conftest.$ac_ext <<_LT_EOF ++#line 11134 "configure" ++#include "confdefs.h" ++ ++#if HAVE_DLFCN_H ++#include ++#endif ++ ++#include ++ ++#ifdef RTLD_GLOBAL ++# define LT_DLGLOBAL RTLD_GLOBAL ++#else ++# ifdef DL_GLOBAL ++# define LT_DLGLOBAL DL_GLOBAL ++# else ++# define LT_DLGLOBAL 0 ++# endif ++#endif ++ ++/* We may have to define LT_DLLAZY_OR_NOW in the command line if we ++ find out it does not work in some platform. */ ++#ifndef LT_DLLAZY_OR_NOW ++# ifdef RTLD_LAZY ++# define LT_DLLAZY_OR_NOW RTLD_LAZY ++# else ++# ifdef DL_LAZY ++# define LT_DLLAZY_OR_NOW DL_LAZY ++# else ++# ifdef RTLD_NOW ++# define LT_DLLAZY_OR_NOW RTLD_NOW ++# else ++# ifdef DL_NOW ++# define LT_DLLAZY_OR_NOW DL_NOW ++# else ++# define LT_DLLAZY_OR_NOW 0 ++# endif ++# endif ++# endif ++# endif ++#endif ++ ++/* When -fvisbility=hidden is used, assume the code has been annotated ++ correspondingly for the symbols needed. */ ++#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) ++void fnord () __attribute__((visibility("default"))); ++#endif ++ ++void fnord () { int i=42; } ++int main () ++{ ++ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); ++ int status = $lt_dlunknown; ++ ++ if (self) ++ { ++ if (dlsym (self,"fnord")) status = $lt_dlno_uscore; ++ else ++ { ++ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; ++ else puts (dlerror ()); ++ } ++ /* dlclose (self); */ ++ } ++ else ++ puts (dlerror ()); ++ ++ return status; ++} ++_LT_EOF ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 ++ (eval $ac_link) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then ++ (./conftest; exit; ) >&5 2>/dev/null ++ lt_status=$? ++ case x$lt_status in ++ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; ++ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; ++ x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; ++ esac ++ else : ++ # compilation failed ++ lt_cv_dlopen_self=no ++ fi ++fi ++rm -fr conftest* ++ ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 ++$as_echo "$lt_cv_dlopen_self" >&6; } ++ ++ if test "x$lt_cv_dlopen_self" = xyes; then ++ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 ++$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } ++if test "${lt_cv_dlopen_self_static+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test "$cross_compiling" = yes; then : ++ lt_cv_dlopen_self_static=cross ++else ++ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 ++ lt_status=$lt_dlunknown ++ cat > conftest.$ac_ext <<_LT_EOF ++#line 11240 "configure" ++#include "confdefs.h" ++ ++#if HAVE_DLFCN_H ++#include ++#endif ++ ++#include ++ ++#ifdef RTLD_GLOBAL ++# define LT_DLGLOBAL RTLD_GLOBAL ++#else ++# ifdef DL_GLOBAL ++# define LT_DLGLOBAL DL_GLOBAL ++# else ++# define LT_DLGLOBAL 0 ++# endif ++#endif ++ ++/* We may have to define LT_DLLAZY_OR_NOW in the command line if we ++ find out it does not work in some platform. */ ++#ifndef LT_DLLAZY_OR_NOW ++# ifdef RTLD_LAZY ++# define LT_DLLAZY_OR_NOW RTLD_LAZY ++# else ++# ifdef DL_LAZY ++# define LT_DLLAZY_OR_NOW DL_LAZY ++# else ++# ifdef RTLD_NOW ++# define LT_DLLAZY_OR_NOW RTLD_NOW ++# else ++# ifdef DL_NOW ++# define LT_DLLAZY_OR_NOW DL_NOW ++# else ++# define LT_DLLAZY_OR_NOW 0 ++# endif ++# endif ++# endif ++# endif ++#endif ++ ++/* When -fvisbility=hidden is used, assume the code has been annotated ++ correspondingly for the symbols needed. */ ++#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) ++void fnord () __attribute__((visibility("default"))); ++#endif ++ ++void fnord () { int i=42; } ++int main () ++{ ++ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); ++ int status = $lt_dlunknown; ++ ++ if (self) ++ { ++ if (dlsym (self,"fnord")) status = $lt_dlno_uscore; ++ else ++ { ++ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; ++ else puts (dlerror ()); ++ } ++ /* dlclose (self); */ ++ } ++ else ++ puts (dlerror ()); ++ ++ return status; ++} ++_LT_EOF ++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 ++ (eval $ac_link) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then ++ (./conftest; exit; ) >&5 2>/dev/null ++ lt_status=$? ++ case x$lt_status in ++ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; ++ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; ++ x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; ++ esac ++ else : ++ # compilation failed ++ lt_cv_dlopen_self_static=no ++ fi ++fi ++rm -fr conftest* ++ ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 ++$as_echo "$lt_cv_dlopen_self_static" >&6; } ++ fi ++ ++ CPPFLAGS="$save_CPPFLAGS" ++ LDFLAGS="$save_LDFLAGS" ++ LIBS="$save_LIBS" ++ ;; ++ esac ++ ++ case $lt_cv_dlopen_self in ++ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; ++ *) enable_dlopen_self=unknown ;; ++ esac ++ ++ case $lt_cv_dlopen_self_static in ++ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; ++ *) enable_dlopen_self_static=unknown ;; ++ esac ++fi ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++striplib= ++old_striplib= ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 ++$as_echo_n "checking whether stripping libraries is possible... " >&6; } ++if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then ++ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" ++ test -z "$striplib" && striplib="$STRIP --strip-unneeded" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++else ++# FIXME - insert some real tests, host_os isn't really good enough ++ case $host_os in ++ darwin*) ++ if test -n "$STRIP" ; then ++ striplib="$STRIP -x" ++ old_striplib="$STRIP -S" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 ++$as_echo "yes" >&6; } ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ fi ++ ;; ++ *) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++ ;; ++ esac ++fi ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ # Report which library types will actually be built ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 ++$as_echo_n "checking if libtool supports shared libraries... " >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 ++$as_echo "$can_build_shared" >&6; } ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 ++$as_echo_n "checking whether to build shared libraries... " >&6; } ++ test "$can_build_shared" = "no" && enable_shared=no ++ ++ # On AIX, shared libraries and static libraries use the same namespace, and ++ # are all built from PIC. ++ case $host_os in ++ aix3*) ++ test "$enable_shared" = yes && enable_static=no ++ if test -n "$RANLIB"; then ++ archive_cmds="$archive_cmds~\$RANLIB \$lib" ++ postinstall_cmds='$RANLIB $lib' ++ fi ++ ;; ++ ++ aix[4-9]*) ++ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then ++ test "$enable_shared" = yes && enable_static=no ++ fi ++ ;; ++ esac ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 ++$as_echo "$enable_shared" >&6; } ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 ++$as_echo_n "checking whether to build static libraries... " >&6; } ++ # Make sure either enable_shared or enable_static is yes. ++ test "$enable_shared" = yes || enable_static=yes ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 ++$as_echo "$enable_static" >&6; } ++ ++ ++ ++ ++fi ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++CC="$lt_save_CC" ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ac_config_commands="$ac_config_commands libtool" ++ ++ ++ ++ ++# Only expand once: ++ ++ ++ ++ ++backtrace_supported=yes ++ ++if test -n "${with_target_subdir}"; then ++ # We are compiling a GCC library. We can assume that the unwind ++ # library exists. ++ BACKTRACE_FILE="backtrace.lo simple.lo" ++else ++ ac_fn_c_check_header_mongrel "$LINENO" "unwind.h" "ac_cv_header_unwind_h" "$ac_includes_default" ++if test "x$ac_cv_header_unwind_h" = x""yes; then : ++ ac_fn_c_check_func "$LINENO" "_Unwind_Backtrace" "ac_cv_func__Unwind_Backtrace" ++if test "x$ac_cv_func__Unwind_Backtrace" = x""yes; then : ++ BACKTRACE_FILE="backtrace.lo simple.lo" ++else ++ BACKTRACE_FILE="nounwind.lo" ++ backtrace_supported=no ++fi ++ ++else ++ BACKTRACE_FILE="nounwind.lo" ++ backtrace_supported=no ++fi ++ ++ ++fi ++ ++ ++EXTRA_FLAGS= ++if test -n "${with_target_subdir}"; then ++ EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@" ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -funwind-tables option" >&5 ++$as_echo_n "checking for -funwind-tables option... " >&6; } ++if test "${libbacktrace_cv_c_unwind_tables+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ CFLAGS_hold="$CFLAGS" ++ CFLAGS="$CFLAGS -funwind-tables" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++static int f() { return 0; } ++int ++main () ++{ ++return f(); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ libbacktrace_cv_c_unwind_tables=yes ++else ++ libbacktrace_cv_c_unwind_tables=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ CFLAGS="$CFLAGS_hold" ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_c_unwind_tables" >&5 ++$as_echo "$libbacktrace_cv_c_unwind_tables" >&6; } ++ if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then ++ EXTRA_FLAGS=-funwind-tables ++ fi ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -frandom-seed=string option" >&5 ++$as_echo_n "checking for -frandom-seed=string option... " >&6; } ++if test "${libbacktrace_cv_c_random_seed_string+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ CFLAGS_hold="$CFLAGS" ++ CFLAGS="$CFLAGS -frandom-seed=conftest.lo" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++return 0; ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ libbacktrace_cv_c_random_seed_string=yes ++else ++ libbacktrace_cv_c_random_seed_string=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ CFLAGS="$CFLAGS_hold" ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_c_random_seed_string" >&5 ++$as_echo "$libbacktrace_cv_c_random_seed_string" >&6; } ++ if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then ++ EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@" ++ fi ++fi ++ ++ ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++WARN_FLAGS= ++save_CFLAGS="$CFLAGS" ++for real_option in -W -Wall -Wwrite-strings -Wstrict-prototypes \ ++ -Wmissing-prototypes -Wold-style-definition \ ++ -Wmissing-format-attribute -Wcast-qual; do ++ # Do the check with the no- prefix removed since gcc silently ++ # accepts any -Wno-* option on purpose ++ case $real_option in ++ -Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;; ++ *) option=$real_option ;; ++ esac ++ as_acx_Woption=`$as_echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh` ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports $option" >&5 ++$as_echo_n "checking whether $CC supports $option... " >&6; } ++if { as_var=$as_acx_Woption; eval "test \"\${$as_var+set}\" = set"; }; then : ++ $as_echo_n "(cached) " >&6 ++else ++ CFLAGS="$option" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ eval "$as_acx_Woption=yes" ++else ++ eval "$as_acx_Woption=no" ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ ++fi ++eval ac_res=\$$as_acx_Woption ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 ++$as_echo "$ac_res" >&6; } ++ if test `eval 'as_val=${'$as_acx_Woption'};$as_echo "$as_val"'` = yes; then : ++ WARN_FLAGS="$WARN_FLAGS${WARN_FLAGS:+ }$real_option" ++fi ++ done ++CFLAGS="$save_CFLAGS" ++ac_ext=c ++ac_cpp='$CPP $CPPFLAGS' ++ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ++ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ++ac_compiler_gnu=$ac_cv_c_compiler_gnu ++ ++ ++ ++if test -n "${with_target_subdir}"; then ++ WARN_FLAGS="$WARN_FLAGS -Werror" ++fi ++ ++ ++ ++if test -n "${with_target_subdir}"; then ++ ++ ++# Check whether --with-system-libunwind was given. ++if test "${with_system_libunwind+set}" = set; then : ++ withval=$with_system_libunwind; ++fi ++ ++ # If system-libunwind was not specifically set, pick a default setting. ++ if test x$with_system_libunwind = x; then ++ case ${target} in ++ ia64-*-hpux*) with_system_libunwind=yes ;; ++ *) with_system_libunwind=no ;; ++ esac ++ fi ++ # Based on system-libunwind and target, do we have ipinfo? ++ if test x$with_system_libunwind = xyes; then ++ case ${target} in ++ ia64-*-*) have_unwind_getipinfo=no ;; ++ *) have_unwind_getipinfo=yes ;; ++ esac ++ else ++ # Darwin before version 9 does not have _Unwind_GetIPInfo. ++ ++ case ${target} in ++ *-*-darwin[3-8]|*-*-darwin[3-8].*) have_unwind_getipinfo=no ;; ++ *) have_unwind_getipinfo=yes ;; ++ esac ++ ++ fi ++ ++ if test x$have_unwind_getipinfo = xyes; then ++ ++$as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h ++ ++ fi ++ ++else ++ ac_save_CFFLAGS="$CFLAGS" ++ CFLAGS="$CFLAGS -Werror-implicit-function-declaration" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _Unwind_GetIPInfo" >&5 ++$as_echo_n "checking for _Unwind_GetIPInfo... " >&6; } ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include "unwind.h" ++ struct _Unwind_Context *context; ++ int ip_before_insn = 0; ++int ++main () ++{ ++return _Unwind_GetIPInfo (context, &ip_before_insn); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ have_unwind_getipinfo=yes ++else ++ have_unwind_getipinfo=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++ CFLAGS="$ac_save_CFLAGS" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_unwind_getipinfo" >&5 ++$as_echo "$have_unwind_getipinfo" >&6; } ++ if test "$have_unwind_getipinfo" = "yes"; then ++ ++$as_echo "#define HAVE_GETIPINFO 1" >>confdefs.h ++ ++ fi ++fi ++ ++# Enable --enable-host-shared. ++# Check whether --enable-host-shared was given. ++if test "${enable_host_shared+set}" = set; then : ++ enableval=$enable_host_shared; PIC_FLAG=-fPIC ++else ++ PIC_FLAG= ++fi ++ ++ ++ ++# Test for __sync support. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking __sync extensions" >&5 ++$as_echo_n "checking __sync extensions... " >&6; } ++if test "${libbacktrace_cv_sys_sync+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "${with_target_subdir}"; then ++ case "${host}" in ++ hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;; ++ *) libbacktrace_cv_sys_sync=yes ;; ++ esac ++ else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++int i; ++int ++main () ++{ ++__sync_bool_compare_and_swap (&i, i, i); ++ __sync_lock_test_and_set (&i, 1); ++ __sync_lock_release (&i); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ libbacktrace_cv_sys_sync=yes ++else ++ libbacktrace_cv_sys_sync=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_sys_sync" >&5 ++$as_echo "$libbacktrace_cv_sys_sync" >&6; } ++BACKTRACE_SUPPORTS_THREADS=0 ++if test "$libbacktrace_cv_sys_sync" = "yes"; then ++ BACKTRACE_SUPPORTS_THREADS=1 ++ ++$as_echo "#define HAVE_SYNC_FUNCTIONS 1" >>confdefs.h ++ ++fi ++ ++ ++# Test for __atomic support. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking __atomic extensions" >&5 ++$as_echo_n "checking __atomic extensions... " >&6; } ++if test "${libbacktrace_cv_sys_atomic+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test -n "${with_target_subdir}"; then ++ libbacktrace_cv_sys_atomic=yes ++ else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++int i; ++int ++main () ++{ ++__atomic_load_n (&i, __ATOMIC_ACQUIRE); ++ __atomic_store_n (&i, 1, __ATOMIC_RELEASE); ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_link "$LINENO"; then : ++ libbacktrace_cv_sys_atomic=yes ++else ++ libbacktrace_cv_sys_atomic=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_sys_atomic" >&5 ++$as_echo "$libbacktrace_cv_sys_atomic" >&6; } ++if test "$libbacktrace_cv_sys_atomic" = "yes"; then ++ ++$as_echo "#define HAVE_ATOMIC_FUNCTIONS 1" >>confdefs.h ++ ++fi ++ ++# The library needs to be able to read the executable itself. Compile ++# a file to determine the executable format. The awk script ++# filetype.awk prints out the file type. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking output filetype" >&5 ++$as_echo_n "checking output filetype... " >&6; } ++if test "${libbacktrace_cv_sys_filetype+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ filetype= ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++int i; ++int ++main () ++{ ++int j; ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext` ++else ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error "compiler failed ++See \`config.log' for more details." "$LINENO" 5; } ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++libbacktrace_cv_sys_filetype=$filetype ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_sys_filetype" >&5 ++$as_echo "$libbacktrace_cv_sys_filetype" >&6; } ++ ++# Match the file type to decide what files to compile. ++FORMAT_FILE= ++backtrace_supports_data=yes ++case "$libbacktrace_cv_sys_filetype" in ++elf*) FORMAT_FILE="elf.lo" ;; ++pecoff) FORMAT_FILE="pecoff.lo" ++ backtrace_supports_data=no ++ ;; ++*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not determine output file type" >&5 ++$as_echo "$as_me: WARNING: could not determine output file type" >&2;} ++ FORMAT_FILE="unknown.lo" ++ backtrace_supported=no ++ ;; ++esac ++ ++ ++# ELF defines. ++elfsize= ++case "$libbacktrace_cv_sys_filetype" in ++elf32) elfsize=32 ;; ++elf64) elfsize=64 ;; ++*) elfsize=unused ++esac ++ ++cat >>confdefs.h <<_ACEOF ++#define BACKTRACE_ELF_SIZE $elfsize ++_ACEOF ++ ++ ++BACKTRACE_SUPPORTED=0 ++if test "$backtrace_supported" = "yes"; then ++ BACKTRACE_SUPPORTED=1 ++fi ++ ++ ++BACKTRACE_SUPPORTS_DATA=0 ++if test "$backtrace_supports_data" = "yes"; then ++ BACKTRACE_SUPPORTS_DATA=1 ++fi ++ ++ ++ ++ ++inttype_headers=`echo inttypes.h sys/inttypes.h | sed -e 's/,/ /g'` ++ ++acx_cv_header_stdint=stddef.h ++acx_cv_header_stdint_kind="(already complete)" ++for i in stdint.h $inttype_headers; do ++ unset ac_cv_type_uintptr_t ++ unset ac_cv_type_uintmax_t ++ unset ac_cv_type_int_least32_t ++ unset ac_cv_type_int_fast32_t ++ unset ac_cv_type_uint64_t ++ $as_echo_n "looking for a compliant stdint.h in $i, " >&6 ++ ac_fn_c_check_type "$LINENO" "uintmax_t" "ac_cv_type_uintmax_t" "#include ++#include <$i> ++" ++if test "x$ac_cv_type_uintmax_t" = x""yes; then : ++ acx_cv_header_stdint=$i ++else ++ continue ++fi ++ ++ ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "#include ++#include <$i> ++" ++if test "x$ac_cv_type_uintptr_t" = x""yes; then : ++ ++else ++ acx_cv_header_stdint_kind="(mostly complete)" ++fi ++ ++ ac_fn_c_check_type "$LINENO" "int_least32_t" "ac_cv_type_int_least32_t" "#include ++#include <$i> ++" ++if test "x$ac_cv_type_int_least32_t" = x""yes; then : ++ ++else ++ acx_cv_header_stdint_kind="(mostly complete)" ++fi ++ ++ ac_fn_c_check_type "$LINENO" "int_fast32_t" "ac_cv_type_int_fast32_t" "#include ++#include <$i> ++" ++if test "x$ac_cv_type_int_fast32_t" = x""yes; then : ++ ++else ++ acx_cv_header_stdint_kind="(mostly complete)" ++fi ++ ++ ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "#include ++#include <$i> ++" ++if test "x$ac_cv_type_uint64_t" = x""yes; then : ++ ++else ++ acx_cv_header_stdint_kind="(lacks uint64_t)" ++fi ++ ++ break ++done ++if test "$acx_cv_header_stdint" = stddef.h; then ++ acx_cv_header_stdint_kind="(lacks uintmax_t)" ++ for i in stdint.h $inttype_headers; do ++ unset ac_cv_type_uintptr_t ++ unset ac_cv_type_uint32_t ++ unset ac_cv_type_uint64_t ++ $as_echo_n "looking for an incomplete stdint.h in $i, " >&6 ++ ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "#include ++#include <$i> ++" ++if test "x$ac_cv_type_uint32_t" = x""yes; then : ++ acx_cv_header_stdint=$i ++else ++ continue ++fi ++ ++ ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "#include ++#include <$i> ++" ++if test "x$ac_cv_type_uint64_t" = x""yes; then : ++ ++fi ++ ++ ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "#include ++#include <$i> ++" ++if test "x$ac_cv_type_uintptr_t" = x""yes; then : ++ ++fi ++ ++ break ++ done ++fi ++if test "$acx_cv_header_stdint" = stddef.h; then ++ acx_cv_header_stdint_kind="(u_intXX_t style)" ++ for i in sys/types.h $inttype_headers; do ++ unset ac_cv_type_u_int32_t ++ unset ac_cv_type_u_int64_t ++ $as_echo_n "looking for u_intXX_t types in $i, " >&6 ++ ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "#include ++#include <$i> ++" ++if test "x$ac_cv_type_u_int32_t" = x""yes; then : ++ acx_cv_header_stdint=$i ++else ++ continue ++fi ++ ++ ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "#include ++#include <$i> ++" ++if test "x$ac_cv_type_u_int64_t" = x""yes; then : ++ ++fi ++ ++ break ++ done ++fi ++if test "$acx_cv_header_stdint" = stddef.h; then ++ acx_cv_header_stdint_kind="(using manual detection)" ++fi ++ ++test -z "$ac_cv_type_uintptr_t" && ac_cv_type_uintptr_t=no ++test -z "$ac_cv_type_uint64_t" && ac_cv_type_uint64_t=no ++test -z "$ac_cv_type_u_int64_t" && ac_cv_type_u_int64_t=no ++test -z "$ac_cv_type_int_least32_t" && ac_cv_type_int_least32_t=no ++test -z "$ac_cv_type_int_fast32_t" && ac_cv_type_int_fast32_t=no ++ ++# ----------------- Summarize what we found so far ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking what to include in gstdint.h" >&5 ++$as_echo_n "checking what to include in gstdint.h... " >&6; } ++ ++case `$as_basename -- gstdint.h || ++$as_expr X/gstdint.h : '.*/\([^/][^/]*\)/*$' \| \ ++ Xgstdint.h : 'X\(//\)$' \| \ ++ Xgstdint.h : 'X\(/\)' \| . 2>/dev/null || ++$as_echo X/gstdint.h | ++ sed '/^.*\/\([^/][^/]*\)\/*$/{ ++ s//\1/ ++ q ++ } ++ /^X\/\(\/\/\)$/{ ++ s//\1/ ++ q ++ } ++ /^X\/\(\/\).*/{ ++ s//\1/ ++ q ++ } ++ s/.*/./; q'` in ++ stdint.h) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: are you sure you want it there?" >&5 ++$as_echo "$as_me: WARNING: are you sure you want it there?" >&2;} ;; ++ inttypes.h) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: are you sure you want it there?" >&5 ++$as_echo "$as_me: WARNING: are you sure you want it there?" >&2;} ;; ++ *) ;; ++esac ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_header_stdint $acx_cv_header_stdint_kind" >&5 ++$as_echo "$acx_cv_header_stdint $acx_cv_header_stdint_kind" >&6; } ++ ++# ----------------- done included file, check C basic types -------- ++ ++# Lacking an uintptr_t? Test size of void * ++case "$acx_cv_header_stdint:$ac_cv_type_uintptr_t" in ++ stddef.h:* | *:no) # The cast to long int works around a bug in the HP C Compiler ++# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects ++# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. ++# This bug is HP SR number 8606223364. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 ++$as_echo_n "checking size of void *... " >&6; } ++if test "${ac_cv_sizeof_void_p+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : ++ ++else ++ if test "$ac_cv_type_void_p" = yes; then ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++{ as_fn_set_status 77 ++as_fn_error "cannot compute sizeof (void *) ++See \`config.log' for more details." "$LINENO" 5; }; } ++ else ++ ac_cv_sizeof_void_p=0 ++ fi ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 ++$as_echo "$ac_cv_sizeof_void_p" >&6; } ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define SIZEOF_VOID_P $ac_cv_sizeof_void_p ++_ACEOF ++ ++ ;; ++esac ++ ++# Lacking an uint64_t? Test size of long ++case "$acx_cv_header_stdint:$ac_cv_type_uint64_t:$ac_cv_type_u_int64_t" in ++ stddef.h:*:* | *:no:no) # The cast to long int works around a bug in the HP C Compiler ++# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects ++# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. ++# This bug is HP SR number 8606223364. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 ++$as_echo_n "checking size of long... " >&6; } ++if test "${ac_cv_sizeof_long+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : ++ ++else ++ if test "$ac_cv_type_long" = yes; then ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++{ as_fn_set_status 77 ++as_fn_error "cannot compute sizeof (long) ++See \`config.log' for more details." "$LINENO" 5; }; } ++ else ++ ac_cv_sizeof_long=0 ++ fi ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 ++$as_echo "$ac_cv_sizeof_long" >&6; } ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define SIZEOF_LONG $ac_cv_sizeof_long ++_ACEOF ++ ++ ;; ++esac ++ ++if test $acx_cv_header_stdint = stddef.h; then ++ # Lacking a good header? Test size of everything and deduce all types. ++ # The cast to long int works around a bug in the HP C Compiler ++# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects ++# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. ++# This bug is HP SR number 8606223364. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 ++$as_echo_n "checking size of int... " >&6; } ++if test "${ac_cv_sizeof_int+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : ++ ++else ++ if test "$ac_cv_type_int" = yes; then ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++{ as_fn_set_status 77 ++as_fn_error "cannot compute sizeof (int) ++See \`config.log' for more details." "$LINENO" 5; }; } ++ else ++ ac_cv_sizeof_int=0 ++ fi ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 ++$as_echo "$ac_cv_sizeof_int" >&6; } ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define SIZEOF_INT $ac_cv_sizeof_int ++_ACEOF ++ ++ ++ # The cast to long int works around a bug in the HP C Compiler ++# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects ++# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. ++# This bug is HP SR number 8606223364. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 ++$as_echo_n "checking size of short... " >&6; } ++if test "${ac_cv_sizeof_short+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : ++ ++else ++ if test "$ac_cv_type_short" = yes; then ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++{ as_fn_set_status 77 ++as_fn_error "cannot compute sizeof (short) ++See \`config.log' for more details." "$LINENO" 5; }; } ++ else ++ ac_cv_sizeof_short=0 ++ fi ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 ++$as_echo "$ac_cv_sizeof_short" >&6; } ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define SIZEOF_SHORT $ac_cv_sizeof_short ++_ACEOF ++ ++ ++ # The cast to long int works around a bug in the HP C Compiler ++# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects ++# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. ++# This bug is HP SR number 8606223364. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char" >&5 ++$as_echo_n "checking size of char... " >&6; } ++if test "${ac_cv_sizeof_char+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char))" "ac_cv_sizeof_char" "$ac_includes_default"; then : ++ ++else ++ if test "$ac_cv_type_char" = yes; then ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++{ as_fn_set_status 77 ++as_fn_error "cannot compute sizeof (char) ++See \`config.log' for more details." "$LINENO" 5; }; } ++ else ++ ac_cv_sizeof_char=0 ++ fi ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char" >&5 ++$as_echo "$ac_cv_sizeof_char" >&6; } ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define SIZEOF_CHAR $ac_cv_sizeof_char ++_ACEOF ++ ++ ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type equivalent to int8_t" >&5 ++$as_echo_n "checking for type equivalent to int8_t... " >&6; } ++ case "$ac_cv_sizeof_char" in ++ 1) acx_cv_type_int8_t=char ;; ++ *) as_fn_error "no 8-bit type, please report a bug" "$LINENO" 5 ++ esac ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_type_int8_t" >&5 ++$as_echo "$acx_cv_type_int8_t" >&6; } ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type equivalent to int16_t" >&5 ++$as_echo_n "checking for type equivalent to int16_t... " >&6; } ++ case "$ac_cv_sizeof_int:$ac_cv_sizeof_short" in ++ 2:*) acx_cv_type_int16_t=int ;; ++ *:2) acx_cv_type_int16_t=short ;; ++ *) as_fn_error "no 16-bit type, please report a bug" "$LINENO" 5 ++ esac ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_type_int16_t" >&5 ++$as_echo "$acx_cv_type_int16_t" >&6; } ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type equivalent to int32_t" >&5 ++$as_echo_n "checking for type equivalent to int32_t... " >&6; } ++ case "$ac_cv_sizeof_int:$ac_cv_sizeof_long" in ++ 4:*) acx_cv_type_int32_t=int ;; ++ *:4) acx_cv_type_int32_t=long ;; ++ *) as_fn_error "no 32-bit type, please report a bug" "$LINENO" 5 ++ esac ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_type_int32_t" >&5 ++$as_echo "$acx_cv_type_int32_t" >&6; } ++fi ++ ++# These tests are here to make the output prettier ++ ++if test "$ac_cv_type_uint64_t" != yes && test "$ac_cv_type_u_int64_t" != yes; then ++ case "$ac_cv_sizeof_long" in ++ 8) acx_cv_type_int64_t=long ;; ++ esac ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type equivalent to int64_t" >&5 ++$as_echo_n "checking for type equivalent to int64_t... " >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${acx_cv_type_int64_t-'using preprocessor symbols'}" >&5 ++$as_echo "${acx_cv_type_int64_t-'using preprocessor symbols'}" >&6; } ++fi ++ ++# Now we can use the above types ++ ++if test "$ac_cv_type_uintptr_t" != yes; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type equivalent to intptr_t" >&5 ++$as_echo_n "checking for type equivalent to intptr_t... " >&6; } ++ case $ac_cv_sizeof_void_p in ++ 2) acx_cv_type_intptr_t=int16_t ;; ++ 4) acx_cv_type_intptr_t=int32_t ;; ++ 8) acx_cv_type_intptr_t=int64_t ;; ++ *) as_fn_error "no equivalent for intptr_t, please report a bug" "$LINENO" 5 ++ esac ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_type_intptr_t" >&5 ++$as_echo "$acx_cv_type_intptr_t" >&6; } ++fi ++ ++# ----------------- done all checks, emit header ------------- ++ac_config_commands="$ac_config_commands gstdint.h" ++ ++ ++ ++ ++for ac_header in sys/mman.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default" ++if test "x$ac_cv_header_sys_mman_h" = x""yes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_SYS_MMAN_H 1 ++_ACEOF ++ ++fi ++ ++done ++ ++if test "$ac_cv_header_sys_mman_h" = "no"; then ++ have_mmap=no ++else ++ if test -n "${with_target_subdir}"; then ++ # When built as a GCC target library, we can't do a link test. We ++ # simply assume that if we have mman.h, we have mmap. ++ have_mmap=yes ++ case "${host}" in ++ spu-*-*|*-*-msdosdjgpp) ++ # The SPU does not have mmap, but it has a sys/mman.h header file ++ # containing "mmap_eaddr" and the mmap flags, confusing the test. ++ # DJGPP also has sys/man.h, but no mmap ++ have_mmap=no ;; ++ esac ++ else ++ ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap" ++if test "x$ac_cv_func_mmap" = x""yes; then : ++ have_mmap=yes ++else ++ have_mmap=no ++fi ++ ++ fi ++fi ++if test "$have_mmap" = "no"; then ++ VIEW_FILE=read.lo ++ ALLOC_FILE=alloc.lo ++else ++ VIEW_FILE=mmapio.lo ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++#include ++#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) ++ #error no MAP_ANONYMOUS ++#endif ++ ++_ACEOF ++if ac_fn_c_try_cpp "$LINENO"; then : ++ ALLOC_FILE=mmap.lo ++else ++ ALLOC_FILE=alloc.lo ++fi ++rm -f conftest.err conftest.$ac_ext ++fi ++ ++ ++ ++BACKTRACE_USES_MALLOC=0 ++if test "$ALLOC_FILE" = "alloc.lo"; then ++ BACKTRACE_USES_MALLOC=1 ++fi ++ ++ ++# Check for dl_iterate_phdr. ++for ac_header in link.h ++do : ++ ac_fn_c_check_header_mongrel "$LINENO" "link.h" "ac_cv_header_link_h" "$ac_includes_default" ++if test "x$ac_cv_header_link_h" = x""yes; then : ++ cat >>confdefs.h <<_ACEOF ++#define HAVE_LINK_H 1 ++_ACEOF ++ ++fi ++ ++done ++ ++if test "$ac_cv_header_link_h" = "no"; then ++ have_dl_iterate_phdr=no ++else ++ if test -n "${with_target_subdir}"; then ++ # When built as a GCC target library, we can't do a link test. ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++#include ++ ++_ACEOF ++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | ++ $EGREP "dl_iterate_phdr" >/dev/null 2>&1; then : ++ have_dl_iterate_phdr=yes ++else ++ have_dl_iterate_phdr=no ++fi ++rm -f conftest* ++ ++ case "${host}" in ++ *-*-solaris2.10*) ++ # Avoid dl_iterate_phdr on Solaris 10, where it is in the ++ # header file but is only in -ldl. ++ have_dl_iterate_phdr=no ;; ++ esac ++ else ++ ac_fn_c_check_func "$LINENO" "dl_iterate_phdr" "ac_cv_func_dl_iterate_phdr" ++if test "x$ac_cv_func_dl_iterate_phdr" = x""yes; then : ++ have_dl_iterate_phdr=yes ++else ++ have_dl_iterate_phdr=no ++fi ++ ++ fi ++fi ++if test "$have_dl_iterate_phdr" = "yes"; then ++ ++$as_echo "#define HAVE_DL_ITERATE_PHDR 1" >>confdefs.h ++ ++fi ++ ++# Check for the fcntl function. ++if test -n "${with_target_subdir}"; then ++ case "${host}" in ++ *-*-mingw*) have_fcntl=no ;; ++ spu-*-*) have_fcntl=no ;; ++ *) have_fcntl=yes ;; ++ esac ++else ++ ac_fn_c_check_func "$LINENO" "fcntl" "ac_cv_func_fcntl" ++if test "x$ac_cv_func_fcntl" = x""yes; then : ++ have_fcntl=yes ++else ++ have_fcntl=no ++fi ++ ++fi ++if test "$have_fcntl" = "yes"; then ++ ++$as_echo "#define HAVE_FCNTL 1" >>confdefs.h ++ ++fi ++ ++ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default" ++if test "x$ac_cv_have_decl_strnlen" = x""yes; then : ++ ac_have_decl=1 ++else ++ ac_have_decl=0 ++fi ++ ++cat >>confdefs.h <<_ACEOF ++#define HAVE_DECL_STRNLEN $ac_have_decl ++_ACEOF ++ ++ ++# Check for getexecname function. ++if test -n "${with_target_subdir}"; then ++ case "${host}" in ++ *-*-solaris2*) have_getexecname=yes ;; ++ *) have_getexecname=no ;; ++ esac ++else ++ ac_fn_c_check_func "$LINENO" "getexecname" "ac_cv_func_getexecname" ++if test "x$ac_cv_func_getexecname" = x""yes; then : ++ have_getexecname=yes ++else ++ have_getexecname=no ++fi ++ ++fi ++if test "$have_getexecname" = "yes"; then ++ ++$as_echo "#define HAVE_GETEXECNAME 1" >>confdefs.h ++ ++fi ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether tests can run" >&5 ++$as_echo_n "checking whether tests can run... " >&6; } ++if test "${libbacktrace_cv_sys_native+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if test "$cross_compiling" = yes; then : ++ libbacktrace_cv_sys_native=no ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++return 0; ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_run "$LINENO"; then : ++ libbacktrace_cv_sys_native=yes ++else ++ libbacktrace_cv_sys_native=no ++fi ++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ ++ conftest.$ac_objext conftest.beam conftest.$ac_ext ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_sys_native" >&5 ++$as_echo "$libbacktrace_cv_sys_native" >&6; } ++ if test "$libbacktrace_cv_sys_native" = "yes"; then ++ NATIVE_TRUE= ++ NATIVE_FALSE='#' ++else ++ NATIVE_TRUE='#' ++ NATIVE_FALSE= ++fi ++ ++ ++if test "${multilib}" = "yes"; then ++ multilib_arg="--enable-multilib" ++else ++ multilib_arg= ++fi ++ ++ac_config_files="$ac_config_files Makefile backtrace-supported.h" ++ ++ ++# We need multilib support, but only if configuring for the target. ++ac_config_commands="$ac_config_commands default" ++ ++ ++cat >confcache <<\_ACEOF ++# This file is a shell script that caches the results of configure ++# tests run on this system so they can be shared between configure ++# scripts and configure runs, see configure's option --config-cache. ++# It is not useful on other systems. If it contains results you don't ++# want to keep, you may remove or edit it. ++# ++# config.status only pays attention to the cache file if you give it ++# the --recheck option to rerun configure. ++# ++# `ac_cv_env_foo' variables (set or unset) will be overridden when ++# loading this file, other *unset* `ac_cv_foo' will be assigned the ++# following values. ++ ++_ACEOF ++ ++# The following way of writing the cache mishandles newlines in values, ++# but we know of no workaround that is simple, portable, and efficient. ++# So, we kill variables containing newlines. ++# Ultrix sh set writes to stderr and can't be redirected directly, ++# and sets the high bit in the cache file unless we assign to the vars. ++( ++ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do ++ eval ac_val=\$$ac_var ++ case $ac_val in #( ++ *${as_nl}*) ++ case $ac_var in #( ++ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 ++$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ++ esac ++ case $ac_var in #( ++ _ | IFS | as_nl) ;; #( ++ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( ++ *) { eval $ac_var=; unset $ac_var;} ;; ++ esac ;; ++ esac ++ done ++ ++ (set) 2>&1 | ++ case $as_nl`(ac_space=' '; set) 2>&1` in #( ++ *${as_nl}ac_space=\ *) ++ # `set' does not quote correctly, so add quotes: double-quote ++ # substitution turns \\\\ into \\, and sed turns \\ into \. ++ sed -n \ ++ "s/'/'\\\\''/g; ++ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ++ ;; #( ++ *) ++ # `set' quotes correctly as required by POSIX, so do not add quotes. ++ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ++ ;; ++ esac | ++ sort ++) | ++ sed ' ++ /^ac_cv_env_/b end ++ t clear ++ :clear ++ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ ++ t end ++ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ ++ :end' >>confcache ++if diff "$cache_file" confcache >/dev/null 2>&1; then :; else ++ if test -w "$cache_file"; then ++ test "x$cache_file" != "x/dev/null" && ++ { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 ++$as_echo "$as_me: updating cache $cache_file" >&6;} ++ cat confcache >$cache_file ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 ++$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} ++ fi ++fi ++rm -f confcache ++ ++test "x$prefix" = xNONE && prefix=$ac_default_prefix ++# Let make expand exec_prefix. ++test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' ++ ++DEFS=-DHAVE_CONFIG_H ++ ++ac_libobjs= ++ac_ltlibobjs= ++for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue ++ # 1. Remove the extension, and $U if already installed. ++ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ++ ac_i=`$as_echo "$ac_i" | sed "$ac_script"` ++ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR ++ # will be set to the directory where LIBOBJS objects are built. ++ as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" ++ as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' ++done ++LIBOBJS=$ac_libobjs ++ ++LTLIBOBJS=$ac_ltlibobjs ++ ++ ++ if test -n "$EXEEXT"; then ++ am__EXEEXT_TRUE= ++ am__EXEEXT_FALSE='#' ++else ++ am__EXEEXT_TRUE='#' ++ am__EXEEXT_FALSE= ++fi ++ ++if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then ++ as_fn_error "conditional \"MAINTAINER_MODE\" was never defined. ++Usually this means the macro was only invoked conditionally." "$LINENO" 5 ++fi ++if test -z "${NATIVE_TRUE}" && test -z "${NATIVE_FALSE}"; then ++ as_fn_error "conditional \"NATIVE\" was never defined. ++Usually this means the macro was only invoked conditionally." "$LINENO" 5 ++fi ++ ++: ${CONFIG_STATUS=./config.status} ++ac_write_fail=0 ++ac_clean_files_save=$ac_clean_files ++ac_clean_files="$ac_clean_files $CONFIG_STATUS" ++{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 ++$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} ++as_write_fail=0 ++cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 ++#! $SHELL ++# Generated by $as_me. ++# Run this file to recreate the current configuration. ++# Compiler output produced by configure, useful for debugging ++# configure, is in config.log if it exists. ++ ++debug=false ++ac_cs_recheck=false ++ac_cs_silent=false ++ ++SHELL=\${CONFIG_SHELL-$SHELL} ++export SHELL ++_ASEOF ++cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ++## -------------------- ## ++## M4sh Initialization. ## ++## -------------------- ## ++ ++# Be more Bourne compatible ++DUALCASE=1; export DUALCASE # for MKS sh ++if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : ++ emulate sh ++ NULLCMD=: ++ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which ++ # is contrary to our usage. Disable this feature. ++ alias -g '${1+"$@"}'='"$@"' ++ setopt NO_GLOB_SUBST ++else ++ case `(set -o) 2>/dev/null` in #( ++ *posix*) : ++ set -o posix ;; #( ++ *) : ++ ;; ++esac ++fi ++ ++ ++as_nl=' ++' ++export as_nl ++# Printing a long string crashes Solaris 7 /usr/bin/printf. ++as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ++as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo ++as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo ++# Prefer a ksh shell builtin over an external printf program on Solaris, ++# but without wasting forks for bash or zsh. ++if test -z "$BASH_VERSION$ZSH_VERSION" \ ++ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then ++ as_echo='print -r --' ++ as_echo_n='print -rn --' ++elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then ++ as_echo='printf %s\n' ++ as_echo_n='printf %s' ++else ++ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then ++ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' ++ as_echo_n='/usr/ucb/echo -n' ++ else ++ as_echo_body='eval expr "X$1" : "X\\(.*\\)"' ++ as_echo_n_body='eval ++ arg=$1; ++ case $arg in #( ++ *"$as_nl"*) ++ expr "X$arg" : "X\\(.*\\)$as_nl"; ++ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; ++ esac; ++ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ++ ' ++ export as_echo_n_body ++ as_echo_n='sh -c $as_echo_n_body as_echo' ++ fi ++ export as_echo_body ++ as_echo='sh -c $as_echo_body as_echo' ++fi ++ ++# The user is always right. ++if test "${PATH_SEPARATOR+set}" != set; then ++ PATH_SEPARATOR=: ++ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { ++ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || ++ PATH_SEPARATOR=';' ++ } ++fi ++ ++ ++# IFS ++# We need space, tab and new line, in precisely that order. Quoting is ++# there to prevent editors from complaining about space-tab. ++# (If _AS_PATH_WALK were called with IFS unset, it would disable word ++# splitting by setting IFS to empty value.) ++IFS=" "" $as_nl" ++ ++# Find who we are. Look in the path if we contain no directory separator. ++case $0 in #(( ++ *[\\/]* ) as_myself=$0 ;; ++ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break ++ done ++IFS=$as_save_IFS ++ ++ ;; ++esac ++# We did not find ourselves, most probably we were run as `sh COMMAND' ++# in which case we are not to be found in the path. ++if test "x$as_myself" = x; then ++ as_myself=$0 ++fi ++if test ! -f "$as_myself"; then ++ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 ++ exit 1 ++fi ++ ++# Unset variables that we do not need and which cause bugs (e.g. in ++# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" ++# suppresses any "Segmentation fault" message there. '((' could ++# trigger a bug in pdksh 5.2.14. ++for as_var in BASH_ENV ENV MAIL MAILPATH ++do eval test x\${$as_var+set} = xset \ ++ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : ++done ++PS1='$ ' ++PS2='> ' ++PS4='+ ' ++ ++# NLS nuisances. ++LC_ALL=C ++export LC_ALL ++LANGUAGE=C ++export LANGUAGE ++ ++# CDPATH. ++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH ++ ++ ++# as_fn_error ERROR [LINENO LOG_FD] ++# --------------------------------- ++# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are ++# provided, also output the error to LOG_FD, referencing LINENO. Then exit the ++# script with status $?, using 1 if that was 0. ++as_fn_error () ++{ ++ as_status=$?; test $as_status -eq 0 && as_status=1 ++ if test "$3"; then ++ as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 ++ fi ++ $as_echo "$as_me: error: $1" >&2 ++ as_fn_exit $as_status ++} # as_fn_error ++ ++ ++# as_fn_set_status STATUS ++# ----------------------- ++# Set $? to STATUS, without forking. ++as_fn_set_status () ++{ ++ return $1 ++} # as_fn_set_status ++ ++# as_fn_exit STATUS ++# ----------------- ++# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. ++as_fn_exit () ++{ ++ set +e ++ as_fn_set_status $1 ++ exit $1 ++} # as_fn_exit ++ ++# as_fn_unset VAR ++# --------------- ++# Portably unset VAR. ++as_fn_unset () ++{ ++ { eval $1=; unset $1;} ++} ++as_unset=as_fn_unset ++# as_fn_append VAR VALUE ++# ---------------------- ++# Append the text in VALUE to the end of the definition contained in VAR. Take ++# advantage of any shell optimizations that allow amortized linear growth over ++# repeated appends, instead of the typical quadratic growth present in naive ++# implementations. ++if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : ++ eval 'as_fn_append () ++ { ++ eval $1+=\$2 ++ }' ++else ++ as_fn_append () ++ { ++ eval $1=\$$1\$2 ++ } ++fi # as_fn_append ++ ++# as_fn_arith ARG... ++# ------------------ ++# Perform arithmetic evaluation on the ARGs, and store the result in the ++# global $as_val. Take advantage of shells that can avoid forks. The arguments ++# must be portable across $(()) and expr. ++if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : ++ eval 'as_fn_arith () ++ { ++ as_val=$(( $* )) ++ }' ++else ++ as_fn_arith () ++ { ++ as_val=`expr "$@" || test $? -eq 1` ++ } ++fi # as_fn_arith ++ ++ ++if expr a : '\(a\)' >/dev/null 2>&1 && ++ test "X`expr 00001 : '.*\(...\)'`" = X001; then ++ as_expr=expr ++else ++ as_expr=false ++fi ++ ++if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then ++ as_basename=basename ++else ++ as_basename=false ++fi ++ ++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then ++ as_dirname=dirname ++else ++ as_dirname=false ++fi ++ ++as_me=`$as_basename -- "$0" || ++$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ ++ X"$0" : 'X\(//\)$' \| \ ++ X"$0" : 'X\(/\)' \| . 2>/dev/null || ++$as_echo X/"$0" | ++ sed '/^.*\/\([^/][^/]*\)\/*$/{ ++ s//\1/ ++ q ++ } ++ /^X\/\(\/\/\)$/{ ++ s//\1/ ++ q ++ } ++ /^X\/\(\/\).*/{ ++ s//\1/ ++ q ++ } ++ s/.*/./; q'` ++ ++# Avoid depending upon Character Ranges. ++as_cr_letters='abcdefghijklmnopqrstuvwxyz' ++as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' ++as_cr_Letters=$as_cr_letters$as_cr_LETTERS ++as_cr_digits='0123456789' ++as_cr_alnum=$as_cr_Letters$as_cr_digits ++ ++ECHO_C= ECHO_N= ECHO_T= ++case `echo -n x` in #((((( ++-n*) ++ case `echo 'xy\c'` in ++ *c*) ECHO_T=' ';; # ECHO_T is single tab character. ++ xy) ECHO_C='\c';; ++ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ++ ECHO_T=' ';; ++ esac;; ++*) ++ ECHO_N='-n';; ++esac ++ ++rm -f conf$$ conf$$.exe conf$$.file ++if test -d conf$$.dir; then ++ rm -f conf$$.dir/conf$$.file ++else ++ rm -f conf$$.dir ++ mkdir conf$$.dir 2>/dev/null ++fi ++if (echo >conf$$.file) 2>/dev/null; then ++ if ln -s conf$$.file conf$$ 2>/dev/null; then ++ as_ln_s='ln -s' ++ # ... but there are two gotchas: ++ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. ++ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. ++ # In both cases, we have to default to `cp -p'. ++ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || ++ as_ln_s='cp -p' ++ elif ln conf$$.file conf$$ 2>/dev/null; then ++ as_ln_s=ln ++ else ++ as_ln_s='cp -p' ++ fi ++else ++ as_ln_s='cp -p' ++fi ++rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file ++rmdir conf$$.dir 2>/dev/null ++ ++ ++# as_fn_mkdir_p ++# ------------- ++# Create "$as_dir" as a directory, including parents if necessary. ++as_fn_mkdir_p () ++{ ++ ++ case $as_dir in #( ++ -*) as_dir=./$as_dir;; ++ esac ++ test -d "$as_dir" || eval $as_mkdir_p || { ++ as_dirs= ++ while :; do ++ case $as_dir in #( ++ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( ++ *) as_qdir=$as_dir;; ++ esac ++ as_dirs="'$as_qdir' $as_dirs" ++ as_dir=`$as_dirname -- "$as_dir" || ++$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ++ X"$as_dir" : 'X\(//\)[^/]' \| \ ++ X"$as_dir" : 'X\(//\)$' \| \ ++ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || ++$as_echo X"$as_dir" | ++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\/\)[^/].*/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\/\)$/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\).*/{ ++ s//\1/ ++ q ++ } ++ s/.*/./; q'` ++ test -d "$as_dir" && break ++ done ++ test -z "$as_dirs" || eval "mkdir $as_dirs" ++ } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" ++ ++ ++} # as_fn_mkdir_p ++if mkdir -p . 2>/dev/null; then ++ as_mkdir_p='mkdir -p "$as_dir"' ++else ++ test -d ./-p && rmdir ./-p ++ as_mkdir_p=false ++fi ++ ++if test -x / >/dev/null 2>&1; then ++ as_test_x='test -x' ++else ++ if ls -dL / >/dev/null 2>&1; then ++ as_ls_L_option=L ++ else ++ as_ls_L_option= ++ fi ++ as_test_x=' ++ eval sh -c '\'' ++ if test -d "$1"; then ++ test -d "$1/."; ++ else ++ case $1 in #( ++ -*)set "./$1";; ++ esac; ++ case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ++ ???[sx]*):;;*)false;;esac;fi ++ '\'' sh ++ ' ++fi ++as_executable_p=$as_test_x ++ ++# Sed expression to map a string onto a valid CPP name. ++as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" ++ ++# Sed expression to map a string onto a valid variable name. ++as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" ++ ++ ++exec 6>&1 ++## ----------------------------------- ## ++## Main body of $CONFIG_STATUS script. ## ++## ----------------------------------- ## ++_ASEOF ++test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 ++ ++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ++# Save the log message, to keep $0 and so on meaningful, and to ++# report actual input values of CONFIG_FILES etc. instead of their ++# values after options handling. ++ac_log=" ++This file was extended by package-unused $as_me version-unused, which was ++generated by GNU Autoconf 2.64. Invocation command line was ++ ++ CONFIG_FILES = $CONFIG_FILES ++ CONFIG_HEADERS = $CONFIG_HEADERS ++ CONFIG_LINKS = $CONFIG_LINKS ++ CONFIG_COMMANDS = $CONFIG_COMMANDS ++ $ $0 $@ ++ ++on `(hostname || uname -n) 2>/dev/null | sed 1q` ++" ++ ++_ACEOF ++ ++case $ac_config_files in *" ++"*) set x $ac_config_files; shift; ac_config_files=$*;; ++esac ++ ++case $ac_config_headers in *" ++"*) set x $ac_config_headers; shift; ac_config_headers=$*;; ++esac ++ ++ ++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ++# Files that config.status was made for. ++config_files="$ac_config_files" ++config_headers="$ac_config_headers" ++config_commands="$ac_config_commands" ++ ++_ACEOF ++ ++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ++ac_cs_usage="\ ++\`$as_me' instantiates files and other configuration actions ++from templates according to the current configuration. Unless the files ++and actions are specified as TAGs, all are instantiated by default. ++ ++Usage: $0 [OPTION]... [TAG]... ++ ++ -h, --help print this help, then exit ++ -V, --version print version number and configuration settings, then exit ++ -q, --quiet, --silent ++ do not print progress messages ++ -d, --debug don't remove temporary files ++ --recheck update $as_me by reconfiguring in the same conditions ++ --file=FILE[:TEMPLATE] ++ instantiate the configuration file FILE ++ --header=FILE[:TEMPLATE] ++ instantiate the configuration header FILE ++ ++Configuration files: ++$config_files ++ ++Configuration headers: ++$config_headers ++ ++Configuration commands: ++$config_commands ++ ++Report bugs to the package provider." ++ ++_ACEOF ++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ++ac_cs_version="\\ ++package-unused config.status version-unused ++configured by $0, generated by GNU Autoconf 2.64, ++ with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" ++ ++Copyright (C) 2009 Free Software Foundation, Inc. ++This config.status script is free software; the Free Software Foundation ++gives unlimited permission to copy, distribute and modify it." ++ ++ac_pwd='$ac_pwd' ++srcdir='$srcdir' ++INSTALL='$INSTALL' ++MKDIR_P='$MKDIR_P' ++AWK='$AWK' ++test -n "\$AWK" || AWK=awk ++_ACEOF ++ ++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ++# The default lists apply if the user does not specify any file. ++ac_need_defaults=: ++while test $# != 0 ++do ++ case $1 in ++ --*=*) ++ ac_option=`expr "X$1" : 'X\([^=]*\)='` ++ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ++ ac_shift=: ++ ;; ++ *) ++ ac_option=$1 ++ ac_optarg=$2 ++ ac_shift=shift ++ ;; ++ esac ++ ++ case $ac_option in ++ # Handling of the options. ++ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ++ ac_cs_recheck=: ;; ++ --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) ++ $as_echo "$ac_cs_version"; exit ;; ++ --debug | --debu | --deb | --de | --d | -d ) ++ debug=: ;; ++ --file | --fil | --fi | --f ) ++ $ac_shift ++ case $ac_optarg in ++ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; ++ esac ++ as_fn_append CONFIG_FILES " '$ac_optarg'" ++ ac_need_defaults=false;; ++ --header | --heade | --head | --hea ) ++ $ac_shift ++ case $ac_optarg in ++ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; ++ esac ++ as_fn_append CONFIG_HEADERS " '$ac_optarg'" ++ ac_need_defaults=false;; ++ --he | --h) ++ # Conflict between --help and --header ++ as_fn_error "ambiguous option: \`$1' ++Try \`$0 --help' for more information.";; ++ --help | --hel | -h ) ++ $as_echo "$ac_cs_usage"; exit ;; ++ -q | -quiet | --quiet | --quie | --qui | --qu | --q \ ++ | -silent | --silent | --silen | --sile | --sil | --si | --s) ++ ac_cs_silent=: ;; ++ ++ # This is an error. ++ -*) as_fn_error "unrecognized option: \`$1' ++Try \`$0 --help' for more information." ;; ++ ++ *) as_fn_append ac_config_targets " $1" ++ ac_need_defaults=false ;; ++ ++ esac ++ shift ++done ++ ++ac_configure_extra_args= ++ ++if $ac_cs_silent; then ++ exec 6>/dev/null ++ ac_configure_extra_args="$ac_configure_extra_args --silent" ++fi ++ ++_ACEOF ++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ++if \$ac_cs_recheck; then ++ set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion ++ shift ++ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 ++ CONFIG_SHELL='$SHELL' ++ export CONFIG_SHELL ++ exec "\$@" ++fi ++ ++_ACEOF ++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ++exec 5>>config.log ++{ ++ echo ++ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ++## Running $as_me. ## ++_ASBOX ++ $as_echo "$ac_log" ++} >&5 ++ ++_ACEOF ++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ++# ++# INIT-COMMANDS ++# ++ ++srcdir="$srcdir" ++host="$host" ++target="$target" ++with_multisubdir="$with_multisubdir" ++with_multisrctop="$with_multisrctop" ++with_target_subdir="$with_target_subdir" ++ac_configure_args="${multilib_arg} ${ac_configure_args}" ++multi_basedir="$multi_basedir" ++CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} ++CC="$CC" ++CXX="$CXX" ++GFORTRAN="$GFORTRAN" ++ ++ ++# The HP-UX ksh and POSIX shell print the target directory to stdout ++# if CDPATH is set. ++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH ++ ++sed_quote_subst='$sed_quote_subst' ++double_quote_subst='$double_quote_subst' ++delay_variable_subst='$delay_variable_subst' ++macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' ++macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' ++enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' ++enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' ++pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' ++enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' ++SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ++ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' ++host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' ++host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' ++host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' ++build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' ++build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' ++build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' ++SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' ++Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' ++GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' ++EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' ++FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' ++LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' ++NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' ++LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' ++max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ++ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' ++exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' ++lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' ++lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' ++lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' ++reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' ++reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' ++OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' ++deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' ++file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' ++AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' ++AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' ++STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' ++RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' ++old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' ++old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' ++old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' ++lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' ++CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' ++CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' ++compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' ++GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' ++lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' ++lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' ++lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' ++lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' ++objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' ++MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' ++lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' ++lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' ++lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' ++lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' ++lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' ++need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' ++DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' ++NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' ++LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' ++OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' ++OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' ++libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' ++shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' ++extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' ++archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' ++enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' ++export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' ++whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' ++compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' ++old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' ++old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' ++archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' ++archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' ++module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' ++module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' ++with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' ++allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' ++no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' ++hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' ++hardcode_libdir_flag_spec_ld='`$ECHO "$hardcode_libdir_flag_spec_ld" | $SED "$delay_single_quote_subst"`' ++hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' ++hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' ++hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' ++hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' ++hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' ++hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' ++inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' ++link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' ++fix_srcfile_path='`$ECHO "$fix_srcfile_path" | $SED "$delay_single_quote_subst"`' ++always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' ++export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' ++exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' ++include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' ++prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' ++file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' ++variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' ++need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' ++need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' ++version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' ++runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' ++shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' ++shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' ++libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' ++library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' ++soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' ++install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' ++postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' ++postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' ++finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' ++finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' ++hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' ++sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' ++sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' ++hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' ++enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' ++enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' ++enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' ++old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' ++striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' ++ ++LTCC='$LTCC' ++LTCFLAGS='$LTCFLAGS' ++compiler='$compiler_DEFAULT' ++ ++# A function that is used when there is no print builtin or printf. ++func_fallback_echo () ++{ ++ eval 'cat <<_LTECHO_EOF ++\$1 ++_LTECHO_EOF' ++} ++ ++# Quote evaled strings. ++for var in SHELL \ ++ECHO \ ++SED \ ++GREP \ ++EGREP \ ++FGREP \ ++LD \ ++NM \ ++LN_S \ ++lt_SP2NL \ ++lt_NL2SP \ ++reload_flag \ ++OBJDUMP \ ++deplibs_check_method \ ++file_magic_cmd \ ++AR \ ++AR_FLAGS \ ++STRIP \ ++RANLIB \ ++CC \ ++CFLAGS \ ++compiler \ ++lt_cv_sys_global_symbol_pipe \ ++lt_cv_sys_global_symbol_to_cdecl \ ++lt_cv_sys_global_symbol_to_c_name_address \ ++lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ ++lt_prog_compiler_no_builtin_flag \ ++lt_prog_compiler_wl \ ++lt_prog_compiler_pic \ ++lt_prog_compiler_static \ ++lt_cv_prog_compiler_c_o \ ++need_locks \ ++DSYMUTIL \ ++NMEDIT \ ++LIPO \ ++OTOOL \ ++OTOOL64 \ ++shrext_cmds \ ++export_dynamic_flag_spec \ ++whole_archive_flag_spec \ ++compiler_needs_object \ ++with_gnu_ld \ ++allow_undefined_flag \ ++no_undefined_flag \ ++hardcode_libdir_flag_spec \ ++hardcode_libdir_flag_spec_ld \ ++hardcode_libdir_separator \ ++fix_srcfile_path \ ++exclude_expsyms \ ++include_expsyms \ ++file_list_spec \ ++variables_saved_for_relink \ ++libname_spec \ ++library_names_spec \ ++soname_spec \ ++install_override_mode \ ++finish_eval \ ++old_striplib \ ++striplib; do ++ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in ++ *[\\\\\\\`\\"\\\$]*) ++ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ++ ;; ++ *) ++ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ++ ;; ++ esac ++done ++ ++# Double-quote double-evaled strings. ++for var in reload_cmds \ ++old_postinstall_cmds \ ++old_postuninstall_cmds \ ++old_archive_cmds \ ++extract_expsyms_cmds \ ++old_archive_from_new_cmds \ ++old_archive_from_expsyms_cmds \ ++archive_cmds \ ++archive_expsym_cmds \ ++module_cmds \ ++module_expsym_cmds \ ++export_symbols_cmds \ ++prelink_cmds \ ++postinstall_cmds \ ++postuninstall_cmds \ ++finish_cmds \ ++sys_lib_search_path_spec \ ++sys_lib_dlsearch_path_spec; do ++ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in ++ *[\\\\\\\`\\"\\\$]*) ++ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ++ ;; ++ *) ++ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ++ ;; ++ esac ++done ++ ++ac_aux_dir='$ac_aux_dir' ++xsi_shell='$xsi_shell' ++lt_shell_append='$lt_shell_append' ++ ++# See if we are running on zsh, and set the options which allow our ++# commands through without removal of \ escapes INIT. ++if test -n "\${ZSH_VERSION+set}" ; then ++ setopt NO_GLOB_SUBST ++fi ++ ++ ++ PACKAGE='$PACKAGE' ++ VERSION='$VERSION' ++ TIMESTAMP='$TIMESTAMP' ++ RM='$RM' ++ ofile='$ofile' ++ ++ ++ ++ ++GCC="$GCC" ++CC="$CC" ++acx_cv_header_stdint="$acx_cv_header_stdint" ++acx_cv_type_int8_t="$acx_cv_type_int8_t" ++acx_cv_type_int16_t="$acx_cv_type_int16_t" ++acx_cv_type_int32_t="$acx_cv_type_int32_t" ++acx_cv_type_int64_t="$acx_cv_type_int64_t" ++acx_cv_type_intptr_t="$acx_cv_type_intptr_t" ++ac_cv_type_uintmax_t="$ac_cv_type_uintmax_t" ++ac_cv_type_uintptr_t="$ac_cv_type_uintptr_t" ++ac_cv_type_uint64_t="$ac_cv_type_uint64_t" ++ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t" ++ac_cv_type_u_int32_t="$ac_cv_type_u_int32_t" ++ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t" ++ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t" ++ac_cv_sizeof_void_p="$ac_cv_sizeof_void_p" ++ ++ ++# Variables needed in config.status (file generation) which aren't already ++# passed by autoconf. ++SUBDIRS="$SUBDIRS" ++ ++ ++_ACEOF ++ ++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ++ ++# Handling of arguments. ++for ac_config_target in $ac_config_targets ++do ++ case $ac_config_target in ++ "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; ++ "default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; ++ "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; ++ "gstdint.h") CONFIG_COMMANDS="$CONFIG_COMMANDS gstdint.h" ;; ++ "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; ++ "backtrace-supported.h") CONFIG_FILES="$CONFIG_FILES backtrace-supported.h" ;; ++ "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; ++ ++ *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; ++ esac ++done ++ ++ ++# If the user did not use the arguments to specify the items to instantiate, ++# then the envvar interface is used. Set only those that are not. ++# We use the long form for the default assignment because of an extremely ++# bizarre bug on SunOS 4.1.3. ++if $ac_need_defaults; then ++ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files ++ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers ++ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands ++fi ++ ++# Have a temporary directory for convenience. Make it in the build tree ++# simply because there is no reason against having it here, and in addition, ++# creating and moving files from /tmp can sometimes cause problems. ++# Hook for its removal unless debugging. ++# Note that there is a small window in which the directory will not be cleaned: ++# after its creation but before its name has been assigned to `$tmp'. ++$debug || ++{ ++ tmp= ++ trap 'exit_status=$? ++ { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ++' 0 ++ trap 'as_fn_exit 1' 1 2 13 15 ++} ++# Create a (secure) tmp directory for tmp files. ++ ++{ ++ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && ++ test -n "$tmp" && test -d "$tmp" ++} || ++{ ++ tmp=./conf$$-$RANDOM ++ (umask 077 && mkdir "$tmp") ++} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 ++ ++# Set up the scripts for CONFIG_FILES section. ++# No need to generate them if there are no CONFIG_FILES. ++# This happens for instance with `./config.status config.h'. ++if test -n "$CONFIG_FILES"; then ++ ++ ++ac_cr=`echo X | tr X '\015'` ++# On cygwin, bash can eat \r inside `` if the user requested igncr. ++# But we know of no other shell where ac_cr would be empty at this ++# point, so we can use a bashism as a fallback. ++if test "x$ac_cr" = x; then ++ eval ac_cr=\$\'\\r\' ++fi ++ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` ++if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ++ ac_cs_awk_cr='\r' ++else ++ ac_cs_awk_cr=$ac_cr ++fi ++ ++echo 'BEGIN {' >"$tmp/subs1.awk" && ++_ACEOF ++ ++ ++{ ++ echo "cat >conf$$subs.awk <<_ACEOF" && ++ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && ++ echo "_ACEOF" ++} >conf$$subs.sh || ++ as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ++ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ++ac_delim='%!_!# ' ++for ac_last_try in false false false false false :; do ++ . ./conf$$subs.sh || ++ as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ++ ++ ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` ++ if test $ac_delim_n = $ac_delim_num; then ++ break ++ elif $ac_last_try; then ++ as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ++ else ++ ac_delim="$ac_delim!$ac_delim _$ac_delim!! " ++ fi ++done ++rm -f conf$$subs.sh ++ ++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ++cat >>"\$tmp/subs1.awk" <<\\_ACAWK && ++_ACEOF ++sed -n ' ++h ++s/^/S["/; s/!.*/"]=/ ++p ++g ++s/^[^!]*!// ++:repl ++t repl ++s/'"$ac_delim"'$// ++t delim ++:nl ++h ++s/\(.\{148\}\).*/\1/ ++t more1 ++s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ ++p ++n ++b repl ++:more1 ++s/["\\]/\\&/g; s/^/"/; s/$/"\\/ ++p ++g ++s/.\{148\}// ++t nl ++:delim ++h ++s/\(.\{148\}\).*/\1/ ++t more2 ++s/["\\]/\\&/g; s/^/"/; s/$/"/ ++p ++b ++:more2 ++s/["\\]/\\&/g; s/^/"/; s/$/"\\/ ++p ++g ++s/.\{148\}// ++t delim ++' >$CONFIG_STATUS || ac_write_fail=1 ++rm -f conf$$subs.awk ++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ++_ACAWK ++cat >>"\$tmp/subs1.awk" <<_ACAWK && ++ for (key in S) S_is_set[key] = 1 ++ FS = "" ++ ++} ++{ ++ line = $ 0 ++ nfields = split(line, field, "@") ++ substed = 0 ++ len = length(field[1]) ++ for (i = 2; i < nfields; i++) { ++ key = field[i] ++ keylen = length(key) ++ if (S_is_set[key]) { ++ value = S[key] ++ line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) ++ len += length(value) + length(field[++i]) ++ substed = 1 ++ } else ++ len += 1 + keylen ++ } ++ ++ print line ++} ++ ++_ACAWK ++_ACEOF ++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ++if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then ++ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" ++else ++ cat ++fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ ++ || as_fn_error "could not setup config files machinery" "$LINENO" 5 ++_ACEOF ++ ++# VPATH may cause trouble with some makes, so we remove $(srcdir), ++# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and ++# trailing colons and then remove the whole line if VPATH becomes empty ++# (actually we leave an empty line to preserve line numbers). ++if test "x$srcdir" = x.; then ++ ac_vpsub='/^[ ]*VPATH[ ]*=/{ ++s/:*\$(srcdir):*/:/ ++s/:*\${srcdir}:*/:/ ++s/:*@srcdir@:*/:/ ++s/^\([^=]*=[ ]*\):*/\1/ ++s/:*$// ++s/^[^=]*=[ ]*$// ++}' ++fi ++ ++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ++fi # test -n "$CONFIG_FILES" ++ ++# Set up the scripts for CONFIG_HEADERS section. ++# No need to generate them if there are no CONFIG_HEADERS. ++# This happens for instance with `./config.status Makefile'. ++if test -n "$CONFIG_HEADERS"; then ++cat >"$tmp/defines.awk" <<\_ACAWK || ++BEGIN { ++_ACEOF ++ ++# Transform confdefs.h into an awk script `defines.awk', embedded as ++# here-document in config.status, that substitutes the proper values into ++# config.h.in to produce config.h. ++ ++# Create a delimiter string that does not exist in confdefs.h, to ease ++# handling of long lines. ++ac_delim='%!_!# ' ++for ac_last_try in false false :; do ++ ac_t=`sed -n "/$ac_delim/p" confdefs.h` ++ if test -z "$ac_t"; then ++ break ++ elif $ac_last_try; then ++ as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 ++ else ++ ac_delim="$ac_delim!$ac_delim _$ac_delim!! " ++ fi ++done ++ ++# For the awk script, D is an array of macro values keyed by name, ++# likewise P contains macro parameters if any. Preserve backslash ++# newline sequences. ++ ++ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* ++sed -n ' ++s/.\{148\}/&'"$ac_delim"'/g ++t rset ++:rset ++s/^[ ]*#[ ]*define[ ][ ]*/ / ++t def ++d ++:def ++s/\\$// ++t bsnl ++s/["\\]/\\&/g ++s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ ++D["\1"]=" \3"/p ++s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p ++d ++:bsnl ++s/["\\]/\\&/g ++s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ ++D["\1"]=" \3\\\\\\n"\\/p ++t cont ++s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p ++t cont ++d ++:cont ++n ++s/.\{148\}/&'"$ac_delim"'/g ++t clear ++:clear ++s/\\$// ++t bsnlc ++s/["\\]/\\&/g; s/^/"/; s/$/"/p ++d ++:bsnlc ++s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p ++b cont ++' >$CONFIG_STATUS || ac_write_fail=1 ++ ++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ++ for (key in D) D_is_set[key] = 1 ++ FS = "" ++} ++/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { ++ line = \$ 0 ++ split(line, arg, " ") ++ if (arg[1] == "#") { ++ defundef = arg[2] ++ mac1 = arg[3] ++ } else { ++ defundef = substr(arg[1], 2) ++ mac1 = arg[2] ++ } ++ split(mac1, mac2, "(") #) ++ macro = mac2[1] ++ prefix = substr(line, 1, index(line, defundef) - 1) ++ if (D_is_set[macro]) { ++ # Preserve the white space surrounding the "#". ++ print prefix "define", macro P[macro] D[macro] ++ next ++ } else { ++ # Replace #undef with comments. This is necessary, for example, ++ # in the case of _POSIX_SOURCE, which is predefined and required ++ # on some systems where configure will not decide to define it. ++ if (defundef == "undef") { ++ print "/*", prefix defundef, macro, "*/" ++ next ++ } ++ } ++} ++{ print } ++_ACAWK ++_ACEOF ++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ++ as_fn_error "could not setup config headers machinery" "$LINENO" 5 ++fi # test -n "$CONFIG_HEADERS" ++ ++ ++eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" ++shift ++for ac_tag ++do ++ case $ac_tag in ++ :[FHLC]) ac_mode=$ac_tag; continue;; ++ esac ++ case $ac_mode$ac_tag in ++ :[FHL]*:*);; ++ :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; ++ :[FH]-) ac_tag=-:-;; ++ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; ++ esac ++ ac_save_IFS=$IFS ++ IFS=: ++ set x $ac_tag ++ IFS=$ac_save_IFS ++ shift ++ ac_file=$1 ++ shift ++ ++ case $ac_mode in ++ :L) ac_source=$1;; ++ :[FH]) ++ ac_file_inputs= ++ for ac_f ++ do ++ case $ac_f in ++ -) ac_f="$tmp/stdin";; ++ *) # Look for the file first in the build tree, then in the source tree ++ # (if the path is not absolute). The absolute path cannot be DOS-style, ++ # because $ac_f cannot contain `:'. ++ test -f "$ac_f" || ++ case $ac_f in ++ [\\/$]*) false;; ++ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; ++ esac || ++ as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; ++ esac ++ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac ++ as_fn_append ac_file_inputs " '$ac_f'" ++ done ++ ++ # Let's still pretend it is `configure' which instantiates (i.e., don't ++ # use $as_me), people would be surprised to read: ++ # /* config.h. Generated by config.status. */ ++ configure_input='Generated from '` ++ $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' ++ `' by configure.' ++ if test x"$ac_file" != x-; then ++ configure_input="$ac_file. $configure_input" ++ { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 ++$as_echo "$as_me: creating $ac_file" >&6;} ++ fi ++ # Neutralize special characters interpreted by sed in replacement strings. ++ case $configure_input in #( ++ *\&* | *\|* | *\\* ) ++ ac_sed_conf_input=`$as_echo "$configure_input" | ++ sed 's/[\\\\&|]/\\\\&/g'`;; #( ++ *) ac_sed_conf_input=$configure_input;; ++ esac ++ ++ case $ac_tag in ++ *:-:* | *:-) cat >"$tmp/stdin" \ ++ || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; ++ esac ++ ;; ++ esac ++ ++ ac_dir=`$as_dirname -- "$ac_file" || ++$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ++ X"$ac_file" : 'X\(//\)[^/]' \| \ ++ X"$ac_file" : 'X\(//\)$' \| \ ++ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || ++$as_echo X"$ac_file" | ++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\/\)[^/].*/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\/\)$/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\).*/{ ++ s//\1/ ++ q ++ } ++ s/.*/./; q'` ++ as_dir="$ac_dir"; as_fn_mkdir_p ++ ac_builddir=. ++ ++case "$ac_dir" in ++.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; ++*) ++ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` ++ # A ".." for each directory in $ac_dir_suffix. ++ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` ++ case $ac_top_builddir_sub in ++ "") ac_top_builddir_sub=. ac_top_build_prefix= ;; ++ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; ++ esac ;; ++esac ++ac_abs_top_builddir=$ac_pwd ++ac_abs_builddir=$ac_pwd$ac_dir_suffix ++# for backward compatibility: ++ac_top_builddir=$ac_top_build_prefix ++ ++case $srcdir in ++ .) # We are building in place. ++ ac_srcdir=. ++ ac_top_srcdir=$ac_top_builddir_sub ++ ac_abs_top_srcdir=$ac_pwd ;; ++ [\\/]* | ?:[\\/]* ) # Absolute name. ++ ac_srcdir=$srcdir$ac_dir_suffix; ++ ac_top_srcdir=$srcdir ++ ac_abs_top_srcdir=$srcdir ;; ++ *) # Relative name. ++ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ++ ac_top_srcdir=$ac_top_build_prefix$srcdir ++ ac_abs_top_srcdir=$ac_pwd/$srcdir ;; ++esac ++ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix ++ ++ ++ case $ac_mode in ++ :F) ++ # ++ # CONFIG_FILE ++ # ++ ++ case $INSTALL in ++ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; ++ *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; ++ esac ++ ac_MKDIR_P=$MKDIR_P ++ case $MKDIR_P in ++ [\\/$]* | ?:[\\/]* ) ;; ++ */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; ++ esac ++_ACEOF ++ ++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ++# If the template does not know about datarootdir, expand it. ++# FIXME: This hack should be removed a few years after 2.60. ++ac_datarootdir_hack=; ac_datarootdir_seen= ++ac_sed_dataroot=' ++/datarootdir/ { ++ p ++ q ++} ++/@datadir@/p ++/@docdir@/p ++/@infodir@/p ++/@localedir@/p ++/@mandir@/p' ++case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in ++*datarootdir*) ac_datarootdir_seen=yes;; ++*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 ++$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} ++_ACEOF ++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ++ ac_datarootdir_hack=' ++ s&@datadir@&$datadir&g ++ s&@docdir@&$docdir&g ++ s&@infodir@&$infodir&g ++ s&@localedir@&$localedir&g ++ s&@mandir@&$mandir&g ++ s&\\\${datarootdir}&$datarootdir&g' ;; ++esac ++_ACEOF ++ ++# Neutralize VPATH when `$srcdir' = `.'. ++# Shell code in configure.ac might set extrasub. ++# FIXME: do we really want to maintain this feature? ++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ++ac_sed_extra="$ac_vpsub ++$extrasub ++_ACEOF ++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ++:t ++/@[a-zA-Z_][a-zA-Z_0-9]*@/!b ++s|@configure_input@|$ac_sed_conf_input|;t t ++s&@top_builddir@&$ac_top_builddir_sub&;t t ++s&@top_build_prefix@&$ac_top_build_prefix&;t t ++s&@srcdir@&$ac_srcdir&;t t ++s&@abs_srcdir@&$ac_abs_srcdir&;t t ++s&@top_srcdir@&$ac_top_srcdir&;t t ++s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t ++s&@builddir@&$ac_builddir&;t t ++s&@abs_builddir@&$ac_abs_builddir&;t t ++s&@abs_top_builddir@&$ac_abs_top_builddir&;t t ++s&@INSTALL@&$ac_INSTALL&;t t ++s&@MKDIR_P@&$ac_MKDIR_P&;t t ++$ac_datarootdir_hack ++" ++eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ ++ || as_fn_error "could not create $ac_file" "$LINENO" 5 ++ ++test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && ++ { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && ++ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' ++which seems to be undefined. Please make sure it is defined." >&5 ++$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' ++which seems to be undefined. Please make sure it is defined." >&2;} ++ ++ rm -f "$tmp/stdin" ++ case $ac_file in ++ -) cat "$tmp/out" && rm -f "$tmp/out";; ++ *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; ++ esac \ ++ || as_fn_error "could not create $ac_file" "$LINENO" 5 ++ ;; ++ :H) ++ # ++ # CONFIG_HEADER ++ # ++ if test x"$ac_file" != x-; then ++ { ++ $as_echo "/* $configure_input */" \ ++ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" ++ } >"$tmp/config.h" \ ++ || as_fn_error "could not create $ac_file" "$LINENO" 5 ++ if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 ++$as_echo "$as_me: $ac_file is unchanged" >&6;} ++ else ++ rm -f "$ac_file" ++ mv "$tmp/config.h" "$ac_file" \ ++ || as_fn_error "could not create $ac_file" "$LINENO" 5 ++ fi ++ else ++ $as_echo "/* $configure_input */" \ ++ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ ++ || as_fn_error "could not create -" "$LINENO" 5 ++ fi ++# Compute "$ac_file"'s index in $config_headers. ++_am_arg="$ac_file" ++_am_stamp_count=1 ++for _am_header in $config_headers :; do ++ case $_am_header in ++ $_am_arg | $_am_arg:* ) ++ break ;; ++ * ) ++ _am_stamp_count=`expr $_am_stamp_count + 1` ;; ++ esac ++done ++echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || ++$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ ++ X"$_am_arg" : 'X\(//\)[^/]' \| \ ++ X"$_am_arg" : 'X\(//\)$' \| \ ++ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || ++$as_echo X"$_am_arg" | ++ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\/\)[^/].*/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\/\)$/{ ++ s//\1/ ++ q ++ } ++ /^X\(\/\).*/{ ++ s//\1/ ++ q ++ } ++ s/.*/./; q'`/stamp-h$_am_stamp_count ++ ;; ++ ++ :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 ++$as_echo "$as_me: executing $ac_file commands" >&6;} ++ ;; ++ esac ++ ++ ++ case $ac_file$ac_mode in ++ "default-1":C) ++# Only add multilib support code if we just rebuilt the top-level ++# Makefile. ++case " $CONFIG_FILES " in ++ *" Makefile "*) ++ ac_file=Makefile . ${multi_basedir}/config-ml.in ++ ;; ++esac ;; ++ "libtool":C) ++ ++ # See if we are running on zsh, and set the options which allow our ++ # commands through without removal of \ escapes. ++ if test -n "${ZSH_VERSION+set}" ; then ++ setopt NO_GLOB_SUBST ++ fi ++ ++ cfgfile="${ofile}T" ++ trap "$RM \"$cfgfile\"; exit 1" 1 2 15 ++ $RM "$cfgfile" ++ ++ cat <<_LT_EOF >> "$cfgfile" ++#! $SHELL ++ ++# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. ++# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION ++# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: ++# NOTE: Changes made to this file will be lost: look at ltmain.sh. ++# ++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, ++# 2006, 2007, 2008, 2009 Free Software Foundation, Inc. ++# Written by Gordon Matzigkeit, 1996 ++# ++# This file is part of GNU Libtool. ++# ++# GNU Libtool is free software; you can redistribute it and/or ++# modify it under the terms of the GNU General Public License as ++# published by the Free Software Foundation; either version 2 of ++# the License, or (at your option) any later version. ++# ++# As a special exception to the GNU General Public License, ++# if you distribute this file as part of a program or library that ++# is built using GNU Libtool, you may include this file under the ++# same distribution terms that you use for the rest of that program. ++# ++# GNU Libtool is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GNU Libtool; see the file COPYING. If not, a copy ++# can be downloaded from http://www.gnu.org/licenses/gpl.html, or ++# obtained by writing to the Free Software Foundation, Inc., ++# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ ++ ++# The names of the tagged configurations supported by this script. ++available_tags="" ++ ++# ### BEGIN LIBTOOL CONFIG ++ ++# Which release of libtool.m4 was used? ++macro_version=$macro_version ++macro_revision=$macro_revision ++ ++# Whether or not to build shared libraries. ++build_libtool_libs=$enable_shared ++ ++# Whether or not to build static libraries. ++build_old_libs=$enable_static ++ ++# What type of objects to build. ++pic_mode=$pic_mode ++ ++# Whether or not to optimize for fast installation. ++fast_install=$enable_fast_install ++ ++# Shell to use when invoking shell scripts. ++SHELL=$lt_SHELL ++ ++# An echo program that protects backslashes. ++ECHO=$lt_ECHO ++ ++# The host system. ++host_alias=$host_alias ++host=$host ++host_os=$host_os ++ ++# The build system. ++build_alias=$build_alias ++build=$build ++build_os=$build_os ++ ++# A sed program that does not truncate output. ++SED=$lt_SED ++ ++# Sed that helps us avoid accidentally triggering echo(1) options like -n. ++Xsed="\$SED -e 1s/^X//" ++ ++# A grep program that handles long lines. ++GREP=$lt_GREP ++ ++# An ERE matcher. ++EGREP=$lt_EGREP ++ ++# A literal string matcher. ++FGREP=$lt_FGREP ++ ++# A BSD- or MS-compatible name lister. ++NM=$lt_NM ++ ++# Whether we need soft or hard links. ++LN_S=$lt_LN_S ++ ++# What is the maximum length of a command? ++max_cmd_len=$max_cmd_len ++ ++# Object file suffix (normally "o"). ++objext=$ac_objext ++ ++# Executable file suffix (normally ""). ++exeext=$exeext ++ ++# whether the shell understands "unset". ++lt_unset=$lt_unset ++ ++# turn spaces into newlines. ++SP2NL=$lt_lt_SP2NL ++ ++# turn newlines into spaces. ++NL2SP=$lt_lt_NL2SP ++ ++# An object symbol dumper. ++OBJDUMP=$lt_OBJDUMP ++ ++# Method to check whether dependent libraries are shared objects. ++deplibs_check_method=$lt_deplibs_check_method ++ ++# Command to use when deplibs_check_method == "file_magic". ++file_magic_cmd=$lt_file_magic_cmd ++ ++# The archiver. ++AR=$lt_AR ++AR_FLAGS=$lt_AR_FLAGS ++ ++# A symbol stripping program. ++STRIP=$lt_STRIP ++ ++# Commands used to install an old-style archive. ++RANLIB=$lt_RANLIB ++old_postinstall_cmds=$lt_old_postinstall_cmds ++old_postuninstall_cmds=$lt_old_postuninstall_cmds ++ ++# Whether to use a lock for old archive extraction. ++lock_old_archive_extraction=$lock_old_archive_extraction ++ ++# A C compiler. ++LTCC=$lt_CC ++ ++# LTCC compiler flags. ++LTCFLAGS=$lt_CFLAGS ++ ++# Take the output of nm and produce a listing of raw symbols and C names. ++global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe ++ ++# Transform the output of nm in a proper C declaration. ++global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl ++ ++# Transform the output of nm in a C name address pair. ++global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address ++ ++# Transform the output of nm in a C name address pair when lib prefix is needed. ++global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix ++ ++# The name of the directory that contains temporary libtool files. ++objdir=$objdir ++ ++# Used to examine libraries when file_magic_cmd begins with "file". ++MAGIC_CMD=$MAGIC_CMD ++ ++# Must we lock files when doing compilation? ++need_locks=$lt_need_locks ++ ++# Tool to manipulate archived DWARF debug symbol files on Mac OS X. ++DSYMUTIL=$lt_DSYMUTIL ++ ++# Tool to change global to local symbols on Mac OS X. ++NMEDIT=$lt_NMEDIT ++ ++# Tool to manipulate fat objects and archives on Mac OS X. ++LIPO=$lt_LIPO ++ ++# ldd/readelf like tool for Mach-O binaries on Mac OS X. ++OTOOL=$lt_OTOOL ++ ++# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. ++OTOOL64=$lt_OTOOL64 ++ ++# Old archive suffix (normally "a"). ++libext=$libext ++ ++# Shared library suffix (normally ".so"). ++shrext_cmds=$lt_shrext_cmds ++ ++# The commands to extract the exported symbol list from a shared archive. ++extract_expsyms_cmds=$lt_extract_expsyms_cmds ++ ++# Variables whose values should be saved in libtool wrapper scripts and ++# restored at link time. ++variables_saved_for_relink=$lt_variables_saved_for_relink ++ ++# Do we need the "lib" prefix for modules? ++need_lib_prefix=$need_lib_prefix ++ ++# Do we need a version for libraries? ++need_version=$need_version ++ ++# Library versioning type. ++version_type=$version_type ++ ++# Shared library runtime path variable. ++runpath_var=$runpath_var ++ ++# Shared library path variable. ++shlibpath_var=$shlibpath_var ++ ++# Is shlibpath searched before the hard-coded library search path? ++shlibpath_overrides_runpath=$shlibpath_overrides_runpath ++ ++# Format of library name prefix. ++libname_spec=$lt_libname_spec ++ ++# List of archive names. First name is the real one, the rest are links. ++# The last name is the one that the linker finds with -lNAME ++library_names_spec=$lt_library_names_spec ++ ++# The coded name of the library, if different from the real name. ++soname_spec=$lt_soname_spec ++ ++# Permission mode override for installation of shared libraries. ++install_override_mode=$lt_install_override_mode ++ ++# Command to use after installation of a shared archive. ++postinstall_cmds=$lt_postinstall_cmds ++ ++# Command to use after uninstallation of a shared archive. ++postuninstall_cmds=$lt_postuninstall_cmds ++ ++# Commands used to finish a libtool library installation in a directory. ++finish_cmds=$lt_finish_cmds ++ ++# As "finish_cmds", except a single script fragment to be evaled but ++# not shown. ++finish_eval=$lt_finish_eval ++ ++# Whether we should hardcode library paths into libraries. ++hardcode_into_libs=$hardcode_into_libs ++ ++# Compile-time system search path for libraries. ++sys_lib_search_path_spec=$lt_sys_lib_search_path_spec ++ ++# Run-time system search path for libraries. ++sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec ++ ++# Whether dlopen is supported. ++dlopen_support=$enable_dlopen ++ ++# Whether dlopen of programs is supported. ++dlopen_self=$enable_dlopen_self ++ ++# Whether dlopen of statically linked programs is supported. ++dlopen_self_static=$enable_dlopen_self_static ++ ++# Commands to strip libraries. ++old_striplib=$lt_old_striplib ++striplib=$lt_striplib ++ ++ ++# The linker used to build libraries. ++LD=$lt_LD ++ ++# How to create reloadable object files. ++reload_flag=$lt_reload_flag ++reload_cmds=$lt_reload_cmds ++ ++# Commands used to build an old-style archive. ++old_archive_cmds=$lt_old_archive_cmds ++ ++# A language specific compiler. ++CC=$lt_compiler ++ ++# Is the compiler the GNU compiler? ++with_gcc=$GCC ++ ++# Compiler flag to turn off builtin functions. ++no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag ++ ++# How to pass a linker flag through the compiler. ++wl=$lt_lt_prog_compiler_wl ++ ++# Additional compiler flags for building library objects. ++pic_flag=$lt_lt_prog_compiler_pic ++ ++# Compiler flag to prevent dynamic linking. ++link_static_flag=$lt_lt_prog_compiler_static ++ ++# Does compiler simultaneously support -c and -o options? ++compiler_c_o=$lt_lt_cv_prog_compiler_c_o ++ ++# Whether or not to add -lc for building shared libraries. ++build_libtool_need_lc=$archive_cmds_need_lc ++ ++# Whether or not to disallow shared libs when runtime libs are static. ++allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes ++ ++# Compiler flag to allow reflexive dlopens. ++export_dynamic_flag_spec=$lt_export_dynamic_flag_spec ++ ++# Compiler flag to generate shared objects directly from archives. ++whole_archive_flag_spec=$lt_whole_archive_flag_spec ++ ++# Whether the compiler copes with passing no objects directly. ++compiler_needs_object=$lt_compiler_needs_object ++ ++# Create an old-style archive from a shared archive. ++old_archive_from_new_cmds=$lt_old_archive_from_new_cmds ++ ++# Create a temporary old-style archive to link instead of a shared archive. ++old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds ++ ++# Commands used to build a shared archive. ++archive_cmds=$lt_archive_cmds ++archive_expsym_cmds=$lt_archive_expsym_cmds ++ ++# Commands used to build a loadable module if different from building ++# a shared archive. ++module_cmds=$lt_module_cmds ++module_expsym_cmds=$lt_module_expsym_cmds ++ ++# Whether we are building with GNU ld or not. ++with_gnu_ld=$lt_with_gnu_ld ++ ++# Flag that allows shared libraries with undefined symbols to be built. ++allow_undefined_flag=$lt_allow_undefined_flag ++ ++# Flag that enforces no undefined symbols. ++no_undefined_flag=$lt_no_undefined_flag ++ ++# Flag to hardcode \$libdir into a binary during linking. ++# This must work even if \$libdir does not exist ++hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec ++ ++# If ld is used when linking, flag to hardcode \$libdir into a binary ++# during linking. This must work even if \$libdir does not exist. ++hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld ++ ++# Whether we need a single "-rpath" flag with a separated argument. ++hardcode_libdir_separator=$lt_hardcode_libdir_separator ++ ++# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes ++# DIR into the resulting binary. ++hardcode_direct=$hardcode_direct ++ ++# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes ++# DIR into the resulting binary and the resulting library dependency is ++# "absolute",i.e impossible to change by setting \${shlibpath_var} if the ++# library is relocated. ++hardcode_direct_absolute=$hardcode_direct_absolute ++ ++# Set to "yes" if using the -LDIR flag during linking hardcodes DIR ++# into the resulting binary. ++hardcode_minus_L=$hardcode_minus_L ++ ++# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR ++# into the resulting binary. ++hardcode_shlibpath_var=$hardcode_shlibpath_var ++ ++# Set to "yes" if building a shared library automatically hardcodes DIR ++# into the library and all subsequent libraries and executables linked ++# against it. ++hardcode_automatic=$hardcode_automatic ++ ++# Set to yes if linker adds runtime paths of dependent libraries ++# to runtime path list. ++inherit_rpath=$inherit_rpath ++ ++# Whether libtool must link a program against all its dependency libraries. ++link_all_deplibs=$link_all_deplibs ++ ++# Fix the shell variable \$srcfile for the compiler. ++fix_srcfile_path=$lt_fix_srcfile_path ++ ++# Set to "yes" if exported symbols are required. ++always_export_symbols=$always_export_symbols ++ ++# The commands to list exported symbols. ++export_symbols_cmds=$lt_export_symbols_cmds ++ ++# Symbols that should not be listed in the preloaded symbols. ++exclude_expsyms=$lt_exclude_expsyms ++ ++# Symbols that must always be exported. ++include_expsyms=$lt_include_expsyms ++ ++# Commands necessary for linking programs (against libraries) with templates. ++prelink_cmds=$lt_prelink_cmds ++ ++# Specify filename containing input files. ++file_list_spec=$lt_file_list_spec ++ ++# How to hardcode a shared library path into an executable. ++hardcode_action=$hardcode_action ++ ++# ### END LIBTOOL CONFIG ++ ++_LT_EOF ++ ++ case $host_os in ++ aix3*) ++ cat <<\_LT_EOF >> "$cfgfile" ++# AIX sometimes has problems with the GCC collect2 program. For some ++# reason, if we set the COLLECT_NAMES environment variable, the problems ++# vanish in a puff of smoke. ++if test "X${COLLECT_NAMES+set}" != Xset; then ++ COLLECT_NAMES= ++ export COLLECT_NAMES ++fi ++_LT_EOF ++ ;; ++ esac ++ ++ ++ltmain="$ac_aux_dir/ltmain.sh" ++ ++ ++ # We use sed instead of cat because bash on DJGPP gets confused if ++ # if finds mixed CR/LF and LF-only lines. Since sed operates in ++ # text mode, it properly converts lines to CR/LF. This bash problem ++ # is reportedly fixed, but why not run on old versions too? ++ sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ ++ || (rm -f "$cfgfile"; exit 1) ++ ++ case $xsi_shell in ++ yes) ++ cat << \_LT_EOF >> "$cfgfile" ++ ++# func_dirname file append nondir_replacement ++# Compute the dirname of FILE. If nonempty, add APPEND to the result, ++# otherwise set result to NONDIR_REPLACEMENT. ++func_dirname () ++{ ++ case ${1} in ++ */*) func_dirname_result="${1%/*}${2}" ;; ++ * ) func_dirname_result="${3}" ;; ++ esac ++} ++ ++# func_basename file ++func_basename () ++{ ++ func_basename_result="${1##*/}" ++} ++ ++# func_dirname_and_basename file append nondir_replacement ++# perform func_basename and func_dirname in a single function ++# call: ++# dirname: Compute the dirname of FILE. If nonempty, ++# add APPEND to the result, otherwise set result ++# to NONDIR_REPLACEMENT. ++# value returned in "$func_dirname_result" ++# basename: Compute filename of FILE. ++# value retuned in "$func_basename_result" ++# Implementation must be kept synchronized with func_dirname ++# and func_basename. For efficiency, we do not delegate to ++# those functions but instead duplicate the functionality here. ++func_dirname_and_basename () ++{ ++ case ${1} in ++ */*) func_dirname_result="${1%/*}${2}" ;; ++ * ) func_dirname_result="${3}" ;; ++ esac ++ func_basename_result="${1##*/}" ++} ++ ++# func_stripname prefix suffix name ++# strip PREFIX and SUFFIX off of NAME. ++# PREFIX and SUFFIX must not contain globbing or regex special ++# characters, hashes, percent signs, but SUFFIX may contain a leading ++# dot (in which case that matches only a dot). ++func_stripname () ++{ ++ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are ++ # positional parameters, so assign one to ordinary parameter first. ++ func_stripname_result=${3} ++ func_stripname_result=${func_stripname_result#"${1}"} ++ func_stripname_result=${func_stripname_result%"${2}"} ++} ++ ++# func_opt_split ++func_opt_split () ++{ ++ func_opt_split_opt=${1%%=*} ++ func_opt_split_arg=${1#*=} ++} ++ ++# func_lo2o object ++func_lo2o () ++{ ++ case ${1} in ++ *.lo) func_lo2o_result=${1%.lo}.${objext} ;; ++ *) func_lo2o_result=${1} ;; ++ esac ++} ++ ++# func_xform libobj-or-source ++func_xform () ++{ ++ func_xform_result=${1%.*}.lo ++} ++ ++# func_arith arithmetic-term... ++func_arith () ++{ ++ func_arith_result=$(( $* )) ++} ++ ++# func_len string ++# STRING may not start with a hyphen. ++func_len () ++{ ++ func_len_result=${#1} ++} ++ ++_LT_EOF ++ ;; ++ *) # Bourne compatible functions. ++ cat << \_LT_EOF >> "$cfgfile" ++ ++# func_dirname file append nondir_replacement ++# Compute the dirname of FILE. If nonempty, add APPEND to the result, ++# otherwise set result to NONDIR_REPLACEMENT. ++func_dirname () ++{ ++ # Extract subdirectory from the argument. ++ func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` ++ if test "X$func_dirname_result" = "X${1}"; then ++ func_dirname_result="${3}" ++ else ++ func_dirname_result="$func_dirname_result${2}" ++ fi ++} ++ ++# func_basename file ++func_basename () ++{ ++ func_basename_result=`$ECHO "${1}" | $SED "$basename"` ++} ++ ++ ++# func_stripname prefix suffix name ++# strip PREFIX and SUFFIX off of NAME. ++# PREFIX and SUFFIX must not contain globbing or regex special ++# characters, hashes, percent signs, but SUFFIX may contain a leading ++# dot (in which case that matches only a dot). ++# func_strip_suffix prefix name ++func_stripname () ++{ ++ case ${2} in ++ .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; ++ *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; ++ esac ++} ++ ++# sed scripts: ++my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' ++my_sed_long_arg='1s/^-[^=]*=//' ++ ++# func_opt_split ++func_opt_split () ++{ ++ func_opt_split_opt=`$ECHO "${1}" | $SED "$my_sed_long_opt"` ++ func_opt_split_arg=`$ECHO "${1}" | $SED "$my_sed_long_arg"` ++} ++ ++# func_lo2o object ++func_lo2o () ++{ ++ func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` ++} ++ ++# func_xform libobj-or-source ++func_xform () ++{ ++ func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` ++} ++ ++# func_arith arithmetic-term... ++func_arith () ++{ ++ func_arith_result=`expr "$@"` ++} ++ ++# func_len string ++# STRING may not start with a hyphen. ++func_len () ++{ ++ func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` ++} ++ ++_LT_EOF ++esac ++ ++case $lt_shell_append in ++ yes) ++ cat << \_LT_EOF >> "$cfgfile" ++ ++# func_append var value ++# Append VALUE to the end of shell variable VAR. ++func_append () ++{ ++ eval "$1+=\$2" ++} ++_LT_EOF ++ ;; ++ *) ++ cat << \_LT_EOF >> "$cfgfile" ++ ++# func_append var value ++# Append VALUE to the end of shell variable VAR. ++func_append () ++{ ++ eval "$1=\$$1\$2" ++} ++ ++_LT_EOF ++ ;; ++ esac ++ ++ ++ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ ++ || (rm -f "$cfgfile"; exit 1) ++ ++ mv -f "$cfgfile" "$ofile" || ++ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") ++ chmod +x "$ofile" ++ ++ ;; ++ "gstdint.h":C) ++if test "$GCC" = yes; then ++ echo "/* generated for " `$CC --version | sed 1q` "*/" > tmp-stdint.h ++else ++ echo "/* generated for $CC */" > tmp-stdint.h ++fi ++ ++sed 's/^ *//' >> tmp-stdint.h < ++EOF ++ ++if test "$acx_cv_header_stdint" != stdint.h; then ++ echo "#include " >> tmp-stdint.h ++fi ++if test "$acx_cv_header_stdint" != stddef.h; then ++ echo "#include <$acx_cv_header_stdint>" >> tmp-stdint.h ++fi ++ ++sed 's/^ *//' >> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <= 199901L ++ #ifndef _INT64_T ++ #define _INT64_T ++ #ifndef __int64_t_defined ++ #ifndef int64_t ++ typedef long long int64_t; ++ #endif ++ #endif ++ #endif ++ #ifndef _UINT64_T ++ #define _UINT64_T ++ #ifndef uint64_t ++ typedef unsigned long long uint64_t; ++ #endif ++ #endif ++ ++ #elif defined __GNUC__ && defined (__STDC__) && __STDC__-0 ++ /* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and ++ does not implement __extension__. But that compiler doesn't define ++ __GNUC_MINOR__. */ ++ # if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) ++ # define __extension__ ++ # endif ++ ++ # ifndef _INT64_T ++ # define _INT64_T ++ # ifndef int64_t ++ __extension__ typedef long long int64_t; ++ # endif ++ # endif ++ # ifndef _UINT64_T ++ # define _UINT64_T ++ # ifndef uint64_t ++ __extension__ typedef unsigned long long uint64_t; ++ # endif ++ # endif ++ ++ #elif !defined __STRICT_ANSI__ ++ # if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ ++ ++ # ifndef _INT64_T ++ # define _INT64_T ++ # ifndef int64_t ++ typedef __int64 int64_t; ++ # endif ++ # endif ++ # ifndef _UINT64_T ++ # define _UINT64_T ++ # ifndef uint64_t ++ typedef unsigned __int64 uint64_t; ++ # endif ++ # endif ++ # endif /* compiler */ ++ ++ #endif /* ANSI version */ ++EOF ++fi ++ ++# ------------- done int64_t types, emit intptr types ------------ ++if test "$ac_cv_type_uintptr_t" != yes; then ++ sed 's/^ *//' >> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h < ++ # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually ++ # append it here. Only modify Makefiles that have just been created. ++ # ++ # Also, get rid of this simulated-VPATH thing that automake does. ++ cat > vpsed << \_EOF ++ s!`test -f '$<' || echo '$(srcdir)/'`!! ++_EOF ++ for i in $SUBDIRS; do ++ case $CONFIG_FILES in ++ *${i}/Makefile*) ++ #echo "Adding MULTISUBDIR to $i/Makefile" ++ sed -f vpsed $i/Makefile > tmp ++ grep '^MULTISUBDIR =' Makefile >> tmp ++ mv tmp $i/Makefile ++ ;; ++ esac ++ done ++ rm vpsed ++ fi ++ fi ++ ;; ++ ++ esac ++done # for ac_tag ++ ++ ++as_fn_exit 0 ++_ACEOF ++ac_clean_files=$ac_clean_files_save ++ ++test $ac_write_fail = 0 || ++ as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 ++ ++ ++# configure is writing to config.log, and then calls config.status. ++# config.status does its own redirection, appending to config.log. ++# Unfortunately, on DOS this fails, as config.log is still kept open ++# by configure, so config.status won't be able to write to it; its ++# output is simply discarded. So we exec the FD to /dev/null, ++# effectively closing config.log, so it can be properly (re)opened and ++# appended to by config.status. When coming back to configure, we ++# need to make the FD available again. ++if test "$no_create" != yes; then ++ ac_cs_success=: ++ ac_config_status_args= ++ test "$silent" = yes && ++ ac_config_status_args="$ac_config_status_args --quiet" ++ exec 5>/dev/null ++ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false ++ exec 5>>config.log ++ # Use ||, not &&, to avoid exiting from the if with $? = 1, which ++ # would make configure fail if this is the last instruction. ++ $ac_cs_success || as_fn_exit $? ++fi ++if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 ++$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} ++fi ++ diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/configure.ac index 000000000,000000000..2b774b058 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/configure.ac @@@ -1,0 -1,0 +1,409 @@@ ++# configure.ac -- Backtrace configure script. ++# Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ ++# Redistribution and use in source and binary forms, with or without ++# modification, are permitted provided that the following conditions are ++# met: ++ ++# (1) Redistributions of source code must retain the above copyright ++# notice, this list of conditions and the following disclaimer. ++ ++# (2) Redistributions in binary form must reproduce the above copyright ++# notice, this list of conditions and the following disclaimer in ++# the documentation and/or other materials provided with the ++# distribution. ++ ++# (3) The name of the author may not be used to ++# endorse or promote products derived from this software without ++# specific prior written permission. ++ ++# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++# POSSIBILITY OF SUCH DAMAGE. ++ ++AC_PREREQ(2.64) ++AC_INIT(package-unused, version-unused,, libbacktrace) ++AC_CONFIG_SRCDIR(backtrace.h) ++AC_CONFIG_HEADER(config.h) ++ ++if test -n "${with_target_subdir}"; then ++ AM_ENABLE_MULTILIB(, ..) ++fi ++ ++AC_CANONICAL_SYSTEM ++target_alias=${target_alias-$host_alias} ++ ++AC_USE_SYSTEM_EXTENSIONS ++ ++libtool_VERSION=1:0:0 ++AC_SUBST(libtool_VERSION) ++ ++# 1.11.1: Require that version of automake. ++# foreign: Don't require README, INSTALL, NEWS, etc. ++# no-define: Don't define PACKAGE and VERSION. ++# no-dependencies: Don't generate automatic dependencies. ++# (because it breaks when using bootstrap-lean, since some of the ++# headers are gone at "make install" time). ++# -Wall: Issue all automake warnings. ++# -Wno-portability: Don't warn about constructs supported by GNU make. ++# (because GCC requires GNU make anyhow). ++AM_INIT_AUTOMAKE([1.11.1 foreign no-dist no-define no-dependencies -Wall -Wno-portability]) ++ ++AM_MAINTAINER_MODE ++ ++AC_ARG_WITH(target-subdir, ++[ --with-target-subdir=SUBDIR Configuring in a subdirectory for target]) ++ ++# We must force CC to /not/ be precious variables; otherwise ++# the wrong, non-multilib-adjusted value will be used in multilibs. ++# As a side effect, we have to subst CFLAGS ourselves. ++m4_rename([_AC_ARG_VAR_PRECIOUS],[backtrace_PRECIOUS]) ++m4_define([_AC_ARG_VAR_PRECIOUS],[]) ++AC_PROG_CC ++m4_rename_force([backtrace_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) ++ ++AC_SUBST(CFLAGS) ++ ++AC_PROG_RANLIB ++ ++AC_PROG_AWK ++case "$AWK" in ++"") AC_MSG_ERROR([can't build without awk]) ;; ++esac ++ ++LT_INIT ++AM_PROG_LIBTOOL ++ ++backtrace_supported=yes ++ ++if test -n "${with_target_subdir}"; then ++ # We are compiling a GCC library. We can assume that the unwind ++ # library exists. ++ BACKTRACE_FILE="backtrace.lo simple.lo" ++else ++ AC_CHECK_HEADER([unwind.h], ++ [AC_CHECK_FUNC([_Unwind_Backtrace], ++ [BACKTRACE_FILE="backtrace.lo simple.lo"], ++ [BACKTRACE_FILE="nounwind.lo" ++ backtrace_supported=no])], ++ [BACKTRACE_FILE="nounwind.lo" ++ backtrace_supported=no]) ++fi ++AC_SUBST(BACKTRACE_FILE) ++ ++EXTRA_FLAGS= ++if test -n "${with_target_subdir}"; then ++ EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@" ++else ++ AC_CACHE_CHECK([for -funwind-tables option], ++ [libbacktrace_cv_c_unwind_tables], ++ [CFLAGS_hold="$CFLAGS" ++ CFLAGS="$CFLAGS -funwind-tables" ++ AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM([static int f() { return 0; }], [return f();])], ++ [libbacktrace_cv_c_unwind_tables=yes], ++ [libbacktrace_cv_c_unwind_tables=no]) ++ CFLAGS="$CFLAGS_hold"]) ++ if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then ++ EXTRA_FLAGS=-funwind-tables ++ fi ++ AC_CACHE_CHECK([for -frandom-seed=string option], ++ [libbacktrace_cv_c_random_seed_string], ++ [CFLAGS_hold="$CFLAGS" ++ CFLAGS="$CFLAGS -frandom-seed=conftest.lo" ++ AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM([], [return 0;])], ++ [libbacktrace_cv_c_random_seed_string=yes], ++ [libbacktrace_cv_c_random_seed_string=no]) ++ CFLAGS="$CFLAGS_hold"]) ++ if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then ++ EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@" ++ fi ++fi ++AC_SUBST(EXTRA_FLAGS) ++ ++ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \ ++ -Wmissing-prototypes -Wold-style-definition \ ++ -Wmissing-format-attribute -Wcast-qual], ++ [WARN_FLAGS]) ++ ++if test -n "${with_target_subdir}"; then ++ WARN_FLAGS="$WARN_FLAGS -Werror" ++fi ++ ++AC_SUBST(WARN_FLAGS) ++ ++if test -n "${with_target_subdir}"; then ++ GCC_CHECK_UNWIND_GETIPINFO ++else ++ ac_save_CFFLAGS="$CFLAGS" ++ CFLAGS="$CFLAGS -Werror-implicit-function-declaration" ++ AC_MSG_CHECKING([for _Unwind_GetIPInfo]) ++ AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM( ++ [#include "unwind.h" ++ struct _Unwind_Context *context; ++ int ip_before_insn = 0;], ++ [return _Unwind_GetIPInfo (context, &ip_before_insn);])], ++ [have_unwind_getipinfo=yes], [have_unwind_getipinfo=no]) ++ CFLAGS="$ac_save_CFLAGS" ++ AC_MSG_RESULT([$have_unwind_getipinfo]) ++ if test "$have_unwind_getipinfo" = "yes"; then ++ AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.]) ++ fi ++fi ++ ++# Enable --enable-host-shared. ++AC_ARG_ENABLE(host-shared, ++[AS_HELP_STRING([--enable-host-shared], ++ [build host code as shared libraries])], ++[PIC_FLAG=-fPIC], [PIC_FLAG=]) ++AC_SUBST(PIC_FLAG) ++ ++# Test for __sync support. ++AC_CACHE_CHECK([__sync extensions], ++[libbacktrace_cv_sys_sync], ++[if test -n "${with_target_subdir}"; then ++ case "${host}" in ++ hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;; ++ *) libbacktrace_cv_sys_sync=yes ;; ++ esac ++ else ++ AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM([int i;], ++ [__sync_bool_compare_and_swap (&i, i, i); ++ __sync_lock_test_and_set (&i, 1); ++ __sync_lock_release (&i);])], ++ [libbacktrace_cv_sys_sync=yes], ++ [libbacktrace_cv_sys_sync=no]) ++ fi]) ++BACKTRACE_SUPPORTS_THREADS=0 ++if test "$libbacktrace_cv_sys_sync" = "yes"; then ++ BACKTRACE_SUPPORTS_THREADS=1 ++ AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1, ++ [Define to 1 if you have the __sync functions]) ++fi ++AC_SUBST(BACKTRACE_SUPPORTS_THREADS) ++ ++# Test for __atomic support. ++AC_CACHE_CHECK([__atomic extensions], ++[libbacktrace_cv_sys_atomic], ++[if test -n "${with_target_subdir}"; then ++ libbacktrace_cv_sys_atomic=yes ++ else ++ AC_LINK_IFELSE( ++ [AC_LANG_PROGRAM([int i;], ++ [__atomic_load_n (&i, __ATOMIC_ACQUIRE); ++ __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])], ++ [libbacktrace_cv_sys_atomic=yes], ++ [libbacktrace_cv_sys_atomic=no]) ++ fi]) ++if test "$libbacktrace_cv_sys_atomic" = "yes"; then ++ AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1, ++ [Define to 1 if you have the __atomic functions]) ++fi ++ ++# The library needs to be able to read the executable itself. Compile ++# a file to determine the executable format. The awk script ++# filetype.awk prints out the file type. ++AC_CACHE_CHECK([output filetype], ++[libbacktrace_cv_sys_filetype], ++[filetype= ++AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM([int i;], [int j;])], ++ [filetype=`${AWK} -f $srcdir/filetype.awk conftest.$ac_objext`], ++ [AC_MSG_FAILURE([compiler failed])]) ++libbacktrace_cv_sys_filetype=$filetype]) ++ ++# Match the file type to decide what files to compile. ++FORMAT_FILE= ++backtrace_supports_data=yes ++case "$libbacktrace_cv_sys_filetype" in ++elf*) FORMAT_FILE="elf.lo" ;; ++pecoff) FORMAT_FILE="pecoff.lo" ++ backtrace_supports_data=no ++ ;; ++*) AC_MSG_WARN([could not determine output file type]) ++ FORMAT_FILE="unknown.lo" ++ backtrace_supported=no ++ ;; ++esac ++AC_SUBST(FORMAT_FILE) ++ ++# ELF defines. ++elfsize= ++case "$libbacktrace_cv_sys_filetype" in ++elf32) elfsize=32 ;; ++elf64) elfsize=64 ;; ++*) elfsize=unused ++esac ++AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64]) ++ ++BACKTRACE_SUPPORTED=0 ++if test "$backtrace_supported" = "yes"; then ++ BACKTRACE_SUPPORTED=1 ++fi ++AC_SUBST(BACKTRACE_SUPPORTED) ++ ++BACKTRACE_SUPPORTS_DATA=0 ++if test "$backtrace_supports_data" = "yes"; then ++ BACKTRACE_SUPPORTS_DATA=1 ++fi ++AC_SUBST(BACKTRACE_SUPPORTS_DATA) ++ ++GCC_HEADER_STDINT(gstdint.h) ++ ++AC_CHECK_HEADERS(sys/mman.h) ++if test "$ac_cv_header_sys_mman_h" = "no"; then ++ have_mmap=no ++else ++ if test -n "${with_target_subdir}"; then ++ # When built as a GCC target library, we can't do a link test. We ++ # simply assume that if we have mman.h, we have mmap. ++ have_mmap=yes ++ case "${host}" in ++ spu-*-*|*-*-msdosdjgpp) ++ # The SPU does not have mmap, but it has a sys/mman.h header file ++ # containing "mmap_eaddr" and the mmap flags, confusing the test. ++ # DJGPP also has sys/man.h, but no mmap ++ have_mmap=no ;; ++ esac ++ else ++ AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no]) ++ fi ++fi ++if test "$have_mmap" = "no"; then ++ VIEW_FILE=read.lo ++ ALLOC_FILE=alloc.lo ++else ++ VIEW_FILE=mmapio.lo ++ AC_PREPROC_IFELSE([ ++#include ++#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) ++ #error no MAP_ANONYMOUS ++#endif ++], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo]) ++fi ++AC_SUBST(VIEW_FILE) ++AC_SUBST(ALLOC_FILE) ++ ++BACKTRACE_USES_MALLOC=0 ++if test "$ALLOC_FILE" = "alloc.lo"; then ++ BACKTRACE_USES_MALLOC=1 ++fi ++AC_SUBST(BACKTRACE_USES_MALLOC) ++ ++# Check for dl_iterate_phdr. ++AC_CHECK_HEADERS(link.h) ++if test "$ac_cv_header_link_h" = "no"; then ++ have_dl_iterate_phdr=no ++else ++ if test -n "${with_target_subdir}"; then ++ # When built as a GCC target library, we can't do a link test. ++ AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes], ++ [have_dl_iterate_phdr=no]) ++ case "${host}" in ++ *-*-solaris2.10*) ++ # Avoid dl_iterate_phdr on Solaris 10, where it is in the ++ # header file but is only in -ldl. ++ have_dl_iterate_phdr=no ;; ++ esac ++ else ++ AC_CHECK_FUNC([dl_iterate_phdr], [have_dl_iterate_phdr=yes], ++ [have_dl_iterate_phdr=no]) ++ fi ++fi ++if test "$have_dl_iterate_phdr" = "yes"; then ++ AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.]) ++fi ++ ++# Check for the fcntl function. ++if test -n "${with_target_subdir}"; then ++ case "${host}" in ++ *-*-mingw*) have_fcntl=no ;; ++ spu-*-*) have_fcntl=no ;; ++ *) have_fcntl=yes ;; ++ esac ++else ++ AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no]) ++fi ++if test "$have_fcntl" = "yes"; then ++ AC_DEFINE([HAVE_FCNTL], 1, ++ [Define to 1 if you have the fcntl function]) ++fi ++ ++AC_CHECK_DECLS(strnlen) ++ ++# Check for getexecname function. ++if test -n "${with_target_subdir}"; then ++ case "${host}" in ++ *-*-solaris2*) have_getexecname=yes ;; ++ *) have_getexecname=no ;; ++ esac ++else ++ AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no]) ++fi ++if test "$have_getexecname" = "yes"; then ++ AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.]) ++fi ++ ++AC_CACHE_CHECK([whether tests can run], ++ [libbacktrace_cv_sys_native], ++ [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])], ++ [libbacktrace_cv_sys_native=yes], ++ [libbacktrace_cv_sys_native=no], ++ [libbacktrace_cv_sys_native=no])]) ++AM_CONDITIONAL(NATIVE, test "$libbacktrace_cv_sys_native" = "yes") ++ ++if test "${multilib}" = "yes"; then ++ multilib_arg="--enable-multilib" ++else ++ multilib_arg= ++fi ++ ++AC_CONFIG_FILES(Makefile backtrace-supported.h) ++ ++# We need multilib support, but only if configuring for the target. ++AC_CONFIG_COMMANDS([default], ++[if test -n "$CONFIG_FILES"; then ++ if test -n "${with_target_subdir}"; then ++ # Multilibs need MULTISUBDIR defined correctly in certain makefiles so ++ # that multilib installs will end up installed in the correct place. ++ # The testsuite needs it for multilib-aware ABI baseline files. ++ # To work around this not being passed down from config-ml.in -> ++ # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually ++ # append it here. Only modify Makefiles that have just been created. ++ # ++ # Also, get rid of this simulated-VPATH thing that automake does. ++ cat > vpsed << \_EOF ++ s!`test -f '$<' || echo '$(srcdir)/'`!! ++_EOF ++ for i in $SUBDIRS; do ++ case $CONFIG_FILES in ++ *${i}/Makefile*) ++ #echo "Adding MULTISUBDIR to $i/Makefile" ++ sed -f vpsed $i/Makefile > tmp ++ grep '^MULTISUBDIR =' Makefile >> tmp ++ mv tmp $i/Makefile ++ ;; ++ esac ++ done ++ rm vpsed ++ fi ++ fi ++], ++[ ++# Variables needed in config.status (file generation) which aren't already ++# passed by autoconf. ++SUBDIRS="$SUBDIRS" ++]) ++ ++AC_OUTPUT diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/dwarf.c index 000000000,000000000..37682c003 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/dwarf.c @@@ -1,0 -1,0 +1,3038 @@@ ++/* dwarf.c -- Get file/line information from DWARF for backtraces. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++#include ++ ++#include "dwarf2.h" ++#include "filenames.h" ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++#if !defined(HAVE_DECL_STRNLEN) || !HAVE_DECL_STRNLEN ++ ++/* If strnlen is not declared, provide our own version. */ ++ ++static size_t ++xstrnlen (const char *s, size_t maxlen) ++{ ++ size_t i; ++ ++ for (i = 0; i < maxlen; ++i) ++ if (s[i] == '\0') ++ break; ++ return i; ++} ++ ++#define strnlen xstrnlen ++ ++#endif ++ ++/* A buffer to read DWARF info. */ ++ ++struct dwarf_buf ++{ ++ /* Buffer name for error messages. */ ++ const char *name; ++ /* Start of the buffer. */ ++ const unsigned char *start; ++ /* Next byte to read. */ ++ const unsigned char *buf; ++ /* The number of bytes remaining. */ ++ size_t left; ++ /* Whether the data is big-endian. */ ++ int is_bigendian; ++ /* Error callback routine. */ ++ backtrace_error_callback error_callback; ++ /* Data for error_callback. */ ++ void *data; ++ /* Non-zero if we've reported an underflow error. */ ++ int reported_underflow; ++}; ++ ++/* A single attribute in a DWARF abbreviation. */ ++ ++struct attr ++{ ++ /* The attribute name. */ ++ enum dwarf_attribute name; ++ /* The attribute form. */ ++ enum dwarf_form form; ++}; ++ ++/* A single DWARF abbreviation. */ ++ ++struct abbrev ++{ ++ /* The abbrev code--the number used to refer to the abbrev. */ ++ uint64_t code; ++ /* The entry tag. */ ++ enum dwarf_tag tag; ++ /* Non-zero if this abbrev has child entries. */ ++ int has_children; ++ /* The number of attributes. */ ++ size_t num_attrs; ++ /* The attributes. */ ++ struct attr *attrs; ++}; ++ ++/* The DWARF abbreviations for a compilation unit. This structure ++ only exists while reading the compilation unit. Most DWARF readers ++ seem to a hash table to map abbrev ID's to abbrev entries. ++ However, we primarily care about GCC, and GCC simply issues ID's in ++ numerical order starting at 1. So we simply keep a sorted vector, ++ and try to just look up the code. */ ++ ++struct abbrevs ++{ ++ /* The number of abbrevs in the vector. */ ++ size_t num_abbrevs; ++ /* The abbrevs, sorted by the code field. */ ++ struct abbrev *abbrevs; ++}; ++ ++/* The different kinds of attribute values. */ ++ ++enum attr_val_encoding ++{ ++ /* An address. */ ++ ATTR_VAL_ADDRESS, ++ /* A unsigned integer. */ ++ ATTR_VAL_UINT, ++ /* A sigd integer. */ ++ ATTR_VAL_SINT, ++ /* A string. */ ++ ATTR_VAL_STRING, ++ /* An offset to other data in the containing unit. */ ++ ATTR_VAL_REF_UNIT, ++ /* An offset to other data within the .dwarf_info section. */ ++ ATTR_VAL_REF_INFO, ++ /* An offset to data in some other section. */ ++ ATTR_VAL_REF_SECTION, ++ /* A type signature. */ ++ ATTR_VAL_REF_TYPE, ++ /* A block of data (not represented). */ ++ ATTR_VAL_BLOCK, ++ /* An expression (not represented). */ ++ ATTR_VAL_EXPR, ++}; ++ ++/* An attribute value. */ ++ ++struct attr_val ++{ ++ /* How the value is stored in the field u. */ ++ enum attr_val_encoding encoding; ++ union ++ { ++ /* ATTR_VAL_ADDRESS, ATTR_VAL_UINT, ATTR_VAL_REF*. */ ++ uint64_t uint; ++ /* ATTR_VAL_SINT. */ ++ int64_t sint; ++ /* ATTR_VAL_STRING. */ ++ const char *string; ++ /* ATTR_VAL_BLOCK not stored. */ ++ } u; ++}; ++ ++/* The line number program header. */ ++ ++struct line_header ++{ ++ /* The version of the line number information. */ ++ int version; ++ /* The minimum instruction length. */ ++ unsigned int min_insn_len; ++ /* The maximum number of ops per instruction. */ ++ unsigned int max_ops_per_insn; ++ /* The line base for special opcodes. */ ++ int line_base; ++ /* The line range for special opcodes. */ ++ unsigned int line_range; ++ /* The opcode base--the first special opcode. */ ++ unsigned int opcode_base; ++ /* Opcode lengths, indexed by opcode - 1. */ ++ const unsigned char *opcode_lengths; ++ /* The number of directory entries. */ ++ size_t dirs_count; ++ /* The directory entries. */ ++ const char **dirs; ++ /* The number of filenames. */ ++ size_t filenames_count; ++ /* The filenames. */ ++ const char **filenames; ++}; ++ ++/* Map a single PC value to a file/line. We will keep a vector of ++ these sorted by PC value. Each file/line will be correct from the ++ PC up to the PC of the next entry if there is one. We allocate one ++ extra entry at the end so that we can use bsearch. */ ++ ++struct line ++{ ++ /* PC. */ ++ uintptr_t pc; ++ /* File name. Many entries in the array are expected to point to ++ the same file name. */ ++ const char *filename; ++ /* Line number. */ ++ int lineno; ++ /* Index of the object in the original array read from the DWARF ++ section, before it has been sorted. The index makes it possible ++ to use Quicksort and maintain stability. */ ++ int idx; ++}; ++ ++/* A growable vector of line number information. This is used while ++ reading the line numbers. */ ++ ++struct line_vector ++{ ++ /* Memory. This is an array of struct line. */ ++ struct backtrace_vector vec; ++ /* Number of valid mappings. */ ++ size_t count; ++}; ++ ++/* A function described in the debug info. */ ++ ++struct function ++{ ++ /* The name of the function. */ ++ const char *name; ++ /* If this is an inlined function, the filename of the call ++ site. */ ++ const char *caller_filename; ++ /* If this is an inlined function, the line number of the call ++ site. */ ++ int caller_lineno; ++ /* Map PC ranges to inlined functions. */ ++ struct function_addrs *function_addrs; ++ size_t function_addrs_count; ++}; ++ ++/* An address range for a function. This maps a PC value to a ++ specific function. */ ++ ++struct function_addrs ++{ ++ /* Range is LOW <= PC < HIGH. */ ++ uint64_t low; ++ uint64_t high; ++ /* Function for this address range. */ ++ struct function *function; ++}; ++ ++/* A growable vector of function address ranges. */ ++ ++struct function_vector ++{ ++ /* Memory. This is an array of struct function_addrs. */ ++ struct backtrace_vector vec; ++ /* Number of address ranges present. */ ++ size_t count; ++}; ++ ++/* A DWARF compilation unit. This only holds the information we need ++ to map a PC to a file and line. */ ++ ++struct unit ++{ ++ /* The first entry for this compilation unit. */ ++ const unsigned char *unit_data; ++ /* The length of the data for this compilation unit. */ ++ size_t unit_data_len; ++ /* The offset of UNIT_DATA from the start of the information for ++ this compilation unit. */ ++ size_t unit_data_offset; ++ /* DWARF version. */ ++ int version; ++ /* Whether unit is DWARF64. */ ++ int is_dwarf64; ++ /* Address size. */ ++ int addrsize; ++ /* Offset into line number information. */ ++ off_t lineoff; ++ /* Primary source file. */ ++ const char *filename; ++ /* Compilation command working directory. */ ++ const char *comp_dir; ++ /* Absolute file name, only set if needed. */ ++ const char *abs_filename; ++ /* The abbreviations for this unit. */ ++ struct abbrevs abbrevs; ++ ++ /* The fields above this point are read in during initialization and ++ may be accessed freely. The fields below this point are read in ++ as needed, and therefore require care, as different threads may ++ try to initialize them simultaneously. */ ++ ++ /* PC to line number mapping. This is NULL if the values have not ++ been read. This is (struct line *) -1 if there was an error ++ reading the values. */ ++ struct line *lines; ++ /* Number of entries in lines. */ ++ size_t lines_count; ++ /* PC ranges to function. */ ++ struct function_addrs *function_addrs; ++ size_t function_addrs_count; ++}; ++ ++/* An address range for a compilation unit. This maps a PC value to a ++ specific compilation unit. Note that we invert the representation ++ in DWARF: instead of listing the units and attaching a list of ++ ranges, we list the ranges and have each one point to the unit. ++ This lets us do a binary search to find the unit. */ ++ ++struct unit_addrs ++{ ++ /* Range is LOW <= PC < HIGH. */ ++ uint64_t low; ++ uint64_t high; ++ /* Compilation unit for this address range. */ ++ struct unit *u; ++}; ++ ++/* A growable vector of compilation unit address ranges. */ ++ ++struct unit_addrs_vector ++{ ++ /* Memory. This is an array of struct unit_addrs. */ ++ struct backtrace_vector vec; ++ /* Number of address ranges present. */ ++ size_t count; ++}; ++ ++/* The information we need to map a PC to a file and line. */ ++ ++struct dwarf_data ++{ ++ /* The data for the next file we know about. */ ++ struct dwarf_data *next; ++ /* The base address for this file. */ ++ uintptr_t base_address; ++ /* A sorted list of address ranges. */ ++ struct unit_addrs *addrs; ++ /* Number of address ranges in list. */ ++ size_t addrs_count; ++ /* The unparsed .debug_info section. */ ++ const unsigned char *dwarf_info; ++ size_t dwarf_info_size; ++ /* The unparsed .debug_line section. */ ++ const unsigned char *dwarf_line; ++ size_t dwarf_line_size; ++ /* The unparsed .debug_ranges section. */ ++ const unsigned char *dwarf_ranges; ++ size_t dwarf_ranges_size; ++ /* The unparsed .debug_str section. */ ++ const unsigned char *dwarf_str; ++ size_t dwarf_str_size; ++ /* Whether the data is big-endian or not. */ ++ int is_bigendian; ++ /* A vector used for function addresses. We keep this here so that ++ we can grow the vector as we read more functions. */ ++ struct function_vector fvec; ++}; ++ ++/* Report an error for a DWARF buffer. */ ++ ++static void ++dwarf_buf_error (struct dwarf_buf *buf, const char *msg) ++{ ++ char b[200]; ++ ++ snprintf (b, sizeof b, "%s in %s at %d", ++ msg, buf->name, (int) (buf->buf - buf->start)); ++ buf->error_callback (buf->data, b, 0); ++} ++ ++/* Require at least COUNT bytes in BUF. Return 1 if all is well, 0 on ++ error. */ ++ ++static int ++require (struct dwarf_buf *buf, size_t count) ++{ ++ if (buf->left >= count) ++ return 1; ++ ++ if (!buf->reported_underflow) ++ { ++ dwarf_buf_error (buf, "DWARF underflow"); ++ buf->reported_underflow = 1; ++ } ++ ++ return 0; ++} ++ ++/* Advance COUNT bytes in BUF. Return 1 if all is well, 0 on ++ error. */ ++ ++static int ++advance (struct dwarf_buf *buf, size_t count) ++{ ++ if (!require (buf, count)) ++ return 0; ++ buf->buf += count; ++ buf->left -= count; ++ return 1; ++} ++ ++/* Read one byte from BUF and advance 1 byte. */ ++ ++static unsigned char ++read_byte (struct dwarf_buf *buf) ++{ ++ const unsigned char *p = buf->buf; ++ ++ if (!advance (buf, 1)) ++ return 0; ++ return p[0]; ++} ++ ++/* Read a signed char from BUF and advance 1 byte. */ ++ ++static signed char ++read_sbyte (struct dwarf_buf *buf) ++{ ++ const unsigned char *p = buf->buf; ++ ++ if (!advance (buf, 1)) ++ return 0; ++ return (*p ^ 0x80) - 0x80; ++} ++ ++/* Read a uint16 from BUF and advance 2 bytes. */ ++ ++static uint16_t ++read_uint16 (struct dwarf_buf *buf) ++{ ++ const unsigned char *p = buf->buf; ++ ++ if (!advance (buf, 2)) ++ return 0; ++ if (buf->is_bigendian) ++ return ((uint16_t) p[0] << 8) | (uint16_t) p[1]; ++ else ++ return ((uint16_t) p[1] << 8) | (uint16_t) p[0]; ++} ++ ++/* Read a uint32 from BUF and advance 4 bytes. */ ++ ++static uint32_t ++read_uint32 (struct dwarf_buf *buf) ++{ ++ const unsigned char *p = buf->buf; ++ ++ if (!advance (buf, 4)) ++ return 0; ++ if (buf->is_bigendian) ++ return (((uint32_t) p[0] << 24) | ((uint32_t) p[1] << 16) ++ | ((uint32_t) p[2] << 8) | (uint32_t) p[3]); ++ else ++ return (((uint32_t) p[3] << 24) | ((uint32_t) p[2] << 16) ++ | ((uint32_t) p[1] << 8) | (uint32_t) p[0]); ++} ++ ++/* Read a uint64 from BUF and advance 8 bytes. */ ++ ++static uint64_t ++read_uint64 (struct dwarf_buf *buf) ++{ ++ const unsigned char *p = buf->buf; ++ ++ if (!advance (buf, 8)) ++ return 0; ++ if (buf->is_bigendian) ++ return (((uint64_t) p[0] << 56) | ((uint64_t) p[1] << 48) ++ | ((uint64_t) p[2] << 40) | ((uint64_t) p[3] << 32) ++ | ((uint64_t) p[4] << 24) | ((uint64_t) p[5] << 16) ++ | ((uint64_t) p[6] << 8) | (uint64_t) p[7]); ++ else ++ return (((uint64_t) p[7] << 56) | ((uint64_t) p[6] << 48) ++ | ((uint64_t) p[5] << 40) | ((uint64_t) p[4] << 32) ++ | ((uint64_t) p[3] << 24) | ((uint64_t) p[2] << 16) ++ | ((uint64_t) p[1] << 8) | (uint64_t) p[0]); ++} ++ ++/* Read an offset from BUF and advance the appropriate number of ++ bytes. */ ++ ++static uint64_t ++read_offset (struct dwarf_buf *buf, int is_dwarf64) ++{ ++ if (is_dwarf64) ++ return read_uint64 (buf); ++ else ++ return read_uint32 (buf); ++} ++ ++/* Read an address from BUF and advance the appropriate number of ++ bytes. */ ++ ++static uint64_t ++read_address (struct dwarf_buf *buf, int addrsize) ++{ ++ switch (addrsize) ++ { ++ case 1: ++ return read_byte (buf); ++ case 2: ++ return read_uint16 (buf); ++ case 4: ++ return read_uint32 (buf); ++ case 8: ++ return read_uint64 (buf); ++ default: ++ dwarf_buf_error (buf, "unrecognized address size"); ++ return 0; ++ } ++} ++ ++/* Return whether a value is the highest possible address, given the ++ address size. */ ++ ++static int ++is_highest_address (uint64_t address, int addrsize) ++{ ++ switch (addrsize) ++ { ++ case 1: ++ return address == (unsigned char) -1; ++ case 2: ++ return address == (uint16_t) -1; ++ case 4: ++ return address == (uint32_t) -1; ++ case 8: ++ return address == (uint64_t) -1; ++ default: ++ return 0; ++ } ++} ++ ++/* Read an unsigned LEB128 number. */ ++ ++static uint64_t ++read_uleb128 (struct dwarf_buf *buf) ++{ ++ uint64_t ret; ++ unsigned int shift; ++ int overflow; ++ unsigned char b; ++ ++ ret = 0; ++ shift = 0; ++ overflow = 0; ++ do ++ { ++ const unsigned char *p; ++ ++ p = buf->buf; ++ if (!advance (buf, 1)) ++ return 0; ++ b = *p; ++ if (shift < 64) ++ ret |= ((uint64_t) (b & 0x7f)) << shift; ++ else if (!overflow) ++ { ++ dwarf_buf_error (buf, "LEB128 overflows uint64_t"); ++ overflow = 1; ++ } ++ shift += 7; ++ } ++ while ((b & 0x80) != 0); ++ ++ return ret; ++} ++ ++/* Read a signed LEB128 number. */ ++ ++static int64_t ++read_sleb128 (struct dwarf_buf *buf) ++{ ++ uint64_t val; ++ unsigned int shift; ++ int overflow; ++ unsigned char b; ++ ++ val = 0; ++ shift = 0; ++ overflow = 0; ++ do ++ { ++ const unsigned char *p; ++ ++ p = buf->buf; ++ if (!advance (buf, 1)) ++ return 0; ++ b = *p; ++ if (shift < 64) ++ val |= ((uint64_t) (b & 0x7f)) << shift; ++ else if (!overflow) ++ { ++ dwarf_buf_error (buf, "signed LEB128 overflows uint64_t"); ++ overflow = 1; ++ } ++ shift += 7; ++ } ++ while ((b & 0x80) != 0); ++ ++ if ((b & 0x40) != 0 && shift < 64) ++ val |= ((uint64_t) -1) << shift; ++ ++ return (int64_t) val; ++} ++ ++/* Return the length of an LEB128 number. */ ++ ++static size_t ++leb128_len (const unsigned char *p) ++{ ++ size_t ret; ++ ++ ret = 1; ++ while ((*p & 0x80) != 0) ++ { ++ ++p; ++ ++ret; ++ } ++ return ret; ++} ++ ++/* Free an abbreviations structure. */ ++ ++static void ++free_abbrevs (struct backtrace_state *state, struct abbrevs *abbrevs, ++ backtrace_error_callback error_callback, void *data) ++{ ++ size_t i; ++ ++ for (i = 0; i < abbrevs->num_abbrevs; ++i) ++ backtrace_free (state, abbrevs->abbrevs[i].attrs, ++ abbrevs->abbrevs[i].num_attrs * sizeof (struct attr), ++ error_callback, data); ++ backtrace_free (state, abbrevs->abbrevs, ++ abbrevs->num_abbrevs * sizeof (struct abbrev), ++ error_callback, data); ++ abbrevs->num_abbrevs = 0; ++ abbrevs->abbrevs = NULL; ++} ++ ++/* Read an attribute value. Returns 1 on success, 0 on failure. If ++ the value can be represented as a uint64_t, sets *VAL and sets ++ *IS_VALID to 1. We don't try to store the value of other attribute ++ forms, because we don't care about them. */ ++ ++static int ++read_attribute (enum dwarf_form form, struct dwarf_buf *buf, ++ int is_dwarf64, int version, int addrsize, ++ const unsigned char *dwarf_str, size_t dwarf_str_size, ++ struct attr_val *val) ++{ ++ /* Avoid warnings about val.u.FIELD may be used uninitialized if ++ this function is inlined. The warnings aren't valid but can ++ occur because the different fields are set and used ++ conditionally. */ ++ memset (val, 0, sizeof *val); ++ ++ switch (form) ++ { ++ case DW_FORM_addr: ++ val->encoding = ATTR_VAL_ADDRESS; ++ val->u.uint = read_address (buf, addrsize); ++ return 1; ++ case DW_FORM_block2: ++ val->encoding = ATTR_VAL_BLOCK; ++ return advance (buf, read_uint16 (buf)); ++ case DW_FORM_block4: ++ val->encoding = ATTR_VAL_BLOCK; ++ return advance (buf, read_uint32 (buf)); ++ case DW_FORM_data2: ++ val->encoding = ATTR_VAL_UINT; ++ val->u.uint = read_uint16 (buf); ++ return 1; ++ case DW_FORM_data4: ++ val->encoding = ATTR_VAL_UINT; ++ val->u.uint = read_uint32 (buf); ++ return 1; ++ case DW_FORM_data8: ++ val->encoding = ATTR_VAL_UINT; ++ val->u.uint = read_uint64 (buf); ++ return 1; ++ case DW_FORM_string: ++ val->encoding = ATTR_VAL_STRING; ++ val->u.string = (const char *) buf->buf; ++ return advance (buf, strnlen ((const char *) buf->buf, buf->left) + 1); ++ case DW_FORM_block: ++ val->encoding = ATTR_VAL_BLOCK; ++ return advance (buf, read_uleb128 (buf)); ++ case DW_FORM_block1: ++ val->encoding = ATTR_VAL_BLOCK; ++ return advance (buf, read_byte (buf)); ++ case DW_FORM_data1: ++ val->encoding = ATTR_VAL_UINT; ++ val->u.uint = read_byte (buf); ++ return 1; ++ case DW_FORM_flag: ++ val->encoding = ATTR_VAL_UINT; ++ val->u.uint = read_byte (buf); ++ return 1; ++ case DW_FORM_sdata: ++ val->encoding = ATTR_VAL_SINT; ++ val->u.sint = read_sleb128 (buf); ++ return 1; ++ case DW_FORM_strp: ++ { ++ uint64_t offset; ++ ++ offset = read_offset (buf, is_dwarf64); ++ if (offset >= dwarf_str_size) ++ { ++ dwarf_buf_error (buf, "DW_FORM_strp out of range"); ++ return 0; ++ } ++ val->encoding = ATTR_VAL_STRING; ++ val->u.string = (const char *) dwarf_str + offset; ++ return 1; ++ } ++ case DW_FORM_udata: ++ val->encoding = ATTR_VAL_UINT; ++ val->u.uint = read_uleb128 (buf); ++ return 1; ++ case DW_FORM_ref_addr: ++ val->encoding = ATTR_VAL_REF_INFO; ++ if (version == 2) ++ val->u.uint = read_address (buf, addrsize); ++ else ++ val->u.uint = read_offset (buf, is_dwarf64); ++ return 1; ++ case DW_FORM_ref1: ++ val->encoding = ATTR_VAL_REF_UNIT; ++ val->u.uint = read_byte (buf); ++ return 1; ++ case DW_FORM_ref2: ++ val->encoding = ATTR_VAL_REF_UNIT; ++ val->u.uint = read_uint16 (buf); ++ return 1; ++ case DW_FORM_ref4: ++ val->encoding = ATTR_VAL_REF_UNIT; ++ val->u.uint = read_uint32 (buf); ++ return 1; ++ case DW_FORM_ref8: ++ val->encoding = ATTR_VAL_REF_UNIT; ++ val->u.uint = read_uint64 (buf); ++ return 1; ++ case DW_FORM_ref_udata: ++ val->encoding = ATTR_VAL_REF_UNIT; ++ val->u.uint = read_uleb128 (buf); ++ return 1; ++ case DW_FORM_indirect: ++ { ++ uint64_t form; ++ ++ form = read_uleb128 (buf); ++ return read_attribute ((enum dwarf_form) form, buf, is_dwarf64, ++ version, addrsize, dwarf_str, dwarf_str_size, ++ val); ++ } ++ case DW_FORM_sec_offset: ++ val->encoding = ATTR_VAL_REF_SECTION; ++ val->u.uint = read_offset (buf, is_dwarf64); ++ return 1; ++ case DW_FORM_exprloc: ++ val->encoding = ATTR_VAL_EXPR; ++ return advance (buf, read_uleb128 (buf)); ++ case DW_FORM_flag_present: ++ val->encoding = ATTR_VAL_UINT; ++ val->u.uint = 1; ++ return 1; ++ case DW_FORM_ref_sig8: ++ val->encoding = ATTR_VAL_REF_TYPE; ++ val->u.uint = read_uint64 (buf); ++ return 1; ++ case DW_FORM_GNU_addr_index: ++ val->encoding = ATTR_VAL_REF_SECTION; ++ val->u.uint = read_uleb128 (buf); ++ return 1; ++ case DW_FORM_GNU_str_index: ++ val->encoding = ATTR_VAL_REF_SECTION; ++ val->u.uint = read_uleb128 (buf); ++ return 1; ++ case DW_FORM_GNU_ref_alt: ++ val->encoding = ATTR_VAL_REF_SECTION; ++ val->u.uint = read_offset (buf, is_dwarf64); ++ return 1; ++ case DW_FORM_GNU_strp_alt: ++ val->encoding = ATTR_VAL_REF_SECTION; ++ val->u.uint = read_offset (buf, is_dwarf64); ++ return 1; ++ default: ++ dwarf_buf_error (buf, "unrecognized DWARF form"); ++ return 0; ++ } ++} ++ ++/* Compare function_addrs for qsort. When ranges are nested, make the ++ smallest one sort last. */ ++ ++static int ++function_addrs_compare (const void *v1, const void *v2) ++{ ++ const struct function_addrs *a1 = (const struct function_addrs *) v1; ++ const struct function_addrs *a2 = (const struct function_addrs *) v2; ++ ++ if (a1->low < a2->low) ++ return -1; ++ if (a1->low > a2->low) ++ return 1; ++ if (a1->high < a2->high) ++ return 1; ++ if (a1->high > a2->high) ++ return -1; ++ return strcmp (a1->function->name, a2->function->name); ++} ++ ++/* Compare a PC against a function_addrs for bsearch. Note that if ++ there are multiple ranges containing PC, which one will be returned ++ is unpredictable. We compensate for that in dwarf_fileline. */ ++ ++static int ++function_addrs_search (const void *vkey, const void *ventry) ++{ ++ const uintptr_t *key = (const uintptr_t *) vkey; ++ const struct function_addrs *entry = (const struct function_addrs *) ventry; ++ uintptr_t pc; ++ ++ pc = *key; ++ if (pc < entry->low) ++ return -1; ++ else if (pc >= entry->high) ++ return 1; ++ else ++ return 0; ++} ++ ++/* Add a new compilation unit address range to a vector. Returns 1 on ++ success, 0 on failure. */ ++ ++static int ++add_unit_addr (struct backtrace_state *state, uintptr_t base_address, ++ struct unit_addrs addrs, ++ backtrace_error_callback error_callback, void *data, ++ struct unit_addrs_vector *vec) ++{ ++ struct unit_addrs *p; ++ ++ /* Add in the base address of the module here, so that we can look ++ up the PC directly. */ ++ addrs.low += base_address; ++ addrs.high += base_address; ++ ++ /* Try to merge with the last entry. */ ++ if (vec->count > 0) ++ { ++ p = (struct unit_addrs *) vec->vec.base + (vec->count - 1); ++ if ((addrs.low == p->high || addrs.low == p->high + 1) ++ && addrs.u == p->u) ++ { ++ if (addrs.high > p->high) ++ p->high = addrs.high; ++ return 1; ++ } ++ } ++ ++ p = ((struct unit_addrs *) ++ backtrace_vector_grow (state, sizeof (struct unit_addrs), ++ error_callback, data, &vec->vec)); ++ if (p == NULL) ++ return 0; ++ ++ *p = addrs; ++ ++vec->count; ++ return 1; ++} ++ ++/* Free a unit address vector. */ ++ ++static void ++free_unit_addrs_vector (struct backtrace_state *state, ++ struct unit_addrs_vector *vec, ++ backtrace_error_callback error_callback, void *data) ++{ ++ struct unit_addrs *addrs; ++ size_t i; ++ ++ addrs = (struct unit_addrs *) vec->vec.base; ++ for (i = 0; i < vec->count; ++i) ++ free_abbrevs (state, &addrs[i].u->abbrevs, error_callback, data); ++} ++ ++/* Compare unit_addrs for qsort. When ranges are nested, make the ++ smallest one sort last. */ ++ ++static int ++unit_addrs_compare (const void *v1, const void *v2) ++{ ++ const struct unit_addrs *a1 = (const struct unit_addrs *) v1; ++ const struct unit_addrs *a2 = (const struct unit_addrs *) v2; ++ ++ if (a1->low < a2->low) ++ return -1; ++ if (a1->low > a2->low) ++ return 1; ++ if (a1->high < a2->high) ++ return 1; ++ if (a1->high > a2->high) ++ return -1; ++ if (a1->u->lineoff < a2->u->lineoff) ++ return -1; ++ if (a1->u->lineoff > a2->u->lineoff) ++ return 1; ++ return 0; ++} ++ ++/* Compare a PC against a unit_addrs for bsearch. Note that if there ++ are multiple ranges containing PC, which one will be returned is ++ unpredictable. We compensate for that in dwarf_fileline. */ ++ ++static int ++unit_addrs_search (const void *vkey, const void *ventry) ++{ ++ const uintptr_t *key = (const uintptr_t *) vkey; ++ const struct unit_addrs *entry = (const struct unit_addrs *) ventry; ++ uintptr_t pc; ++ ++ pc = *key; ++ if (pc < entry->low) ++ return -1; ++ else if (pc >= entry->high) ++ return 1; ++ else ++ return 0; ++} ++ ++/* Sort the line vector by PC. We want a stable sort here to maintain ++ the order of lines for the same PC values. Since the sequence is ++ being sorted in place, their addresses cannot be relied on to ++ maintain stability. That is the purpose of the index member. */ ++ ++static int ++line_compare (const void *v1, const void *v2) ++{ ++ const struct line *ln1 = (const struct line *) v1; ++ const struct line *ln2 = (const struct line *) v2; ++ ++ if (ln1->pc < ln2->pc) ++ return -1; ++ else if (ln1->pc > ln2->pc) ++ return 1; ++ else if (ln1->idx < ln2->idx) ++ return -1; ++ else if (ln1->idx > ln2->idx) ++ return 1; ++ else ++ return 0; ++} ++ ++/* Find a PC in a line vector. We always allocate an extra entry at ++ the end of the lines vector, so that this routine can safely look ++ at the next entry. Note that when there are multiple mappings for ++ the same PC value, this will return the last one. */ ++ ++static int ++line_search (const void *vkey, const void *ventry) ++{ ++ const uintptr_t *key = (const uintptr_t *) vkey; ++ const struct line *entry = (const struct line *) ventry; ++ uintptr_t pc; ++ ++ pc = *key; ++ if (pc < entry->pc) ++ return -1; ++ else if (pc >= (entry + 1)->pc) ++ return 1; ++ else ++ return 0; ++} ++ ++/* Sort the abbrevs by the abbrev code. This function is passed to ++ both qsort and bsearch. */ ++ ++static int ++abbrev_compare (const void *v1, const void *v2) ++{ ++ const struct abbrev *a1 = (const struct abbrev *) v1; ++ const struct abbrev *a2 = (const struct abbrev *) v2; ++ ++ if (a1->code < a2->code) ++ return -1; ++ else if (a1->code > a2->code) ++ return 1; ++ else ++ { ++ /* This really shouldn't happen. It means there are two ++ different abbrevs with the same code, and that means we don't ++ know which one lookup_abbrev should return. */ ++ return 0; ++ } ++} ++ ++/* Read the abbreviation table for a compilation unit. Returns 1 on ++ success, 0 on failure. */ ++ ++static int ++read_abbrevs (struct backtrace_state *state, uint64_t abbrev_offset, ++ const unsigned char *dwarf_abbrev, size_t dwarf_abbrev_size, ++ int is_bigendian, backtrace_error_callback error_callback, ++ void *data, struct abbrevs *abbrevs) ++{ ++ struct dwarf_buf abbrev_buf; ++ struct dwarf_buf count_buf; ++ size_t num_abbrevs; ++ ++ abbrevs->num_abbrevs = 0; ++ abbrevs->abbrevs = NULL; ++ ++ if (abbrev_offset >= dwarf_abbrev_size) ++ { ++ error_callback (data, "abbrev offset out of range", 0); ++ return 0; ++ } ++ ++ abbrev_buf.name = ".debug_abbrev"; ++ abbrev_buf.start = dwarf_abbrev; ++ abbrev_buf.buf = dwarf_abbrev + abbrev_offset; ++ abbrev_buf.left = dwarf_abbrev_size - abbrev_offset; ++ abbrev_buf.is_bigendian = is_bigendian; ++ abbrev_buf.error_callback = error_callback; ++ abbrev_buf.data = data; ++ abbrev_buf.reported_underflow = 0; ++ ++ /* Count the number of abbrevs in this list. */ ++ ++ count_buf = abbrev_buf; ++ num_abbrevs = 0; ++ while (read_uleb128 (&count_buf) != 0) ++ { ++ if (count_buf.reported_underflow) ++ return 0; ++ ++num_abbrevs; ++ // Skip tag. ++ read_uleb128 (&count_buf); ++ // Skip has_children. ++ read_byte (&count_buf); ++ // Skip attributes. ++ while (read_uleb128 (&count_buf) != 0) ++ read_uleb128 (&count_buf); ++ // Skip form of last attribute. ++ read_uleb128 (&count_buf); ++ } ++ ++ if (count_buf.reported_underflow) ++ return 0; ++ ++ if (num_abbrevs == 0) ++ return 1; ++ ++ abbrevs->num_abbrevs = num_abbrevs; ++ abbrevs->abbrevs = ((struct abbrev *) ++ backtrace_alloc (state, ++ num_abbrevs * sizeof (struct abbrev), ++ error_callback, data)); ++ if (abbrevs->abbrevs == NULL) ++ return 0; ++ memset (abbrevs->abbrevs, 0, num_abbrevs * sizeof (struct abbrev)); ++ ++ num_abbrevs = 0; ++ while (1) ++ { ++ uint64_t code; ++ struct abbrev a; ++ size_t num_attrs; ++ struct attr *attrs; ++ ++ if (abbrev_buf.reported_underflow) ++ goto fail; ++ ++ code = read_uleb128 (&abbrev_buf); ++ if (code == 0) ++ break; ++ ++ a.code = code; ++ a.tag = (enum dwarf_tag) read_uleb128 (&abbrev_buf); ++ a.has_children = read_byte (&abbrev_buf); ++ ++ count_buf = abbrev_buf; ++ num_attrs = 0; ++ while (read_uleb128 (&count_buf) != 0) ++ { ++ ++num_attrs; ++ read_uleb128 (&count_buf); ++ } ++ ++ if (num_attrs == 0) ++ { ++ attrs = NULL; ++ read_uleb128 (&abbrev_buf); ++ read_uleb128 (&abbrev_buf); ++ } ++ else ++ { ++ attrs = ((struct attr *) ++ backtrace_alloc (state, num_attrs * sizeof *attrs, ++ error_callback, data)); ++ if (attrs == NULL) ++ goto fail; ++ num_attrs = 0; ++ while (1) ++ { ++ uint64_t name; ++ uint64_t form; ++ ++ name = read_uleb128 (&abbrev_buf); ++ form = read_uleb128 (&abbrev_buf); ++ if (name == 0) ++ break; ++ attrs[num_attrs].name = (enum dwarf_attribute) name; ++ attrs[num_attrs].form = (enum dwarf_form) form; ++ ++num_attrs; ++ } ++ } ++ ++ a.num_attrs = num_attrs; ++ a.attrs = attrs; ++ ++ abbrevs->abbrevs[num_abbrevs] = a; ++ ++num_abbrevs; ++ } ++ ++ backtrace_qsort (abbrevs->abbrevs, abbrevs->num_abbrevs, ++ sizeof (struct abbrev), abbrev_compare); ++ ++ return 1; ++ ++ fail: ++ free_abbrevs (state, abbrevs, error_callback, data); ++ return 0; ++} ++ ++/* Return the abbrev information for an abbrev code. */ ++ ++static const struct abbrev * ++lookup_abbrev (struct abbrevs *abbrevs, uint64_t code, ++ backtrace_error_callback error_callback, void *data) ++{ ++ struct abbrev key; ++ void *p; ++ ++ /* With GCC, where abbrevs are simply numbered in order, we should ++ be able to just look up the entry. */ ++ if (code - 1 < abbrevs->num_abbrevs ++ && abbrevs->abbrevs[code - 1].code == code) ++ return &abbrevs->abbrevs[code - 1]; ++ ++ /* Otherwise we have to search. */ ++ memset (&key, 0, sizeof key); ++ key.code = code; ++ p = bsearch (&key, abbrevs->abbrevs, abbrevs->num_abbrevs, ++ sizeof (struct abbrev), abbrev_compare); ++ if (p == NULL) ++ { ++ error_callback (data, "invalid abbreviation code", 0); ++ return NULL; ++ } ++ return (const struct abbrev *) p; ++} ++ ++/* Add non-contiguous address ranges for a compilation unit. Returns ++ 1 on success, 0 on failure. */ ++ ++static int ++add_unit_ranges (struct backtrace_state *state, uintptr_t base_address, ++ struct unit *u, uint64_t ranges, uint64_t base, ++ int is_bigendian, const unsigned char *dwarf_ranges, ++ size_t dwarf_ranges_size, ++ backtrace_error_callback error_callback, void *data, ++ struct unit_addrs_vector *addrs) ++{ ++ struct dwarf_buf ranges_buf; ++ ++ if (ranges >= dwarf_ranges_size) ++ { ++ error_callback (data, "ranges offset out of range", 0); ++ return 0; ++ } ++ ++ ranges_buf.name = ".debug_ranges"; ++ ranges_buf.start = dwarf_ranges; ++ ranges_buf.buf = dwarf_ranges + ranges; ++ ranges_buf.left = dwarf_ranges_size - ranges; ++ ranges_buf.is_bigendian = is_bigendian; ++ ranges_buf.error_callback = error_callback; ++ ranges_buf.data = data; ++ ranges_buf.reported_underflow = 0; ++ ++ while (1) ++ { ++ uint64_t low; ++ uint64_t high; ++ ++ if (ranges_buf.reported_underflow) ++ return 0; ++ ++ low = read_address (&ranges_buf, u->addrsize); ++ high = read_address (&ranges_buf, u->addrsize); ++ ++ if (low == 0 && high == 0) ++ break; ++ ++ if (is_highest_address (low, u->addrsize)) ++ base = high; ++ else ++ { ++ struct unit_addrs a; ++ ++ a.low = low + base; ++ a.high = high + base; ++ a.u = u; ++ if (!add_unit_addr (state, base_address, a, error_callback, data, ++ addrs)) ++ return 0; ++ } ++ } ++ ++ if (ranges_buf.reported_underflow) ++ return 0; ++ ++ return 1; ++} ++ ++/* Find the address range covered by a compilation unit, reading from ++ UNIT_BUF and adding values to U. Returns 1 if all data could be ++ read, 0 if there is some error. */ ++ ++static int ++find_address_ranges (struct backtrace_state *state, uintptr_t base_address, ++ struct dwarf_buf *unit_buf, ++ const unsigned char *dwarf_str, size_t dwarf_str_size, ++ const unsigned char *dwarf_ranges, ++ size_t dwarf_ranges_size, ++ int is_bigendian, backtrace_error_callback error_callback, ++ void *data, struct unit *u, ++ struct unit_addrs_vector *addrs) ++{ ++ while (unit_buf->left > 0) ++ { ++ uint64_t code; ++ const struct abbrev *abbrev; ++ uint64_t lowpc; ++ int have_lowpc; ++ uint64_t highpc; ++ int have_highpc; ++ int highpc_is_relative; ++ uint64_t ranges; ++ int have_ranges; ++ size_t i; ++ ++ code = read_uleb128 (unit_buf); ++ if (code == 0) ++ return 1; ++ ++ abbrev = lookup_abbrev (&u->abbrevs, code, error_callback, data); ++ if (abbrev == NULL) ++ return 0; ++ ++ lowpc = 0; ++ have_lowpc = 0; ++ highpc = 0; ++ have_highpc = 0; ++ highpc_is_relative = 0; ++ ranges = 0; ++ have_ranges = 0; ++ for (i = 0; i < abbrev->num_attrs; ++i) ++ { ++ struct attr_val val; ++ ++ if (!read_attribute (abbrev->attrs[i].form, unit_buf, ++ u->is_dwarf64, u->version, u->addrsize, ++ dwarf_str, dwarf_str_size, &val)) ++ return 0; ++ ++ switch (abbrev->attrs[i].name) ++ { ++ case DW_AT_low_pc: ++ if (val.encoding == ATTR_VAL_ADDRESS) ++ { ++ lowpc = val.u.uint; ++ have_lowpc = 1; ++ } ++ break; ++ ++ case DW_AT_high_pc: ++ if (val.encoding == ATTR_VAL_ADDRESS) ++ { ++ highpc = val.u.uint; ++ have_highpc = 1; ++ } ++ else if (val.encoding == ATTR_VAL_UINT) ++ { ++ highpc = val.u.uint; ++ have_highpc = 1; ++ highpc_is_relative = 1; ++ } ++ break; ++ ++ case DW_AT_ranges: ++ if (val.encoding == ATTR_VAL_UINT ++ || val.encoding == ATTR_VAL_REF_SECTION) ++ { ++ ranges = val.u.uint; ++ have_ranges = 1; ++ } ++ break; ++ ++ case DW_AT_stmt_list: ++ if (abbrev->tag == DW_TAG_compile_unit ++ && (val.encoding == ATTR_VAL_UINT ++ || val.encoding == ATTR_VAL_REF_SECTION)) ++ u->lineoff = val.u.uint; ++ break; ++ ++ case DW_AT_name: ++ if (abbrev->tag == DW_TAG_compile_unit ++ && val.encoding == ATTR_VAL_STRING) ++ u->filename = val.u.string; ++ break; ++ ++ case DW_AT_comp_dir: ++ if (abbrev->tag == DW_TAG_compile_unit ++ && val.encoding == ATTR_VAL_STRING) ++ u->comp_dir = val.u.string; ++ break; ++ ++ default: ++ break; ++ } ++ } ++ ++ if (abbrev->tag == DW_TAG_compile_unit ++ || abbrev->tag == DW_TAG_subprogram) ++ { ++ if (have_ranges) ++ { ++ if (!add_unit_ranges (state, base_address, u, ranges, lowpc, ++ is_bigendian, dwarf_ranges, ++ dwarf_ranges_size, error_callback, ++ data, addrs)) ++ return 0; ++ } ++ else if (have_lowpc && have_highpc) ++ { ++ struct unit_addrs a; ++ ++ if (highpc_is_relative) ++ highpc += lowpc; ++ a.low = lowpc; ++ a.high = highpc; ++ a.u = u; ++ ++ if (!add_unit_addr (state, base_address, a, error_callback, data, ++ addrs)) ++ return 0; ++ } ++ ++ /* If we found the PC range in the DW_TAG_compile_unit, we ++ can stop now. */ ++ if (abbrev->tag == DW_TAG_compile_unit ++ && (have_ranges || (have_lowpc && have_highpc))) ++ return 1; ++ } ++ ++ if (abbrev->has_children) ++ { ++ if (!find_address_ranges (state, base_address, unit_buf, ++ dwarf_str, dwarf_str_size, ++ dwarf_ranges, dwarf_ranges_size, ++ is_bigendian, error_callback, data, ++ u, addrs)) ++ return 0; ++ } ++ } ++ ++ return 1; ++} ++ ++/* Build a mapping from address ranges to the compilation units where ++ the line number information for that range can be found. Returns 1 ++ on success, 0 on failure. */ ++ ++static int ++build_address_map (struct backtrace_state *state, uintptr_t base_address, ++ const unsigned char *dwarf_info, size_t dwarf_info_size, ++ const unsigned char *dwarf_abbrev, size_t dwarf_abbrev_size, ++ const unsigned char *dwarf_ranges, size_t dwarf_ranges_size, ++ const unsigned char *dwarf_str, size_t dwarf_str_size, ++ int is_bigendian, backtrace_error_callback error_callback, ++ void *data, struct unit_addrs_vector *addrs) ++{ ++ struct dwarf_buf info; ++ struct abbrevs abbrevs; ++ ++ memset (&addrs->vec, 0, sizeof addrs->vec); ++ addrs->count = 0; ++ ++ /* Read through the .debug_info section. FIXME: Should we use the ++ .debug_aranges section? gdb and addr2line don't use it, but I'm ++ not sure why. */ ++ ++ info.name = ".debug_info"; ++ info.start = dwarf_info; ++ info.buf = dwarf_info; ++ info.left = dwarf_info_size; ++ info.is_bigendian = is_bigendian; ++ info.error_callback = error_callback; ++ info.data = data; ++ info.reported_underflow = 0; ++ ++ memset (&abbrevs, 0, sizeof abbrevs); ++ while (info.left > 0) ++ { ++ const unsigned char *unit_data_start; ++ uint64_t len; ++ int is_dwarf64; ++ struct dwarf_buf unit_buf; ++ int version; ++ uint64_t abbrev_offset; ++ int addrsize; ++ struct unit *u; ++ ++ if (info.reported_underflow) ++ goto fail; ++ ++ unit_data_start = info.buf; ++ ++ is_dwarf64 = 0; ++ len = read_uint32 (&info); ++ if (len == 0xffffffff) ++ { ++ len = read_uint64 (&info); ++ is_dwarf64 = 1; ++ } ++ ++ unit_buf = info; ++ unit_buf.left = len; ++ ++ if (!advance (&info, len)) ++ goto fail; ++ ++ version = read_uint16 (&unit_buf); ++ if (version < 2 || version > 4) ++ { ++ dwarf_buf_error (&unit_buf, "unrecognized DWARF version"); ++ goto fail; ++ } ++ ++ abbrev_offset = read_offset (&unit_buf, is_dwarf64); ++ if (!read_abbrevs (state, abbrev_offset, dwarf_abbrev, dwarf_abbrev_size, ++ is_bigendian, error_callback, data, &abbrevs)) ++ goto fail; ++ ++ addrsize = read_byte (&unit_buf); ++ ++ u = ((struct unit *) ++ backtrace_alloc (state, sizeof *u, error_callback, data)); ++ if (u == NULL) ++ goto fail; ++ u->unit_data = unit_buf.buf; ++ u->unit_data_len = unit_buf.left; ++ u->unit_data_offset = unit_buf.buf - unit_data_start; ++ u->version = version; ++ u->is_dwarf64 = is_dwarf64; ++ u->addrsize = addrsize; ++ u->filename = NULL; ++ u->comp_dir = NULL; ++ u->abs_filename = NULL; ++ u->lineoff = 0; ++ u->abbrevs = abbrevs; ++ memset (&abbrevs, 0, sizeof abbrevs); ++ ++ /* The actual line number mappings will be read as needed. */ ++ u->lines = NULL; ++ u->lines_count = 0; ++ u->function_addrs = NULL; ++ u->function_addrs_count = 0; ++ ++ if (!find_address_ranges (state, base_address, &unit_buf, ++ dwarf_str, dwarf_str_size, ++ dwarf_ranges, dwarf_ranges_size, ++ is_bigendian, error_callback, data, ++ u, addrs)) ++ { ++ free_abbrevs (state, &u->abbrevs, error_callback, data); ++ backtrace_free (state, u, sizeof *u, error_callback, data); ++ goto fail; ++ } ++ ++ if (unit_buf.reported_underflow) ++ { ++ free_abbrevs (state, &u->abbrevs, error_callback, data); ++ backtrace_free (state, u, sizeof *u, error_callback, data); ++ goto fail; ++ } ++ } ++ if (info.reported_underflow) ++ goto fail; ++ ++ return 1; ++ ++ fail: ++ free_abbrevs (state, &abbrevs, error_callback, data); ++ free_unit_addrs_vector (state, addrs, error_callback, data); ++ return 0; ++} ++ ++/* Add a new mapping to the vector of line mappings that we are ++ building. Returns 1 on success, 0 on failure. */ ++ ++static int ++add_line (struct backtrace_state *state, struct dwarf_data *ddata, ++ uintptr_t pc, const char *filename, int lineno, ++ backtrace_error_callback error_callback, void *data, ++ struct line_vector *vec) ++{ ++ struct line *ln; ++ ++ /* If we are adding the same mapping, ignore it. This can happen ++ when using discriminators. */ ++ if (vec->count > 0) ++ { ++ ln = (struct line *) vec->vec.base + (vec->count - 1); ++ if (pc == ln->pc && filename == ln->filename && lineno == ln->lineno) ++ return 1; ++ } ++ ++ ln = ((struct line *) ++ backtrace_vector_grow (state, sizeof (struct line), error_callback, ++ data, &vec->vec)); ++ if (ln == NULL) ++ return 0; ++ ++ /* Add in the base address here, so that we can look up the PC ++ directly. */ ++ ln->pc = pc + ddata->base_address; ++ ++ ln->filename = filename; ++ ln->lineno = lineno; ++ ln->idx = vec->count; ++ ++ ++vec->count; ++ ++ return 1; ++} ++ ++/* Free the line header information. If FREE_FILENAMES is true we ++ free the file names themselves, otherwise we leave them, as there ++ may be line structures pointing to them. */ ++ ++static void ++free_line_header (struct backtrace_state *state, struct line_header *hdr, ++ backtrace_error_callback error_callback, void *data) ++{ ++ backtrace_free (state, hdr->dirs, hdr->dirs_count * sizeof (const char *), ++ error_callback, data); ++ backtrace_free (state, hdr->filenames, ++ hdr->filenames_count * sizeof (char *), ++ error_callback, data); ++} ++ ++/* Read the line header. Return 1 on success, 0 on failure. */ ++ ++static int ++read_line_header (struct backtrace_state *state, struct unit *u, ++ int is_dwarf64, struct dwarf_buf *line_buf, ++ struct line_header *hdr) ++{ ++ uint64_t hdrlen; ++ struct dwarf_buf hdr_buf; ++ const unsigned char *p; ++ const unsigned char *pend; ++ size_t i; ++ ++ hdr->version = read_uint16 (line_buf); ++ if (hdr->version < 2 || hdr->version > 4) ++ { ++ dwarf_buf_error (line_buf, "unsupported line number version"); ++ return 0; ++ } ++ ++ hdrlen = read_offset (line_buf, is_dwarf64); ++ ++ hdr_buf = *line_buf; ++ hdr_buf.left = hdrlen; ++ ++ if (!advance (line_buf, hdrlen)) ++ return 0; ++ ++ hdr->min_insn_len = read_byte (&hdr_buf); ++ if (hdr->version < 4) ++ hdr->max_ops_per_insn = 1; ++ else ++ hdr->max_ops_per_insn = read_byte (&hdr_buf); ++ ++ /* We don't care about default_is_stmt. */ ++ read_byte (&hdr_buf); ++ ++ hdr->line_base = read_sbyte (&hdr_buf); ++ hdr->line_range = read_byte (&hdr_buf); ++ ++ hdr->opcode_base = read_byte (&hdr_buf); ++ hdr->opcode_lengths = hdr_buf.buf; ++ if (!advance (&hdr_buf, hdr->opcode_base - 1)) ++ return 0; ++ ++ /* Count the number of directory entries. */ ++ hdr->dirs_count = 0; ++ p = hdr_buf.buf; ++ pend = p + hdr_buf.left; ++ while (p < pend && *p != '\0') ++ { ++ p += strnlen((const char *) p, pend - p) + 1; ++ ++hdr->dirs_count; ++ } ++ ++ hdr->dirs = ((const char **) ++ backtrace_alloc (state, ++ hdr->dirs_count * sizeof (const char *), ++ line_buf->error_callback, line_buf->data)); ++ if (hdr->dirs == NULL) ++ return 0; ++ ++ i = 0; ++ while (*hdr_buf.buf != '\0') ++ { ++ if (hdr_buf.reported_underflow) ++ return 0; ++ ++ hdr->dirs[i] = (const char *) hdr_buf.buf; ++ ++i; ++ if (!advance (&hdr_buf, ++ strnlen ((const char *) hdr_buf.buf, hdr_buf.left) + 1)) ++ return 0; ++ } ++ if (!advance (&hdr_buf, 1)) ++ return 0; ++ ++ /* Count the number of file entries. */ ++ hdr->filenames_count = 0; ++ p = hdr_buf.buf; ++ pend = p + hdr_buf.left; ++ while (p < pend && *p != '\0') ++ { ++ p += strnlen ((const char *) p, pend - p) + 1; ++ p += leb128_len (p); ++ p += leb128_len (p); ++ p += leb128_len (p); ++ ++hdr->filenames_count; ++ } ++ ++ hdr->filenames = ((const char **) ++ backtrace_alloc (state, ++ hdr->filenames_count * sizeof (char *), ++ line_buf->error_callback, ++ line_buf->data)); ++ if (hdr->filenames == NULL) ++ return 0; ++ i = 0; ++ while (*hdr_buf.buf != '\0') ++ { ++ const char *filename; ++ uint64_t dir_index; ++ ++ if (hdr_buf.reported_underflow) ++ return 0; ++ ++ filename = (const char *) hdr_buf.buf; ++ if (!advance (&hdr_buf, ++ strnlen ((const char *) hdr_buf.buf, hdr_buf.left) + 1)) ++ return 0; ++ dir_index = read_uleb128 (&hdr_buf); ++ if (IS_ABSOLUTE_PATH (filename) ++ || (dir_index == 0 && u->comp_dir == NULL)) ++ hdr->filenames[i] = filename; ++ else ++ { ++ const char *dir; ++ size_t dir_len; ++ size_t filename_len; ++ char *s; ++ ++ if (dir_index == 0) ++ dir = u->comp_dir; ++ else if (dir_index - 1 < hdr->dirs_count) ++ dir = hdr->dirs[dir_index - 1]; ++ else ++ { ++ dwarf_buf_error (line_buf, ++ ("invalid directory index in " ++ "line number program header")); ++ return 0; ++ } ++ dir_len = strlen (dir); ++ filename_len = strlen (filename); ++ s = ((char *) ++ backtrace_alloc (state, dir_len + filename_len + 2, ++ line_buf->error_callback, line_buf->data)); ++ if (s == NULL) ++ return 0; ++ memcpy (s, dir, dir_len); ++ /* FIXME: If we are on a DOS-based file system, and the ++ directory or the file name use backslashes, then we ++ should use a backslash here. */ ++ s[dir_len] = '/'; ++ memcpy (s + dir_len + 1, filename, filename_len + 1); ++ hdr->filenames[i] = s; ++ } ++ ++ /* Ignore the modification time and size. */ ++ read_uleb128 (&hdr_buf); ++ read_uleb128 (&hdr_buf); ++ ++ ++i; ++ } ++ ++ if (hdr_buf.reported_underflow) ++ return 0; ++ ++ return 1; ++} ++ ++/* Read the line program, adding line mappings to VEC. Return 1 on ++ success, 0 on failure. */ ++ ++static int ++read_line_program (struct backtrace_state *state, struct dwarf_data *ddata, ++ struct unit *u, const struct line_header *hdr, ++ struct dwarf_buf *line_buf, struct line_vector *vec) ++{ ++ uint64_t address; ++ unsigned int op_index; ++ const char *reset_filename; ++ const char *filename; ++ int lineno; ++ ++ address = 0; ++ op_index = 0; ++ if (hdr->filenames_count > 0) ++ reset_filename = hdr->filenames[0]; ++ else ++ reset_filename = ""; ++ filename = reset_filename; ++ lineno = 1; ++ while (line_buf->left > 0) ++ { ++ unsigned int op; ++ ++ op = read_byte (line_buf); ++ if (op >= hdr->opcode_base) ++ { ++ unsigned int advance; ++ ++ /* Special opcode. */ ++ op -= hdr->opcode_base; ++ advance = op / hdr->line_range; ++ address += (hdr->min_insn_len * (op_index + advance) ++ / hdr->max_ops_per_insn); ++ op_index = (op_index + advance) % hdr->max_ops_per_insn; ++ lineno += hdr->line_base + (int) (op % hdr->line_range); ++ add_line (state, ddata, address, filename, lineno, ++ line_buf->error_callback, line_buf->data, vec); ++ } ++ else if (op == DW_LNS_extended_op) ++ { ++ uint64_t len; ++ ++ len = read_uleb128 (line_buf); ++ op = read_byte (line_buf); ++ switch (op) ++ { ++ case DW_LNE_end_sequence: ++ /* FIXME: Should we mark the high PC here? It seems ++ that we already have that information from the ++ compilation unit. */ ++ address = 0; ++ op_index = 0; ++ filename = reset_filename; ++ lineno = 1; ++ break; ++ case DW_LNE_set_address: ++ address = read_address (line_buf, u->addrsize); ++ break; ++ case DW_LNE_define_file: ++ { ++ const char *f; ++ unsigned int dir_index; ++ ++ f = (const char *) line_buf->buf; ++ if (!advance (line_buf, strnlen (f, line_buf->left) + 1)) ++ return 0; ++ dir_index = read_uleb128 (line_buf); ++ /* Ignore that time and length. */ ++ read_uleb128 (line_buf); ++ read_uleb128 (line_buf); ++ if (IS_ABSOLUTE_PATH (f)) ++ filename = f; ++ else ++ { ++ const char *dir; ++ size_t dir_len; ++ size_t f_len; ++ char *p; ++ ++ if (dir_index == 0) ++ dir = u->comp_dir; ++ else if (dir_index - 1 < hdr->dirs_count) ++ dir = hdr->dirs[dir_index - 1]; ++ else ++ { ++ dwarf_buf_error (line_buf, ++ ("invalid directory index " ++ "in line number program")); ++ return 0; ++ } ++ dir_len = strlen (dir); ++ f_len = strlen (f); ++ p = ((char *) ++ backtrace_alloc (state, dir_len + f_len + 2, ++ line_buf->error_callback, ++ line_buf->data)); ++ if (p == NULL) ++ return 0; ++ memcpy (p, dir, dir_len); ++ /* FIXME: If we are on a DOS-based file system, ++ and the directory or the file name use ++ backslashes, then we should use a backslash ++ here. */ ++ p[dir_len] = '/'; ++ memcpy (p + dir_len + 1, f, f_len + 1); ++ filename = p; ++ } ++ } ++ break; ++ case DW_LNE_set_discriminator: ++ /* We don't care about discriminators. */ ++ read_uleb128 (line_buf); ++ break; ++ default: ++ if (!advance (line_buf, len - 1)) ++ return 0; ++ break; ++ } ++ } ++ else ++ { ++ switch (op) ++ { ++ case DW_LNS_copy: ++ add_line (state, ddata, address, filename, lineno, ++ line_buf->error_callback, line_buf->data, vec); ++ break; ++ case DW_LNS_advance_pc: ++ { ++ uint64_t advance; ++ ++ advance = read_uleb128 (line_buf); ++ address += (hdr->min_insn_len * (op_index + advance) ++ / hdr->max_ops_per_insn); ++ op_index = (op_index + advance) % hdr->max_ops_per_insn; ++ } ++ break; ++ case DW_LNS_advance_line: ++ lineno += (int) read_sleb128 (line_buf); ++ break; ++ case DW_LNS_set_file: ++ { ++ uint64_t fileno; ++ ++ fileno = read_uleb128 (line_buf); ++ if (fileno == 0) ++ filename = ""; ++ else ++ { ++ if (fileno - 1 >= hdr->filenames_count) ++ { ++ dwarf_buf_error (line_buf, ++ ("invalid file number in " ++ "line number program")); ++ return 0; ++ } ++ filename = hdr->filenames[fileno - 1]; ++ } ++ } ++ break; ++ case DW_LNS_set_column: ++ read_uleb128 (line_buf); ++ break; ++ case DW_LNS_negate_stmt: ++ break; ++ case DW_LNS_set_basic_block: ++ break; ++ case DW_LNS_const_add_pc: ++ { ++ unsigned int advance; ++ ++ op = 255 - hdr->opcode_base; ++ advance = op / hdr->line_range; ++ address += (hdr->min_insn_len * (op_index + advance) ++ / hdr->max_ops_per_insn); ++ op_index = (op_index + advance) % hdr->max_ops_per_insn; ++ } ++ break; ++ case DW_LNS_fixed_advance_pc: ++ address += read_uint16 (line_buf); ++ op_index = 0; ++ break; ++ case DW_LNS_set_prologue_end: ++ break; ++ case DW_LNS_set_epilogue_begin: ++ break; ++ case DW_LNS_set_isa: ++ read_uleb128 (line_buf); ++ break; ++ default: ++ { ++ unsigned int i; ++ ++ for (i = hdr->opcode_lengths[op - 1]; i > 0; --i) ++ read_uleb128 (line_buf); ++ } ++ break; ++ } ++ } ++ } ++ ++ return 1; ++} ++ ++/* Read the line number information for a compilation unit. Returns 1 ++ on success, 0 on failure. */ ++ ++static int ++read_line_info (struct backtrace_state *state, struct dwarf_data *ddata, ++ backtrace_error_callback error_callback, void *data, ++ struct unit *u, struct line_header *hdr, struct line **lines, ++ size_t *lines_count) ++{ ++ struct line_vector vec; ++ struct dwarf_buf line_buf; ++ uint64_t len; ++ int is_dwarf64; ++ struct line *ln; ++ ++ memset (&vec.vec, 0, sizeof vec.vec); ++ vec.count = 0; ++ ++ memset (hdr, 0, sizeof *hdr); ++ ++ if (u->lineoff != (off_t) (size_t) u->lineoff ++ || (size_t) u->lineoff >= ddata->dwarf_line_size) ++ { ++ error_callback (data, "unit line offset out of range", 0); ++ goto fail; ++ } ++ ++ line_buf.name = ".debug_line"; ++ line_buf.start = ddata->dwarf_line; ++ line_buf.buf = ddata->dwarf_line + u->lineoff; ++ line_buf.left = ddata->dwarf_line_size - u->lineoff; ++ line_buf.is_bigendian = ddata->is_bigendian; ++ line_buf.error_callback = error_callback; ++ line_buf.data = data; ++ line_buf.reported_underflow = 0; ++ ++ is_dwarf64 = 0; ++ len = read_uint32 (&line_buf); ++ if (len == 0xffffffff) ++ { ++ len = read_uint64 (&line_buf); ++ is_dwarf64 = 1; ++ } ++ line_buf.left = len; ++ ++ if (!read_line_header (state, u, is_dwarf64, &line_buf, hdr)) ++ goto fail; ++ ++ if (!read_line_program (state, ddata, u, hdr, &line_buf, &vec)) ++ goto fail; ++ ++ if (line_buf.reported_underflow) ++ goto fail; ++ ++ if (vec.count == 0) ++ { ++ /* This is not a failure in the sense of a generating an error, ++ but it is a failure in that sense that we have no useful ++ information. */ ++ goto fail; ++ } ++ ++ /* Allocate one extra entry at the end. */ ++ ln = ((struct line *) ++ backtrace_vector_grow (state, sizeof (struct line), error_callback, ++ data, &vec.vec)); ++ if (ln == NULL) ++ goto fail; ++ ln->pc = (uintptr_t) -1; ++ ln->filename = NULL; ++ ln->lineno = 0; ++ ln->idx = 0; ++ ++ if (!backtrace_vector_release (state, &vec.vec, error_callback, data)) ++ goto fail; ++ ++ ln = (struct line *) vec.vec.base; ++ backtrace_qsort (ln, vec.count, sizeof (struct line), line_compare); ++ ++ *lines = ln; ++ *lines_count = vec.count; ++ ++ return 1; ++ ++ fail: ++ vec.vec.alc += vec.vec.size; ++ vec.vec.size = 0; ++ backtrace_vector_release (state, &vec.vec, error_callback, data); ++ free_line_header (state, hdr, error_callback, data); ++ *lines = (struct line *) (uintptr_t) -1; ++ *lines_count = 0; ++ return 0; ++} ++ ++/* Read the name of a function from a DIE referenced by a ++ DW_AT_abstract_origin or DW_AT_specification tag. OFFSET is within ++ the same compilation unit. */ ++ ++static const char * ++read_referenced_name (struct dwarf_data *ddata, struct unit *u, ++ uint64_t offset, backtrace_error_callback error_callback, ++ void *data) ++{ ++ struct dwarf_buf unit_buf; ++ uint64_t code; ++ const struct abbrev *abbrev; ++ const char *ret; ++ size_t i; ++ ++ /* OFFSET is from the start of the data for this compilation unit. ++ U->unit_data is the data, but it starts U->unit_data_offset bytes ++ from the beginning. */ ++ ++ if (offset < u->unit_data_offset ++ || offset - u->unit_data_offset >= u->unit_data_len) ++ { ++ error_callback (data, ++ "abstract origin or specification out of range", ++ 0); ++ return NULL; ++ } ++ ++ offset -= u->unit_data_offset; ++ ++ unit_buf.name = ".debug_info"; ++ unit_buf.start = ddata->dwarf_info; ++ unit_buf.buf = u->unit_data + offset; ++ unit_buf.left = u->unit_data_len - offset; ++ unit_buf.is_bigendian = ddata->is_bigendian; ++ unit_buf.error_callback = error_callback; ++ unit_buf.data = data; ++ unit_buf.reported_underflow = 0; ++ ++ code = read_uleb128 (&unit_buf); ++ if (code == 0) ++ { ++ dwarf_buf_error (&unit_buf, "invalid abstract origin or specification"); ++ return NULL; ++ } ++ ++ abbrev = lookup_abbrev (&u->abbrevs, code, error_callback, data); ++ if (abbrev == NULL) ++ return NULL; ++ ++ ret = NULL; ++ for (i = 0; i < abbrev->num_attrs; ++i) ++ { ++ struct attr_val val; ++ ++ if (!read_attribute (abbrev->attrs[i].form, &unit_buf, ++ u->is_dwarf64, u->version, u->addrsize, ++ ddata->dwarf_str, ddata->dwarf_str_size, ++ &val)) ++ return NULL; ++ ++ switch (abbrev->attrs[i].name) ++ { ++ case DW_AT_name: ++ /* We prefer the linkage name if get one. */ ++ if (val.encoding == ATTR_VAL_STRING) ++ ret = val.u.string; ++ break; ++ ++ case DW_AT_linkage_name: ++ case DW_AT_MIPS_linkage_name: ++ if (val.encoding == ATTR_VAL_STRING) ++ return val.u.string; ++ break; ++ ++ case DW_AT_specification: ++ if (abbrev->attrs[i].form == DW_FORM_ref_addr ++ || abbrev->attrs[i].form == DW_FORM_ref_sig8) ++ { ++ /* This refers to a specification defined in some other ++ compilation unit. We can handle this case if we ++ must, but it's harder. */ ++ break; ++ } ++ if (val.encoding == ATTR_VAL_UINT ++ || val.encoding == ATTR_VAL_REF_UNIT) ++ { ++ const char *name; ++ ++ name = read_referenced_name (ddata, u, val.u.uint, ++ error_callback, data); ++ if (name != NULL) ++ ret = name; ++ } ++ break; ++ ++ default: ++ break; ++ } ++ } ++ ++ return ret; ++} ++ ++/* Add a single range to U that maps to function. Returns 1 on ++ success, 0 on error. */ ++ ++static int ++add_function_range (struct backtrace_state *state, struct dwarf_data *ddata, ++ struct function *function, uint64_t lowpc, uint64_t highpc, ++ backtrace_error_callback error_callback, ++ void *data, struct function_vector *vec) ++{ ++ struct function_addrs *p; ++ ++ /* Add in the base address here, so that we can look up the PC ++ directly. */ ++ lowpc += ddata->base_address; ++ highpc += ddata->base_address; ++ ++ if (vec->count > 0) ++ { ++ p = (struct function_addrs *) vec->vec.base + vec->count - 1; ++ if ((lowpc == p->high || lowpc == p->high + 1) ++ && function == p->function) ++ { ++ if (highpc > p->high) ++ p->high = highpc; ++ return 1; ++ } ++ } ++ ++ p = ((struct function_addrs *) ++ backtrace_vector_grow (state, sizeof (struct function_addrs), ++ error_callback, data, &vec->vec)); ++ if (p == NULL) ++ return 0; ++ ++ p->low = lowpc; ++ p->high = highpc; ++ p->function = function; ++ ++vec->count; ++ return 1; ++} ++ ++/* Add PC ranges to U that map to FUNCTION. Returns 1 on success, 0 ++ on error. */ ++ ++static int ++add_function_ranges (struct backtrace_state *state, struct dwarf_data *ddata, ++ struct unit *u, struct function *function, ++ uint64_t ranges, uint64_t base, ++ backtrace_error_callback error_callback, void *data, ++ struct function_vector *vec) ++{ ++ struct dwarf_buf ranges_buf; ++ ++ if (ranges >= ddata->dwarf_ranges_size) ++ { ++ error_callback (data, "function ranges offset out of range", 0); ++ return 0; ++ } ++ ++ ranges_buf.name = ".debug_ranges"; ++ ranges_buf.start = ddata->dwarf_ranges; ++ ranges_buf.buf = ddata->dwarf_ranges + ranges; ++ ranges_buf.left = ddata->dwarf_ranges_size - ranges; ++ ranges_buf.is_bigendian = ddata->is_bigendian; ++ ranges_buf.error_callback = error_callback; ++ ranges_buf.data = data; ++ ranges_buf.reported_underflow = 0; ++ ++ while (1) ++ { ++ uint64_t low; ++ uint64_t high; ++ ++ if (ranges_buf.reported_underflow) ++ return 0; ++ ++ low = read_address (&ranges_buf, u->addrsize); ++ high = read_address (&ranges_buf, u->addrsize); ++ ++ if (low == 0 && high == 0) ++ break; ++ ++ if (is_highest_address (low, u->addrsize)) ++ base = high; ++ else ++ { ++ if (!add_function_range (state, ddata, function, low + base, ++ high + base, error_callback, data, vec)) ++ return 0; ++ } ++ } ++ ++ if (ranges_buf.reported_underflow) ++ return 0; ++ ++ return 1; ++} ++ ++/* Read one entry plus all its children. Add function addresses to ++ VEC. Returns 1 on success, 0 on error. */ ++ ++static int ++read_function_entry (struct backtrace_state *state, struct dwarf_data *ddata, ++ struct unit *u, uint64_t base, struct dwarf_buf *unit_buf, ++ const struct line_header *lhdr, ++ backtrace_error_callback error_callback, void *data, ++ struct function_vector *vec_function, ++ struct function_vector *vec_inlined) ++{ ++ while (unit_buf->left > 0) ++ { ++ uint64_t code; ++ const struct abbrev *abbrev; ++ int is_function; ++ struct function *function; ++ struct function_vector *vec; ++ size_t i; ++ uint64_t lowpc; ++ int have_lowpc; ++ uint64_t highpc; ++ int have_highpc; ++ int highpc_is_relative; ++ uint64_t ranges; ++ int have_ranges; ++ ++ code = read_uleb128 (unit_buf); ++ if (code == 0) ++ return 1; ++ ++ abbrev = lookup_abbrev (&u->abbrevs, code, error_callback, data); ++ if (abbrev == NULL) ++ return 0; ++ ++ is_function = (abbrev->tag == DW_TAG_subprogram ++ || abbrev->tag == DW_TAG_entry_point ++ || abbrev->tag == DW_TAG_inlined_subroutine); ++ ++ if (abbrev->tag == DW_TAG_inlined_subroutine) ++ vec = vec_inlined; ++ else ++ vec = vec_function; ++ ++ function = NULL; ++ if (is_function) ++ { ++ function = ((struct function *) ++ backtrace_alloc (state, sizeof *function, ++ error_callback, data)); ++ if (function == NULL) ++ return 0; ++ memset (function, 0, sizeof *function); ++ } ++ ++ lowpc = 0; ++ have_lowpc = 0; ++ highpc = 0; ++ have_highpc = 0; ++ highpc_is_relative = 0; ++ ranges = 0; ++ have_ranges = 0; ++ for (i = 0; i < abbrev->num_attrs; ++i) ++ { ++ struct attr_val val; ++ ++ if (!read_attribute (abbrev->attrs[i].form, unit_buf, ++ u->is_dwarf64, u->version, u->addrsize, ++ ddata->dwarf_str, ddata->dwarf_str_size, ++ &val)) ++ return 0; ++ ++ /* The compile unit sets the base address for any address ++ ranges in the function entries. */ ++ if (abbrev->tag == DW_TAG_compile_unit ++ && abbrev->attrs[i].name == DW_AT_low_pc ++ && val.encoding == ATTR_VAL_ADDRESS) ++ base = val.u.uint; ++ ++ if (is_function) ++ { ++ switch (abbrev->attrs[i].name) ++ { ++ case DW_AT_call_file: ++ if (val.encoding == ATTR_VAL_UINT) ++ { ++ if (val.u.uint == 0) ++ function->caller_filename = ""; ++ else ++ { ++ if (val.u.uint - 1 >= lhdr->filenames_count) ++ { ++ dwarf_buf_error (unit_buf, ++ ("invalid file number in " ++ "DW_AT_call_file attribute")); ++ return 0; ++ } ++ function->caller_filename = ++ lhdr->filenames[val.u.uint - 1]; ++ } ++ } ++ break; ++ ++ case DW_AT_call_line: ++ if (val.encoding == ATTR_VAL_UINT) ++ function->caller_lineno = val.u.uint; ++ break; ++ ++ case DW_AT_abstract_origin: ++ case DW_AT_specification: ++ if (abbrev->attrs[i].form == DW_FORM_ref_addr ++ || abbrev->attrs[i].form == DW_FORM_ref_sig8) ++ { ++ /* This refers to an abstract origin defined in ++ some other compilation unit. We can handle ++ this case if we must, but it's harder. */ ++ break; ++ } ++ if (val.encoding == ATTR_VAL_UINT ++ || val.encoding == ATTR_VAL_REF_UNIT) ++ { ++ const char *name; ++ ++ name = read_referenced_name (ddata, u, val.u.uint, ++ error_callback, data); ++ if (name != NULL) ++ function->name = name; ++ } ++ break; ++ ++ case DW_AT_name: ++ if (val.encoding == ATTR_VAL_STRING) ++ { ++ /* Don't override a name we found in some other ++ way, as it will normally be more ++ useful--e.g., this name is normally not ++ mangled. */ ++ if (function->name == NULL) ++ function->name = val.u.string; ++ } ++ break; ++ ++ case DW_AT_linkage_name: ++ case DW_AT_MIPS_linkage_name: ++ if (val.encoding == ATTR_VAL_STRING) ++ function->name = val.u.string; ++ break; ++ ++ case DW_AT_low_pc: ++ if (val.encoding == ATTR_VAL_ADDRESS) ++ { ++ lowpc = val.u.uint; ++ have_lowpc = 1; ++ } ++ break; ++ ++ case DW_AT_high_pc: ++ if (val.encoding == ATTR_VAL_ADDRESS) ++ { ++ highpc = val.u.uint; ++ have_highpc = 1; ++ } ++ else if (val.encoding == ATTR_VAL_UINT) ++ { ++ highpc = val.u.uint; ++ have_highpc = 1; ++ highpc_is_relative = 1; ++ } ++ break; ++ ++ case DW_AT_ranges: ++ if (val.encoding == ATTR_VAL_UINT ++ || val.encoding == ATTR_VAL_REF_SECTION) ++ { ++ ranges = val.u.uint; ++ have_ranges = 1; ++ } ++ break; ++ ++ default: ++ break; ++ } ++ } ++ } ++ ++ /* If we couldn't find a name for the function, we have no use ++ for it. */ ++ if (is_function && function->name == NULL) ++ { ++ backtrace_free (state, function, sizeof *function, ++ error_callback, data); ++ is_function = 0; ++ } ++ ++ if (is_function) ++ { ++ if (have_ranges) ++ { ++ if (!add_function_ranges (state, ddata, u, function, ranges, ++ base, error_callback, data, vec)) ++ return 0; ++ } ++ else if (have_lowpc && have_highpc) ++ { ++ if (highpc_is_relative) ++ highpc += lowpc; ++ if (!add_function_range (state, ddata, function, lowpc, highpc, ++ error_callback, data, vec)) ++ return 0; ++ } ++ else ++ { ++ backtrace_free (state, function, sizeof *function, ++ error_callback, data); ++ is_function = 0; ++ } ++ } ++ ++ if (abbrev->has_children) ++ { ++ if (!is_function) ++ { ++ if (!read_function_entry (state, ddata, u, base, unit_buf, lhdr, ++ error_callback, data, vec_function, ++ vec_inlined)) ++ return 0; ++ } ++ else ++ { ++ struct function_vector fvec; ++ ++ /* Gather any information for inlined functions in ++ FVEC. */ ++ ++ memset (&fvec, 0, sizeof fvec); ++ ++ if (!read_function_entry (state, ddata, u, base, unit_buf, lhdr, ++ error_callback, data, vec_function, ++ &fvec)) ++ return 0; ++ ++ if (fvec.count > 0) ++ { ++ struct function_addrs *faddrs; ++ ++ if (!backtrace_vector_release (state, &fvec.vec, ++ error_callback, data)) ++ return 0; ++ ++ faddrs = (struct function_addrs *) fvec.vec.base; ++ backtrace_qsort (faddrs, fvec.count, ++ sizeof (struct function_addrs), ++ function_addrs_compare); ++ ++ function->function_addrs = faddrs; ++ function->function_addrs_count = fvec.count; ++ } ++ } ++ } ++ } ++ ++ return 1; ++} ++ ++/* Read function name information for a compilation unit. We look ++ through the whole unit looking for function tags. */ ++ ++static void ++read_function_info (struct backtrace_state *state, struct dwarf_data *ddata, ++ const struct line_header *lhdr, ++ backtrace_error_callback error_callback, void *data, ++ struct unit *u, struct function_vector *fvec, ++ struct function_addrs **ret_addrs, ++ size_t *ret_addrs_count) ++{ ++ struct function_vector lvec; ++ struct function_vector *pfvec; ++ struct dwarf_buf unit_buf; ++ struct function_addrs *addrs; ++ size_t addrs_count; ++ ++ /* Use FVEC if it is not NULL. Otherwise use our own vector. */ ++ if (fvec != NULL) ++ pfvec = fvec; ++ else ++ { ++ memset (&lvec, 0, sizeof lvec); ++ pfvec = &lvec; ++ } ++ ++ unit_buf.name = ".debug_info"; ++ unit_buf.start = ddata->dwarf_info; ++ unit_buf.buf = u->unit_data; ++ unit_buf.left = u->unit_data_len; ++ unit_buf.is_bigendian = ddata->is_bigendian; ++ unit_buf.error_callback = error_callback; ++ unit_buf.data = data; ++ unit_buf.reported_underflow = 0; ++ ++ while (unit_buf.left > 0) ++ { ++ if (!read_function_entry (state, ddata, u, 0, &unit_buf, lhdr, ++ error_callback, data, pfvec, pfvec)) ++ return; ++ } ++ ++ if (pfvec->count == 0) ++ return; ++ ++ addrs_count = pfvec->count; ++ ++ if (fvec == NULL) ++ { ++ if (!backtrace_vector_release (state, &lvec.vec, error_callback, data)) ++ return; ++ addrs = (struct function_addrs *) pfvec->vec.base; ++ } ++ else ++ { ++ /* Finish this list of addresses, but leave the remaining space in ++ the vector available for the next function unit. */ ++ addrs = ((struct function_addrs *) ++ backtrace_vector_finish (state, &fvec->vec, ++ error_callback, data)); ++ if (addrs == NULL) ++ return; ++ fvec->count = 0; ++ } ++ ++ backtrace_qsort (addrs, addrs_count, sizeof (struct function_addrs), ++ function_addrs_compare); ++ ++ *ret_addrs = addrs; ++ *ret_addrs_count = addrs_count; ++} ++ ++/* See if PC is inlined in FUNCTION. If it is, print out the inlined ++ information, and update FILENAME and LINENO for the caller. ++ Returns whatever CALLBACK returns, or 0 to keep going. */ ++ ++static int ++report_inlined_functions (uintptr_t pc, struct function *function, ++ backtrace_full_callback callback, void *data, ++ const char **filename, int *lineno) ++{ ++ struct function_addrs *function_addrs; ++ struct function *inlined; ++ int ret; ++ ++ if (function->function_addrs_count == 0) ++ return 0; ++ ++ function_addrs = ((struct function_addrs *) ++ bsearch (&pc, function->function_addrs, ++ function->function_addrs_count, ++ sizeof (struct function_addrs), ++ function_addrs_search)); ++ if (function_addrs == NULL) ++ return 0; ++ ++ while (((size_t) (function_addrs - function->function_addrs) + 1 ++ < function->function_addrs_count) ++ && pc >= (function_addrs + 1)->low ++ && pc < (function_addrs + 1)->high) ++ ++function_addrs; ++ ++ /* We found an inlined call. */ ++ ++ inlined = function_addrs->function; ++ ++ /* Report any calls inlined into this one. */ ++ ret = report_inlined_functions (pc, inlined, callback, data, ++ filename, lineno); ++ if (ret != 0) ++ return ret; ++ ++ /* Report this inlined call. */ ++ ret = callback (data, pc, *filename, *lineno, inlined->name); ++ if (ret != 0) ++ return ret; ++ ++ /* Our caller will report the caller of the inlined function; tell ++ it the appropriate filename and line number. */ ++ *filename = inlined->caller_filename; ++ *lineno = inlined->caller_lineno; ++ ++ return 0; ++} ++ ++/* Look for a PC in the DWARF mapping for one module. On success, ++ call CALLBACK and return whatever it returns. On error, call ++ ERROR_CALLBACK and return 0. Sets *FOUND to 1 if the PC is found, ++ 0 if not. */ ++ ++static int ++dwarf_lookup_pc (struct backtrace_state *state, struct dwarf_data *ddata, ++ uintptr_t pc, backtrace_full_callback callback, ++ backtrace_error_callback error_callback, void *data, ++ int *found) ++{ ++ struct unit_addrs *entry; ++ struct unit *u; ++ int new_data; ++ struct line *lines; ++ struct line *ln; ++ struct function_addrs *function_addrs; ++ struct function *function; ++ const char *filename; ++ int lineno; ++ int ret; ++ ++ *found = 1; ++ ++ /* Find an address range that includes PC. */ ++ entry = bsearch (&pc, ddata->addrs, ddata->addrs_count, ++ sizeof (struct unit_addrs), unit_addrs_search); ++ ++ if (entry == NULL) ++ { ++ *found = 0; ++ return 0; ++ } ++ ++ /* If there are multiple ranges that contain PC, use the last one, ++ in order to produce predictable results. If we assume that all ++ ranges are properly nested, then the last range will be the ++ smallest one. */ ++ while ((size_t) (entry - ddata->addrs) + 1 < ddata->addrs_count ++ && pc >= (entry + 1)->low ++ && pc < (entry + 1)->high) ++ ++entry; ++ ++ /* We need the lines, lines_count, function_addrs, ++ function_addrs_count fields of u. If they are not set, we need ++ to set them. When running in threaded mode, we need to allow for ++ the possibility that some other thread is setting them ++ simultaneously. */ ++ ++ u = entry->u; ++ lines = u->lines; ++ ++ /* Skip units with no useful line number information by walking ++ backward. Useless line number information is marked by setting ++ lines == -1. */ ++ while (entry > ddata->addrs ++ && pc >= (entry - 1)->low ++ && pc < (entry - 1)->high) ++ { ++ if (state->threaded) ++ lines = (struct line *) backtrace_atomic_load_pointer (&u->lines); ++ ++ if (lines != (struct line *) (uintptr_t) -1) ++ break; ++ ++ --entry; ++ ++ u = entry->u; ++ lines = u->lines; ++ } ++ ++ if (state->threaded) ++ lines = backtrace_atomic_load_pointer (&u->lines); ++ ++ new_data = 0; ++ if (lines == NULL) ++ { ++ size_t function_addrs_count; ++ struct line_header lhdr; ++ size_t count; ++ ++ /* We have never read the line information for this unit. Read ++ it now. */ ++ ++ function_addrs = NULL; ++ function_addrs_count = 0; ++ if (read_line_info (state, ddata, error_callback, data, entry->u, &lhdr, ++ &lines, &count)) ++ { ++ struct function_vector *pfvec; ++ ++ /* If not threaded, reuse DDATA->FVEC for better memory ++ consumption. */ ++ if (state->threaded) ++ pfvec = NULL; ++ else ++ pfvec = &ddata->fvec; ++ read_function_info (state, ddata, &lhdr, error_callback, data, ++ entry->u, pfvec, &function_addrs, ++ &function_addrs_count); ++ free_line_header (state, &lhdr, error_callback, data); ++ new_data = 1; ++ } ++ ++ /* Atomically store the information we just read into the unit. ++ If another thread is simultaneously writing, it presumably ++ read the same information, and we don't care which one we ++ wind up with; we just leak the other one. We do have to ++ write the lines field last, so that the acquire-loads above ++ ensure that the other fields are set. */ ++ ++ if (!state->threaded) ++ { ++ u->lines_count = count; ++ u->function_addrs = function_addrs; ++ u->function_addrs_count = function_addrs_count; ++ u->lines = lines; ++ } ++ else ++ { ++ backtrace_atomic_store_size_t (&u->lines_count, count); ++ backtrace_atomic_store_pointer (&u->function_addrs, function_addrs); ++ backtrace_atomic_store_size_t (&u->function_addrs_count, ++ function_addrs_count); ++ backtrace_atomic_store_pointer (&u->lines, lines); ++ } ++ } ++ ++ /* Now all fields of U have been initialized. */ ++ ++ if (lines == (struct line *) (uintptr_t) -1) ++ { ++ /* If reading the line number information failed in some way, ++ try again to see if there is a better compilation unit for ++ this PC. */ ++ if (new_data) ++ return dwarf_lookup_pc (state, ddata, pc, callback, error_callback, ++ data, found); ++ return callback (data, pc, NULL, 0, NULL); ++ } ++ ++ /* Search for PC within this unit. */ ++ ++ ln = (struct line *) bsearch (&pc, lines, entry->u->lines_count, ++ sizeof (struct line), line_search); ++ if (ln == NULL) ++ { ++ /* The PC is between the low_pc and high_pc attributes of the ++ compilation unit, but no entry in the line table covers it. ++ This implies that the start of the compilation unit has no ++ line number information. */ ++ ++ if (entry->u->abs_filename == NULL) ++ { ++ const char *filename; ++ ++ filename = entry->u->filename; ++ if (filename != NULL ++ && !IS_ABSOLUTE_PATH (filename) ++ && entry->u->comp_dir != NULL) ++ { ++ size_t filename_len; ++ const char *dir; ++ size_t dir_len; ++ char *s; ++ ++ filename_len = strlen (filename); ++ dir = entry->u->comp_dir; ++ dir_len = strlen (dir); ++ s = (char *) backtrace_alloc (state, dir_len + filename_len + 2, ++ error_callback, data); ++ if (s == NULL) ++ { ++ *found = 0; ++ return 0; ++ } ++ memcpy (s, dir, dir_len); ++ /* FIXME: Should use backslash if DOS file system. */ ++ s[dir_len] = '/'; ++ memcpy (s + dir_len + 1, filename, filename_len + 1); ++ filename = s; ++ } ++ entry->u->abs_filename = filename; ++ } ++ ++ return callback (data, pc, entry->u->abs_filename, 0, NULL); ++ } ++ ++ /* Search for function name within this unit. */ ++ ++ if (entry->u->function_addrs_count == 0) ++ return callback (data, pc, ln->filename, ln->lineno, NULL); ++ ++ function_addrs = ((struct function_addrs *) ++ bsearch (&pc, entry->u->function_addrs, ++ entry->u->function_addrs_count, ++ sizeof (struct function_addrs), ++ function_addrs_search)); ++ if (function_addrs == NULL) ++ return callback (data, pc, ln->filename, ln->lineno, NULL); ++ ++ /* If there are multiple function ranges that contain PC, use the ++ last one, in order to produce predictable results. */ ++ ++ while (((size_t) (function_addrs - entry->u->function_addrs + 1) ++ < entry->u->function_addrs_count) ++ && pc >= (function_addrs + 1)->low ++ && pc < (function_addrs + 1)->high) ++ ++function_addrs; ++ ++ function = function_addrs->function; ++ ++ filename = ln->filename; ++ lineno = ln->lineno; ++ ++ ret = report_inlined_functions (pc, function, callback, data, ++ &filename, &lineno); ++ if (ret != 0) ++ return ret; ++ ++ return callback (data, pc, filename, lineno, function->name); ++} ++ ++ ++/* Return the file/line information for a PC using the DWARF mapping ++ we built earlier. */ ++ ++static int ++dwarf_fileline (struct backtrace_state *state, uintptr_t pc, ++ backtrace_full_callback callback, ++ backtrace_error_callback error_callback, void *data) ++{ ++ struct dwarf_data *ddata; ++ int found; ++ int ret; ++ ++ if (!state->threaded) ++ { ++ for (ddata = (struct dwarf_data *) state->fileline_data; ++ ddata != NULL; ++ ddata = ddata->next) ++ { ++ ret = dwarf_lookup_pc (state, ddata, pc, callback, error_callback, ++ data, &found); ++ if (ret != 0 || found) ++ return ret; ++ } ++ } ++ else ++ { ++ struct dwarf_data **pp; ++ ++ pp = (struct dwarf_data **) (void *) &state->fileline_data; ++ while (1) ++ { ++ ddata = backtrace_atomic_load_pointer (pp); ++ if (ddata == NULL) ++ break; ++ ++ ret = dwarf_lookup_pc (state, ddata, pc, callback, error_callback, ++ data, &found); ++ if (ret != 0 || found) ++ return ret; ++ ++ pp = &ddata->next; ++ } ++ } ++ ++ /* FIXME: See if any libraries have been dlopen'ed. */ ++ ++ return callback (data, pc, NULL, 0, NULL); ++} ++ ++/* Initialize our data structures from the DWARF debug info for a ++ file. Return NULL on failure. */ ++ ++static struct dwarf_data * ++build_dwarf_data (struct backtrace_state *state, ++ uintptr_t base_address, ++ const unsigned char *dwarf_info, ++ size_t dwarf_info_size, ++ const unsigned char *dwarf_line, ++ size_t dwarf_line_size, ++ const unsigned char *dwarf_abbrev, ++ size_t dwarf_abbrev_size, ++ const unsigned char *dwarf_ranges, ++ size_t dwarf_ranges_size, ++ const unsigned char *dwarf_str, ++ size_t dwarf_str_size, ++ int is_bigendian, ++ backtrace_error_callback error_callback, ++ void *data) ++{ ++ struct unit_addrs_vector addrs_vec; ++ struct unit_addrs *addrs; ++ size_t addrs_count; ++ struct dwarf_data *fdata; ++ ++ if (!build_address_map (state, base_address, dwarf_info, dwarf_info_size, ++ dwarf_abbrev, dwarf_abbrev_size, dwarf_ranges, ++ dwarf_ranges_size, dwarf_str, dwarf_str_size, ++ is_bigendian, error_callback, data, &addrs_vec)) ++ return NULL; ++ ++ if (!backtrace_vector_release (state, &addrs_vec.vec, error_callback, data)) ++ return NULL; ++ addrs = (struct unit_addrs *) addrs_vec.vec.base; ++ addrs_count = addrs_vec.count; ++ backtrace_qsort (addrs, addrs_count, sizeof (struct unit_addrs), ++ unit_addrs_compare); ++ ++ fdata = ((struct dwarf_data *) ++ backtrace_alloc (state, sizeof (struct dwarf_data), ++ error_callback, data)); ++ if (fdata == NULL) ++ return NULL; ++ ++ fdata->next = NULL; ++ fdata->base_address = base_address; ++ fdata->addrs = addrs; ++ fdata->addrs_count = addrs_count; ++ fdata->dwarf_info = dwarf_info; ++ fdata->dwarf_info_size = dwarf_info_size; ++ fdata->dwarf_line = dwarf_line; ++ fdata->dwarf_line_size = dwarf_line_size; ++ fdata->dwarf_ranges = dwarf_ranges; ++ fdata->dwarf_ranges_size = dwarf_ranges_size; ++ fdata->dwarf_str = dwarf_str; ++ fdata->dwarf_str_size = dwarf_str_size; ++ fdata->is_bigendian = is_bigendian; ++ memset (&fdata->fvec, 0, sizeof fdata->fvec); ++ ++ return fdata; ++} ++ ++/* Build our data structures from the DWARF sections for a module. ++ Set FILELINE_FN and STATE->FILELINE_DATA. Return 1 on success, 0 ++ on failure. */ ++ ++int ++backtrace_dwarf_add (struct backtrace_state *state, ++ uintptr_t base_address, ++ const unsigned char *dwarf_info, ++ size_t dwarf_info_size, ++ const unsigned char *dwarf_line, ++ size_t dwarf_line_size, ++ const unsigned char *dwarf_abbrev, ++ size_t dwarf_abbrev_size, ++ const unsigned char *dwarf_ranges, ++ size_t dwarf_ranges_size, ++ const unsigned char *dwarf_str, ++ size_t dwarf_str_size, ++ int is_bigendian, ++ backtrace_error_callback error_callback, ++ void *data, fileline *fileline_fn) ++{ ++ struct dwarf_data *fdata; ++ ++ fdata = build_dwarf_data (state, base_address, dwarf_info, dwarf_info_size, ++ dwarf_line, dwarf_line_size, dwarf_abbrev, ++ dwarf_abbrev_size, dwarf_ranges, dwarf_ranges_size, ++ dwarf_str, dwarf_str_size, is_bigendian, ++ error_callback, data); ++ if (fdata == NULL) ++ return 0; ++ ++ if (!state->threaded) ++ { ++ struct dwarf_data **pp; ++ ++ for (pp = (struct dwarf_data **) (void *) &state->fileline_data; ++ *pp != NULL; ++ pp = &(*pp)->next) ++ ; ++ *pp = fdata; ++ } ++ else ++ { ++ while (1) ++ { ++ struct dwarf_data **pp; ++ ++ pp = (struct dwarf_data **) (void *) &state->fileline_data; ++ ++ while (1) ++ { ++ struct dwarf_data *p; ++ ++ p = backtrace_atomic_load_pointer (pp); ++ ++ if (p == NULL) ++ break; ++ ++ pp = &p->next; ++ } ++ ++ if (__sync_bool_compare_and_swap (pp, NULL, fdata)) ++ break; ++ } ++ } ++ ++ *fileline_fn = dwarf_fileline; ++ ++ return 1; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/dwarf2.def index 000000000,000000000..bb916ca23 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/dwarf2.def @@@ -1,0 -1,0 +1,773 @@@ ++/* -*- c -*- ++ Declarations and definitions of codes relating to the DWARF2 and ++ DWARF3 symbolic debugging information formats. ++ Copyright (C) 1992-2015 Free Software Foundation, Inc. ++ ++ Written by Gary Funck (gary@intrepid.com) The Ada Joint Program ++ Office (AJPO), Florida State University and Silicon Graphics Inc. ++ provided support for this effort -- June 21, 1995. ++ ++ Derived from the DWARF 1 implementation written by Ron Guilmette ++ (rfg@netcom.com), November 1990. ++ ++ This file is part of GCC. ++ ++ GCC is free software; you can redistribute it and/or modify it under ++ the terms of the GNU General Public License as published by the Free ++ Software Foundation; either version 3, or (at your option) any later ++ version. ++ ++ GCC is distributed in the hope that it will be useful, but WITHOUT ++ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ++ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public ++ License for more details. ++ ++ Under Section 7 of GPL version 3, you are granted additional ++ permissions described in the GCC Runtime Library Exception, version ++ 3.1, as published by the Free Software Foundation. ++ ++ You should have received a copy of the GNU General Public License and ++ a copy of the GCC Runtime Library Exception along with this program; ++ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ++ . */ ++ ++/* This file is derived from the DWARF specification (a public document) ++ Revision 2.0.0 (July 27, 1993) developed by the UNIX International ++ Programming Languages Special Interest Group (UI/PLSIG) and distributed ++ by UNIX International. Copies of this specification are available from ++ UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054. ++ ++ This file also now contains definitions from the DWARF 3 specification ++ published Dec 20, 2005, available from: http://dwarf.freestandards.org. ++ ++ This file also now contains definitions from the DWARF 4 ++ specification, available from: http://dwarfstd.org/ */ ++ ++/* This file declares various DWARF-related constants using a set of ++ macros which can be redefined by the including file. ++ ++ The macros are in sections. Each section corresponds to a single ++ set of DWARF constants and has a corresponding key. The key is ++ used in all the macro names. ++ ++ The sections are TAG (for DW_TAG_ constants), FORM (DW_FORM_), AT ++ (DW_AT_), OP (DW_OP_), ATE (DW_ATE_), and CFA (DW_CFA_). ++ ++ Using TAG as an example, the following macros may be used for each ++ key: ++ ++ DW_FIRST_TAG(name, value) - Introduce the first DW_TAG constant. ++ ++ DW_TAG(name, value) - Define a subsequent constant. ++ ++ DW_TAG_DUP(name, value) - Define a subsequent constant whose value ++ is a duplicate of some other constant. Not all keys use the _DUP ++ macro form. If more than one name shares a value, then the base ++ (DW_TAG) form will be the preferred name and DW_TAG_DUP will hold ++ any alternate names. ++ ++ DW_END_TAG - Invoked at the end of the DW_TAG constants. */ ++ ++DW_FIRST_TAG (DW_TAG_padding, 0x00) ++DW_TAG (DW_TAG_array_type, 0x01) ++DW_TAG (DW_TAG_class_type, 0x02) ++DW_TAG (DW_TAG_entry_point, 0x03) ++DW_TAG (DW_TAG_enumeration_type, 0x04) ++DW_TAG (DW_TAG_formal_parameter, 0x05) ++DW_TAG (DW_TAG_imported_declaration, 0x08) ++DW_TAG (DW_TAG_label, 0x0a) ++DW_TAG (DW_TAG_lexical_block, 0x0b) ++DW_TAG (DW_TAG_member, 0x0d) ++DW_TAG (DW_TAG_pointer_type, 0x0f) ++DW_TAG (DW_TAG_reference_type, 0x10) ++DW_TAG (DW_TAG_compile_unit, 0x11) ++DW_TAG (DW_TAG_string_type, 0x12) ++DW_TAG (DW_TAG_structure_type, 0x13) ++DW_TAG (DW_TAG_subroutine_type, 0x15) ++DW_TAG (DW_TAG_typedef, 0x16) ++DW_TAG (DW_TAG_union_type, 0x17) ++DW_TAG (DW_TAG_unspecified_parameters, 0x18) ++DW_TAG (DW_TAG_variant, 0x19) ++DW_TAG (DW_TAG_common_block, 0x1a) ++DW_TAG (DW_TAG_common_inclusion, 0x1b) ++DW_TAG (DW_TAG_inheritance, 0x1c) ++DW_TAG (DW_TAG_inlined_subroutine, 0x1d) ++DW_TAG (DW_TAG_module, 0x1e) ++DW_TAG (DW_TAG_ptr_to_member_type, 0x1f) ++DW_TAG (DW_TAG_set_type, 0x20) ++DW_TAG (DW_TAG_subrange_type, 0x21) ++DW_TAG (DW_TAG_with_stmt, 0x22) ++DW_TAG (DW_TAG_access_declaration, 0x23) ++DW_TAG (DW_TAG_base_type, 0x24) ++DW_TAG (DW_TAG_catch_block, 0x25) ++DW_TAG (DW_TAG_const_type, 0x26) ++DW_TAG (DW_TAG_constant, 0x27) ++DW_TAG (DW_TAG_enumerator, 0x28) ++DW_TAG (DW_TAG_file_type, 0x29) ++DW_TAG (DW_TAG_friend, 0x2a) ++DW_TAG (DW_TAG_namelist, 0x2b) ++DW_TAG (DW_TAG_namelist_item, 0x2c) ++DW_TAG (DW_TAG_packed_type, 0x2d) ++DW_TAG (DW_TAG_subprogram, 0x2e) ++DW_TAG (DW_TAG_template_type_param, 0x2f) ++DW_TAG (DW_TAG_template_value_param, 0x30) ++DW_TAG (DW_TAG_thrown_type, 0x31) ++DW_TAG (DW_TAG_try_block, 0x32) ++DW_TAG (DW_TAG_variant_part, 0x33) ++DW_TAG (DW_TAG_variable, 0x34) ++DW_TAG (DW_TAG_volatile_type, 0x35) ++/* DWARF 3. */ ++DW_TAG (DW_TAG_dwarf_procedure, 0x36) ++DW_TAG (DW_TAG_restrict_type, 0x37) ++DW_TAG (DW_TAG_interface_type, 0x38) ++DW_TAG (DW_TAG_namespace, 0x39) ++DW_TAG (DW_TAG_imported_module, 0x3a) ++DW_TAG (DW_TAG_unspecified_type, 0x3b) ++DW_TAG (DW_TAG_partial_unit, 0x3c) ++DW_TAG (DW_TAG_imported_unit, 0x3d) ++DW_TAG (DW_TAG_condition, 0x3f) ++DW_TAG (DW_TAG_shared_type, 0x40) ++/* DWARF 4. */ ++DW_TAG (DW_TAG_type_unit, 0x41) ++DW_TAG (DW_TAG_rvalue_reference_type, 0x42) ++DW_TAG (DW_TAG_template_alias, 0x43) ++/* DWARF 5. */ ++DW_TAG (DW_TAG_coarray_type, 0x44) ++DW_TAG (DW_TAG_generic_subrange, 0x45) ++DW_TAG (DW_TAG_dynamic_type, 0x46) ++DW_TAG (DW_TAG_atomic_type, 0x47) ++DW_TAG (DW_TAG_call_site, 0x48) ++DW_TAG (DW_TAG_call_site_parameter, 0x49) ++DW_TAG (DW_TAG_skeleton_unit, 0x4a) ++DW_TAG (DW_TAG_immutable_type, 0x4b) ++ ++DW_TAG_DUP (DW_TAG_lo_user, 0x4080) ++DW_TAG_DUP (DW_TAG_hi_user, 0xffff) ++ ++/* SGI/MIPS Extensions. */ ++DW_TAG (DW_TAG_MIPS_loop, 0x4081) ++ ++/* HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz . */ ++DW_TAG (DW_TAG_HP_array_descriptor, 0x4090) ++DW_TAG (DW_TAG_HP_Bliss_field, 0x4091) ++DW_TAG (DW_TAG_HP_Bliss_field_set, 0x4092) ++ ++/* GNU extensions. */ ++DW_TAG (DW_TAG_format_label, 0x4101) /* For FORTRAN 77 and Fortran 90. */ ++DW_TAG (DW_TAG_function_template, 0x4102) /* For C++. */ ++DW_TAG (DW_TAG_class_template, 0x4103) /* For C++. */ ++DW_TAG (DW_TAG_GNU_BINCL, 0x4104) ++DW_TAG (DW_TAG_GNU_EINCL, 0x4105) ++/* Template template parameter. ++ See http://gcc.gnu.org/wiki/TemplateParmsDwarf . */ ++DW_TAG (DW_TAG_GNU_template_template_param, 0x4106) ++ ++/* Template parameter pack extension, specified at ++ http://wiki.dwarfstd.org/index.php?title=C%2B%2B0x:_Variadic_templates ++ The values of these two TAGS are in the DW_TAG_GNU_* space until the tags ++ are properly part of DWARF 5. */ ++DW_TAG (DW_TAG_GNU_template_parameter_pack, 0x4107) ++DW_TAG (DW_TAG_GNU_formal_parameter_pack, 0x4108) ++/* The GNU call site extension, specified at ++ http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open . ++ The values of these two TAGS are in the DW_TAG_GNU_* space until the tags ++ are properly part of DWARF 5. */ ++DW_TAG (DW_TAG_GNU_call_site, 0x4109) ++DW_TAG (DW_TAG_GNU_call_site_parameter, 0x410a) ++/* Extensions for UPC. See: http://dwarfstd.org/doc/DWARF4.pdf. */ ++DW_TAG (DW_TAG_upc_shared_type, 0x8765) ++DW_TAG (DW_TAG_upc_strict_type, 0x8766) ++DW_TAG (DW_TAG_upc_relaxed_type, 0x8767) ++/* PGI (STMicroelectronics) extensions. No documentation available. */ ++DW_TAG (DW_TAG_PGI_kanji_type, 0xA000) ++DW_TAG (DW_TAG_PGI_interface_block, 0xA020) ++DW_END_TAG ++ ++DW_FIRST_FORM (DW_FORM_addr, 0x01) ++DW_FORM (DW_FORM_block2, 0x03) ++DW_FORM (DW_FORM_block4, 0x04) ++DW_FORM (DW_FORM_data2, 0x05) ++DW_FORM (DW_FORM_data4, 0x06) ++DW_FORM (DW_FORM_data8, 0x07) ++DW_FORM (DW_FORM_string, 0x08) ++DW_FORM (DW_FORM_block, 0x09) ++DW_FORM (DW_FORM_block1, 0x0a) ++DW_FORM (DW_FORM_data1, 0x0b) ++DW_FORM (DW_FORM_flag, 0x0c) ++DW_FORM (DW_FORM_sdata, 0x0d) ++DW_FORM (DW_FORM_strp, 0x0e) ++DW_FORM (DW_FORM_udata, 0x0f) ++DW_FORM (DW_FORM_ref_addr, 0x10) ++DW_FORM (DW_FORM_ref1, 0x11) ++DW_FORM (DW_FORM_ref2, 0x12) ++DW_FORM (DW_FORM_ref4, 0x13) ++DW_FORM (DW_FORM_ref8, 0x14) ++DW_FORM (DW_FORM_ref_udata, 0x15) ++DW_FORM (DW_FORM_indirect, 0x16) ++/* DWARF 4. */ ++DW_FORM (DW_FORM_sec_offset, 0x17) ++DW_FORM (DW_FORM_exprloc, 0x18) ++DW_FORM (DW_FORM_flag_present, 0x19) ++DW_FORM (DW_FORM_ref_sig8, 0x20) ++/* DWARF 5. */ ++DW_FORM (DW_FORM_strx, 0x1a) ++DW_FORM (DW_FORM_addrx, 0x1b) ++DW_FORM (DW_FORM_ref_sup, 0x1c) ++DW_FORM (DW_FORM_strp_sup, 0x1d) ++DW_FORM (DW_FORM_data16, 0x1e) ++DW_FORM (DW_FORM_line_strp, 0x1f) ++DW_FORM (DW_FORM_implicit_const, 0x21) ++DW_FORM (DW_FORM_loclistx, 0x22) ++DW_FORM (DW_FORM_rnglistx, 0x23) ++/* Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission. */ ++DW_FORM (DW_FORM_GNU_addr_index, 0x1f01) ++DW_FORM (DW_FORM_GNU_str_index, 0x1f02) ++/* Extensions for DWZ multifile. ++ See http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open . */ ++DW_FORM (DW_FORM_GNU_ref_alt, 0x1f20) ++DW_FORM (DW_FORM_GNU_strp_alt, 0x1f21) ++DW_END_FORM ++ ++DW_FIRST_AT (DW_AT_sibling, 0x01) ++DW_AT (DW_AT_location, 0x02) ++DW_AT (DW_AT_name, 0x03) ++DW_AT (DW_AT_ordering, 0x09) ++DW_AT (DW_AT_subscr_data, 0x0a) ++DW_AT (DW_AT_byte_size, 0x0b) ++DW_AT (DW_AT_bit_offset, 0x0c) ++DW_AT (DW_AT_bit_size, 0x0d) ++DW_AT (DW_AT_element_list, 0x0f) ++DW_AT (DW_AT_stmt_list, 0x10) ++DW_AT (DW_AT_low_pc, 0x11) ++DW_AT (DW_AT_high_pc, 0x12) ++DW_AT (DW_AT_language, 0x13) ++DW_AT (DW_AT_member, 0x14) ++DW_AT (DW_AT_discr, 0x15) ++DW_AT (DW_AT_discr_value, 0x16) ++DW_AT (DW_AT_visibility, 0x17) ++DW_AT (DW_AT_import, 0x18) ++DW_AT (DW_AT_string_length, 0x19) ++DW_AT (DW_AT_common_reference, 0x1a) ++DW_AT (DW_AT_comp_dir, 0x1b) ++DW_AT (DW_AT_const_value, 0x1c) ++DW_AT (DW_AT_containing_type, 0x1d) ++DW_AT (DW_AT_default_value, 0x1e) ++DW_AT (DW_AT_inline, 0x20) ++DW_AT (DW_AT_is_optional, 0x21) ++DW_AT (DW_AT_lower_bound, 0x22) ++DW_AT (DW_AT_producer, 0x25) ++DW_AT (DW_AT_prototyped, 0x27) ++DW_AT (DW_AT_return_addr, 0x2a) ++DW_AT (DW_AT_start_scope, 0x2c) ++DW_AT (DW_AT_bit_stride, 0x2e) ++DW_AT (DW_AT_upper_bound, 0x2f) ++DW_AT (DW_AT_abstract_origin, 0x31) ++DW_AT (DW_AT_accessibility, 0x32) ++DW_AT (DW_AT_address_class, 0x33) ++DW_AT (DW_AT_artificial, 0x34) ++DW_AT (DW_AT_base_types, 0x35) ++DW_AT (DW_AT_calling_convention, 0x36) ++DW_AT (DW_AT_count, 0x37) ++DW_AT (DW_AT_data_member_location, 0x38) ++DW_AT (DW_AT_decl_column, 0x39) ++DW_AT (DW_AT_decl_file, 0x3a) ++DW_AT (DW_AT_decl_line, 0x3b) ++DW_AT (DW_AT_declaration, 0x3c) ++DW_AT (DW_AT_discr_list, 0x3d) ++DW_AT (DW_AT_encoding, 0x3e) ++DW_AT (DW_AT_external, 0x3f) ++DW_AT (DW_AT_frame_base, 0x40) ++DW_AT (DW_AT_friend, 0x41) ++DW_AT (DW_AT_identifier_case, 0x42) ++DW_AT (DW_AT_macro_info, 0x43) ++DW_AT (DW_AT_namelist_items, 0x44) ++DW_AT (DW_AT_priority, 0x45) ++DW_AT (DW_AT_segment, 0x46) ++DW_AT (DW_AT_specification, 0x47) ++DW_AT (DW_AT_static_link, 0x48) ++DW_AT (DW_AT_type, 0x49) ++DW_AT (DW_AT_use_location, 0x4a) ++DW_AT (DW_AT_variable_parameter, 0x4b) ++DW_AT (DW_AT_virtuality, 0x4c) ++DW_AT (DW_AT_vtable_elem_location, 0x4d) ++/* DWARF 3 values. */ ++DW_AT (DW_AT_allocated, 0x4e) ++DW_AT (DW_AT_associated, 0x4f) ++DW_AT (DW_AT_data_location, 0x50) ++DW_AT (DW_AT_byte_stride, 0x51) ++DW_AT (DW_AT_entry_pc, 0x52) ++DW_AT (DW_AT_use_UTF8, 0x53) ++DW_AT (DW_AT_extension, 0x54) ++DW_AT (DW_AT_ranges, 0x55) ++DW_AT (DW_AT_trampoline, 0x56) ++DW_AT (DW_AT_call_column, 0x57) ++DW_AT (DW_AT_call_file, 0x58) ++DW_AT (DW_AT_call_line, 0x59) ++DW_AT (DW_AT_description, 0x5a) ++DW_AT (DW_AT_binary_scale, 0x5b) ++DW_AT (DW_AT_decimal_scale, 0x5c) ++DW_AT (DW_AT_small, 0x5d) ++DW_AT (DW_AT_decimal_sign, 0x5e) ++DW_AT (DW_AT_digit_count, 0x5f) ++DW_AT (DW_AT_picture_string, 0x60) ++DW_AT (DW_AT_mutable, 0x61) ++DW_AT (DW_AT_threads_scaled, 0x62) ++DW_AT (DW_AT_explicit, 0x63) ++DW_AT (DW_AT_object_pointer, 0x64) ++DW_AT (DW_AT_endianity, 0x65) ++DW_AT (DW_AT_elemental, 0x66) ++DW_AT (DW_AT_pure, 0x67) ++DW_AT (DW_AT_recursive, 0x68) ++/* DWARF 4. */ ++DW_AT (DW_AT_signature, 0x69) ++DW_AT (DW_AT_main_subprogram, 0x6a) ++DW_AT (DW_AT_data_bit_offset, 0x6b) ++DW_AT (DW_AT_const_expr, 0x6c) ++DW_AT (DW_AT_enum_class, 0x6d) ++DW_AT (DW_AT_linkage_name, 0x6e) ++/* DWARF 5. */ ++DW_AT (DW_AT_string_length_bit_size, 0x6f) ++DW_AT (DW_AT_string_length_byte_size, 0x70) ++DW_AT (DW_AT_rank, 0x71) ++DW_AT (DW_AT_str_offsets_base, 0x72) ++DW_AT (DW_AT_addr_base, 0x73) ++DW_AT (DW_AT_rnglists_base, 0x74) ++DW_AT (DW_AT_dwo_name, 0x76) ++DW_AT (DW_AT_reference, 0x77) ++DW_AT (DW_AT_rvalue_reference, 0x78) ++DW_AT (DW_AT_macros, 0x79) ++DW_AT (DW_AT_call_all_calls, 0x7a) ++DW_AT (DW_AT_call_all_source_calls, 0x7b) ++DW_AT (DW_AT_call_all_tail_calls, 0x7c) ++DW_AT (DW_AT_call_return_pc, 0x7d) ++DW_AT (DW_AT_call_value, 0x7e) ++DW_AT (DW_AT_call_origin, 0x7f) ++DW_AT (DW_AT_call_parameter, 0x80) ++DW_AT (DW_AT_call_pc, 0x81) ++DW_AT (DW_AT_call_tail_call, 0x82) ++DW_AT (DW_AT_call_target, 0x83) ++DW_AT (DW_AT_call_target_clobbered, 0x84) ++DW_AT (DW_AT_call_data_location, 0x85) ++DW_AT (DW_AT_call_data_value, 0x86) ++DW_AT (DW_AT_noreturn, 0x87) ++DW_AT (DW_AT_alignment, 0x88) ++DW_AT (DW_AT_export_symbols, 0x89) ++DW_AT (DW_AT_deleted, 0x8a) ++DW_AT (DW_AT_defaulted, 0x8b) ++DW_AT (DW_AT_loclists_base, 0x8c) ++ ++DW_AT_DUP (DW_AT_lo_user, 0x2000) /* Implementation-defined range start. */ ++DW_AT_DUP (DW_AT_hi_user, 0x3fff) /* Implementation-defined range end. */ ++ ++/* SGI/MIPS extensions. */ ++DW_AT (DW_AT_MIPS_fde, 0x2001) ++DW_AT (DW_AT_MIPS_loop_begin, 0x2002) ++DW_AT (DW_AT_MIPS_tail_loop_begin, 0x2003) ++DW_AT (DW_AT_MIPS_epilog_begin, 0x2004) ++DW_AT (DW_AT_MIPS_loop_unroll_factor, 0x2005) ++DW_AT (DW_AT_MIPS_software_pipeline_depth, 0x2006) ++DW_AT (DW_AT_MIPS_linkage_name, 0x2007) ++DW_AT (DW_AT_MIPS_stride, 0x2008) ++DW_AT (DW_AT_MIPS_abstract_name, 0x2009) ++DW_AT (DW_AT_MIPS_clone_origin, 0x200a) ++DW_AT (DW_AT_MIPS_has_inlines, 0x200b) ++/* HP extensions. */ ++DW_AT (DW_AT_HP_block_index, 0x2000) ++DW_AT_DUP (DW_AT_HP_unmodifiable, 0x2001) /* Same as DW_AT_MIPS_fde. */ ++DW_AT_DUP (DW_AT_HP_prologue, 0x2005) /* Same as DW_AT_MIPS_loop_unroll. */ ++DW_AT_DUP (DW_AT_HP_epilogue, 0x2008) /* Same as DW_AT_MIPS_stride. */ ++DW_AT (DW_AT_HP_actuals_stmt_list, 0x2010) ++DW_AT (DW_AT_HP_proc_per_section, 0x2011) ++DW_AT (DW_AT_HP_raw_data_ptr, 0x2012) ++DW_AT (DW_AT_HP_pass_by_reference, 0x2013) ++DW_AT (DW_AT_HP_opt_level, 0x2014) ++DW_AT (DW_AT_HP_prof_version_id, 0x2015) ++DW_AT (DW_AT_HP_opt_flags, 0x2016) ++DW_AT (DW_AT_HP_cold_region_low_pc, 0x2017) ++DW_AT (DW_AT_HP_cold_region_high_pc, 0x2018) ++DW_AT (DW_AT_HP_all_variables_modifiable, 0x2019) ++DW_AT (DW_AT_HP_linkage_name, 0x201a) ++DW_AT (DW_AT_HP_prof_flags, 0x201b) /* In comp unit of procs_info for -g. */ ++DW_AT (DW_AT_HP_unit_name, 0x201f) ++DW_AT (DW_AT_HP_unit_size, 0x2020) ++DW_AT (DW_AT_HP_widened_byte_size, 0x2021) ++DW_AT (DW_AT_HP_definition_points, 0x2022) ++DW_AT (DW_AT_HP_default_location, 0x2023) ++DW_AT (DW_AT_HP_is_result_param, 0x2029) ++ ++/* GNU extensions. */ ++DW_AT (DW_AT_sf_names, 0x2101) ++DW_AT (DW_AT_src_info, 0x2102) ++DW_AT (DW_AT_mac_info, 0x2103) ++DW_AT (DW_AT_src_coords, 0x2104) ++DW_AT (DW_AT_body_begin, 0x2105) ++DW_AT (DW_AT_body_end, 0x2106) ++DW_AT (DW_AT_GNU_vector, 0x2107) ++/* Thread-safety annotations. ++ See http://gcc.gnu.org/wiki/ThreadSafetyAnnotation . */ ++DW_AT (DW_AT_GNU_guarded_by, 0x2108) ++DW_AT (DW_AT_GNU_pt_guarded_by, 0x2109) ++DW_AT (DW_AT_GNU_guarded, 0x210a) ++DW_AT (DW_AT_GNU_pt_guarded, 0x210b) ++DW_AT (DW_AT_GNU_locks_excluded, 0x210c) ++DW_AT (DW_AT_GNU_exclusive_locks_required, 0x210d) ++DW_AT (DW_AT_GNU_shared_locks_required, 0x210e) ++/* One-definition rule violation detection. ++ See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo . */ ++DW_AT (DW_AT_GNU_odr_signature, 0x210f) ++/* Template template argument name. ++ See http://gcc.gnu.org/wiki/TemplateParmsDwarf . */ ++DW_AT (DW_AT_GNU_template_name, 0x2110) ++/* The GNU call site extension. ++ See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open . */ ++DW_AT (DW_AT_GNU_call_site_value, 0x2111) ++DW_AT (DW_AT_GNU_call_site_data_value, 0x2112) ++DW_AT (DW_AT_GNU_call_site_target, 0x2113) ++DW_AT (DW_AT_GNU_call_site_target_clobbered, 0x2114) ++DW_AT (DW_AT_GNU_tail_call, 0x2115) ++DW_AT (DW_AT_GNU_all_tail_call_sites, 0x2116) ++DW_AT (DW_AT_GNU_all_call_sites, 0x2117) ++DW_AT (DW_AT_GNU_all_source_call_sites, 0x2118) ++/* Section offset into .debug_macro section. */ ++DW_AT (DW_AT_GNU_macros, 0x2119) ++/* Attribute for C++ deleted special member functions (= delete;). */ ++DW_AT (DW_AT_GNU_deleted, 0x211a) ++/* Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission. */ ++DW_AT (DW_AT_GNU_dwo_name, 0x2130) ++DW_AT (DW_AT_GNU_dwo_id, 0x2131) ++DW_AT (DW_AT_GNU_ranges_base, 0x2132) ++DW_AT (DW_AT_GNU_addr_base, 0x2133) ++DW_AT (DW_AT_GNU_pubnames, 0x2134) ++DW_AT (DW_AT_GNU_pubtypes, 0x2135) ++/* Attribute for discriminator. ++ See http://gcc.gnu.org/wiki/Discriminator */ ++DW_AT (DW_AT_GNU_discriminator, 0x2136) ++/* VMS extensions. */ ++DW_AT (DW_AT_VMS_rtnbeg_pd_address, 0x2201) ++/* GNAT extensions. */ ++/* GNAT descriptive type. ++ See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type . */ ++DW_AT (DW_AT_use_GNAT_descriptive_type, 0x2301) ++DW_AT (DW_AT_GNAT_descriptive_type, 0x2302) ++/* Rational constant extension. ++ See https://gcc.gnu.org/wiki/DW_AT_GNU_numerator_denominator . */ ++DW_TAG (DW_AT_GNU_numerator, 0x2303) ++DW_TAG (DW_AT_GNU_denominator, 0x2304) ++/* Biased integer extension. ++ See https://gcc.gnu.org/wiki/DW_AT_GNU_bias . */ ++DW_TAG (DW_AT_GNU_bias, 0x2305) ++/* UPC extension. */ ++DW_AT (DW_AT_upc_threads_scaled, 0x3210) ++/* PGI (STMicroelectronics) extensions. */ ++DW_AT (DW_AT_PGI_lbase, 0x3a00) ++DW_AT (DW_AT_PGI_soffset, 0x3a01) ++DW_AT (DW_AT_PGI_lstride, 0x3a02) ++/* Apple extensions. */ ++DW_AT (DW_AT_APPLE_optimized, 0x3fe1) ++DW_AT (DW_AT_APPLE_flags, 0x3fe2) ++DW_AT (DW_AT_APPLE_isa, 0x3fe3) ++DW_AT (DW_AT_APPLE_block, 0x3fe4) ++DW_AT (DW_AT_APPLE_major_runtime_vers, 0x3fe5) ++DW_AT (DW_AT_APPLE_runtime_class, 0x3fe6) ++DW_AT (DW_AT_APPLE_omit_frame_ptr, 0x3fe7) ++DW_AT (DW_AT_APPLE_property_name, 0x3fe8) ++DW_AT (DW_AT_APPLE_property_getter, 0x3fe9) ++DW_AT (DW_AT_APPLE_property_setter, 0x3fea) ++DW_AT (DW_AT_APPLE_property_attribute, 0x3feb) ++DW_AT (DW_AT_APPLE_objc_complete_type, 0x3fec) ++DW_AT (DW_AT_APPLE_property, 0x3fed) ++DW_END_AT ++ ++DW_FIRST_OP (DW_OP_addr, 0x03) ++DW_OP (DW_OP_deref, 0x06) ++DW_OP (DW_OP_const1u, 0x08) ++DW_OP (DW_OP_const1s, 0x09) ++DW_OP (DW_OP_const2u, 0x0a) ++DW_OP (DW_OP_const2s, 0x0b) ++DW_OP (DW_OP_const4u, 0x0c) ++DW_OP (DW_OP_const4s, 0x0d) ++DW_OP (DW_OP_const8u, 0x0e) ++DW_OP (DW_OP_const8s, 0x0f) ++DW_OP (DW_OP_constu, 0x10) ++DW_OP (DW_OP_consts, 0x11) ++DW_OP (DW_OP_dup, 0x12) ++DW_OP (DW_OP_drop, 0x13) ++DW_OP (DW_OP_over, 0x14) ++DW_OP (DW_OP_pick, 0x15) ++DW_OP (DW_OP_swap, 0x16) ++DW_OP (DW_OP_rot, 0x17) ++DW_OP (DW_OP_xderef, 0x18) ++DW_OP (DW_OP_abs, 0x19) ++DW_OP (DW_OP_and, 0x1a) ++DW_OP (DW_OP_div, 0x1b) ++DW_OP (DW_OP_minus, 0x1c) ++DW_OP (DW_OP_mod, 0x1d) ++DW_OP (DW_OP_mul, 0x1e) ++DW_OP (DW_OP_neg, 0x1f) ++DW_OP (DW_OP_not, 0x20) ++DW_OP (DW_OP_or, 0x21) ++DW_OP (DW_OP_plus, 0x22) ++DW_OP (DW_OP_plus_uconst, 0x23) ++DW_OP (DW_OP_shl, 0x24) ++DW_OP (DW_OP_shr, 0x25) ++DW_OP (DW_OP_shra, 0x26) ++DW_OP (DW_OP_xor, 0x27) ++DW_OP (DW_OP_bra, 0x28) ++DW_OP (DW_OP_eq, 0x29) ++DW_OP (DW_OP_ge, 0x2a) ++DW_OP (DW_OP_gt, 0x2b) ++DW_OP (DW_OP_le, 0x2c) ++DW_OP (DW_OP_lt, 0x2d) ++DW_OP (DW_OP_ne, 0x2e) ++DW_OP (DW_OP_skip, 0x2f) ++DW_OP (DW_OP_lit0, 0x30) ++DW_OP (DW_OP_lit1, 0x31) ++DW_OP (DW_OP_lit2, 0x32) ++DW_OP (DW_OP_lit3, 0x33) ++DW_OP (DW_OP_lit4, 0x34) ++DW_OP (DW_OP_lit5, 0x35) ++DW_OP (DW_OP_lit6, 0x36) ++DW_OP (DW_OP_lit7, 0x37) ++DW_OP (DW_OP_lit8, 0x38) ++DW_OP (DW_OP_lit9, 0x39) ++DW_OP (DW_OP_lit10, 0x3a) ++DW_OP (DW_OP_lit11, 0x3b) ++DW_OP (DW_OP_lit12, 0x3c) ++DW_OP (DW_OP_lit13, 0x3d) ++DW_OP (DW_OP_lit14, 0x3e) ++DW_OP (DW_OP_lit15, 0x3f) ++DW_OP (DW_OP_lit16, 0x40) ++DW_OP (DW_OP_lit17, 0x41) ++DW_OP (DW_OP_lit18, 0x42) ++DW_OP (DW_OP_lit19, 0x43) ++DW_OP (DW_OP_lit20, 0x44) ++DW_OP (DW_OP_lit21, 0x45) ++DW_OP (DW_OP_lit22, 0x46) ++DW_OP (DW_OP_lit23, 0x47) ++DW_OP (DW_OP_lit24, 0x48) ++DW_OP (DW_OP_lit25, 0x49) ++DW_OP (DW_OP_lit26, 0x4a) ++DW_OP (DW_OP_lit27, 0x4b) ++DW_OP (DW_OP_lit28, 0x4c) ++DW_OP (DW_OP_lit29, 0x4d) ++DW_OP (DW_OP_lit30, 0x4e) ++DW_OP (DW_OP_lit31, 0x4f) ++DW_OP (DW_OP_reg0, 0x50) ++DW_OP (DW_OP_reg1, 0x51) ++DW_OP (DW_OP_reg2, 0x52) ++DW_OP (DW_OP_reg3, 0x53) ++DW_OP (DW_OP_reg4, 0x54) ++DW_OP (DW_OP_reg5, 0x55) ++DW_OP (DW_OP_reg6, 0x56) ++DW_OP (DW_OP_reg7, 0x57) ++DW_OP (DW_OP_reg8, 0x58) ++DW_OP (DW_OP_reg9, 0x59) ++DW_OP (DW_OP_reg10, 0x5a) ++DW_OP (DW_OP_reg11, 0x5b) ++DW_OP (DW_OP_reg12, 0x5c) ++DW_OP (DW_OP_reg13, 0x5d) ++DW_OP (DW_OP_reg14, 0x5e) ++DW_OP (DW_OP_reg15, 0x5f) ++DW_OP (DW_OP_reg16, 0x60) ++DW_OP (DW_OP_reg17, 0x61) ++DW_OP (DW_OP_reg18, 0x62) ++DW_OP (DW_OP_reg19, 0x63) ++DW_OP (DW_OP_reg20, 0x64) ++DW_OP (DW_OP_reg21, 0x65) ++DW_OP (DW_OP_reg22, 0x66) ++DW_OP (DW_OP_reg23, 0x67) ++DW_OP (DW_OP_reg24, 0x68) ++DW_OP (DW_OP_reg25, 0x69) ++DW_OP (DW_OP_reg26, 0x6a) ++DW_OP (DW_OP_reg27, 0x6b) ++DW_OP (DW_OP_reg28, 0x6c) ++DW_OP (DW_OP_reg29, 0x6d) ++DW_OP (DW_OP_reg30, 0x6e) ++DW_OP (DW_OP_reg31, 0x6f) ++DW_OP (DW_OP_breg0, 0x70) ++DW_OP (DW_OP_breg1, 0x71) ++DW_OP (DW_OP_breg2, 0x72) ++DW_OP (DW_OP_breg3, 0x73) ++DW_OP (DW_OP_breg4, 0x74) ++DW_OP (DW_OP_breg5, 0x75) ++DW_OP (DW_OP_breg6, 0x76) ++DW_OP (DW_OP_breg7, 0x77) ++DW_OP (DW_OP_breg8, 0x78) ++DW_OP (DW_OP_breg9, 0x79) ++DW_OP (DW_OP_breg10, 0x7a) ++DW_OP (DW_OP_breg11, 0x7b) ++DW_OP (DW_OP_breg12, 0x7c) ++DW_OP (DW_OP_breg13, 0x7d) ++DW_OP (DW_OP_breg14, 0x7e) ++DW_OP (DW_OP_breg15, 0x7f) ++DW_OP (DW_OP_breg16, 0x80) ++DW_OP (DW_OP_breg17, 0x81) ++DW_OP (DW_OP_breg18, 0x82) ++DW_OP (DW_OP_breg19, 0x83) ++DW_OP (DW_OP_breg20, 0x84) ++DW_OP (DW_OP_breg21, 0x85) ++DW_OP (DW_OP_breg22, 0x86) ++DW_OP (DW_OP_breg23, 0x87) ++DW_OP (DW_OP_breg24, 0x88) ++DW_OP (DW_OP_breg25, 0x89) ++DW_OP (DW_OP_breg26, 0x8a) ++DW_OP (DW_OP_breg27, 0x8b) ++DW_OP (DW_OP_breg28, 0x8c) ++DW_OP (DW_OP_breg29, 0x8d) ++DW_OP (DW_OP_breg30, 0x8e) ++DW_OP (DW_OP_breg31, 0x8f) ++DW_OP (DW_OP_regx, 0x90) ++DW_OP (DW_OP_fbreg, 0x91) ++DW_OP (DW_OP_bregx, 0x92) ++DW_OP (DW_OP_piece, 0x93) ++DW_OP (DW_OP_deref_size, 0x94) ++DW_OP (DW_OP_xderef_size, 0x95) ++DW_OP (DW_OP_nop, 0x96) ++/* DWARF 3 extensions. */ ++DW_OP (DW_OP_push_object_address, 0x97) ++DW_OP (DW_OP_call2, 0x98) ++DW_OP (DW_OP_call4, 0x99) ++DW_OP (DW_OP_call_ref, 0x9a) ++DW_OP (DW_OP_form_tls_address, 0x9b) ++DW_OP (DW_OP_call_frame_cfa, 0x9c) ++DW_OP (DW_OP_bit_piece, 0x9d) ++ ++/* DWARF 4 extensions. */ ++DW_OP (DW_OP_implicit_value, 0x9e) ++DW_OP (DW_OP_stack_value, 0x9f) ++ ++/* DWARF 5 extensions. */ ++DW_OP (DW_OP_implicit_pointer, 0xa0) ++DW_OP (DW_OP_addrx, 0xa1) ++DW_OP (DW_OP_constx, 0xa2) ++DW_OP (DW_OP_entry_value, 0xa3) ++DW_OP (DW_OP_const_type, 0xa4) ++DW_OP (DW_OP_regval_type, 0xa5) ++DW_OP (DW_OP_deref_type, 0xa6) ++DW_OP (DW_OP_xderef_type, 0xa7) ++DW_OP (DW_OP_convert, 0xa8) ++DW_OP (DW_OP_reinterpret, 0xa9) ++ ++DW_OP_DUP (DW_OP_lo_user, 0xe0) /* Implementation-defined range start. */ ++DW_OP_DUP (DW_OP_hi_user, 0xff) /* Implementation-defined range end. */ ++ ++/* GNU extensions. */ ++DW_OP (DW_OP_GNU_push_tls_address, 0xe0) ++/* The following is for marking variables that are uninitialized. */ ++DW_OP (DW_OP_GNU_uninit, 0xf0) ++DW_OP (DW_OP_GNU_encoded_addr, 0xf1) ++/* The GNU implicit pointer extension. ++ See http://www.dwarfstd.org/ShowIssue.php?issue=100831.1&type=open . */ ++DW_OP (DW_OP_GNU_implicit_pointer, 0xf2) ++/* The GNU entry value extension. ++ See http://www.dwarfstd.org/ShowIssue.php?issue=100909.1&type=open . */ ++DW_OP (DW_OP_GNU_entry_value, 0xf3) ++/* The GNU typed stack extension. ++ See http://www.dwarfstd.org/doc/040408.1.html . */ ++DW_OP (DW_OP_GNU_const_type, 0xf4) ++DW_OP (DW_OP_GNU_regval_type, 0xf5) ++DW_OP (DW_OP_GNU_deref_type, 0xf6) ++DW_OP (DW_OP_GNU_convert, 0xf7) ++DW_OP (DW_OP_GNU_reinterpret, 0xf9) ++/* The GNU parameter ref extension. */ ++DW_OP (DW_OP_GNU_parameter_ref, 0xfa) ++/* Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission. */ ++DW_OP (DW_OP_GNU_addr_index, 0xfb) ++DW_OP (DW_OP_GNU_const_index, 0xfc) ++/* HP extensions. */ ++DW_OP_DUP (DW_OP_HP_unknown, 0xe0) /* Ouch, the same as GNU_push_tls_address. */ ++DW_OP (DW_OP_HP_is_value, 0xe1) ++DW_OP (DW_OP_HP_fltconst4, 0xe2) ++DW_OP (DW_OP_HP_fltconst8, 0xe3) ++DW_OP (DW_OP_HP_mod_range, 0xe4) ++DW_OP (DW_OP_HP_unmod_range, 0xe5) ++DW_OP (DW_OP_HP_tls, 0xe6) ++/* PGI (STMicroelectronics) extensions. */ ++DW_OP (DW_OP_PGI_omp_thread_num, 0xf8) ++DW_END_OP ++ ++DW_FIRST_ATE (DW_ATE_void, 0x0) ++DW_ATE (DW_ATE_address, 0x1) ++DW_ATE (DW_ATE_boolean, 0x2) ++DW_ATE (DW_ATE_complex_float, 0x3) ++DW_ATE (DW_ATE_float, 0x4) ++DW_ATE (DW_ATE_signed, 0x5) ++DW_ATE (DW_ATE_signed_char, 0x6) ++DW_ATE (DW_ATE_unsigned, 0x7) ++DW_ATE (DW_ATE_unsigned_char, 0x8) ++/* DWARF 3. */ ++DW_ATE (DW_ATE_imaginary_float, 0x9) ++DW_ATE (DW_ATE_packed_decimal, 0xa) ++DW_ATE (DW_ATE_numeric_string, 0xb) ++DW_ATE (DW_ATE_edited, 0xc) ++DW_ATE (DW_ATE_signed_fixed, 0xd) ++DW_ATE (DW_ATE_unsigned_fixed, 0xe) ++DW_ATE (DW_ATE_decimal_float, 0xf) ++/* DWARF 4. */ ++DW_ATE (DW_ATE_UTF, 0x10) ++/* DWARF 5. */ ++DW_ATE (DW_ATE_UCS, 0x11) ++DW_ATE (DW_ATE_ASCII, 0x12) ++ ++DW_ATE_DUP (DW_ATE_lo_user, 0x80) ++DW_ATE_DUP (DW_ATE_hi_user, 0xff) ++ ++/* HP extensions. */ ++DW_ATE (DW_ATE_HP_float80, 0x80) /* Floating-point (80 bit). */ ++DW_ATE (DW_ATE_HP_complex_float80, 0x81) /* Complex floating-point (80 bit). */ ++DW_ATE (DW_ATE_HP_float128, 0x82) /* Floating-point (128 bit). */ ++DW_ATE (DW_ATE_HP_complex_float128, 0x83) /* Complex fp (128 bit). */ ++DW_ATE (DW_ATE_HP_floathpintel, 0x84) /* Floating-point (82 bit IA64). */ ++DW_ATE (DW_ATE_HP_imaginary_float80, 0x85) ++DW_ATE (DW_ATE_HP_imaginary_float128, 0x86) ++DW_ATE (DW_ATE_HP_VAX_float, 0x88) /* F or G floating. */ ++DW_ATE (DW_ATE_HP_VAX_float_d, 0x89) /* D floating. */ ++DW_ATE (DW_ATE_HP_packed_decimal, 0x8a) /* Cobol. */ ++DW_ATE (DW_ATE_HP_zoned_decimal, 0x8b) /* Cobol. */ ++DW_ATE (DW_ATE_HP_edited, 0x8c) /* Cobol. */ ++DW_ATE (DW_ATE_HP_signed_fixed, 0x8d) /* Cobol. */ ++DW_ATE (DW_ATE_HP_unsigned_fixed, 0x8e) /* Cobol. */ ++DW_ATE (DW_ATE_HP_VAX_complex_float, 0x8f) /* F or G floating complex. */ ++DW_ATE (DW_ATE_HP_VAX_complex_float_d, 0x90) /* D floating complex. */ ++ ++DW_END_ATE ++ ++DW_FIRST_CFA (DW_CFA_advance_loc, 0x40) ++DW_CFA (DW_CFA_offset, 0x80) ++DW_CFA (DW_CFA_restore, 0xc0) ++DW_CFA (DW_CFA_nop, 0x00) ++DW_CFA (DW_CFA_set_loc, 0x01) ++DW_CFA (DW_CFA_advance_loc1, 0x02) ++DW_CFA (DW_CFA_advance_loc2, 0x03) ++DW_CFA (DW_CFA_advance_loc4, 0x04) ++DW_CFA (DW_CFA_offset_extended, 0x05) ++DW_CFA (DW_CFA_restore_extended, 0x06) ++DW_CFA (DW_CFA_undefined, 0x07) ++DW_CFA (DW_CFA_same_value, 0x08) ++DW_CFA (DW_CFA_register, 0x09) ++DW_CFA (DW_CFA_remember_state, 0x0a) ++DW_CFA (DW_CFA_restore_state, 0x0b) ++DW_CFA (DW_CFA_def_cfa, 0x0c) ++DW_CFA (DW_CFA_def_cfa_register, 0x0d) ++DW_CFA (DW_CFA_def_cfa_offset, 0x0e) ++/* DWARF 3. */ ++DW_CFA (DW_CFA_def_cfa_expression, 0x0f) ++DW_CFA (DW_CFA_expression, 0x10) ++DW_CFA (DW_CFA_offset_extended_sf, 0x11) ++DW_CFA (DW_CFA_def_cfa_sf, 0x12) ++DW_CFA (DW_CFA_def_cfa_offset_sf, 0x13) ++DW_CFA (DW_CFA_val_offset, 0x14) ++DW_CFA (DW_CFA_val_offset_sf, 0x15) ++DW_CFA (DW_CFA_val_expression, 0x16) ++ ++DW_CFA (DW_CFA_lo_user, 0x1c) ++DW_CFA (DW_CFA_hi_user, 0x3f) ++ ++/* SGI/MIPS specific. */ ++DW_CFA (DW_CFA_MIPS_advance_loc8, 0x1d) ++/* GNU extensions. */ ++DW_CFA (DW_CFA_GNU_window_save, 0x2d) ++DW_CFA (DW_CFA_GNU_args_size, 0x2e) ++DW_CFA (DW_CFA_GNU_negative_offset_extended, 0x2f) ++ ++DW_END_CFA diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/dwarf2.h index 000000000,000000000..ca8ff3b6d new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/dwarf2.h @@@ -1,0 -1,0 +1,531 @@@ ++/* Declarations and definitions of codes relating to the DWARF2 and ++ DWARF3 symbolic debugging information formats. ++ Copyright (C) 1992-2016 Free Software Foundation, Inc. ++ ++ Written by Gary Funck (gary@intrepid.com) The Ada Joint Program ++ Office (AJPO), Florida State University and Silicon Graphics Inc. ++ provided support for this effort -- June 21, 1995. ++ ++ Derived from the DWARF 1 implementation written by Ron Guilmette ++ (rfg@netcom.com), November 1990. ++ ++ This file is part of GCC. ++ ++ GCC is free software; you can redistribute it and/or modify it under ++ the terms of the GNU General Public License as published by the Free ++ Software Foundation; either version 3, or (at your option) any later ++ version. ++ ++ GCC is distributed in the hope that it will be useful, but WITHOUT ++ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ++ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public ++ License for more details. ++ ++ Under Section 7 of GPL version 3, you are granted additional ++ permissions described in the GCC Runtime Library Exception, version ++ 3.1, as published by the Free Software Foundation. ++ ++ You should have received a copy of the GNU General Public License and ++ a copy of the GCC Runtime Library Exception along with this program; ++ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ++ . */ ++ ++/* This file is derived from the DWARF specification (a public document) ++ Revision 2.0.0 (July 27, 1993) developed by the UNIX International ++ Programming Languages Special Interest Group (UI/PLSIG) and distributed ++ by UNIX International. Copies of this specification are available from ++ UNIX International, 20 Waterview Boulevard, Parsippany, NJ, 07054. ++ ++ This file also now contains definitions from the DWARF 3 specification ++ published Dec 20, 2005, available from: http://dwarf.freestandards.org. */ ++ ++#ifndef _DWARF2_H ++#define _DWARF2_H ++ ++#define DW_TAG(name, value) , name = value ++#define DW_TAG_DUP(name, value) , name = value ++#define DW_FORM(name, value) , name = value ++#define DW_AT(name, value) , name = value ++#define DW_AT_DUP(name, value) , name = value ++#define DW_OP(name, value) , name = value ++#define DW_OP_DUP(name, value) , name = value ++#define DW_ATE(name, value) , name = value ++#define DW_ATE_DUP(name, value) , name = value ++#define DW_CFA(name, value) , name = value ++ ++#define DW_FIRST_TAG(name, value) enum dwarf_tag { \ ++ name = value ++#define DW_END_TAG }; ++#define DW_FIRST_FORM(name, value) enum dwarf_form { \ ++ name = value ++#define DW_END_FORM }; ++#define DW_FIRST_AT(name, value) enum dwarf_attribute { \ ++ name = value ++#define DW_END_AT }; ++#define DW_FIRST_OP(name, value) enum dwarf_location_atom { \ ++ name = value ++#define DW_END_OP }; ++#define DW_FIRST_ATE(name, value) enum dwarf_type { \ ++ name = value ++#define DW_END_ATE }; ++#define DW_FIRST_CFA(name, value) enum dwarf_call_frame_info { \ ++ name = value ++#define DW_END_CFA }; ++ ++#include "dwarf2.def" ++ ++#undef DW_FIRST_TAG ++#undef DW_END_TAG ++#undef DW_FIRST_FORM ++#undef DW_END_FORM ++#undef DW_FIRST_AT ++#undef DW_END_AT ++#undef DW_FIRST_OP ++#undef DW_END_OP ++#undef DW_FIRST_ATE ++#undef DW_END_ATE ++#undef DW_FIRST_CFA ++#undef DW_END_CFA ++ ++#undef DW_TAG ++#undef DW_TAG_DUP ++#undef DW_FORM ++#undef DW_AT ++#undef DW_AT_DUP ++#undef DW_OP ++#undef DW_OP_DUP ++#undef DW_ATE ++#undef DW_ATE_DUP ++#undef DW_CFA ++ ++/* Flag that tells whether entry has a child or not. */ ++#define DW_children_no 0 ++#define DW_children_yes 1 ++ ++#define DW_AT_stride_size DW_AT_bit_stride /* Note: The use of DW_AT_stride_size is deprecated. */ ++#define DW_AT_stride DW_AT_byte_stride /* Note: The use of DW_AT_stride is deprecated. */ ++ ++/* Decimal sign encodings. */ ++enum dwarf_decimal_sign_encoding ++ { ++ /* DWARF 3. */ ++ DW_DS_unsigned = 0x01, ++ DW_DS_leading_overpunch = 0x02, ++ DW_DS_trailing_overpunch = 0x03, ++ DW_DS_leading_separate = 0x04, ++ DW_DS_trailing_separate = 0x05 ++ }; ++ ++/* Endianity encodings. */ ++enum dwarf_endianity_encoding ++ { ++ /* DWARF 3. */ ++ DW_END_default = 0x00, ++ DW_END_big = 0x01, ++ DW_END_little = 0x02, ++ ++ DW_END_lo_user = 0x40, ++ DW_END_hi_user = 0xff ++ }; ++ ++/* Array ordering names and codes. */ ++enum dwarf_array_dim_ordering ++ { ++ DW_ORD_row_major = 0, ++ DW_ORD_col_major = 1 ++ }; ++ ++/* Access attribute. */ ++enum dwarf_access_attribute ++ { ++ DW_ACCESS_public = 1, ++ DW_ACCESS_protected = 2, ++ DW_ACCESS_private = 3 ++ }; ++ ++/* Visibility. */ ++enum dwarf_visibility_attribute ++ { ++ DW_VIS_local = 1, ++ DW_VIS_exported = 2, ++ DW_VIS_qualified = 3 ++ }; ++ ++/* Virtuality. */ ++enum dwarf_virtuality_attribute ++ { ++ DW_VIRTUALITY_none = 0, ++ DW_VIRTUALITY_virtual = 1, ++ DW_VIRTUALITY_pure_virtual = 2 ++ }; ++ ++/* Case sensitivity. */ ++enum dwarf_id_case ++ { ++ DW_ID_case_sensitive = 0, ++ DW_ID_up_case = 1, ++ DW_ID_down_case = 2, ++ DW_ID_case_insensitive = 3 ++ }; ++ ++/* Calling convention. */ ++enum dwarf_calling_convention ++ { ++ DW_CC_normal = 0x1, ++ DW_CC_program = 0x2, ++ DW_CC_nocall = 0x3, ++ ++ /* DWARF 5. */ ++ DW_CC_pass_by_reference = 0x4, ++ DW_CC_pass_by_value = 0x5, ++ ++ DW_CC_lo_user = 0x40, ++ DW_CC_hi_user = 0xff, ++ ++ DW_CC_GNU_renesas_sh = 0x40, ++ DW_CC_GNU_borland_fastcall_i386 = 0x41, ++ ++ /* This DW_CC_ value is not currently generated by any toolchain. It is ++ used internally to GDB to indicate OpenCL C functions that have been ++ compiled with the IBM XL C for OpenCL compiler and use a non-platform ++ calling convention for passing OpenCL C vector types. This value may ++ be changed freely as long as it does not conflict with any other DW_CC_ ++ value defined here. */ ++ DW_CC_GDB_IBM_OpenCL = 0xff ++ }; ++ ++/* Inline attribute. */ ++enum dwarf_inline_attribute ++ { ++ DW_INL_not_inlined = 0, ++ DW_INL_inlined = 1, ++ DW_INL_declared_not_inlined = 2, ++ DW_INL_declared_inlined = 3 ++ }; ++ ++/* Discriminant lists. */ ++enum dwarf_discrim_list ++ { ++ DW_DSC_label = 0, ++ DW_DSC_range = 1 ++ }; ++ ++/* Line number opcodes. */ ++enum dwarf_line_number_ops ++ { ++ DW_LNS_extended_op = 0, ++ DW_LNS_copy = 1, ++ DW_LNS_advance_pc = 2, ++ DW_LNS_advance_line = 3, ++ DW_LNS_set_file = 4, ++ DW_LNS_set_column = 5, ++ DW_LNS_negate_stmt = 6, ++ DW_LNS_set_basic_block = 7, ++ DW_LNS_const_add_pc = 8, ++ DW_LNS_fixed_advance_pc = 9, ++ /* DWARF 3. */ ++ DW_LNS_set_prologue_end = 10, ++ DW_LNS_set_epilogue_begin = 11, ++ DW_LNS_set_isa = 12 ++ }; ++ ++/* Line number extended opcodes. */ ++enum dwarf_line_number_x_ops ++ { ++ DW_LNE_end_sequence = 1, ++ DW_LNE_set_address = 2, ++ DW_LNE_define_file = 3, ++ DW_LNE_set_discriminator = 4, ++ /* HP extensions. */ ++ DW_LNE_HP_negate_is_UV_update = 0x11, ++ DW_LNE_HP_push_context = 0x12, ++ DW_LNE_HP_pop_context = 0x13, ++ DW_LNE_HP_set_file_line_column = 0x14, ++ DW_LNE_HP_set_routine_name = 0x15, ++ DW_LNE_HP_set_sequence = 0x16, ++ DW_LNE_HP_negate_post_semantics = 0x17, ++ DW_LNE_HP_negate_function_exit = 0x18, ++ DW_LNE_HP_negate_front_end_logical = 0x19, ++ DW_LNE_HP_define_proc = 0x20, ++ DW_LNE_HP_source_file_correlation = 0x80, ++ ++ DW_LNE_lo_user = 0x80, ++ DW_LNE_hi_user = 0xff ++ }; ++ ++/* Sub-opcodes for DW_LNE_HP_source_file_correlation. */ ++enum dwarf_line_number_hp_sfc_ops ++ { ++ DW_LNE_HP_SFC_formfeed = 1, ++ DW_LNE_HP_SFC_set_listing_line = 2, ++ DW_LNE_HP_SFC_associate = 3 ++ }; ++ ++/* Content type codes in line table directory_entry_format ++ and file_name_entry_format sequences. */ ++enum dwarf_line_number_content_type ++ { ++ DW_LNCT_path = 0x1, ++ DW_LNCT_directory_index = 0x2, ++ DW_LNCT_timestamp = 0x3, ++ DW_LNCT_size = 0x4, ++ DW_LNCT_MD5 = 0x5, ++ DW_LNCT_lo_user = 0x2000, ++ DW_LNCT_hi_user = 0x3fff ++ }; ++ ++/* Type codes for location list entries. */ ++enum dwarf_location_list_entry_type ++ { ++ DW_LLE_end_of_list = 0x00, ++ DW_LLE_base_addressx = 0x01, ++ DW_LLE_startx_endx = 0x02, ++ DW_LLE_startx_length = 0x03, ++ DW_LLE_offset_pair = 0x04, ++ DW_LLE_default_location = 0x05, ++ DW_LLE_base_address = 0x06, ++ DW_LLE_start_end = 0x07, ++ DW_LLE_start_length = 0x08, ++ ++ /* Former extension for Fission. ++ See http://gcc.gnu.org/wiki/DebugFission. */ ++ DW_LLE_GNU_end_of_list_entry = 0x00, ++ DW_LLE_GNU_base_address_selection_entry = 0x01, ++ DW_LLE_GNU_start_end_entry = 0x02, ++ DW_LLE_GNU_start_length_entry = 0x03 ++ }; ++ ++#define DW_CIE_ID 0xffffffff ++#define DW64_CIE_ID 0xffffffffffffffffULL ++#define DW_CIE_VERSION 1 ++ ++#define DW_CFA_extended 0 ++ ++#define DW_CHILDREN_no 0x00 ++#define DW_CHILDREN_yes 0x01 ++ ++#define DW_ADDR_none 0 ++ ++/* Source language names and codes. */ ++enum dwarf_source_language ++ { ++ DW_LANG_C89 = 0x0001, ++ DW_LANG_C = 0x0002, ++ DW_LANG_Ada83 = 0x0003, ++ DW_LANG_C_plus_plus = 0x0004, ++ DW_LANG_Cobol74 = 0x0005, ++ DW_LANG_Cobol85 = 0x0006, ++ DW_LANG_Fortran77 = 0x0007, ++ DW_LANG_Fortran90 = 0x0008, ++ DW_LANG_Pascal83 = 0x0009, ++ DW_LANG_Modula2 = 0x000a, ++ /* DWARF 3. */ ++ DW_LANG_Java = 0x000b, ++ DW_LANG_C99 = 0x000c, ++ DW_LANG_Ada95 = 0x000d, ++ DW_LANG_Fortran95 = 0x000e, ++ DW_LANG_PLI = 0x000f, ++ DW_LANG_ObjC = 0x0010, ++ DW_LANG_ObjC_plus_plus = 0x0011, ++ DW_LANG_UPC = 0x0012, ++ DW_LANG_D = 0x0013, ++ /* DWARF 4. */ ++ DW_LANG_Python = 0x0014, ++ /* DWARF 5. */ ++ DW_LANG_OpenCL = 0x0015, ++ DW_LANG_Go = 0x0016, ++ DW_LANG_Modula3 = 0x0017, ++ DW_LANG_Haskell = 0x0018, ++ DW_LANG_C_plus_plus_03 = 0x0019, ++ DW_LANG_C_plus_plus_11 = 0x001a, ++ DW_LANG_OCaml = 0x001b, ++ DW_LANG_Rust = 0x001c, ++ DW_LANG_C11 = 0x001d, ++ DW_LANG_Swift = 0x001e, ++ DW_LANG_Julia = 0x001f, ++ DW_LANG_Dylan = 0x0020, ++ DW_LANG_C_plus_plus_14 = 0x0021, ++ DW_LANG_Fortran03 = 0x0022, ++ DW_LANG_Fortran08 = 0x0023, ++ DW_LANG_RenderScript = 0x0024, ++ ++ DW_LANG_lo_user = 0x8000, /* Implementation-defined range start. */ ++ DW_LANG_hi_user = 0xffff, /* Implementation-defined range start. */ ++ ++ /* MIPS. */ ++ DW_LANG_Mips_Assembler = 0x8001, ++ /* UPC. */ ++ DW_LANG_Upc = 0x8765, ++ /* HP extensions. */ ++ DW_LANG_HP_Bliss = 0x8003, ++ DW_LANG_HP_Basic91 = 0x8004, ++ DW_LANG_HP_Pascal91 = 0x8005, ++ DW_LANG_HP_IMacro = 0x8006, ++ DW_LANG_HP_Assembler = 0x8007, ++ ++ /* Rust extension, but replaced in DWARF 5. */ ++ DW_LANG_Rust_old = 0x9000 ++ }; ++ ++/* Names and codes for macro information. */ ++enum dwarf_macinfo_record_type ++ { ++ DW_MACINFO_define = 1, ++ DW_MACINFO_undef = 2, ++ DW_MACINFO_start_file = 3, ++ DW_MACINFO_end_file = 4, ++ DW_MACINFO_vendor_ext = 255 ++ }; ++ ++/* DW_TAG_defaulted/DW_TAG_GNU_defaulted attributes. */ ++enum dwarf_defaulted_attribute ++ { ++ DW_DEFAULTED_no = 0x00, ++ DW_DEFAULTED_in_class = 0x01, ++ DW_DEFAULTED_out_of_class = 0x02 ++ }; ++ ++/* Names and codes for new style macro information. */ ++enum dwarf_macro_record_type ++ { ++ DW_MACRO_define = 0x01, ++ DW_MACRO_undef = 0x02, ++ DW_MACRO_start_file = 0x03, ++ DW_MACRO_end_file = 0x04, ++ DW_MACRO_define_strp = 0x05, ++ DW_MACRO_undef_strp = 0x06, ++ DW_MACRO_import = 0x07, ++ DW_MACRO_define_sup = 0x08, ++ DW_MACRO_undef_sup = 0x09, ++ DW_MACRO_import_sup = 0x0a, ++ DW_MACRO_define_strx = 0x0b, ++ DW_MACRO_undef_strx = 0x0c, ++ DW_MACRO_lo_user = 0xe0, ++ DW_MACRO_hi_user = 0xff, ++ ++ /* Compatibility macros for the GNU .debug_macro extension. */ ++ DW_MACRO_GNU_define = 0x01, ++ DW_MACRO_GNU_undef = 0x02, ++ DW_MACRO_GNU_start_file = 0x03, ++ DW_MACRO_GNU_end_file = 0x04, ++ DW_MACRO_GNU_define_indirect = 0x05, ++ DW_MACRO_GNU_undef_indirect = 0x06, ++ DW_MACRO_GNU_transparent_include = 0x07, ++ /* Extensions for DWZ multifile. ++ See http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open . */ ++ DW_MACRO_GNU_define_indirect_alt = 0x08, ++ DW_MACRO_GNU_undef_indirect_alt = 0x09, ++ DW_MACRO_GNU_transparent_include_alt = 0x0a, ++ DW_MACRO_GNU_lo_user = 0xe0, ++ DW_MACRO_GNU_hi_user = 0xff ++ }; ++ ++/* Index attributes in the Abbreviations Table. */ ++enum dwarf_name_index_attribute ++ { ++ DW_IDX_compile_unit = 1, ++ DW_IDX_type_unit = 2, ++ DW_IDX_die_offset = 3, ++ DW_IDX_parent = 4, ++ DW_IDX_type_hash = 5, ++ DW_IDX_lo_user = 0x2000, ++ DW_IDX_hi_user = 0x3fff ++ }; ++ ++/* Range list entry kinds in .debug_rnglists* section. */ ++enum dwarf_range_list_entry ++ { ++ DW_RLE_end_of_list = 0x00, ++ DW_RLE_base_addressx = 0x01, ++ DW_RLE_startx_endx = 0x02, ++ DW_RLE_startx_length = 0x03, ++ DW_RLE_offset_pair = 0x04, ++ DW_RLE_base_address = 0x05, ++ DW_RLE_start_end = 0x06, ++ DW_RLE_start_length = 0x07 ++ }; ++ ++/* Unit types in unit_type unit header field. */ ++enum dwarf_unit_type ++ { ++ DW_UT_compile = 0x01, ++ DW_UT_type = 0x02, ++ DW_UT_partial = 0x03, ++ DW_UT_skeleton = 0x04, ++ DW_UT_split_compile = 0x05, ++ DW_UT_split_type = 0x06, ++ DW_UT_lo_user = 0x80, ++ DW_UT_hi_user = 0xff ++ }; ++ ++/* @@@ For use with GNU frame unwind information. */ ++ ++#define DW_EH_PE_absptr 0x00 ++#define DW_EH_PE_omit 0xff ++ ++#define DW_EH_PE_uleb128 0x01 ++#define DW_EH_PE_udata2 0x02 ++#define DW_EH_PE_udata4 0x03 ++#define DW_EH_PE_udata8 0x04 ++#define DW_EH_PE_sleb128 0x09 ++#define DW_EH_PE_sdata2 0x0A ++#define DW_EH_PE_sdata4 0x0B ++#define DW_EH_PE_sdata8 0x0C ++#define DW_EH_PE_signed 0x08 ++ ++#define DW_EH_PE_pcrel 0x10 ++#define DW_EH_PE_textrel 0x20 ++#define DW_EH_PE_datarel 0x30 ++#define DW_EH_PE_funcrel 0x40 ++#define DW_EH_PE_aligned 0x50 ++ ++#define DW_EH_PE_indirect 0x80 ++ ++/* Codes for the debug sections in a dwarf package (.dwp) file. ++ Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFissionDWP. */ ++enum dwarf_sect ++ { ++ DW_SECT_INFO = 1, ++ DW_SECT_TYPES = 2, ++ DW_SECT_ABBREV = 3, ++ DW_SECT_LINE = 4, ++ DW_SECT_LOC = 5, ++ DW_SECT_STR_OFFSETS = 6, ++ DW_SECT_MACINFO = 7, ++ DW_SECT_MACRO = 8, ++ DW_SECT_MAX = 8 ++ }; ++ ++#ifdef __cplusplus ++extern "C" { ++#endif /* __cplusplus */ ++ ++/* Return the name of a DW_TAG_ constant, or NULL if the value is not ++ recognized. */ ++extern const char *get_DW_TAG_name (unsigned int tag); ++ ++/* Return the name of a DW_AT_ constant, or NULL if the value is not ++ recognized. */ ++extern const char *get_DW_AT_name (unsigned int attr); ++ ++/* Return the name of a DW_FORM_ constant, or NULL if the value is not ++ recognized. */ ++extern const char *get_DW_FORM_name (unsigned int form); ++ ++/* Return the name of a DW_OP_ constant, or NULL if the value is not ++ recognized. */ ++extern const char *get_DW_OP_name (unsigned int op); ++ ++/* Return the name of a DW_ATE_ constant, or NULL if the value is not ++ recognized. */ ++extern const char *get_DW_ATE_name (unsigned int enc); ++ ++/* Return the name of a DW_CFA_ constant, or NULL if the value is not ++ recognized. */ ++extern const char *get_DW_CFA_name (unsigned int opc); ++ ++#ifdef __cplusplus ++} ++#endif /* __cplusplus */ ++ ++#endif /* _DWARF2_H */ diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/elf.c index 000000000,000000000..e87741382 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/elf.c @@@ -1,0 -1,0 +1,979 @@@ ++/* elf.c -- Get debug data from an ELF file for backtraces. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++ ++#ifdef HAVE_DL_ITERATE_PHDR ++#include ++#endif ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++#ifndef HAVE_DL_ITERATE_PHDR ++ ++/* Dummy version of dl_iterate_phdr for systems that don't have it. */ ++ ++#define dl_phdr_info x_dl_phdr_info ++#define dl_iterate_phdr x_dl_iterate_phdr ++ ++struct dl_phdr_info ++{ ++ uintptr_t dlpi_addr; ++ const char *dlpi_name; ++}; ++ ++static int ++dl_iterate_phdr (int (*callback) (struct dl_phdr_info *, ++ size_t, void *) ATTRIBUTE_UNUSED, ++ void *data ATTRIBUTE_UNUSED) ++{ ++ return 0; ++} ++ ++#endif /* ! defined (HAVE_DL_ITERATE_PHDR) */ ++ ++/* The configure script must tell us whether we are 32-bit or 64-bit ++ ELF. We could make this code test and support either possibility, ++ but there is no point. This code only works for the currently ++ running executable, which means that we know the ELF mode at ++ configure mode. */ ++ ++#if BACKTRACE_ELF_SIZE != 32 && BACKTRACE_ELF_SIZE != 64 ++#error "Unknown BACKTRACE_ELF_SIZE" ++#endif ++ ++/* might #include which might define our constants ++ with slightly different values. Undefine them to be safe. */ ++ ++#undef EI_NIDENT ++#undef EI_MAG0 ++#undef EI_MAG1 ++#undef EI_MAG2 ++#undef EI_MAG3 ++#undef EI_CLASS ++#undef EI_DATA ++#undef EI_VERSION ++#undef ELF_MAG0 ++#undef ELF_MAG1 ++#undef ELF_MAG2 ++#undef ELF_MAG3 ++#undef ELFCLASS32 ++#undef ELFCLASS64 ++#undef ELFDATA2LSB ++#undef ELFDATA2MSB ++#undef EV_CURRENT ++#undef ET_DYN ++#undef SHN_LORESERVE ++#undef SHN_XINDEX ++#undef SHN_UNDEF ++#undef SHT_SYMTAB ++#undef SHT_STRTAB ++#undef SHT_DYNSYM ++#undef STT_OBJECT ++#undef STT_FUNC ++ ++/* Basic types. */ ++ ++typedef uint16_t b_elf_half; /* Elf_Half. */ ++typedef uint32_t b_elf_word; /* Elf_Word. */ ++typedef int32_t b_elf_sword; /* Elf_Sword. */ ++ ++#if BACKTRACE_ELF_SIZE == 32 ++ ++typedef uint32_t b_elf_addr; /* Elf_Addr. */ ++typedef uint32_t b_elf_off; /* Elf_Off. */ ++ ++typedef uint32_t b_elf_wxword; /* 32-bit Elf_Word, 64-bit ELF_Xword. */ ++ ++#else ++ ++typedef uint64_t b_elf_addr; /* Elf_Addr. */ ++typedef uint64_t b_elf_off; /* Elf_Off. */ ++typedef uint64_t b_elf_xword; /* Elf_Xword. */ ++typedef int64_t b_elf_sxword; /* Elf_Sxword. */ ++ ++typedef uint64_t b_elf_wxword; /* 32-bit Elf_Word, 64-bit ELF_Xword. */ ++ ++#endif ++ ++/* Data structures and associated constants. */ ++ ++#define EI_NIDENT 16 ++ ++typedef struct { ++ unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */ ++ b_elf_half e_type; /* Identifies object file type */ ++ b_elf_half e_machine; /* Specifies required architecture */ ++ b_elf_word e_version; /* Identifies object file version */ ++ b_elf_addr e_entry; /* Entry point virtual address */ ++ b_elf_off e_phoff; /* Program header table file offset */ ++ b_elf_off e_shoff; /* Section header table file offset */ ++ b_elf_word e_flags; /* Processor-specific flags */ ++ b_elf_half e_ehsize; /* ELF header size in bytes */ ++ b_elf_half e_phentsize; /* Program header table entry size */ ++ b_elf_half e_phnum; /* Program header table entry count */ ++ b_elf_half e_shentsize; /* Section header table entry size */ ++ b_elf_half e_shnum; /* Section header table entry count */ ++ b_elf_half e_shstrndx; /* Section header string table index */ ++} b_elf_ehdr; /* Elf_Ehdr. */ ++ ++#define EI_MAG0 0 ++#define EI_MAG1 1 ++#define EI_MAG2 2 ++#define EI_MAG3 3 ++#define EI_CLASS 4 ++#define EI_DATA 5 ++#define EI_VERSION 6 ++ ++#define ELFMAG0 0x7f ++#define ELFMAG1 'E' ++#define ELFMAG2 'L' ++#define ELFMAG3 'F' ++ ++#define ELFCLASS32 1 ++#define ELFCLASS64 2 ++ ++#define ELFDATA2LSB 1 ++#define ELFDATA2MSB 2 ++ ++#define EV_CURRENT 1 ++ ++#define ET_DYN 3 ++ ++typedef struct { ++ b_elf_word sh_name; /* Section name, index in string tbl */ ++ b_elf_word sh_type; /* Type of section */ ++ b_elf_wxword sh_flags; /* Miscellaneous section attributes */ ++ b_elf_addr sh_addr; /* Section virtual addr at execution */ ++ b_elf_off sh_offset; /* Section file offset */ ++ b_elf_wxword sh_size; /* Size of section in bytes */ ++ b_elf_word sh_link; /* Index of another section */ ++ b_elf_word sh_info; /* Additional section information */ ++ b_elf_wxword sh_addralign; /* Section alignment */ ++ b_elf_wxword sh_entsize; /* Entry size if section holds table */ ++} b_elf_shdr; /* Elf_Shdr. */ ++ ++#define SHN_UNDEF 0x0000 /* Undefined section */ ++#define SHN_LORESERVE 0xFF00 /* Begin range of reserved indices */ ++#define SHN_XINDEX 0xFFFF /* Section index is held elsewhere */ ++ ++#define SHT_SYMTAB 2 ++#define SHT_STRTAB 3 ++#define SHT_DYNSYM 11 ++ ++#if BACKTRACE_ELF_SIZE == 32 ++ ++typedef struct ++{ ++ b_elf_word st_name; /* Symbol name, index in string tbl */ ++ b_elf_addr st_value; /* Symbol value */ ++ b_elf_word st_size; /* Symbol size */ ++ unsigned char st_info; /* Symbol binding and type */ ++ unsigned char st_other; /* Visibility and other data */ ++ b_elf_half st_shndx; /* Symbol section index */ ++} b_elf_sym; /* Elf_Sym. */ ++ ++#else /* BACKTRACE_ELF_SIZE != 32 */ ++ ++typedef struct ++{ ++ b_elf_word st_name; /* Symbol name, index in string tbl */ ++ unsigned char st_info; /* Symbol binding and type */ ++ unsigned char st_other; /* Visibility and other data */ ++ b_elf_half st_shndx; /* Symbol section index */ ++ b_elf_addr st_value; /* Symbol value */ ++ b_elf_xword st_size; /* Symbol size */ ++} b_elf_sym; /* Elf_Sym. */ ++ ++#endif /* BACKTRACE_ELF_SIZE != 32 */ ++ ++#define STT_OBJECT 1 ++#define STT_FUNC 2 ++ ++/* An index of ELF sections we care about. */ ++ ++enum debug_section ++{ ++ DEBUG_INFO, ++ DEBUG_LINE, ++ DEBUG_ABBREV, ++ DEBUG_RANGES, ++ DEBUG_STR, ++ DEBUG_MAX ++}; ++ ++/* Names of sections, indexed by enum elf_section. */ ++ ++static const char * const debug_section_names[DEBUG_MAX] = ++{ ++ ".debug_info", ++ ".debug_line", ++ ".debug_abbrev", ++ ".debug_ranges", ++ ".debug_str" ++}; ++ ++/* Information we gather for the sections we care about. */ ++ ++struct debug_section_info ++{ ++ /* Section file offset. */ ++ off_t offset; ++ /* Section size. */ ++ size_t size; ++ /* Section contents, after read from file. */ ++ const unsigned char *data; ++}; ++ ++/* Information we keep for an ELF symbol. */ ++ ++struct elf_symbol ++{ ++ /* The name of the symbol. */ ++ const char *name; ++ /* The address of the symbol. */ ++ uintptr_t address; ++ /* The size of the symbol. */ ++ size_t size; ++}; ++ ++/* Information to pass to elf_syminfo. */ ++ ++struct elf_syminfo_data ++{ ++ /* Symbols for the next module. */ ++ struct elf_syminfo_data *next; ++ /* The ELF symbols, sorted by address. */ ++ struct elf_symbol *symbols; ++ /* The number of symbols. */ ++ size_t count; ++}; ++ ++/* A dummy callback function used when we can't find any debug info. */ ++ ++static int ++elf_nodebug (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ uintptr_t pc ATTRIBUTE_UNUSED, ++ backtrace_full_callback callback ATTRIBUTE_UNUSED, ++ backtrace_error_callback error_callback, void *data) ++{ ++ error_callback (data, "no debug info in ELF executable", -1); ++ return 0; ++} ++ ++/* A dummy callback function used when we can't find a symbol ++ table. */ ++ ++static void ++elf_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ uintptr_t addr ATTRIBUTE_UNUSED, ++ backtrace_syminfo_callback callback ATTRIBUTE_UNUSED, ++ backtrace_error_callback error_callback, void *data) ++{ ++ error_callback (data, "no symbol table in ELF executable", -1); ++} ++ ++/* Compare struct elf_symbol for qsort. */ ++ ++static int ++elf_symbol_compare (const void *v1, const void *v2) ++{ ++ const struct elf_symbol *e1 = (const struct elf_symbol *) v1; ++ const struct elf_symbol *e2 = (const struct elf_symbol *) v2; ++ ++ if (e1->address < e2->address) ++ return -1; ++ else if (e1->address > e2->address) ++ return 1; ++ else ++ return 0; ++} ++ ++/* Compare an ADDR against an elf_symbol for bsearch. We allocate one ++ extra entry in the array so that this can look safely at the next ++ entry. */ ++ ++static int ++elf_symbol_search (const void *vkey, const void *ventry) ++{ ++ const uintptr_t *key = (const uintptr_t *) vkey; ++ const struct elf_symbol *entry = (const struct elf_symbol *) ventry; ++ uintptr_t addr; ++ ++ addr = *key; ++ if (addr < entry->address) ++ return -1; ++ else if (addr >= entry->address + entry->size) ++ return 1; ++ else ++ return 0; ++} ++ ++/* Initialize the symbol table info for elf_syminfo. */ ++ ++static int ++elf_initialize_syminfo (struct backtrace_state *state, ++ uintptr_t base_address, ++ const unsigned char *symtab_data, size_t symtab_size, ++ const unsigned char *strtab, size_t strtab_size, ++ backtrace_error_callback error_callback, ++ void *data, struct elf_syminfo_data *sdata) ++{ ++ size_t sym_count; ++ const b_elf_sym *sym; ++ size_t elf_symbol_count; ++ size_t elf_symbol_size; ++ struct elf_symbol *elf_symbols; ++ size_t i; ++ unsigned int j; ++ ++ sym_count = symtab_size / sizeof (b_elf_sym); ++ ++ /* We only care about function symbols. Count them. */ ++ sym = (const b_elf_sym *) symtab_data; ++ elf_symbol_count = 0; ++ for (i = 0; i < sym_count; ++i, ++sym) ++ { ++ int info; ++ ++ info = sym->st_info & 0xf; ++ if ((info == STT_FUNC || info == STT_OBJECT) ++ && sym->st_shndx != SHN_UNDEF) ++ ++elf_symbol_count; ++ } ++ ++ elf_symbol_size = elf_symbol_count * sizeof (struct elf_symbol); ++ elf_symbols = ((struct elf_symbol *) ++ backtrace_alloc (state, elf_symbol_size, error_callback, ++ data)); ++ if (elf_symbols == NULL) ++ return 0; ++ ++ sym = (const b_elf_sym *) symtab_data; ++ j = 0; ++ for (i = 0; i < sym_count; ++i, ++sym) ++ { ++ int info; ++ ++ info = sym->st_info & 0xf; ++ if (info != STT_FUNC && info != STT_OBJECT) ++ continue; ++ if (sym->st_shndx == SHN_UNDEF) ++ continue; ++ if (sym->st_name >= strtab_size) ++ { ++ error_callback (data, "symbol string index out of range", 0); ++ backtrace_free (state, elf_symbols, elf_symbol_size, error_callback, ++ data); ++ return 0; ++ } ++ elf_symbols[j].name = (const char *) strtab + sym->st_name; ++ elf_symbols[j].address = sym->st_value + base_address; ++ elf_symbols[j].size = sym->st_size; ++ ++j; ++ } ++ ++ backtrace_qsort (elf_symbols, elf_symbol_count, sizeof (struct elf_symbol), ++ elf_symbol_compare); ++ ++ sdata->next = NULL; ++ sdata->symbols = elf_symbols; ++ sdata->count = elf_symbol_count; ++ ++ return 1; ++} ++ ++/* Add EDATA to the list in STATE. */ ++ ++static void ++elf_add_syminfo_data (struct backtrace_state *state, ++ struct elf_syminfo_data *edata) ++{ ++ if (!state->threaded) ++ { ++ struct elf_syminfo_data **pp; ++ ++ for (pp = (struct elf_syminfo_data **) (void *) &state->syminfo_data; ++ *pp != NULL; ++ pp = &(*pp)->next) ++ ; ++ *pp = edata; ++ } ++ else ++ { ++ while (1) ++ { ++ struct elf_syminfo_data **pp; ++ ++ pp = (struct elf_syminfo_data **) (void *) &state->syminfo_data; ++ ++ while (1) ++ { ++ struct elf_syminfo_data *p; ++ ++ p = backtrace_atomic_load_pointer (pp); ++ ++ if (p == NULL) ++ break; ++ ++ pp = &p->next; ++ } ++ ++ if (__sync_bool_compare_and_swap (pp, NULL, edata)) ++ break; ++ } ++ } ++} ++ ++/* Return the symbol name and value for an ADDR. */ ++ ++static void ++elf_syminfo (struct backtrace_state *state, uintptr_t addr, ++ backtrace_syminfo_callback callback, ++ backtrace_error_callback error_callback ATTRIBUTE_UNUSED, ++ void *data) ++{ ++ struct elf_syminfo_data *edata; ++ struct elf_symbol *sym = NULL; ++ ++ if (!state->threaded) ++ { ++ for (edata = (struct elf_syminfo_data *) state->syminfo_data; ++ edata != NULL; ++ edata = edata->next) ++ { ++ sym = ((struct elf_symbol *) ++ bsearch (&addr, edata->symbols, edata->count, ++ sizeof (struct elf_symbol), elf_symbol_search)); ++ if (sym != NULL) ++ break; ++ } ++ } ++ else ++ { ++ struct elf_syminfo_data **pp; ++ ++ pp = (struct elf_syminfo_data **) (void *) &state->syminfo_data; ++ while (1) ++ { ++ edata = backtrace_atomic_load_pointer (pp); ++ if (edata == NULL) ++ break; ++ ++ sym = ((struct elf_symbol *) ++ bsearch (&addr, edata->symbols, edata->count, ++ sizeof (struct elf_symbol), elf_symbol_search)); ++ if (sym != NULL) ++ break; ++ ++ pp = &edata->next; ++ } ++ } ++ ++ if (sym == NULL) ++ callback (data, addr, NULL, 0, 0); ++ else ++ callback (data, addr, sym->name, sym->address, sym->size); ++} ++ ++/* Add the backtrace data for one ELF file. Returns 1 on success, ++ 0 on failure (in both cases descriptor is closed) or -1 if exe ++ is non-zero and the ELF file is ET_DYN, which tells the caller that ++ elf_add will need to be called on the descriptor again after ++ base_address is determined. */ ++ ++static int ++elf_add (struct backtrace_state *state, int descriptor, uintptr_t base_address, ++ backtrace_error_callback error_callback, void *data, ++ fileline *fileline_fn, int *found_sym, int *found_dwarf, int exe) ++{ ++ struct backtrace_view ehdr_view; ++ b_elf_ehdr ehdr; ++ off_t shoff; ++ unsigned int shnum; ++ unsigned int shstrndx; ++ struct backtrace_view shdrs_view; ++ int shdrs_view_valid; ++ const b_elf_shdr *shdrs; ++ const b_elf_shdr *shstrhdr; ++ size_t shstr_size; ++ off_t shstr_off; ++ struct backtrace_view names_view; ++ int names_view_valid; ++ const char *names; ++ unsigned int symtab_shndx; ++ unsigned int dynsym_shndx; ++ unsigned int i; ++ struct debug_section_info sections[DEBUG_MAX]; ++ struct backtrace_view symtab_view; ++ int symtab_view_valid; ++ struct backtrace_view strtab_view; ++ int strtab_view_valid; ++ off_t min_offset; ++ off_t max_offset; ++ struct backtrace_view debug_view; ++ int debug_view_valid; ++ ++ *found_sym = 0; ++ *found_dwarf = 0; ++ ++ shdrs_view_valid = 0; ++ names_view_valid = 0; ++ symtab_view_valid = 0; ++ strtab_view_valid = 0; ++ debug_view_valid = 0; ++ ++ if (!backtrace_get_view (state, descriptor, 0, sizeof ehdr, error_callback, ++ data, &ehdr_view)) ++ goto fail; ++ ++ memcpy (&ehdr, ehdr_view.data, sizeof ehdr); ++ ++ backtrace_release_view (state, &ehdr_view, error_callback, data); ++ ++ if (ehdr.e_ident[EI_MAG0] != ELFMAG0 ++ || ehdr.e_ident[EI_MAG1] != ELFMAG1 ++ || ehdr.e_ident[EI_MAG2] != ELFMAG2 ++ || ehdr.e_ident[EI_MAG3] != ELFMAG3) ++ { ++ error_callback (data, "executable file is not ELF", 0); ++ goto fail; ++ } ++ if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) ++ { ++ error_callback (data, "executable file is unrecognized ELF version", 0); ++ goto fail; ++ } ++ ++#if BACKTRACE_ELF_SIZE == 32 ++#define BACKTRACE_ELFCLASS ELFCLASS32 ++#else ++#define BACKTRACE_ELFCLASS ELFCLASS64 ++#endif ++ ++ if (ehdr.e_ident[EI_CLASS] != BACKTRACE_ELFCLASS) ++ { ++ error_callback (data, "executable file is unexpected ELF class", 0); ++ goto fail; ++ } ++ ++ if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB ++ && ehdr.e_ident[EI_DATA] != ELFDATA2MSB) ++ { ++ error_callback (data, "executable file has unknown endianness", 0); ++ goto fail; ++ } ++ ++ /* If the executable is ET_DYN, it is either a PIE, or we are running ++ directly a shared library with .interp. We need to wait for ++ dl_iterate_phdr in that case to determine the actual base_address. */ ++ if (exe && ehdr.e_type == ET_DYN) ++ return -1; ++ ++ shoff = ehdr.e_shoff; ++ shnum = ehdr.e_shnum; ++ shstrndx = ehdr.e_shstrndx; ++ ++ if ((shnum == 0 || shstrndx == SHN_XINDEX) ++ && shoff != 0) ++ { ++ struct backtrace_view shdr_view; ++ const b_elf_shdr *shdr; ++ ++ if (!backtrace_get_view (state, descriptor, shoff, sizeof shdr, ++ error_callback, data, &shdr_view)) ++ goto fail; ++ ++ shdr = (const b_elf_shdr *) shdr_view.data; ++ ++ if (shnum == 0) ++ shnum = shdr->sh_size; ++ ++ if (shstrndx == SHN_XINDEX) ++ { ++ shstrndx = shdr->sh_link; ++ ++ /* Versions of the GNU binutils between 2.12 and 2.18 did ++ not handle objects with more than SHN_LORESERVE sections ++ correctly. All large section indexes were offset by ++ 0x100. There is more information at ++ http://sourceware.org/bugzilla/show_bug.cgi?id-5900 . ++ Fortunately these object files are easy to detect, as the ++ GNU binutils always put the section header string table ++ near the end of the list of sections. Thus if the ++ section header string table index is larger than the ++ number of sections, then we know we have to subtract ++ 0x100 to get the real section index. */ ++ if (shstrndx >= shnum && shstrndx >= SHN_LORESERVE + 0x100) ++ shstrndx -= 0x100; ++ } ++ ++ backtrace_release_view (state, &shdr_view, error_callback, data); ++ } ++ ++ /* To translate PC to file/line when using DWARF, we need to find ++ the .debug_info and .debug_line sections. */ ++ ++ /* Read the section headers, skipping the first one. */ ++ ++ if (!backtrace_get_view (state, descriptor, shoff + sizeof (b_elf_shdr), ++ (shnum - 1) * sizeof (b_elf_shdr), ++ error_callback, data, &shdrs_view)) ++ goto fail; ++ shdrs_view_valid = 1; ++ shdrs = (const b_elf_shdr *) shdrs_view.data; ++ ++ /* Read the section names. */ ++ ++ shstrhdr = &shdrs[shstrndx - 1]; ++ shstr_size = shstrhdr->sh_size; ++ shstr_off = shstrhdr->sh_offset; ++ ++ if (!backtrace_get_view (state, descriptor, shstr_off, shstr_size, ++ error_callback, data, &names_view)) ++ goto fail; ++ names_view_valid = 1; ++ names = (const char *) names_view.data; ++ ++ symtab_shndx = 0; ++ dynsym_shndx = 0; ++ ++ memset (sections, 0, sizeof sections); ++ ++ /* Look for the symbol table. */ ++ for (i = 1; i < shnum; ++i) ++ { ++ const b_elf_shdr *shdr; ++ unsigned int sh_name; ++ const char *name; ++ int j; ++ ++ shdr = &shdrs[i - 1]; ++ ++ if (shdr->sh_type == SHT_SYMTAB) ++ symtab_shndx = i; ++ else if (shdr->sh_type == SHT_DYNSYM) ++ dynsym_shndx = i; ++ ++ sh_name = shdr->sh_name; ++ if (sh_name >= shstr_size) ++ { ++ error_callback (data, "ELF section name out of range", 0); ++ goto fail; ++ } ++ ++ name = names + sh_name; ++ ++ for (j = 0; j < (int) DEBUG_MAX; ++j) ++ { ++ if (strcmp (name, debug_section_names[j]) == 0) ++ { ++ sections[j].offset = shdr->sh_offset; ++ sections[j].size = shdr->sh_size; ++ break; ++ } ++ } ++ } ++ ++ if (symtab_shndx == 0) ++ symtab_shndx = dynsym_shndx; ++ if (symtab_shndx != 0) ++ { ++ const b_elf_shdr *symtab_shdr; ++ unsigned int strtab_shndx; ++ const b_elf_shdr *strtab_shdr; ++ struct elf_syminfo_data *sdata; ++ ++ symtab_shdr = &shdrs[symtab_shndx - 1]; ++ strtab_shndx = symtab_shdr->sh_link; ++ if (strtab_shndx >= shnum) ++ { ++ error_callback (data, ++ "ELF symbol table strtab link out of range", 0); ++ goto fail; ++ } ++ strtab_shdr = &shdrs[strtab_shndx - 1]; ++ ++ if (!backtrace_get_view (state, descriptor, symtab_shdr->sh_offset, ++ symtab_shdr->sh_size, error_callback, data, ++ &symtab_view)) ++ goto fail; ++ symtab_view_valid = 1; ++ ++ if (!backtrace_get_view (state, descriptor, strtab_shdr->sh_offset, ++ strtab_shdr->sh_size, error_callback, data, ++ &strtab_view)) ++ goto fail; ++ strtab_view_valid = 1; ++ ++ sdata = ((struct elf_syminfo_data *) ++ backtrace_alloc (state, sizeof *sdata, error_callback, data)); ++ if (sdata == NULL) ++ goto fail; ++ ++ if (!elf_initialize_syminfo (state, base_address, ++ symtab_view.data, symtab_shdr->sh_size, ++ strtab_view.data, strtab_shdr->sh_size, ++ error_callback, data, sdata)) ++ { ++ backtrace_free (state, sdata, sizeof *sdata, error_callback, data); ++ goto fail; ++ } ++ ++ /* We no longer need the symbol table, but we hold on to the ++ string table permanently. */ ++ backtrace_release_view (state, &symtab_view, error_callback, data); ++ ++ *found_sym = 1; ++ ++ elf_add_syminfo_data (state, sdata); ++ } ++ ++ /* FIXME: Need to handle compressed debug sections. */ ++ ++ backtrace_release_view (state, &shdrs_view, error_callback, data); ++ shdrs_view_valid = 0; ++ backtrace_release_view (state, &names_view, error_callback, data); ++ names_view_valid = 0; ++ ++ /* Read all the debug sections in a single view, since they are ++ probably adjacent in the file. We never release this view. */ ++ ++ min_offset = 0; ++ max_offset = 0; ++ for (i = 0; i < (int) DEBUG_MAX; ++i) ++ { ++ off_t end; ++ ++ if (sections[i].size == 0) ++ continue; ++ if (min_offset == 0 || sections[i].offset < min_offset) ++ min_offset = sections[i].offset; ++ end = sections[i].offset + sections[i].size; ++ if (end > max_offset) ++ max_offset = end; ++ } ++ if (min_offset == 0 || max_offset == 0) ++ { ++ if (!backtrace_close (descriptor, error_callback, data)) ++ goto fail; ++ return 1; ++ } ++ ++ if (!backtrace_get_view (state, descriptor, min_offset, ++ max_offset - min_offset, ++ error_callback, data, &debug_view)) ++ goto fail; ++ debug_view_valid = 1; ++ ++ /* We've read all we need from the executable. */ ++ if (!backtrace_close (descriptor, error_callback, data)) ++ goto fail; ++ descriptor = -1; ++ ++ for (i = 0; i < (int) DEBUG_MAX; ++i) ++ { ++ if (sections[i].size == 0) ++ sections[i].data = NULL; ++ else ++ sections[i].data = ((const unsigned char *) debug_view.data ++ + (sections[i].offset - min_offset)); ++ } ++ ++ if (!backtrace_dwarf_add (state, base_address, ++ sections[DEBUG_INFO].data, ++ sections[DEBUG_INFO].size, ++ sections[DEBUG_LINE].data, ++ sections[DEBUG_LINE].size, ++ sections[DEBUG_ABBREV].data, ++ sections[DEBUG_ABBREV].size, ++ sections[DEBUG_RANGES].data, ++ sections[DEBUG_RANGES].size, ++ sections[DEBUG_STR].data, ++ sections[DEBUG_STR].size, ++ ehdr.e_ident[EI_DATA] == ELFDATA2MSB, ++ error_callback, data, fileline_fn)) ++ goto fail; ++ ++ *found_dwarf = 1; ++ ++ return 1; ++ ++ fail: ++ if (shdrs_view_valid) ++ backtrace_release_view (state, &shdrs_view, error_callback, data); ++ if (names_view_valid) ++ backtrace_release_view (state, &names_view, error_callback, data); ++ if (symtab_view_valid) ++ backtrace_release_view (state, &symtab_view, error_callback, data); ++ if (strtab_view_valid) ++ backtrace_release_view (state, &strtab_view, error_callback, data); ++ if (debug_view_valid) ++ backtrace_release_view (state, &debug_view, error_callback, data); ++ if (descriptor != -1) ++ backtrace_close (descriptor, error_callback, data); ++ return 0; ++} ++ ++/* Data passed to phdr_callback. */ ++ ++struct phdr_data ++{ ++ struct backtrace_state *state; ++ backtrace_error_callback error_callback; ++ void *data; ++ fileline *fileline_fn; ++ int *found_sym; ++ int *found_dwarf; ++ int exe_descriptor; ++}; ++ ++/* Callback passed to dl_iterate_phdr. Load debug info from shared ++ libraries. */ ++ ++static int ++#ifdef __i386__ ++__attribute__ ((__force_align_arg_pointer__)) ++#endif ++phdr_callback (struct dl_phdr_info *info, size_t size ATTRIBUTE_UNUSED, ++ void *pdata) ++{ ++ struct phdr_data *pd = (struct phdr_data *) pdata; ++ int descriptor; ++ int does_not_exist; ++ fileline elf_fileline_fn; ++ int found_dwarf; ++ ++ /* There is not much we can do if we don't have the module name, ++ unless executable is ET_DYN, where we expect the very first ++ phdr_callback to be for the PIE. */ ++ if (info->dlpi_name == NULL || info->dlpi_name[0] == '\0') ++ { ++ if (pd->exe_descriptor == -1) ++ return 0; ++ descriptor = pd->exe_descriptor; ++ pd->exe_descriptor = -1; ++ } ++ else ++ { ++ if (pd->exe_descriptor != -1) ++ { ++ backtrace_close (pd->exe_descriptor, pd->error_callback, pd->data); ++ pd->exe_descriptor = -1; ++ } ++ ++ descriptor = backtrace_open (info->dlpi_name, pd->error_callback, ++ pd->data, &does_not_exist); ++ if (descriptor < 0) ++ return 0; ++ } ++ ++ if (elf_add (pd->state, descriptor, info->dlpi_addr, pd->error_callback, ++ pd->data, &elf_fileline_fn, pd->found_sym, &found_dwarf, 0)) ++ { ++ if (found_dwarf) ++ { ++ *pd->found_dwarf = 1; ++ *pd->fileline_fn = elf_fileline_fn; ++ } ++ } ++ ++ return 0; ++} ++ ++/* Initialize the backtrace data we need from an ELF executable. At ++ the ELF level, all we need to do is find the debug info ++ sections. */ ++ ++int ++backtrace_initialize (struct backtrace_state *state, int descriptor, ++ backtrace_error_callback error_callback, ++ void *data, fileline *fileline_fn) ++{ ++ int ret; ++ int found_sym; ++ int found_dwarf; ++ fileline elf_fileline_fn = elf_nodebug; ++ struct phdr_data pd; ++ ++ ret = elf_add (state, descriptor, 0, error_callback, data, &elf_fileline_fn, ++ &found_sym, &found_dwarf, 1); ++ if (!ret) ++ return 0; ++ ++ pd.state = state; ++ pd.error_callback = error_callback; ++ pd.data = data; ++ pd.fileline_fn = &elf_fileline_fn; ++ pd.found_sym = &found_sym; ++ pd.found_dwarf = &found_dwarf; ++ pd.exe_descriptor = ret < 0 ? descriptor : -1; ++ ++ dl_iterate_phdr (phdr_callback, (void *) &pd); ++ ++ if (!state->threaded) ++ { ++ if (found_sym) ++ state->syminfo_fn = elf_syminfo; ++ else if (state->syminfo_fn == NULL) ++ state->syminfo_fn = elf_nosyms; ++ } ++ else ++ { ++ if (found_sym) ++ backtrace_atomic_store_pointer (&state->syminfo_fn, elf_syminfo); ++ else ++ (void) __sync_bool_compare_and_swap (&state->syminfo_fn, NULL, ++ elf_nosyms); ++ } ++ ++ if (!state->threaded) ++ { ++ if (state->fileline_fn == NULL || state->fileline_fn == elf_nodebug) ++ *fileline_fn = elf_fileline_fn; ++ } ++ else ++ { ++ fileline current_fn; ++ ++ current_fn = backtrace_atomic_load_pointer (&state->fileline_fn); ++ if (current_fn == NULL || current_fn == elf_nodebug) ++ *fileline_fn = elf_fileline_fn; ++ } ++ ++ return 1; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/fileline.c index 000000000,000000000..503bbc6bc new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/fileline.c @@@ -1,0 -1,0 +1,194 @@@ ++/* fileline.c -- Get file and line number information in a backtrace. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++#ifndef HAVE_GETEXECNAME ++#define getexecname() NULL ++#endif ++ ++/* Initialize the fileline information from the executable. Returns 1 ++ on success, 0 on failure. */ ++ ++static int ++fileline_initialize (struct backtrace_state *state, ++ backtrace_error_callback error_callback, void *data) ++{ ++ int failed; ++ fileline fileline_fn; ++ int pass; ++ int called_error_callback; ++ int descriptor; ++ ++ if (!state->threaded) ++ failed = state->fileline_initialization_failed; ++ else ++ failed = backtrace_atomic_load_int (&state->fileline_initialization_failed); ++ ++ if (failed) ++ { ++ error_callback (data, "failed to read executable information", -1); ++ return 0; ++ } ++ ++ if (!state->threaded) ++ fileline_fn = state->fileline_fn; ++ else ++ fileline_fn = backtrace_atomic_load_pointer (&state->fileline_fn); ++ if (fileline_fn != NULL) ++ return 1; ++ ++ /* We have not initialized the information. Do it now. */ ++ ++ descriptor = -1; ++ called_error_callback = 0; ++ for (pass = 0; pass < 4; ++pass) ++ { ++ const char *filename; ++ int does_not_exist; ++ ++ switch (pass) ++ { ++ case 0: ++ filename = state->filename; ++ break; ++ case 1: ++ filename = getexecname (); ++ break; ++ case 2: ++ filename = "/proc/self/exe"; ++ break; ++ case 3: ++ filename = "/proc/curproc/file"; ++ break; ++ default: ++ abort (); ++ } ++ ++ if (filename == NULL) ++ continue; ++ ++ descriptor = backtrace_open (filename, error_callback, data, ++ &does_not_exist); ++ if (descriptor < 0 && !does_not_exist) ++ { ++ called_error_callback = 1; ++ break; ++ } ++ if (descriptor >= 0) ++ break; ++ } ++ ++ if (descriptor < 0) ++ { ++ if (!called_error_callback) ++ { ++ if (state->filename != NULL) ++ error_callback (data, state->filename, ENOENT); ++ else ++ error_callback (data, ++ "libbacktrace could not find executable to open", ++ 0); ++ } ++ failed = 1; ++ } ++ ++ if (!failed) ++ { ++ if (!backtrace_initialize (state, descriptor, error_callback, data, ++ &fileline_fn)) ++ failed = 1; ++ } ++ ++ if (failed) ++ { ++ if (!state->threaded) ++ state->fileline_initialization_failed = 1; ++ else ++ backtrace_atomic_store_int (&state->fileline_initialization_failed, 1); ++ return 0; ++ } ++ ++ if (!state->threaded) ++ state->fileline_fn = fileline_fn; ++ else ++ { ++ backtrace_atomic_store_pointer (&state->fileline_fn, fileline_fn); ++ ++ /* Note that if two threads initialize at once, one of the data ++ sets may be leaked. */ ++ } ++ ++ return 1; ++} ++ ++/* Given a PC, find the file name, line number, and function name. */ ++ ++int ++backtrace_pcinfo (struct backtrace_state *state, uintptr_t pc, ++ backtrace_full_callback callback, ++ backtrace_error_callback error_callback, void *data) ++{ ++ if (!fileline_initialize (state, error_callback, data)) ++ return 0; ++ ++ if (state->fileline_initialization_failed) ++ return 0; ++ ++ return state->fileline_fn (state, pc, callback, error_callback, data); ++} ++ ++/* Given a PC, find the symbol for it, and its value. */ ++ ++int ++backtrace_syminfo (struct backtrace_state *state, uintptr_t pc, ++ backtrace_syminfo_callback callback, ++ backtrace_error_callback error_callback, void *data) ++{ ++ if (!fileline_initialize (state, error_callback, data)) ++ return 0; ++ ++ if (state->fileline_initialization_failed) ++ return 0; ++ ++ state->syminfo_fn (state, pc, callback, error_callback, data); ++ return 1; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/filenames.h index 000000000,000000000..1161daaa4 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/filenames.h @@@ -1,0 -1,0 +1,99 @@@ ++/* Macros for taking apart, interpreting and processing file names. ++ ++ These are here because some non-Posix (a.k.a. DOSish) systems have ++ drive letter brain-damage at the beginning of an absolute file name, ++ use forward- and back-slash in path names interchangeably, and ++ some of them have case-insensitive file names. ++ ++ Copyright (C) 2000-2015 Free Software Foundation, Inc. ++ ++This file is part of BFD, the Binary File Descriptor library. ++ ++This program is free software; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation; either version 2 of the License, or ++(at your option) any later version. ++ ++This program is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++You should have received a copy of the GNU General Public License ++along with this program; if not, write to the Free Software ++Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ ++ ++#ifndef FILENAMES_H ++#define FILENAMES_H ++ ++#include "hashtab.h" /* for hashval_t */ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__) ++# ifndef HAVE_DOS_BASED_FILE_SYSTEM ++# define HAVE_DOS_BASED_FILE_SYSTEM 1 ++# endif ++# ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM ++# define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1 ++# endif ++# define HAS_DRIVE_SPEC(f) HAS_DOS_DRIVE_SPEC (f) ++# define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c) ++# define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f) ++#else /* not DOSish */ ++# if defined(__APPLE__) ++# ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM ++# define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1 ++# endif ++# endif /* __APPLE__ */ ++# define HAS_DRIVE_SPEC(f) (0) ++# define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c) ++# define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f) ++#endif ++ ++#define IS_DIR_SEPARATOR_1(dos_based, c) \ ++ (((c) == '/') \ ++ || (((c) == '\\') && (dos_based))) ++ ++#define HAS_DRIVE_SPEC_1(dos_based, f) \ ++ ((f)[0] && ((f)[1] == ':') && (dos_based)) ++ ++/* Remove the drive spec from F, assuming HAS_DRIVE_SPEC (f). ++ The result is a pointer to the remainder of F. */ ++#define STRIP_DRIVE_SPEC(f) ((f) + 2) ++ ++#define IS_DOS_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (1, c) ++#define IS_DOS_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (1, f) ++#define HAS_DOS_DRIVE_SPEC(f) HAS_DRIVE_SPEC_1 (1, f) ++ ++#define IS_UNIX_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (0, c) ++#define IS_UNIX_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (0, f) ++ ++/* Note that when DOS_BASED is true, IS_ABSOLUTE_PATH accepts d:foo as ++ well, although it is only semi-absolute. This is because the users ++ of IS_ABSOLUTE_PATH want to know whether to prepend the current ++ working directory to a file name, which should not be done with a ++ name like d:foo. */ ++#define IS_ABSOLUTE_PATH_1(dos_based, f) \ ++ (IS_DIR_SEPARATOR_1 (dos_based, (f)[0]) \ ++ || HAS_DRIVE_SPEC_1 (dos_based, f)) ++ ++extern int filename_cmp (const char *s1, const char *s2); ++#define FILENAME_CMP(s1, s2) filename_cmp(s1, s2) ++ ++extern int filename_ncmp (const char *s1, const char *s2, ++ size_t n); ++ ++extern hashval_t filename_hash (const void *s); ++ ++extern int filename_eq (const void *s1, const void *s2); ++ ++extern int canonical_filename_eq (const char *a, const char *b); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* FILENAMES_H */ diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/filetype.awk index 000000000,000000000..57bab797a new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/filetype.awk @@@ -1,0 -1,0 +1,5 @@@ ++# An awk script to determine the type of a file. ++/\177ELF\001/ { if (NR == 1) { print "elf32"; exit } } ++/\177ELF\002/ { if (NR == 1) { print "elf64"; exit } } ++/\114\001/ { if (NR == 1) { print "pecoff"; exit } } ++/\144\206/ { if (NR == 1) { print "pecoff"; exit } } diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/hashtab.h index 000000000,000000000..b1b5877aa new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/hashtab.h @@@ -1,0 -1,0 +1,204 @@@ ++/* An expandable hash tables datatype. ++ Copyright (C) 1999-2015 Free Software Foundation, Inc. ++ Contributed by Vladimir Makarov (vmakarov@cygnus.com). ++ ++This program is free software; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation; either version 2 of the License, or ++(at your option) any later version. ++ ++This program is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++You should have received a copy of the GNU General Public License ++along with this program; if not, write to the Free Software ++Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ ++ ++/* This package implements basic hash table functionality. It is possible ++ to search for an entry, create an entry and destroy an entry. ++ ++ Elements in the table are generic pointers. ++ ++ The size of the table is not fixed; if the occupancy of the table ++ grows too high the hash table will be expanded. ++ ++ The abstract data implementation is based on generalized Algorithm D ++ from Knuth's book "The art of computer programming". Hash table is ++ expanded by creation of new hash table and transferring elements from ++ the old table to the new table. */ ++ ++#ifndef __HASHTAB_H__ ++#define __HASHTAB_H__ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif /* __cplusplus */ ++ ++#include "ansidecl.h" ++ ++/* The type for a hash code. */ ++typedef unsigned int hashval_t; ++ ++/* Callback function pointer types. */ ++ ++/* Calculate hash of a table entry. */ ++typedef hashval_t (*htab_hash) (const void *); ++ ++/* Compare a table entry with a possible entry. The entry already in ++ the table always comes first, so the second element can be of a ++ different type (but in this case htab_find and htab_find_slot ++ cannot be used; instead the variants that accept a hash value ++ must be used). */ ++typedef int (*htab_eq) (const void *, const void *); ++ ++/* Cleanup function called whenever a live element is removed from ++ the hash table. */ ++typedef void (*htab_del) (void *); ++ ++/* Function called by htab_traverse for each live element. The first ++ arg is the slot of the element (which can be passed to htab_clear_slot ++ if desired), the second arg is the auxiliary pointer handed to ++ htab_traverse. Return 1 to continue scan, 0 to stop. */ ++typedef int (*htab_trav) (void **, void *); ++ ++/* Memory-allocation function, with the same functionality as calloc(). ++ Iff it returns NULL, the hash table implementation will pass an error ++ code back to the user, so if your code doesn't handle errors, ++ best if you use xcalloc instead. */ ++typedef void *(*htab_alloc) (size_t, size_t); ++ ++/* We also need a free() routine. */ ++typedef void (*htab_free) (void *); ++ ++/* Memory allocation and deallocation; variants which take an extra ++ argument. */ ++typedef void *(*htab_alloc_with_arg) (void *, size_t, size_t); ++typedef void (*htab_free_with_arg) (void *, void *); ++ ++/* This macro defines reserved value for empty table entry. */ ++ ++#define HTAB_EMPTY_ENTRY ((PTR) 0) ++ ++/* This macro defines reserved value for table entry which contained ++ a deleted element. */ ++ ++#define HTAB_DELETED_ENTRY ((PTR) 1) ++ ++/* Hash tables are of the following type. The structure ++ (implementation) of this type is not needed for using the hash ++ tables. All work with hash table should be executed only through ++ functions mentioned below. The size of this structure is subject to ++ change. */ ++ ++struct htab { ++ /* Pointer to hash function. */ ++ htab_hash hash_f; ++ ++ /* Pointer to comparison function. */ ++ htab_eq eq_f; ++ ++ /* Pointer to cleanup function. */ ++ htab_del del_f; ++ ++ /* Table itself. */ ++ void **entries; ++ ++ /* Current size (in entries) of the hash table. */ ++ size_t size; ++ ++ /* Current number of elements including also deleted elements. */ ++ size_t n_elements; ++ ++ /* Current number of deleted elements in the table. */ ++ size_t n_deleted; ++ ++ /* The following member is used for debugging. Its value is number ++ of all calls of `htab_find_slot' for the hash table. */ ++ unsigned int searches; ++ ++ /* The following member is used for debugging. Its value is number ++ of collisions fixed for time of work with the hash table. */ ++ unsigned int collisions; ++ ++ /* Pointers to allocate/free functions. */ ++ htab_alloc alloc_f; ++ htab_free free_f; ++ ++ /* Alternate allocate/free functions, which take an extra argument. */ ++ void *alloc_arg; ++ htab_alloc_with_arg alloc_with_arg_f; ++ htab_free_with_arg free_with_arg_f; ++ ++ /* Current size (in entries) of the hash table, as an index into the ++ table of primes. */ ++ unsigned int size_prime_index; ++}; ++ ++typedef struct htab *htab_t; ++ ++/* An enum saying whether we insert into the hash table or not. */ ++enum insert_option {NO_INSERT, INSERT}; ++ ++/* The prototypes of the package functions. */ ++ ++extern htab_t htab_create_alloc (size_t, htab_hash, ++ htab_eq, htab_del, ++ htab_alloc, htab_free); ++ ++extern htab_t htab_create_alloc_ex (size_t, htab_hash, ++ htab_eq, htab_del, ++ void *, htab_alloc_with_arg, ++ htab_free_with_arg); ++ ++extern htab_t htab_create_typed_alloc (size_t, htab_hash, htab_eq, htab_del, ++ htab_alloc, htab_alloc, htab_free); ++ ++/* Backward-compatibility functions. */ ++extern htab_t htab_create (size_t, htab_hash, htab_eq, htab_del); ++extern htab_t htab_try_create (size_t, htab_hash, htab_eq, htab_del); ++ ++extern void htab_set_functions_ex (htab_t, htab_hash, ++ htab_eq, htab_del, ++ void *, htab_alloc_with_arg, ++ htab_free_with_arg); ++ ++extern void htab_delete (htab_t); ++extern void htab_empty (htab_t); ++ ++extern void * htab_find (htab_t, const void *); ++extern void ** htab_find_slot (htab_t, const void *, enum insert_option); ++extern void * htab_find_with_hash (htab_t, const void *, hashval_t); ++extern void ** htab_find_slot_with_hash (htab_t, const void *, ++ hashval_t, enum insert_option); ++extern void htab_clear_slot (htab_t, void **); ++extern void htab_remove_elt (htab_t, void *); ++extern void htab_remove_elt_with_hash (htab_t, void *, hashval_t); ++ ++extern void htab_traverse (htab_t, htab_trav, void *); ++extern void htab_traverse_noresize (htab_t, htab_trav, void *); ++ ++extern size_t htab_size (htab_t); ++extern size_t htab_elements (htab_t); ++extern double htab_collisions (htab_t); ++ ++/* A hash function for pointers. */ ++extern htab_hash htab_hash_pointer; ++ ++/* An equality function for pointers. */ ++extern htab_eq htab_eq_pointer; ++ ++/* A hash function for null-terminated strings. */ ++extern hashval_t htab_hash_string (const void *); ++ ++/* An iterative hash function for arbitrary data. */ ++extern hashval_t iterative_hash (const void *, size_t, hashval_t); ++/* Shorthand for hashing something with an intrinsic size. */ ++#define iterative_hash_object(OB,INIT) iterative_hash (&OB, sizeof (OB), INIT) ++ ++#ifdef __cplusplus ++} ++#endif /* __cplusplus */ ++ ++#endif /* __HASHTAB_H */ diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/install-sh index 000000000,000000000..0b0fdcbba new file mode 100755 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/install-sh @@@ -1,0 -1,0 +1,501 @@@ ++#!/bin/sh ++# install - install a program, script, or datafile ++ ++scriptversion=2013-12-25.23; # UTC ++ ++# This originates from X11R5 (mit/util/scripts/install.sh), which was ++# later released in X11R6 (xc/config/util/install.sh) with the ++# following copyright and license. ++# ++# Copyright (C) 1994 X Consortium ++# ++# 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 ++# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN ++# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- ++# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++# ++# Except as contained in this notice, the name of the X Consortium shall not ++# be used in advertising or otherwise to promote the sale, use or other deal- ++# ings in this Software without prior written authorization from the X Consor- ++# tium. ++# ++# ++# FSF changes to this file are in the public domain. ++# ++# Calling this script install-sh is preferred over install.sh, to prevent ++# 'make' implicit rules from creating a file called install from it ++# when there is no Makefile. ++# ++# This script is compatible with the BSD install script, but was written ++# from scratch. ++ ++tab=' ' ++nl=' ++' ++IFS=" $tab$nl" ++ ++# Set DOITPROG to "echo" to test this script. ++ ++doit=${DOITPROG-} ++doit_exec=${doit:-exec} ++ ++# Put in absolute file names if you don't have them in your path; ++# or use environment vars. ++ ++chgrpprog=${CHGRPPROG-chgrp} ++chmodprog=${CHMODPROG-chmod} ++chownprog=${CHOWNPROG-chown} ++cmpprog=${CMPPROG-cmp} ++cpprog=${CPPROG-cp} ++mkdirprog=${MKDIRPROG-mkdir} ++mvprog=${MVPROG-mv} ++rmprog=${RMPROG-rm} ++stripprog=${STRIPPROG-strip} ++ ++posix_mkdir= ++ ++# Desired mode of installed file. ++mode=0755 ++ ++chgrpcmd= ++chmodcmd=$chmodprog ++chowncmd= ++mvcmd=$mvprog ++rmcmd="$rmprog -f" ++stripcmd= ++ ++src= ++dst= ++dir_arg= ++dst_arg= ++ ++copy_on_change=false ++is_target_a_directory=possibly ++ ++usage="\ ++Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE ++ or: $0 [OPTION]... SRCFILES... DIRECTORY ++ or: $0 [OPTION]... -t DIRECTORY SRCFILES... ++ or: $0 [OPTION]... -d DIRECTORIES... ++ ++In the 1st form, copy SRCFILE to DSTFILE. ++In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. ++In the 4th, create DIRECTORIES. ++ ++Options: ++ --help display this help and exit. ++ --version display version info and exit. ++ ++ -c (ignored) ++ -C install only if different (preserve the last data modification time) ++ -d create directories instead of installing files. ++ -g GROUP $chgrpprog installed files to GROUP. ++ -m MODE $chmodprog installed files to MODE. ++ -o USER $chownprog installed files to USER. ++ -s $stripprog installed files. ++ -t DIRECTORY install into DIRECTORY. ++ -T report an error if DSTFILE is a directory. ++ ++Environment variables override the default commands: ++ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG ++ RMPROG STRIPPROG ++" ++ ++while test $# -ne 0; do ++ case $1 in ++ -c) ;; ++ ++ -C) copy_on_change=true;; ++ ++ -d) dir_arg=true;; ++ ++ -g) chgrpcmd="$chgrpprog $2" ++ shift;; ++ ++ --help) echo "$usage"; exit $?;; ++ ++ -m) mode=$2 ++ case $mode in ++ *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) ++ echo "$0: invalid mode: $mode" >&2 ++ exit 1;; ++ esac ++ shift;; ++ ++ -o) chowncmd="$chownprog $2" ++ shift;; ++ ++ -s) stripcmd=$stripprog;; ++ ++ -t) ++ is_target_a_directory=always ++ dst_arg=$2 ++ # Protect names problematic for 'test' and other utilities. ++ case $dst_arg in ++ -* | [=\(\)!]) dst_arg=./$dst_arg;; ++ esac ++ shift;; ++ ++ -T) is_target_a_directory=never;; ++ ++ --version) echo "$0 $scriptversion"; exit $?;; ++ ++ --) shift ++ break;; ++ ++ -*) echo "$0: invalid option: $1" >&2 ++ exit 1;; ++ ++ *) break;; ++ esac ++ shift ++done ++ ++# We allow the use of options -d and -T together, by making -d ++# take the precedence; this is for compatibility with GNU install. ++ ++if test -n "$dir_arg"; then ++ if test -n "$dst_arg"; then ++ echo "$0: target directory not allowed when installing a directory." >&2 ++ exit 1 ++ fi ++fi ++ ++if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then ++ # When -d is used, all remaining arguments are directories to create. ++ # When -t is used, the destination is already specified. ++ # Otherwise, the last argument is the destination. Remove it from $@. ++ for arg ++ do ++ if test -n "$dst_arg"; then ++ # $@ is not empty: it contains at least $arg. ++ set fnord "$@" "$dst_arg" ++ shift # fnord ++ fi ++ shift # arg ++ dst_arg=$arg ++ # Protect names problematic for 'test' and other utilities. ++ case $dst_arg in ++ -* | [=\(\)!]) dst_arg=./$dst_arg;; ++ esac ++ done ++fi ++ ++if test $# -eq 0; then ++ if test -z "$dir_arg"; then ++ echo "$0: no input file specified." >&2 ++ exit 1 ++ fi ++ # It's OK to call 'install-sh -d' without argument. ++ # This can happen when creating conditional directories. ++ exit 0 ++fi ++ ++if test -z "$dir_arg"; then ++ if test $# -gt 1 || test "$is_target_a_directory" = always; then ++ if test ! -d "$dst_arg"; then ++ echo "$0: $dst_arg: Is not a directory." >&2 ++ exit 1 ++ fi ++ fi ++fi ++ ++if test -z "$dir_arg"; then ++ do_exit='(exit $ret); exit $ret' ++ trap "ret=129; $do_exit" 1 ++ trap "ret=130; $do_exit" 2 ++ trap "ret=141; $do_exit" 13 ++ trap "ret=143; $do_exit" 15 ++ ++ # Set umask so as not to create temps with too-generous modes. ++ # However, 'strip' requires both read and write access to temps. ++ case $mode in ++ # Optimize common cases. ++ *644) cp_umask=133;; ++ *755) cp_umask=22;; ++ ++ *[0-7]) ++ if test -z "$stripcmd"; then ++ u_plus_rw= ++ else ++ u_plus_rw='% 200' ++ fi ++ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; ++ *) ++ if test -z "$stripcmd"; then ++ u_plus_rw= ++ else ++ u_plus_rw=,u+rw ++ fi ++ cp_umask=$mode$u_plus_rw;; ++ esac ++fi ++ ++for src ++do ++ # Protect names problematic for 'test' and other utilities. ++ case $src in ++ -* | [=\(\)!]) src=./$src;; ++ esac ++ ++ if test -n "$dir_arg"; then ++ dst=$src ++ dstdir=$dst ++ test -d "$dstdir" ++ dstdir_status=$? ++ else ++ ++ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command ++ # might cause directories to be created, which would be especially bad ++ # if $src (and thus $dsttmp) contains '*'. ++ if test ! -f "$src" && test ! -d "$src"; then ++ echo "$0: $src does not exist." >&2 ++ exit 1 ++ fi ++ ++ if test -z "$dst_arg"; then ++ echo "$0: no destination specified." >&2 ++ exit 1 ++ fi ++ dst=$dst_arg ++ ++ # If destination is a directory, append the input filename; won't work ++ # if double slashes aren't ignored. ++ if test -d "$dst"; then ++ if test "$is_target_a_directory" = never; then ++ echo "$0: $dst_arg: Is a directory" >&2 ++ exit 1 ++ fi ++ dstdir=$dst ++ dst=$dstdir/`basename "$src"` ++ dstdir_status=0 ++ else ++ dstdir=`dirname "$dst"` ++ test -d "$dstdir" ++ dstdir_status=$? ++ fi ++ fi ++ ++ obsolete_mkdir_used=false ++ ++ if test $dstdir_status != 0; then ++ case $posix_mkdir in ++ '') ++ # Create intermediate dirs using mode 755 as modified by the umask. ++ # This is like FreeBSD 'install' as of 1997-10-28. ++ umask=`umask` ++ case $stripcmd.$umask in ++ # Optimize common cases. ++ *[2367][2367]) mkdir_umask=$umask;; ++ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; ++ ++ *[0-7]) ++ mkdir_umask=`expr $umask + 22 \ ++ - $umask % 100 % 40 + $umask % 20 \ ++ - $umask % 10 % 4 + $umask % 2 ++ `;; ++ *) mkdir_umask=$umask,go-w;; ++ esac ++ ++ # With -d, create the new directory with the user-specified mode. ++ # Otherwise, rely on $mkdir_umask. ++ if test -n "$dir_arg"; then ++ mkdir_mode=-m$mode ++ else ++ mkdir_mode= ++ fi ++ ++ posix_mkdir=false ++ case $umask in ++ *[123567][0-7][0-7]) ++ # POSIX mkdir -p sets u+wx bits regardless of umask, which ++ # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ++ ;; ++ *) ++ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ ++ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 ++ ++ if (umask $mkdir_umask && ++ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 ++ then ++ if test -z "$dir_arg" || { ++ # Check for POSIX incompatibilities with -m. ++ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or ++ # other-writable bit of parent directory when it shouldn't. ++ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ++ ls_ld_tmpdir=`ls -ld "$tmpdir"` ++ case $ls_ld_tmpdir in ++ d????-?r-*) different_mode=700;; ++ d????-?--*) different_mode=755;; ++ *) false;; ++ esac && ++ $mkdirprog -m$different_mode -p -- "$tmpdir" && { ++ ls_ld_tmpdir_1=`ls -ld "$tmpdir"` ++ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" ++ } ++ } ++ then posix_mkdir=: ++ fi ++ rmdir "$tmpdir/d" "$tmpdir" ++ else ++ # Remove any dirs left behind by ancient mkdir implementations. ++ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null ++ fi ++ trap '' 0;; ++ esac;; ++ esac ++ ++ if ++ $posix_mkdir && ( ++ umask $mkdir_umask && ++ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ++ ) ++ then : ++ else ++ ++ # The umask is ridiculous, or mkdir does not conform to POSIX, ++ # or it failed possibly due to a race condition. Create the ++ # directory the slow way, step by step, checking for races as we go. ++ ++ case $dstdir in ++ /*) prefix='/';; ++ [-=\(\)!]*) prefix='./';; ++ *) prefix='';; ++ esac ++ ++ oIFS=$IFS ++ IFS=/ ++ set -f ++ set fnord $dstdir ++ shift ++ set +f ++ IFS=$oIFS ++ ++ prefixes= ++ ++ for d ++ do ++ test X"$d" = X && continue ++ ++ prefix=$prefix$d ++ if test -d "$prefix"; then ++ prefixes= ++ else ++ if $posix_mkdir; then ++ (umask=$mkdir_umask && ++ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break ++ # Don't fail if two instances are running concurrently. ++ test -d "$prefix" || exit 1 ++ else ++ case $prefix in ++ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; ++ *) qprefix=$prefix;; ++ esac ++ prefixes="$prefixes '$qprefix'" ++ fi ++ fi ++ prefix=$prefix/ ++ done ++ ++ if test -n "$prefixes"; then ++ # Don't fail if two instances are running concurrently. ++ (umask $mkdir_umask && ++ eval "\$doit_exec \$mkdirprog $prefixes") || ++ test -d "$dstdir" || exit 1 ++ obsolete_mkdir_used=true ++ fi ++ fi ++ fi ++ ++ if test -n "$dir_arg"; then ++ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && ++ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && ++ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || ++ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 ++ else ++ ++ # Make a couple of temp file names in the proper directory. ++ dsttmp=$dstdir/_inst.$$_ ++ rmtmp=$dstdir/_rm.$$_ ++ ++ # Trap to clean up those temp files at exit. ++ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 ++ ++ # Copy the file name to the temp name. ++ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && ++ ++ # and set any options; do chmod last to preserve setuid bits. ++ # ++ # If any of these fail, we abort the whole thing. If we want to ++ # ignore errors from any of these, just make sure not to ignore ++ # errors from the above "$doit $cpprog $src $dsttmp" command. ++ # ++ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && ++ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && ++ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && ++ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && ++ ++ # If -C, don't bother to copy if it wouldn't change the file. ++ if $copy_on_change && ++ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && ++ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && ++ set -f && ++ set X $old && old=:$2:$4:$5:$6 && ++ set X $new && new=:$2:$4:$5:$6 && ++ set +f && ++ test "$old" = "$new" && ++ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 ++ then ++ rm -f "$dsttmp" ++ else ++ # Rename the file to the real destination. ++ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || ++ ++ # The rename failed, perhaps because mv can't rename something else ++ # to itself, or perhaps because mv is so ancient that it does not ++ # support -f. ++ { ++ # Now remove or move aside any old file at destination location. ++ # We try this two ways since rm can't unlink itself on some ++ # systems and the destination file might be busy for other ++ # reasons. In this case, the final cleanup might fail but the new ++ # file should still install successfully. ++ { ++ test ! -f "$dst" || ++ $doit $rmcmd -f "$dst" 2>/dev/null || ++ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && ++ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } ++ } || ++ { echo "$0: cannot unlink or rename $dst" >&2 ++ (exit 1); exit 1 ++ } ++ } && ++ ++ # Now rename the file to the real destination. ++ $doit $mvcmd "$dsttmp" "$dst" ++ } ++ fi || exit 1 ++ ++ trap '' 0 ++ fi ++done ++ ++# Local variables: ++# eval: (add-hook 'write-file-hooks 'time-stamp) ++# time-stamp-start: "scriptversion=" ++# time-stamp-format: "%:y-%02m-%02d.%02H" ++# time-stamp-time-zone: "UTC" ++# time-stamp-end: "; # UTC" ++# End: diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/internal.h index 000000000,000000000..aab4e2a00 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/internal.h @@@ -1,0 -1,0 +1,294 @@@ ++/* internal.h -- Internal header file for stack backtrace library. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#ifndef BACKTRACE_INTERNAL_H ++#define BACKTRACE_INTERNAL_H ++ ++/* We assume that and "backtrace.h" have already been ++ included. */ ++ ++#ifndef GCC_VERSION ++# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) ++#endif ++ ++#if (GCC_VERSION < 2007) ++# define __attribute__(x) ++#endif ++ ++#ifndef ATTRIBUTE_UNUSED ++# define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) ++#endif ++ ++#ifndef ATTRIBUTE_MALLOC ++# if (GCC_VERSION >= 2096) ++# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) ++# else ++# define ATTRIBUTE_MALLOC ++# endif ++#endif ++ ++#ifndef HAVE_SYNC_FUNCTIONS ++ ++/* Define out the sync functions. These should never be called if ++ they are not available. */ ++ ++#define __sync_bool_compare_and_swap(A, B, C) (abort(), 1) ++#define __sync_lock_test_and_set(A, B) (abort(), 0) ++#define __sync_lock_release(A) abort() ++ ++#endif /* !defined (HAVE_SYNC_FUNCTIONS) */ ++ ++#ifdef HAVE_ATOMIC_FUNCTIONS ++ ++/* We have the atomic builtin functions. */ ++ ++#define backtrace_atomic_load_pointer(p) \ ++ __atomic_load_n ((p), __ATOMIC_ACQUIRE) ++#define backtrace_atomic_load_int(p) \ ++ __atomic_load_n ((p), __ATOMIC_ACQUIRE) ++#define backtrace_atomic_store_pointer(p, v) \ ++ __atomic_store_n ((p), (v), __ATOMIC_RELEASE) ++#define backtrace_atomic_store_size_t(p, v) \ ++ __atomic_store_n ((p), (v), __ATOMIC_RELEASE) ++#define backtrace_atomic_store_int(p, v) \ ++ __atomic_store_n ((p), (v), __ATOMIC_RELEASE) ++ ++#else /* !defined (HAVE_ATOMIC_FUNCTIONS) */ ++#ifdef HAVE_SYNC_FUNCTIONS ++ ++/* We have the sync functions but not the atomic functions. Define ++ the atomic ones in terms of the sync ones. */ ++ ++extern void *backtrace_atomic_load_pointer (void *); ++extern int backtrace_atomic_load_int (int *); ++extern void backtrace_atomic_store_pointer (void *, void *); ++extern void backtrace_atomic_store_size_t (size_t *, size_t); ++extern void backtrace_atomic_store_int (int *, int); ++ ++#else /* !defined (HAVE_SYNC_FUNCTIONS) */ ++ ++/* We have neither the sync nor the atomic functions. These will ++ never be called. */ ++ ++#define backtrace_atomic_load_pointer(p) (abort(), (void *) NULL) ++#define backtrace_atomic_load_int(p) (abort(), 0) ++#define backtrace_atomic_store_pointer(p, v) abort() ++#define backtrace_atomic_store_size_t(p, v) abort() ++#define backtrace_atomic_store_int(p, v) abort() ++ ++#endif /* !defined (HAVE_SYNC_FUNCTIONS) */ ++#endif /* !defined (HAVE_ATOMIC_FUNCTIONS) */ ++ ++/* The type of the function that collects file/line information. This ++ is like backtrace_pcinfo. */ ++ ++typedef int (*fileline) (struct backtrace_state *state, uintptr_t pc, ++ backtrace_full_callback callback, ++ backtrace_error_callback error_callback, void *data); ++ ++/* The type of the function that collects symbol information. This is ++ like backtrace_syminfo. */ ++ ++typedef void (*syminfo) (struct backtrace_state *state, uintptr_t pc, ++ backtrace_syminfo_callback callback, ++ backtrace_error_callback error_callback, void *data); ++ ++/* What the backtrace state pointer points to. */ ++ ++struct backtrace_state ++{ ++ /* The name of the executable. */ ++ const char *filename; ++ /* Non-zero if threaded. */ ++ int threaded; ++ /* The master lock for fileline_fn, fileline_data, syminfo_fn, ++ syminfo_data, fileline_initialization_failed and everything the ++ data pointers point to. */ ++ void *lock; ++ /* The function that returns file/line information. */ ++ fileline fileline_fn; ++ /* The data to pass to FILELINE_FN. */ ++ void *fileline_data; ++ /* The function that returns symbol information. */ ++ syminfo syminfo_fn; ++ /* The data to pass to SYMINFO_FN. */ ++ void *syminfo_data; ++ /* Whether initializing the file/line information failed. */ ++ int fileline_initialization_failed; ++ /* The lock for the freelist. */ ++ int lock_alloc; ++ /* The freelist when using mmap. */ ++ struct backtrace_freelist_struct *freelist; ++}; ++ ++/* Open a file for reading. Returns -1 on error. If DOES_NOT_EXIST ++ is not NULL, *DOES_NOT_EXIST will be set to 0 normally and set to 1 ++ if the file does not exist. If the file does not exist and ++ DOES_NOT_EXIST is not NULL, the function will return -1 and will ++ not call ERROR_CALLBACK. On other errors, or if DOES_NOT_EXIST is ++ NULL, the function will call ERROR_CALLBACK before returning. */ ++extern int backtrace_open (const char *filename, ++ backtrace_error_callback error_callback, ++ void *data, ++ int *does_not_exist); ++ ++/* A view of the contents of a file. This supports mmap when ++ available. A view will remain in memory even after backtrace_close ++ is called on the file descriptor from which the view was ++ obtained. */ ++ ++struct backtrace_view ++{ ++ /* The data that the caller requested. */ ++ const void *data; ++ /* The base of the view. */ ++ void *base; ++ /* The total length of the view. */ ++ size_t len; ++}; ++ ++/* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. Store the ++ result in *VIEW. Returns 1 on success, 0 on error. */ ++extern int backtrace_get_view (struct backtrace_state *state, int descriptor, ++ off_t offset, size_t size, ++ backtrace_error_callback error_callback, ++ void *data, struct backtrace_view *view); ++ ++/* Release a view created by backtrace_get_view. */ ++extern void backtrace_release_view (struct backtrace_state *state, ++ struct backtrace_view *view, ++ backtrace_error_callback error_callback, ++ void *data); ++ ++/* Close a file opened by backtrace_open. Returns 1 on success, 0 on ++ error. */ ++ ++extern int backtrace_close (int descriptor, ++ backtrace_error_callback error_callback, ++ void *data); ++ ++/* Sort without using memory. */ ++ ++extern void backtrace_qsort (void *base, size_t count, size_t size, ++ int (*compar) (const void *, const void *)); ++ ++/* Allocate memory. This is like malloc. If ERROR_CALLBACK is NULL, ++ this does not report an error, it just returns NULL. */ ++ ++extern void *backtrace_alloc (struct backtrace_state *state, size_t size, ++ backtrace_error_callback error_callback, ++ void *data) ATTRIBUTE_MALLOC; ++ ++/* Free memory allocated by backtrace_alloc. If ERROR_CALLBACK is ++ NULL, this does not report an error. */ ++ ++extern void backtrace_free (struct backtrace_state *state, void *mem, ++ size_t size, ++ backtrace_error_callback error_callback, ++ void *data); ++ ++/* A growable vector of some struct. This is used for more efficient ++ allocation when we don't know the final size of some group of data ++ that we want to represent as an array. */ ++ ++struct backtrace_vector ++{ ++ /* The base of the vector. */ ++ void *base; ++ /* The number of bytes in the vector. */ ++ size_t size; ++ /* The number of bytes available at the current allocation. */ ++ size_t alc; ++}; ++ ++/* Grow VEC by SIZE bytes. Return a pointer to the newly allocated ++ bytes. Note that this may move the entire vector to a new memory ++ location. Returns NULL on failure. */ ++ ++extern void *backtrace_vector_grow (struct backtrace_state *state, size_t size, ++ backtrace_error_callback error_callback, ++ void *data, ++ struct backtrace_vector *vec); ++ ++/* Finish the current allocation on VEC. Prepare to start a new ++ allocation. The finished allocation will never be freed. Returns ++ a pointer to the base of the finished entries, or NULL on ++ failure. */ ++ ++extern void* backtrace_vector_finish (struct backtrace_state *state, ++ struct backtrace_vector *vec, ++ backtrace_error_callback error_callback, ++ void *data); ++ ++/* Release any extra space allocated for VEC. This may change ++ VEC->base. Returns 1 on success, 0 on failure. */ ++ ++extern int backtrace_vector_release (struct backtrace_state *state, ++ struct backtrace_vector *vec, ++ backtrace_error_callback error_callback, ++ void *data); ++ ++/* Read initial debug data from a descriptor, and set the ++ fileline_data, syminfo_fn, and syminfo_data fields of STATE. ++ Return the fileln_fn field in *FILELN_FN--this is done this way so ++ that the synchronization code is only implemented once. This is ++ called after the descriptor has first been opened. It will close ++ the descriptor if it is no longer needed. Returns 1 on success, 0 ++ on error. There will be multiple implementations of this function, ++ for different file formats. Each system will compile the ++ appropriate one. */ ++ ++extern int backtrace_initialize (struct backtrace_state *state, ++ int descriptor, ++ backtrace_error_callback error_callback, ++ void *data, ++ fileline *fileline_fn); ++ ++/* Add file/line information for a DWARF module. */ ++ ++extern int backtrace_dwarf_add (struct backtrace_state *state, ++ uintptr_t base_address, ++ const unsigned char* dwarf_info, ++ size_t dwarf_info_size, ++ const unsigned char *dwarf_line, ++ size_t dwarf_line_size, ++ const unsigned char *dwarf_abbrev, ++ size_t dwarf_abbrev_size, ++ const unsigned char *dwarf_ranges, ++ size_t dwarf_range_size, ++ const unsigned char *dwarf_str, ++ size_t dwarf_str_size, ++ int is_bigendian, ++ backtrace_error_callback error_callback, ++ void *data, fileline *fileline_fn); ++ ++#endif diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/ltmain.sh index 000000000,000000000..9503ec85d new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/ltmain.sh @@@ -1,0 -1,0 +1,8636 @@@ ++# Generated from ltmain.m4sh. ++ ++# libtool (GNU libtool 1.3134 2009-11-29) 2.2.7a ++# Written by Gordon Matzigkeit , 1996 ++ ++# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, ++# 2007, 2008, 2009 Free Software Foundation, Inc. ++# This is free software; see the source for copying conditions. There is NO ++# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ++ ++# GNU Libtool is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# As a special exception to the GNU General Public License, ++# if you distribute this file as part of a program or library that ++# is built using GNU Libtool, you may include this file under the ++# same distribution terms that you use for the rest of that program. ++# ++# GNU Libtool is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GNU Libtool; see the file COPYING. If not, a copy ++# can be downloaded from http://www.gnu.org/licenses/gpl.html, ++# or obtained by writing to the Free Software Foundation, Inc., ++# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ ++# Usage: $progname [OPTION]... [MODE-ARG]... ++# ++# Provide generalized library-building support services. ++# ++# --config show all configuration variables ++# --debug enable verbose shell tracing ++# -n, --dry-run display commands without modifying any files ++# --features display basic configuration information and exit ++# --mode=MODE use operation mode MODE ++# --no-finish let install mode avoid finish commands ++# --preserve-dup-deps don't remove duplicate dependency libraries ++# --quiet, --silent don't print informational messages ++# --no-quiet, --no-silent ++# print informational messages (default) ++# --tag=TAG use configuration variables from tag TAG ++# -v, --verbose print more informational messages than default ++# --no-verbose don't print the extra informational messages ++# --version print version information ++# -h, --help, --help-all print short, long, or detailed help message ++# ++# MODE must be one of the following: ++# ++# clean remove files from the build directory ++# compile compile a source file into a libtool object ++# execute automatically set library path, then run a program ++# finish complete the installation of libtool libraries ++# install install libraries or executables ++# link create a library or an executable ++# uninstall remove libraries from an installed directory ++# ++# MODE-ARGS vary depending on the MODE. When passed as first option, ++# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. ++# Try `$progname --help --mode=MODE' for a more detailed description of MODE. ++# ++# When reporting a bug, please describe a test case to reproduce it and ++# include the following information: ++# ++# host-triplet: $host ++# shell: $SHELL ++# compiler: $LTCC ++# compiler flags: $LTCFLAGS ++# linker: $LD (gnu? $with_gnu_ld) ++# $progname: (GNU libtool 1.3134 2009-11-29) 2.2.7a ++# automake: $automake_version ++# autoconf: $autoconf_version ++# ++# Report bugs to . ++ ++PROGRAM=libtool ++PACKAGE=libtool ++VERSION=2.2.7a ++TIMESTAMP=" 1.3134 2009-11-29" ++package_revision=1.3134 ++ ++# Be Bourne compatible ++if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then ++ emulate sh ++ NULLCMD=: ++ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which ++ # is contrary to our usage. Disable this feature. ++ alias -g '${1+"$@"}'='"$@"' ++ setopt NO_GLOB_SUBST ++else ++ case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac ++fi ++BIN_SH=xpg4; export BIN_SH # for Tru64 ++DUALCASE=1; export DUALCASE # for MKS sh ++ ++# A function that is used when there is no print builtin or printf. ++func_fallback_echo () ++{ ++ eval 'cat <<_LTECHO_EOF ++$1 ++_LTECHO_EOF' ++} ++ ++# NLS nuisances: We save the old values to restore during execute mode. ++# Only set LANG and LC_ALL to C if already set. ++# These must not be set unconditionally because not all systems understand ++# e.g. LANG=C (notably SCO). ++lt_user_locale= ++lt_safe_locale= ++for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES ++do ++ eval "if test \"\${$lt_var+set}\" = set; then ++ save_$lt_var=\$$lt_var ++ $lt_var=C ++ export $lt_var ++ lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" ++ lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" ++ fi" ++done ++ ++$lt_unset CDPATH ++ ++ ++ ++ ++ ++ ++ ++# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh ++# is ksh but when the shell is invoked as "sh" and the current value of ++# the _XPG environment variable is not equal to 1 (one), the special ++# positional parameter $0, within a function call, is the name of the ++# function. ++progpath="$0" ++ ++ ++ ++: ${CP="cp -f"} ++: ${ECHO=$as_echo} ++: ${EGREP="/bin/grep -E"} ++: ${FGREP="/bin/grep -F"} ++: ${GREP="/bin/grep"} ++: ${LN_S="ln -s"} ++: ${MAKE="make"} ++: ${MKDIR="mkdir"} ++: ${MV="mv -f"} ++: ${RM="rm -f"} ++: ${SED="/mount/endor/wildenhu/local-x86_64/bin/sed"} ++: ${SHELL="${CONFIG_SHELL-/bin/sh}"} ++: ${Xsed="$SED -e 1s/^X//"} ++ ++# Global variables: ++EXIT_SUCCESS=0 ++EXIT_FAILURE=1 ++EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. ++EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. ++ ++exit_status=$EXIT_SUCCESS ++ ++# Make sure IFS has a sensible default ++lt_nl=' ++' ++IFS=" $lt_nl" ++ ++dirname="s,/[^/]*$,," ++basename="s,^.*/,," ++ ++# func_dirname_and_basename file append nondir_replacement ++# perform func_basename and func_dirname in a single function ++# call: ++# dirname: Compute the dirname of FILE. If nonempty, ++# add APPEND to the result, otherwise set result ++# to NONDIR_REPLACEMENT. ++# value returned in "$func_dirname_result" ++# basename: Compute filename of FILE. ++# value retuned in "$func_basename_result" ++# Implementation must be kept synchronized with func_dirname ++# and func_basename. For efficiency, we do not delegate to ++# those functions but instead duplicate the functionality here. ++func_dirname_and_basename () ++{ ++ # Extract subdirectory from the argument. ++ func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` ++ if test "X$func_dirname_result" = "X${1}"; then ++ func_dirname_result="${3}" ++ else ++ func_dirname_result="$func_dirname_result${2}" ++ fi ++ func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` ++} ++ ++# Generated shell functions inserted here. ++ ++# These SED scripts presuppose an absolute path with a trailing slash. ++pathcar='s,^/\([^/]*\).*$,\1,' ++pathcdr='s,^/[^/]*,,' ++removedotparts=':dotsl ++ s@/\./@/@g ++ t dotsl ++ s,/\.$,/,' ++collapseslashes='s@/\{1,\}@/@g' ++finalslash='s,/*$,/,' ++ ++# func_normal_abspath PATH ++# Remove doubled-up and trailing slashes, "." path components, ++# and cancel out any ".." path components in PATH after making ++# it an absolute path. ++# value returned in "$func_normal_abspath_result" ++func_normal_abspath () ++{ ++ # Start from root dir and reassemble the path. ++ func_normal_abspath_result= ++ func_normal_abspath_tpath=$1 ++ func_normal_abspath_altnamespace= ++ case $func_normal_abspath_tpath in ++ "") ++ # Empty path, that just means $cwd. ++ func_stripname '' '/' "`pwd`" ++ func_normal_abspath_result=$func_stripname_result ++ return ++ ;; ++ # The next three entries are used to spot a run of precisely ++ # two leading slashes without using negated character classes; ++ # we take advantage of case's first-match behaviour. ++ ///*) ++ # Unusual form of absolute path, do nothing. ++ ;; ++ //*) ++ # Not necessarily an ordinary path; POSIX reserves leading '//' ++ # and for example Cygwin uses it to access remote file shares ++ # over CIFS/SMB, so we conserve a leading double slash if found. ++ func_normal_abspath_altnamespace=/ ++ ;; ++ /*) ++ # Absolute path, do nothing. ++ ;; ++ *) ++ # Relative path, prepend $cwd. ++ func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ++ ;; ++ esac ++ # Cancel out all the simple stuff to save iterations. We also want ++ # the path to end with a slash for ease of parsing, so make sure ++ # there is one (and only one) here. ++ func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ ++ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` ++ while :; do ++ # Processed it all yet? ++ if test "$func_normal_abspath_tpath" = / ; then ++ # If we ascended to the root using ".." the result may be empty now. ++ if test -z "$func_normal_abspath_result" ; then ++ func_normal_abspath_result=/ ++ fi ++ break ++ fi ++ func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ ++ -e "$pathcar"` ++ func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ ++ -e "$pathcdr"` ++ # Figure out what to do with it ++ case $func_normal_abspath_tcomponent in ++ "") ++ # Trailing empty path component, ignore it. ++ ;; ++ ..) ++ # Parent dir; strip last assembled component from result. ++ func_dirname "$func_normal_abspath_result" ++ func_normal_abspath_result=$func_dirname_result ++ ;; ++ *) ++ # Actual path component, append it. ++ func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ++ ;; ++ esac ++ done ++ # Restore leading double-slash if one was found on entry. ++ func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result ++} ++ ++# func_relative_path SRCDIR DSTDIR ++# generates a relative path from SRCDIR to DSTDIR, with a trailing ++# slash if non-empty, suitable for immediately appending a filename ++# without needing to append a separator. ++# value returned in "$func_relative_path_result" ++func_relative_path () ++{ ++ func_relative_path_result= ++ func_normal_abspath "$1" ++ func_relative_path_tlibdir=$func_normal_abspath_result ++ func_normal_abspath "$2" ++ func_relative_path_tbindir=$func_normal_abspath_result ++ ++ # Ascend the tree starting from libdir ++ while :; do ++ # check if we have found a prefix of bindir ++ case $func_relative_path_tbindir in ++ $func_relative_path_tlibdir) ++ # found an exact match ++ func_relative_path_tcancelled= ++ break ++ ;; ++ $func_relative_path_tlibdir*) ++ # found a matching prefix ++ func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" ++ func_relative_path_tcancelled=$func_stripname_result ++ if test -z "$func_relative_path_result"; then ++ func_relative_path_result=. ++ fi ++ break ++ ;; ++ *) ++ func_dirname $func_relative_path_tlibdir ++ func_relative_path_tlibdir=${func_dirname_result} ++ if test "x$func_relative_path_tlibdir" = x ; then ++ # Have to descend all the way to the root! ++ func_relative_path_result=../$func_relative_path_result ++ func_relative_path_tcancelled=$func_relative_path_tbindir ++ break ++ fi ++ func_relative_path_result=../$func_relative_path_result ++ ;; ++ esac ++ done ++ ++ # Now calculate path; take care to avoid doubling-up slashes. ++ func_stripname '' '/' "$func_relative_path_result" ++ func_relative_path_result=$func_stripname_result ++ func_stripname '/' '/' "$func_relative_path_tcancelled" ++ if test "x$func_stripname_result" != x ; then ++ func_relative_path_result=${func_relative_path_result}/${func_stripname_result} ++ fi ++ ++ # Normalisation. If bindir is libdir, return empty string, ++ # else relative path ending with a slash; either way, target ++ # file name can be directly appended. ++ if test ! -z "$func_relative_path_result"; then ++ func_stripname './' '' "$func_relative_path_result/" ++ func_relative_path_result=$func_stripname_result ++ fi ++} ++ ++# The name of this program: ++func_dirname_and_basename "$progpath" ++progname=$func_basename_result ++ ++# Make sure we have an absolute path for reexecution: ++case $progpath in ++ [\\/]*|[A-Za-z]:\\*) ;; ++ *[\\/]*) ++ progdir=$func_dirname_result ++ progdir=`cd "$progdir" && pwd` ++ progpath="$progdir/$progname" ++ ;; ++ *) ++ save_IFS="$IFS" ++ IFS=: ++ for progdir in $PATH; do ++ IFS="$save_IFS" ++ test -x "$progdir/$progname" && break ++ done ++ IFS="$save_IFS" ++ test -n "$progdir" || progdir=`pwd` ++ progpath="$progdir/$progname" ++ ;; ++esac ++ ++# Sed substitution that helps us do robust quoting. It backslashifies ++# metacharacters that are still active within double-quoted strings. ++Xsed="${SED}"' -e 1s/^X//' ++sed_quote_subst='s/\([`"$\\]\)/\\\1/g' ++ ++# Same as above, but do not quote variable references. ++double_quote_subst='s/\(["`\\]\)/\\\1/g' ++ ++# Re-`\' parameter expansions in output of double_quote_subst that were ++# `\'-ed in input to the same. If an odd number of `\' preceded a '$' ++# in input to double_quote_subst, that '$' was protected from expansion. ++# Since each input `\' is now two `\'s, look for any number of runs of ++# four `\'s followed by two `\'s and then a '$'. `\' that '$'. ++bs='\\' ++bs2='\\\\' ++bs4='\\\\\\\\' ++dollar='\$' ++sed_double_backslash="\ ++ s/$bs4/&\\ ++/g ++ s/^$bs2$dollar/$bs&/ ++ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g ++ s/\n//g" ++ ++# Standard options: ++opt_dry_run=false ++opt_help=false ++opt_quiet=false ++opt_verbose=false ++opt_warning=: ++ ++# func_echo arg... ++# Echo program name prefixed message, along with the current mode ++# name if it has been set yet. ++func_echo () ++{ ++ $ECHO "$progname${mode+: }$mode: $*" ++} ++ ++# func_verbose arg... ++# Echo program name prefixed message in verbose mode only. ++func_verbose () ++{ ++ $opt_verbose && func_echo ${1+"$@"} ++ ++ # A bug in bash halts the script if the last line of a function ++ # fails when set -e is in force, so we need another command to ++ # work around that: ++ : ++} ++ ++# func_echo_all arg... ++# Invoke $ECHO with all args, space-separated. ++func_echo_all () ++{ ++ $ECHO "$*" ++} ++ ++# func_error arg... ++# Echo program name prefixed message to standard error. ++func_error () ++{ ++ $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 ++} ++ ++# func_warning arg... ++# Echo program name prefixed warning message to standard error. ++func_warning () ++{ ++ $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 ++ ++ # bash bug again: ++ : ++} ++ ++# func_fatal_error arg... ++# Echo program name prefixed message to standard error, and exit. ++func_fatal_error () ++{ ++ func_error ${1+"$@"} ++ exit $EXIT_FAILURE ++} ++ ++# func_fatal_help arg... ++# Echo program name prefixed message to standard error, followed by ++# a help hint, and exit. ++func_fatal_help () ++{ ++ func_error ${1+"$@"} ++ func_fatal_error "$help" ++} ++help="Try \`$progname --help' for more information." ## default ++ ++ ++# func_grep expression filename ++# Check whether EXPRESSION matches any line of FILENAME, without output. ++func_grep () ++{ ++ $GREP "$1" "$2" >/dev/null 2>&1 ++} ++ ++ ++# func_mkdir_p directory-path ++# Make sure the entire path to DIRECTORY-PATH is available. ++func_mkdir_p () ++{ ++ my_directory_path="$1" ++ my_dir_list= ++ ++ if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then ++ ++ # Protect directory names starting with `-' ++ case $my_directory_path in ++ -*) my_directory_path="./$my_directory_path" ;; ++ esac ++ ++ # While some portion of DIR does not yet exist... ++ while test ! -d "$my_directory_path"; do ++ # ...make a list in topmost first order. Use a colon delimited ++ # list incase some portion of path contains whitespace. ++ my_dir_list="$my_directory_path:$my_dir_list" ++ ++ # If the last portion added has no slash in it, the list is done ++ case $my_directory_path in */*) ;; *) break ;; esac ++ ++ # ...otherwise throw away the child directory and loop ++ my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` ++ done ++ my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` ++ ++ save_mkdir_p_IFS="$IFS"; IFS=':' ++ for my_dir in $my_dir_list; do ++ IFS="$save_mkdir_p_IFS" ++ # mkdir can fail with a `File exist' error if two processes ++ # try to create one of the directories concurrently. Don't ++ # stop in that case! ++ $MKDIR "$my_dir" 2>/dev/null || : ++ done ++ IFS="$save_mkdir_p_IFS" ++ ++ # Bail out if we (or some other process) failed to create a directory. ++ test -d "$my_directory_path" || \ ++ func_fatal_error "Failed to create \`$1'" ++ fi ++} ++ ++ ++# func_mktempdir [string] ++# Make a temporary directory that won't clash with other running ++# libtool processes, and avoids race conditions if possible. If ++# given, STRING is the basename for that directory. ++func_mktempdir () ++{ ++ my_template="${TMPDIR-/tmp}/${1-$progname}" ++ ++ if test "$opt_dry_run" = ":"; then ++ # Return a directory name, but don't create it in dry-run mode ++ my_tmpdir="${my_template}-$$" ++ else ++ ++ # If mktemp works, use that first and foremost ++ my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` ++ ++ if test ! -d "$my_tmpdir"; then ++ # Failing that, at least try and use $RANDOM to avoid a race ++ my_tmpdir="${my_template}-${RANDOM-0}$$" ++ ++ save_mktempdir_umask=`umask` ++ umask 0077 ++ $MKDIR "$my_tmpdir" ++ umask $save_mktempdir_umask ++ fi ++ ++ # If we're not in dry-run mode, bomb out on failure ++ test -d "$my_tmpdir" || \ ++ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" ++ fi ++ ++ $ECHO "$my_tmpdir" ++} ++ ++ ++# func_quote_for_eval arg ++# Aesthetically quote ARG to be evaled later. ++# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT ++# is double-quoted, suitable for a subsequent eval, whereas ++# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters ++# which are still active within double quotes backslashified. ++func_quote_for_eval () ++{ ++ case $1 in ++ *[\\\`\"\$]*) ++ func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; ++ *) ++ func_quote_for_eval_unquoted_result="$1" ;; ++ esac ++ ++ case $func_quote_for_eval_unquoted_result in ++ # Double-quote args containing shell metacharacters to delay ++ # word splitting, command substitution and and variable ++ # expansion for a subsequent eval. ++ # Many Bourne shells cannot handle close brackets correctly ++ # in scan sets, so we specify it separately. ++ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") ++ func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ++ ;; ++ *) ++ func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" ++ esac ++} ++ ++ ++# func_quote_for_expand arg ++# Aesthetically quote ARG to be evaled later; same as above, ++# but do not quote variable references. ++func_quote_for_expand () ++{ ++ case $1 in ++ *[\\\`\"]*) ++ my_arg=`$ECHO "$1" | $SED \ ++ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; ++ *) ++ my_arg="$1" ;; ++ esac ++ ++ case $my_arg in ++ # Double-quote args containing shell metacharacters to delay ++ # word splitting and command substitution for a subsequent eval. ++ # Many Bourne shells cannot handle close brackets correctly ++ # in scan sets, so we specify it separately. ++ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") ++ my_arg="\"$my_arg\"" ++ ;; ++ esac ++ ++ func_quote_for_expand_result="$my_arg" ++} ++ ++ ++# func_show_eval cmd [fail_exp] ++# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is ++# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP ++# is given, then evaluate it. ++func_show_eval () ++{ ++ my_cmd="$1" ++ my_fail_exp="${2-:}" ++ ++ ${opt_silent-false} || { ++ func_quote_for_expand "$my_cmd" ++ eval "func_echo $func_quote_for_expand_result" ++ } ++ ++ if ${opt_dry_run-false}; then :; else ++ eval "$my_cmd" ++ my_status=$? ++ if test "$my_status" -eq 0; then :; else ++ eval "(exit $my_status); $my_fail_exp" ++ fi ++ fi ++} ++ ++ ++# func_show_eval_locale cmd [fail_exp] ++# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is ++# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP ++# is given, then evaluate it. Use the saved locale for evaluation. ++func_show_eval_locale () ++{ ++ my_cmd="$1" ++ my_fail_exp="${2-:}" ++ ++ ${opt_silent-false} || { ++ func_quote_for_expand "$my_cmd" ++ eval "func_echo $func_quote_for_expand_result" ++ } ++ ++ if ${opt_dry_run-false}; then :; else ++ eval "$lt_user_locale ++ $my_cmd" ++ my_status=$? ++ eval "$lt_safe_locale" ++ if test "$my_status" -eq 0; then :; else ++ eval "(exit $my_status); $my_fail_exp" ++ fi ++ fi ++} ++ ++ ++ ++ ++ ++# func_version ++# Echo version message to standard output and exit. ++func_version () ++{ ++ $SED -n '/(C)/!b go ++ :more ++ /\./!{ ++ N ++ s/\n# // ++ b more ++ } ++ :go ++ /^# '$PROGRAM' (GNU /,/# warranty; / { ++ s/^# // ++ s/^# *$// ++ s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ ++ p ++ }' < "$progpath" ++ exit $? ++} ++ ++# func_usage ++# Echo short help message to standard output and exit. ++func_usage () ++{ ++ $SED -n '/^# Usage:/,/^# *-h/ { ++ s/^# // ++ s/^# *$// ++ s/\$progname/'$progname'/ ++ p ++ }' < "$progpath" ++ echo ++ $ECHO "run \`$progname --help | more' for full usage" ++ exit $? ++} ++ ++# func_help [NOEXIT] ++# Echo long help message to standard output and exit, ++# unless 'noexit' is passed as argument. ++func_help () ++{ ++ $SED -n '/^# Usage:/,/# Report bugs to/ { ++ s/^# // ++ s/^# *$// ++ s*\$progname*'$progname'* ++ s*\$host*'"$host"'* ++ s*\$SHELL*'"$SHELL"'* ++ s*\$LTCC*'"$LTCC"'* ++ s*\$LTCFLAGS*'"$LTCFLAGS"'* ++ s*\$LD*'"$LD"'* ++ s/\$with_gnu_ld/'"$with_gnu_ld"'/ ++ s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ ++ s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ ++ p ++ }' < "$progpath" ++ ret=$? ++ if test -z "$1"; then ++ exit $ret ++ fi ++} ++ ++# func_missing_arg argname ++# Echo program name prefixed message to standard error and set global ++# exit_cmd. ++func_missing_arg () ++{ ++ func_error "missing argument for $1" ++ exit_cmd=exit ++} ++ ++exit_cmd=: ++ ++ ++ ++ ++ ++ ++magic="%%%MAGIC variable%%%" ++magic_exe="%%%MAGIC EXE variable%%%" ++ ++# Global variables. ++# $mode is unset ++nonopt= ++execute_dlfiles= ++preserve_args= ++lo2o="s/\\.lo\$/.${objext}/" ++o2lo="s/\\.${objext}\$/.lo/" ++extracted_archives= ++extracted_serial=0 ++ ++opt_dry_run=false ++opt_finish=: ++opt_duplicate_deps=false ++opt_silent=false ++opt_debug=: ++ ++# If this variable is set in any of the actions, the command in it ++# will be execed at the end. This prevents here-documents from being ++# left over by shells. ++exec_cmd= ++ ++# func_fatal_configuration arg... ++# Echo program name prefixed message to standard error, followed by ++# a configuration failure hint, and exit. ++func_fatal_configuration () ++{ ++ func_error ${1+"$@"} ++ func_error "See the $PACKAGE documentation for more information." ++ func_fatal_error "Fatal configuration error." ++} ++ ++ ++# func_config ++# Display the configuration for all the tags in this script. ++func_config () ++{ ++ re_begincf='^# ### BEGIN LIBTOOL' ++ re_endcf='^# ### END LIBTOOL' ++ ++ # Default configuration. ++ $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" ++ ++ # Now print the configurations for the tags. ++ for tagname in $taglist; do ++ $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" ++ done ++ ++ exit $? ++} ++ ++# func_features ++# Display the features supported by this script. ++func_features () ++{ ++ echo "host: $host" ++ if test "$build_libtool_libs" = yes; then ++ echo "enable shared libraries" ++ else ++ echo "disable shared libraries" ++ fi ++ if test "$build_old_libs" = yes; then ++ echo "enable static libraries" ++ else ++ echo "disable static libraries" ++ fi ++ ++ exit $? ++} ++ ++# func_enable_tag tagname ++# Verify that TAGNAME is valid, and either flag an error and exit, or ++# enable the TAGNAME tag. We also add TAGNAME to the global $taglist ++# variable here. ++func_enable_tag () ++{ ++ # Global variable: ++ tagname="$1" ++ ++ re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" ++ re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" ++ sed_extractcf="/$re_begincf/,/$re_endcf/p" ++ ++ # Validate tagname. ++ case $tagname in ++ *[!-_A-Za-z0-9,/]*) ++ func_fatal_error "invalid tag name: $tagname" ++ ;; ++ esac ++ ++ # Don't test for the "default" C tag, as we know it's ++ # there but not specially marked. ++ case $tagname in ++ CC) ;; ++ *) ++ if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then ++ taglist="$taglist $tagname" ++ ++ # Evaluate the configuration. Be careful to quote the path ++ # and the sed script, to avoid splitting on whitespace, but ++ # also don't use non-portable quotes within backquotes within ++ # quotes we have to do it in 2 steps: ++ extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` ++ eval "$extractedcf" ++ else ++ func_error "ignoring unknown tag $tagname" ++ fi ++ ;; ++ esac ++} ++ ++# Parse options once, thoroughly. This comes as soon as possible in ++# the script to make things like `libtool --version' happen quickly. ++{ ++ ++ # Shorthand for --mode=foo, only valid as the first argument ++ case $1 in ++ clean|clea|cle|cl) ++ shift; set dummy --mode clean ${1+"$@"}; shift ++ ;; ++ compile|compil|compi|comp|com|co|c) ++ shift; set dummy --mode compile ${1+"$@"}; shift ++ ;; ++ execute|execut|execu|exec|exe|ex|e) ++ shift; set dummy --mode execute ${1+"$@"}; shift ++ ;; ++ finish|finis|fini|fin|fi|f) ++ shift; set dummy --mode finish ${1+"$@"}; shift ++ ;; ++ install|instal|insta|inst|ins|in|i) ++ shift; set dummy --mode install ${1+"$@"}; shift ++ ;; ++ link|lin|li|l) ++ shift; set dummy --mode link ${1+"$@"}; shift ++ ;; ++ uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) ++ shift; set dummy --mode uninstall ${1+"$@"}; shift ++ ;; ++ esac ++ ++ # Parse non-mode specific arguments: ++ while test "$#" -gt 0; do ++ opt="$1" ++ shift ++ ++ case $opt in ++ --config) func_config ;; ++ ++ --debug) preserve_args="$preserve_args $opt" ++ func_echo "enabling shell trace mode" ++ opt_debug='set -x' ++ $opt_debug ++ ;; ++ ++ -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break ++ execute_dlfiles="$execute_dlfiles $1" ++ shift ++ ;; ++ ++ --dry-run | -n) opt_dry_run=: ;; ++ --features) func_features ;; ++ --finish) mode="finish" ;; ++ --no-finish) opt_finish=false ;; ++ ++ --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break ++ case $1 in ++ # Valid mode arguments: ++ clean) ;; ++ compile) ;; ++ execute) ;; ++ finish) ;; ++ install) ;; ++ link) ;; ++ relink) ;; ++ uninstall) ;; ++ ++ # Catch anything else as an error ++ *) func_error "invalid argument for $opt" ++ exit_cmd=exit ++ break ++ ;; ++ esac ++ ++ mode="$1" ++ shift ++ ;; ++ ++ --preserve-dup-deps) ++ opt_duplicate_deps=: ;; ++ ++ --quiet|--silent) preserve_args="$preserve_args $opt" ++ opt_silent=: ++ opt_verbose=false ++ ;; ++ ++ --no-quiet|--no-silent) ++ preserve_args="$preserve_args $opt" ++ opt_silent=false ++ ;; ++ ++ --verbose| -v) preserve_args="$preserve_args $opt" ++ opt_silent=false ++ opt_verbose=: ++ ;; ++ ++ --no-verbose) preserve_args="$preserve_args $opt" ++ opt_verbose=false ++ ;; ++ ++ --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break ++ preserve_args="$preserve_args $opt $1" ++ func_enable_tag "$1" # tagname is set here ++ shift ++ ;; ++ ++ # Separate optargs to long options: ++ -dlopen=*|--mode=*|--tag=*) ++ func_opt_split "$opt" ++ set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} ++ shift ++ ;; ++ ++ -\?|-h) func_usage ;; ++ --help) opt_help=: ;; ++ --help-all) opt_help=': help-all' ;; ++ --version) func_version ;; ++ ++ -*) func_fatal_help "unrecognized option \`$opt'" ;; ++ ++ *) nonopt="$opt" ++ break ++ ;; ++ esac ++ done ++ ++ ++ case $host in ++ *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* ) ++ # don't eliminate duplications in $postdeps and $predeps ++ opt_duplicate_compiler_generated_deps=: ++ ;; ++ *) ++ opt_duplicate_compiler_generated_deps=$opt_duplicate_deps ++ ;; ++ esac ++ ++ # Having warned about all mis-specified options, bail out if ++ # anything was wrong. ++ $exit_cmd $EXIT_FAILURE ++} ++ ++# func_check_version_match ++# Ensure that we are using m4 macros, and libtool script from the same ++# release of libtool. ++func_check_version_match () ++{ ++ if test "$package_revision" != "$macro_revision"; then ++ if test "$VERSION" != "$macro_version"; then ++ if test -z "$macro_version"; then ++ cat >&2 <<_LT_EOF ++$progname: Version mismatch error. This is $PACKAGE $VERSION, but the ++$progname: definition of this LT_INIT comes from an older release. ++$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION ++$progname: and run autoconf again. ++_LT_EOF ++ else ++ cat >&2 <<_LT_EOF ++$progname: Version mismatch error. This is $PACKAGE $VERSION, but the ++$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. ++$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION ++$progname: and run autoconf again. ++_LT_EOF ++ fi ++ else ++ cat >&2 <<_LT_EOF ++$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, ++$progname: but the definition of this LT_INIT comes from revision $macro_revision. ++$progname: You should recreate aclocal.m4 with macros from revision $package_revision ++$progname: of $PACKAGE $VERSION and run autoconf again. ++_LT_EOF ++ fi ++ ++ exit $EXIT_MISMATCH ++ fi ++} ++ ++ ++## ----------- ## ++## Main. ## ++## ----------- ## ++ ++$opt_help || { ++ # Sanity checks first: ++ func_check_version_match ++ ++ if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then ++ func_fatal_configuration "not configured to build any kind of library" ++ fi ++ ++ test -z "$mode" && func_fatal_error "error: you must specify a MODE." ++ ++ ++ # Darwin sucks ++ eval "std_shrext=\"$shrext_cmds\"" ++ ++ ++ # Only execute mode is allowed to have -dlopen flags. ++ if test -n "$execute_dlfiles" && test "$mode" != execute; then ++ func_error "unrecognized option \`-dlopen'" ++ $ECHO "$help" 1>&2 ++ exit $EXIT_FAILURE ++ fi ++ ++ # Change the help message to a mode-specific one. ++ generic_help="$help" ++ help="Try \`$progname --help --mode=$mode' for more information." ++} ++ ++ ++# func_lalib_p file ++# True iff FILE is a libtool `.la' library or `.lo' object file. ++# This function is only a basic sanity check; it will hardly flush out ++# determined imposters. ++func_lalib_p () ++{ ++ test -f "$1" && ++ $SED -e 4q "$1" 2>/dev/null \ ++ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 ++} ++ ++# func_lalib_unsafe_p file ++# True iff FILE is a libtool `.la' library or `.lo' object file. ++# This function implements the same check as func_lalib_p without ++# resorting to external programs. To this end, it redirects stdin and ++# closes it afterwards, without saving the original file descriptor. ++# As a safety measure, use it only where a negative result would be ++# fatal anyway. Works if `file' does not exist. ++func_lalib_unsafe_p () ++{ ++ lalib_p=no ++ if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then ++ for lalib_p_l in 1 2 3 4 ++ do ++ read lalib_p_line ++ case "$lalib_p_line" in ++ \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; ++ esac ++ done ++ exec 0<&5 5<&- ++ fi ++ test "$lalib_p" = yes ++} ++ ++# func_ltwrapper_script_p file ++# True iff FILE is a libtool wrapper script ++# This function is only a basic sanity check; it will hardly flush out ++# determined imposters. ++func_ltwrapper_script_p () ++{ ++ func_lalib_p "$1" ++} ++ ++# func_ltwrapper_executable_p file ++# True iff FILE is a libtool wrapper executable ++# This function is only a basic sanity check; it will hardly flush out ++# determined imposters. ++func_ltwrapper_executable_p () ++{ ++ func_ltwrapper_exec_suffix= ++ case $1 in ++ *.exe) ;; ++ *) func_ltwrapper_exec_suffix=.exe ;; ++ esac ++ $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 ++} ++ ++# func_ltwrapper_scriptname file ++# Assumes file is an ltwrapper_executable ++# uses $file to determine the appropriate filename for a ++# temporary ltwrapper_script. ++func_ltwrapper_scriptname () ++{ ++ func_ltwrapper_scriptname_result="" ++ if func_ltwrapper_executable_p "$1"; then ++ func_dirname_and_basename "$1" "" "." ++ func_stripname '' '.exe' "$func_basename_result" ++ func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" ++ fi ++} ++ ++# func_ltwrapper_p file ++# True iff FILE is a libtool wrapper script or wrapper executable ++# This function is only a basic sanity check; it will hardly flush out ++# determined imposters. ++func_ltwrapper_p () ++{ ++ func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" ++} ++ ++ ++# func_execute_cmds commands fail_cmd ++# Execute tilde-delimited COMMANDS. ++# If FAIL_CMD is given, eval that upon failure. ++# FAIL_CMD may read-access the current command in variable CMD! ++func_execute_cmds () ++{ ++ $opt_debug ++ save_ifs=$IFS; IFS='~' ++ for cmd in $1; do ++ IFS=$save_ifs ++ eval "cmd=\"$cmd\"" ++ func_show_eval "$cmd" "${2-:}" ++ done ++ IFS=$save_ifs ++} ++ ++ ++# func_source file ++# Source FILE, adding directory component if necessary. ++# Note that it is not necessary on cygwin/mingw to append a dot to ++# FILE even if both FILE and FILE.exe exist: automatic-append-.exe ++# behavior happens only for exec(3), not for open(2)! Also, sourcing ++# `FILE.' does not work on cygwin managed mounts. ++func_source () ++{ ++ $opt_debug ++ case $1 in ++ */* | *\\*) . "$1" ;; ++ *) . "./$1" ;; ++ esac ++} ++ ++ ++# func_infer_tag arg ++# Infer tagged configuration to use if any are available and ++# if one wasn't chosen via the "--tag" command line option. ++# Only attempt this if the compiler in the base compile ++# command doesn't match the default compiler. ++# arg is usually of the form 'gcc ...' ++func_infer_tag () ++{ ++ $opt_debug ++ if test -n "$available_tags" && test -z "$tagname"; then ++ CC_quoted= ++ for arg in $CC; do ++ func_quote_for_eval "$arg" ++ CC_quoted="$CC_quoted $func_quote_for_eval_result" ++ done ++ CC_expanded=`func_echo_all $CC` ++ CC_quoted_expanded=`func_echo_all $CC_quoted` ++ case $@ in ++ # Blanks in the command may have been stripped by the calling shell, ++ # but not from the CC environment variable when configure was run. ++ " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ ++ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; ++ # Blanks at the start of $base_compile will cause this to fail ++ # if we don't check for them as well. ++ *) ++ for z in $available_tags; do ++ if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then ++ # Evaluate the configuration. ++ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" ++ CC_quoted= ++ for arg in $CC; do ++ # Double-quote args containing other shell metacharacters. ++ func_quote_for_eval "$arg" ++ CC_quoted="$CC_quoted $func_quote_for_eval_result" ++ done ++ CC_expanded=`func_echo_all $CC` ++ CC_quoted_expanded=`func_echo_all $CC_quoted` ++ case "$@ " in ++ " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ ++ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ++ # The compiler in the base compile command matches ++ # the one in the tagged configuration. ++ # Assume this is the tagged configuration we want. ++ tagname=$z ++ break ++ ;; ++ esac ++ fi ++ done ++ # If $tagname still isn't set, then no tagged configuration ++ # was found and let the user know that the "--tag" command ++ # line option must be used. ++ if test -z "$tagname"; then ++ func_echo "unable to infer tagged configuration" ++ func_fatal_error "specify a tag with \`--tag'" ++# else ++# func_verbose "using $tagname tagged configuration" ++ fi ++ ;; ++ esac ++ fi ++} ++ ++ ++ ++# func_write_libtool_object output_name pic_name nonpic_name ++# Create a libtool object file (analogous to a ".la" file), ++# but don't create it if we're doing a dry run. ++func_write_libtool_object () ++{ ++ write_libobj=${1} ++ if test "$build_libtool_libs" = yes; then ++ write_lobj=\'${2}\' ++ else ++ write_lobj=none ++ fi ++ ++ if test "$build_old_libs" = yes; then ++ write_oldobj=\'${3}\' ++ else ++ write_oldobj=none ++ fi ++ ++ $opt_dry_run || { ++ cat >${write_libobj}T <?"'"'"' &()|`$[]' \ ++ && func_warning "libobj name \`$libobj' may not contain shell special characters." ++ func_dirname_and_basename "$obj" "/" "" ++ objname="$func_basename_result" ++ xdir="$func_dirname_result" ++ lobj=${xdir}$objdir/$objname ++ ++ test -z "$base_compile" && \ ++ func_fatal_help "you must specify a compilation command" ++ ++ # Delete any leftover library objects. ++ if test "$build_old_libs" = yes; then ++ removelist="$obj $lobj $libobj ${libobj}T" ++ else ++ removelist="$lobj $libobj ${libobj}T" ++ fi ++ ++ # On Cygwin there's no "real" PIC flag so we must build both object types ++ case $host_os in ++ cygwin* | mingw* | pw32* | os2* | cegcc*) ++ pic_mode=default ++ ;; ++ esac ++ if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then ++ # non-PIC code in shared libraries is not supported ++ pic_mode=default ++ fi ++ ++ # Calculate the filename of the output object if compiler does ++ # not support -o with -c ++ if test "$compiler_c_o" = no; then ++ output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} ++ lockfile="$output_obj.lock" ++ else ++ output_obj= ++ need_locks=no ++ lockfile= ++ fi ++ ++ # Lock this critical section if it is needed ++ # We use this script file to make the link, it avoids creating a new file ++ if test "$need_locks" = yes; then ++ until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do ++ func_echo "Waiting for $lockfile to be removed" ++ sleep 2 ++ done ++ elif test "$need_locks" = warn; then ++ if test -f "$lockfile"; then ++ $ECHO "\ ++*** ERROR, $lockfile exists and contains: ++`cat $lockfile 2>/dev/null` ++ ++This indicates that another process is trying to use the same ++temporary object file, and libtool could not work around it because ++your compiler does not support \`-c' and \`-o' together. If you ++repeat this compilation, it may succeed, by chance, but you had better ++avoid parallel builds (make -j) in this platform, or get a better ++compiler." ++ ++ $opt_dry_run || $RM $removelist ++ exit $EXIT_FAILURE ++ fi ++ removelist="$removelist $output_obj" ++ $ECHO "$srcfile" > "$lockfile" ++ fi ++ ++ $opt_dry_run || $RM $removelist ++ removelist="$removelist $lockfile" ++ trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 ++ ++ if test -n "$fix_srcfile_path"; then ++ eval "srcfile=\"$fix_srcfile_path\"" ++ fi ++ func_quote_for_eval "$srcfile" ++ qsrcfile=$func_quote_for_eval_result ++ ++ # Only build a PIC object if we are building libtool libraries. ++ if test "$build_libtool_libs" = yes; then ++ # Without this assignment, base_compile gets emptied. ++ fbsd_hideous_sh_bug=$base_compile ++ ++ if test "$pic_mode" != no; then ++ command="$base_compile $qsrcfile $pic_flag" ++ else ++ # Don't build PIC code ++ command="$base_compile $qsrcfile" ++ fi ++ ++ func_mkdir_p "$xdir$objdir" ++ ++ if test -z "$output_obj"; then ++ # Place PIC objects in $objdir ++ command="$command -o $lobj" ++ fi ++ ++ func_show_eval_locale "$command" \ ++ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' ++ ++ if test "$need_locks" = warn && ++ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then ++ $ECHO "\ ++*** ERROR, $lockfile contains: ++`cat $lockfile 2>/dev/null` ++ ++but it should contain: ++$srcfile ++ ++This indicates that another process is trying to use the same ++temporary object file, and libtool could not work around it because ++your compiler does not support \`-c' and \`-o' together. If you ++repeat this compilation, it may succeed, by chance, but you had better ++avoid parallel builds (make -j) in this platform, or get a better ++compiler." ++ ++ $opt_dry_run || $RM $removelist ++ exit $EXIT_FAILURE ++ fi ++ ++ # Just move the object if needed, then go on to compile the next one ++ if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then ++ func_show_eval '$MV "$output_obj" "$lobj"' \ ++ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' ++ fi ++ ++ # Allow error messages only from the first compilation. ++ if test "$suppress_opt" = yes; then ++ suppress_output=' >/dev/null 2>&1' ++ fi ++ fi ++ ++ # Only build a position-dependent object if we build old libraries. ++ if test "$build_old_libs" = yes; then ++ if test "$pic_mode" != yes; then ++ # Don't build PIC code ++ command="$base_compile $qsrcfile$pie_flag" ++ else ++ command="$base_compile $qsrcfile $pic_flag" ++ fi ++ if test "$compiler_c_o" = yes; then ++ command="$command -o $obj" ++ fi ++ ++ # Suppress compiler output if we already did a PIC compilation. ++ command="$command$suppress_output" ++ func_show_eval_locale "$command" \ ++ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' ++ ++ if test "$need_locks" = warn && ++ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then ++ $ECHO "\ ++*** ERROR, $lockfile contains: ++`cat $lockfile 2>/dev/null` ++ ++but it should contain: ++$srcfile ++ ++This indicates that another process is trying to use the same ++temporary object file, and libtool could not work around it because ++your compiler does not support \`-c' and \`-o' together. If you ++repeat this compilation, it may succeed, by chance, but you had better ++avoid parallel builds (make -j) in this platform, or get a better ++compiler." ++ ++ $opt_dry_run || $RM $removelist ++ exit $EXIT_FAILURE ++ fi ++ ++ # Just move the object if needed ++ if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then ++ func_show_eval '$MV "$output_obj" "$obj"' \ ++ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' ++ fi ++ fi ++ ++ $opt_dry_run || { ++ func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" ++ ++ # Unlock the critical section if it was locked ++ if test "$need_locks" != no; then ++ removelist=$lockfile ++ $RM "$lockfile" ++ fi ++ } ++ ++ exit $EXIT_SUCCESS ++} ++ ++$opt_help || { ++ test "$mode" = compile && func_mode_compile ${1+"$@"} ++} ++ ++func_mode_help () ++{ ++ # We need to display help for each of the modes. ++ case $mode in ++ "") ++ # Generic help is extracted from the usage comments ++ # at the start of this file. ++ func_help ++ ;; ++ ++ clean) ++ $ECHO \ ++"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... ++ ++Remove files from the build directory. ++ ++RM is the name of the program to use to delete files associated with each FILE ++(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed ++to RM. ++ ++If FILE is a libtool library, object or program, all the files associated ++with it are deleted. Otherwise, only FILE itself is deleted using RM." ++ ;; ++ ++ compile) ++ $ECHO \ ++"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE ++ ++Compile a source file into a libtool library object. ++ ++This mode accepts the following additional options: ++ ++ -o OUTPUT-FILE set the output file name to OUTPUT-FILE ++ -no-suppress do not suppress compiler output for multiple passes ++ -prefer-pic try to building PIC objects only ++ -prefer-non-pic try to building non-PIC objects only ++ -shared do not build a \`.o' file suitable for static linking ++ -static only build a \`.o' file suitable for static linking ++ -Wc,FLAG pass FLAG directly to the compiler ++ ++COMPILE-COMMAND is a command to be used in creating a \`standard' object file ++from the given SOURCEFILE. ++ ++The output file name is determined by removing the directory component from ++SOURCEFILE, then substituting the C source code suffix \`.c' with the ++library object suffix, \`.lo'." ++ ;; ++ ++ execute) ++ $ECHO \ ++"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... ++ ++Automatically set library path, then run a program. ++ ++This mode accepts the following additional options: ++ ++ -dlopen FILE add the directory containing FILE to the library path ++ ++This mode sets the library path environment variable according to \`-dlopen' ++flags. ++ ++If any of the ARGS are libtool executable wrappers, then they are translated ++into their corresponding uninstalled binary, and any of their required library ++directories are added to the library path. ++ ++Then, COMMAND is executed, with ARGS as arguments." ++ ;; ++ ++ finish) ++ $ECHO \ ++"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... ++ ++Complete the installation of libtool libraries. ++ ++Each LIBDIR is a directory that contains libtool libraries. ++ ++The commands that this mode executes may require superuser privileges. Use ++the \`--dry-run' option if you just want to see what would be executed." ++ ;; ++ ++ install) ++ $ECHO \ ++"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... ++ ++Install executables or libraries. ++ ++INSTALL-COMMAND is the installation command. The first component should be ++either the \`install' or \`cp' program. ++ ++The following components of INSTALL-COMMAND are treated specially: ++ ++ -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation ++ ++The rest of the components are interpreted as arguments to that command (only ++BSD-compatible install options are recognized)." ++ ;; ++ ++ link) ++ $ECHO \ ++"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... ++ ++Link object files or libraries together to form another library, or to ++create an executable program. ++ ++LINK-COMMAND is a command using the C compiler that you would use to create ++a program from several object files. ++ ++The following components of LINK-COMMAND are treated specially: ++ ++ -all-static do not do any dynamic linking at all ++ -avoid-version do not add a version suffix if possible ++ -bindir BINDIR specify path to binaries directory (for systems where ++ libraries must be found in the PATH setting at runtime) ++ -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime ++ -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols ++ -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) ++ -export-symbols SYMFILE ++ try to export only the symbols listed in SYMFILE ++ -export-symbols-regex REGEX ++ try to export only the symbols matching REGEX ++ -LLIBDIR search LIBDIR for required installed libraries ++ -lNAME OUTPUT-FILE requires the installed library libNAME ++ -module build a library that can dlopened ++ -no-fast-install disable the fast-install mode ++ -no-install link a not-installable executable ++ -no-undefined declare that a library does not refer to external symbols ++ -o OUTPUT-FILE create OUTPUT-FILE from the specified objects ++ -objectlist FILE Use a list of object files found in FILE to specify objects ++ -precious-files-regex REGEX ++ don't remove output files matching REGEX ++ -release RELEASE specify package release information ++ -rpath LIBDIR the created library will eventually be installed in LIBDIR ++ -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries ++ -shared only do dynamic linking of libtool libraries ++ -shrext SUFFIX override the standard shared library file extension ++ -static do not do any dynamic linking of uninstalled libtool libraries ++ -static-libtool-libs ++ do not do any dynamic linking of libtool libraries ++ -version-info CURRENT[:REVISION[:AGE]] ++ specify library version info [each variable defaults to 0] ++ -weak LIBNAME declare that the target provides the LIBNAME interface ++ -Wc,FLAG ++ -Xcompiler FLAG pass linker-specific FLAG directly to the compiler ++ -Wl,FLAG ++ -Xlinker FLAG pass linker-specific FLAG directly to the linker ++ -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) ++ ++All other options (arguments beginning with \`-') are ignored. ++ ++Every other argument is treated as a filename. Files ending in \`.la' are ++treated as uninstalled libtool libraries, other files are standard or library ++object files. ++ ++If the OUTPUT-FILE ends in \`.la', then a libtool library is created, ++only library objects (\`.lo' files) may be specified, and \`-rpath' is ++required, except when creating a convenience library. ++ ++If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created ++using \`ar' and \`ranlib', or on Windows using \`lib'. ++ ++If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file ++is created, otherwise an executable program is created." ++ ;; ++ ++ uninstall) ++ $ECHO \ ++"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... ++ ++Remove libraries from an installation directory. ++ ++RM is the name of the program to use to delete files associated with each FILE ++(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed ++to RM. ++ ++If FILE is a libtool library, all the files associated with it are deleted. ++Otherwise, only FILE itself is deleted using RM." ++ ;; ++ ++ *) ++ func_fatal_help "invalid operation mode \`$mode'" ++ ;; ++ esac ++ ++ echo ++ $ECHO "Try \`$progname --help' for more information about other modes." ++} ++ ++# Now that we've collected a possible --mode arg, show help if necessary ++if $opt_help; then ++ if test "$opt_help" = :; then ++ func_mode_help ++ else ++ { ++ func_help noexit ++ for mode in compile link execute install finish uninstall clean; do ++ func_mode_help ++ done ++ } | sed -n '1p; 2,$s/^Usage:/ or: /p' ++ { ++ func_help noexit ++ for mode in compile link execute install finish uninstall clean; do ++ echo ++ func_mode_help ++ done ++ } | ++ sed '1d ++ /^When reporting/,/^Report/{ ++ H ++ d ++ } ++ $x ++ /information about other modes/d ++ /more detailed .*MODE/d ++ s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' ++ fi ++ exit $? ++fi ++ ++ ++# func_mode_execute arg... ++func_mode_execute () ++{ ++ $opt_debug ++ # The first argument is the command name. ++ cmd="$nonopt" ++ test -z "$cmd" && \ ++ func_fatal_help "you must specify a COMMAND" ++ ++ # Handle -dlopen flags immediately. ++ for file in $execute_dlfiles; do ++ test -f "$file" \ ++ || func_fatal_help "\`$file' is not a file" ++ ++ dir= ++ case $file in ++ *.la) ++ # Check to see that this really is a libtool archive. ++ func_lalib_unsafe_p "$file" \ ++ || func_fatal_help "\`$lib' is not a valid libtool archive" ++ ++ # Read the libtool library. ++ dlname= ++ library_names= ++ func_source "$file" ++ ++ # Skip this library if it cannot be dlopened. ++ if test -z "$dlname"; then ++ # Warn if it was a shared library. ++ test -n "$library_names" && \ ++ func_warning "\`$file' was not linked with \`-export-dynamic'" ++ continue ++ fi ++ ++ func_dirname "$file" "" "." ++ dir="$func_dirname_result" ++ ++ if test -f "$dir/$objdir/$dlname"; then ++ dir="$dir/$objdir" ++ else ++ if test ! -f "$dir/$dlname"; then ++ func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" ++ fi ++ fi ++ ;; ++ ++ *.lo) ++ # Just add the directory containing the .lo file. ++ func_dirname "$file" "" "." ++ dir="$func_dirname_result" ++ ;; ++ ++ *) ++ func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" ++ continue ++ ;; ++ esac ++ ++ # Get the absolute pathname. ++ absdir=`cd "$dir" && pwd` ++ test -n "$absdir" && dir="$absdir" ++ ++ # Now add the directory to shlibpath_var. ++ if eval test -z \"\$$shlibpath_var\"; then ++ eval $shlibpath_var=\$dir ++ else ++ eval $shlibpath_var=\$dir:\$$shlibpath_var ++ fi ++ done ++ ++ # This variable tells wrapper scripts just to set shlibpath_var ++ # rather than running their programs. ++ libtool_execute_magic="$magic" ++ ++ # Check if any of the arguments is a wrapper script. ++ args= ++ for file ++ do ++ case $file in ++ -* | *.la | *.lo ) ;; ++ *) ++ # Do a test to see if this is really a libtool program. ++ if func_ltwrapper_script_p "$file"; then ++ func_source "$file" ++ # Transform arg to wrapped name. ++ file="$progdir/$program" ++ elif func_ltwrapper_executable_p "$file"; then ++ func_ltwrapper_scriptname "$file" ++ func_source "$func_ltwrapper_scriptname_result" ++ # Transform arg to wrapped name. ++ file="$progdir/$program" ++ fi ++ ;; ++ esac ++ # Quote arguments (to preserve shell metacharacters). ++ func_quote_for_eval "$file" ++ args="$args $func_quote_for_eval_result" ++ done ++ ++ if test "X$opt_dry_run" = Xfalse; then ++ if test -n "$shlibpath_var"; then ++ # Export the shlibpath_var. ++ eval "export $shlibpath_var" ++ fi ++ ++ # Restore saved environment variables ++ for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES ++ do ++ eval "if test \"\${save_$lt_var+set}\" = set; then ++ $lt_var=\$save_$lt_var; export $lt_var ++ else ++ $lt_unset $lt_var ++ fi" ++ done ++ ++ # Now prepare to actually exec the command. ++ exec_cmd="\$cmd$args" ++ else ++ # Display what would be done. ++ if test -n "$shlibpath_var"; then ++ eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" ++ echo "export $shlibpath_var" ++ fi ++ $ECHO "$cmd$args" ++ exit $EXIT_SUCCESS ++ fi ++} ++ ++test "$mode" = execute && func_mode_execute ${1+"$@"} ++ ++ ++# func_mode_finish arg... ++func_mode_finish () ++{ ++ $opt_debug ++ libdirs="$nonopt" ++ admincmds= ++ ++ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then ++ for dir ++ do ++ libdirs="$libdirs $dir" ++ done ++ ++ for libdir in $libdirs; do ++ if test -n "$finish_cmds"; then ++ # Do each command in the finish commands. ++ func_execute_cmds "$finish_cmds" 'admincmds="$admincmds ++'"$cmd"'"' ++ fi ++ if test -n "$finish_eval"; then ++ # Do the single finish_eval. ++ eval cmds=\"$finish_eval\" ++ $opt_dry_run || eval "$cmds" || admincmds="$admincmds ++ $cmds" ++ fi ++ done ++ fi ++ ++ # Exit here if they wanted silent mode. ++ $opt_silent && exit $EXIT_SUCCESS ++ ++ echo "----------------------------------------------------------------------" ++ echo "Libraries have been installed in:" ++ for libdir in $libdirs; do ++ $ECHO " $libdir" ++ done ++ echo ++ echo "If you ever happen to want to link against installed libraries" ++ echo "in a given directory, LIBDIR, you must either use libtool, and" ++ echo "specify the full pathname of the library, or use the \`-LLIBDIR'" ++ echo "flag during linking and do at least one of the following:" ++ if test -n "$shlibpath_var"; then ++ echo " - add LIBDIR to the \`$shlibpath_var' environment variable" ++ echo " during execution" ++ fi ++ if test -n "$runpath_var"; then ++ echo " - add LIBDIR to the \`$runpath_var' environment variable" ++ echo " during linking" ++ fi ++ if test -n "$hardcode_libdir_flag_spec"; then ++ libdir=LIBDIR ++ eval "flag=\"$hardcode_libdir_flag_spec\"" ++ ++ $ECHO " - use the \`$flag' linker flag" ++ fi ++ if test -n "$admincmds"; then ++ $ECHO " - have your system administrator run these commands:$admincmds" ++ fi ++ if test -f /etc/ld.so.conf; then ++ echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" ++ fi ++ echo ++ ++ echo "See any operating system documentation about shared libraries for" ++ case $host in ++ solaris2.[6789]|solaris2.1[0-9]) ++ echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" ++ echo "pages." ++ ;; ++ *) ++ echo "more information, such as the ld(1) and ld.so(8) manual pages." ++ ;; ++ esac ++ echo "----------------------------------------------------------------------" ++ exit $EXIT_SUCCESS ++} ++ ++test "$mode" = finish && func_mode_finish ${1+"$@"} ++ ++ ++# func_mode_install arg... ++func_mode_install () ++{ ++ $opt_debug ++ # There may be an optional sh(1) argument at the beginning of ++ # install_prog (especially on Windows NT). ++ if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || ++ # Allow the use of GNU shtool's install command. ++ case $nonopt in *shtool*) :;; *) false;; esac; then ++ # Aesthetically quote it. ++ func_quote_for_eval "$nonopt" ++ install_prog="$func_quote_for_eval_result " ++ arg=$1 ++ shift ++ else ++ install_prog= ++ arg=$nonopt ++ fi ++ ++ # The real first argument should be the name of the installation program. ++ # Aesthetically quote it. ++ func_quote_for_eval "$arg" ++ install_prog="$install_prog$func_quote_for_eval_result" ++ install_shared_prog=$install_prog ++ case " $install_prog " in ++ *[\\\ /]cp\ *) install_cp=: ;; ++ *) install_cp=false ;; ++ esac ++ ++ # We need to accept at least all the BSD install flags. ++ dest= ++ files= ++ opts= ++ prev= ++ install_type= ++ isdir=no ++ stripme= ++ no_mode=: ++ for arg ++ do ++ arg2= ++ if test -n "$dest"; then ++ files="$files $dest" ++ dest=$arg ++ continue ++ fi ++ ++ case $arg in ++ -d) isdir=yes ;; ++ -f) ++ if $install_cp; then :; else ++ prev=$arg ++ fi ++ ;; ++ -g | -m | -o) ++ prev=$arg ++ ;; ++ -s) ++ stripme=" -s" ++ continue ++ ;; ++ -*) ++ ;; ++ *) ++ # If the previous option needed an argument, then skip it. ++ if test -n "$prev"; then ++ if test "x$prev" = x-m && test -n "$install_override_mode"; then ++ arg2=$install_override_mode ++ no_mode=false ++ fi ++ prev= ++ else ++ dest=$arg ++ continue ++ fi ++ ;; ++ esac ++ ++ # Aesthetically quote the argument. ++ func_quote_for_eval "$arg" ++ install_prog="$install_prog $func_quote_for_eval_result" ++ if test -n "$arg2"; then ++ func_quote_for_eval "$arg2" ++ fi ++ install_shared_prog="$install_shared_prog $func_quote_for_eval_result" ++ done ++ ++ test -z "$install_prog" && \ ++ func_fatal_help "you must specify an install program" ++ ++ test -n "$prev" && \ ++ func_fatal_help "the \`$prev' option requires an argument" ++ ++ if test -n "$install_override_mode" && $no_mode; then ++ if $install_cp; then :; else ++ func_quote_for_eval "$install_override_mode" ++ install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result" ++ fi ++ fi ++ ++ if test -z "$files"; then ++ if test -z "$dest"; then ++ func_fatal_help "no file or destination specified" ++ else ++ func_fatal_help "you must specify a destination" ++ fi ++ fi ++ ++ # Strip any trailing slash from the destination. ++ func_stripname '' '/' "$dest" ++ dest=$func_stripname_result ++ ++ # Check to see that the destination is a directory. ++ test -d "$dest" && isdir=yes ++ if test "$isdir" = yes; then ++ destdir="$dest" ++ destname= ++ else ++ func_dirname_and_basename "$dest" "" "." ++ destdir="$func_dirname_result" ++ destname="$func_basename_result" ++ ++ # Not a directory, so check to see that there is only one file specified. ++ set dummy $files; shift ++ test "$#" -gt 1 && \ ++ func_fatal_help "\`$dest' is not a directory" ++ fi ++ case $destdir in ++ [\\/]* | [A-Za-z]:[\\/]*) ;; ++ *) ++ for file in $files; do ++ case $file in ++ *.lo) ;; ++ *) ++ func_fatal_help "\`$destdir' must be an absolute directory name" ++ ;; ++ esac ++ done ++ ;; ++ esac ++ ++ # This variable tells wrapper scripts just to set variables rather ++ # than running their programs. ++ libtool_install_magic="$magic" ++ ++ staticlibs= ++ future_libdirs= ++ current_libdirs= ++ for file in $files; do ++ ++ # Do each installation. ++ case $file in ++ *.$libext) ++ # Do the static libraries later. ++ staticlibs="$staticlibs $file" ++ ;; ++ ++ *.la) ++ # Check to see that this really is a libtool archive. ++ func_lalib_unsafe_p "$file" \ ++ || func_fatal_help "\`$file' is not a valid libtool archive" ++ ++ library_names= ++ old_library= ++ relink_command= ++ func_source "$file" ++ ++ # Add the libdir to current_libdirs if it is the destination. ++ if test "X$destdir" = "X$libdir"; then ++ case "$current_libdirs " in ++ *" $libdir "*) ;; ++ *) current_libdirs="$current_libdirs $libdir" ;; ++ esac ++ else ++ # Note the libdir as a future libdir. ++ case "$future_libdirs " in ++ *" $libdir "*) ;; ++ *) future_libdirs="$future_libdirs $libdir" ;; ++ esac ++ fi ++ ++ func_dirname "$file" "/" "" ++ dir="$func_dirname_result" ++ dir="$dir$objdir" ++ ++ if test -n "$relink_command"; then ++ # Determine the prefix the user has applied to our future dir. ++ inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` ++ ++ # Don't allow the user to place us outside of our expected ++ # location b/c this prevents finding dependent libraries that ++ # are installed to the same prefix. ++ # At present, this check doesn't affect windows .dll's that ++ # are installed into $libdir/../bin (currently, that works fine) ++ # but it's something to keep an eye on. ++ test "$inst_prefix_dir" = "$destdir" && \ ++ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" ++ ++ if test -n "$inst_prefix_dir"; then ++ # Stick the inst_prefix_dir data into the link command. ++ relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` ++ else ++ relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` ++ fi ++ ++ func_warning "relinking \`$file'" ++ func_show_eval "$relink_command" \ ++ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' ++ fi ++ ++ # See the names of the shared library. ++ set dummy $library_names; shift ++ if test -n "$1"; then ++ realname="$1" ++ shift ++ ++ srcname="$realname" ++ test -n "$relink_command" && srcname="$realname"T ++ ++ # Install the shared library and build the symlinks. ++ func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ ++ 'exit $?' ++ tstripme="$stripme" ++ case $host_os in ++ cygwin* | mingw* | pw32* | cegcc*) ++ case $realname in ++ *.dll.a) ++ tstripme="" ++ ;; ++ esac ++ ;; ++ esac ++ if test -n "$tstripme" && test -n "$striplib"; then ++ func_show_eval "$striplib $destdir/$realname" 'exit $?' ++ fi ++ ++ if test "$#" -gt 0; then ++ # Delete the old symlinks, and create new ones. ++ # Try `ln -sf' first, because the `ln' binary might depend on ++ # the symlink we replace! Solaris /bin/ln does not understand -f, ++ # so we also need to try rm && ln -s. ++ for linkname ++ do ++ test "$linkname" != "$realname" \ ++ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" ++ done ++ fi ++ ++ # Do each command in the postinstall commands. ++ lib="$destdir/$realname" ++ func_execute_cmds "$postinstall_cmds" 'exit $?' ++ fi ++ ++ # Install the pseudo-library for information purposes. ++ func_basename "$file" ++ name="$func_basename_result" ++ instname="$dir/$name"i ++ func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' ++ ++ # Maybe install the static library, too. ++ test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" ++ ;; ++ ++ *.lo) ++ # Install (i.e. copy) a libtool object. ++ ++ # Figure out destination file name, if it wasn't already specified. ++ if test -n "$destname"; then ++ destfile="$destdir/$destname" ++ else ++ func_basename "$file" ++ destfile="$func_basename_result" ++ destfile="$destdir/$destfile" ++ fi ++ ++ # Deduce the name of the destination old-style object file. ++ case $destfile in ++ *.lo) ++ func_lo2o "$destfile" ++ staticdest=$func_lo2o_result ++ ;; ++ *.$objext) ++ staticdest="$destfile" ++ destfile= ++ ;; ++ *) ++ func_fatal_help "cannot copy a libtool object to \`$destfile'" ++ ;; ++ esac ++ ++ # Install the libtool object if requested. ++ test -n "$destfile" && \ ++ func_show_eval "$install_prog $file $destfile" 'exit $?' ++ ++ # Install the old object if enabled. ++ if test "$build_old_libs" = yes; then ++ # Deduce the name of the old-style object file. ++ func_lo2o "$file" ++ staticobj=$func_lo2o_result ++ func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' ++ fi ++ exit $EXIT_SUCCESS ++ ;; ++ ++ *) ++ # Figure out destination file name, if it wasn't already specified. ++ if test -n "$destname"; then ++ destfile="$destdir/$destname" ++ else ++ func_basename "$file" ++ destfile="$func_basename_result" ++ destfile="$destdir/$destfile" ++ fi ++ ++ # If the file is missing, and there is a .exe on the end, strip it ++ # because it is most likely a libtool script we actually want to ++ # install ++ stripped_ext="" ++ case $file in ++ *.exe) ++ if test ! -f "$file"; then ++ func_stripname '' '.exe' "$file" ++ file=$func_stripname_result ++ stripped_ext=".exe" ++ fi ++ ;; ++ esac ++ ++ # Do a test to see if this is really a libtool program. ++ case $host in ++ *cygwin* | *mingw*) ++ if func_ltwrapper_executable_p "$file"; then ++ func_ltwrapper_scriptname "$file" ++ wrapper=$func_ltwrapper_scriptname_result ++ else ++ func_stripname '' '.exe' "$file" ++ wrapper=$func_stripname_result ++ fi ++ ;; ++ *) ++ wrapper=$file ++ ;; ++ esac ++ if func_ltwrapper_script_p "$wrapper"; then ++ notinst_deplibs= ++ relink_command= ++ ++ func_source "$wrapper" ++ ++ # Check the variables that should have been set. ++ test -z "$generated_by_libtool_version" && \ ++ func_fatal_error "invalid libtool wrapper script \`$wrapper'" ++ ++ finalize=yes ++ for lib in $notinst_deplibs; do ++ # Check to see that each library is installed. ++ libdir= ++ if test -f "$lib"; then ++ func_source "$lib" ++ fi ++ libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test ++ if test -n "$libdir" && test ! -f "$libfile"; then ++ func_warning "\`$lib' has not been installed in \`$libdir'" ++ finalize=no ++ fi ++ done ++ ++ relink_command= ++ func_source "$wrapper" ++ ++ outputname= ++ if test "$fast_install" = no && test -n "$relink_command"; then ++ $opt_dry_run || { ++ if test "$finalize" = yes; then ++ tmpdir=`func_mktempdir` ++ func_basename "$file$stripped_ext" ++ file="$func_basename_result" ++ outputname="$tmpdir/$file" ++ # Replace the output file specification. ++ relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` ++ ++ $opt_silent || { ++ func_quote_for_expand "$relink_command" ++ eval "func_echo $func_quote_for_expand_result" ++ } ++ if eval "$relink_command"; then : ++ else ++ func_error "error: relink \`$file' with the above command before installing it" ++ $opt_dry_run || ${RM}r "$tmpdir" ++ continue ++ fi ++ file="$outputname" ++ else ++ func_warning "cannot relink \`$file'" ++ fi ++ } ++ else ++ # Install the binary that we compiled earlier. ++ file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` ++ fi ++ fi ++ ++ # remove .exe since cygwin /usr/bin/install will append another ++ # one anyway ++ case $install_prog,$host in ++ */usr/bin/install*,*cygwin*) ++ case $file:$destfile in ++ *.exe:*.exe) ++ # this is ok ++ ;; ++ *.exe:*) ++ destfile=$destfile.exe ++ ;; ++ *:*.exe) ++ func_stripname '' '.exe' "$destfile" ++ destfile=$func_stripname_result ++ ;; ++ esac ++ ;; ++ esac ++ func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' ++ $opt_dry_run || if test -n "$outputname"; then ++ ${RM}r "$tmpdir" ++ fi ++ ;; ++ esac ++ done ++ ++ for file in $staticlibs; do ++ func_basename "$file" ++ name="$func_basename_result" ++ ++ # Set up the ranlib parameters. ++ oldlib="$destdir/$name" ++ ++ func_show_eval "$install_prog \$file \$oldlib" 'exit $?' ++ ++ if test -n "$stripme" && test -n "$old_striplib"; then ++ func_show_eval "$old_striplib $oldlib" 'exit $?' ++ fi ++ ++ # Do each command in the postinstall commands. ++ func_execute_cmds "$old_postinstall_cmds" 'exit $?' ++ done ++ ++ test -n "$future_libdirs" && \ ++ func_warning "remember to run \`$progname --finish$future_libdirs'" ++ ++ if test -n "$current_libdirs" && $opt_finish; then ++ # Maybe just do a dry run. ++ $opt_dry_run && current_libdirs=" -n$current_libdirs" ++ exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' ++ else ++ exit $EXIT_SUCCESS ++ fi ++} ++ ++test "$mode" = install && func_mode_install ${1+"$@"} ++ ++ ++# func_generate_dlsyms outputname originator pic_p ++# Extract symbols from dlprefiles and create ${outputname}S.o with ++# a dlpreopen symbol table. ++func_generate_dlsyms () ++{ ++ $opt_debug ++ my_outputname="$1" ++ my_originator="$2" ++ my_pic_p="${3-no}" ++ my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` ++ my_dlsyms= ++ ++ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then ++ if test -n "$NM" && test -n "$global_symbol_pipe"; then ++ my_dlsyms="${my_outputname}S.c" ++ else ++ func_error "not configured to extract global symbols from dlpreopened files" ++ fi ++ fi ++ ++ if test -n "$my_dlsyms"; then ++ case $my_dlsyms in ++ "") ;; ++ *.c) ++ # Discover the nlist of each of the dlfiles. ++ nlist="$output_objdir/${my_outputname}.nm" ++ ++ func_show_eval "$RM $nlist ${nlist}S ${nlist}T" ++ ++ # Parse the name list into a source file. ++ func_verbose "creating $output_objdir/$my_dlsyms" ++ ++ $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ ++/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ ++/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ ++ ++#ifdef __cplusplus ++extern \"C\" { ++#endif ++ ++#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) ++#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" ++#endif ++ ++/* External symbol declarations for the compiler. */\ ++" ++ ++ if test "$dlself" = yes; then ++ func_verbose "generating symbol list for \`$output'" ++ ++ $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" ++ ++ # Add our own program objects to the symbol list. ++ progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` ++ for progfile in $progfiles; do ++ func_verbose "extracting global C symbols from \`$progfile'" ++ $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" ++ done ++ ++ if test -n "$exclude_expsyms"; then ++ $opt_dry_run || { ++ $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T ++ $MV "$nlist"T "$nlist" ++ } ++ fi ++ ++ if test -n "$export_symbols_regex"; then ++ $opt_dry_run || { ++ $EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T ++ $MV "$nlist"T "$nlist" ++ } ++ fi ++ ++ # Prepare the list of exported symbols ++ if test -z "$export_symbols"; then ++ export_symbols="$output_objdir/$outputname.exp" ++ $opt_dry_run || { ++ $RM $export_symbols ++ ${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' < "$nlist" > "$export_symbols" ++ case $host in ++ *cygwin* | *mingw* | *cegcc* ) ++ echo EXPORTS > "$output_objdir/$outputname.def" ++ cat "$export_symbols" >> "$output_objdir/$outputname.def" ++ ;; ++ esac ++ } ++ else ++ $opt_dry_run || { ++ ${SED} -e 's/\([].[*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/' < "$export_symbols" > "$output_objdir/$outputname.exp" ++ $GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T ++ $MV "$nlist"T "$nlist" ++ case $host in ++ *cygwin* | *mingw* | *cegcc* ) ++ echo EXPORTS > "$output_objdir/$outputname.def" ++ cat "$nlist" >> "$output_objdir/$outputname.def" ++ ;; ++ esac ++ } ++ fi ++ fi ++ ++ for dlprefile in $dlprefiles; do ++ func_verbose "extracting global C symbols from \`$dlprefile'" ++ func_basename "$dlprefile" ++ name="$func_basename_result" ++ $opt_dry_run || { ++ $ECHO ": $name " >> "$nlist" ++ eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" ++ } ++ done ++ ++ $opt_dry_run || { ++ # Make sure we have at least an empty file. ++ test -f "$nlist" || : > "$nlist" ++ ++ if test -n "$exclude_expsyms"; then ++ $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T ++ $MV "$nlist"T "$nlist" ++ fi ++ ++ # Try sorting and uniquifying the output. ++ if $GREP -v "^: " < "$nlist" | ++ if sort -k 3 /dev/null 2>&1; then ++ sort -k 3 ++ else ++ sort +2 ++ fi | ++ uniq > "$nlist"S; then ++ : ++ else ++ $GREP -v "^: " < "$nlist" > "$nlist"S ++ fi ++ ++ if test -f "$nlist"S; then ++ eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' ++ else ++ echo '/* NONE */' >> "$output_objdir/$my_dlsyms" ++ fi ++ ++ echo >> "$output_objdir/$my_dlsyms" "\ ++ ++/* The mapping between symbol names and symbols. */ ++typedef struct { ++ const char *name; ++ void *address; ++} lt_dlsymlist; ++" ++ case $host in ++ *cygwin* | *mingw* | *cegcc* ) ++ echo >> "$output_objdir/$my_dlsyms" "\ ++/* DATA imports from DLLs on WIN32 con't be const, because ++ runtime relocations are performed -- see ld's documentation ++ on pseudo-relocs. */" ++ lt_dlsym_const= ;; ++ *osf5*) ++ echo >> "$output_objdir/$my_dlsyms" "\ ++/* This system does not cope well with relocations in const data */" ++ lt_dlsym_const= ;; ++ *) ++ lt_dlsym_const=const ;; ++ esac ++ ++ echo >> "$output_objdir/$my_dlsyms" "\ ++extern $lt_dlsym_const lt_dlsymlist ++lt_${my_prefix}_LTX_preloaded_symbols[]; ++$lt_dlsym_const lt_dlsymlist ++lt_${my_prefix}_LTX_preloaded_symbols[] = ++{\ ++ { \"$my_originator\", (void *) 0 }," ++ ++ case $need_lib_prefix in ++ no) ++ eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ++ ;; ++ *) ++ eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ++ ;; ++ esac ++ echo >> "$output_objdir/$my_dlsyms" "\ ++ {0, (void *) 0} ++}; ++ ++/* This works around a problem in FreeBSD linker */ ++#ifdef FREEBSD_WORKAROUND ++static const void *lt_preloaded_setup() { ++ return lt_${my_prefix}_LTX_preloaded_symbols; ++} ++#endif ++ ++#ifdef __cplusplus ++} ++#endif\ ++" ++ } # !$opt_dry_run ++ ++ pic_flag_for_symtable= ++ case "$compile_command " in ++ *" -static "*) ;; ++ *) ++ case $host in ++ # compiling the symbol table file with pic_flag works around ++ # a FreeBSD bug that causes programs to crash when -lm is ++ # linked before any other PIC object. But we must not use ++ # pic_flag when linking with -static. The problem exists in ++ # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. ++ *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) ++ pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; ++ *-*-hpux*) ++ pic_flag_for_symtable=" $pic_flag" ;; ++ *) ++ if test "X$my_pic_p" != Xno; then ++ pic_flag_for_symtable=" $pic_flag" ++ fi ++ ;; ++ esac ++ ;; ++ esac ++ symtab_cflags= ++ for arg in $LTCFLAGS; do ++ case $arg in ++ -pie | -fpie | -fPIE) ;; ++ *) symtab_cflags="$symtab_cflags $arg" ;; ++ esac ++ done ++ ++ # Now compile the dynamic symbol file. ++ func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' ++ ++ # Clean up the generated files. ++ func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' ++ ++ # Transform the symbol file into the correct name. ++ symfileobj="$output_objdir/${my_outputname}S.$objext" ++ case $host in ++ *cygwin* | *mingw* | *cegcc* ) ++ if test -f "$output_objdir/$my_outputname.def"; then ++ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` ++ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` ++ else ++ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` ++ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ++ fi ++ ;; ++ *) ++ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` ++ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ++ ;; ++ esac ++ ;; ++ *) ++ func_fatal_error "unknown suffix for \`$my_dlsyms'" ++ ;; ++ esac ++ else ++ # We keep going just in case the user didn't refer to ++ # lt_preloaded_symbols. The linker will fail if global_symbol_pipe ++ # really was required. ++ ++ # Nullify the symbol file. ++ compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` ++ finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` ++ fi ++} ++ ++# func_win32_libid arg ++# return the library type of file 'arg' ++# ++# Need a lot of goo to handle *both* DLLs and import libs ++# Has to be a shell function in order to 'eat' the argument ++# that is supplied when $file_magic_command is called. ++# Despite the name, also deal with 64 bit binaries. ++func_win32_libid () ++{ ++ $opt_debug ++ win32_libid_type="unknown" ++ win32_fileres=`file -L $1 2>/dev/null` ++ case $win32_fileres in ++ *ar\ archive\ import\ library*) # definitely import ++ win32_libid_type="x86 archive import" ++ ;; ++ *ar\ archive*) # could be an import, or static ++ if $OBJDUMP -f "$1" | $SED -e '10q' 2>/dev/null | ++ $EGREP 'file format (pe-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then ++ win32_nmres=`$NM -f posix -A "$1" | ++ $SED -n -e ' ++ 1,100{ ++ / I /{ ++ s,.*,import, ++ p ++ q ++ } ++ }'` ++ case $win32_nmres in ++ import*) win32_libid_type="x86 archive import";; ++ *) win32_libid_type="x86 archive static";; ++ esac ++ fi ++ ;; ++ *DLL*) ++ win32_libid_type="x86 DLL" ++ ;; ++ *executable*) # but shell scripts are "executable" too... ++ case $win32_fileres in ++ *MS\ Windows\ PE\ Intel*) ++ win32_libid_type="x86 DLL" ++ ;; ++ esac ++ ;; ++ esac ++ $ECHO "$win32_libid_type" ++} ++ ++ ++ ++# func_extract_an_archive dir oldlib ++func_extract_an_archive () ++{ ++ $opt_debug ++ f_ex_an_ar_dir="$1"; shift ++ f_ex_an_ar_oldlib="$1" ++ if test "$lock_old_archive_extraction" = yes; then ++ lockfile=$f_ex_an_ar_oldlib.lock ++ until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do ++ func_echo "Waiting for $lockfile to be removed" ++ sleep 2 ++ done ++ fi ++ func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ ++ 'stat=$?; rm -f "$lockfile"; exit $stat' ++ if test "$lock_old_archive_extraction" = yes; then ++ $opt_dry_run || rm -f "$lockfile" ++ fi ++ if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then ++ : ++ else ++ func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" ++ fi ++} ++ ++ ++# func_extract_archives gentop oldlib ... ++func_extract_archives () ++{ ++ $opt_debug ++ my_gentop="$1"; shift ++ my_oldlibs=${1+"$@"} ++ my_oldobjs="" ++ my_xlib="" ++ my_xabs="" ++ my_xdir="" ++ ++ for my_xlib in $my_oldlibs; do ++ # Extract the objects. ++ case $my_xlib in ++ [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; ++ *) my_xabs=`pwd`"/$my_xlib" ;; ++ esac ++ func_basename "$my_xlib" ++ my_xlib="$func_basename_result" ++ my_xlib_u=$my_xlib ++ while :; do ++ case " $extracted_archives " in ++ *" $my_xlib_u "*) ++ func_arith $extracted_serial + 1 ++ extracted_serial=$func_arith_result ++ my_xlib_u=lt$extracted_serial-$my_xlib ;; ++ *) break ;; ++ esac ++ done ++ extracted_archives="$extracted_archives $my_xlib_u" ++ my_xdir="$my_gentop/$my_xlib_u" ++ ++ func_mkdir_p "$my_xdir" ++ ++ case $host in ++ *-darwin*) ++ func_verbose "Extracting $my_xabs" ++ # Do not bother doing anything if just a dry run ++ $opt_dry_run || { ++ darwin_orig_dir=`pwd` ++ cd $my_xdir || exit $? ++ darwin_archive=$my_xabs ++ darwin_curdir=`pwd` ++ darwin_base_archive=`basename "$darwin_archive"` ++ darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` ++ if test -n "$darwin_arches"; then ++ darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` ++ darwin_arch= ++ func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" ++ for darwin_arch in $darwin_arches ; do ++ func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" ++ $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" ++ cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" ++ func_extract_an_archive "`pwd`" "${darwin_base_archive}" ++ cd "$darwin_curdir" ++ $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" ++ done # $darwin_arches ++ ## Okay now we've a bunch of thin objects, gotta fatten them up :) ++ darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` ++ darwin_file= ++ darwin_files= ++ for darwin_file in $darwin_filelist; do ++ darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` ++ $LIPO -create -output "$darwin_file" $darwin_files ++ done # $darwin_filelist ++ $RM -rf unfat-$$ ++ cd "$darwin_orig_dir" ++ else ++ cd $darwin_orig_dir ++ func_extract_an_archive "$my_xdir" "$my_xabs" ++ fi # $darwin_arches ++ } # !$opt_dry_run ++ ;; ++ *) ++ func_extract_an_archive "$my_xdir" "$my_xabs" ++ ;; ++ esac ++ my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` ++ done ++ ++ func_extract_archives_result="$my_oldobjs" ++} ++ ++ ++# func_emit_wrapper [arg=no] ++# ++# Emit a libtool wrapper script on stdout. ++# Don't directly open a file because we may want to ++# incorporate the script contents within a cygwin/mingw ++# wrapper executable. Must ONLY be called from within ++# func_mode_link because it depends on a number of variables ++# set therein. ++# ++# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR ++# variable will take. If 'yes', then the emitted script ++# will assume that the directory in which it is stored is ++# the $objdir directory. This is a cygwin/mingw-specific ++# behavior. ++func_emit_wrapper () ++{ ++ func_emit_wrapper_arg1=${1-no} ++ ++ $ECHO "\ ++#! $SHELL ++ ++# $output - temporary wrapper script for $objdir/$outputname ++# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION ++# ++# The $output program cannot be directly executed until all the libtool ++# libraries that it depends on are installed. ++# ++# This wrapper script should never be moved out of the build directory. ++# If it is, it will not operate correctly. ++ ++# Sed substitution that helps us do robust quoting. It backslashifies ++# metacharacters that are still active within double-quoted strings. ++sed_quote_subst='$sed_quote_subst' ++ ++# Be Bourne compatible ++if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then ++ emulate sh ++ NULLCMD=: ++ # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which ++ # is contrary to our usage. Disable this feature. ++ alias -g '\${1+\"\$@\"}'='\"\$@\"' ++ setopt NO_GLOB_SUBST ++else ++ case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac ++fi ++BIN_SH=xpg4; export BIN_SH # for Tru64 ++DUALCASE=1; export DUALCASE # for MKS sh ++ ++# The HP-UX ksh and POSIX shell print the target directory to stdout ++# if CDPATH is set. ++(unset CDPATH) >/dev/null 2>&1 && unset CDPATH ++ ++relink_command=\"$relink_command\" ++ ++# This environment variable determines our operation mode. ++if test \"\$libtool_install_magic\" = \"$magic\"; then ++ # install mode needs the following variables: ++ generated_by_libtool_version='$macro_version' ++ notinst_deplibs='$notinst_deplibs' ++else ++ # When we are sourced in execute mode, \$file and \$ECHO are already set. ++ if test \"\$libtool_execute_magic\" != \"$magic\"; then ++ file=\"\$0\"" ++ ++ qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` ++ $ECHO "\ ++ ++# A function that is used when there is no print builtin or printf. ++func_fallback_echo () ++{ ++ eval 'cat <<_LTECHO_EOF ++\$1 ++_LTECHO_EOF' ++} ++ ECHO=\"$qECHO\" ++ fi\ ++ ++ # Find the directory that this script lives in. ++ thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` ++ test \"x\$thisdir\" = \"x\$file\" && thisdir=. ++ ++ # Follow symbolic links until we get to the real thisdir. ++ file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` ++ while test -n \"\$file\"; do ++ destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` ++ ++ # If there was a directory component, then change thisdir. ++ if test \"x\$destdir\" != \"x\$file\"; then ++ case \"\$destdir\" in ++ [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; ++ *) thisdir=\"\$thisdir/\$destdir\" ;; ++ esac ++ fi ++ ++ file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` ++ file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` ++ done ++ ++ # Usually 'no', except on cygwin/mingw when embedded into ++ # the cwrapper. ++ WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 ++ if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then ++ # special case for '.' ++ if test \"\$thisdir\" = \".\"; then ++ thisdir=\`pwd\` ++ fi ++ # remove .libs from thisdir ++ case \"\$thisdir\" in ++ *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; ++ $objdir ) thisdir=. ;; ++ esac ++ fi ++ ++ # Try to get the absolute directory name. ++ absdir=\`cd \"\$thisdir\" && pwd\` ++ test -n \"\$absdir\" && thisdir=\"\$absdir\" ++" ++ ++ if test "$fast_install" = yes; then ++ $ECHO "\ ++ program=lt-'$outputname'$exeext ++ progdir=\"\$thisdir/$objdir\" ++ ++ if test ! -f \"\$progdir/\$program\" || ++ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ ++ test \"X\$file\" != \"X\$progdir/\$program\"; }; then ++ ++ file=\"\$\$-\$program\" ++ ++ if test ! -d \"\$progdir\"; then ++ $MKDIR \"\$progdir\" ++ else ++ $RM \"\$progdir/\$file\" ++ fi" ++ ++ $ECHO "\ ++ ++ # relink executable if necessary ++ if test -n \"\$relink_command\"; then ++ if relink_command_output=\`eval \"\$relink_command\" 2>&1\`; then : ++ else ++ $ECHO \"\$relink_command_output\" >&2 ++ $RM \"\$progdir/\$file\" ++ exit 1 ++ fi ++ fi ++ ++ $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || ++ { $RM \"\$progdir/\$program\"; ++ $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } ++ $RM \"\$progdir/\$file\" ++ fi" ++ else ++ $ECHO "\ ++ program='$outputname' ++ progdir=\"\$thisdir/$objdir\" ++" ++ fi ++ ++ $ECHO "\ ++ ++ if test -f \"\$progdir/\$program\"; then" ++ ++ # Export our shlibpath_var if we have one. ++ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then ++ $ECHO "\ ++ # Add our own library path to $shlibpath_var ++ $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" ++ ++ # Some systems cannot cope with colon-terminated $shlibpath_var ++ # The second colon is a workaround for a bug in BeOS R4 sed ++ $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` ++ ++ export $shlibpath_var ++" ++ fi ++ ++ # fixup the dll searchpath if we need to. ++ if test -n "$dllsearchpath"; then ++ $ECHO "\ ++ # Add the dll search path components to the executable PATH ++ PATH=$dllsearchpath:\$PATH ++" ++ fi ++ ++ $ECHO "\ ++ if test \"\$libtool_execute_magic\" != \"$magic\"; then ++ # Run the actual program with our arguments. ++" ++ case $host in ++ # Backslashes separate directories on plain windows ++ *-*-mingw | *-*-os2* | *-cegcc*) ++ $ECHO "\ ++ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} ++" ++ ;; ++ ++ *) ++ $ECHO "\ ++ exec \"\$progdir/\$program\" \${1+\"\$@\"} ++" ++ ;; ++ esac ++ $ECHO "\ ++ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 ++ exit 1 ++ fi ++ else ++ # The program doesn't exist. ++ \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 ++ \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 ++ \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 ++ exit 1 ++ fi ++fi\ ++" ++} ++ ++ ++# func_to_host_path arg ++# ++# Convert paths to host format when used with build tools. ++# Intended for use with "native" mingw (where libtool itself ++# is running under the msys shell), or in the following cross- ++# build environments: ++# $build $host ++# mingw (msys) mingw [e.g. native] ++# cygwin mingw ++# *nix + wine mingw ++# where wine is equipped with the `winepath' executable. ++# In the native mingw case, the (msys) shell automatically ++# converts paths for any non-msys applications it launches, ++# but that facility isn't available from inside the cwrapper. ++# Similar accommodations are necessary for $host mingw and ++# $build cygwin. Calling this function does no harm for other ++# $host/$build combinations not listed above. ++# ++# ARG is the path (on $build) that should be converted to ++# the proper representation for $host. The result is stored ++# in $func_to_host_path_result. ++func_to_host_path () ++{ ++ func_to_host_path_result="$1" ++ if test -n "$1"; then ++ case $host in ++ *mingw* ) ++ lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' ++ case $build in ++ *mingw* ) # actually, msys ++ # awkward: cmd appends spaces to result ++ func_to_host_path_result=`( cmd //c echo "$1" ) 2>/dev/null | ++ $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` ++ ;; ++ *cygwin* ) ++ func_to_host_path_result=`cygpath -w "$1" | ++ $SED -e "$lt_sed_naive_backslashify"` ++ ;; ++ * ) ++ # Unfortunately, winepath does not exit with a non-zero ++ # error code, so we are forced to check the contents of ++ # stdout. On the other hand, if the command is not ++ # found, the shell will set an exit code of 127 and print ++ # *an error message* to stdout. So we must check for both ++ # error code of zero AND non-empty stdout, which explains ++ # the odd construction: ++ func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` ++ if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then ++ func_to_host_path_result=`$ECHO "$func_to_host_path_tmp1" | ++ $SED -e "$lt_sed_naive_backslashify"` ++ else ++ # Allow warning below. ++ func_to_host_path_result= ++ fi ++ ;; ++ esac ++ if test -z "$func_to_host_path_result" ; then ++ func_error "Could not determine host path corresponding to" ++ func_error " \`$1'" ++ func_error "Continuing, but uninstalled executables may not work." ++ # Fallback: ++ func_to_host_path_result="$1" ++ fi ++ ;; ++ esac ++ fi ++} ++# end: func_to_host_path ++ ++# func_to_host_pathlist arg ++# ++# Convert pathlists to host format when used with build tools. ++# See func_to_host_path(), above. This function supports the ++# following $build/$host combinations (but does no harm for ++# combinations not listed here): ++# $build $host ++# mingw (msys) mingw [e.g. native] ++# cygwin mingw ++# *nix + wine mingw ++# ++# Path separators are also converted from $build format to ++# $host format. If ARG begins or ends with a path separator ++# character, it is preserved (but converted to $host format) ++# on output. ++# ++# ARG is a pathlist (on $build) that should be converted to ++# the proper representation on $host. The result is stored ++# in $func_to_host_pathlist_result. ++func_to_host_pathlist () ++{ ++ func_to_host_pathlist_result="$1" ++ if test -n "$1"; then ++ case $host in ++ *mingw* ) ++ lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' ++ # Remove leading and trailing path separator characters from ++ # ARG. msys behavior is inconsistent here, cygpath turns them ++ # into '.;' and ';.', and winepath ignores them completely. ++ func_stripname : : "$1" ++ func_to_host_pathlist_tmp1=$func_stripname_result ++ case $build in ++ *mingw* ) # Actually, msys. ++ # Awkward: cmd appends spaces to result. ++ func_to_host_pathlist_result=` ++ ( cmd //c echo "$func_to_host_pathlist_tmp1" ) 2>/dev/null | ++ $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` ++ ;; ++ *cygwin* ) ++ func_to_host_pathlist_result=`cygpath -w -p "$func_to_host_pathlist_tmp1" | ++ $SED -e "$lt_sed_naive_backslashify"` ++ ;; ++ * ) ++ # unfortunately, winepath doesn't convert pathlists ++ func_to_host_pathlist_result="" ++ func_to_host_pathlist_oldIFS=$IFS ++ IFS=: ++ for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do ++ IFS=$func_to_host_pathlist_oldIFS ++ if test -n "$func_to_host_pathlist_f" ; then ++ func_to_host_path "$func_to_host_pathlist_f" ++ if test -n "$func_to_host_path_result" ; then ++ if test -z "$func_to_host_pathlist_result" ; then ++ func_to_host_pathlist_result="$func_to_host_path_result" ++ else ++ func_append func_to_host_pathlist_result ";$func_to_host_path_result" ++ fi ++ fi ++ fi ++ done ++ IFS=$func_to_host_pathlist_oldIFS ++ ;; ++ esac ++ if test -z "$func_to_host_pathlist_result"; then ++ func_error "Could not determine the host path(s) corresponding to" ++ func_error " \`$1'" ++ func_error "Continuing, but uninstalled executables may not work." ++ # Fallback. This may break if $1 contains DOS-style drive ++ # specifications. The fix is not to complicate the expression ++ # below, but for the user to provide a working wine installation ++ # with winepath so that path translation in the cross-to-mingw ++ # case works properly. ++ lt_replace_pathsep_nix_to_dos="s|:|;|g" ++ func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ ++ $SED -e "$lt_replace_pathsep_nix_to_dos"` ++ fi ++ # Now, add the leading and trailing path separators back ++ case "$1" in ++ :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" ++ ;; ++ esac ++ case "$1" in ++ *: ) func_append func_to_host_pathlist_result ";" ++ ;; ++ esac ++ ;; ++ esac ++ fi ++} ++# end: func_to_host_pathlist ++ ++# func_emit_cwrapperexe_src ++# emit the source code for a wrapper executable on stdout ++# Must ONLY be called from within func_mode_link because ++# it depends on a number of variable set therein. ++func_emit_cwrapperexe_src () ++{ ++ cat < ++#include ++#ifdef _MSC_VER ++# include ++# include ++# include ++#else ++# include ++# include ++# ifdef __CYGWIN__ ++# include ++# endif ++#endif ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* declarations of non-ANSI functions */ ++#if defined(__MINGW32__) ++# ifdef __STRICT_ANSI__ ++int _putenv (const char *); ++# endif ++#elif defined(__CYGWIN__) ++# ifdef __STRICT_ANSI__ ++char *realpath (const char *, char *); ++int putenv (char *); ++int setenv (const char *, const char *, int); ++# endif ++/* #elif defined (other platforms) ... */ ++#endif ++ ++/* portability defines, excluding path handling macros */ ++#if defined(_MSC_VER) ++# define setmode _setmode ++# define stat _stat ++# define chmod _chmod ++# define getcwd _getcwd ++# define putenv _putenv ++# define S_IXUSR _S_IEXEC ++# ifndef _INTPTR_T_DEFINED ++# define _INTPTR_T_DEFINED ++# define intptr_t int ++# endif ++#elif defined(__MINGW32__) ++# define setmode _setmode ++# define stat _stat ++# define chmod _chmod ++# define getcwd _getcwd ++# define putenv _putenv ++#elif defined(__CYGWIN__) ++# define HAVE_SETENV ++# define FOPEN_WB "wb" ++/* #elif defined (other platforms) ... */ ++#endif ++ ++#if defined(PATH_MAX) ++# define LT_PATHMAX PATH_MAX ++#elif defined(MAXPATHLEN) ++# define LT_PATHMAX MAXPATHLEN ++#else ++# define LT_PATHMAX 1024 ++#endif ++ ++#ifndef S_IXOTH ++# define S_IXOTH 0 ++#endif ++#ifndef S_IXGRP ++# define S_IXGRP 0 ++#endif ++ ++/* path handling portability macros */ ++#ifndef DIR_SEPARATOR ++# define DIR_SEPARATOR '/' ++# define PATH_SEPARATOR ':' ++#endif ++ ++#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ ++ defined (__OS2__) ++# define HAVE_DOS_BASED_FILE_SYSTEM ++# define FOPEN_WB "wb" ++# ifndef DIR_SEPARATOR_2 ++# define DIR_SEPARATOR_2 '\\' ++# endif ++# ifndef PATH_SEPARATOR_2 ++# define PATH_SEPARATOR_2 ';' ++# endif ++#endif ++ ++#ifndef DIR_SEPARATOR_2 ++# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) ++#else /* DIR_SEPARATOR_2 */ ++# define IS_DIR_SEPARATOR(ch) \ ++ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) ++#endif /* DIR_SEPARATOR_2 */ ++ ++#ifndef PATH_SEPARATOR_2 ++# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) ++#else /* PATH_SEPARATOR_2 */ ++# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) ++#endif /* PATH_SEPARATOR_2 */ ++ ++#ifndef FOPEN_WB ++# define FOPEN_WB "w" ++#endif ++#ifndef _O_BINARY ++# define _O_BINARY 0 ++#endif ++ ++#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) ++#define XFREE(stale) do { \ ++ if (stale) { free ((void *) stale); stale = 0; } \ ++} while (0) ++ ++#undef LTWRAPPER_DEBUGPRINTF ++#if defined LT_DEBUGWRAPPER ++# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args ++static void ++ltwrapper_debugprintf (const char *fmt, ...) ++{ ++ va_list args; ++ va_start (args, fmt); ++ (void) vfprintf (stderr, fmt, args); ++ va_end (args); ++} ++#else ++# define LTWRAPPER_DEBUGPRINTF(args) ++#endif ++ ++const char *program_name = NULL; ++ ++void *xmalloc (size_t num); ++char *xstrdup (const char *string); ++const char *base_name (const char *name); ++char *find_executable (const char *wrapper); ++char *chase_symlinks (const char *pathspec); ++int make_executable (const char *path); ++int check_executable (const char *path); ++char *strendzap (char *str, const char *pat); ++void lt_fatal (const char *message, ...); ++void lt_setenv (const char *name, const char *value); ++char *lt_extend_str (const char *orig_value, const char *add, int to_end); ++void lt_update_exe_path (const char *name, const char *value); ++void lt_update_lib_path (const char *name, const char *value); ++char **prepare_spawn (char **argv); ++void lt_dump_script (FILE *f); ++EOF ++ ++ cat <"))); ++ for (i = 0; i < newargc; i++) ++ { ++ LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : ""))); ++ } ++ ++EOF ++ ++ case $host_os in ++ mingw*) ++ cat <<"EOF" ++ /* execv doesn't actually work on mingw as expected on unix */ ++ newargz = prepare_spawn (newargz); ++ rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); ++ if (rval == -1) ++ { ++ /* failed to start process */ ++ LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno)); ++ return 127; ++ } ++ return rval; ++EOF ++ ;; ++ *) ++ cat <<"EOF" ++ execv (lt_argv_zero, newargz); ++ return rval; /* =127, but avoids unused variable warning */ ++EOF ++ ;; ++ esac ++ ++ cat <<"EOF" ++} ++ ++void * ++xmalloc (size_t num) ++{ ++ void *p = (void *) malloc (num); ++ if (!p) ++ lt_fatal ("Memory exhausted"); ++ ++ return p; ++} ++ ++char * ++xstrdup (const char *string) ++{ ++ return string ? strcpy ((char *) xmalloc (strlen (string) + 1), ++ string) : NULL; ++} ++ ++const char * ++base_name (const char *name) ++{ ++ const char *base; ++ ++#if defined (HAVE_DOS_BASED_FILE_SYSTEM) ++ /* Skip over the disk name in MSDOS pathnames. */ ++ if (isalpha ((unsigned char) name[0]) && name[1] == ':') ++ name += 2; ++#endif ++ ++ for (base = name; *name; name++) ++ if (IS_DIR_SEPARATOR (*name)) ++ base = name + 1; ++ return base; ++} ++ ++int ++check_executable (const char *path) ++{ ++ struct stat st; ++ ++ LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n", ++ path ? (*path ? path : "EMPTY!") : "NULL!")); ++ if ((!path) || (!*path)) ++ return 0; ++ ++ if ((stat (path, &st) >= 0) ++ && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) ++ return 1; ++ else ++ return 0; ++} ++ ++int ++make_executable (const char *path) ++{ ++ int rval = 0; ++ struct stat st; ++ ++ LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", ++ path ? (*path ? path : "EMPTY!") : "NULL!")); ++ if ((!path) || (!*path)) ++ return 0; ++ ++ if (stat (path, &st) >= 0) ++ { ++ rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); ++ } ++ return rval; ++} ++ ++/* Searches for the full path of the wrapper. Returns ++ newly allocated full path name if found, NULL otherwise ++ Does not chase symlinks, even on platforms that support them. ++*/ ++char * ++find_executable (const char *wrapper) ++{ ++ int has_slash = 0; ++ const char *p; ++ const char *p_next; ++ /* static buffer for getcwd */ ++ char tmp[LT_PATHMAX + 1]; ++ int tmp_len; ++ char *concat_name; ++ ++ LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", ++ wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); ++ ++ if ((wrapper == NULL) || (*wrapper == '\0')) ++ return NULL; ++ ++ /* Absolute path? */ ++#if defined (HAVE_DOS_BASED_FILE_SYSTEM) ++ if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') ++ { ++ concat_name = xstrdup (wrapper); ++ if (check_executable (concat_name)) ++ return concat_name; ++ XFREE (concat_name); ++ } ++ else ++ { ++#endif ++ if (IS_DIR_SEPARATOR (wrapper[0])) ++ { ++ concat_name = xstrdup (wrapper); ++ if (check_executable (concat_name)) ++ return concat_name; ++ XFREE (concat_name); ++ } ++#if defined (HAVE_DOS_BASED_FILE_SYSTEM) ++ } ++#endif ++ ++ for (p = wrapper; *p; p++) ++ if (*p == '/') ++ { ++ has_slash = 1; ++ break; ++ } ++ if (!has_slash) ++ { ++ /* no slashes; search PATH */ ++ const char *path = getenv ("PATH"); ++ if (path != NULL) ++ { ++ for (p = path; *p; p = p_next) ++ { ++ const char *q; ++ size_t p_len; ++ for (q = p; *q; q++) ++ if (IS_PATH_SEPARATOR (*q)) ++ break; ++ p_len = q - p; ++ p_next = (*q == '\0' ? q : q + 1); ++ if (p_len == 0) ++ { ++ /* empty path: current directory */ ++ if (getcwd (tmp, LT_PATHMAX) == NULL) ++ lt_fatal ("getcwd failed"); ++ tmp_len = strlen (tmp); ++ concat_name = ++ XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); ++ memcpy (concat_name, tmp, tmp_len); ++ concat_name[tmp_len] = '/'; ++ strcpy (concat_name + tmp_len + 1, wrapper); ++ } ++ else ++ { ++ concat_name = ++ XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); ++ memcpy (concat_name, p, p_len); ++ concat_name[p_len] = '/'; ++ strcpy (concat_name + p_len + 1, wrapper); ++ } ++ if (check_executable (concat_name)) ++ return concat_name; ++ XFREE (concat_name); ++ } ++ } ++ /* not found in PATH; assume curdir */ ++ } ++ /* Relative path | not found in path: prepend cwd */ ++ if (getcwd (tmp, LT_PATHMAX) == NULL) ++ lt_fatal ("getcwd failed"); ++ tmp_len = strlen (tmp); ++ concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); ++ memcpy (concat_name, tmp, tmp_len); ++ concat_name[tmp_len] = '/'; ++ strcpy (concat_name + tmp_len + 1, wrapper); ++ ++ if (check_executable (concat_name)) ++ return concat_name; ++ XFREE (concat_name); ++ return NULL; ++} ++ ++char * ++chase_symlinks (const char *pathspec) ++{ ++#ifndef S_ISLNK ++ return xstrdup (pathspec); ++#else ++ char buf[LT_PATHMAX]; ++ struct stat s; ++ char *tmp_pathspec = xstrdup (pathspec); ++ char *p; ++ int has_symlinks = 0; ++ while (strlen (tmp_pathspec) && !has_symlinks) ++ { ++ LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n", ++ tmp_pathspec)); ++ if (lstat (tmp_pathspec, &s) == 0) ++ { ++ if (S_ISLNK (s.st_mode) != 0) ++ { ++ has_symlinks = 1; ++ break; ++ } ++ ++ /* search backwards for last DIR_SEPARATOR */ ++ p = tmp_pathspec + strlen (tmp_pathspec) - 1; ++ while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) ++ p--; ++ if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) ++ { ++ /* no more DIR_SEPARATORS left */ ++ break; ++ } ++ *p = '\0'; ++ } ++ else ++ { ++ char *errstr = strerror (errno); ++ lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); ++ } ++ } ++ XFREE (tmp_pathspec); ++ ++ if (!has_symlinks) ++ { ++ return xstrdup (pathspec); ++ } ++ ++ tmp_pathspec = realpath (pathspec, buf); ++ if (tmp_pathspec == 0) ++ { ++ lt_fatal ("Could not follow symlinks for %s", pathspec); ++ } ++ return xstrdup (tmp_pathspec); ++#endif ++} ++ ++char * ++strendzap (char *str, const char *pat) ++{ ++ size_t len, patlen; ++ ++ assert (str != NULL); ++ assert (pat != NULL); ++ ++ len = strlen (str); ++ patlen = strlen (pat); ++ ++ if (patlen <= len) ++ { ++ str += len - patlen; ++ if (strcmp (str, pat) == 0) ++ *str = '\0'; ++ } ++ return str; ++} ++ ++static void ++lt_error_core (int exit_status, const char *mode, ++ const char *message, va_list ap) ++{ ++ fprintf (stderr, "%s: %s: ", program_name, mode); ++ vfprintf (stderr, message, ap); ++ fprintf (stderr, ".\n"); ++ ++ if (exit_status >= 0) ++ exit (exit_status); ++} ++ ++void ++lt_fatal (const char *message, ...) ++{ ++ va_list ap; ++ va_start (ap, message); ++ lt_error_core (EXIT_FAILURE, "FATAL", message, ap); ++ va_end (ap); ++} ++ ++void ++lt_setenv (const char *name, const char *value) ++{ ++ LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n", ++ (name ? name : ""), ++ (value ? value : ""))); ++ { ++#ifdef HAVE_SETENV ++ /* always make a copy, for consistency with !HAVE_SETENV */ ++ char *str = xstrdup (value); ++ setenv (name, str, 1); ++#else ++ int len = strlen (name) + 1 + strlen (value) + 1; ++ char *str = XMALLOC (char, len); ++ sprintf (str, "%s=%s", name, value); ++ if (putenv (str) != EXIT_SUCCESS) ++ { ++ XFREE (str); ++ } ++#endif ++ } ++} ++ ++char * ++lt_extend_str (const char *orig_value, const char *add, int to_end) ++{ ++ char *new_value; ++ if (orig_value && *orig_value) ++ { ++ int orig_value_len = strlen (orig_value); ++ int add_len = strlen (add); ++ new_value = XMALLOC (char, add_len + orig_value_len + 1); ++ if (to_end) ++ { ++ strcpy (new_value, orig_value); ++ strcpy (new_value + orig_value_len, add); ++ } ++ else ++ { ++ strcpy (new_value, add); ++ strcpy (new_value + add_len, orig_value); ++ } ++ } ++ else ++ { ++ new_value = xstrdup (add); ++ } ++ return new_value; ++} ++ ++void ++lt_update_exe_path (const char *name, const char *value) ++{ ++ LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n", ++ (name ? name : ""), ++ (value ? value : ""))); ++ ++ if (name && *name && value && *value) ++ { ++ char *new_value = lt_extend_str (getenv (name), value, 0); ++ /* some systems can't cope with a ':'-terminated path #' */ ++ int len = strlen (new_value); ++ while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) ++ { ++ new_value[len-1] = '\0'; ++ } ++ lt_setenv (name, new_value); ++ XFREE (new_value); ++ } ++} ++ ++void ++lt_update_lib_path (const char *name, const char *value) ++{ ++ LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n", ++ (name ? name : ""), ++ (value ? value : ""))); ++ ++ if (name && *name && value && *value) ++ { ++ char *new_value = lt_extend_str (getenv (name), value, 0); ++ lt_setenv (name, new_value); ++ XFREE (new_value); ++ } ++} ++ ++EOF ++ case $host_os in ++ mingw*) ++ cat <<"EOF" ++ ++/* Prepares an argument vector before calling spawn(). ++ Note that spawn() does not by itself call the command interpreter ++ (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ++ ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); ++ GetVersionEx(&v); ++ v.dwPlatformId == VER_PLATFORM_WIN32_NT; ++ }) ? "cmd.exe" : "command.com"). ++ Instead it simply concatenates the arguments, separated by ' ', and calls ++ CreateProcess(). We must quote the arguments since Win32 CreateProcess() ++ interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a ++ special way: ++ - Space and tab are interpreted as delimiters. They are not treated as ++ delimiters if they are surrounded by double quotes: "...". ++ - Unescaped double quotes are removed from the input. Their only effect is ++ that within double quotes, space and tab are treated like normal ++ characters. ++ - Backslashes not followed by double quotes are not special. ++ - But 2*n+1 backslashes followed by a double quote become ++ n backslashes followed by a double quote (n >= 0): ++ \" -> " ++ \\\" -> \" ++ \\\\\" -> \\" ++ */ ++#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" ++#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" ++char ** ++prepare_spawn (char **argv) ++{ ++ size_t argc; ++ char **new_argv; ++ size_t i; ++ ++ /* Count number of arguments. */ ++ for (argc = 0; argv[argc] != NULL; argc++) ++ ; ++ ++ /* Allocate new argument vector. */ ++ new_argv = XMALLOC (char *, argc + 1); ++ ++ /* Put quoted arguments into the new argument vector. */ ++ for (i = 0; i < argc; i++) ++ { ++ const char *string = argv[i]; ++ ++ if (string[0] == '\0') ++ new_argv[i] = xstrdup ("\"\""); ++ else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) ++ { ++ int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); ++ size_t length; ++ unsigned int backslashes; ++ const char *s; ++ char *quoted_string; ++ char *p; ++ ++ length = 0; ++ backslashes = 0; ++ if (quote_around) ++ length++; ++ for (s = string; *s != '\0'; s++) ++ { ++ char c = *s; ++ if (c == '"') ++ length += backslashes + 1; ++ length++; ++ if (c == '\\') ++ backslashes++; ++ else ++ backslashes = 0; ++ } ++ if (quote_around) ++ length += backslashes + 1; ++ ++ quoted_string = XMALLOC (char, length + 1); ++ ++ p = quoted_string; ++ backslashes = 0; ++ if (quote_around) ++ *p++ = '"'; ++ for (s = string; *s != '\0'; s++) ++ { ++ char c = *s; ++ if (c == '"') ++ { ++ unsigned int j; ++ for (j = backslashes + 1; j > 0; j--) ++ *p++ = '\\'; ++ } ++ *p++ = c; ++ if (c == '\\') ++ backslashes++; ++ else ++ backslashes = 0; ++ } ++ if (quote_around) ++ { ++ unsigned int j; ++ for (j = backslashes; j > 0; j--) ++ *p++ = '\\'; ++ *p++ = '"'; ++ } ++ *p = '\0'; ++ ++ new_argv[i] = quoted_string; ++ } ++ else ++ new_argv[i] = (char *) string; ++ } ++ new_argv[argc] = NULL; ++ ++ return new_argv; ++} ++EOF ++ ;; ++ esac ++ ++ cat <<"EOF" ++void lt_dump_script (FILE* f) ++{ ++EOF ++ func_emit_wrapper yes | ++ $SED -e 's/\([\\"]\)/\\\1/g' \ ++ -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' ++ ++ cat <<"EOF" ++} ++EOF ++} ++# end: func_emit_cwrapperexe_src ++ ++# func_win32_import_lib_p ARG ++# True if ARG is an import lib, as indicated by $file_magic_cmd ++func_win32_import_lib_p () ++{ ++ $opt_debug ++ case `eval "$file_magic_cmd \"\$1\" 2>/dev/null" | $SED -e 10q` in ++ *import*) : ;; ++ *) false ;; ++ esac ++} ++ ++# func_mode_link arg... ++func_mode_link () ++{ ++ $opt_debug ++ case $host in ++ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) ++ # It is impossible to link a dll without this setting, and ++ # we shouldn't force the makefile maintainer to figure out ++ # which system we are compiling for in order to pass an extra ++ # flag for every libtool invocation. ++ # allow_undefined=no ++ ++ # FIXME: Unfortunately, there are problems with the above when trying ++ # to make a dll which has undefined symbols, in which case not ++ # even a static library is built. For now, we need to specify ++ # -no-undefined on the libtool link line when we can be certain ++ # that all symbols are satisfied, otherwise we get a static library. ++ allow_undefined=yes ++ ;; ++ *) ++ allow_undefined=yes ++ ;; ++ esac ++ libtool_args=$nonopt ++ base_compile="$nonopt $@" ++ compile_command=$nonopt ++ finalize_command=$nonopt ++ ++ compile_rpath= ++ finalize_rpath= ++ compile_shlibpath= ++ finalize_shlibpath= ++ convenience= ++ old_convenience= ++ deplibs= ++ old_deplibs= ++ compiler_flags= ++ linker_flags= ++ dllsearchpath= ++ lib_search_path=`pwd` ++ inst_prefix_dir= ++ new_inherited_linker_flags= ++ ++ avoid_version=no ++ bindir= ++ dlfiles= ++ dlprefiles= ++ dlself=no ++ export_dynamic=no ++ export_symbols= ++ export_symbols_regex= ++ generated= ++ libobjs= ++ ltlibs= ++ module=no ++ no_install=no ++ objs= ++ non_pic_objects= ++ precious_files_regex= ++ prefer_static_libs=no ++ preload=no ++ prev= ++ prevarg= ++ release= ++ rpath= ++ xrpath= ++ perm_rpath= ++ temp_rpath= ++ thread_safe=no ++ vinfo= ++ vinfo_number=no ++ weak_libs= ++ single_module="${wl}-single_module" ++ func_infer_tag $base_compile ++ ++ # We need to know -static, to get the right output filenames. ++ for arg ++ do ++ case $arg in ++ -shared) ++ test "$build_libtool_libs" != yes && \ ++ func_fatal_configuration "can not build a shared library" ++ build_old_libs=no ++ break ++ ;; ++ -all-static | -static | -static-libtool-libs) ++ case $arg in ++ -all-static) ++ if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then ++ func_warning "complete static linking is impossible in this configuration" ++ fi ++ if test -n "$link_static_flag"; then ++ dlopen_self=$dlopen_self_static ++ fi ++ prefer_static_libs=yes ++ ;; ++ -static) ++ if test -z "$pic_flag" && test -n "$link_static_flag"; then ++ dlopen_self=$dlopen_self_static ++ fi ++ prefer_static_libs=built ++ ;; ++ -static-libtool-libs) ++ if test -z "$pic_flag" && test -n "$link_static_flag"; then ++ dlopen_self=$dlopen_self_static ++ fi ++ prefer_static_libs=yes ++ ;; ++ esac ++ build_libtool_libs=no ++ build_old_libs=yes ++ break ++ ;; ++ esac ++ done ++ ++ # See if our shared archives depend on static archives. ++ test -n "$old_archive_from_new_cmds" && build_old_libs=yes ++ ++ # Go through the arguments, transforming them on the way. ++ while test "$#" -gt 0; do ++ arg="$1" ++ shift ++ func_quote_for_eval "$arg" ++ qarg=$func_quote_for_eval_unquoted_result ++ func_append libtool_args " $func_quote_for_eval_result" ++ ++ # If the previous option needs an argument, assign it. ++ if test -n "$prev"; then ++ case $prev in ++ output) ++ func_append compile_command " @OUTPUT@" ++ func_append finalize_command " @OUTPUT@" ++ ;; ++ esac ++ ++ case $prev in ++ bindir) ++ bindir="$arg" ++ prev= ++ continue ++ ;; ++ dlfiles|dlprefiles) ++ if test "$preload" = no; then ++ # Add the symbol object into the linking commands. ++ func_append compile_command " @SYMFILE@" ++ func_append finalize_command " @SYMFILE@" ++ preload=yes ++ fi ++ case $arg in ++ *.la | *.lo) ;; # We handle these cases below. ++ force) ++ if test "$dlself" = no; then ++ dlself=needless ++ export_dynamic=yes ++ fi ++ prev= ++ continue ++ ;; ++ self) ++ if test "$prev" = dlprefiles; then ++ dlself=yes ++ elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then ++ dlself=yes ++ else ++ dlself=needless ++ export_dynamic=yes ++ fi ++ prev= ++ continue ++ ;; ++ *) ++ if test "$prev" = dlfiles; then ++ dlfiles="$dlfiles $arg" ++ else ++ dlprefiles="$dlprefiles $arg" ++ fi ++ prev= ++ continue ++ ;; ++ esac ++ ;; ++ expsyms) ++ export_symbols="$arg" ++ test -f "$arg" \ ++ || func_fatal_error "symbol file \`$arg' does not exist" ++ prev= ++ continue ++ ;; ++ expsyms_regex) ++ export_symbols_regex="$arg" ++ prev= ++ continue ++ ;; ++ framework) ++ case $host in ++ *-*-darwin*) ++ case "$deplibs " in ++ *" $qarg.ltframework "*) ;; ++ *) deplibs="$deplibs $qarg.ltframework" # this is fixed later ++ ;; ++ esac ++ ;; ++ esac ++ prev= ++ continue ++ ;; ++ inst_prefix) ++ inst_prefix_dir="$arg" ++ prev= ++ continue ++ ;; ++ objectlist) ++ if test -f "$arg"; then ++ save_arg=$arg ++ moreargs= ++ for fil in `cat "$save_arg"` ++ do ++# moreargs="$moreargs $fil" ++ arg=$fil ++ # A libtool-controlled object. ++ ++ # Check to see that this really is a libtool object. ++ if func_lalib_unsafe_p "$arg"; then ++ pic_object= ++ non_pic_object= ++ ++ # Read the .lo file ++ func_source "$arg" ++ ++ if test -z "$pic_object" || ++ test -z "$non_pic_object" || ++ test "$pic_object" = none && ++ test "$non_pic_object" = none; then ++ func_fatal_error "cannot find name of object for \`$arg'" ++ fi ++ ++ # Extract subdirectory from the argument. ++ func_dirname "$arg" "/" "" ++ xdir="$func_dirname_result" ++ ++ if test "$pic_object" != none; then ++ # Prepend the subdirectory the object is found in. ++ pic_object="$xdir$pic_object" ++ ++ if test "$prev" = dlfiles; then ++ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then ++ dlfiles="$dlfiles $pic_object" ++ prev= ++ continue ++ else ++ # If libtool objects are unsupported, then we need to preload. ++ prev=dlprefiles ++ fi ++ fi ++ ++ # CHECK ME: I think I busted this. -Ossama ++ if test "$prev" = dlprefiles; then ++ # Preload the old-style object. ++ dlprefiles="$dlprefiles $pic_object" ++ prev= ++ fi ++ ++ # A PIC object. ++ func_append libobjs " $pic_object" ++ arg="$pic_object" ++ fi ++ ++ # Non-PIC object. ++ if test "$non_pic_object" != none; then ++ # Prepend the subdirectory the object is found in. ++ non_pic_object="$xdir$non_pic_object" ++ ++ # A standard non-PIC object ++ func_append non_pic_objects " $non_pic_object" ++ if test -z "$pic_object" || test "$pic_object" = none ; then ++ arg="$non_pic_object" ++ fi ++ else ++ # If the PIC object exists, use it instead. ++ # $xdir was prepended to $pic_object above. ++ non_pic_object="$pic_object" ++ func_append non_pic_objects " $non_pic_object" ++ fi ++ else ++ # Only an error if not doing a dry-run. ++ if $opt_dry_run; then ++ # Extract subdirectory from the argument. ++ func_dirname "$arg" "/" "" ++ xdir="$func_dirname_result" ++ ++ func_lo2o "$arg" ++ pic_object=$xdir$objdir/$func_lo2o_result ++ non_pic_object=$xdir$func_lo2o_result ++ func_append libobjs " $pic_object" ++ func_append non_pic_objects " $non_pic_object" ++ else ++ func_fatal_error "\`$arg' is not a valid libtool object" ++ fi ++ fi ++ done ++ else ++ func_fatal_error "link input file \`$arg' does not exist" ++ fi ++ arg=$save_arg ++ prev= ++ continue ++ ;; ++ precious_regex) ++ precious_files_regex="$arg" ++ prev= ++ continue ++ ;; ++ release) ++ release="-$arg" ++ prev= ++ continue ++ ;; ++ rpath | xrpath) ++ # We need an absolute path. ++ case $arg in ++ [\\/]* | [A-Za-z]:[\\/]*) ;; ++ *) ++ func_fatal_error "only absolute run-paths are allowed" ++ ;; ++ esac ++ if test "$prev" = rpath; then ++ case "$rpath " in ++ *" $arg "*) ;; ++ *) rpath="$rpath $arg" ;; ++ esac ++ else ++ case "$xrpath " in ++ *" $arg "*) ;; ++ *) xrpath="$xrpath $arg" ;; ++ esac ++ fi ++ prev= ++ continue ++ ;; ++ shrext) ++ shrext_cmds="$arg" ++ prev= ++ continue ++ ;; ++ weak) ++ weak_libs="$weak_libs $arg" ++ prev= ++ continue ++ ;; ++ xcclinker) ++ linker_flags="$linker_flags $qarg" ++ compiler_flags="$compiler_flags $qarg" ++ prev= ++ func_append compile_command " $qarg" ++ func_append finalize_command " $qarg" ++ continue ++ ;; ++ xcompiler) ++ compiler_flags="$compiler_flags $qarg" ++ prev= ++ func_append compile_command " $qarg" ++ func_append finalize_command " $qarg" ++ continue ++ ;; ++ xlinker) ++ linker_flags="$linker_flags $qarg" ++ compiler_flags="$compiler_flags $wl$qarg" ++ prev= ++ func_append compile_command " $wl$qarg" ++ func_append finalize_command " $wl$qarg" ++ continue ++ ;; ++ *) ++ eval "$prev=\"\$arg\"" ++ prev= ++ continue ++ ;; ++ esac ++ fi # test -n "$prev" ++ ++ prevarg="$arg" ++ ++ case $arg in ++ -all-static) ++ if test -n "$link_static_flag"; then ++ # See comment for -static flag below, for more details. ++ func_append compile_command " $link_static_flag" ++ func_append finalize_command " $link_static_flag" ++ fi ++ continue ++ ;; ++ ++ -allow-undefined) ++ # FIXME: remove this flag sometime in the future. ++ func_fatal_error "\`-allow-undefined' must not be used because it is the default" ++ ;; ++ ++ -avoid-version) ++ avoid_version=yes ++ continue ++ ;; ++ ++ -bindir) ++ prev=bindir ++ continue ++ ;; ++ ++ -dlopen) ++ prev=dlfiles ++ continue ++ ;; ++ ++ -dlpreopen) ++ prev=dlprefiles ++ continue ++ ;; ++ ++ -export-dynamic) ++ export_dynamic=yes ++ continue ++ ;; ++ ++ -export-symbols | -export-symbols-regex) ++ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then ++ func_fatal_error "more than one -exported-symbols argument is not allowed" ++ fi ++ if test "X$arg" = "X-export-symbols"; then ++ prev=expsyms ++ else ++ prev=expsyms_regex ++ fi ++ continue ++ ;; ++ ++ -framework) ++ prev=framework ++ continue ++ ;; ++ ++ -inst-prefix-dir) ++ prev=inst_prefix ++ continue ++ ;; ++ ++ # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* ++ # so, if we see these flags be careful not to treat them like -L ++ -L[A-Z][A-Z]*:*) ++ case $with_gcc/$host in ++ no/*-*-irix* | /*-*-irix*) ++ func_append compile_command " $arg" ++ func_append finalize_command " $arg" ++ ;; ++ esac ++ continue ++ ;; ++ ++ -L*) ++ func_stripname '-L' '' "$arg" ++ dir=$func_stripname_result ++ if test -z "$dir"; then ++ if test "$#" -gt 0; then ++ func_fatal_error "require no space between \`-L' and \`$1'" ++ else ++ func_fatal_error "need path for \`-L' option" ++ fi ++ fi ++ # We need an absolute path. ++ case $dir in ++ [\\/]* | [A-Za-z]:[\\/]*) ;; ++ *) ++ absdir=`cd "$dir" && pwd` ++ test -z "$absdir" && \ ++ func_fatal_error "cannot determine absolute directory name of \`$dir'" ++ dir="$absdir" ++ ;; ++ esac ++ case "$deplibs " in ++ *" -L$dir "*) ;; ++ *) ++ deplibs="$deplibs -L$dir" ++ lib_search_path="$lib_search_path $dir" ++ ;; ++ esac ++ case $host in ++ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) ++ testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` ++ case :$dllsearchpath: in ++ *":$dir:"*) ;; ++ ::) dllsearchpath=$dir;; ++ *) dllsearchpath="$dllsearchpath:$dir";; ++ esac ++ case :$dllsearchpath: in ++ *":$testbindir:"*) ;; ++ ::) dllsearchpath=$testbindir;; ++ *) dllsearchpath="$dllsearchpath:$testbindir";; ++ esac ++ ;; ++ esac ++ continue ++ ;; ++ ++ -l*) ++ if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then ++ case $host in ++ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) ++ # These systems don't actually have a C or math library (as such) ++ continue ++ ;; ++ *-*-os2*) ++ # These systems don't actually have a C library (as such) ++ test "X$arg" = "X-lc" && continue ++ ;; ++ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) ++ # Do not include libc due to us having libc/libc_r. ++ test "X$arg" = "X-lc" && continue ++ ;; ++ *-*-rhapsody* | *-*-darwin1.[012]) ++ # Rhapsody C and math libraries are in the System framework ++ deplibs="$deplibs System.ltframework" ++ continue ++ ;; ++ *-*-sco3.2v5* | *-*-sco5v6*) ++ # Causes problems with __ctype ++ test "X$arg" = "X-lc" && continue ++ ;; ++ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) ++ # Compiler inserts libc in the correct place for threads to work ++ test "X$arg" = "X-lc" && continue ++ ;; ++ *-*-linux*) ++ test "X$arg" = "X-lc" && continue ++ ;; ++ esac ++ elif test "X$arg" = "X-lc_r"; then ++ case $host in ++ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) ++ # Do not include libc_r directly, use -pthread flag. ++ continue ++ ;; ++ esac ++ fi ++ deplibs="$deplibs $arg" ++ continue ++ ;; ++ ++ -module) ++ module=yes ++ continue ++ ;; ++ ++ # Tru64 UNIX uses -model [arg] to determine the layout of C++ ++ # classes, name mangling, and exception handling. ++ # Darwin uses the -arch flag to determine output architecture. ++ -model|-arch|-isysroot) ++ compiler_flags="$compiler_flags $arg" ++ func_append compile_command " $arg" ++ func_append finalize_command " $arg" ++ prev=xcompiler ++ continue ++ ;; ++ ++ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) ++ compiler_flags="$compiler_flags $arg" ++ func_append compile_command " $arg" ++ func_append finalize_command " $arg" ++ case "$new_inherited_linker_flags " in ++ *" $arg "*) ;; ++ * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; ++ esac ++ continue ++ ;; ++ ++ -multi_module) ++ single_module="${wl}-multi_module" ++ continue ++ ;; ++ ++ -no-fast-install) ++ fast_install=no ++ continue ++ ;; ++ ++ -no-install) ++ case $host in ++ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) ++ # The PATH hackery in wrapper scripts is required on Windows ++ # and Darwin in order for the loader to find any dlls it needs. ++ func_warning "\`-no-install' is ignored for $host" ++ func_warning "assuming \`-no-fast-install' instead" ++ fast_install=no ++ ;; ++ *) no_install=yes ;; ++ esac ++ continue ++ ;; ++ ++ -no-undefined) ++ allow_undefined=no ++ continue ++ ;; ++ ++ -objectlist) ++ prev=objectlist ++ continue ++ ;; ++ ++ -o) prev=output ;; ++ ++ -precious-files-regex) ++ prev=precious_regex ++ continue ++ ;; ++ ++ -release) ++ prev=release ++ continue ++ ;; ++ ++ -rpath) ++ prev=rpath ++ continue ++ ;; ++ ++ -R) ++ prev=xrpath ++ continue ++ ;; ++ ++ -R*) ++ func_stripname '-R' '' "$arg" ++ dir=$func_stripname_result ++ # We need an absolute path. ++ case $dir in ++ [\\/]* | [A-Za-z]:[\\/]*) ;; ++ *) ++ func_fatal_error "only absolute run-paths are allowed" ++ ;; ++ esac ++ case "$xrpath " in ++ *" $dir "*) ;; ++ *) xrpath="$xrpath $dir" ;; ++ esac ++ continue ++ ;; ++ ++ -shared) ++ # The effects of -shared are defined in a previous loop. ++ continue ++ ;; ++ ++ -shrext) ++ prev=shrext ++ continue ++ ;; ++ ++ -static | -static-libtool-libs) ++ # The effects of -static are defined in a previous loop. ++ # We used to do the same as -all-static on platforms that ++ # didn't have a PIC flag, but the assumption that the effects ++ # would be equivalent was wrong. It would break on at least ++ # Digital Unix and AIX. ++ continue ++ ;; ++ ++ -thread-safe) ++ thread_safe=yes ++ continue ++ ;; ++ ++ -version-info) ++ prev=vinfo ++ continue ++ ;; ++ ++ -version-number) ++ prev=vinfo ++ vinfo_number=yes ++ continue ++ ;; ++ ++ -weak) ++ prev=weak ++ continue ++ ;; ++ ++ -Wc,*) ++ func_stripname '-Wc,' '' "$arg" ++ args=$func_stripname_result ++ arg= ++ save_ifs="$IFS"; IFS=',' ++ for flag in $args; do ++ IFS="$save_ifs" ++ func_quote_for_eval "$flag" ++ arg="$arg $func_quote_for_eval_result" ++ compiler_flags="$compiler_flags $func_quote_for_eval_result" ++ done ++ IFS="$save_ifs" ++ func_stripname ' ' '' "$arg" ++ arg=$func_stripname_result ++ ;; ++ ++ -Wl,*) ++ func_stripname '-Wl,' '' "$arg" ++ args=$func_stripname_result ++ arg= ++ save_ifs="$IFS"; IFS=',' ++ for flag in $args; do ++ IFS="$save_ifs" ++ func_quote_for_eval "$flag" ++ arg="$arg $wl$func_quote_for_eval_result" ++ compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" ++ linker_flags="$linker_flags $func_quote_for_eval_result" ++ done ++ IFS="$save_ifs" ++ func_stripname ' ' '' "$arg" ++ arg=$func_stripname_result ++ ;; ++ ++ -Xcompiler) ++ prev=xcompiler ++ continue ++ ;; ++ ++ -Xlinker) ++ prev=xlinker ++ continue ++ ;; ++ ++ -XCClinker) ++ prev=xcclinker ++ continue ++ ;; ++ ++ # -msg_* for osf cc ++ -msg_*) ++ func_quote_for_eval "$arg" ++ arg="$func_quote_for_eval_result" ++ ;; ++ ++ # -64, -mips[0-9] enable 64-bit mode on the SGI compiler ++ # -r[0-9][0-9]* specifies the processor on the SGI compiler ++ # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler ++ # +DA*, +DD* enable 64-bit mode on the HP compiler ++ # -q* pass through compiler args for the IBM compiler ++ # -m*, -t[45]*, -txscale* pass through architecture-specific ++ # compiler args for GCC ++ # -F/path gives path to uninstalled frameworks, gcc on darwin ++ # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC ++ # @file GCC response files ++ # -tp=* Portland pgcc target processor selection ++ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ ++ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*) ++ func_quote_for_eval "$arg" ++ arg="$func_quote_for_eval_result" ++ func_append compile_command " $arg" ++ func_append finalize_command " $arg" ++ compiler_flags="$compiler_flags $arg" ++ continue ++ ;; ++ ++ # Some other compiler flag. ++ -* | +*) ++ func_quote_for_eval "$arg" ++ arg="$func_quote_for_eval_result" ++ ;; ++ ++ *.$objext) ++ # A standard object. ++ objs="$objs $arg" ++ ;; ++ ++ *.lo) ++ # A libtool-controlled object. ++ ++ # Check to see that this really is a libtool object. ++ if func_lalib_unsafe_p "$arg"; then ++ pic_object= ++ non_pic_object= ++ ++ # Read the .lo file ++ func_source "$arg" ++ ++ if test -z "$pic_object" || ++ test -z "$non_pic_object" || ++ test "$pic_object" = none && ++ test "$non_pic_object" = none; then ++ func_fatal_error "cannot find name of object for \`$arg'" ++ fi ++ ++ # Extract subdirectory from the argument. ++ func_dirname "$arg" "/" "" ++ xdir="$func_dirname_result" ++ ++ if test "$pic_object" != none; then ++ # Prepend the subdirectory the object is found in. ++ pic_object="$xdir$pic_object" ++ ++ if test "$prev" = dlfiles; then ++ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then ++ dlfiles="$dlfiles $pic_object" ++ prev= ++ continue ++ else ++ # If libtool objects are unsupported, then we need to preload. ++ prev=dlprefiles ++ fi ++ fi ++ ++ # CHECK ME: I think I busted this. -Ossama ++ if test "$prev" = dlprefiles; then ++ # Preload the old-style object. ++ dlprefiles="$dlprefiles $pic_object" ++ prev= ++ fi ++ ++ # A PIC object. ++ func_append libobjs " $pic_object" ++ arg="$pic_object" ++ fi ++ ++ # Non-PIC object. ++ if test "$non_pic_object" != none; then ++ # Prepend the subdirectory the object is found in. ++ non_pic_object="$xdir$non_pic_object" ++ ++ # A standard non-PIC object ++ func_append non_pic_objects " $non_pic_object" ++ if test -z "$pic_object" || test "$pic_object" = none ; then ++ arg="$non_pic_object" ++ fi ++ else ++ # If the PIC object exists, use it instead. ++ # $xdir was prepended to $pic_object above. ++ non_pic_object="$pic_object" ++ func_append non_pic_objects " $non_pic_object" ++ fi ++ else ++ # Only an error if not doing a dry-run. ++ if $opt_dry_run; then ++ # Extract subdirectory from the argument. ++ func_dirname "$arg" "/" "" ++ xdir="$func_dirname_result" ++ ++ func_lo2o "$arg" ++ pic_object=$xdir$objdir/$func_lo2o_result ++ non_pic_object=$xdir$func_lo2o_result ++ func_append libobjs " $pic_object" ++ func_append non_pic_objects " $non_pic_object" ++ else ++ func_fatal_error "\`$arg' is not a valid libtool object" ++ fi ++ fi ++ ;; ++ ++ *.$libext) ++ # An archive. ++ deplibs="$deplibs $arg" ++ old_deplibs="$old_deplibs $arg" ++ continue ++ ;; ++ ++ *.la) ++ # A libtool-controlled library. ++ ++ if test "$prev" = dlfiles; then ++ # This library was specified with -dlopen. ++ dlfiles="$dlfiles $arg" ++ prev= ++ elif test "$prev" = dlprefiles; then ++ # The library was specified with -dlpreopen. ++ dlprefiles="$dlprefiles $arg" ++ prev= ++ else ++ deplibs="$deplibs $arg" ++ fi ++ continue ++ ;; ++ ++ # Some other compiler argument. ++ *) ++ # Unknown arguments in both finalize_command and compile_command need ++ # to be aesthetically quoted because they are evaled later. ++ func_quote_for_eval "$arg" ++ arg="$func_quote_for_eval_result" ++ ;; ++ esac # arg ++ ++ # Now actually substitute the argument into the commands. ++ if test -n "$arg"; then ++ func_append compile_command " $arg" ++ func_append finalize_command " $arg" ++ fi ++ done # argument parsing loop ++ ++ test -n "$prev" && \ ++ func_fatal_help "the \`$prevarg' option requires an argument" ++ ++ if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then ++ eval "arg=\"$export_dynamic_flag_spec\"" ++ func_append compile_command " $arg" ++ func_append finalize_command " $arg" ++ fi ++ ++ oldlibs= ++ # calculate the name of the file, without its directory ++ func_basename "$output" ++ outputname="$func_basename_result" ++ libobjs_save="$libobjs" ++ ++ if test -n "$shlibpath_var"; then ++ # get the directories listed in $shlibpath_var ++ eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` ++ else ++ shlib_search_path= ++ fi ++ eval "sys_lib_search_path=\"$sys_lib_search_path_spec\"" ++ eval "sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"" ++ ++ func_dirname "$output" "/" "" ++ output_objdir="$func_dirname_result$objdir" ++ # Create the object directory. ++ func_mkdir_p "$output_objdir" ++ ++ # Determine the type of output ++ case $output in ++ "") ++ func_fatal_help "you must specify an output file" ++ ;; ++ *.$libext) linkmode=oldlib ;; ++ *.lo | *.$objext) linkmode=obj ;; ++ *.la) linkmode=lib ;; ++ *) linkmode=prog ;; # Anything else should be a program. ++ esac ++ ++ specialdeplibs= ++ ++ libs= ++ # Find all interdependent deplibs by searching for libraries ++ # that are linked more than once (e.g. -la -lb -la) ++ for deplib in $deplibs; do ++ if $opt_duplicate_deps ; then ++ case "$libs " in ++ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; ++ esac ++ fi ++ libs="$libs $deplib" ++ done ++ ++ if test "$linkmode" = lib; then ++ libs="$predeps $libs $compiler_lib_search_path $postdeps" ++ ++ # Compute libraries that are listed more than once in $predeps ++ # $postdeps and mark them as special (i.e., whose duplicates are ++ # not to be eliminated). ++ pre_post_deps= ++ if $opt_duplicate_compiler_generated_deps; then ++ for pre_post_dep in $predeps $postdeps; do ++ case "$pre_post_deps " in ++ *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; ++ esac ++ pre_post_deps="$pre_post_deps $pre_post_dep" ++ done ++ fi ++ pre_post_deps= ++ fi ++ ++ deplibs= ++ newdependency_libs= ++ newlib_search_path= ++ need_relink=no # whether we're linking any uninstalled libtool libraries ++ notinst_deplibs= # not-installed libtool libraries ++ notinst_path= # paths that contain not-installed libtool libraries ++ ++ case $linkmode in ++ lib) ++ passes="conv dlpreopen link" ++ for file in $dlfiles $dlprefiles; do ++ case $file in ++ *.la) ;; ++ *) ++ func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ++ ;; ++ esac ++ done ++ ;; ++ prog) ++ compile_deplibs= ++ finalize_deplibs= ++ alldeplibs=no ++ newdlfiles= ++ newdlprefiles= ++ passes="conv scan dlopen dlpreopen link" ++ ;; ++ *) passes="conv" ++ ;; ++ esac ++ ++ for pass in $passes; do ++ # The preopen pass in lib mode reverses $deplibs; put it back here ++ # so that -L comes before libs that need it for instance... ++ if test "$linkmode,$pass" = "lib,link"; then ++ ## FIXME: Find the place where the list is rebuilt in the wrong ++ ## order, and fix it there properly ++ tmp_deplibs= ++ for deplib in $deplibs; do ++ tmp_deplibs="$deplib $tmp_deplibs" ++ done ++ deplibs="$tmp_deplibs" ++ fi ++ ++ if test "$linkmode,$pass" = "lib,link" || ++ test "$linkmode,$pass" = "prog,scan"; then ++ libs="$deplibs" ++ deplibs= ++ fi ++ if test "$linkmode" = prog; then ++ case $pass in ++ dlopen) libs="$dlfiles" ;; ++ dlpreopen) libs="$dlprefiles" ;; ++ link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; ++ esac ++ fi ++ if test "$linkmode,$pass" = "lib,dlpreopen"; then ++ # Collect and forward deplibs of preopened libtool libs ++ for lib in $dlprefiles; do ++ # Ignore non-libtool-libs ++ dependency_libs= ++ case $lib in ++ *.la) func_source "$lib" ;; ++ esac ++ ++ # Collect preopened libtool deplibs, except any this library ++ # has declared as weak libs ++ for deplib in $dependency_libs; do ++ func_basename "$deplib" ++ deplib_base=$func_basename_result ++ case " $weak_libs " in ++ *" $deplib_base "*) ;; ++ *) deplibs="$deplibs $deplib" ;; ++ esac ++ done ++ done ++ libs="$dlprefiles" ++ fi ++ if test "$pass" = dlopen; then ++ # Collect dlpreopened libraries ++ save_deplibs="$deplibs" ++ deplibs= ++ fi ++ ++ for deplib in $libs; do ++ lib= ++ found=no ++ case $deplib in ++ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) ++ if test "$linkmode,$pass" = "prog,link"; then ++ compile_deplibs="$deplib $compile_deplibs" ++ finalize_deplibs="$deplib $finalize_deplibs" ++ else ++ compiler_flags="$compiler_flags $deplib" ++ if test "$linkmode" = lib ; then ++ case "$new_inherited_linker_flags " in ++ *" $deplib "*) ;; ++ * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; ++ esac ++ fi ++ fi ++ continue ++ ;; ++ -l*) ++ if test "$linkmode" != lib && test "$linkmode" != prog; then ++ func_warning "\`-l' is ignored for archives/objects" ++ continue ++ fi ++ func_stripname '-l' '' "$deplib" ++ name=$func_stripname_result ++ if test "$linkmode" = lib; then ++ searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" ++ else ++ searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" ++ fi ++ for searchdir in $searchdirs; do ++ for search_ext in .la $std_shrext .so .a; do ++ # Search the libtool library ++ lib="$searchdir/lib${name}${search_ext}" ++ if test -f "$lib"; then ++ if test "$search_ext" = ".la"; then ++ found=yes ++ else ++ found=no ++ fi ++ break 2 ++ fi ++ done ++ done ++ if test "$found" != yes; then ++ # deplib doesn't seem to be a libtool library ++ if test "$linkmode,$pass" = "prog,link"; then ++ compile_deplibs="$deplib $compile_deplibs" ++ finalize_deplibs="$deplib $finalize_deplibs" ++ else ++ deplibs="$deplib $deplibs" ++ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" ++ fi ++ continue ++ else # deplib is a libtool library ++ # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, ++ # We need to do some special things here, and not later. ++ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then ++ case " $predeps $postdeps " in ++ *" $deplib "*) ++ if func_lalib_p "$lib"; then ++ library_names= ++ old_library= ++ func_source "$lib" ++ for l in $old_library $library_names; do ++ ll="$l" ++ done ++ if test "X$ll" = "X$old_library" ; then # only static version available ++ found=no ++ func_dirname "$lib" "" "." ++ ladir="$func_dirname_result" ++ lib=$ladir/$old_library ++ if test "$linkmode,$pass" = "prog,link"; then ++ compile_deplibs="$deplib $compile_deplibs" ++ finalize_deplibs="$deplib $finalize_deplibs" ++ else ++ deplibs="$deplib $deplibs" ++ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" ++ fi ++ continue ++ fi ++ fi ++ ;; ++ *) ;; ++ esac ++ fi ++ fi ++ ;; # -l ++ *.ltframework) ++ if test "$linkmode,$pass" = "prog,link"; then ++ compile_deplibs="$deplib $compile_deplibs" ++ finalize_deplibs="$deplib $finalize_deplibs" ++ else ++ deplibs="$deplib $deplibs" ++ if test "$linkmode" = lib ; then ++ case "$new_inherited_linker_flags " in ++ *" $deplib "*) ;; ++ * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; ++ esac ++ fi ++ fi ++ continue ++ ;; ++ -L*) ++ case $linkmode in ++ lib) ++ deplibs="$deplib $deplibs" ++ test "$pass" = conv && continue ++ newdependency_libs="$deplib $newdependency_libs" ++ func_stripname '-L' '' "$deplib" ++ newlib_search_path="$newlib_search_path $func_stripname_result" ++ ;; ++ prog) ++ if test "$pass" = conv; then ++ deplibs="$deplib $deplibs" ++ continue ++ fi ++ if test "$pass" = scan; then ++ deplibs="$deplib $deplibs" ++ else ++ compile_deplibs="$deplib $compile_deplibs" ++ finalize_deplibs="$deplib $finalize_deplibs" ++ fi ++ func_stripname '-L' '' "$deplib" ++ newlib_search_path="$newlib_search_path $func_stripname_result" ++ ;; ++ *) ++ func_warning "\`-L' is ignored for archives/objects" ++ ;; ++ esac # linkmode ++ continue ++ ;; # -L ++ -R*) ++ if test "$pass" = link; then ++ func_stripname '-R' '' "$deplib" ++ dir=$func_stripname_result ++ # Make sure the xrpath contains only unique directories. ++ case "$xrpath " in ++ *" $dir "*) ;; ++ *) xrpath="$xrpath $dir" ;; ++ esac ++ fi ++ deplibs="$deplib $deplibs" ++ continue ++ ;; ++ *.la) lib="$deplib" ;; ++ *.$libext) ++ if test "$pass" = conv; then ++ deplibs="$deplib $deplibs" ++ continue ++ fi ++ case $linkmode in ++ lib) ++ # Linking convenience modules into shared libraries is allowed, ++ # but linking other static libraries is non-portable. ++ case " $dlpreconveniencelibs " in ++ *" $deplib "*) ;; ++ *) ++ valid_a_lib=no ++ case $deplibs_check_method in ++ match_pattern*) ++ set dummy $deplibs_check_method; shift ++ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` ++ if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ ++ | $EGREP "$match_pattern_regex" > /dev/null; then ++ valid_a_lib=yes ++ fi ++ ;; ++ pass_all) ++ valid_a_lib=yes ++ ;; ++ esac ++ if test "$valid_a_lib" != yes; then ++ echo ++ $ECHO "*** Warning: Trying to link with static lib archive $deplib." ++ echo "*** I have the capability to make that library automatically link in when" ++ echo "*** you link to this library. But I can only do this if you have a" ++ echo "*** shared version of the library, which you do not appear to have" ++ echo "*** because the file extensions .$libext of this argument makes me believe" ++ echo "*** that it is just a static archive that I should not use here." ++ else ++ echo ++ $ECHO "*** Warning: Linking the shared library $output against the" ++ $ECHO "*** static library $deplib is not portable!" ++ deplibs="$deplib $deplibs" ++ fi ++ ;; ++ esac ++ continue ++ ;; ++ prog) ++ if test "$pass" != link; then ++ deplibs="$deplib $deplibs" ++ else ++ compile_deplibs="$deplib $compile_deplibs" ++ finalize_deplibs="$deplib $finalize_deplibs" ++ fi ++ continue ++ ;; ++ esac # linkmode ++ ;; # *.$libext ++ *.lo | *.$objext) ++ if test "$pass" = conv; then ++ deplibs="$deplib $deplibs" ++ elif test "$linkmode" = prog; then ++ if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then ++ # If there is no dlopen support or we're linking statically, ++ # we need to preload. ++ newdlprefiles="$newdlprefiles $deplib" ++ compile_deplibs="$deplib $compile_deplibs" ++ finalize_deplibs="$deplib $finalize_deplibs" ++ else ++ newdlfiles="$newdlfiles $deplib" ++ fi ++ fi ++ continue ++ ;; ++ %DEPLIBS%) ++ alldeplibs=yes ++ continue ++ ;; ++ esac # case $deplib ++ ++ if test "$found" = yes || test -f "$lib"; then : ++ else ++ func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" ++ fi ++ ++ # Check to see that this really is a libtool archive. ++ func_lalib_unsafe_p "$lib" \ ++ || func_fatal_error "\`$lib' is not a valid libtool archive" ++ ++ func_dirname "$lib" "" "." ++ ladir="$func_dirname_result" ++ ++ dlname= ++ dlopen= ++ dlpreopen= ++ libdir= ++ library_names= ++ old_library= ++ inherited_linker_flags= ++ # If the library was installed with an old release of libtool, ++ # it will not redefine variables installed, or shouldnotlink ++ installed=yes ++ shouldnotlink=no ++ avoidtemprpath= ++ ++ ++ # Read the .la file ++ func_source "$lib" ++ ++ # Convert "-framework foo" to "foo.ltframework" ++ if test -n "$inherited_linker_flags"; then ++ tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` ++ for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do ++ case " $new_inherited_linker_flags " in ++ *" $tmp_inherited_linker_flag "*) ;; ++ *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; ++ esac ++ done ++ fi ++ dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ++ if test "$linkmode,$pass" = "lib,link" || ++ test "$linkmode,$pass" = "prog,scan" || ++ { test "$linkmode" != prog && test "$linkmode" != lib; }; then ++ test -n "$dlopen" && dlfiles="$dlfiles $dlopen" ++ test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" ++ fi ++ ++ if test "$pass" = conv; then ++ # Only check for convenience libraries ++ deplibs="$lib $deplibs" ++ if test -z "$libdir"; then ++ if test -z "$old_library"; then ++ func_fatal_error "cannot find name of link library for \`$lib'" ++ fi ++ # It is a libtool convenience library, so add in its objects. ++ convenience="$convenience $ladir/$objdir/$old_library" ++ old_convenience="$old_convenience $ladir/$objdir/$old_library" ++ elif test "$linkmode" != prog && test "$linkmode" != lib; then ++ func_fatal_error "\`$lib' is not a convenience library" ++ fi ++ tmp_libs= ++ for deplib in $dependency_libs; do ++ deplibs="$deplib $deplibs" ++ if $opt_duplicate_deps ; then ++ case "$tmp_libs " in ++ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; ++ esac ++ fi ++ tmp_libs="$tmp_libs $deplib" ++ done ++ continue ++ fi # $pass = conv ++ ++ ++ # Get the name of the library we link against. ++ linklib= ++ for l in $old_library $library_names; do ++ linklib="$l" ++ done ++ if test -z "$linklib"; then ++ func_fatal_error "cannot find name of link library for \`$lib'" ++ fi ++ ++ # This library was specified with -dlopen. ++ if test "$pass" = dlopen; then ++ if test -z "$libdir"; then ++ func_fatal_error "cannot -dlopen a convenience library: \`$lib'" ++ fi ++ if test -z "$dlname" || ++ test "$dlopen_support" != yes || ++ test "$build_libtool_libs" = no; then ++ # If there is no dlname, no dlopen support or we're linking ++ # statically, we need to preload. We also need to preload any ++ # dependent libraries so libltdl's deplib preloader doesn't ++ # bomb out in the load deplibs phase. ++ dlprefiles="$dlprefiles $lib $dependency_libs" ++ else ++ newdlfiles="$newdlfiles $lib" ++ fi ++ continue ++ fi # $pass = dlopen ++ ++ # We need an absolute path. ++ case $ladir in ++ [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; ++ *) ++ abs_ladir=`cd "$ladir" && pwd` ++ if test -z "$abs_ladir"; then ++ func_warning "cannot determine absolute directory name of \`$ladir'" ++ func_warning "passing it literally to the linker, although it might fail" ++ abs_ladir="$ladir" ++ fi ++ ;; ++ esac ++ func_basename "$lib" ++ laname="$func_basename_result" ++ ++ # Find the relevant object directory and library name. ++ if test "X$installed" = Xyes; then ++ if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then ++ func_warning "library \`$lib' was moved." ++ dir="$ladir" ++ absdir="$abs_ladir" ++ libdir="$abs_ladir" ++ else ++ dir="$libdir" ++ absdir="$libdir" ++ fi ++ test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes ++ else ++ if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then ++ dir="$ladir" ++ absdir="$abs_ladir" ++ # Remove this search path later ++ notinst_path="$notinst_path $abs_ladir" ++ else ++ dir="$ladir/$objdir" ++ absdir="$abs_ladir/$objdir" ++ # Remove this search path later ++ notinst_path="$notinst_path $abs_ladir" ++ fi ++ fi # $installed = yes ++ func_stripname 'lib' '.la' "$laname" ++ name=$func_stripname_result ++ ++ # This library was specified with -dlpreopen. ++ if test "$pass" = dlpreopen; then ++ if test -z "$libdir" && test "$linkmode" = prog; then ++ func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" ++ fi ++ # Prefer using a static library (so that no silly _DYNAMIC symbols ++ # are required to link). ++ if test -n "$old_library"; then ++ newdlprefiles="$newdlprefiles $dir/$old_library" ++ # Keep a list of preopened convenience libraries to check ++ # that they are being used correctly in the link pass. ++ test -z "$libdir" && \ ++ dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" ++ # Otherwise, use the dlname, so that lt_dlopen finds it. ++ elif test -n "$dlname"; then ++ newdlprefiles="$newdlprefiles $dir/$dlname" ++ else ++ newdlprefiles="$newdlprefiles $dir/$linklib" ++ fi ++ fi # $pass = dlpreopen ++ ++ if test -z "$libdir"; then ++ # Link the convenience library ++ if test "$linkmode" = lib; then ++ deplibs="$dir/$old_library $deplibs" ++ elif test "$linkmode,$pass" = "prog,link"; then ++ compile_deplibs="$dir/$old_library $compile_deplibs" ++ finalize_deplibs="$dir/$old_library $finalize_deplibs" ++ else ++ deplibs="$lib $deplibs" # used for prog,scan pass ++ fi ++ continue ++ fi ++ ++ ++ if test "$linkmode" = prog && test "$pass" != link; then ++ newlib_search_path="$newlib_search_path $ladir" ++ deplibs="$lib $deplibs" ++ ++ linkalldeplibs=no ++ if test "$link_all_deplibs" != no || test -z "$library_names" || ++ test "$build_libtool_libs" = no; then ++ linkalldeplibs=yes ++ fi ++ ++ tmp_libs= ++ for deplib in $dependency_libs; do ++ case $deplib in ++ -L*) func_stripname '-L' '' "$deplib" ++ newlib_search_path="$newlib_search_path $func_stripname_result" ++ ;; ++ esac ++ # Need to link against all dependency_libs? ++ if test "$linkalldeplibs" = yes; then ++ deplibs="$deplib $deplibs" ++ else ++ # Need to hardcode shared library paths ++ # or/and link against static libraries ++ newdependency_libs="$deplib $newdependency_libs" ++ fi ++ if $opt_duplicate_deps ; then ++ case "$tmp_libs " in ++ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; ++ esac ++ fi ++ tmp_libs="$tmp_libs $deplib" ++ done # for deplib ++ continue ++ fi # $linkmode = prog... ++ ++ if test "$linkmode,$pass" = "prog,link"; then ++ if test -n "$library_names" && ++ { { test "$prefer_static_libs" = no || ++ test "$prefer_static_libs,$installed" = "built,yes"; } || ++ test -z "$old_library"; }; then ++ # We need to hardcode the library path ++ if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then ++ # Make sure the rpath contains only unique directories. ++ case "$temp_rpath:" in ++ *"$absdir:"*) ;; ++ *) temp_rpath="$temp_rpath$absdir:" ;; ++ esac ++ fi ++ ++ # Hardcode the library path. ++ # Skip directories that are in the system default run-time ++ # search path. ++ case " $sys_lib_dlsearch_path " in ++ *" $absdir "*) ;; ++ *) ++ case "$compile_rpath " in ++ *" $absdir "*) ;; ++ *) compile_rpath="$compile_rpath $absdir" ++ esac ++ ;; ++ esac ++ case " $sys_lib_dlsearch_path " in ++ *" $libdir "*) ;; ++ *) ++ case "$finalize_rpath " in ++ *" $libdir "*) ;; ++ *) finalize_rpath="$finalize_rpath $libdir" ++ esac ++ ;; ++ esac ++ fi # $linkmode,$pass = prog,link... ++ ++ if test "$alldeplibs" = yes && ++ { test "$deplibs_check_method" = pass_all || ++ { test "$build_libtool_libs" = yes && ++ test -n "$library_names"; }; }; then ++ # We only need to search for static libraries ++ continue ++ fi ++ fi ++ ++ link_static=no # Whether the deplib will be linked statically ++ use_static_libs=$prefer_static_libs ++ if test "$use_static_libs" = built && test "$installed" = yes; then ++ use_static_libs=no ++ fi ++ if test -n "$library_names" && ++ { test "$use_static_libs" = no || test -z "$old_library"; }; then ++ case $host in ++ *cygwin* | *mingw* | *cegcc*) ++ # No point in relinking DLLs because paths are not encoded ++ notinst_deplibs="$notinst_deplibs $lib" ++ need_relink=no ++ ;; ++ *) ++ if test "$installed" = no; then ++ notinst_deplibs="$notinst_deplibs $lib" ++ need_relink=yes ++ fi ++ ;; ++ esac ++ # This is a shared library ++ ++ # Warn about portability, can't link against -module's on some ++ # systems (darwin). Don't bleat about dlopened modules though! ++ dlopenmodule="" ++ for dlpremoduletest in $dlprefiles; do ++ if test "X$dlpremoduletest" = "X$lib"; then ++ dlopenmodule="$dlpremoduletest" ++ break ++ fi ++ done ++ if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then ++ echo ++ if test "$linkmode" = prog; then ++ $ECHO "*** Warning: Linking the executable $output against the loadable module" ++ else ++ $ECHO "*** Warning: Linking the shared library $output against the loadable module" ++ fi ++ $ECHO "*** $linklib is not portable!" ++ fi ++ if test "$linkmode" = lib && ++ test "$hardcode_into_libs" = yes; then ++ # Hardcode the library path. ++ # Skip directories that are in the system default run-time ++ # search path. ++ case " $sys_lib_dlsearch_path " in ++ *" $absdir "*) ;; ++ *) ++ case "$compile_rpath " in ++ *" $absdir "*) ;; ++ *) compile_rpath="$compile_rpath $absdir" ++ esac ++ ;; ++ esac ++ case " $sys_lib_dlsearch_path " in ++ *" $libdir "*) ;; ++ *) ++ case "$finalize_rpath " in ++ *" $libdir "*) ;; ++ *) finalize_rpath="$finalize_rpath $libdir" ++ esac ++ ;; ++ esac ++ fi ++ ++ if test -n "$old_archive_from_expsyms_cmds"; then ++ # figure out the soname ++ set dummy $library_names ++ shift ++ realname="$1" ++ shift ++ eval "libname=\"$libname_spec\"" ++ # use dlname if we got it. it's perfectly good, no? ++ if test -n "$dlname"; then ++ soname="$dlname" ++ elif test -n "$soname_spec"; then ++ # bleh windows ++ case $host in ++ *cygwin* | mingw* | *cegcc*) ++ func_arith $current - $age ++ major=$func_arith_result ++ versuffix="-$major" ++ ;; ++ esac ++ eval "soname=\"$soname_spec\"" ++ else ++ soname="$realname" ++ fi ++ ++ # Make a new name for the extract_expsyms_cmds to use ++ soroot="$soname" ++ func_basename "$soroot" ++ soname="$func_basename_result" ++ func_stripname 'lib' '.dll' "$soname" ++ newlib=libimp-$func_stripname_result.a ++ ++ # If the library has no export list, then create one now ++ if test -f "$output_objdir/$soname-def"; then : ++ else ++ func_verbose "extracting exported symbol list from \`$soname'" ++ func_execute_cmds "$extract_expsyms_cmds" 'exit $?' ++ fi ++ ++ # Create $newlib ++ if test -f "$output_objdir/$newlib"; then :; else ++ func_verbose "generating import library for \`$soname'" ++ func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' ++ fi ++ # make sure the library variables are pointing to the new library ++ dir=$output_objdir ++ linklib=$newlib ++ fi # test -n "$old_archive_from_expsyms_cmds" ++ ++ if test "$linkmode" = prog || test "$mode" != relink; then ++ add_shlibpath= ++ add_dir= ++ add= ++ lib_linked=yes ++ case $hardcode_action in ++ immediate | unsupported) ++ if test "$hardcode_direct" = no; then ++ add="$dir/$linklib" ++ case $host in ++ *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; ++ *-*-sysv4*uw2*) add_dir="-L$dir" ;; ++ *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ ++ *-*-unixware7*) add_dir="-L$dir" ;; ++ *-*-darwin* ) ++ # if the lib is a (non-dlopened) module then we can not ++ # link against it, someone is ignoring the earlier warnings ++ if /usr/bin/file -L $add 2> /dev/null | ++ $GREP ": [^:]* bundle" >/dev/null ; then ++ if test "X$dlopenmodule" != "X$lib"; then ++ $ECHO "*** Warning: lib $linklib is a module, not a shared library" ++ if test -z "$old_library" ; then ++ echo ++ echo "*** And there doesn't seem to be a static archive available" ++ echo "*** The link will probably fail, sorry" ++ else ++ add="$dir/$old_library" ++ fi ++ elif test -n "$old_library"; then ++ add="$dir/$old_library" ++ fi ++ fi ++ esac ++ elif test "$hardcode_minus_L" = no; then ++ case $host in ++ *-*-sunos*) add_shlibpath="$dir" ;; ++ esac ++ add_dir="-L$dir" ++ add="-l$name" ++ elif test "$hardcode_shlibpath_var" = no; then ++ add_shlibpath="$dir" ++ add="-l$name" ++ else ++ lib_linked=no ++ fi ++ ;; ++ relink) ++ if test "$hardcode_direct" = yes && ++ test "$hardcode_direct_absolute" = no; then ++ add="$dir/$linklib" ++ elif test "$hardcode_minus_L" = yes; then ++ add_dir="-L$absdir" ++ # Try looking first in the location we're being installed to. ++ if test -n "$inst_prefix_dir"; then ++ case $libdir in ++ [\\/]*) ++ add_dir="$add_dir -L$inst_prefix_dir$libdir" ++ ;; ++ esac ++ fi ++ add="-l$name" ++ elif test "$hardcode_shlibpath_var" = yes; then ++ add_shlibpath="$dir" ++ add="-l$name" ++ else ++ lib_linked=no ++ fi ++ ;; ++ *) lib_linked=no ;; ++ esac ++ ++ if test "$lib_linked" != yes; then ++ func_fatal_configuration "unsupported hardcode properties" ++ fi ++ ++ if test -n "$add_shlibpath"; then ++ case :$compile_shlibpath: in ++ *":$add_shlibpath:"*) ;; ++ *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; ++ esac ++ fi ++ if test "$linkmode" = prog; then ++ test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" ++ test -n "$add" && compile_deplibs="$add $compile_deplibs" ++ else ++ test -n "$add_dir" && deplibs="$add_dir $deplibs" ++ test -n "$add" && deplibs="$add $deplibs" ++ if test "$hardcode_direct" != yes && ++ test "$hardcode_minus_L" != yes && ++ test "$hardcode_shlibpath_var" = yes; then ++ case :$finalize_shlibpath: in ++ *":$libdir:"*) ;; ++ *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; ++ esac ++ fi ++ fi ++ fi ++ ++ if test "$linkmode" = prog || test "$mode" = relink; then ++ add_shlibpath= ++ add_dir= ++ add= ++ # Finalize command for both is simple: just hardcode it. ++ if test "$hardcode_direct" = yes && ++ test "$hardcode_direct_absolute" = no; then ++ add="$libdir/$linklib" ++ elif test "$hardcode_minus_L" = yes; then ++ add_dir="-L$libdir" ++ add="-l$name" ++ elif test "$hardcode_shlibpath_var" = yes; then ++ case :$finalize_shlibpath: in ++ *":$libdir:"*) ;; ++ *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; ++ esac ++ add="-l$name" ++ elif test "$hardcode_automatic" = yes; then ++ if test -n "$inst_prefix_dir" && ++ test -f "$inst_prefix_dir$libdir/$linklib" ; then ++ add="$inst_prefix_dir$libdir/$linklib" ++ else ++ add="$libdir/$linklib" ++ fi ++ else ++ # We cannot seem to hardcode it, guess we'll fake it. ++ add_dir="-L$libdir" ++ # Try looking first in the location we're being installed to. ++ if test -n "$inst_prefix_dir"; then ++ case $libdir in ++ [\\/]*) ++ add_dir="$add_dir -L$inst_prefix_dir$libdir" ++ ;; ++ esac ++ fi ++ add="-l$name" ++ fi ++ ++ if test "$linkmode" = prog; then ++ test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" ++ test -n "$add" && finalize_deplibs="$add $finalize_deplibs" ++ else ++ test -n "$add_dir" && deplibs="$add_dir $deplibs" ++ test -n "$add" && deplibs="$add $deplibs" ++ fi ++ fi ++ elif test "$linkmode" = prog; then ++ # Here we assume that one of hardcode_direct or hardcode_minus_L ++ # is not unsupported. This is valid on all known static and ++ # shared platforms. ++ if test "$hardcode_direct" != unsupported; then ++ test -n "$old_library" && linklib="$old_library" ++ compile_deplibs="$dir/$linklib $compile_deplibs" ++ finalize_deplibs="$dir/$linklib $finalize_deplibs" ++ else ++ compile_deplibs="-l$name -L$dir $compile_deplibs" ++ finalize_deplibs="-l$name -L$dir $finalize_deplibs" ++ fi ++ elif test "$build_libtool_libs" = yes; then ++ # Not a shared library ++ if test "$deplibs_check_method" != pass_all; then ++ # We're trying link a shared library against a static one ++ # but the system doesn't support it. ++ ++ # Just print a warning and add the library to dependency_libs so ++ # that the program can be linked against the static library. ++ echo ++ $ECHO "*** Warning: This system can not link to static lib archive $lib." ++ echo "*** I have the capability to make that library automatically link in when" ++ echo "*** you link to this library. But I can only do this if you have a" ++ echo "*** shared version of the library, which you do not appear to have." ++ if test "$module" = yes; then ++ echo "*** But as you try to build a module library, libtool will still create " ++ echo "*** a static module, that should work as long as the dlopening application" ++ echo "*** is linked with the -dlopen flag to resolve symbols at runtime." ++ if test -z "$global_symbol_pipe"; then ++ echo ++ echo "*** However, this would only work if libtool was able to extract symbol" ++ echo "*** lists from a program, using \`nm' or equivalent, but libtool could" ++ echo "*** not find such a program. So, this module is probably useless." ++ echo "*** \`nm' from GNU binutils and a full rebuild may help." ++ fi ++ if test "$build_old_libs" = no; then ++ build_libtool_libs=module ++ build_old_libs=yes ++ else ++ build_libtool_libs=no ++ fi ++ fi ++ else ++ deplibs="$dir/$old_library $deplibs" ++ link_static=yes ++ fi ++ fi # link shared/static library? ++ ++ if test "$linkmode" = lib; then ++ if test -n "$dependency_libs" && ++ { test "$hardcode_into_libs" != yes || ++ test "$build_old_libs" = yes || ++ test "$link_static" = yes; }; then ++ # Extract -R from dependency_libs ++ temp_deplibs= ++ for libdir in $dependency_libs; do ++ case $libdir in ++ -R*) func_stripname '-R' '' "$libdir" ++ temp_xrpath=$func_stripname_result ++ case " $xrpath " in ++ *" $temp_xrpath "*) ;; ++ *) xrpath="$xrpath $temp_xrpath";; ++ esac;; ++ *) temp_deplibs="$temp_deplibs $libdir";; ++ esac ++ done ++ dependency_libs="$temp_deplibs" ++ fi ++ ++ newlib_search_path="$newlib_search_path $absdir" ++ # Link against this library ++ test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" ++ # ... and its dependency_libs ++ tmp_libs= ++ for deplib in $dependency_libs; do ++ newdependency_libs="$deplib $newdependency_libs" ++ if $opt_duplicate_deps ; then ++ case "$tmp_libs " in ++ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; ++ esac ++ fi ++ tmp_libs="$tmp_libs $deplib" ++ done ++ ++ if test "$link_all_deplibs" != no; then ++ # Add the search paths of all dependency libraries ++ for deplib in $dependency_libs; do ++ path= ++ case $deplib in ++ -L*) path="$deplib" ;; ++ *.la) ++ func_dirname "$deplib" "" "." ++ dir="$func_dirname_result" ++ # We need an absolute path. ++ case $dir in ++ [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; ++ *) ++ absdir=`cd "$dir" && pwd` ++ if test -z "$absdir"; then ++ func_warning "cannot determine absolute directory name of \`$dir'" ++ absdir="$dir" ++ fi ++ ;; ++ esac ++ if $GREP "^installed=no" $deplib > /dev/null; then ++ case $host in ++ *-*-darwin*) ++ depdepl= ++ deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` ++ if test -n "$deplibrary_names" ; then ++ for tmp in $deplibrary_names ; do ++ depdepl=$tmp ++ done ++ if test -f "$absdir/$objdir/$depdepl" ; then ++ depdepl="$absdir/$objdir/$depdepl" ++ darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` ++ if test -z "$darwin_install_name"; then ++ darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` ++ fi ++ compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" ++ linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" ++ path= ++ fi ++ fi ++ ;; ++ *) ++ path="-L$absdir/$objdir" ++ ;; ++ esac ++ else ++ libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` ++ test -z "$libdir" && \ ++ func_fatal_error "\`$deplib' is not a valid libtool archive" ++ test "$absdir" != "$libdir" && \ ++ func_warning "\`$deplib' seems to be moved" ++ ++ path="-L$absdir" ++ fi ++ ;; ++ esac ++ case " $deplibs " in ++ *" $path "*) ;; ++ *) deplibs="$path $deplibs" ;; ++ esac ++ done ++ fi # link_all_deplibs != no ++ fi # linkmode = lib ++ done # for deplib in $libs ++ if test "$pass" = link; then ++ if test "$linkmode" = "prog"; then ++ compile_deplibs="$new_inherited_linker_flags $compile_deplibs" ++ finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" ++ else ++ compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ++ fi ++ fi ++ dependency_libs="$newdependency_libs" ++ if test "$pass" = dlpreopen; then ++ # Link the dlpreopened libraries before other libraries ++ for deplib in $save_deplibs; do ++ deplibs="$deplib $deplibs" ++ done ++ fi ++ if test "$pass" != dlopen; then ++ if test "$pass" != conv; then ++ # Make sure lib_search_path contains only unique directories. ++ lib_search_path= ++ for dir in $newlib_search_path; do ++ case "$lib_search_path " in ++ *" $dir "*) ;; ++ *) lib_search_path="$lib_search_path $dir" ;; ++ esac ++ done ++ newlib_search_path= ++ fi ++ ++ if test "$linkmode,$pass" != "prog,link"; then ++ vars="deplibs" ++ else ++ vars="compile_deplibs finalize_deplibs" ++ fi ++ for var in $vars dependency_libs; do ++ # Add libraries to $var in reverse order ++ eval tmp_libs=\$$var ++ new_libs= ++ for deplib in $tmp_libs; do ++ # FIXME: Pedantically, this is the right thing to do, so ++ # that some nasty dependency loop isn't accidentally ++ # broken: ++ #new_libs="$deplib $new_libs" ++ # Pragmatically, this seems to cause very few problems in ++ # practice: ++ case $deplib in ++ -L*) new_libs="$deplib $new_libs" ;; ++ -R*) ;; ++ *) ++ # And here is the reason: when a library appears more ++ # than once as an explicit dependence of a library, or ++ # is implicitly linked in more than once by the ++ # compiler, it is considered special, and multiple ++ # occurrences thereof are not removed. Compare this ++ # with having the same library being listed as a ++ # dependency of multiple other libraries: in this case, ++ # we know (pedantically, we assume) the library does not ++ # need to be listed more than once, so we keep only the ++ # last copy. This is not always right, but it is rare ++ # enough that we require users that really mean to play ++ # such unportable linking tricks to link the library ++ # using -Wl,-lname, so that libtool does not consider it ++ # for duplicate removal. ++ case " $specialdeplibs " in ++ *" $deplib "*) new_libs="$deplib $new_libs" ;; ++ *) ++ case " $new_libs " in ++ *" $deplib "*) ;; ++ *) new_libs="$deplib $new_libs" ;; ++ esac ++ ;; ++ esac ++ ;; ++ esac ++ done ++ tmp_libs= ++ for deplib in $new_libs; do ++ case $deplib in ++ -L*) ++ case " $tmp_libs " in ++ *" $deplib "*) ;; ++ *) tmp_libs="$tmp_libs $deplib" ;; ++ esac ++ ;; ++ *) tmp_libs="$tmp_libs $deplib" ;; ++ esac ++ done ++ eval $var=\$tmp_libs ++ done # for var ++ fi ++ # Last step: remove runtime libs from dependency_libs ++ # (they stay in deplibs) ++ tmp_libs= ++ for i in $dependency_libs ; do ++ case " $predeps $postdeps $compiler_lib_search_path " in ++ *" $i "*) ++ i="" ++ ;; ++ esac ++ if test -n "$i" ; then ++ tmp_libs="$tmp_libs $i" ++ fi ++ done ++ dependency_libs=$tmp_libs ++ done # for pass ++ if test "$linkmode" = prog; then ++ dlfiles="$newdlfiles" ++ fi ++ if test "$linkmode" = prog || test "$linkmode" = lib; then ++ dlprefiles="$newdlprefiles" ++ fi ++ ++ case $linkmode in ++ oldlib) ++ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then ++ func_warning "\`-dlopen' is ignored for archives" ++ fi ++ ++ case " $deplibs" in ++ *\ -l* | *\ -L*) ++ func_warning "\`-l' and \`-L' are ignored for archives" ;; ++ esac ++ ++ test -n "$rpath" && \ ++ func_warning "\`-rpath' is ignored for archives" ++ ++ test -n "$xrpath" && \ ++ func_warning "\`-R' is ignored for archives" ++ ++ test -n "$vinfo" && \ ++ func_warning "\`-version-info/-version-number' is ignored for archives" ++ ++ test -n "$release" && \ ++ func_warning "\`-release' is ignored for archives" ++ ++ test -n "$export_symbols$export_symbols_regex" && \ ++ func_warning "\`-export-symbols' is ignored for archives" ++ ++ # Now set the variables for building old libraries. ++ build_libtool_libs=no ++ oldlibs="$output" ++ objs="$objs$old_deplibs" ++ ;; ++ ++ lib) ++ # Make sure we only generate libraries of the form `libNAME.la'. ++ case $outputname in ++ lib*) ++ func_stripname 'lib' '.la' "$outputname" ++ name=$func_stripname_result ++ eval "shared_ext=\"$shrext_cmds\"" ++ eval "libname=\"$libname_spec\"" ++ ;; ++ *) ++ test "$module" = no && \ ++ func_fatal_help "libtool library \`$output' must begin with \`lib'" ++ ++ if test "$need_lib_prefix" != no; then ++ # Add the "lib" prefix for modules if required ++ func_stripname '' '.la' "$outputname" ++ name=$func_stripname_result ++ eval "shared_ext=\"$shrext_cmds\"" ++ eval "libname=\"$libname_spec\"" ++ else ++ func_stripname '' '.la' "$outputname" ++ libname=$func_stripname_result ++ fi ++ ;; ++ esac ++ ++ if test -n "$objs"; then ++ if test "$deplibs_check_method" != pass_all; then ++ func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" ++ else ++ echo ++ $ECHO "*** Warning: Linking the shared library $output against the non-libtool" ++ $ECHO "*** objects $objs is not portable!" ++ libobjs="$libobjs $objs" ++ fi ++ fi ++ ++ test "$dlself" != no && \ ++ func_warning "\`-dlopen self' is ignored for libtool libraries" ++ ++ set dummy $rpath ++ shift ++ test "$#" -gt 1 && \ ++ func_warning "ignoring multiple \`-rpath's for a libtool library" ++ ++ install_libdir="$1" ++ ++ oldlibs= ++ if test -z "$rpath"; then ++ if test "$build_libtool_libs" = yes; then ++ # Building a libtool convenience library. ++ # Some compilers have problems with a `.al' extension so ++ # convenience libraries should have the same extension an ++ # archive normally would. ++ oldlibs="$output_objdir/$libname.$libext $oldlibs" ++ build_libtool_libs=convenience ++ build_old_libs=yes ++ fi ++ ++ test -n "$vinfo" && \ ++ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" ++ ++ test -n "$release" && \ ++ func_warning "\`-release' is ignored for convenience libraries" ++ else ++ ++ # Parse the version information argument. ++ save_ifs="$IFS"; IFS=':' ++ set dummy $vinfo 0 0 0 ++ shift ++ IFS="$save_ifs" ++ ++ test -n "$7" && \ ++ func_fatal_help "too many parameters to \`-version-info'" ++ ++ # convert absolute version numbers to libtool ages ++ # this retains compatibility with .la files and attempts ++ # to make the code below a bit more comprehensible ++ ++ case $vinfo_number in ++ yes) ++ number_major="$1" ++ number_minor="$2" ++ number_revision="$3" ++ # ++ # There are really only two kinds -- those that ++ # use the current revision as the major version ++ # and those that subtract age and use age as ++ # a minor version. But, then there is irix ++ # which has an extra 1 added just for fun ++ # ++ case $version_type in ++ darwin|linux|osf|windows|none) ++ func_arith $number_major + $number_minor ++ current=$func_arith_result ++ age="$number_minor" ++ revision="$number_revision" ++ ;; ++ freebsd-aout|freebsd-elf|qnx|sunos) ++ current="$number_major" ++ revision="$number_minor" ++ age="0" ++ ;; ++ irix|nonstopux) ++ func_arith $number_major + $number_minor ++ current=$func_arith_result ++ age="$number_minor" ++ revision="$number_minor" ++ lt_irix_increment=no ++ ;; ++ esac ++ ;; ++ no) ++ current="$1" ++ revision="$2" ++ age="$3" ++ ;; ++ esac ++ ++ # Check that each of the things are valid numbers. ++ case $current in ++ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; ++ *) ++ func_error "CURRENT \`$current' must be a nonnegative integer" ++ func_fatal_error "\`$vinfo' is not valid version information" ++ ;; ++ esac ++ ++ case $revision in ++ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; ++ *) ++ func_error "REVISION \`$revision' must be a nonnegative integer" ++ func_fatal_error "\`$vinfo' is not valid version information" ++ ;; ++ esac ++ ++ case $age in ++ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; ++ *) ++ func_error "AGE \`$age' must be a nonnegative integer" ++ func_fatal_error "\`$vinfo' is not valid version information" ++ ;; ++ esac ++ ++ if test "$age" -gt "$current"; then ++ func_error "AGE \`$age' is greater than the current interface number \`$current'" ++ func_fatal_error "\`$vinfo' is not valid version information" ++ fi ++ ++ # Calculate the version variables. ++ major= ++ versuffix= ++ verstring= ++ case $version_type in ++ none) ;; ++ ++ darwin) ++ # Like Linux, but with the current version available in ++ # verstring for coding it into the library header ++ func_arith $current - $age ++ major=.$func_arith_result ++ versuffix="$major.$age.$revision" ++ # Darwin ld doesn't like 0 for these options... ++ func_arith $current + 1 ++ minor_current=$func_arith_result ++ xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" ++ verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ++ ;; ++ ++ freebsd-aout) ++ major=".$current" ++ versuffix=".$current.$revision"; ++ ;; ++ ++ freebsd-elf) ++ major=".$current" ++ versuffix=".$current" ++ ;; ++ ++ irix | nonstopux) ++ if test "X$lt_irix_increment" = "Xno"; then ++ func_arith $current - $age ++ else ++ func_arith $current - $age + 1 ++ fi ++ major=$func_arith_result ++ ++ case $version_type in ++ nonstopux) verstring_prefix=nonstopux ;; ++ *) verstring_prefix=sgi ;; ++ esac ++ verstring="$verstring_prefix$major.$revision" ++ ++ # Add in all the interfaces that we are compatible with. ++ loop=$revision ++ while test "$loop" -ne 0; do ++ func_arith $revision - $loop ++ iface=$func_arith_result ++ func_arith $loop - 1 ++ loop=$func_arith_result ++ verstring="$verstring_prefix$major.$iface:$verstring" ++ done ++ ++ # Before this point, $major must not contain `.'. ++ major=.$major ++ versuffix="$major.$revision" ++ ;; ++ ++ linux) ++ func_arith $current - $age ++ major=.$func_arith_result ++ versuffix="$major.$age.$revision" ++ ;; ++ ++ osf) ++ func_arith $current - $age ++ major=.$func_arith_result ++ versuffix=".$current.$age.$revision" ++ verstring="$current.$age.$revision" ++ ++ # Add in all the interfaces that we are compatible with. ++ loop=$age ++ while test "$loop" -ne 0; do ++ func_arith $current - $loop ++ iface=$func_arith_result ++ func_arith $loop - 1 ++ loop=$func_arith_result ++ verstring="$verstring:${iface}.0" ++ done ++ ++ # Make executables depend on our current version. ++ verstring="$verstring:${current}.0" ++ ;; ++ ++ qnx) ++ major=".$current" ++ versuffix=".$current" ++ ;; ++ ++ sunos) ++ major=".$current" ++ versuffix=".$current.$revision" ++ ;; ++ ++ windows) ++ # Use '-' rather than '.', since we only want one ++ # extension on DOS 8.3 filesystems. ++ func_arith $current - $age ++ major=$func_arith_result ++ versuffix="-$major" ++ ;; ++ ++ *) ++ func_fatal_configuration "unknown library version type \`$version_type'" ++ ;; ++ esac ++ ++ # Clear the version info if we defaulted, and they specified a release. ++ if test -z "$vinfo" && test -n "$release"; then ++ major= ++ case $version_type in ++ darwin) ++ # we can't check for "0.0" in archive_cmds due to quoting ++ # problems, so we reset it completely ++ verstring= ++ ;; ++ *) ++ verstring="0.0" ++ ;; ++ esac ++ if test "$need_version" = no; then ++ versuffix= ++ else ++ versuffix=".0.0" ++ fi ++ fi ++ ++ # Remove version info from name if versioning should be avoided ++ if test "$avoid_version" = yes && test "$need_version" = no; then ++ major= ++ versuffix= ++ verstring="" ++ fi ++ ++ # Check to see if the archive will have undefined symbols. ++ if test "$allow_undefined" = yes; then ++ if test "$allow_undefined_flag" = unsupported; then ++ func_warning "undefined symbols not allowed in $host shared libraries" ++ build_libtool_libs=no ++ build_old_libs=yes ++ fi ++ else ++ # Don't allow undefined symbols. ++ allow_undefined_flag="$no_undefined_flag" ++ fi ++ ++ fi ++ ++ func_generate_dlsyms "$libname" "$libname" "yes" ++ libobjs="$libobjs $symfileobj" ++ test "X$libobjs" = "X " && libobjs= ++ ++ if test "$mode" != relink; then ++ # Remove our outputs, but don't remove object files since they ++ # may have been created when compiling PIC objects. ++ removelist= ++ tempremovelist=`$ECHO "$output_objdir/*"` ++ for p in $tempremovelist; do ++ case $p in ++ *.$objext | *.gcno) ++ ;; ++ $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) ++ if test "X$precious_files_regex" != "X"; then ++ if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 ++ then ++ continue ++ fi ++ fi ++ removelist="$removelist $p" ++ ;; ++ *) ;; ++ esac ++ done ++ test -n "$removelist" && \ ++ func_show_eval "${RM}r \$removelist" ++ fi ++ ++ # Now set the variables for building old libraries. ++ if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then ++ oldlibs="$oldlibs $output_objdir/$libname.$libext" ++ ++ # Transform .lo files to .o files. ++ oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` ++ fi ++ ++ # Eliminate all temporary directories. ++ #for path in $notinst_path; do ++ # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` ++ # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` ++ # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` ++ #done ++ ++ if test -n "$xrpath"; then ++ # If the user specified any rpath flags, then add them. ++ temp_xrpath= ++ for libdir in $xrpath; do ++ temp_xrpath="$temp_xrpath -R$libdir" ++ case "$finalize_rpath " in ++ *" $libdir "*) ;; ++ *) finalize_rpath="$finalize_rpath $libdir" ;; ++ esac ++ done ++ if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then ++ dependency_libs="$temp_xrpath $dependency_libs" ++ fi ++ fi ++ ++ # Make sure dlfiles contains only unique files that won't be dlpreopened ++ old_dlfiles="$dlfiles" ++ dlfiles= ++ for lib in $old_dlfiles; do ++ case " $dlprefiles $dlfiles " in ++ *" $lib "*) ;; ++ *) dlfiles="$dlfiles $lib" ;; ++ esac ++ done ++ ++ # Make sure dlprefiles contains only unique files ++ old_dlprefiles="$dlprefiles" ++ dlprefiles= ++ for lib in $old_dlprefiles; do ++ case "$dlprefiles " in ++ *" $lib "*) ;; ++ *) dlprefiles="$dlprefiles $lib" ;; ++ esac ++ done ++ ++ if test "$build_libtool_libs" = yes; then ++ if test -n "$rpath"; then ++ case $host in ++ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) ++ # these systems don't actually have a c library (as such)! ++ ;; ++ *-*-rhapsody* | *-*-darwin1.[012]) ++ # Rhapsody C library is in the System framework ++ deplibs="$deplibs System.ltframework" ++ ;; ++ *-*-netbsd*) ++ # Don't link with libc until the a.out ld.so is fixed. ++ ;; ++ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) ++ # Do not include libc due to us having libc/libc_r. ++ ;; ++ *-*-sco3.2v5* | *-*-sco5v6*) ++ # Causes problems with __ctype ++ ;; ++ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) ++ # Compiler inserts libc in the correct place for threads to work ++ ;; ++ *) ++ # Add libc to deplibs on all other systems if necessary. ++ if test "$build_libtool_need_lc" = "yes"; then ++ deplibs="$deplibs -lc" ++ fi ++ ;; ++ esac ++ fi ++ ++ # Transform deplibs into only deplibs that can be linked in shared. ++ name_save=$name ++ libname_save=$libname ++ release_save=$release ++ versuffix_save=$versuffix ++ major_save=$major ++ # I'm not sure if I'm treating the release correctly. I think ++ # release should show up in the -l (ie -lgmp5) so we don't want to ++ # add it in twice. Is that correct? ++ release="" ++ versuffix="" ++ major="" ++ newdeplibs= ++ droppeddeps=no ++ case $deplibs_check_method in ++ pass_all) ++ # Don't check for shared/static. Everything works. ++ # This might be a little naive. We might want to check ++ # whether the library exists or not. But this is on ++ # osf3 & osf4 and I'm not really sure... Just ++ # implementing what was already the behavior. ++ newdeplibs=$deplibs ++ ;; ++ test_compile) ++ # This code stresses the "libraries are programs" paradigm to its ++ # limits. Maybe even breaks it. We compile a program, linking it ++ # against the deplibs as a proxy for the library. Then we can check ++ # whether they linked in statically or dynamically with ldd. ++ $opt_dry_run || $RM conftest.c ++ cat > conftest.c </dev/null` ++ for potent_lib in $potential_libs; do ++ # Follow soft links. ++ if ls -lLd "$potent_lib" 2>/dev/null | ++ $GREP " -> " >/dev/null; then ++ continue ++ fi ++ # The statement above tries to avoid entering an ++ # endless loop below, in case of cyclic links. ++ # We might still enter an endless loop, since a link ++ # loop can be closed while we follow links, ++ # but so what? ++ potlib="$potent_lib" ++ while test -h "$potlib" 2>/dev/null; do ++ potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` ++ case $potliblink in ++ [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; ++ *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; ++ esac ++ done ++ if eval "$file_magic_cmd \"\$potlib\"" 2>/dev/null | ++ $SED -e 10q | ++ $EGREP "$file_magic_regex" > /dev/null; then ++ newdeplibs="$newdeplibs $a_deplib" ++ a_deplib="" ++ break 2 ++ fi ++ done ++ done ++ fi ++ if test -n "$a_deplib" ; then ++ droppeddeps=yes ++ echo ++ $ECHO "*** Warning: linker path does not have real file for library $a_deplib." ++ echo "*** I have the capability to make that library automatically link in when" ++ echo "*** you link to this library. But I can only do this if you have a" ++ echo "*** shared version of the library, which you do not appear to have" ++ echo "*** because I did check the linker path looking for a file starting" ++ if test -z "$potlib" ; then ++ $ECHO "*** with $libname but no candidates were found. (...for file magic test)" ++ else ++ $ECHO "*** with $libname and none of the candidates passed a file format test" ++ $ECHO "*** using a file magic. Last file checked: $potlib" ++ fi ++ fi ++ ;; ++ *) ++ # Add a -L argument. ++ newdeplibs="$newdeplibs $a_deplib" ++ ;; ++ esac ++ done # Gone through all deplibs. ++ ;; ++ match_pattern*) ++ set dummy $deplibs_check_method; shift ++ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` ++ for a_deplib in $deplibs; do ++ case $a_deplib in ++ -l*) ++ func_stripname -l '' "$a_deplib" ++ name=$func_stripname_result ++ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then ++ case " $predeps $postdeps " in ++ *" $a_deplib "*) ++ newdeplibs="$newdeplibs $a_deplib" ++ a_deplib="" ++ ;; ++ esac ++ fi ++ if test -n "$a_deplib" ; then ++ eval "libname=\"$libname_spec\"" ++ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do ++ potential_libs=`ls $i/$libname[.-]* 2>/dev/null` ++ for potent_lib in $potential_libs; do ++ potlib="$potent_lib" # see symlink-check above in file_magic test ++ if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ ++ $EGREP "$match_pattern_regex" > /dev/null; then ++ newdeplibs="$newdeplibs $a_deplib" ++ a_deplib="" ++ break 2 ++ fi ++ done ++ done ++ fi ++ if test -n "$a_deplib" ; then ++ droppeddeps=yes ++ echo ++ $ECHO "*** Warning: linker path does not have real file for library $a_deplib." ++ echo "*** I have the capability to make that library automatically link in when" ++ echo "*** you link to this library. But I can only do this if you have a" ++ echo "*** shared version of the library, which you do not appear to have" ++ echo "*** because I did check the linker path looking for a file starting" ++ if test -z "$potlib" ; then ++ $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" ++ else ++ $ECHO "*** with $libname and none of the candidates passed a file format test" ++ $ECHO "*** using a regex pattern. Last file checked: $potlib" ++ fi ++ fi ++ ;; ++ *) ++ # Add a -L argument. ++ newdeplibs="$newdeplibs $a_deplib" ++ ;; ++ esac ++ done # Gone through all deplibs. ++ ;; ++ none | unknown | *) ++ newdeplibs="" ++ tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` ++ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then ++ for i in $predeps $postdeps ; do ++ # can't use Xsed below, because $i might contain '/' ++ tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` ++ done ++ fi ++ case $tmp_deplibs in ++ *[!\ \ ]*) ++ echo ++ if test "X$deplibs_check_method" = "Xnone"; then ++ echo "*** Warning: inter-library dependencies are not supported in this platform." ++ else ++ echo "*** Warning: inter-library dependencies are not known to be supported." ++ fi ++ echo "*** All declared inter-library dependencies are being dropped." ++ droppeddeps=yes ++ ;; ++ esac ++ ;; ++ esac ++ versuffix=$versuffix_save ++ major=$major_save ++ release=$release_save ++ libname=$libname_save ++ name=$name_save ++ ++ case $host in ++ *-*-rhapsody* | *-*-darwin1.[012]) ++ # On Rhapsody replace the C library with the System framework ++ newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ++ ;; ++ esac ++ ++ if test "$droppeddeps" = yes; then ++ if test "$module" = yes; then ++ echo ++ echo "*** Warning: libtool could not satisfy all declared inter-library" ++ $ECHO "*** dependencies of module $libname. Therefore, libtool will create" ++ echo "*** a static module, that should work as long as the dlopening" ++ echo "*** application is linked with the -dlopen flag." ++ if test -z "$global_symbol_pipe"; then ++ echo ++ echo "*** However, this would only work if libtool was able to extract symbol" ++ echo "*** lists from a program, using \`nm' or equivalent, but libtool could" ++ echo "*** not find such a program. So, this module is probably useless." ++ echo "*** \`nm' from GNU binutils and a full rebuild may help." ++ fi ++ if test "$build_old_libs" = no; then ++ oldlibs="$output_objdir/$libname.$libext" ++ build_libtool_libs=module ++ build_old_libs=yes ++ else ++ build_libtool_libs=no ++ fi ++ else ++ echo "*** The inter-library dependencies that have been dropped here will be" ++ echo "*** automatically added whenever a program is linked with this library" ++ echo "*** or is declared to -dlopen it." ++ ++ if test "$allow_undefined" = no; then ++ echo ++ echo "*** Since this library must not contain undefined symbols," ++ echo "*** because either the platform does not support them or" ++ echo "*** it was explicitly requested with -no-undefined," ++ echo "*** libtool will only create a static version of it." ++ if test "$build_old_libs" = no; then ++ oldlibs="$output_objdir/$libname.$libext" ++ build_libtool_libs=module ++ build_old_libs=yes ++ else ++ build_libtool_libs=no ++ fi ++ fi ++ fi ++ fi ++ # Done checking deplibs! ++ deplibs=$newdeplibs ++ fi ++ # Time to change all our "foo.ltframework" stuff back to "-framework foo" ++ case $host in ++ *-*-darwin*) ++ newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ++ new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ++ deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ++ ;; ++ esac ++ ++ # move library search paths that coincide with paths to not yet ++ # installed libraries to the beginning of the library search list ++ new_libs= ++ for path in $notinst_path; do ++ case " $new_libs " in ++ *" -L$path/$objdir "*) ;; ++ *) ++ case " $deplibs " in ++ *" -L$path/$objdir "*) ++ new_libs="$new_libs -L$path/$objdir" ;; ++ esac ++ ;; ++ esac ++ done ++ for deplib in $deplibs; do ++ case $deplib in ++ -L*) ++ case " $new_libs " in ++ *" $deplib "*) ;; ++ *) new_libs="$new_libs $deplib" ;; ++ esac ++ ;; ++ *) new_libs="$new_libs $deplib" ;; ++ esac ++ done ++ deplibs="$new_libs" ++ ++ # All the library-specific variables (install_libdir is set above). ++ library_names= ++ old_library= ++ dlname= ++ ++ # Test again, we may have decided not to build it any more ++ if test "$build_libtool_libs" = yes; then ++ if test "$hardcode_into_libs" = yes; then ++ # Hardcode the library paths ++ hardcode_libdirs= ++ dep_rpath= ++ rpath="$finalize_rpath" ++ test "$mode" != relink && rpath="$compile_rpath$rpath" ++ for libdir in $rpath; do ++ if test -n "$hardcode_libdir_flag_spec"; then ++ if test -n "$hardcode_libdir_separator"; then ++ if test -z "$hardcode_libdirs"; then ++ hardcode_libdirs="$libdir" ++ else ++ # Just accumulate the unique libdirs. ++ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in ++ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ++ ;; ++ *) ++ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ++ ;; ++ esac ++ fi ++ else ++ eval "flag=\"$hardcode_libdir_flag_spec\"" ++ dep_rpath="$dep_rpath $flag" ++ fi ++ elif test -n "$runpath_var"; then ++ case "$perm_rpath " in ++ *" $libdir "*) ;; ++ *) perm_rpath="$perm_rpath $libdir" ;; ++ esac ++ fi ++ done ++ # Substitute the hardcoded libdirs into the rpath. ++ if test -n "$hardcode_libdir_separator" && ++ test -n "$hardcode_libdirs"; then ++ libdir="$hardcode_libdirs" ++ if test -n "$hardcode_libdir_flag_spec_ld"; then ++ eval "dep_rpath=\"$hardcode_libdir_flag_spec_ld\"" ++ else ++ eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" ++ fi ++ fi ++ if test -n "$runpath_var" && test -n "$perm_rpath"; then ++ # We should set the runpath_var. ++ rpath= ++ for dir in $perm_rpath; do ++ rpath="$rpath$dir:" ++ done ++ eval $runpath_var=\$rpath\$$runpath_var ++ export $runpath_var ++ fi ++ test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" ++ fi ++ ++ shlibpath="$finalize_shlibpath" ++ test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" ++ if test -n "$shlibpath"; then ++ eval $shlibpath_var=\$shlibpath\$$shlibpath_var ++ export $shlibpath_var ++ fi ++ ++ # Get the real and link names of the library. ++ eval "shared_ext=\"$shrext_cmds\"" ++ eval "library_names=\"$library_names_spec\"" ++ set dummy $library_names ++ shift ++ realname="$1" ++ shift ++ ++ if test -n "$soname_spec"; then ++ eval "soname=\"$soname_spec\"" ++ else ++ soname="$realname" ++ fi ++ if test -z "$dlname"; then ++ dlname=$soname ++ fi ++ ++ lib="$output_objdir/$realname" ++ linknames= ++ for link ++ do ++ linknames="$linknames $link" ++ done ++ ++ # Use standard objects if they are pic ++ test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` ++ test "X$libobjs" = "X " && libobjs= ++ ++ delfiles= ++ if test -n "$export_symbols" && test -n "$include_expsyms"; then ++ $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" ++ export_symbols="$output_objdir/$libname.uexp" ++ delfiles="$delfiles $export_symbols" ++ fi ++ ++ orig_export_symbols= ++ case $host_os in ++ cygwin* | mingw* | cegcc*) ++ if test -n "$export_symbols" && test -z "$export_symbols_regex"; then ++ # exporting using user supplied symfile ++ if test "x`$SED 1q $export_symbols`" != xEXPORTS; then ++ # and it's NOT already a .def file. Must figure out ++ # which of the given symbols are data symbols and tag ++ # them as such. So, trigger use of export_symbols_cmds. ++ # export_symbols gets reassigned inside the "prepare ++ # the list of exported symbols" if statement, so the ++ # include_expsyms logic still works. ++ orig_export_symbols="$export_symbols" ++ export_symbols= ++ always_export_symbols=yes ++ fi ++ fi ++ ;; ++ esac ++ ++ # Prepare the list of exported symbols ++ if test -z "$export_symbols"; then ++ if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then ++ func_verbose "generating symbol list for \`$libname.la'" ++ export_symbols="$output_objdir/$libname.exp" ++ $opt_dry_run || $RM $export_symbols ++ cmds=$export_symbols_cmds ++ save_ifs="$IFS"; IFS='~' ++ for cmd in $cmds; do ++ IFS="$save_ifs" ++ eval "cmd=\"$cmd\"" ++ func_len " $cmd" ++ len=$func_len_result ++ if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then ++ func_show_eval "$cmd" 'exit $?' ++ skipped_export=false ++ else ++ # The command line is too long to execute in one step. ++ func_verbose "using reloadable object file for export list..." ++ skipped_export=: ++ # Break out early, otherwise skipped_export may be ++ # set to false by a later but shorter cmd. ++ break ++ fi ++ done ++ IFS="$save_ifs" ++ if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then ++ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' ++ func_show_eval '$MV "${export_symbols}T" "$export_symbols"' ++ fi ++ fi ++ fi ++ ++ if test -n "$export_symbols" && test -n "$include_expsyms"; then ++ tmp_export_symbols="$export_symbols" ++ test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" ++ $opt_dry_run || $ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols" ++ fi ++ ++ if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then ++ # The given exports_symbols file has to be filtered, so filter it. ++ func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" ++ # FIXME: $output_objdir/$libname.filter potentially contains lots of ++ # 's' commands which not all seds can handle. GNU sed should be fine ++ # though. Also, the filter scales superlinearly with the number of ++ # global variables. join(1) would be nice here, but unfortunately ++ # isn't a blessed tool. ++ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter ++ delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" ++ export_symbols=$output_objdir/$libname.def ++ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols ++ fi ++ ++ tmp_deplibs= ++ for test_deplib in $deplibs; do ++ case " $convenience " in ++ *" $test_deplib "*) ;; ++ *) ++ tmp_deplibs="$tmp_deplibs $test_deplib" ++ ;; ++ esac ++ done ++ deplibs="$tmp_deplibs" ++ ++ if test -n "$convenience"; then ++ if test -n "$whole_archive_flag_spec" && ++ test "$compiler_needs_object" = yes && ++ test -z "$libobjs"; then ++ # extract the archives, so we have objects to list. ++ # TODO: could optimize this to just extract one archive. ++ whole_archive_flag_spec= ++ fi ++ if test -n "$whole_archive_flag_spec"; then ++ save_libobjs=$libobjs ++ eval "libobjs=\"\$libobjs $whole_archive_flag_spec\"" ++ test "X$libobjs" = "X " && libobjs= ++ else ++ gentop="$output_objdir/${outputname}x" ++ generated="$generated $gentop" ++ ++ func_extract_archives $gentop $convenience ++ libobjs="$libobjs $func_extract_archives_result" ++ test "X$libobjs" = "X " && libobjs= ++ fi ++ fi ++ ++ if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then ++ eval "flag=\"$thread_safe_flag_spec\"" ++ linker_flags="$linker_flags $flag" ++ fi ++ ++ # Make a backup of the uninstalled library when relinking ++ if test "$mode" = relink; then ++ $opt_dry_run || (cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U) || exit $? ++ fi ++ ++ # Do each of the archive commands. ++ if test "$module" = yes && test -n "$module_cmds" ; then ++ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then ++ eval "test_cmds=\"$module_expsym_cmds\"" ++ cmds=$module_expsym_cmds ++ else ++ eval "test_cmds=\"$module_cmds\"" ++ cmds=$module_cmds ++ fi ++ else ++ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then ++ eval "test_cmds=\"$archive_expsym_cmds\"" ++ cmds=$archive_expsym_cmds ++ else ++ eval "test_cmds=\"$archive_cmds\"" ++ cmds=$archive_cmds ++ fi ++ fi ++ ++ if test "X$skipped_export" != "X:" && ++ func_len " $test_cmds" && ++ len=$func_len_result && ++ test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then ++ : ++ else ++ # The command line is too long to link in one step, link piecewise ++ # or, if using GNU ld and skipped_export is not :, use a linker ++ # script. ++ ++ # Save the value of $output and $libobjs because we want to ++ # use them later. If we have whole_archive_flag_spec, we ++ # want to use save_libobjs as it was before ++ # whole_archive_flag_spec was expanded, because we can't ++ # assume the linker understands whole_archive_flag_spec. ++ # This may have to be revisited, in case too many ++ # convenience libraries get linked in and end up exceeding ++ # the spec. ++ if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then ++ save_libobjs=$libobjs ++ fi ++ save_output=$output ++ func_basename "$output" ++ output_la=$func_basename_result ++ ++ # Clear the reloadable object creation command queue and ++ # initialize k to one. ++ test_cmds= ++ concat_cmds= ++ objlist= ++ last_robj= ++ k=1 ++ ++ if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then ++ output=${output_objdir}/${output_la}.lnkscript ++ func_verbose "creating GNU ld script: $output" ++ echo 'INPUT (' > $output ++ for obj in $save_libobjs ++ do ++ $ECHO "$obj" >> $output ++ done ++ echo ')' >> $output ++ delfiles="$delfiles $output" ++ elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then ++ output=${output_objdir}/${output_la}.lnk ++ func_verbose "creating linker input file list: $output" ++ : > $output ++ set x $save_libobjs ++ shift ++ firstobj= ++ if test "$compiler_needs_object" = yes; then ++ firstobj="$1 " ++ shift ++ fi ++ for obj ++ do ++ $ECHO "$obj" >> $output ++ done ++ delfiles="$delfiles $output" ++ output=$firstobj\"$file_list_spec$output\" ++ else ++ if test -n "$save_libobjs"; then ++ func_verbose "creating reloadable object files..." ++ output=$output_objdir/$output_la-${k}.$objext ++ eval "test_cmds=\"$reload_cmds\"" ++ func_len " $test_cmds" ++ len0=$func_len_result ++ len=$len0 ++ ++ # Loop over the list of objects to be linked. ++ for obj in $save_libobjs ++ do ++ func_len " $obj" ++ func_arith $len + $func_len_result ++ len=$func_arith_result ++ if test "X$objlist" = X || ++ test "$len" -lt "$max_cmd_len"; then ++ func_append objlist " $obj" ++ else ++ # The command $test_cmds is almost too long, add a ++ # command to the queue. ++ if test "$k" -eq 1 ; then ++ # The first file doesn't have a previous command to add. ++ reload_objs=$objlist ++ eval "concat_cmds=\"$reload_cmds\"" ++ else ++ # All subsequent reloadable object files will link in ++ # the last one created. ++ reload_objs="$objlist $last_robj" ++ eval "concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"" ++ fi ++ last_robj=$output_objdir/$output_la-${k}.$objext ++ func_arith $k + 1 ++ k=$func_arith_result ++ output=$output_objdir/$output_la-${k}.$objext ++ objlist=" $obj" ++ func_len " $last_robj" ++ func_arith $len0 + $func_len_result ++ len=$func_arith_result ++ fi ++ done ++ # Handle the remaining objects by creating one last ++ # reloadable object file. All subsequent reloadable object ++ # files will link in the last one created. ++ test -z "$concat_cmds" || concat_cmds=$concat_cmds~ ++ reload_objs="$objlist $last_robj" ++ eval "concat_cmds=\"\${concat_cmds}$reload_cmds\"" ++ if test -n "$last_robj"; then ++ eval "concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"" ++ fi ++ delfiles="$delfiles $output" ++ ++ else ++ output= ++ fi ++ ++ if ${skipped_export-false}; then ++ func_verbose "generating symbol list for \`$libname.la'" ++ export_symbols="$output_objdir/$libname.exp" ++ $opt_dry_run || $RM $export_symbols ++ libobjs=$output ++ # Append the command to create the export file. ++ test -z "$concat_cmds" || concat_cmds=$concat_cmds~ ++ eval "concat_cmds=\"\$concat_cmds$export_symbols_cmds\"" ++ if test -n "$last_robj"; then ++ eval "concat_cmds=\"\$concat_cmds~\$RM $last_robj\"" ++ fi ++ fi ++ ++ test -n "$save_libobjs" && ++ func_verbose "creating a temporary reloadable object file: $output" ++ ++ # Loop through the commands generated above and execute them. ++ save_ifs="$IFS"; IFS='~' ++ for cmd in $concat_cmds; do ++ IFS="$save_ifs" ++ $opt_silent || { ++ func_quote_for_expand "$cmd" ++ eval "func_echo $func_quote_for_expand_result" ++ } ++ $opt_dry_run || eval "$cmd" || { ++ lt_exit=$? ++ ++ # Restore the uninstalled library and exit ++ if test "$mode" = relink; then ++ ( cd "$output_objdir" && \ ++ $RM "${realname}T" && \ ++ $MV "${realname}U" "$realname" ) ++ fi ++ ++ exit $lt_exit ++ } ++ done ++ IFS="$save_ifs" ++ ++ if test -n "$export_symbols_regex" && ${skipped_export-false}; then ++ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' ++ func_show_eval '$MV "${export_symbols}T" "$export_symbols"' ++ fi ++ fi ++ ++ if ${skipped_export-false}; then ++ if test -n "$export_symbols" && test -n "$include_expsyms"; then ++ tmp_export_symbols="$export_symbols" ++ test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" ++ $opt_dry_run || $ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols" ++ fi ++ ++ if test -n "$orig_export_symbols"; then ++ # The given exports_symbols file has to be filtered, so filter it. ++ func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" ++ # FIXME: $output_objdir/$libname.filter potentially contains lots of ++ # 's' commands which not all seds can handle. GNU sed should be fine ++ # though. Also, the filter scales superlinearly with the number of ++ # global variables. join(1) would be nice here, but unfortunately ++ # isn't a blessed tool. ++ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter ++ delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" ++ export_symbols=$output_objdir/$libname.def ++ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols ++ fi ++ fi ++ ++ libobjs=$output ++ # Restore the value of output. ++ output=$save_output ++ ++ if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then ++ eval "libobjs=\"\$libobjs $whole_archive_flag_spec\"" ++ test "X$libobjs" = "X " && libobjs= ++ fi ++ # Expand the library linking commands again to reset the ++ # value of $libobjs for piecewise linking. ++ ++ # Do each of the archive commands. ++ if test "$module" = yes && test -n "$module_cmds" ; then ++ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then ++ cmds=$module_expsym_cmds ++ else ++ cmds=$module_cmds ++ fi ++ else ++ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then ++ cmds=$archive_expsym_cmds ++ else ++ cmds=$archive_cmds ++ fi ++ fi ++ fi ++ ++ if test -n "$delfiles"; then ++ # Append the command to remove temporary files to $cmds. ++ eval "cmds=\"\$cmds~\$RM $delfiles\"" ++ fi ++ ++ # Add any objects from preloaded convenience libraries ++ if test -n "$dlprefiles"; then ++ gentop="$output_objdir/${outputname}x" ++ generated="$generated $gentop" ++ ++ func_extract_archives $gentop $dlprefiles ++ libobjs="$libobjs $func_extract_archives_result" ++ test "X$libobjs" = "X " && libobjs= ++ fi ++ ++ save_ifs="$IFS"; IFS='~' ++ for cmd in $cmds; do ++ IFS="$save_ifs" ++ eval "cmd=\"$cmd\"" ++ $opt_silent || { ++ func_quote_for_expand "$cmd" ++ eval "func_echo $func_quote_for_expand_result" ++ } ++ $opt_dry_run || eval "$cmd" || { ++ lt_exit=$? ++ ++ # Restore the uninstalled library and exit ++ if test "$mode" = relink; then ++ ( cd "$output_objdir" && \ ++ $RM "${realname}T" && \ ++ $MV "${realname}U" "$realname" ) ++ fi ++ ++ exit $lt_exit ++ } ++ done ++ IFS="$save_ifs" ++ ++ # Restore the uninstalled library and exit ++ if test "$mode" = relink; then ++ $opt_dry_run || (cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname) || exit $? ++ ++ if test -n "$convenience"; then ++ if test -z "$whole_archive_flag_spec"; then ++ func_show_eval '${RM}r "$gentop"' ++ fi ++ fi ++ ++ exit $EXIT_SUCCESS ++ fi ++ ++ # Create links to the real library. ++ for linkname in $linknames; do ++ if test "$realname" != "$linkname"; then ++ func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' ++ fi ++ done ++ ++ # If -module or -export-dynamic was specified, set the dlname. ++ if test "$module" = yes || test "$export_dynamic" = yes; then ++ # On all known operating systems, these are identical. ++ dlname="$soname" ++ fi ++ fi ++ ;; ++ ++ obj) ++ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then ++ func_warning "\`-dlopen' is ignored for objects" ++ fi ++ ++ case " $deplibs" in ++ *\ -l* | *\ -L*) ++ func_warning "\`-l' and \`-L' are ignored for objects" ;; ++ esac ++ ++ test -n "$rpath" && \ ++ func_warning "\`-rpath' is ignored for objects" ++ ++ test -n "$xrpath" && \ ++ func_warning "\`-R' is ignored for objects" ++ ++ test -n "$vinfo" && \ ++ func_warning "\`-version-info' is ignored for objects" ++ ++ test -n "$release" && \ ++ func_warning "\`-release' is ignored for objects" ++ ++ case $output in ++ *.lo) ++ test -n "$objs$old_deplibs" && \ ++ func_fatal_error "cannot build library object \`$output' from non-libtool objects" ++ ++ libobj=$output ++ func_lo2o "$libobj" ++ obj=$func_lo2o_result ++ ;; ++ *) ++ libobj= ++ obj="$output" ++ ;; ++ esac ++ ++ # Delete the old objects. ++ $opt_dry_run || $RM $obj $libobj ++ ++ # Objects from convenience libraries. This assumes ++ # single-version convenience libraries. Whenever we create ++ # different ones for PIC/non-PIC, this we'll have to duplicate ++ # the extraction. ++ reload_conv_objs= ++ gentop= ++ # reload_cmds runs $LD directly, so let us get rid of ++ # -Wl from whole_archive_flag_spec and hope we can get by with ++ # turning comma into space.. ++ wl= ++ ++ if test -n "$convenience"; then ++ if test -n "$whole_archive_flag_spec"; then ++ eval "tmp_whole_archive_flags=\"$whole_archive_flag_spec\"" ++ reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` ++ else ++ gentop="$output_objdir/${obj}x" ++ generated="$generated $gentop" ++ ++ func_extract_archives $gentop $convenience ++ reload_conv_objs="$reload_objs $func_extract_archives_result" ++ fi ++ fi ++ ++ # Create the old-style object. ++ reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test ++ ++ output="$obj" ++ func_execute_cmds "$reload_cmds" 'exit $?' ++ ++ # Exit if we aren't doing a library object file. ++ if test -z "$libobj"; then ++ if test -n "$gentop"; then ++ func_show_eval '${RM}r "$gentop"' ++ fi ++ ++ exit $EXIT_SUCCESS ++ fi ++ ++ if test "$build_libtool_libs" != yes; then ++ if test -n "$gentop"; then ++ func_show_eval '${RM}r "$gentop"' ++ fi ++ ++ # Create an invalid libtool object if no PIC, so that we don't ++ # accidentally link it into a program. ++ # $show "echo timestamp > $libobj" ++ # $opt_dry_run || echo timestamp > $libobj || exit $? ++ exit $EXIT_SUCCESS ++ fi ++ ++ if test -n "$pic_flag" || test "$pic_mode" != default; then ++ # Only do commands if we really have different PIC objects. ++ reload_objs="$libobjs $reload_conv_objs" ++ output="$libobj" ++ func_execute_cmds "$reload_cmds" 'exit $?' ++ fi ++ ++ if test -n "$gentop"; then ++ func_show_eval '${RM}r "$gentop"' ++ fi ++ ++ exit $EXIT_SUCCESS ++ ;; ++ ++ prog) ++ case $host in ++ *cygwin*) func_stripname '' '.exe' "$output" ++ output=$func_stripname_result.exe;; ++ esac ++ test -n "$vinfo" && \ ++ func_warning "\`-version-info' is ignored for programs" ++ ++ test -n "$release" && \ ++ func_warning "\`-release' is ignored for programs" ++ ++ test "$preload" = yes \ ++ && test "$dlopen_support" = unknown \ ++ && test "$dlopen_self" = unknown \ ++ && test "$dlopen_self_static" = unknown && \ ++ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." ++ ++ case $host in ++ *-*-rhapsody* | *-*-darwin1.[012]) ++ # On Rhapsody replace the C library is the System framework ++ compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` ++ finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ++ ;; ++ esac ++ ++ case $host in ++ *-*-darwin*) ++ # Don't allow lazy linking, it breaks C++ global constructors ++ # But is supposedly fixed on 10.4 or later (yay!). ++ if test "$tagname" = CXX ; then ++ case ${MACOSX_DEPLOYMENT_TARGET-10.0} in ++ 10.[0123]) ++ compile_command="$compile_command ${wl}-bind_at_load" ++ finalize_command="$finalize_command ${wl}-bind_at_load" ++ ;; ++ esac ++ fi ++ # Time to change all our "foo.ltframework" stuff back to "-framework foo" ++ compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ++ finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ++ ;; ++ esac ++ ++ ++ # move library search paths that coincide with paths to not yet ++ # installed libraries to the beginning of the library search list ++ new_libs= ++ for path in $notinst_path; do ++ case " $new_libs " in ++ *" -L$path/$objdir "*) ;; ++ *) ++ case " $compile_deplibs " in ++ *" -L$path/$objdir "*) ++ new_libs="$new_libs -L$path/$objdir" ;; ++ esac ++ ;; ++ esac ++ done ++ for deplib in $compile_deplibs; do ++ case $deplib in ++ -L*) ++ case " $new_libs " in ++ *" $deplib "*) ;; ++ *) new_libs="$new_libs $deplib" ;; ++ esac ++ ;; ++ *) new_libs="$new_libs $deplib" ;; ++ esac ++ done ++ compile_deplibs="$new_libs" ++ ++ ++ compile_command="$compile_command $compile_deplibs" ++ finalize_command="$finalize_command $finalize_deplibs" ++ ++ if test -n "$rpath$xrpath"; then ++ # If the user specified any rpath flags, then add them. ++ for libdir in $rpath $xrpath; do ++ # This is the magic to use -rpath. ++ case "$finalize_rpath " in ++ *" $libdir "*) ;; ++ *) finalize_rpath="$finalize_rpath $libdir" ;; ++ esac ++ done ++ fi ++ ++ # Now hardcode the library paths ++ rpath= ++ hardcode_libdirs= ++ for libdir in $compile_rpath $finalize_rpath; do ++ if test -n "$hardcode_libdir_flag_spec"; then ++ if test -n "$hardcode_libdir_separator"; then ++ if test -z "$hardcode_libdirs"; then ++ hardcode_libdirs="$libdir" ++ else ++ # Just accumulate the unique libdirs. ++ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in ++ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ++ ;; ++ *) ++ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ++ ;; ++ esac ++ fi ++ else ++ eval "flag=\"$hardcode_libdir_flag_spec\"" ++ rpath="$rpath $flag" ++ fi ++ elif test -n "$runpath_var"; then ++ case "$perm_rpath " in ++ *" $libdir "*) ;; ++ *) perm_rpath="$perm_rpath $libdir" ;; ++ esac ++ fi ++ case $host in ++ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) ++ testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` ++ case :$dllsearchpath: in ++ *":$libdir:"*) ;; ++ ::) dllsearchpath=$libdir;; ++ *) dllsearchpath="$dllsearchpath:$libdir";; ++ esac ++ case :$dllsearchpath: in ++ *":$testbindir:"*) ;; ++ ::) dllsearchpath=$testbindir;; ++ *) dllsearchpath="$dllsearchpath:$testbindir";; ++ esac ++ ;; ++ esac ++ done ++ # Substitute the hardcoded libdirs into the rpath. ++ if test -n "$hardcode_libdir_separator" && ++ test -n "$hardcode_libdirs"; then ++ libdir="$hardcode_libdirs" ++ eval "rpath=\" $hardcode_libdir_flag_spec\"" ++ fi ++ compile_rpath="$rpath" ++ ++ rpath= ++ hardcode_libdirs= ++ for libdir in $finalize_rpath; do ++ if test -n "$hardcode_libdir_flag_spec"; then ++ if test -n "$hardcode_libdir_separator"; then ++ if test -z "$hardcode_libdirs"; then ++ hardcode_libdirs="$libdir" ++ else ++ # Just accumulate the unique libdirs. ++ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in ++ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ++ ;; ++ *) ++ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ++ ;; ++ esac ++ fi ++ else ++ eval "flag=\"$hardcode_libdir_flag_spec\"" ++ rpath="$rpath $flag" ++ fi ++ elif test -n "$runpath_var"; then ++ case "$finalize_perm_rpath " in ++ *" $libdir "*) ;; ++ *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; ++ esac ++ fi ++ done ++ # Substitute the hardcoded libdirs into the rpath. ++ if test -n "$hardcode_libdir_separator" && ++ test -n "$hardcode_libdirs"; then ++ libdir="$hardcode_libdirs" ++ eval "rpath=\" $hardcode_libdir_flag_spec\"" ++ fi ++ finalize_rpath="$rpath" ++ ++ if test -n "$libobjs" && test "$build_old_libs" = yes; then ++ # Transform all the library objects into standard objects. ++ compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` ++ finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` ++ fi ++ ++ func_generate_dlsyms "$outputname" "@PROGRAM@" "no" ++ ++ # template prelinking step ++ if test -n "$prelink_cmds"; then ++ func_execute_cmds "$prelink_cmds" 'exit $?' ++ fi ++ ++ wrappers_required=yes ++ case $host in ++ *cegcc* | *mingw32ce*) ++ # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. ++ wrappers_required=no ++ ;; ++ *cygwin* | *mingw* ) ++ if test "$build_libtool_libs" != yes; then ++ wrappers_required=no ++ fi ++ ;; ++ *) ++ if test "$need_relink" = no || test "$build_libtool_libs" != yes; then ++ wrappers_required=no ++ fi ++ ;; ++ esac ++ if test "$wrappers_required" = no; then ++ # Replace the output file specification. ++ compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` ++ link_command="$compile_command$compile_rpath" ++ ++ # We have no uninstalled library dependencies, so finalize right now. ++ exit_status=0 ++ func_show_eval "$link_command" 'exit_status=$?' ++ ++ # Delete the generated files. ++ if test -f "$output_objdir/${outputname}S.${objext}"; then ++ func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' ++ fi ++ ++ exit $exit_status ++ fi ++ ++ if test -n "$compile_shlibpath$finalize_shlibpath"; then ++ compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" ++ fi ++ if test -n "$finalize_shlibpath"; then ++ finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" ++ fi ++ ++ compile_var= ++ finalize_var= ++ if test -n "$runpath_var"; then ++ if test -n "$perm_rpath"; then ++ # We should set the runpath_var. ++ rpath= ++ for dir in $perm_rpath; do ++ rpath="$rpath$dir:" ++ done ++ compile_var="$runpath_var=\"$rpath\$$runpath_var\" " ++ fi ++ if test -n "$finalize_perm_rpath"; then ++ # We should set the runpath_var. ++ rpath= ++ for dir in $finalize_perm_rpath; do ++ rpath="$rpath$dir:" ++ done ++ finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " ++ fi ++ fi ++ ++ if test "$no_install" = yes; then ++ # We don't need to create a wrapper script. ++ link_command="$compile_var$compile_command$compile_rpath" ++ # Replace the output file specification. ++ link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` ++ # Delete the old output file. ++ $opt_dry_run || $RM $output ++ # Link the executable and exit ++ func_show_eval "$link_command" 'exit $?' ++ exit $EXIT_SUCCESS ++ fi ++ ++ if test "$hardcode_action" = relink; then ++ # Fast installation is not supported ++ link_command="$compile_var$compile_command$compile_rpath" ++ relink_command="$finalize_var$finalize_command$finalize_rpath" ++ ++ func_warning "this platform does not like uninstalled shared libraries" ++ func_warning "\`$output' will be relinked during installation" ++ else ++ if test "$fast_install" != no; then ++ link_command="$finalize_var$compile_command$finalize_rpath" ++ if test "$fast_install" = yes; then ++ relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` ++ else ++ # fast_install is set to needless ++ relink_command= ++ fi ++ else ++ link_command="$compile_var$compile_command$compile_rpath" ++ relink_command="$finalize_var$finalize_command$finalize_rpath" ++ fi ++ fi ++ ++ # Replace the output file specification. ++ link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` ++ ++ # Delete the old output files. ++ $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname ++ ++ func_show_eval "$link_command" 'exit $?' ++ ++ # Now create the wrapper script. ++ func_verbose "creating $output" ++ ++ # Quote the relink command for shipping. ++ if test -n "$relink_command"; then ++ # Preserve any variables that may affect compiler behavior ++ for var in $variables_saved_for_relink; do ++ if eval test -z \"\${$var+set}\"; then ++ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" ++ elif eval var_value=\$$var; test -z "$var_value"; then ++ relink_command="$var=; export $var; $relink_command" ++ else ++ func_quote_for_eval "$var_value" ++ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" ++ fi ++ done ++ relink_command="(cd `pwd`; $relink_command)" ++ relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` ++ fi ++ ++ # Only actually do things if not in dry run mode. ++ $opt_dry_run || { ++ # win32 will think the script is a binary if it has ++ # a .exe suffix, so we strip it off here. ++ case $output in ++ *.exe) func_stripname '' '.exe' "$output" ++ output=$func_stripname_result ;; ++ esac ++ # test for cygwin because mv fails w/o .exe extensions ++ case $host in ++ *cygwin*) ++ exeext=.exe ++ func_stripname '' '.exe' "$outputname" ++ outputname=$func_stripname_result ;; ++ *) exeext= ;; ++ esac ++ case $host in ++ *cygwin* | *mingw* ) ++ func_dirname_and_basename "$output" "" "." ++ output_name=$func_basename_result ++ output_path=$func_dirname_result ++ cwrappersource="$output_path/$objdir/lt-$output_name.c" ++ cwrapper="$output_path/$output_name.exe" ++ $RM $cwrappersource $cwrapper ++ trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 ++ ++ func_emit_cwrapperexe_src > $cwrappersource ++ ++ # The wrapper executable is built using the $host compiler, ++ # because it contains $host paths and files. If cross- ++ # compiling, it, like the target executable, must be ++ # executed on the $host or under an emulation environment. ++ $opt_dry_run || { ++ $LTCC $LTCFLAGS -o $cwrapper $cwrappersource ++ $STRIP $cwrapper ++ } ++ ++ # Now, create the wrapper script for func_source use: ++ func_ltwrapper_scriptname $cwrapper ++ $RM $func_ltwrapper_scriptname_result ++ trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 ++ $opt_dry_run || { ++ # note: this script will not be executed, so do not chmod. ++ if test "x$build" = "x$host" ; then ++ $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result ++ else ++ func_emit_wrapper no > $func_ltwrapper_scriptname_result ++ fi ++ } ++ ;; ++ * ) ++ $RM $output ++ trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 ++ ++ func_emit_wrapper no > $output ++ chmod +x $output ++ ;; ++ esac ++ } ++ exit $EXIT_SUCCESS ++ ;; ++ esac ++ ++ # See if we need to build an old-fashioned archive. ++ for oldlib in $oldlibs; do ++ ++ if test "$build_libtool_libs" = convenience; then ++ oldobjs="$libobjs_save $symfileobj" ++ addlibs="$convenience" ++ build_libtool_libs=no ++ else ++ if test "$build_libtool_libs" = module; then ++ oldobjs="$libobjs_save" ++ build_libtool_libs=no ++ else ++ oldobjs="$old_deplibs $non_pic_objects" ++ if test "$preload" = yes && test -f "$symfileobj"; then ++ oldobjs="$oldobjs $symfileobj" ++ fi ++ fi ++ addlibs="$old_convenience" ++ fi ++ ++ if test -n "$addlibs"; then ++ gentop="$output_objdir/${outputname}x" ++ generated="$generated $gentop" ++ ++ func_extract_archives $gentop $addlibs ++ oldobjs="$oldobjs $func_extract_archives_result" ++ fi ++ ++ # Do each command in the archive commands. ++ if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then ++ cmds=$old_archive_from_new_cmds ++ else ++ ++ # Add any objects from preloaded convenience libraries ++ if test -n "$dlprefiles"; then ++ gentop="$output_objdir/${outputname}x" ++ generated="$generated $gentop" ++ ++ func_extract_archives $gentop $dlprefiles ++ oldobjs="$oldobjs $func_extract_archives_result" ++ fi ++ ++ # POSIX demands no paths to be encoded in archives. We have ++ # to avoid creating archives with duplicate basenames if we ++ # might have to extract them afterwards, e.g., when creating a ++ # static archive out of a convenience library, or when linking ++ # the entirety of a libtool archive into another (currently ++ # not supported by libtool). ++ if (for obj in $oldobjs ++ do ++ func_basename "$obj" ++ $ECHO "$func_basename_result" ++ done | sort | sort -uc >/dev/null 2>&1); then ++ : ++ else ++ echo "copying selected object files to avoid basename conflicts..." ++ gentop="$output_objdir/${outputname}x" ++ generated="$generated $gentop" ++ func_mkdir_p "$gentop" ++ save_oldobjs=$oldobjs ++ oldobjs= ++ counter=1 ++ for obj in $save_oldobjs ++ do ++ func_basename "$obj" ++ objbase="$func_basename_result" ++ case " $oldobjs " in ++ " ") oldobjs=$obj ;; ++ *[\ /]"$objbase "*) ++ while :; do ++ # Make sure we don't pick an alternate name that also ++ # overlaps. ++ newobj=lt$counter-$objbase ++ func_arith $counter + 1 ++ counter=$func_arith_result ++ case " $oldobjs " in ++ *[\ /]"$newobj "*) ;; ++ *) if test ! -f "$gentop/$newobj"; then break; fi ;; ++ esac ++ done ++ func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" ++ oldobjs="$oldobjs $gentop/$newobj" ++ ;; ++ *) oldobjs="$oldobjs $obj" ;; ++ esac ++ done ++ fi ++ eval "cmds=\"$old_archive_cmds\"" ++ ++ func_len " $cmds" ++ len=$func_len_result ++ if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then ++ cmds=$old_archive_cmds ++ else ++ # the command line is too long to link in one step, link in parts ++ func_verbose "using piecewise archive linking..." ++ save_RANLIB=$RANLIB ++ RANLIB=: ++ objlist= ++ concat_cmds= ++ save_oldobjs=$oldobjs ++ oldobjs= ++ # Is there a better way of finding the last object in the list? ++ for obj in $save_oldobjs ++ do ++ last_oldobj=$obj ++ done ++ eval "test_cmds=\"$old_archive_cmds\"" ++ func_len " $test_cmds" ++ len0=$func_len_result ++ len=$len0 ++ for obj in $save_oldobjs ++ do ++ func_len " $obj" ++ func_arith $len + $func_len_result ++ len=$func_arith_result ++ func_append objlist " $obj" ++ if test "$len" -lt "$max_cmd_len"; then ++ : ++ else ++ # the above command should be used before it gets too long ++ oldobjs=$objlist ++ if test "$obj" = "$last_oldobj" ; then ++ RANLIB=$save_RANLIB ++ fi ++ test -z "$concat_cmds" || concat_cmds=$concat_cmds~ ++ eval "concat_cmds=\"\${concat_cmds}$old_archive_cmds\"" ++ objlist= ++ len=$len0 ++ fi ++ done ++ RANLIB=$save_RANLIB ++ oldobjs=$objlist ++ if test "X$oldobjs" = "X" ; then ++ eval "cmds=\"\$concat_cmds\"" ++ else ++ eval "cmds=\"\$concat_cmds~\$old_archive_cmds\"" ++ fi ++ fi ++ fi ++ func_execute_cmds "$cmds" 'exit $?' ++ done ++ ++ test -n "$generated" && \ ++ func_show_eval "${RM}r$generated" ++ ++ # Now create the libtool archive. ++ case $output in ++ *.la) ++ old_library= ++ test "$build_old_libs" = yes && old_library="$libname.$libext" ++ func_verbose "creating $output" ++ ++ # Preserve any variables that may affect compiler behavior ++ for var in $variables_saved_for_relink; do ++ if eval test -z \"\${$var+set}\"; then ++ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" ++ elif eval var_value=\$$var; test -z "$var_value"; then ++ relink_command="$var=; export $var; $relink_command" ++ else ++ func_quote_for_eval "$var_value" ++ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" ++ fi ++ done ++ # Quote the link command for shipping. ++ relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" ++ relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` ++ if test "$hardcode_automatic" = yes ; then ++ relink_command= ++ fi ++ ++ # Only create the output if not a dry run. ++ $opt_dry_run || { ++ for installed in no yes; do ++ if test "$installed" = yes; then ++ if test -z "$install_libdir"; then ++ break ++ fi ++ output="$output_objdir/$outputname"i ++ # Replace all uninstalled libtool libraries with the installed ones ++ newdependency_libs= ++ for deplib in $dependency_libs; do ++ case $deplib in ++ *.la) ++ func_basename "$deplib" ++ name="$func_basename_result" ++ libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` ++ test -z "$libdir" && \ ++ func_fatal_error "\`$deplib' is not a valid libtool archive" ++ newdependency_libs="$newdependency_libs $libdir/$name" ++ ;; ++ *) newdependency_libs="$newdependency_libs $deplib" ;; ++ esac ++ done ++ dependency_libs="$newdependency_libs" ++ newdlfiles= ++ ++ for lib in $dlfiles; do ++ case $lib in ++ *.la) ++ func_basename "$lib" ++ name="$func_basename_result" ++ libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` ++ test -z "$libdir" && \ ++ func_fatal_error "\`$lib' is not a valid libtool archive" ++ newdlfiles="$newdlfiles $libdir/$name" ++ ;; ++ *) newdlfiles="$newdlfiles $lib" ;; ++ esac ++ done ++ dlfiles="$newdlfiles" ++ newdlprefiles= ++ for lib in $dlprefiles; do ++ case $lib in ++ *.la) ++ # Only pass preopened files to the pseudo-archive (for ++ # eventual linking with the app. that links it) if we ++ # didn't already link the preopened objects directly into ++ # the library: ++ func_basename "$lib" ++ name="$func_basename_result" ++ libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` ++ test -z "$libdir" && \ ++ func_fatal_error "\`$lib' is not a valid libtool archive" ++ newdlprefiles="$newdlprefiles $libdir/$name" ++ ;; ++ esac ++ done ++ dlprefiles="$newdlprefiles" ++ else ++ newdlfiles= ++ for lib in $dlfiles; do ++ case $lib in ++ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; ++ *) abs=`pwd`"/$lib" ;; ++ esac ++ newdlfiles="$newdlfiles $abs" ++ done ++ dlfiles="$newdlfiles" ++ newdlprefiles= ++ for lib in $dlprefiles; do ++ case $lib in ++ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; ++ *) abs=`pwd`"/$lib" ;; ++ esac ++ newdlprefiles="$newdlprefiles $abs" ++ done ++ dlprefiles="$newdlprefiles" ++ fi ++ $RM $output ++ # place dlname in correct position for cygwin ++ # In fact, it would be nice if we could use this code for all target ++ # systems that can't hard-code library paths into their executables ++ # and that have no shared library path variable independent of PATH, ++ # but it turns out we can't easily determine that from inspecting ++ # libtool variables, so we have to hard-code the OSs to which it ++ # applies here; at the moment, that means platforms that use the PE ++ # object format with DLL files. See the long comment at the top of ++ # tests/bindir.at for full details. ++ tdlname=$dlname ++ case $host,$output,$installed,$module,$dlname in ++ *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) ++ # If a -bindir argument was supplied, place the dll there. ++ if test "x$bindir" != x ; ++ then ++ func_relative_path "$install_libdir" "$bindir" ++ tdlname=$func_relative_path_result$dlname ++ else ++ # Otherwise fall back on heuristic. ++ tdlname=../bin/$dlname ++ fi ++ ;; ++ esac ++ $ECHO > $output "\ ++# $outputname - a libtool library file ++# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION ++# ++# Please DO NOT delete this file! ++# It is necessary for linking the library. ++ ++# The name that we can dlopen(3). ++dlname='$tdlname' ++ ++# Names of this library. ++library_names='$library_names' ++ ++# The name of the static archive. ++old_library='$old_library' ++ ++# Linker flags that can not go in dependency_libs. ++inherited_linker_flags='$new_inherited_linker_flags' ++ ++# Libraries that this one depends upon. ++dependency_libs='$dependency_libs' ++ ++# Names of additional weak libraries provided by this library ++weak_library_names='$weak_libs' ++ ++# Version information for $libname. ++current=$current ++age=$age ++revision=$revision ++ ++# Is this an already installed library? ++installed=$installed ++ ++# Should we warn about portability when linking against -modules? ++shouldnotlink=$module ++ ++# Files to dlopen/dlpreopen ++dlopen='$dlfiles' ++dlpreopen='$dlprefiles' ++ ++# Directory that this library needs to be installed in: ++libdir='$install_libdir'" ++ if test "$installed" = no && test "$need_relink" = yes; then ++ $ECHO >> $output "\ ++relink_command=\"$relink_command\"" ++ fi ++ done ++ } ++ ++ # Do a symbolic link so that the libtool archive can be found in ++ # LD_LIBRARY_PATH before the program is installed. ++ func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ++ ;; ++ esac ++ exit $EXIT_SUCCESS ++} ++ ++{ test "$mode" = link || test "$mode" = relink; } && ++ func_mode_link ${1+"$@"} ++ ++ ++# func_mode_uninstall arg... ++func_mode_uninstall () ++{ ++ $opt_debug ++ RM="$nonopt" ++ files= ++ rmforce= ++ exit_status=0 ++ ++ # This variable tells wrapper scripts just to set variables rather ++ # than running their programs. ++ libtool_install_magic="$magic" ++ ++ for arg ++ do ++ case $arg in ++ -f) RM="$RM $arg"; rmforce=yes ;; ++ -*) RM="$RM $arg" ;; ++ *) files="$files $arg" ;; ++ esac ++ done ++ ++ test -z "$RM" && \ ++ func_fatal_help "you must specify an RM program" ++ ++ rmdirs= ++ ++ origobjdir="$objdir" ++ for file in $files; do ++ func_dirname "$file" "" "." ++ dir="$func_dirname_result" ++ if test "X$dir" = X.; then ++ objdir="$origobjdir" ++ else ++ objdir="$dir/$origobjdir" ++ fi ++ func_basename "$file" ++ name="$func_basename_result" ++ test "$mode" = uninstall && objdir="$dir" ++ ++ # Remember objdir for removal later, being careful to avoid duplicates ++ if test "$mode" = clean; then ++ case " $rmdirs " in ++ *" $objdir "*) ;; ++ *) rmdirs="$rmdirs $objdir" ;; ++ esac ++ fi ++ ++ # Don't error if the file doesn't exist and rm -f was used. ++ if { test -L "$file"; } >/dev/null 2>&1 || ++ { test -h "$file"; } >/dev/null 2>&1 || ++ test -f "$file"; then ++ : ++ elif test -d "$file"; then ++ exit_status=1 ++ continue ++ elif test "$rmforce" = yes; then ++ continue ++ fi ++ ++ rmfiles="$file" ++ ++ case $name in ++ *.la) ++ # Possibly a libtool archive, so verify it. ++ if func_lalib_p "$file"; then ++ func_source $dir/$name ++ ++ # Delete the libtool libraries and symlinks. ++ for n in $library_names; do ++ rmfiles="$rmfiles $objdir/$n" ++ done ++ test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" ++ ++ case "$mode" in ++ clean) ++ case " $library_names " in ++ # " " in the beginning catches empty $dlname ++ *" $dlname "*) ;; ++ *) rmfiles="$rmfiles $objdir/$dlname" ;; ++ esac ++ test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" ++ ;; ++ uninstall) ++ if test -n "$library_names"; then ++ # Do each command in the postuninstall commands. ++ func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' ++ fi ++ ++ if test -n "$old_library"; then ++ # Do each command in the old_postuninstall commands. ++ func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' ++ fi ++ # FIXME: should reinstall the best remaining shared library. ++ ;; ++ esac ++ fi ++ ;; ++ ++ *.lo) ++ # Possibly a libtool object, so verify it. ++ if func_lalib_p "$file"; then ++ ++ # Read the .lo file ++ func_source $dir/$name ++ ++ # Add PIC object to the list of files to remove. ++ if test -n "$pic_object" && ++ test "$pic_object" != none; then ++ rmfiles="$rmfiles $dir/$pic_object" ++ fi ++ ++ # Add non-PIC object to the list of files to remove. ++ if test -n "$non_pic_object" && ++ test "$non_pic_object" != none; then ++ rmfiles="$rmfiles $dir/$non_pic_object" ++ fi ++ fi ++ ;; ++ ++ *) ++ if test "$mode" = clean ; then ++ noexename=$name ++ case $file in ++ *.exe) ++ func_stripname '' '.exe' "$file" ++ file=$func_stripname_result ++ func_stripname '' '.exe' "$name" ++ noexename=$func_stripname_result ++ # $file with .exe has already been added to rmfiles, ++ # add $file without .exe ++ rmfiles="$rmfiles $file" ++ ;; ++ esac ++ # Do a test to see if this is a libtool program. ++ if func_ltwrapper_p "$file"; then ++ if func_ltwrapper_executable_p "$file"; then ++ func_ltwrapper_scriptname "$file" ++ relink_command= ++ func_source $func_ltwrapper_scriptname_result ++ rmfiles="$rmfiles $func_ltwrapper_scriptname_result" ++ else ++ relink_command= ++ func_source $dir/$noexename ++ fi ++ ++ # note $name still contains .exe if it was in $file originally ++ # as does the version of $file that was added into $rmfiles ++ rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" ++ if test "$fast_install" = yes && test -n "$relink_command"; then ++ rmfiles="$rmfiles $objdir/lt-$name" ++ fi ++ if test "X$noexename" != "X$name" ; then ++ rmfiles="$rmfiles $objdir/lt-${noexename}.c" ++ fi ++ fi ++ fi ++ ;; ++ esac ++ func_show_eval "$RM $rmfiles" 'exit_status=1' ++ done ++ objdir="$origobjdir" ++ ++ # Try to remove the ${objdir}s in the directories where we deleted files ++ for dir in $rmdirs; do ++ if test -d "$dir"; then ++ func_show_eval "rmdir $dir >/dev/null 2>&1" ++ fi ++ done ++ ++ exit $exit_status ++} ++ ++{ test "$mode" = uninstall || test "$mode" = clean; } && ++ func_mode_uninstall ${1+"$@"} ++ ++test -z "$mode" && { ++ help="$generic_help" ++ func_fatal_help "you must specify a MODE" ++} ++ ++test -z "$exec_cmd" && \ ++ func_fatal_help "invalid operation mode \`$mode'" ++ ++if test -n "$exec_cmd"; then ++ eval exec "$exec_cmd" ++ exit $EXIT_FAILURE ++fi ++ ++exit $exit_status ++ ++ ++# The TAGs below are defined such that we never get into a situation ++# in which we disable both kinds of libraries. Given conflicting ++# choices, we go for a static library, that is the most portable, ++# since we can't tell whether shared libraries were disabled because ++# the user asked for that or because the platform doesn't support ++# them. This is particularly important on AIX, because we don't ++# support having both static and shared libraries enabled at the same ++# time on that platform, so we default to a shared-only configuration. ++# If a disable-shared tag is given, we'll fallback to a static-only ++# configuration. But we'll never go from static-only to shared-only. ++ ++# ### BEGIN LIBTOOL TAG CONFIG: disable-shared ++build_libtool_libs=no ++build_old_libs=yes ++# ### END LIBTOOL TAG CONFIG: disable-shared ++ ++# ### BEGIN LIBTOOL TAG CONFIG: disable-static ++build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` ++# ### END LIBTOOL TAG CONFIG: disable-static ++ ++# Local Variables: ++# mode:shell-script ++# sh-indentation:2 ++# End: ++# vi:sw=2 ++ diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/missing index 000000000,000000000..f62bbae30 new file mode 100755 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/missing @@@ -1,0 -1,0 +1,215 @@@ ++#! /bin/sh ++# Common wrapper for a few potentially missing GNU programs. ++ ++scriptversion=2013-10-28.13; # UTC ++ ++# Copyright (C) 1996-2014 Free Software Foundation, Inc. ++# Originally written by Fran,cois Pinard , 1996. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2, or (at your option) ++# any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# As a special exception to the GNU General Public License, if you ++# distribute this file as part of a program that contains a ++# configuration script generated by Autoconf, you may include it under ++# the same distribution terms that you use for the rest of that program. ++ ++if test $# -eq 0; then ++ echo 1>&2 "Try '$0 --help' for more information" ++ exit 1 ++fi ++ ++case $1 in ++ ++ --is-lightweight) ++ # Used by our autoconf macros to check whether the available missing ++ # script is modern enough. ++ exit 0 ++ ;; ++ ++ --run) ++ # Back-compat with the calling convention used by older automake. ++ shift ++ ;; ++ ++ -h|--h|--he|--hel|--help) ++ echo "\ ++$0 [OPTION]... PROGRAM [ARGUMENT]... ++ ++Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due ++to PROGRAM being missing or too old. ++ ++Options: ++ -h, --help display this help and exit ++ -v, --version output version information and exit ++ ++Supported PROGRAM values: ++ aclocal autoconf autoheader autom4te automake makeinfo ++ bison yacc flex lex help2man ++ ++Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and ++'g' are ignored when checking the name. ++ ++Send bug reports to ." ++ exit $? ++ ;; ++ ++ -v|--v|--ve|--ver|--vers|--versi|--versio|--version) ++ echo "missing $scriptversion (GNU Automake)" ++ exit $? ++ ;; ++ ++ -*) ++ echo 1>&2 "$0: unknown '$1' option" ++ echo 1>&2 "Try '$0 --help' for more information" ++ exit 1 ++ ;; ++ ++esac ++ ++# Run the given program, remember its exit status. ++"$@"; st=$? ++ ++# If it succeeded, we are done. ++test $st -eq 0 && exit 0 ++ ++# Also exit now if we it failed (or wasn't found), and '--version' was ++# passed; such an option is passed most likely to detect whether the ++# program is present and works. ++case $2 in --version|--help) exit $st;; esac ++ ++# Exit code 63 means version mismatch. This often happens when the user ++# tries to use an ancient version of a tool on a file that requires a ++# minimum version. ++if test $st -eq 63; then ++ msg="probably too old" ++elif test $st -eq 127; then ++ # Program was missing. ++ msg="missing on your system" ++else ++ # Program was found and executed, but failed. Give up. ++ exit $st ++fi ++ ++perl_URL=http://www.perl.org/ ++flex_URL=http://flex.sourceforge.net/ ++gnu_software_URL=http://www.gnu.org/software ++ ++program_details () ++{ ++ case $1 in ++ aclocal|automake) ++ echo "The '$1' program is part of the GNU Automake package:" ++ echo "<$gnu_software_URL/automake>" ++ echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" ++ echo "<$gnu_software_URL/autoconf>" ++ echo "<$gnu_software_URL/m4/>" ++ echo "<$perl_URL>" ++ ;; ++ autoconf|autom4te|autoheader) ++ echo "The '$1' program is part of the GNU Autoconf package:" ++ echo "<$gnu_software_URL/autoconf/>" ++ echo "It also requires GNU m4 and Perl in order to run:" ++ echo "<$gnu_software_URL/m4/>" ++ echo "<$perl_URL>" ++ ;; ++ esac ++} ++ ++give_advice () ++{ ++ # Normalize program name to check for. ++ normalized_program=`echo "$1" | sed ' ++ s/^gnu-//; t ++ s/^gnu//; t ++ s/^g//; t'` ++ ++ printf '%s\n' "'$1' is $msg." ++ ++ configure_deps="'configure.ac' or m4 files included by 'configure.ac'" ++ case $normalized_program in ++ autoconf*) ++ echo "You should only need it if you modified 'configure.ac'," ++ echo "or m4 files included by it." ++ program_details 'autoconf' ++ ;; ++ autoheader*) ++ echo "You should only need it if you modified 'acconfig.h' or" ++ echo "$configure_deps." ++ program_details 'autoheader' ++ ;; ++ automake*) ++ echo "You should only need it if you modified 'Makefile.am' or" ++ echo "$configure_deps." ++ program_details 'automake' ++ ;; ++ aclocal*) ++ echo "You should only need it if you modified 'acinclude.m4' or" ++ echo "$configure_deps." ++ program_details 'aclocal' ++ ;; ++ autom4te*) ++ echo "You might have modified some maintainer files that require" ++ echo "the 'autom4te' program to be rebuilt." ++ program_details 'autom4te' ++ ;; ++ bison*|yacc*) ++ echo "You should only need it if you modified a '.y' file." ++ echo "You may want to install the GNU Bison package:" ++ echo "<$gnu_software_URL/bison/>" ++ ;; ++ lex*|flex*) ++ echo "You should only need it if you modified a '.l' file." ++ echo "You may want to install the Fast Lexical Analyzer package:" ++ echo "<$flex_URL>" ++ ;; ++ help2man*) ++ echo "You should only need it if you modified a dependency" \ ++ "of a man page." ++ echo "You may want to install the GNU Help2man package:" ++ echo "<$gnu_software_URL/help2man/>" ++ ;; ++ makeinfo*) ++ echo "You should only need it if you modified a '.texi' file, or" ++ echo "any other file indirectly affecting the aspect of the manual." ++ echo "You might want to install the Texinfo package:" ++ echo "<$gnu_software_URL/texinfo/>" ++ echo "The spurious makeinfo call might also be the consequence of" ++ echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" ++ echo "want to install GNU make:" ++ echo "<$gnu_software_URL/make/>" ++ ;; ++ *) ++ echo "You might have modified some files without having the proper" ++ echo "tools for further handling them. Check the 'README' file, it" ++ echo "often tells you about the needed prerequisites for installing" ++ echo "this package. You may also peek at any GNU archive site, in" ++ echo "case some other package contains this missing '$1' program." ++ ;; ++ esac ++} ++ ++give_advice "$1" | sed -e '1s/^/WARNING: /' \ ++ -e '2,$s/^/ /' >&2 ++ ++# Propagate the correct exit status (expected to be 127 for a program ++# not found, 63 for a program that failed due to version mismatch). ++exit $st ++ ++# Local variables: ++# eval: (add-hook 'write-file-hooks 'time-stamp) ++# time-stamp-start: "scriptversion=" ++# time-stamp-format: "%:y-%02m-%02d.%02H" ++# time-stamp-time-zone: "UTC" ++# time-stamp-end: "; # UTC" ++# End: diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/mmap.c index 000000000,000000000..e30d1c1a3 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/mmap.c @@@ -1,0 -1,0 +1,303 @@@ ++/* mmap.c -- Memory allocation with mmap. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++/* Memory allocation on systems that provide anonymous mmap. This ++ permits the backtrace functions to be invoked from a signal ++ handler, assuming that mmap is async-signal safe. */ ++ ++#ifndef MAP_ANONYMOUS ++#define MAP_ANONYMOUS MAP_ANON ++#endif ++ ++#ifndef MAP_FAILED ++#define MAP_FAILED ((void *)-1) ++#endif ++ ++/* A list of free memory blocks. */ ++ ++struct backtrace_freelist_struct ++{ ++ /* Next on list. */ ++ struct backtrace_freelist_struct *next; ++ /* Size of this block, including this structure. */ ++ size_t size; ++}; ++ ++/* Free memory allocated by backtrace_alloc. */ ++ ++static void ++backtrace_free_locked (struct backtrace_state *state, void *addr, size_t size) ++{ ++ /* Just leak small blocks. We don't have to be perfect. */ ++ if (size >= sizeof (struct backtrace_freelist_struct)) ++ { ++ struct backtrace_freelist_struct *p; ++ ++ p = (struct backtrace_freelist_struct *) addr; ++ p->next = state->freelist; ++ p->size = size; ++ state->freelist = p; ++ } ++} ++ ++/* Allocate memory like malloc. If ERROR_CALLBACK is NULL, don't ++ report an error. */ ++ ++void * ++backtrace_alloc (struct backtrace_state *state, ++ size_t size, backtrace_error_callback error_callback, ++ void *data) ++{ ++ void *ret; ++ int locked; ++ struct backtrace_freelist_struct **pp; ++ size_t pagesize; ++ size_t asksize; ++ void *page; ++ ++ ret = NULL; ++ ++ /* If we can acquire the lock, then see if there is space on the ++ free list. If we can't acquire the lock, drop straight into ++ using mmap. __sync_lock_test_and_set returns the old state of ++ the lock, so we have acquired it if it returns 0. */ ++ ++ if (!state->threaded) ++ locked = 1; ++ else ++ locked = __sync_lock_test_and_set (&state->lock_alloc, 1) == 0; ++ ++ if (locked) ++ { ++ for (pp = &state->freelist; *pp != NULL; pp = &(*pp)->next) ++ { ++ if ((*pp)->size >= size) ++ { ++ struct backtrace_freelist_struct *p; ++ ++ p = *pp; ++ *pp = p->next; ++ ++ /* Round for alignment; we assume that no type we care about ++ is more than 8 bytes. */ ++ size = (size + 7) & ~ (size_t) 7; ++ if (size < p->size) ++ backtrace_free_locked (state, (char *) p + size, ++ p->size - size); ++ ++ ret = (void *) p; ++ ++ break; ++ } ++ } ++ ++ if (state->threaded) ++ __sync_lock_release (&state->lock_alloc); ++ } ++ ++ if (ret == NULL) ++ { ++ /* Allocate a new page. */ ++ ++ pagesize = getpagesize (); ++ asksize = (size + pagesize - 1) & ~ (pagesize - 1); ++ page = mmap (NULL, asksize, PROT_READ | PROT_WRITE, ++ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); ++ if (page == MAP_FAILED) ++ { ++ if (error_callback) ++ error_callback (data, "mmap", errno); ++ } ++ else ++ { ++ size = (size + 7) & ~ (size_t) 7; ++ if (size < asksize) ++ backtrace_free (state, (char *) page + size, asksize - size, ++ error_callback, data); ++ ++ ret = page; ++ } ++ } ++ ++ return ret; ++} ++ ++/* Free memory allocated by backtrace_alloc. */ ++ ++void ++backtrace_free (struct backtrace_state *state, void *addr, size_t size, ++ backtrace_error_callback error_callback ATTRIBUTE_UNUSED, ++ void *data ATTRIBUTE_UNUSED) ++{ ++ int locked; ++ ++ /* If we are freeing a large aligned block, just release it back to ++ the system. This case arises when growing a vector for a large ++ binary with lots of debug info. Calling munmap here may cause us ++ to call mmap again if there is also a large shared library; we ++ just live with that. */ ++ if (size >= 16 * 4096) ++ { ++ size_t pagesize; ++ ++ pagesize = getpagesize (); ++ if (((uintptr_t) addr & (pagesize - 1)) == 0 ++ && (size & (pagesize - 1)) == 0) ++ { ++ /* If munmap fails for some reason, just add the block to ++ the freelist. */ ++ if (munmap (addr, size) == 0) ++ return; ++ } ++ } ++ ++ /* If we can acquire the lock, add the new space to the free list. ++ If we can't acquire the lock, just leak the memory. ++ __sync_lock_test_and_set returns the old state of the lock, so we ++ have acquired it if it returns 0. */ ++ ++ if (!state->threaded) ++ locked = 1; ++ else ++ locked = __sync_lock_test_and_set (&state->lock_alloc, 1) == 0; ++ ++ if (locked) ++ { ++ backtrace_free_locked (state, addr, size); ++ ++ if (state->threaded) ++ __sync_lock_release (&state->lock_alloc); ++ } ++} ++ ++/* Grow VEC by SIZE bytes. */ ++ ++void * ++backtrace_vector_grow (struct backtrace_state *state,size_t size, ++ backtrace_error_callback error_callback, ++ void *data, struct backtrace_vector *vec) ++{ ++ void *ret; ++ ++ if (size > vec->alc) ++ { ++ size_t pagesize; ++ size_t alc; ++ void *base; ++ ++ pagesize = getpagesize (); ++ alc = vec->size + size; ++ if (vec->size == 0) ++ alc = 16 * size; ++ else if (alc < pagesize) ++ { ++ alc *= 2; ++ if (alc > pagesize) ++ alc = pagesize; ++ } ++ else ++ { ++ alc *= 2; ++ alc = (alc + pagesize - 1) & ~ (pagesize - 1); ++ } ++ base = backtrace_alloc (state, alc, error_callback, data); ++ if (base == NULL) ++ return NULL; ++ if (vec->base != NULL) ++ { ++ memcpy (base, vec->base, vec->size); ++ backtrace_free (state, vec->base, vec->size + vec->alc, ++ error_callback, data); ++ } ++ vec->base = base; ++ vec->alc = alc - vec->size; ++ } ++ ++ ret = (char *) vec->base + vec->size; ++ vec->size += size; ++ vec->alc -= size; ++ return ret; ++} ++ ++/* Finish the current allocation on VEC. */ ++ ++void * ++backtrace_vector_finish ( ++ struct backtrace_state *state ATTRIBUTE_UNUSED, ++ struct backtrace_vector *vec, ++ backtrace_error_callback error_callback ATTRIBUTE_UNUSED, ++ void *data ATTRIBUTE_UNUSED) ++{ ++ void *ret; ++ ++ ret = vec->base; ++ vec->base = (char *) vec->base + vec->size; ++ vec->size = 0; ++ return ret; ++} ++ ++/* Release any extra space allocated for VEC. */ ++ ++int ++backtrace_vector_release (struct backtrace_state *state, ++ struct backtrace_vector *vec, ++ backtrace_error_callback error_callback, ++ void *data) ++{ ++ size_t size; ++ size_t alc; ++ size_t aligned; ++ ++ /* Make sure that the block that we free is aligned on an 8-byte ++ boundary. */ ++ size = vec->size; ++ alc = vec->alc; ++ aligned = (size + 7) & ~ (size_t) 7; ++ alc -= aligned - size; ++ ++ backtrace_free (state, (char *) vec->base + aligned, alc, ++ error_callback, data); ++ vec->alc = 0; ++ return 1; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/mmapio.c index 000000000,000000000..8a9ba8e7b new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/mmapio.c @@@ -1,0 -1,0 +1,100 @@@ ++/* mmapio.c -- File views using mmap. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++#ifndef MAP_FAILED ++#define MAP_FAILED ((void *)-1) ++#endif ++ ++/* This file implements file views and memory allocation when mmap is ++ available. */ ++ ++/* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. */ ++ ++int ++backtrace_get_view (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ int descriptor, off_t offset, size_t size, ++ backtrace_error_callback error_callback, ++ void *data, struct backtrace_view *view) ++{ ++ size_t pagesize; ++ unsigned int inpage; ++ off_t pageoff; ++ void *map; ++ ++ pagesize = getpagesize (); ++ inpage = offset % pagesize; ++ pageoff = offset - inpage; ++ ++ size += inpage; ++ size = (size + (pagesize - 1)) & ~ (pagesize - 1); ++ ++ map = mmap (NULL, size, PROT_READ, MAP_PRIVATE, descriptor, pageoff); ++ if (map == MAP_FAILED) ++ { ++ error_callback (data, "mmap", errno); ++ return 0; ++ } ++ ++ view->data = (char *) map + inpage; ++ view->base = map; ++ view->len = size; ++ ++ return 1; ++} ++ ++/* Release a view read by backtrace_get_view. */ ++ ++void ++backtrace_release_view (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ struct backtrace_view *view, ++ backtrace_error_callback error_callback, ++ void *data) ++{ ++ union { ++ const void *cv; ++ void *v; ++ } const_cast; ++ ++ const_cast.cv = view->base; ++ if (munmap (const_cast.v, view->len) < 0) ++ error_callback (data, "munmap", errno); ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/nounwind.c index 000000000,000000000..0deaeef0a new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/nounwind.c @@@ -1,0 -1,0 +1,66 @@@ ++/* backtrace.c -- Entry point for stack backtrace library. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++ ++#include "backtrace.h" ++ ++#include "internal.h" ++ ++/* This source file is compiled if the unwind library is not ++ available. */ ++ ++int ++backtrace_full (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ int skip ATTRIBUTE_UNUSED, ++ backtrace_full_callback callback ATTRIBUTE_UNUSED, ++ backtrace_error_callback error_callback, void *data) ++{ ++ error_callback (data, ++ "no stack trace because unwind library not available", ++ 0); ++ return 0; ++} ++ ++int ++backtrace_simple (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ int skip ATTRIBUTE_UNUSED, ++ backtrace_simple_callback callback ATTRIBUTE_UNUSED, ++ backtrace_error_callback error_callback, void *data) ++{ ++ error_callback (data, ++ "no stack trace because unwind library not available", ++ 0); ++ return 0; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/pecoff.c index 000000000,000000000..c7d32aa6b new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/pecoff.c @@@ -1,0 -1,0 +1,937 @@@ ++/* pecoff.c -- Get debug data from a PE/COFFF file for backtraces. ++ Copyright (C) 2015-2016 Free Software Foundation, Inc. ++ Adapted from elf.c by Tristan Gingold, AdaCore. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++/* Coff file header. */ ++ ++typedef struct { ++ uint16_t machine; ++ uint16_t number_of_sections; ++ uint32_t time_date_stamp; ++ uint32_t pointer_to_symbol_table; ++ uint32_t number_of_symbols; ++ uint16_t size_of_optional_header; ++ uint16_t characteristics; ++} b_coff_file_header; ++ ++/* Coff optional header. */ ++ ++typedef struct { ++ uint16_t magic; ++ uint8_t major_linker_version; ++ uint8_t minor_linker_version; ++ uint32_t size_of_code; ++ uint32_t size_of_initialized_data; ++ uint32_t size_of_uninitialized_data; ++ uint32_t address_of_entry_point; ++ uint32_t base_of_code; ++ union { ++ struct { ++ uint32_t base_of_data; ++ uint32_t image_base; ++ } pe; ++ struct { ++ uint64_t image_base; ++ } pep; ++ } u; ++} b_coff_optional_header; ++ ++/* Values of magic in optional header. */ ++ ++#define PE_MAGIC 0x10b /* PE32 executable. */ ++#define PEP_MAGIC 0x20b /* PE32+ executable (for 64bit targets). */ ++ ++/* Coff section header. */ ++ ++typedef struct { ++ char name[8]; ++ uint32_t virtual_size; ++ uint32_t virtual_address; ++ uint32_t size_of_raw_data; ++ uint32_t pointer_to_raw_data; ++ uint32_t pointer_to_relocations; ++ uint32_t pointer_to_line_numbers; ++ uint16_t number_of_relocations; ++ uint16_t number_of_line_numbers; ++ uint32_t characteristics; ++} b_coff_section_header; ++ ++/* Coff symbol name. */ ++ ++typedef union { ++ char short_name[8]; ++ struct { ++ unsigned char zeroes[4]; ++ unsigned char off[4]; ++ } long_name; ++} b_coff_name; ++ ++/* Coff symbol (external representation which is unaligned). */ ++ ++typedef struct { ++ b_coff_name name; ++ unsigned char value[4]; ++ unsigned char section_number[2]; ++ unsigned char type[2]; ++ unsigned char storage_class; ++ unsigned char number_of_aux_symbols; ++} b_coff_external_symbol; ++ ++/* Symbol types. */ ++ ++#define N_TBSHFT 4 /* Shift for the derived type. */ ++#define IMAGE_SYM_DTYPE_FUNCTION 2 /* Function derived type. */ ++ ++/* Size of a coff symbol. */ ++ ++#define SYM_SZ 18 ++ ++/* Coff symbol, internal representation (aligned). */ ++ ++typedef struct { ++ const char *name; ++ uint32_t value; ++ int16_t sec; ++ uint16_t type; ++ uint16_t sc; ++} b_coff_internal_symbol; ++ ++/* An index of sections we care about. */ ++ ++enum debug_section ++{ ++ DEBUG_INFO, ++ DEBUG_LINE, ++ DEBUG_ABBREV, ++ DEBUG_RANGES, ++ DEBUG_STR, ++ DEBUG_MAX ++}; ++ ++/* Names of sections, indexed by enum debug_section. */ ++ ++static const char * const debug_section_names[DEBUG_MAX] = ++{ ++ ".debug_info", ++ ".debug_line", ++ ".debug_abbrev", ++ ".debug_ranges", ++ ".debug_str" ++}; ++ ++/* Information we gather for the sections we care about. */ ++ ++struct debug_section_info ++{ ++ /* Section file offset. */ ++ off_t offset; ++ /* Section size. */ ++ size_t size; ++ /* Section contents, after read from file. */ ++ const unsigned char *data; ++}; ++ ++/* Information we keep for an coff symbol. */ ++ ++struct coff_symbol ++{ ++ /* The name of the symbol. */ ++ const char *name; ++ /* The address of the symbol. */ ++ uintptr_t address; ++}; ++ ++/* Information to pass to coff_syminfo. */ ++ ++struct coff_syminfo_data ++{ ++ /* Symbols for the next module. */ ++ struct coff_syminfo_data *next; ++ /* The COFF symbols, sorted by address. */ ++ struct coff_symbol *symbols; ++ /* The number of symbols. */ ++ size_t count; ++}; ++ ++/* A dummy callback function used when we can't find any debug info. */ ++ ++static int ++coff_nodebug (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ uintptr_t pc ATTRIBUTE_UNUSED, ++ backtrace_full_callback callback ATTRIBUTE_UNUSED, ++ backtrace_error_callback error_callback, void *data) ++{ ++ error_callback (data, "no debug info in PE/COFF executable", -1); ++ return 0; ++} ++ ++/* A dummy callback function used when we can't find a symbol ++ table. */ ++ ++static void ++coff_nosyms (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ uintptr_t addr ATTRIBUTE_UNUSED, ++ backtrace_syminfo_callback callback ATTRIBUTE_UNUSED, ++ backtrace_error_callback error_callback, void *data) ++{ ++ error_callback (data, "no symbol table in PE/COFF executable", -1); ++} ++ ++/* Read a potentially unaligned 4 byte word at P, using native endianness. */ ++ ++static uint32_t ++coff_read4 (const unsigned char *p) ++{ ++ uint32_t res; ++ ++ memcpy (&res, p, 4); ++ return res; ++} ++ ++/* Read a potentially unaligned 2 byte word at P, using native endianness. ++ All 2 byte word in symbols are always aligned, but for coherency all ++ fields are declared as char arrays. */ ++ ++static uint16_t ++coff_read2 (const unsigned char *p) ++{ ++ uint16_t res; ++ ++ memcpy (&res, p, sizeof (res)); ++ return res; ++} ++ ++/* Return the length (without the trailing 0) of a COFF short name. */ ++ ++static size_t ++coff_short_name_len (const char *name) ++{ ++ int i; ++ ++ for (i = 0; i < 8; i++) ++ if (name[i] == 0) ++ return i; ++ return 8; ++} ++ ++/* Return true iff COFF short name CNAME is the same as NAME (a NUL-terminated ++ string). */ ++ ++static int ++coff_short_name_eq (const char *name, const char *cname) ++{ ++ int i; ++ ++ for (i = 0; i < 8; i++) ++ { ++ if (name[i] != cname[i]) ++ return 0; ++ if (name[i] == 0) ++ return 1; ++ } ++ return name[8] == 0; ++} ++ ++/* Return true iff NAME is the same as string at offset OFF. */ ++ ++static int ++coff_long_name_eq (const char *name, unsigned int off, ++ struct backtrace_view *str_view) ++{ ++ if (off >= str_view->len) ++ return 0; ++ return strcmp (name, (const char *)str_view->data + off) == 0; ++} ++ ++/* Compare struct coff_symbol for qsort. */ ++ ++static int ++coff_symbol_compare (const void *v1, const void *v2) ++{ ++ const struct coff_symbol *e1 = (const struct coff_symbol *) v1; ++ const struct coff_symbol *e2 = (const struct coff_symbol *) v2; ++ ++ if (e1->address < e2->address) ++ return -1; ++ else if (e1->address > e2->address) ++ return 1; ++ else ++ return 0; ++} ++ ++/* Convert SYM to internal (and aligned) format ISYM, using string table ++ from STRTAB and STRTAB_SIZE, and number of sections SECTS_NUM. ++ Return -1 in case of error (invalid section number or string index). */ ++ ++static int ++coff_expand_symbol (b_coff_internal_symbol *isym, ++ const b_coff_external_symbol *sym, ++ uint16_t sects_num, ++ const unsigned char *strtab, size_t strtab_size) ++{ ++ isym->type = coff_read2 (sym->type); ++ isym->sec = coff_read2 (sym->section_number); ++ isym->sc = sym->storage_class; ++ ++ if (isym->sec > 0 && (uint16_t) isym->sec > sects_num) ++ return -1; ++ if (sym->name.short_name[0] != 0) ++ isym->name = sym->name.short_name; ++ else ++ { ++ uint32_t off = coff_read4 (sym->name.long_name.off); ++ ++ if (off >= strtab_size) ++ return -1; ++ isym->name = (const char *) strtab + off; ++ } ++ return 0; ++} ++ ++/* Return true iff SYM is a defined symbol for a function. Data symbols ++ aren't considered because they aren't easily identified (same type as ++ section names, presence of symbols defined by the linker script). */ ++ ++static int ++coff_is_function_symbol (const b_coff_internal_symbol *isym) ++{ ++ return (isym->type >> N_TBSHFT) == IMAGE_SYM_DTYPE_FUNCTION ++ && isym->sec > 0; ++} ++ ++/* Initialize the symbol table info for coff_syminfo. */ ++ ++static int ++coff_initialize_syminfo (struct backtrace_state *state, ++ uintptr_t base_address, ++ const b_coff_section_header *sects, size_t sects_num, ++ const b_coff_external_symbol *syms, size_t syms_size, ++ const unsigned char *strtab, size_t strtab_size, ++ backtrace_error_callback error_callback, ++ void *data, struct coff_syminfo_data *sdata) ++{ ++ size_t syms_count; ++ char *coff_symstr; ++ size_t coff_symstr_len; ++ size_t coff_symbol_count; ++ size_t coff_symbol_size; ++ struct coff_symbol *coff_symbols; ++ struct coff_symbol *coff_sym; ++ char *coff_str; ++ size_t i; ++ ++ syms_count = syms_size / SYM_SZ; ++ ++ /* We only care about function symbols. Count them. Also count size of ++ strings for in-symbol names. */ ++ coff_symbol_count = 0; ++ coff_symstr_len = 0; ++ for (i = 0; i < syms_count; ++i) ++ { ++ const b_coff_external_symbol *asym = &syms[i]; ++ b_coff_internal_symbol isym; ++ ++ if (coff_expand_symbol (&isym, asym, sects_num, strtab, strtab_size) < 0) ++ { ++ error_callback (data, "invalid section or offset in coff symbol", 0); ++ return 0; ++ } ++ if (coff_is_function_symbol (&isym)) ++ { ++ ++coff_symbol_count; ++ if (asym->name.short_name[0] != 0) ++ coff_symstr_len += coff_short_name_len (asym->name.short_name) + 1; ++ } ++ ++ i += asym->number_of_aux_symbols; ++ } ++ ++ coff_symbol_size = (coff_symbol_count + 1) * sizeof (struct coff_symbol); ++ coff_symbols = ((struct coff_symbol *) ++ backtrace_alloc (state, coff_symbol_size, error_callback, ++ data)); ++ if (coff_symbols == NULL) ++ return 0; ++ ++ /* Allocate memory for symbols strings. */ ++ if (coff_symstr_len > 0) ++ { ++ coff_symstr = ((char *) ++ backtrace_alloc (state, coff_symstr_len, error_callback, ++ data)); ++ if (coff_symstr == NULL) ++ { ++ backtrace_free (state, coff_symbols, coff_symbol_size, ++ error_callback, data); ++ return 0; ++ } ++ } ++ else ++ coff_symstr = NULL; ++ ++ /* Copy symbols. */ ++ coff_sym = coff_symbols; ++ coff_str = coff_symstr; ++ for (i = 0; i < syms_count; ++i) ++ { ++ const b_coff_external_symbol *asym = &syms[i]; ++ b_coff_internal_symbol isym; ++ ++ if (coff_expand_symbol (&isym, asym, sects_num, strtab, strtab_size)) ++ { ++ /* Should not fail, as it was already tested in the previous ++ loop. */ ++ abort (); ++ } ++ if (coff_is_function_symbol (&isym)) ++ { ++ const char *name; ++ int16_t secnum; ++ ++ if (asym->name.short_name[0] != 0) ++ { ++ size_t len = coff_short_name_len (isym.name); ++ name = coff_str; ++ memcpy (coff_str, isym.name, len); ++ coff_str[len] = 0; ++ coff_str += len + 1; ++ } ++ else ++ name = isym.name; ++ ++ /* Strip leading '_'. */ ++ if (name[0] == '_') ++ name++; ++ ++ /* Symbol value is section relative, so we need to read the address ++ of its section. */ ++ secnum = coff_read2 (asym->section_number); ++ ++ coff_sym->name = name; ++ coff_sym->address = (coff_read4 (asym->value) ++ + sects[secnum - 1].virtual_address ++ + base_address); ++ coff_sym++; ++ } ++ ++ i += asym->number_of_aux_symbols; ++ } ++ ++ /* End of symbols marker. */ ++ coff_sym->name = NULL; ++ coff_sym->address = -1; ++ ++ backtrace_qsort (coff_symbols, coff_symbol_count, ++ sizeof (struct coff_symbol), coff_symbol_compare); ++ ++ sdata->next = NULL; ++ sdata->symbols = coff_symbols; ++ sdata->count = coff_symbol_count; ++ ++ return 1; ++} ++ ++/* Add EDATA to the list in STATE. */ ++ ++static void ++coff_add_syminfo_data (struct backtrace_state *state, ++ struct coff_syminfo_data *sdata) ++{ ++ if (!state->threaded) ++ { ++ struct coff_syminfo_data **pp; ++ ++ for (pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data; ++ *pp != NULL; ++ pp = &(*pp)->next) ++ ; ++ *pp = sdata; ++ } ++ else ++ { ++ while (1) ++ { ++ struct coff_syminfo_data **pp; ++ ++ pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data; ++ ++ while (1) ++ { ++ struct coff_syminfo_data *p; ++ ++ p = backtrace_atomic_load_pointer (pp); ++ ++ if (p == NULL) ++ break; ++ ++ pp = &p->next; ++ } ++ ++ if (__sync_bool_compare_and_swap (pp, NULL, sdata)) ++ break; ++ } ++ } ++} ++ ++/* Compare an ADDR against an elf_symbol for bsearch. We allocate one ++ extra entry in the array so that this can look safely at the next ++ entry. */ ++ ++static int ++coff_symbol_search (const void *vkey, const void *ventry) ++{ ++ const uintptr_t *key = (const uintptr_t *) vkey; ++ const struct coff_symbol *entry = (const struct coff_symbol *) ventry; ++ uintptr_t addr; ++ ++ addr = *key; ++ if (addr < entry->address) ++ return -1; ++ else if (addr >= entry[1].address) ++ return 1; ++ else ++ return 0; ++} ++ ++/* Return the symbol name and value for an ADDR. */ ++ ++static void ++coff_syminfo (struct backtrace_state *state, uintptr_t addr, ++ backtrace_syminfo_callback callback, ++ backtrace_error_callback error_callback ATTRIBUTE_UNUSED, ++ void *data) ++{ ++ struct coff_syminfo_data *sdata; ++ struct coff_symbol *sym = NULL; ++ ++ if (!state->threaded) ++ { ++ for (sdata = (struct coff_syminfo_data *) state->syminfo_data; ++ sdata != NULL; ++ sdata = sdata->next) ++ { ++ sym = ((struct coff_symbol *) ++ bsearch (&addr, sdata->symbols, sdata->count, ++ sizeof (struct coff_symbol), coff_symbol_search)); ++ if (sym != NULL) ++ break; ++ } ++ } ++ else ++ { ++ struct coff_syminfo_data **pp; ++ ++ pp = (struct coff_syminfo_data **) (void *) &state->syminfo_data; ++ while (1) ++ { ++ sdata = backtrace_atomic_load_pointer (pp); ++ if (sdata == NULL) ++ break; ++ ++ sym = ((struct coff_symbol *) ++ bsearch (&addr, sdata->symbols, sdata->count, ++ sizeof (struct coff_symbol), coff_symbol_search)); ++ if (sym != NULL) ++ break; ++ ++ pp = &sdata->next; ++ } ++ } ++ ++ if (sym == NULL) ++ callback (data, addr, NULL, 0, 0); ++ else ++ callback (data, addr, sym->name, sym->address, 0); ++} ++ ++/* Add the backtrace data for one PE/COFF file. Returns 1 on success, ++ 0 on failure (in both cases descriptor is closed). */ ++ ++static int ++coff_add (struct backtrace_state *state, int descriptor, ++ backtrace_error_callback error_callback, void *data, ++ fileline *fileline_fn, int *found_sym, int *found_dwarf) ++{ ++ struct backtrace_view fhdr_view; ++ off_t fhdr_off; ++ int magic_ok; ++ b_coff_file_header fhdr; ++ off_t opt_sects_off; ++ size_t opt_sects_size; ++ unsigned int sects_num; ++ struct backtrace_view sects_view; ++ int sects_view_valid; ++ const b_coff_optional_header *opt_hdr; ++ const b_coff_section_header *sects; ++ struct backtrace_view str_view; ++ int str_view_valid; ++ size_t str_size; ++ off_t str_off; ++ struct backtrace_view syms_view; ++ off_t syms_off; ++ size_t syms_size; ++ int syms_view_valid; ++ unsigned int syms_num; ++ unsigned int i; ++ struct debug_section_info sections[DEBUG_MAX]; ++ off_t min_offset; ++ off_t max_offset; ++ struct backtrace_view debug_view; ++ int debug_view_valid; ++ uintptr_t image_base; ++ ++ *found_sym = 0; ++ *found_dwarf = 0; ++ ++ sects_view_valid = 0; ++ syms_view_valid = 0; ++ str_view_valid = 0; ++ debug_view_valid = 0; ++ ++ /* Map the MS-DOS stub (if any) and extract file header offset. */ ++ if (!backtrace_get_view (state, descriptor, 0, 0x40, error_callback, ++ data, &fhdr_view)) ++ goto fail; ++ ++ { ++ const char *vptr = (const char *)fhdr_view.data; ++ ++ if (vptr[0] == 'M' && vptr[1] == 'Z') ++ memcpy (&fhdr_off, vptr + 0x3c, 4); ++ else ++ fhdr_off = 0; ++ } ++ ++ backtrace_release_view (state, &fhdr_view, error_callback, data); ++ ++ /* Map the coff file header. */ ++ if (!backtrace_get_view (state, descriptor, fhdr_off, ++ sizeof (b_coff_file_header) + 4, ++ error_callback, data, &fhdr_view)) ++ goto fail; ++ ++ if (fhdr_off != 0) ++ { ++ const char *magic = (const char *) fhdr_view.data; ++ magic_ok = memcmp (magic, "PE\0", 4) == 0; ++ fhdr_off += 4; ++ ++ memcpy (&fhdr, fhdr_view.data + 4, sizeof fhdr); ++ } ++ else ++ { ++ memcpy (&fhdr, fhdr_view.data, sizeof fhdr); ++ /* TODO: test fhdr.machine for coff but non-PE platforms. */ ++ magic_ok = 0; ++ } ++ backtrace_release_view (state, &fhdr_view, error_callback, data); ++ ++ if (!magic_ok) ++ { ++ error_callback (data, "executable file is not COFF", 0); ++ goto fail; ++ } ++ ++ sects_num = fhdr.number_of_sections; ++ syms_num = fhdr.number_of_symbols; ++ ++ opt_sects_off = fhdr_off + sizeof (fhdr); ++ opt_sects_size = (fhdr.size_of_optional_header ++ + sects_num * sizeof (b_coff_section_header)); ++ ++ /* To translate PC to file/line when using DWARF, we need to find ++ the .debug_info and .debug_line sections. */ ++ ++ /* Read the optional header and the section headers. */ ++ ++ if (!backtrace_get_view (state, descriptor, opt_sects_off, opt_sects_size, ++ error_callback, data, §s_view)) ++ goto fail; ++ sects_view_valid = 1; ++ opt_hdr = (const b_coff_optional_header *) sects_view.data; ++ sects = (const b_coff_section_header *) ++ (sects_view.data + fhdr.size_of_optional_header); ++ ++ if (fhdr.size_of_optional_header > sizeof (*opt_hdr)) ++ { ++ if (opt_hdr->magic == PE_MAGIC) ++ image_base = opt_hdr->u.pe.image_base; ++ else if (opt_hdr->magic == PEP_MAGIC) ++ image_base = opt_hdr->u.pep.image_base; ++ else ++ { ++ error_callback (data, "bad magic in PE optional header", 0); ++ goto fail; ++ } ++ } ++ else ++ image_base = 0; ++ ++ /* Read the symbol table and the string table. */ ++ ++ if (fhdr.pointer_to_symbol_table == 0) ++ { ++ /* No symbol table, no string table. */ ++ str_off = 0; ++ str_size = 0; ++ syms_num = 0; ++ syms_size = 0; ++ } ++ else ++ { ++ /* Symbol table is followed by the string table. The string table ++ starts with its length (on 4 bytes). ++ Map the symbol table and the length of the string table. */ ++ syms_off = fhdr.pointer_to_symbol_table; ++ syms_size = syms_num * SYM_SZ; ++ ++ if (!backtrace_get_view (state, descriptor, syms_off, syms_size + 4, ++ error_callback, data, &syms_view)) ++ goto fail; ++ syms_view_valid = 1; ++ ++ memcpy (&str_size, syms_view.data + syms_size, 4); ++ ++ str_off = syms_off + syms_size; ++ ++ if (str_size > 4) ++ { ++ /* Map string table (including the length word). */ ++ ++ if (!backtrace_get_view (state, descriptor, str_off, str_size, ++ error_callback, data, &str_view)) ++ goto fail; ++ str_view_valid = 1; ++ } ++ } ++ ++ memset (sections, 0, sizeof sections); ++ ++ /* Look for the symbol table. */ ++ for (i = 0; i < sects_num; ++i) ++ { ++ const b_coff_section_header *s = sects + i; ++ unsigned int str_off; ++ int j; ++ ++ if (s->name[0] == '/') ++ { ++ /* Extended section name. */ ++ str_off = atoi (s->name + 1); ++ } ++ else ++ str_off = 0; ++ ++ for (j = 0; j < (int) DEBUG_MAX; ++j) ++ { ++ const char *dbg_name = debug_section_names[j]; ++ int match; ++ ++ if (str_off != 0) ++ match = coff_long_name_eq (dbg_name, str_off, &str_view); ++ else ++ match = coff_short_name_eq (dbg_name, s->name); ++ if (match) ++ { ++ sections[j].offset = s->pointer_to_raw_data; ++ sections[j].size = s->virtual_size <= s->size_of_raw_data ? ++ s->virtual_size : s->size_of_raw_data; ++ break; ++ } ++ } ++ } ++ ++ if (syms_num != 0) ++ { ++ struct coff_syminfo_data *sdata; ++ ++ sdata = ((struct coff_syminfo_data *) ++ backtrace_alloc (state, sizeof *sdata, error_callback, data)); ++ if (sdata == NULL) ++ goto fail; ++ ++ if (!coff_initialize_syminfo (state, image_base, ++ sects, sects_num, ++ syms_view.data, syms_size, ++ str_view.data, str_size, ++ error_callback, data, sdata)) ++ { ++ backtrace_free (state, sdata, sizeof *sdata, error_callback, data); ++ goto fail; ++ } ++ ++ *found_sym = 1; ++ ++ coff_add_syminfo_data (state, sdata); ++ } ++ ++ backtrace_release_view (state, §s_view, error_callback, data); ++ sects_view_valid = 0; ++ backtrace_release_view (state, &syms_view, error_callback, data); ++ syms_view_valid = 0; ++ ++ /* Read all the debug sections in a single view, since they are ++ probably adjacent in the file. We never release this view. */ ++ ++ min_offset = 0; ++ max_offset = 0; ++ for (i = 0; i < (int) DEBUG_MAX; ++i) ++ { ++ off_t end; ++ ++ if (sections[i].size == 0) ++ continue; ++ if (min_offset == 0 || sections[i].offset < min_offset) ++ min_offset = sections[i].offset; ++ end = sections[i].offset + sections[i].size; ++ if (end > max_offset) ++ max_offset = end; ++ } ++ if (min_offset == 0 || max_offset == 0) ++ { ++ if (!backtrace_close (descriptor, error_callback, data)) ++ goto fail; ++ *fileline_fn = coff_nodebug; ++ return 1; ++ } ++ ++ if (!backtrace_get_view (state, descriptor, min_offset, ++ max_offset - min_offset, ++ error_callback, data, &debug_view)) ++ goto fail; ++ debug_view_valid = 1; ++ ++ /* We've read all we need from the executable. */ ++ if (!backtrace_close (descriptor, error_callback, data)) ++ goto fail; ++ descriptor = -1; ++ ++ for (i = 0; i < (int) DEBUG_MAX; ++i) ++ { ++ if (sections[i].size == 0) ++ sections[i].data = NULL; ++ else ++ sections[i].data = ((const unsigned char *) debug_view.data ++ + (sections[i].offset - min_offset)); ++ } ++ ++ if (!backtrace_dwarf_add (state, /* base_address */ 0, ++ sections[DEBUG_INFO].data, ++ sections[DEBUG_INFO].size, ++ sections[DEBUG_LINE].data, ++ sections[DEBUG_LINE].size, ++ sections[DEBUG_ABBREV].data, ++ sections[DEBUG_ABBREV].size, ++ sections[DEBUG_RANGES].data, ++ sections[DEBUG_RANGES].size, ++ sections[DEBUG_STR].data, ++ sections[DEBUG_STR].size, ++ 0, /* FIXME */ ++ error_callback, data, fileline_fn)) ++ goto fail; ++ ++ *found_dwarf = 1; ++ ++ return 1; ++ ++ fail: ++ if (sects_view_valid) ++ backtrace_release_view (state, §s_view, error_callback, data); ++ if (str_view_valid) ++ backtrace_release_view (state, &str_view, error_callback, data); ++ if (syms_view_valid) ++ backtrace_release_view (state, &syms_view, error_callback, data); ++ if (debug_view_valid) ++ backtrace_release_view (state, &debug_view, error_callback, data); ++ if (descriptor != -1) ++ backtrace_close (descriptor, error_callback, data); ++ return 0; ++} ++ ++/* Initialize the backtrace data we need from an ELF executable. At ++ the ELF level, all we need to do is find the debug info ++ sections. */ ++ ++int ++backtrace_initialize (struct backtrace_state *state, int descriptor, ++ backtrace_error_callback error_callback, ++ void *data, fileline *fileline_fn) ++{ ++ int ret; ++ int found_sym; ++ int found_dwarf; ++ fileline coff_fileline_fn; ++ ++ ret = coff_add (state, descriptor, error_callback, data, ++ &coff_fileline_fn, &found_sym, &found_dwarf); ++ if (!ret) ++ return 0; ++ ++ if (!state->threaded) ++ { ++ if (found_sym) ++ state->syminfo_fn = coff_syminfo; ++ else if (state->syminfo_fn == NULL) ++ state->syminfo_fn = coff_nosyms; ++ } ++ else ++ { ++ if (found_sym) ++ backtrace_atomic_store_pointer (&state->syminfo_fn, coff_syminfo); ++ else ++ __sync_bool_compare_and_swap (&state->syminfo_fn, NULL, coff_nosyms); ++ } ++ ++ if (!state->threaded) ++ { ++ if (state->fileline_fn == NULL || state->fileline_fn == coff_nodebug) ++ *fileline_fn = coff_fileline_fn; ++ } ++ else ++ { ++ fileline current_fn; ++ ++ current_fn = backtrace_atomic_load_pointer (&state->fileline_fn); ++ if (current_fn == NULL || current_fn == coff_nodebug) ++ *fileline_fn = coff_fileline_fn; ++ } ++ ++ return 1; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/posix.c index 000000000,000000000..be7357e6b new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/posix.c @@@ -1,0 -1,0 +1,100 @@@ ++/* posix.c -- POSIX file I/O routines for the backtrace library. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++#ifndef O_BINARY ++#define O_BINARY 0 ++#endif ++ ++#ifndef O_CLOEXEC ++#define O_CLOEXEC 0 ++#endif ++ ++#ifndef FD_CLOEXEC ++#define FD_CLOEXEC 1 ++#endif ++ ++/* Open a file for reading. */ ++ ++int ++backtrace_open (const char *filename, backtrace_error_callback error_callback, ++ void *data, int *does_not_exist) ++{ ++ int descriptor; ++ ++ if (does_not_exist != NULL) ++ *does_not_exist = 0; ++ ++ descriptor = open (filename, (int) (O_RDONLY | O_BINARY | O_CLOEXEC)); ++ if (descriptor < 0) ++ { ++ if (does_not_exist != NULL && errno == ENOENT) ++ *does_not_exist = 1; ++ else ++ error_callback (data, filename, errno); ++ return -1; ++ } ++ ++#ifdef HAVE_FCNTL ++ /* Set FD_CLOEXEC just in case the kernel does not support ++ O_CLOEXEC. It doesn't matter if this fails for some reason. ++ FIXME: At some point it should be safe to only do this if ++ O_CLOEXEC == 0. */ ++ fcntl (descriptor, F_SETFD, FD_CLOEXEC); ++#endif ++ ++ return descriptor; ++} ++ ++/* Close DESCRIPTOR. */ ++ ++int ++backtrace_close (int descriptor, backtrace_error_callback error_callback, ++ void *data) ++{ ++ if (close (descriptor) < 0) ++ { ++ error_callback (data, "close", errno); ++ return 0; ++ } ++ return 1; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/print.c index 000000000,000000000..73b8abc19 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/print.c @@@ -1,0 -1,0 +1,92 @@@ ++/* print.c -- Print the current backtrace. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++/* Passed to callbacks. */ ++ ++struct print_data ++{ ++ struct backtrace_state *state; ++ FILE *f; ++}; ++ ++/* Print one level of a backtrace. */ ++ ++static int ++print_callback (void *data, uintptr_t pc, const char *filename, int lineno, ++ const char *function) ++{ ++ struct print_data *pdata = (struct print_data *) data; ++ ++ fprintf (pdata->f, "0x%lx %s\n\t%s:%d\n", ++ (unsigned long) pc, ++ function == NULL ? "???" : function, ++ filename == NULL ? "???" : filename, ++ lineno); ++ return 0; ++} ++ ++/* Print errors to stderr. */ ++ ++static void ++error_callback (void *data, const char *msg, int errnum) ++{ ++ struct print_data *pdata = (struct print_data *) data; ++ ++ if (pdata->state->filename != NULL) ++ fprintf (stderr, "%s: ", pdata->state->filename); ++ fprintf (stderr, "libbacktrace: %s", msg); ++ if (errnum > 0) ++ fprintf (stderr, ": %s", strerror (errnum)); ++ fputc ('\n', stderr); ++} ++ ++/* Print a backtrace. */ ++ ++void ++backtrace_print (struct backtrace_state *state, int skip, FILE *f) ++{ ++ struct print_data data; ++ ++ data.state = state; ++ data.f = f; ++ backtrace_full (state, skip + 1, print_callback, error_callback, ++ (void *) &data); ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/read.c index 000000000,000000000..33b68f843 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/read.c @@@ -1,0 -1,0 +1,96 @@@ ++/* read.c -- File views without mmap. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++/* This file implements file views when mmap is not available. */ ++ ++/* Create a view of SIZE bytes from DESCRIPTOR at OFFSET. */ ++ ++int ++backtrace_get_view (struct backtrace_state *state, int descriptor, ++ off_t offset, size_t size, ++ backtrace_error_callback error_callback, ++ void *data, struct backtrace_view *view) ++{ ++ ssize_t got; ++ ++ if (lseek (descriptor, offset, SEEK_SET) < 0) ++ { ++ error_callback (data, "lseek", errno); ++ return 0; ++ } ++ ++ view->base = backtrace_alloc (state, size, error_callback, data); ++ if (view->base == NULL) ++ return 0; ++ view->data = view->base; ++ view->len = size; ++ ++ got = read (descriptor, view->base, size); ++ if (got < 0) ++ { ++ error_callback (data, "read", errno); ++ free (view->base); ++ return 0; ++ } ++ ++ if ((size_t) got < size) ++ { ++ error_callback (data, "file too short", 0); ++ free (view->base); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++/* Release a view read by backtrace_get_view. */ ++ ++void ++backtrace_release_view (struct backtrace_state *state, ++ struct backtrace_view *view, ++ backtrace_error_callback error_callback, ++ void *data) ++{ ++ backtrace_free (state, view->base, view->len, error_callback, data); ++ view->data = NULL; ++ view->base = NULL; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/simple.c index 000000000,000000000..493fd6de7 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/simple.c @@@ -1,0 -1,0 +1,108 @@@ ++/* simple.c -- The backtrace_simple function. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include "unwind.h" ++#include "backtrace.h" ++ ++/* The simple_backtrace routine. */ ++ ++/* Data passed through _Unwind_Backtrace. */ ++ ++struct backtrace_simple_data ++{ ++ /* Number of frames to skip. */ ++ int skip; ++ /* Library state. */ ++ struct backtrace_state *state; ++ /* Callback routine. */ ++ backtrace_simple_callback callback; ++ /* Error callback routine. */ ++ backtrace_error_callback error_callback; ++ /* Data to pass to callback routine. */ ++ void *data; ++ /* Value to return from backtrace. */ ++ int ret; ++}; ++ ++/* Unwind library callback routine. This is passd to ++ _Unwind_Backtrace. */ ++ ++static _Unwind_Reason_Code ++simple_unwind (struct _Unwind_Context *context, void *vdata) ++{ ++ struct backtrace_simple_data *bdata = (struct backtrace_simple_data *) vdata; ++ uintptr_t pc; ++ int ip_before_insn = 0; ++ ++#ifdef HAVE_GETIPINFO ++ pc = _Unwind_GetIPInfo (context, &ip_before_insn); ++#else ++ pc = _Unwind_GetIP (context); ++#endif ++ ++ if (bdata->skip > 0) ++ { ++ --bdata->skip; ++ return _URC_NO_REASON; ++ } ++ ++ if (!ip_before_insn) ++ --pc; ++ ++ bdata->ret = bdata->callback (bdata->data, pc); ++ ++ if (bdata->ret != 0) ++ return _URC_END_OF_STACK; ++ ++ return _URC_NO_REASON; ++} ++ ++/* Get a simple stack backtrace. */ ++ ++int ++backtrace_simple (struct backtrace_state *state, int skip, ++ backtrace_simple_callback callback, ++ backtrace_error_callback error_callback, void *data) ++{ ++ struct backtrace_simple_data bdata; ++ ++ bdata.skip = skip + 1; ++ bdata.state = state; ++ bdata.callback = callback; ++ bdata.error_callback = error_callback; ++ bdata.data = data; ++ bdata.ret = 0; ++ _Unwind_Backtrace (simple_unwind, &bdata); ++ return bdata.ret; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/sort.c index 000000000,000000000..f352fca5e new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/sort.c @@@ -1,0 -1,0 +1,108 @@@ ++/* sort.c -- Sort without allocating memory ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++/* The GNU glibc version of qsort allocates memory, which we must not ++ do if we are invoked by a signal handler. So provide our own ++ sort. */ ++ ++static void ++swap (char *a, char *b, size_t size) ++{ ++ size_t i; ++ ++ for (i = 0; i < size; i++, a++, b++) ++ { ++ char t; ++ ++ t = *a; ++ *a = *b; ++ *b = t; ++ } ++} ++ ++void ++backtrace_qsort (void *basearg, size_t count, size_t size, ++ int (*compar) (const void *, const void *)) ++{ ++ char *base = (char *) basearg; ++ size_t i; ++ size_t mid; ++ ++ tail_recurse: ++ if (count < 2) ++ return; ++ ++ /* The symbol table and DWARF tables, which is all we use this ++ routine for, tend to be roughly sorted. Pick the middle element ++ in the array as our pivot point, so that we are more likely to ++ cut the array in half for each recursion step. */ ++ swap (base, base + (count / 2) * size, size); ++ ++ mid = 0; ++ for (i = 1; i < count; i++) ++ { ++ if ((*compar) (base, base + i * size) > 0) ++ { ++ ++mid; ++ if (i != mid) ++ swap (base + mid * size, base + i * size, size); ++ } ++ } ++ ++ if (mid > 0) ++ swap (base, base + mid * size, size); ++ ++ /* Recurse with the smaller array, loop with the larger one. That ++ ensures that our maximum stack depth is log count. */ ++ if (2 * mid < count) ++ { ++ backtrace_qsort (base, mid, size, compar); ++ base += (mid + 1) * size; ++ count -= mid + 1; ++ goto tail_recurse; ++ } ++ else ++ { ++ backtrace_qsort (base + (mid + 1) * size, count - (mid + 1), ++ size, compar); ++ count = mid; ++ goto tail_recurse; ++ } ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/state.c index 000000000,000000000..361a3963c new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/state.c @@@ -1,0 -1,0 +1,72 @@@ ++/* state.c -- Create the backtrace state. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++ ++#include "backtrace.h" ++#include "backtrace-supported.h" ++#include "internal.h" ++ ++/* Create the backtrace state. This will then be passed to all the ++ other routines. */ ++ ++struct backtrace_state * ++backtrace_create_state (const char *filename, int threaded, ++ backtrace_error_callback error_callback, ++ void *data) ++{ ++ struct backtrace_state init_state; ++ struct backtrace_state *state; ++ ++#ifndef HAVE_SYNC_FUNCTIONS ++ if (threaded) ++ { ++ error_callback (data, "backtrace library does not support threads", 0); ++ return NULL; ++ } ++#endif ++ ++ memset (&init_state, 0, sizeof init_state); ++ init_state.filename = filename; ++ init_state.threaded = threaded; ++ ++ state = ((struct backtrace_state *) ++ backtrace_alloc (&init_state, sizeof *state, error_callback, data)); ++ if (state == NULL) ++ return NULL; ++ *state = init_state; ++ ++ return state; ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/stest.c index 000000000,000000000..7a0b06d3e new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/stest.c @@@ -1,0 -1,0 +1,137 @@@ ++/* stest.c -- Test for libbacktrace internal sort function ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++#include ++#include ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++/* Test the local qsort implementation. */ ++ ++#define MAX 10 ++ ++struct test ++{ ++ size_t count; ++ int input[MAX]; ++ int output[MAX]; ++}; ++ ++static struct test tests[] = ++ { ++ { ++ 10, ++ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, ++ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } ++ }, ++ { ++ 9, ++ { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, ++ { 1, 2, 3, 4, 5, 6, 7, 8, 9 } ++ }, ++ { ++ 10, ++ { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }, ++ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, ++ }, ++ { ++ 9, ++ { 9, 8, 7, 6, 5, 4, 3, 2, 1 }, ++ { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, ++ }, ++ { ++ 10, ++ { 2, 4, 6, 8, 10, 1, 3, 5, 7, 9 }, ++ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, ++ }, ++ { ++ 5, ++ { 4, 5, 3, 1, 2 }, ++ { 1, 2, 3, 4, 5 }, ++ }, ++ { ++ 5, ++ { 1, 1, 1, 1, 1 }, ++ { 1, 1, 1, 1, 1 }, ++ }, ++ { ++ 5, ++ { 1, 1, 2, 1, 1 }, ++ { 1, 1, 1, 1, 2 }, ++ }, ++ { ++ 5, ++ { 2, 1, 1, 1, 1 }, ++ { 1, 1, 1, 1, 2 }, ++ }, ++ }; ++ ++static int ++compare (const void *a, const void *b) ++{ ++ const int *ai = (const int *) a; ++ const int *bi = (const int *) b; ++ ++ return *ai - *bi; ++} ++ ++int ++main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) ++{ ++ int failures; ++ size_t i; ++ int a[MAX]; ++ ++ failures = 0; ++ for (i = 0; i < sizeof tests / sizeof tests[0]; i++) ++ { ++ memcpy (a, tests[i].input, tests[i].count * sizeof (int)); ++ backtrace_qsort (a, tests[i].count, sizeof (int), compare); ++ if (memcmp (a, tests[i].output, tests[i].count * sizeof (int)) != 0) ++ { ++ size_t j; ++ ++ fprintf (stderr, "test %d failed:", (int) i); ++ for (j = 0; j < tests[i].count; j++) ++ fprintf (stderr, " %d", a[j]); ++ fprintf (stderr, "\n"); ++ ++failures; ++ } ++ } ++ ++ exit (failures > 0 ? EXIT_FAILURE : EXIT_SUCCESS); ++} diff --cc vendor/backtrace-sys-0.1.14/src/libbacktrace/unknown.c index 000000000,000000000..8afe65b3f new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/src/libbacktrace/unknown.c @@@ -1,0 -1,0 +1,64 @@@ ++/* unknown.c -- used when backtrace configury does not know file format. ++ Copyright (C) 2012-2016 Free Software Foundation, Inc. ++ Written by Ian Lance Taylor, Google. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are ++met: ++ ++ (1) Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ (2) Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in ++ the documentation and/or other materials provided with the ++ distribution. ++ ++ (3) The name of the author may not be used to ++ endorse or promote products derived from this software without ++ specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR ++IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, ++INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ++SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ++STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ++IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++POSSIBILITY OF SUCH DAMAGE. */ ++ ++#include "config.h" ++ ++#include ++ ++#include "backtrace.h" ++#include "internal.h" ++ ++/* A trivial routine that always fails to find fileline data. */ ++ ++static int ++unknown_fileline (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ uintptr_t pc, backtrace_full_callback callback, ++ backtrace_error_callback error_callback ATTRIBUTE_UNUSED, ++ void *data) ++ ++{ ++ return callback (data, pc, NULL, 0, NULL); ++} ++ ++/* Initialize the backtrace data when we don't know how to read the ++ debug info. */ ++ ++int ++backtrace_initialize (struct backtrace_state *state ATTRIBUTE_UNUSED, ++ int descriptor ATTRIBUTE_UNUSED, ++ backtrace_error_callback error_callback ATTRIBUTE_UNUSED, ++ void *data ATTRIBUTE_UNUSED, fileline *fileline_fn) ++{ ++ state->fileline_data = NULL; ++ *fileline_fn = unknown_fileline; ++ return 1; ++} diff --cc vendor/backtrace-sys-0.1.14/symbol-map index 000000000,000000000..fbadc7369 new file mode 100644 --- /dev/null +++ b/vendor/backtrace-sys-0.1.14/symbol-map @@@ -1,0 -1,0 +1,18 @@@ ++backtrace_full __rbt_backtrace_full ++backtrace_dwarf_add __rbt_backtrace_dwarf_add ++backtrace_initialize __rbt_backtrace_initialize ++backtrace_pcinfo __rbt_backtrace_pcinfo ++backtrace_syminfo __rbt_backtrace_syminfo ++backtrace_get_view __rbt_backtrace_get_view ++backtrace_release_view __rbt_backtrace_release_view ++backtrace_alloc __rbt_backtrace_alloc ++backtrace_free __rbt_backtrace_free ++backtrace_vector_finish __rbt_backtrace_vector_finish ++backtrace_vector_grow __rbt_backtrace_vector_grow ++backtrace_vector_release __rbt_backtrace_vector_release ++backtrace_close __rbt_backtrace_close ++backtrace_open __rbt_backtrace_open ++backtrace_print __rbt_backtrace_print ++backtrace_simple __rbt_backtrace_simple ++backtrace_qsort __rbt_backtrace_qsort ++backtrace_create_state __rbt_backtrace_create_state diff --cc vendor/cc-1.0.0/.cargo-checksum.json index 000000000,000000000..9a1130cbc new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"7db2f146208d7e0fbee761b09cd65a7f51ccc38705d4e7262dad4d73b12a76b1"} diff --cc vendor/cc-1.0.0/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/.cargo-ok diff --cc vendor/cc-1.0.0/.travis.yml index 000000000,000000000..0f0a094ec new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/.travis.yml @@@ -1,0 -1,0 +1,48 @@@ ++language: rust ++rust: ++ - stable ++ - beta ++ - nightly ++matrix: ++ include: ++ # Minimum version supported ++ - rust: 1.13.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 ++ - if [ -z "$NO_ADD" ]; then rustup target add $TARGET; fi ++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 NO_ADD=1 ++ - ARCH=i686 ++notifications: ++ email: ++ on_success: never ++os: ++ - linux ++ - osx ++addons: ++ apt: ++ packages: ++ - g++-multilib diff --cc vendor/cc-1.0.0/Cargo.toml index 000000000,000000000..90e52bec9 new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/Cargo.toml @@@ -1,0 -1,0 +1,36 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "cc" ++version = "1.0.0" ++authors = ["Alex Crichton "] ++description = "A build-time dependency for Cargo build scripts to assist in invoking the native\nC compiler to compile native C code into a static archive to be linked into Rust\ncode.\n" ++documentation = "https://docs.rs/cc" ++readme = "README.md" ++keywords = ["build-dependencies"] ++categories = ["development-tools"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/cc-rs" ++[dependencies.rayon] ++version = "0.8" ++optional = true ++[dev-dependencies.tempdir] ++version = "0.3" ++ ++[features] ++parallel = ["rayon"] ++[badges.travis-ci] ++repository = "alexcrichton/gcc-rs" ++ ++[badges.appveyor] ++repository = "alexcrichton/gcc-rs" diff --cc vendor/cc-1.0.0/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/cc-1.0.0/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/cc-1.0.0/README.md index 000000000,000000000..edb0d402c new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/README.md @@@ -1,0 -1,0 +1,161 @@@ ++# cc-rs ++ ++A library to compile C/C++/assembly into a Rust library/application. ++ ++[![Build Status](https://travis-ci.org/alexcrichton/cc-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/cc-rs) ++[![Build status](https://ci.appveyor.com/api/projects/status/onu270iw98h81nwv?svg=true)](https://ci.appveyor.com/project/alexcrichton/cc-rs) ++ ++[Documentation](https://docs.rs/cc) ++ ++A simple library meant to be used as a build dependency with Cargo packages in ++order to build a set of C/C++ files into a static archive. This crate calls out ++to the most relevant compiler for a platform, for example using `cl` on MSVC. ++ ++## Using cc-rs ++ ++First, you'll want to both add a build script for your crate (`build.rs`) and ++also add this crate to your `Cargo.toml` via: ++ ++```toml ++[build-dependencies] ++cc = "1.0" ++``` ++ ++Next up, you'll want to write a build script like so: ++ ++```rust,no_run ++// build.rs ++ ++extern crate cc; ++ ++fn main() { ++ cc::Build::new() ++ .file("foo.c") ++ .file("bar.c") ++ .compile("foo"); ++} ++``` ++ ++And that's it! Running `cargo build` should take care of the rest and your Rust ++application will now have the C files `foo.c` and `bar.c` compiled into a file ++named libfoo.a. You can call the functions in Rust by declaring functions in ++your Rust code like so: ++ ++``` ++extern { ++ fn foo_function(); ++ fn bar_function(); ++} ++ ++pub fn call() { ++ unsafe { ++ foo_function(); ++ bar_function(); ++ } ++} ++ ++fn main() { ++ // ... ++} ++``` ++ ++## External configuration via environment variables ++ ++To control the programs and flags used for building, the builder can set a ++number of different environment variables. ++ ++* `CFLAGS` - a series of space separated flags passed to compilers. Note that ++ individual flags cannot currently contain spaces, so doing ++ something like: "-L=foo\ bar" is not possible. ++* `CC` - the actual C compiler used. Note that this is used as an exact ++ executable name, so (for example) no extra flags can be passed inside ++ this variable, and the builder must ensure that there aren't any ++ trailing spaces. This compiler must understand the `-c` flag. For ++ certain `TARGET`s, it also is assumed to know about other flags (most ++ common is `-fPIC`). ++* `AR` - the `ar` (archiver) executable to use to build the static library. ++ ++Each of these variables can also be supplied with certain prefixes and suffixes, ++in the following prioritized order: ++ ++1. `_` - for example, `CC_x86_64-unknown-linux-gnu` ++2. `_` - for example, `CC_x86_64_unknown_linux_gnu` ++3. `_` - for example, `HOST_CC` or `TARGET_CFLAGS` ++4. `` - a plain `CC`, `AR` as above. ++ ++If none of these variables exist, cc-rs uses built-in defaults ++ ++In addition to the the above optional environment variables, `cc-rs` has some ++functions with hard requirements on some variables supplied by [cargo's ++build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`, ++and `HOST` variables. ++ ++[cargo]: http://doc.crates.io/build-script.html#inputs-to-the-build-script ++ ++## Optional features ++ ++Currently cc-rs supports parallel compilation (think `make -jN`) but this ++feature is turned off by default. To enable cc-rs to compile C/C++ in parallel, ++you can change your dependency to: ++ ++```toml ++[build-dependencies] ++cc = { version = "1.0", features = ["parallel"] } ++``` ++ ++By default cc-rs will limit parallelism to `$NUM_JOBS`, or if not present it ++will limit it to the number of cpus on the machine. If you are using cargo, ++use `-jN` option of `build`, `test` and `run` commands as `$NUM_JOBS` ++is supplied by cargo. ++ ++## Compile-time Requirements ++ ++To work properly this crate needs access to a C compiler when the build script ++is being run. This crate does not ship a C compiler with it. The compiler ++required varies per platform, but there are three broad categories: ++ ++* Unix platforms require `cc` to be the C compiler. This can be found by ++ installing cc/clang on Linux distributions and Xcode on OSX, for example. ++* Windows platforms targeting MSVC (e.g. your target triple ends in `-msvc`) ++ require `cl.exe` to be available and in `PATH`. This is typically found in ++ standard Visual Studio installations and the `PATH` can be set up by running ++ the appropriate developer tools shell. ++* Windows platforms targeting MinGW (e.g. your target triple ends in `-gnu`) ++ require `cc` to be available in `PATH`. We recommend the ++ [MinGW-w64](http://mingw-w64.org) distribution, which is using the ++ [Win-builds](http://win-builds.org) installation system. ++ You may also acquire it via ++ [MSYS2](http://msys2.github.io), as explained [here][msys2-help]. Make sure ++ to install the appropriate architecture corresponding to your installation of ++ rustc. GCC from older [MinGW](http://www.mingw.org) project is compatible ++ only with 32-bit rust compiler. ++ ++[msys2-help]: http://github.com/rust-lang/rust#building-on-windows ++ ++## C++ support ++ ++`cc-rs` supports C++ libraries compilation by using the `cpp` method on ++`Build`: ++ ++```rust,no_run ++extern crate cc; ++ ++fn main() { ++ cc::Build::new() ++ .cpp(true) // Switch to C++ library compilation. ++ .file("foo.cpp") ++ .compile("libfoo.a"); ++} ++``` ++ ++When using C++ library compilation switch, the `CXX` and `CXXFLAGS` env ++variables are used instead of `CC` and `CFLAGS` and the C++ standard library is ++linked to the crate target. ++ ++## License ++ ++`cc-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 --cc vendor/cc-1.0.0/appveyor.yml index 000000000,000000000..aa1edb5f4 new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/appveyor.yml @@@ -1,0 -1,0 +1,55 @@@ ++environment: ++ ++ # At the time this was added AppVeyor was having troubles with checking ++ # revocation of SSL certificates of sites like static.rust-lang.org and what ++ # we think is crates.io. The libcurl HTTP client by default checks for ++ # revocation on Windows and according to a mailing list [1] this can be ++ # disabled. ++ # ++ # The `CARGO_HTTP_CHECK_REVOKE` env var here tells cargo to disable SSL ++ # revocation checking on Windows in libcurl. Note, though, that rustup, which ++ # we're using to download Rust here, also uses libcurl as the default backend. ++ # Unlike Cargo, however, rustup doesn't have a mechanism to disable revocation ++ # checking. To get rustup working we set `RUSTUP_USE_HYPER` which forces it to ++ # use the Hyper instead of libcurl backend. Both Hyper and libcurl use ++ # schannel on Windows but it appears that Hyper configures it slightly ++ # differently such that revocation checking isn't turned on by default. ++ # ++ # [1]: https://curl.haxx.se/mail/lib-2016-03/0202.html ++ RUSTUP_USE_HYPER: 1 ++ CARGO_HTTP_CHECK_REVOKE: false ++ ++ matrix: ++ - TARGET: x86_64-pc-windows-msvc ++ 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 --cc vendor/cc-1.0.0/src/bin/gcc-shim.rs index 000000000,000000000..7fd0ea8fa new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/src/bin/gcc-shim.rs @@@ -1,0 -1,0 +1,23 @@@ ++#![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 --cc vendor/cc-1.0.0/src/com.rs index 000000000,000000000..bd8cce714 new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/src/com.rs @@@ -1,0 -1,0 +1,125 @@@ ++// Copyright © 2017 winapi-rs developers ++// Licensed under the Apache License, Version 2.0 ++// or the MIT license ++// , at your option. ++// All files in the project carrying such notice may not be copied, modified, or distributed ++// except according to those terms. ++ ++#![allow(unused)] ++ ++use std::ffi::{OsStr, OsString}; ++use std::mem::forget; ++use std::ops::Deref; ++use std::os::windows::ffi::{OsStrExt, OsStringExt}; ++use std::ptr::null_mut; ++use std::slice::from_raw_parts; ++use winapi::Interface; ++use winapi::BSTR; ++use winapi::CoInitializeEx; ++use winapi::COINIT_MULTITHREADED; ++use winapi::{SysFreeString, SysStringLen}; ++use winapi::IUnknown; ++use winapi::{S_OK, S_FALSE, HRESULT}; ++ ++pub fn initialize() -> Result<(), HRESULT> { ++ let err = unsafe { CoInitializeEx(null_mut(), COINIT_MULTITHREADED) }; ++ if err != S_OK && err != S_FALSE { ++ // S_FALSE just means COM is already initialized ++ return Err(err); ++ } ++ Ok(()) ++} ++ ++pub struct ComPtr(*mut T) where T: Interface; ++impl ComPtr where T: Interface { ++ /// Creates a `ComPtr` to wrap a raw pointer. ++ /// It takes ownership over the pointer which means it does __not__ call `AddRef`. ++ /// `T` __must__ be a COM interface that inherits from `IUnknown`. ++ pub unsafe fn from_raw(ptr: *mut T) -> ComPtr { ++ assert!(!ptr.is_null()); ++ ComPtr(ptr) ++ } ++ /// Casts up the inheritance chain ++ pub fn up(self) -> ComPtr where T: Deref, U: Interface { ++ ComPtr(self.into_raw() as *mut U) ++ } ++ /// Extracts the raw pointer. ++ /// You are now responsible for releasing it yourself. ++ pub fn into_raw(self) -> *mut T { ++ let p = self.0; ++ forget(self); ++ p ++ } ++ /// For internal use only. ++ fn as_unknown(&self) -> &IUnknown { ++ unsafe { &*(self.0 as *mut IUnknown) } ++ } ++ /// Performs QueryInterface fun. ++ pub fn cast(&self) -> Result, i32> where U: Interface { ++ let mut obj = null_mut(); ++ let err = unsafe { self.as_unknown().QueryInterface(&U::uuidof(), &mut obj) }; ++ if err < 0 { return Err(err); } ++ Ok(unsafe { ComPtr::from_raw(obj as *mut U) }) ++ } ++} ++impl Deref for ComPtr where T: Interface { ++ type Target = T; ++ fn deref(&self) -> &T { ++ unsafe { &*self.0 } ++ } ++} ++impl Clone for ComPtr where T: Interface { ++ fn clone(&self) -> Self { ++ unsafe { ++ self.as_unknown().AddRef(); ++ ComPtr::from_raw(self.0) ++ } ++ } ++} ++impl Drop for ComPtr where T: Interface { ++ fn drop(&mut self) { ++ unsafe { self.as_unknown().Release(); } ++ } ++} ++pub struct BStr(BSTR); ++impl BStr { ++ pub unsafe fn from_raw(s: BSTR) -> BStr { ++ BStr(s) ++ } ++ pub fn to_osstring(&self) -> OsString { ++ let len = unsafe { SysStringLen(self.0) }; ++ let slice = unsafe { from_raw_parts(self.0, len as usize) }; ++ OsStringExt::from_wide(slice) ++ } ++} ++impl Drop for BStr { ++ fn drop(&mut self) { ++ unsafe { SysFreeString(self.0) }; ++ } ++} ++ ++pub trait ToWide { ++ fn to_wide(&self) -> Vec; ++ fn to_wide_null(&self) -> Vec; ++} ++impl ToWide for T where T: AsRef { ++ fn to_wide(&self) -> Vec { ++ self.as_ref().encode_wide().collect() ++ } ++ fn to_wide_null(&self) -> Vec { ++ self.as_ref().encode_wide().chain(Some(0)).collect() ++ } ++} ++pub trait FromWide where Self: Sized { ++ fn from_wide(wide: &[u16]) -> Self; ++ fn from_wide_null(wide: &[u16]) -> Self { ++ let len = wide.iter().take_while(|&&c| c != 0).count(); ++ Self::from_wide(&wide[..len]) ++ } ++} ++impl FromWide for OsString { ++ fn from_wide(wide: &[u16]) -> OsString { ++ OsStringExt::from_wide(wide) ++ } ++} ++ diff --cc vendor/cc-1.0.0/src/lib.rs index 000000000,000000000..ac966b4e5 new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/src/lib.rs @@@ -1,0 -1,0 +1,1659 @@@ ++//! A library for build scripts to compile custom C code ++//! ++//! This library is intended to be used as a `build-dependencies` entry in ++//! `Cargo.toml`: ++//! ++//! ```toml ++//! [build-dependencies] ++//! cc = "1.0" ++//! ``` ++//! ++//! The purpose of this crate is to provide the utility functions necessary to ++//! compile C code into a static archive which is then linked into a Rust crate. ++//! Configuration is available through the `Build` struct. ++//! ++//! This crate will automatically detect situations such as cross compilation or ++//! other environment variables set by Cargo and will build code appropriately. ++//! ++//! The crate is not limited to C code, it can accept any source code that can ++//! be passed to a C or C++ compiler. As such, assembly files with extensions ++//! `.s` (gcc/clang) and `.asm` (MSVC) can also be compiled. ++//! ++//! [`Build`]: struct.Build.html ++//! ++//! # Examples ++//! ++//! Use the `Build` struct to compile `src/foo.c`: ++//! ++//! ```no_run ++//! extern crate cc; ++//! ++//! fn main() { ++//! cc::Build::new() ++//! .file("src/foo.c") ++//! .define("FOO", Some("bar")) ++//! .include("src") ++//! .compile("foo"); ++//! } ++//! ``` ++ ++#![doc(html_root_url = "https://docs.rs/cc/1.0")] ++#![cfg_attr(test, deny(warnings))] ++#![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, Child}; ++use std::io::{self, BufReader, BufRead, Read, Write}; ++use std::thread::{self, JoinHandle}; ++ ++#[cfg(feature = "parallel")] ++use std::sync::Mutex; ++ ++// These modules are all glue to support reading the MSVC version from ++// the registry and from COM interfaces ++#[cfg(windows)] ++mod registry; ++#[cfg(windows)] ++#[macro_use] ++mod winapi; ++#[cfg(windows)] ++mod com; ++#[cfg(windows)] ++mod setup_config; ++ ++pub mod windows_registry; ++ ++/// A builder for compilation of a native static library. ++/// ++/// A `Build` is the main type of the `cc` crate and is used to control all the ++/// various configuration options and such of a compile. You'll find more ++/// documentation on each method itself. ++#[derive(Clone, Debug)] ++pub struct Build { ++ include_directories: Vec, ++ definitions: Vec<(String, Option)>, ++ objects: Vec, ++ flags: Vec, ++ flags_supported: Vec, ++ files: Vec, ++ cpp: bool, ++ cpp_link_stdlib: Option>, ++ cpp_set_stdlib: Option, ++ target: Option, ++ host: Option, ++ out_dir: Option, ++ opt_level: Option, ++ debug: Option, ++ env: Vec<(OsString, OsString)>, ++ compiler: Option, ++ archiver: Option, ++ cargo_metadata: bool, ++ pic: Option, ++ static_crt: Option, ++ shared_flag: Option, ++ static_flag: Option, ++ warnings_into_errors: bool, ++ warnings: bool, ++} ++ ++/// Represents the types of errors that may occur while using cc-rs. ++#[derive(Clone, Debug)] ++enum ErrorKind { ++ /// Error occurred while performing I/O. ++ IOError, ++ /// Invalid architecture supplied. ++ ArchitectureInvalid, ++ /// Environment variable not found, with the var in question as extra info. ++ EnvVarNotFound, ++ /// Error occurred while using external tools (ie: invocation of compiler). ++ ToolExecError, ++ /// Error occurred due to missing external tools. ++ ToolNotFound, ++} ++ ++/// Represents an internal error that occurred, with an explaination. ++#[derive(Clone, Debug)] ++pub struct Error { ++ /// Describes the kind of error that occurred. ++ kind: ErrorKind, ++ /// More explaination of error that occurred. ++ message: String, ++} ++ ++impl Error { ++ fn new(kind: ErrorKind, message: &str) -> Error { ++ Error { kind: kind, message: message.to_owned() } ++ } ++} ++ ++impl From for Error { ++ fn from(e: io::Error) -> Error { ++ Error::new(ErrorKind::IOError, &format!("{}", e)) ++ } ++} ++ ++/// Configuration used to represent an invocation of a C compiler. ++/// ++/// This can be used to figure out what compiler is in use, what the arguments ++/// to it are, and what the environment variables look like for the compiler. ++/// This can be used to further configure other build systems (e.g. forward ++/// along CC and/or CFLAGS) or the `to_command` method can be used to run the ++/// compiler itself. ++#[derive(Clone, Debug)] ++pub struct Tool { ++ path: PathBuf, ++ args: Vec, ++ 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, PartialEq)] ++enum ToolFamily { ++ /// Tool is GNU Compiler Collection-like. ++ Gnu, ++ /// Tool is Clang-like. It differs from the GCC in a sense that it accepts superset of flags ++ /// and its cross-compilation approach is different. ++ Clang, ++ /// Tool is the MSVC cl.exe. ++ Msvc, ++} ++ ++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", ++ } ++ } ++ ++ /// What the flags to enable all warnings ++ fn warnings_flags(&self) -> &'static [&'static str] { ++ static MSVC_FLAGS: &'static [&'static str] = &["/W4"]; ++ static GNU_CLANG_FLAGS: &'static [&'static str] = &["-Wall", "-Wextra"]; ++ ++ match *self { ++ ToolFamily::Msvc => &MSVC_FLAGS, ++ ToolFamily::Gnu | ++ ToolFamily::Clang => &GNU_CLANG_FLAGS, ++ } ++ } ++ ++ /// What the flag to turn warning into errors ++ fn warnings_to_errors_flag(&self) -> &'static str { ++ match *self { ++ ToolFamily::Msvc => "/WX", ++ ToolFamily::Gnu | ++ ToolFamily::Clang => "-Werror" ++ } ++ } ++} ++ ++impl Build { ++ /// Construct a new instance of a blank set of configuration. ++ /// ++ /// This builder is finished with the [`compile`] function. ++ /// ++ /// [`compile`]: struct.Build.html#method.compile ++ pub fn new() -> Build { ++ Build { ++ include_directories: Vec::new(), ++ definitions: Vec::new(), ++ objects: Vec::new(), ++ flags: Vec::new(), ++ flags_supported: Vec::new(), ++ files: Vec::new(), ++ shared_flag: None, ++ static_flag: None, ++ 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, ++ static_crt: None, ++ warnings: true, ++ warnings_into_errors: false, ++ } ++ } ++ ++ /// Add a directory to the `-I` or include path for headers ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// use std::path::Path; ++ /// ++ /// let library_path = Path::new("/path/to/library"); ++ /// ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .include(library_path) ++ /// .include("src") ++ /// .compile("foo"); ++ /// ``` ++ pub fn include>(&mut self, dir: P) -> &mut Build { ++ self.include_directories.push(dir.as_ref().to_path_buf()); ++ self ++ } ++ ++ /// Specify a `-D` variable with an optional value. ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .define("FOO", "BAR") ++ /// .define("BAZ", None) ++ /// .compile("foo"); ++ /// ``` ++ pub fn define<'a, V: Into>>(&mut self, var: &str, val: V) -> &mut Build { ++ self.definitions.push((var.to_string(), val.into().map(|s| s.to_string()))); ++ self ++ } ++ ++ /// Add an arbitrary object file to link in ++ pub fn object>(&mut self, obj: P) -> &mut Build { ++ self.objects.push(obj.as_ref().to_path_buf()); ++ self ++ } ++ ++ /// Add an arbitrary flag to the invocation of the compiler ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .flag("-ffunction-sections") ++ /// .compile("foo"); ++ /// ``` ++ pub fn flag(&mut self, flag: &str) -> &mut Build { ++ self.flags.push(flag.to_string()); ++ self ++ } ++ ++ fn ensure_check_file(&self) -> Result { ++ let out_dir = self.get_out_dir()?; ++ let src = if self.cpp { ++ out_dir.join("flag_check.cpp") ++ } else { ++ out_dir.join("flag_check.c") ++ }; ++ ++ if !src.exists() { ++ let mut f = fs::File::create(&src)?; ++ write!(f, "int main(void) {{ return 0; }}")?; ++ } ++ ++ Ok(src) ++ } ++ ++ fn is_flag_supported(&self, flag: &str) -> Result { ++ let out_dir = self.get_out_dir()?; ++ let src = self.ensure_check_file()?; ++ let obj = out_dir.join("flag_check"); ++ let target = self.get_target()?; ++ let mut cfg = Build::new(); ++ cfg.flag(flag) ++ .target(&target) ++ .opt_level(0) ++ .host(&target) ++ .debug(false) ++ .cpp(self.cpp); ++ let compiler = cfg.try_get_compiler()?; ++ let mut cmd = compiler.to_command(); ++ command_add_output_file(&mut cmd, &obj, target.contains("msvc"), false); ++ cmd.arg(&src); ++ ++ let output = cmd.output()?; ++ Ok(output.stderr.is_empty()) ++ } ++ ++ /// Add an arbitrary flag to the invocation of the compiler if it supports it ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .flag_if_supported("-Wlogical-op") // only supported by GCC ++ /// .flag_if_supported("-Wunreachable-code") // only supported by clang ++ /// .compile("foo"); ++ /// ``` ++ pub fn flag_if_supported(&mut self, flag: &str) -> &mut Build { ++ self.flags_supported.push(flag.to_string()); ++ self ++ } ++ ++ /// Set the `-shared` flag. ++ /// ++ /// When enabled, the compiler will produce a shared object which can ++ /// then be linked with other objects to form an executable. ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .shared_flag(true) ++ /// .compile("libfoo.so"); ++ /// ``` ++ ++ pub fn shared_flag(&mut self, shared_flag: bool) -> &mut Build { ++ self.shared_flag = Some(shared_flag); ++ self ++ } ++ ++ /// Set the `-static` flag. ++ /// ++ /// When enabled on systems that support dynamic linking, this prevents ++ /// linking with the shared libraries. ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .shared_flag(true) ++ /// .static_flag(true) ++ /// .compile("foo"); ++ /// ``` ++ pub fn static_flag(&mut self, static_flag: bool) -> &mut Build { ++ self.static_flag = Some(static_flag); ++ self ++ } ++ ++ /// Add a file which will be compiled ++ pub fn file>(&mut self, p: P) -> &mut Build { ++ self.files.push(p.as_ref().to_path_buf()); ++ self ++ } ++ ++ /// Add files which will be compiled ++ pub fn files

(&mut self, p: P) -> &mut Build ++ where P: IntoIterator, ++ P::Item: AsRef { ++ for file in p.into_iter() { ++ self.file(file); ++ } ++ self ++ } ++ ++ /// Set C++ support. ++ /// ++ /// The other `cpp_*` options will only become active if this is set to ++ /// `true`. ++ pub fn cpp(&mut self, cpp: bool) -> &mut Build { ++ self.cpp = cpp; ++ self ++ } ++ ++ /// Set warnings into errors flag. ++ /// ++ /// Disabled by default. ++ /// ++ /// Warning: turning warnings into errors only make sense ++ /// if you are a developer of the crate using cc-rs. ++ /// Some warnings only appear on some architecture or ++ /// specific version of the compiler. Any user of this crate, ++ /// or any other crate depending on it, could fail during ++ /// compile time. ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .warnings_into_errors(true) ++ /// .compile("libfoo.a"); ++ /// ``` ++ pub fn warnings_into_errors(&mut self, warnings_into_errors: bool) -> &mut Build { ++ self.warnings_into_errors = warnings_into_errors; ++ self ++ } ++ ++ /// Set warnings flags. ++ /// ++ /// Adds some flags: ++ /// - "/Wall" for MSVC. ++ /// - "-Wall", "-Wextra" for GNU and Clang. ++ /// ++ /// Enabled by default. ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .warnings(false) ++ /// .compile("libfoo.a"); ++ /// ``` ++ pub fn warnings(&mut self, warnings: bool) -> &mut Build { ++ self.warnings = warnings; ++ self ++ } ++ ++ /// Set the standard library to link against when compiling with C++ ++ /// support. ++ /// ++ /// The default value of this property depends on the current target: On ++ /// OS X `Some("c++")` is used, when compiling for a Visual Studio based ++ /// target `None` is used and for other targets `Some("stdc++")` is used. ++ /// ++ /// A value of `None` indicates that no automatic linking should happen, ++ /// otherwise cargo will link against the specified library. ++ /// ++ /// The given library name must not contain the `lib` prefix. ++ /// ++ /// Common values: ++ /// - `stdc++` for GNU ++ /// - `c++` for Clang ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .shared_flag(true) ++ /// .cpp_link_stdlib("stdc++") ++ /// .compile("libfoo.so"); ++ /// ``` ++ pub fn cpp_link_stdlib<'a, V: Into>>(&mut self, cpp_link_stdlib: V) -> &mut Build { ++ self.cpp_link_stdlib = Some(cpp_link_stdlib.into().map(|s| s.into())); ++ self ++ } ++ ++ /// Force the C++ compiler to use the specified standard library. ++ /// ++ /// Setting this option will automatically set `cpp_link_stdlib` to the same ++ /// value. ++ /// ++ /// The default value of this option is always `None`. ++ /// ++ /// This option has no effect when compiling for a Visual Studio based ++ /// target. ++ /// ++ /// This option sets the `-stdlib` flag, which is only supported by some ++ /// compilers (clang, icc) but not by others (gcc). The library will not ++ /// detect which compiler is used, as such it is the responsibility of the ++ /// caller to ensure that this option is only used in conjuction with a ++ /// compiler which supports the `-stdlib` flag. ++ /// ++ /// A value of `None` indicates that no specific C++ standard library should ++ /// be used, otherwise `-stdlib` is added to the compile invocation. ++ /// ++ /// The given library name must not contain the `lib` prefix. ++ /// ++ /// Common values: ++ /// - `stdc++` for GNU ++ /// - `c++` for Clang ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .cpp_set_stdlib("c++") ++ /// .compile("libfoo.a"); ++ /// ``` ++ pub fn cpp_set_stdlib<'a, V: Into>>(&mut self, cpp_set_stdlib: V) -> &mut Build { ++ let cpp_set_stdlib = cpp_set_stdlib.into(); ++ self.cpp_set_stdlib = cpp_set_stdlib.map(|s| s.into()); ++ self.cpp_link_stdlib(cpp_set_stdlib); ++ self ++ } ++ ++ /// Configures the target this configuration will be compiling for. ++ /// ++ /// This option is automatically scraped from the `TARGET` environment ++ /// variable by build scripts, so it's not required to call this function. ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .target("aarch64-linux-android") ++ /// .compile("foo"); ++ /// ``` ++ pub fn target(&mut self, target: &str) -> &mut Build { ++ self.target = Some(target.to_string()); ++ self ++ } ++ ++ /// Configures the host assumed by this configuration. ++ /// ++ /// This option is automatically scraped from the `HOST` environment ++ /// variable by build scripts, so it's not required to call this function. ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// cc::Build::new() ++ /// .file("src/foo.c") ++ /// .host("arm-linux-gnueabihf") ++ /// .compile("foo"); ++ /// ``` ++ pub fn host(&mut self, host: &str) -> &mut Build { ++ self.host = Some(host.to_string()); ++ self ++ } ++ ++ /// Configures the optimization level of the generated object files. ++ /// ++ /// This option is automatically scraped from the `OPT_LEVEL` environment ++ /// variable by build scripts, so it's not required to call this function. ++ pub fn opt_level(&mut self, opt_level: u32) -> &mut Build { ++ self.opt_level = Some(opt_level.to_string()); ++ self ++ } ++ ++ /// Configures the optimization level of the generated object files. ++ /// ++ /// This option is automatically scraped from the `OPT_LEVEL` environment ++ /// variable by build scripts, so it's not required to call this function. ++ pub fn opt_level_str(&mut self, opt_level: &str) -> &mut Build { ++ self.opt_level = Some(opt_level.to_string()); ++ self ++ } ++ ++ /// Configures whether the compiler will emit debug information when ++ /// generating object files. ++ /// ++ /// This option is automatically scraped from the `PROFILE` environment ++ /// variable by build scripts (only enabled when the profile is "debug"), so ++ /// it's not required to call this function. ++ pub fn debug(&mut self, debug: bool) -> &mut Build { ++ self.debug = Some(debug); ++ self ++ } ++ ++ /// Configures the output directory where all object files and static ++ /// libraries will be located. ++ /// ++ /// This option is automatically scraped from the `OUT_DIR` environment ++ /// variable by build scripts, so it's not required to call this function. ++ pub fn out_dir>(&mut self, out_dir: P) -> &mut Build { ++ self.out_dir = Some(out_dir.as_ref().to_owned()); ++ self ++ } ++ ++ /// Configures the compiler to be used to produce output. ++ /// ++ /// This option is automatically determined from the target platform or a ++ /// number of environment variables, so it's not required to call this ++ /// function. ++ pub fn compiler>(&mut self, compiler: P) -> &mut Build { ++ self.compiler = Some(compiler.as_ref().to_owned()); ++ self ++ } ++ ++ /// Configures the tool used to assemble archives. ++ /// ++ /// This option is automatically determined from the target platform or a ++ /// number of environment variables, so it's not required to call this ++ /// function. ++ pub fn archiver>(&mut self, archiver: P) -> &mut Build { ++ self.archiver = Some(archiver.as_ref().to_owned()); ++ self ++ } ++ /// Define whether metadata should be emitted for cargo allowing it to ++ /// automatically link the binary. Defaults to `true`. ++ /// ++ /// The emitted metadata is: ++ /// ++ /// - `rustc-link-lib=static=`*compiled lib* ++ /// - `rustc-link-search=native=`*target folder* ++ /// - When target is MSVC, the ATL-MFC libs are added via `rustc-link-search=native=` ++ /// - When C++ is enabled, the C++ stdlib is added via `rustc-link-lib` ++ /// ++ pub fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Build { ++ self.cargo_metadata = cargo_metadata; ++ self ++ } ++ ++ /// Configures whether the compiler will emit position independent code. ++ /// ++ /// This option defaults to `false` for `windows-gnu` targets and ++ /// to `true` for all other targets. ++ pub fn pic(&mut self, pic: bool) -> &mut Build { ++ self.pic = Some(pic); ++ self ++ } ++ ++ /// Configures whether the /MT flag or the /MD flag will be passed to msvc build tools. ++ /// ++ /// This option defaults to `false`, and affect only msvc targets. ++ pub fn static_crt(&mut self, static_crt: bool) -> &mut Build { ++ self.static_crt = Some(static_crt); ++ self ++ } ++ ++ #[doc(hidden)] ++ pub fn __set_env(&mut self, a: A, b: B) -> &mut Build ++ where A: AsRef, ++ B: AsRef ++ { ++ self.env.push((a.as_ref().to_owned(), b.as_ref().to_owned())); ++ self ++ } ++ ++ /// Run the compiler, generating the file `output` ++ /// ++ /// This will return a result instead of panicing; see compile() for the complete description. ++ pub fn try_compile(&self, output: &str) -> Result<(), Error> { ++ let (lib_name, gnu_lib_name) = if output.starts_with("lib") && output.ends_with(".a") { ++ (&output[3..output.len() - 2], output.to_owned()) ++ } else { ++ let mut gnu = String::with_capacity(5 + output.len()); ++ gnu.push_str("lib"); ++ gnu.push_str(&output); ++ gnu.push_str(".a"); ++ (output, gnu) ++ }; ++ let dst = self.get_out_dir()?; ++ ++ let mut objects = Vec::new(); ++ 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().ok_or_else(|| Error::new(ErrorKind::IOError, "Getting object file details failed."))?) ++ } else { ++ obj ++ }; ++ ++ match obj.parent() { ++ Some(s) => fs::create_dir_all(s)?, ++ None => return Err(Error::new(ErrorKind::IOError, "Getting object file details failed.")), ++ }; ++ ++ src_dst.push((file.to_path_buf(), obj.clone())); ++ objects.push(obj); ++ } ++ self.compile_objects(&src_dst)?; ++ self.assemble(lib_name, &dst.join(gnu_lib_name), &objects)?; ++ ++ if self.get_target()?.contains("msvc") { ++ let compiler = self.get_base_compiler()?; ++ let atlmfc_lib = compiler.env() ++ .iter() ++ .find(|&&(ref var, _)| var.as_os_str() == OsStr::new("LIB")) ++ .and_then(|&(_, ref lib_paths)| { ++ env::split_paths(lib_paths).find(|path| { ++ let sub = Path::new("atlmfc/lib"); ++ path.ends_with(sub) || path.parent().map_or(false, |p| p.ends_with(sub)) ++ }) ++ }); ++ ++ if let Some(atlmfc_lib) = atlmfc_lib { ++ self.print(&format!("cargo:rustc-link-search=native={}", atlmfc_lib.display())); ++ } ++ } ++ ++ self.print(&format!("cargo:rustc-link-lib=static={}", lib_name)); ++ self.print(&format!("cargo:rustc-link-search=native={}", dst.display())); ++ ++ // Add specific C++ libraries, if enabled. ++ if self.cpp { ++ if let Some(stdlib) = self.get_cpp_link_stdlib()? { ++ self.print(&format!("cargo:rustc-link-lib={}", stdlib)); ++ } ++ } ++ ++ Ok(()) ++ } ++ ++ /// Run the compiler, generating the file `output` ++ /// ++ /// The name `output` should be the name of the library. For backwards compatibility, ++ /// the `output` may start with `lib` and end with `.a`. The Rust compilier will create ++ /// the assembly with the lib prefix and .a extension. MSVC will create a file without prefix, ++ /// ending with `.lib`. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `output` is not formatted correctly or if one of the underlying ++ /// compiler commands fails. It can also panic if it fails reading file names ++ /// or creating directories. ++ pub fn compile(&self, output: &str) { ++ if let Err(e) = self.try_compile(output) { ++ fail(&e.message); ++ } ++ } ++ ++ #[cfg(feature = "parallel")] ++ fn compile_objects(&self, objs: &[(PathBuf, PathBuf)]) -> Result<(), Error> { ++ 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.num_threads(amt); ++ } ++ } ++ drop(rayon::initialize(cfg)); ++ ++ let results: Mutex>> = Mutex::new(Vec::new()); ++ ++ objs.par_iter().with_max_len(1) ++ .for_each(|&(ref src, ref dst)| results.lock().unwrap().push(self.compile_object(src, dst))); ++ ++ // Check for any errors and return the first one found. ++ for result in results.into_inner().unwrap().iter() { ++ if result.is_err() { ++ return result.clone(); ++ } ++ } ++ ++ Ok(()) ++ } ++ ++ #[cfg(not(feature = "parallel"))] ++ fn compile_objects(&self, objs: &[(PathBuf, PathBuf)]) -> Result<(), Error> { ++ for &(ref src, ref dst) in objs { ++ self.compile_object(src, dst)?; ++ } ++ Ok(()) ++ } ++ ++ fn compile_object(&self, file: &Path, dst: &Path) -> Result<(), Error> { ++ 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.try_get_compiler()?; ++ let mut cmd = compiler.to_command(); ++ for &(ref a, ref b) in self.env.iter() { ++ cmd.env(a, b); ++ } ++ (cmd, ++ compiler.path ++ .file_name() ++ .ok_or_else(|| Error::new(ErrorKind::IOError, "Failed to get compiler path."))? ++ .to_string_lossy() ++ .into_owned()) ++ }; ++ command_add_output_file(&mut cmd, dst, msvc, is_asm); ++ cmd.arg(if msvc { "/c" } else { "-c" }); ++ cmd.arg(file); ++ ++ run(&mut cmd, &name)?; ++ Ok(()) ++ } ++ ++ /// This will return a result instead of panicing; see expand() for the complete description. ++ pub fn try_expand(&self) -> Result, Error> { ++ let compiler = self.try_get_compiler()?; ++ let mut cmd = compiler.to_command(); ++ for &(ref a, ref b) in self.env.iter() { ++ cmd.env(a, b); ++ } ++ cmd.arg(compiler.family.expand_flag()); ++ ++ assert!(self.files.len() <= 1, ++ "Expand may only be called for a single file"); ++ ++ for file in self.files.iter() { ++ cmd.arg(file); ++ } ++ ++ let name = compiler.path ++ .file_name() ++ .ok_or_else(|| Error::new(ErrorKind::IOError, "Failed to get compiler path."))? ++ .to_string_lossy() ++ .into_owned(); ++ ++ Ok(run_output(&mut cmd, &name)?) ++ } ++ ++ /// Run the compiler, returning the macro-expanded version of the input files. ++ /// ++ /// This is only relevant for C and C++ files. ++ /// ++ /// # Panics ++ /// Panics if more than one file is present in the config, or if compiler ++ /// path has an invalid file name. ++ /// ++ /// # Example ++ /// ```no_run ++ /// let out = cc::Build::new().file("src/foo.c").expand(); ++ /// ``` ++ pub fn expand(&self) -> Vec { ++ match self.try_expand() { ++ Err(e) => fail(&e.message), ++ Ok(v) => v, ++ } ++ } ++ ++ /// Get the compiler that's in use for this configuration. ++ /// ++ /// This function will return a `Tool` which represents the culmination ++ /// of this configuration at a snapshot in time. The returned compiler can ++ /// be inspected (e.g. the path, arguments, environment) to forward along to ++ /// other tools, or the `to_command` method can be used to invoke the ++ /// compiler itself. ++ /// ++ /// This method will take into account all configuration such as debug ++ /// information, optimization level, include directories, defines, etc. ++ /// Additionally, the compiler binary in use follows the standard ++ /// conventions for this path, e.g. looking at the explicitly set compiler, ++ /// environment variables (a number of which are inspected here), and then ++ /// falling back to the default configuration. ++ /// ++ /// # Panics ++ /// ++ /// Panics if an error occurred while determining the architecture. ++ pub fn get_compiler(&self) -> Tool { ++ match self.try_get_compiler() { ++ Ok(tool) => tool, ++ Err(e) => fail(&e.message), ++ } ++ } ++ ++ /// Get the compiler that's in use for this configuration. ++ /// ++ /// This will return a result instead of panicing; see get_compiler() for the complete description. ++ pub fn try_get_compiler(&self) -> Result { ++ 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 crt_flag = match self.static_crt { ++ Some(true) => "/MT", ++ Some(false) => "/MD", ++ None => { ++ let features = env::var("CARGO_CFG_TARGET_FEATURE") ++ .unwrap_or(String::new()); ++ if features.contains("crt-static") { ++ "/MT" ++ } else { ++ "/MD" ++ } ++ }, ++ }; ++ cmd.args.push(crt_flag.into()); ++ ++ match &opt_level[..] { ++ "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 => { ++ // arm-linux-androideabi-gcc 4.8 shipped with Android NDK does ++ // not support '-Oz' ++ if opt_level == "z" && cmd.family != ToolFamily::Clang { ++ cmd.args.push("-Os".into()); ++ } else { ++ 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 self.static_flag.is_none() && target.contains("musl") { ++ cmd.args.push("-static".into()); ++ } ++ ++ // armv7 targets get to use armv7 instructions ++ if target.starts_with("armv7-") && target.contains("-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()); ++ cmd.args.push("-mfloat-abi=softfp".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()); ++ } ++ ++ // We can guarantee some settings for FRC ++ if target.starts_with("arm-frc-") { ++ cmd.args.push("-march=armv7-a".into()); ++ cmd.args.push("-mcpu=cortex-a9".into()); ++ cmd.args.push("-mfpu=vfpv3".into()); ++ cmd.args.push("-mfloat-abi=softfp".into()); ++ cmd.args.push("-marm".into()); ++ } ++ ++ // Turn codegen down on i586 to avoid some instructions. ++ if target.starts_with("i586-unknown-linux-") { ++ cmd.args.push("-march=pentium".into()); ++ } ++ ++ // Set codegen level for i686 correctly ++ if target.starts_with("i686-unknown-linux-") { ++ cmd.args.push("-march=i686".into()); ++ } ++ ++ // Looks like `musl-gcc` makes is hard for `-m32` to make its way ++ // all the way to the linker, so we need to actually instruct the ++ // linker that we're generating 32-bit executables as well. This'll ++ // typically only be used for build scripts which transitively use ++ // these flags that try to compile executables. ++ if target == "i686-unknown-linux-musl" { ++ 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.static_flag.unwrap_or(false) { ++ cmd.args.push("-static".into()); ++ } ++ if self.shared_flag.unwrap_or(false) { ++ cmd.args.push("-shared".into()); ++ } ++ ++ if self.cpp { ++ match (self.cpp_set_stdlib.as_ref(), cmd.family) { ++ (None, _) => { } ++ (Some(stdlib), ToolFamily::Gnu) | ++ (Some(stdlib), ToolFamily::Clang) => { ++ cmd.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 flag in self.flags_supported.iter() { ++ if self.is_flag_supported(flag).unwrap_or(false) { ++ 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()); ++ } ++ } ++ ++ if self.warnings { ++ for flag in cmd.family.warnings_flags().iter() { ++ cmd.args.push(flag.into()); ++ } ++ } ++ ++ if self.warnings_into_errors { ++ cmd.args.push(cmd.family.warnings_to_errors_flag().into()); ++ } ++ ++ Ok(cmd) ++ } ++ ++ fn msvc_macro_assembler(&self) -> Result<(Command, String), Error> { ++ 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); ++ } ++ ++ Ok((cmd, tool.to_string())) ++ } ++ ++ fn assemble(&self, lib_name: &str, dst: &Path, objects: &[PathBuf]) -> Result<(), Error> { ++ // Delete the destination if it exists as the `ar` tool at least on Unix ++ // appends to it, which we don't want. ++ let _ = fs::remove_file(&dst); ++ ++ let 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_else(|| 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); ++ match fs::hard_link(&dst, &lib_dst) ++ .or_else(|_| { ++ // if hard-link fails, just copy (ignoring the number of bytes written) ++ fs::copy(&dst, &lib_dst).map(|_| ()) ++ }) { ++ Ok(_) => (), ++ Err(_) => return Err(Error::new(ErrorKind::IOError, "Could not copy or create a hard-link to the generated lib file.")), ++ }; ++ } else { ++ let ar = self.get_ar()?; ++ let cmd = ar.file_name() ++ .ok_or_else(|| Error::new(ErrorKind::IOError, "Failed to get archiver (ar) path."))? ++ .to_string_lossy(); ++ run(self.cmd(&ar) ++ .arg("crs") ++ .arg(dst) ++ .args(objects) ++ .args(&self.objects), ++ &cmd)?; ++ } ++ ++ Ok(()) ++ } ++ ++ fn ios_flags(&self, cmd: &mut Tool) -> Result<(), Error> { ++ enum ArchSpec { ++ Device(&'static str), ++ Simulator(&'static str), ++ } ++ ++ let target = self.get_target()?; ++ let arch = target.split('-').nth(0).ok_or_else(|| Error::new(ErrorKind::ArchitectureInvalid, "Unknown architecture for iOS target."))?; ++ let arch = match arch { ++ "arm" | "armv7" | "thumbv7" => ArchSpec::Device("armv7"), ++ "armv7s" | "thumbv7s" => ArchSpec::Device("armv7s"), ++ "arm64" | "aarch64" => ArchSpec::Device("arm64"), ++ "i386" | "i686" => ArchSpec::Simulator("-m32"), ++ "x86_64" => ArchSpec::Simulator("-m64"), ++ _ => return Err(Error::new(ErrorKind::ArchitectureInvalid, "Unknown architecture for iOS target.")), ++ }; ++ ++ let sdk = match arch { ++ ArchSpec::Device(arch) => { ++ cmd.args.push("-arch".into()); ++ cmd.args.push(arch.into()); ++ cmd.args.push("-miphoneos-version-min=7.0".into()); ++ "iphoneos" ++ } ++ ArchSpec::Simulator(arch) => { ++ cmd.args.push(arch.into()); ++ cmd.args.push("-mios-simulator-version-min=7.0".into()); ++ "iphonesimulator" ++ } ++ }; ++ ++ self.print(&format!("Detecting iOS SDK path for {}", sdk)); ++ let sdk_path = self.cmd("xcrun") ++ .arg("--show-sdk-path") ++ .arg("--sdk") ++ .arg(sdk) ++ .stderr(Stdio::inherit()) ++ .output()? ++ .stdout; ++ ++ let sdk_path = match String::from_utf8(sdk_path) { ++ Ok(p) => p, ++ Err(_) => return Err(Error::new(ErrorKind::IOError, "Unable to determine iOS SDK path.")), ++ }; ++ ++ cmd.args.push("-isysroot".into()); ++ cmd.args.push(sdk_path.trim().into()); ++ ++ Ok(()) ++ } ++ ++ fn cmd>(&self, prog: P) -> Command { ++ let mut cmd = Command::new(prog); ++ for &(ref a, ref b) in self.env.iter() { ++ cmd.env(a, b); ++ } ++ cmd ++ } ++ ++ fn get_base_compiler(&self) -> Result { ++ if let Some(ref c) = self.compiler { ++ return Ok(Tool::new(c.clone())); ++ } ++ let host = self.get_host()?; ++ let target = self.get_target()?; ++ let (env, msvc, gnu) = if self.cpp { ++ ("CXX", "cl.exe", "g++") ++ } else { ++ ("CC", "cl.exe", "gcc") ++ }; ++ ++ let default = if host.contains("solaris") { ++ // In this case, c++/cc unlikely to exist or be correct. ++ gnu ++ } else if self.cpp { ++ "c++" ++ } else { ++ "cc" ++ }; ++ ++ let tool_opt: Option = self.env_tool(env) ++ .map(|(tool, args)| { ++ let mut t = Tool::new(PathBuf::from(tool)); ++ for arg in args { ++ t.args.push(arg.into()); ++ } ++ t ++ }) ++ .or_else(|| { ++ if target.contains("emscripten") { ++ let tool = if self.cpp { ++ "em++" ++ } else { ++ "emcc" ++ }; ++ // Windows uses bat file so we have to be a bit more specific ++ if cfg!(windows) { ++ let mut t = Tool::new(PathBuf::from("cmd")); ++ t.args.push("/c".into()); ++ t.args.push(format!("{}.bat", tool).into()); ++ Some(t) ++ } else { ++ Some(Tool::new(PathBuf::from(tool))) ++ } ++ } else { ++ None ++ } ++ }) ++ .or_else(|| windows_registry::find_tool(&target, "cl.exe")); ++ ++ let tool = match tool_opt { ++ Some(t) => t, ++ None => { ++ let compiler = if host.contains("windows") && target.contains("windows") { ++ if target.contains("msvc") { ++ msvc.to_string() ++ } else { ++ format!("{}.exe", gnu) ++ } ++ } else if target.contains("android") { ++ 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-frc-linux-gnueabi" => Some("arm-frc-linux-gnueabi"), ++ "arm-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), ++ "arm-unknown-linux-musleabi" => Some("arm-linux-musleabi"), ++ "arm-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), ++ "arm-unknown-netbsd-eabi" => Some("arm--netbsdelf-eabi"), ++ "armv6-unknown-netbsd-eabihf" => Some("armv6--netbsdelf-eabihf"), ++ "armv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), ++ "armv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), ++ "armv7-unknown-netbsd-eabihf" => Some("armv7--netbsdelf-eabihf"), ++ "i686-pc-windows-gnu" => Some("i686-w64-mingw32"), ++ "i686-unknown-linux-musl" => Some("musl"), ++ "i686-unknown-netbsd" => Some("i486--netbsdelf"), ++ "mips-unknown-linux-gnu" => Some("mips-linux-gnu"), ++ "mipsel-unknown-linux-gnu" => Some("mipsel-linux-gnu"), ++ "mips64-unknown-linux-gnuabi64" => Some("mips64-linux-gnuabi64"), ++ "mips64el-unknown-linux-gnuabi64" => Some("mips64el-linux-gnuabi64"), ++ "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"), ++ "sparcv9-sun-solaris" => Some("sparcv9-sun-solaris"), ++ "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)) ++ } ++ }; ++ ++ Ok(tool) ++ } ++ ++ fn get_var(&self, var_base: &str) -> Result { ++ let target = self.get_target()?; ++ let host = self.get_host()?; ++ let kind = if host == target { "HOST" } else { "TARGET" }; ++ let target_u = target.replace("-", "_"); ++ let res = self.getenv(&format!("{}_{}", var_base, target)) ++ .or_else(|| self.getenv(&format!("{}_{}", var_base, target_u))) ++ .or_else(|| self.getenv(&format!("{}_{}", kind, var_base))) ++ .or_else(|| self.getenv(var_base)); ++ ++ match res { ++ Some(res) => Ok(res), ++ None => Err(Error::new(ErrorKind::EnvVarNotFound, &format!("Could not find environment variable {}.", var_base))), ++ } ++ } ++ ++ fn envflags(&self, name: &str) -> Vec { ++ 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)> { ++ self.get_var(name).ok().map(|tool| { ++ let whitelist = ["ccache", "distcc", "sccache"]; ++ 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) -> Result, Error> { ++ match self.cpp_link_stdlib.clone() { ++ Some(s) => Ok(s), ++ None => { ++ let target = self.get_target()?; ++ if target.contains("msvc") { ++ Ok(None) ++ } else if target.contains("darwin") { ++ Ok(Some("c++".to_string())) ++ } else if target.contains("freebsd") { ++ Ok(Some("c++".to_string())) ++ } else { ++ Ok(Some("stdc++".to_string())) ++ } ++ }, ++ } ++ } ++ ++ fn get_ar(&self) -> Result { ++ match self.archiver ++ .clone() ++ .or_else(|| self.get_var("AR").map(PathBuf::from).ok()) { ++ Some(p) => Ok(p), ++ None => { ++ if self.get_target()?.contains("android") { ++ Ok(PathBuf::from(format!("{}-ar", self.get_target()?.replace("armv7", "arm")))) ++ } else if self.get_target()?.contains("emscripten") { ++ //Windows use bat files so we have to be a bit more specific ++ let tool = if cfg!(windows) { ++ "emar.bat" ++ } else { ++ "emar" ++ }; ++ ++ Ok(PathBuf::from(tool)) ++ } else { ++ Ok(PathBuf::from("ar")) ++ } ++ } ++ } ++ } ++ ++ fn get_target(&self) -> Result { ++ match self.target.clone() { ++ Some(t) => Ok(t), ++ None => Ok(self.getenv_unwrap("TARGET")?), ++ } ++ } ++ ++ fn get_host(&self) -> Result { ++ match self.host.clone() { ++ Some(h) => Ok(h), ++ None => Ok(self.getenv_unwrap("HOST")?), ++ } ++ } ++ ++ fn get_opt_level(&self) -> Result { ++ match self.opt_level.as_ref().cloned() { ++ Some(ol) => Ok(ol), ++ None => Ok(self.getenv_unwrap("OPT_LEVEL")?), ++ } ++ } ++ ++ fn get_debug(&self) -> bool { ++ self.debug.unwrap_or_else(|| { ++ match self.getenv("DEBUG") { ++ Some(s) => s != "false", ++ None => false, ++ } ++ }) ++ } ++ ++ fn get_out_dir(&self) -> Result { ++ match self.out_dir.clone() { ++ Some(p) => Ok(p), ++ None => Ok(env::var_os("OUT_DIR") ++ .map(PathBuf::from) ++ .ok_or_else(|| Error::new(ErrorKind::EnvVarNotFound, "Environment variable OUT_DIR not defined."))?), ++ } ++ } ++ ++ fn getenv(&self, v: &str) -> Option { ++ let r = env::var(v).ok(); ++ self.print(&format!("{} = {:?}", v, r)); ++ r ++ } ++ ++ fn getenv_unwrap(&self, v: &str) -> Result { ++ match self.getenv(v) { ++ Some(s) => Ok(s), ++ None => Err(Error::new(ErrorKind::EnvVarNotFound, &format!("Environment variable {} not defined.", v.to_string()))), ++ } ++ } ++ ++ fn print(&self, s: &str) { ++ if self.cargo_metadata { ++ println!("{}", s); ++ } ++ } ++} ++ ++impl Default for Build { ++ fn default() -> Build { ++ Build::new() ++ } ++} ++ ++impl Tool { ++ fn new(path: PathBuf) -> Tool { ++ // 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") && !fname.contains("uclibc") { ++ 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) -> Result<(), Error> { ++ let (mut child, print) = spawn(cmd, program)?; ++ let status = match child.wait() { ++ Ok(s) => s, ++ Err(_) => return Err(Error::new(ErrorKind::ToolExecError, &format!("Failed to wait on spawned child process, command {:?} with args {:?}.", cmd, program))), ++ }; ++ print.join().unwrap(); ++ println!("{}", status); ++ ++ if status.success() { ++ Ok(()) ++ } else { ++ Err(Error::new(ErrorKind::ToolExecError, &format!("Command {:?} with args {:?} did not execute successfully (status code {}).", cmd, program, status))) ++ } ++} ++ ++fn run_output(cmd: &mut Command, program: &str) -> Result, Error> { ++ cmd.stdout(Stdio::piped()); ++ let (mut child, print) = spawn(cmd, program)?; ++ let mut stdout = vec![]; ++ child.stdout.take().unwrap().read_to_end(&mut stdout).unwrap(); ++ let status = match child.wait() { ++ Ok(s) => s, ++ Err(_) => return Err(Error::new(ErrorKind::ToolExecError, &format!("Failed to wait on spawned child process, command {:?} with args {:?}.", cmd, program))), ++ }; ++ print.join().unwrap(); ++ println!("{}", status); ++ ++ if status.success() { ++ Ok(stdout) ++ } else { ++ Err(Error::new(ErrorKind::ToolExecError, &format!("Command {:?} with args {:?} did not execute successfully (status code {}).", cmd, program, status))) ++ } ++} ++ ++fn spawn(cmd: &mut Command, program: &str) -> Result<(Child, JoinHandle<()>), Error> { ++ println!("running: {:?}", cmd); ++ ++ // Capture the standard error coming from these programs, and write it out ++ // with cargo:warning= prefixes. Note that this is a bit wonky to avoid ++ // requiring the output to be UTF-8, we instead just ship bytes from one ++ // location to another. ++ match cmd.stderr(Stdio::piped()).spawn() { ++ Ok(mut child) => { ++ let stderr = BufReader::new(child.stderr.take().unwrap()); ++ let print = thread::spawn(move || { ++ for line in stderr.split(b'\n').filter_map(|l| l.ok()) { ++ print!("cargo:warning="); ++ std::io::stdout().write_all(&line).unwrap(); ++ println!(""); ++ } ++ }); ++ Ok((child, print)) ++ } ++ Err(ref e) if e.kind() == io::ErrorKind::NotFound => { ++ let extra = if cfg!(windows) { ++ " (see https://github.com/alexcrichton/cc-rs#compile-time-requirements \ ++ for help)" ++ } else { ++ "" ++ }; ++ Err(Error::new(ErrorKind::ToolNotFound, &format!("Failed to find tool. Is `{}` installed?{}", program, extra))) ++ } ++ Err(_) => Err(Error::new(ErrorKind::ToolExecError, &format!("Command {:?} with args {:?} failed to start.", cmd, program))), ++ } ++} ++ ++fn fail(s: &str) -> ! { ++ panic!("\n\nInternal error occurred: {}\n\n", s) ++} ++ ++ ++fn command_add_output_file(cmd: &mut Command, dst: &Path, msvc: bool, is_asm: bool) { ++ if msvc && is_asm { ++ cmd.arg("/Fo").arg(dst); ++ } else if msvc { ++ let mut s = OsString::from("/Fo"); ++ s.push(&dst); ++ cmd.arg(s); ++ } else { ++ cmd.arg("-o").arg(&dst); ++ } ++} diff --cc vendor/cc-1.0.0/src/registry.rs index 000000000,000000000..a45272344 new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/src/registry.rs @@@ -1,0 -1,0 +1,190 @@@ ++// 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 or the MIT license ++// , 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, ++ 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 { ++ let key = key.encode_wide().chain(Some(0)).collect::>(); ++ 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 { ++ let name: &OsStr = name.as_ref(); ++ let name = name.encode_wide().chain(Some(0)).collect::>(); ++ 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; ++ ++ fn next(&mut self) -> Option> { ++ 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 --cc vendor/cc-1.0.0/src/setup_config.rs index 000000000,000000000..175b7f157 new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/src/setup_config.rs @@@ -1,0 -1,0 +1,257 @@@ ++// Copyright © 2017 winapi-rs developers ++// Licensed under the Apache License, Version 2.0 ++// or the MIT license ++// , at your option. ++// All files in the project carrying such notice may not be copied, modified, or distributed ++// except according to those terms. ++ ++#![allow(bad_style)] ++#![allow(unused)] ++ ++use std::ffi::OsString; ++use std::ptr::null_mut; ++use winapi::Interface; ++use winapi::{LPFILETIME, ULONG}; ++use winapi::S_FALSE; ++use winapi::BSTR; ++use winapi::LPCOLESTR; ++use winapi::{CLSCTX_ALL, CoCreateInstance}; ++use winapi::LPSAFEARRAY; ++use winapi::{IUnknown, IUnknownVtbl}; ++use winapi::{HRESULT, LCID, LPCWSTR, PULONGLONG}; ++ ++use com::{BStr, ComPtr}; ++ ++// Bindings to the Setup.Configuration stuff ++pub type InstanceState = u32; ++ ++pub const eNone: InstanceState = 0; ++pub const eLocal: InstanceState = 1; ++pub const eRegistered: InstanceState = 2; ++pub const eNoRebootRequired: InstanceState = 4; ++pub const eComplete: InstanceState = -1i32 as u32; ++ ++RIDL!{#[uuid(0xb41463c3, 0x8866, 0x43b5, 0xbc, 0x33, 0x2b, 0x06, 0x76, 0xf7, 0xf4, 0x2e)] ++interface ISetupInstance(ISetupInstanceVtbl): IUnknown(IUnknownVtbl) { ++ fn GetInstanceId( ++ pbstrInstanceId: *mut BSTR, ++ ) -> HRESULT, ++ fn GetInstallDate( ++ pInstallDate: LPFILETIME, ++ ) -> HRESULT, ++ fn GetInstallationName( ++ pbstrInstallationName: *mut BSTR, ++ ) -> HRESULT, ++ fn GetInstallationPath( ++ pbstrInstallationPath: *mut BSTR, ++ ) -> HRESULT, ++ fn GetInstallationVersion( ++ pbstrInstallationVersion: *mut BSTR, ++ ) -> HRESULT, ++ fn GetDisplayName( ++ lcid: LCID, ++ pbstrDisplayName: *mut BSTR, ++ ) -> HRESULT, ++ fn GetDescription( ++ lcid: LCID, ++ pbstrDescription: *mut BSTR, ++ ) -> HRESULT, ++ fn ResolvePath( ++ pwszRelativePath: LPCOLESTR, ++ pbstrAbsolutePath: *mut BSTR, ++ ) -> HRESULT, ++}} ++ ++RIDL!{#[uuid(0x89143c9a, 0x05af, 0x49b0, 0xb7, 0x17, 0x72, 0xe2, 0x18, 0xa2, 0x18, 0x5c)] ++interface ISetupInstance2(ISetupInstance2Vtbl): ISetupInstance(ISetupInstanceVtbl) { ++ fn GetState( ++ pState: *mut InstanceState, ++ ) -> HRESULT, ++ fn GetPackages( ++ ppsaPackages: *mut LPSAFEARRAY, ++ ) -> HRESULT, ++ fn GetProduct( ++ ppPackage: *mut *mut ISetupPackageReference, ++ ) -> HRESULT, ++ fn GetProductPath( ++ pbstrProductPath: *mut BSTR, ++ ) -> HRESULT, ++}} ++ ++RIDL!{#[uuid(0x6380bcff, 0x41d3, 0x4b2e, 0x8b, 0x2e, 0xbf, 0x8a, 0x68, 0x10, 0xc8, 0x48)] ++interface IEnumSetupInstances(IEnumSetupInstancesVtbl): IUnknown(IUnknownVtbl) { ++ fn Next( ++ celt: ULONG, ++ rgelt: *mut *mut ISetupInstance, ++ pceltFetched: *mut ULONG, ++ ) -> HRESULT, ++ fn Skip( ++ celt: ULONG, ++ ) -> HRESULT, ++ fn Reset() -> HRESULT, ++ fn Clone( ++ ppenum: *mut *mut IEnumSetupInstances, ++ ) -> HRESULT, ++}} ++ ++RIDL!{#[uuid(0x42843719, 0xdb4c, 0x46c2, 0x8e, 0x7c, 0x64, 0xf1, 0x81, 0x6e, 0xfd, 0x5b)] ++interface ISetupConfiguration(ISetupConfigurationVtbl): IUnknown(IUnknownVtbl) { ++ fn EnumInstances( ++ ppEnumInstances: *mut *mut IEnumSetupInstances, ++ ) -> HRESULT, ++ fn GetInstanceForCurrentProcess( ++ ppInstance: *mut *mut ISetupInstance, ++ ) -> HRESULT, ++ fn GetInstanceForPath( ++ wzPath: LPCWSTR, ++ ppInstance: *mut *mut ISetupInstance, ++ ) -> HRESULT, ++}} ++ ++RIDL!{#[uuid(0x26aab78c, 0x4a60, 0x49d6, 0xaf, 0x3b, 0x3c, 0x35, 0xbc, 0x93, 0x36, 0x5d)] ++interface ISetupConfiguration2(ISetupConfiguration2Vtbl): ++ ISetupConfiguration(ISetupConfigurationVtbl) { ++ fn EnumAllInstances( ++ ppEnumInstances: *mut *mut IEnumSetupInstances, ++ ) -> HRESULT, ++}} ++ ++RIDL!{#[uuid(0xda8d8a16, 0xb2b6, 0x4487, 0xa2, 0xf1, 0x59, 0x4c, 0xcc, 0xcd, 0x6b, 0xf5)] ++interface ISetupPackageReference(ISetupPackageReferenceVtbl): IUnknown(IUnknownVtbl) { ++ fn GetId( ++ pbstrId: *mut BSTR, ++ ) -> HRESULT, ++ fn GetVersion( ++ pbstrVersion: *mut BSTR, ++ ) -> HRESULT, ++ fn GetChip( ++ pbstrChip: *mut BSTR, ++ ) -> HRESULT, ++ fn GetLanguage( ++ pbstrLanguage: *mut BSTR, ++ ) -> HRESULT, ++ fn GetBranch( ++ pbstrBranch: *mut BSTR, ++ ) -> HRESULT, ++ fn GetType( ++ pbstrType: *mut BSTR, ++ ) -> HRESULT, ++ fn GetUniqueId( ++ pbstrUniqueId: *mut BSTR, ++ ) -> HRESULT, ++}} ++ ++RIDL!{#[uuid(0x42b21b78, 0x6192, 0x463e, 0x87, 0xbf, 0xd5, 0x77, 0x83, 0x8f, 0x1d, 0x5c)] ++interface ISetupHelper(ISetupHelperVtbl): IUnknown(IUnknownVtbl) { ++ fn ParseVersion( ++ pwszVersion: LPCOLESTR, ++ pullVersion: PULONGLONG, ++ ) -> HRESULT, ++ fn ParseVersionRange( ++ pwszVersionRange: LPCOLESTR, ++ pullMinVersion: PULONGLONG, ++ pullMaxVersion: PULONGLONG, ++ ) -> HRESULT, ++}} ++ ++DEFINE_GUID!{CLSID_SetupConfiguration, ++ 0x177f0c4a, 0x1cd3, 0x4de7, 0xa3, 0x2c, 0x71, 0xdb, 0xbb, 0x9f, 0xa3, 0x6d} ++ ++// Safe wrapper around the COM interfaces ++pub struct SetupConfiguration(ComPtr); ++ ++impl SetupConfiguration { ++ pub fn new() -> Result { ++ let mut obj = null_mut(); ++ let err = unsafe { CoCreateInstance( ++ &CLSID_SetupConfiguration, null_mut(), CLSCTX_ALL, ++ &ISetupConfiguration::uuidof(), &mut obj, ++ ) }; ++ if err < 0 { return Err(err); } ++ let obj = unsafe { ComPtr::from_raw(obj as *mut ISetupConfiguration) }; ++ Ok(SetupConfiguration(obj)) ++ } ++ pub fn get_instance_for_current_process(&self) -> Result { ++ let mut obj = null_mut(); ++ let err = unsafe { self.0.GetInstanceForCurrentProcess(&mut obj) }; ++ if err < 0 { return Err(err); } ++ Ok(unsafe { SetupInstance::from_raw(obj) }) ++ } ++ pub fn enum_instances(&self) -> Result { ++ let mut obj = null_mut(); ++ let err = unsafe { self.0.EnumInstances(&mut obj) }; ++ if err < 0 { return Err(err); } ++ Ok(unsafe { EnumSetupInstances::from_raw(obj) }) ++ } ++ pub fn enum_all_instances(&self) -> Result { ++ let mut obj = null_mut(); ++ let this = try!(self.0.cast::()); ++ let err = unsafe { this.EnumAllInstances(&mut obj) }; ++ if err < 0 { return Err(err); } ++ Ok(unsafe { EnumSetupInstances::from_raw(obj) }) ++ } ++} ++ ++pub struct SetupInstance(ComPtr); ++ ++impl SetupInstance { ++ pub unsafe fn from_raw(obj: *mut ISetupInstance) -> SetupInstance { ++ SetupInstance(ComPtr::from_raw(obj)) ++ } ++ pub fn instance_id(&self) -> Result { ++ let mut s = null_mut(); ++ let err = unsafe { self.0.GetInstanceId(&mut s) }; ++ let bstr = unsafe { BStr::from_raw(s) }; ++ if err < 0 { return Err(err); } ++ Ok(bstr.to_osstring()) ++ } ++ pub fn installation_name(&self) -> Result { ++ let mut s = null_mut(); ++ let err = unsafe { self.0.GetInstallationName(&mut s) }; ++ let bstr = unsafe { BStr::from_raw(s) }; ++ if err < 0 { return Err(err); } ++ Ok(bstr.to_osstring()) ++ } ++ pub fn installation_path(&self) -> Result { ++ let mut s = null_mut(); ++ let err = unsafe { self.0.GetInstallationPath(&mut s) }; ++ let bstr = unsafe { BStr::from_raw(s) }; ++ if err < 0 { return Err(err); } ++ Ok(bstr.to_osstring()) ++ } ++ pub fn installation_version(&self) -> Result { ++ let mut s = null_mut(); ++ let err = unsafe { self.0.GetInstallationVersion(&mut s) }; ++ let bstr = unsafe { BStr::from_raw(s) }; ++ if err < 0 { return Err(err); } ++ Ok(bstr.to_osstring()) ++ } ++ pub fn product_path(&self) -> Result { ++ let mut s = null_mut(); ++ let this = try!(self.0.cast::()); ++ let err = unsafe { this.GetProductPath(&mut s) }; ++ let bstr = unsafe { BStr::from_raw(s) }; ++ if err < 0 { return Err(err); } ++ Ok(bstr.to_osstring()) ++ } ++} ++ ++pub struct EnumSetupInstances(ComPtr); ++ ++impl EnumSetupInstances { ++ pub unsafe fn from_raw(obj: *mut IEnumSetupInstances) -> EnumSetupInstances { ++ EnumSetupInstances(ComPtr::from_raw(obj)) ++ } ++} ++ ++impl Iterator for EnumSetupInstances { ++ type Item = Result; ++ fn next(&mut self) -> Option> { ++ let mut obj = null_mut(); ++ let err = unsafe { self.0.Next(1, &mut obj, null_mut()) }; ++ if err < 0 { return Some(Err(err)); } ++ if err == S_FALSE { return None; } ++ Some(Ok(unsafe { SetupInstance::from_raw(obj) })) ++ } ++} ++ diff --cc vendor/cc-1.0.0/src/winapi.rs index 000000000,000000000..3fb04087f new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/src/winapi.rs @@@ -1,0 -1,0 +1,214 @@@ ++// Copyright © 2015-2017 winapi-rs developers ++// Licensed under the Apache License, Version 2.0 ++// or the MIT license ++// , at your option. ++// All files in the project carrying such notice may not be copied, modified, or distributed ++// except according to those terms. ++ ++#![allow(bad_style)] ++ ++use std::os::raw; ++ ++pub type wchar_t = u16; ++ ++pub type UINT = raw::c_uint; ++pub type LPUNKNOWN = *mut IUnknown; ++pub type REFIID = *const IID; ++pub type IID = GUID; ++pub type REFCLSID = *const IID; ++pub type PVOID = *mut raw::c_void; ++pub type USHORT = raw::c_ushort; ++pub type ULONG = raw::c_ulong; ++pub type LONG = raw::c_long; ++pub type DWORD = u32; ++pub type LPVOID = *mut raw::c_void; ++pub type HRESULT = raw::c_long; ++pub type LPFILETIME = *mut FILETIME; ++pub type BSTR = *mut OLECHAR; ++pub type OLECHAR = WCHAR; ++pub type WCHAR = wchar_t; ++pub type LPCOLESTR = *const OLECHAR; ++pub type LCID = DWORD; ++pub type LPCWSTR = *const WCHAR; ++pub type PULONGLONG = *mut ULONGLONG; ++pub type ULONGLONG = u64; ++ ++pub const S_OK: HRESULT = 0; ++pub const S_FALSE: HRESULT = 1; ++pub const COINIT_MULTITHREADED: u32 = 0x0; ++ ++pub type CLSCTX = u32; ++ ++pub const CLSCTX_INPROC_SERVER: CLSCTX = 0x1; ++pub const CLSCTX_INPROC_HANDLER: CLSCTX = 0x2; ++pub const CLSCTX_LOCAL_SERVER: CLSCTX = 0x4; ++pub const CLSCTX_REMOTE_SERVER: CLSCTX = 0x10; ++ ++pub const CLSCTX_ALL: CLSCTX = CLSCTX_INPROC_SERVER | ++ CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER; ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct GUID { ++ pub Data1: raw::c_ulong, ++ pub Data2: raw::c_ushort, ++ pub Data3: raw::c_ushort, ++ pub Data4: [raw::c_uchar; 8], ++} ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct FILETIME { ++ pub dwLowDateTime: DWORD, ++ pub dwHighDateTime: DWORD, ++} ++ ++pub trait Interface { ++ fn uuidof() -> GUID; ++} ++ ++#[link(name = "ole32")] ++#[link(name = "oleaut32")] ++extern { } ++ ++extern "system" { ++ pub fn CoInitializeEx(pvReserved: LPVOID, dwCoInit: DWORD) -> HRESULT; ++ pub fn CoCreateInstance(rclsid: REFCLSID, pUnkOuter: LPUNKNOWN, ++ dwClsContext: DWORD, riid: REFIID, ++ ppv: *mut LPVOID) -> HRESULT; ++ pub fn SysFreeString(bstrString: BSTR); ++ pub fn SysStringLen(pbstr: BSTR) -> UINT; ++} ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct SAFEARRAYBOUND { ++ pub cElements: ULONG, ++ pub lLbound: LONG, ++} ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct SAFEARRAY { ++ pub cDims: USHORT, ++ pub fFeatures: USHORT, ++ pub cbElements: ULONG, ++ pub cLocks: ULONG, ++ pub pvData: PVOID, ++ pub rgsabound: [SAFEARRAYBOUND; 1], ++} ++ ++pub type LPSAFEARRAY = *mut SAFEARRAY; ++ ++macro_rules! DEFINE_GUID { ++ ( ++ $name:ident, $l:expr, $w1:expr, $w2:expr, ++ $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr ++ ) => { ++ pub const $name: $crate::winapi::GUID = $crate::winapi::GUID { ++ Data1: $l, ++ Data2: $w1, ++ Data3: $w2, ++ Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], ++ }; ++ } ++} ++ ++macro_rules! RIDL { ++ (#[uuid($($uuid:expr),+)] ++ interface $interface:ident ($vtbl:ident) {$( ++ fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, ++ )+}) => ( ++ #[repr(C)] ++ pub struct $vtbl { ++ $(pub $method: unsafe extern "system" fn( ++ This: *mut $interface, ++ $($p: $t),* ++ ) -> $rtr,)+ ++ } ++ #[repr(C)] ++ pub struct $interface { ++ pub lpVtbl: *const $vtbl, ++ } ++ RIDL!{@impl $interface {$(fn $method($($p: $t,)*) -> $rtr,)+}} ++ RIDL!{@uuid $interface $($uuid),+} ++ ); ++ (#[uuid($($uuid:expr),+)] ++ interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) { ++ }) => ( ++ #[repr(C)] ++ pub struct $vtbl { ++ pub parent: $pvtbl, ++ } ++ #[repr(C)] ++ pub struct $interface { ++ pub lpVtbl: *const $vtbl, ++ } ++ RIDL!{@deref $interface $pinterface} ++ RIDL!{@uuid $interface $($uuid),+} ++ ); ++ (#[uuid($($uuid:expr),+)] ++ interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) {$( ++ fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, ++ )+}) => ( ++ #[repr(C)] ++ pub struct $vtbl { ++ pub parent: $pvtbl, ++ $(pub $method: unsafe extern "system" fn( ++ This: *mut $interface, ++ $($p: $t,)* ++ ) -> $rtr,)+ ++ } ++ #[repr(C)] ++ pub struct $interface { ++ pub lpVtbl: *const $vtbl, ++ } ++ RIDL!{@impl $interface {$(fn $method($($p: $t,)*) -> $rtr,)+}} ++ RIDL!{@deref $interface $pinterface} ++ RIDL!{@uuid $interface $($uuid),+} ++ ); ++ (@deref $interface:ident $pinterface:ident) => ( ++ impl ::std::ops::Deref for $interface { ++ type Target = $pinterface; ++ #[inline] ++ fn deref(&self) -> &$pinterface { ++ unsafe { &*(self as *const $interface as *const $pinterface) } ++ } ++ } ++ ); ++ (@impl $interface:ident {$( ++ fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, ++ )+}) => ( ++ impl $interface { ++ $(#[inline] pub unsafe fn $method(&self, $($p: $t,)*) -> $rtr { ++ ((*self.lpVtbl).$method)(self as *const _ as *mut _, $($p,)*) ++ })+ ++ } ++ ); ++ (@uuid $interface:ident ++ $l:expr, $w1:expr, $w2:expr, ++ $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr ++ ) => ( ++ impl $crate::winapi::Interface for $interface { ++ #[inline] ++ fn uuidof() -> $crate::winapi::GUID { ++ $crate::winapi::GUID { ++ Data1: $l, ++ Data2: $w1, ++ Data3: $w2, ++ Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], ++ } ++ } ++ } ++ ); ++} ++ ++RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] ++interface IUnknown(IUnknownVtbl) { ++ fn QueryInterface( ++ riid: REFIID, ++ ppvObject: *mut *mut raw::c_void, ++ ) -> HRESULT, ++ fn AddRef() -> ULONG, ++ fn Release() -> ULONG, ++}} diff --cc vendor/cc-1.0.0/src/windows_registry.rs index 000000000,000000000..9099e0f8d new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/src/windows_registry.rs @@@ -1,0 -1,0 +1,634 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! A helper module to probe the Windows Registry when looking for ++//! windows-specific tools. ++ ++use std::process::Command; ++ ++use Tool; ++ ++#[cfg(windows)] ++macro_rules! otry { ++ ($expr:expr) => (match $expr { ++ Some(val) => val, ++ None => return None, ++ }) ++} ++ ++/// Attempts to find a tool within an MSVC installation using the Windows ++/// registry as a point to search from. ++/// ++/// The `target` argument is the target that the tool should work for (e.g. ++/// compile or link for) and the `tool` argument is the tool to find (e.g. ++/// `cl.exe` or `link.exe`). ++/// ++/// This function will return `None` if the tool could not be found, or it will ++/// return `Some(cmd)` which represents a command that's ready to execute the ++/// tool with the appropriate environment variables set. ++/// ++/// Note that this function always returns `None` for non-MSVC targets. ++pub fn find(target: &str, tool: &str) -> Option { ++ 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 { ++ None ++} ++ ++/// Documented above. ++#[cfg(windows)] ++pub fn find_tool(target: &str, tool: &str) -> Option { ++ use std::env; ++ ++ // This logic is all tailored for MSVC, if we're not that then bail out ++ // early. ++ if !target.contains("msvc") { ++ return None; ++ } ++ ++ // Looks like msbuild isn't located in the same location as other tools like ++ // cl.exe and lib.exe. To handle this we probe for it manually with ++ // dedicated registry keys. ++ if tool.contains("msbuild") { ++ return impl_::find_msbuild(target); ++ } ++ ++ // If VCINSTALLDIR is set, then someone's probably already run vcvars and we ++ // should just find whatever that indicates. ++ if env::var_os("VCINSTALLDIR").is_some() { ++ return env::var_os("PATH") ++ .and_then(|path| env::split_paths(&path).map(|p| p.join(tool)).find(|p| p.exists())) ++ .map(|path| Tool::new(path.into())); ++ } ++ ++ // Ok, if we're here, now comes the fun part of the probing. Default shells ++ // or shells like MSYS aren't really configured to execute `cl.exe` and the ++ // various compiler tools shipped as part of Visual Studio. Here we try to ++ // first find the relevant tool, then we also have to be sure to fill in ++ // environment variables like `LIB`, `INCLUDE`, and `PATH` to ensure that ++ // the tool is actually usable. ++ ++ return impl_::find_msvc_15(tool, target) ++ .or_else(|| impl_::find_msvc_14(tool, target)) ++ .or_else(|| impl_::find_msvc_12(tool, target)) ++ .or_else(|| impl_::find_msvc_11(tool, target)); ++} ++ ++/// A version of Visual Studio ++#[derive(Debug, PartialEq, Eq, Copy, Clone)] ++pub enum VsVers { ++ /// Visual Studio 12 (2013) ++ Vs12, ++ /// Visual Studio 14 (2015) ++ Vs14, ++ /// Visual Studio 15 (2017) ++ Vs15, ++ ++ /// Hidden variant that should not be matched on. Callers that want to ++ /// handle an enumeration of `VsVers` instances should always have a default ++ /// case meaning that it's a VS version they don't understand. ++ #[doc(hidden)] ++ #[allow(bad_style)] ++ __Nonexhaustive_do_not_match_this_or_your_code_will_break, ++} ++ ++/// Find the most recent installed version of Visual Studio ++/// ++/// This is used by the cmake crate to figure out the correct ++/// generator. ++#[cfg(not(windows))] ++pub fn find_vs_version() -> Result { ++ Err(format!("not windows")) ++} ++ ++/// Documented above ++#[cfg(windows)] ++pub fn find_vs_version() -> Result { ++ use std::env; ++ ++ match env::var("VisualStudioVersion") { ++ Ok(version) => { ++ match &version[..] { ++ "15.0" => Ok(VsVers::Vs15), ++ "14.0" => Ok(VsVers::Vs14), ++ "12.0" => Ok(VsVers::Vs12), ++ vers => Err(format!("\n\n\ ++ unsupported or unknown VisualStudio version: {}\n\ ++ if another version is installed consider running \ ++ the appropriate vcvars script before building this \ ++ crate\n\ ++ ", vers)), ++ } ++ } ++ _ => { ++ // Check for the presense of a specific registry key ++ // that indicates visual studio is installed. ++ if impl_::has_msbuild_version("15.0") { ++ Ok(VsVers::Vs15) ++ } else if impl_::has_msbuild_version("14.0") { ++ Ok(VsVers::Vs14) ++ } else if impl_::has_msbuild_version("12.0") { ++ Ok(VsVers::Vs12) ++ } else { ++ Err(format!("\n\n\ ++ couldn't determine visual studio generator\n\ ++ if VisualStudio is installed, however, consider \ ++ running the appropriate vcvars script before building \ ++ this crate\n\ ++ ")) ++ } ++ } ++ } ++} ++ ++#[cfg(windows)] ++mod impl_ { ++ use std::env; ++ use std::ffi::OsString; ++ use std::mem; ++ use std::path::{Path, PathBuf}; ++ use std::fs::File; ++ use std::io::Read; ++ use registry::{RegistryKey, LOCAL_MACHINE}; ++ use com; ++ use setup_config::{SetupConfiguration, SetupInstance}; ++ ++ use Tool; ++ ++ struct MsvcTool { ++ tool: PathBuf, ++ libs: Vec, ++ path: Vec, ++ include: Vec, ++ } ++ ++ 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 ++ } ++ } ++ ++ // In MSVC 15 (2017) MS once again changed the scheme for locating ++ // the tooling. Now we must go through some COM interfaces, which ++ // is super fun for Rust. ++ // ++ // Note that much of this logic can be found [online] wrt paths, COM, etc. ++ // ++ // [online]: https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/ ++ pub fn find_msvc_15(tool: &str, target: &str) -> Option { ++ otry!(com::initialize().ok()); ++ ++ let config = otry!(SetupConfiguration::new().ok()); ++ let iter = otry!(config.enum_all_instances().ok()); ++ for instance in iter { ++ let instance = otry!(instance.ok()); ++ let tool = tool_from_vs15_instance(tool, target, &instance); ++ if tool.is_some() { ++ return tool; ++ } ++ } ++ ++ None ++ } ++ ++ fn tool_from_vs15_instance(tool: &str, target: &str, ++ instance: &SetupInstance) -> Option { ++ let (bin_path, host_dylib_path, lib_path, include_path) = otry!(vs15_vc_paths(target, instance)); ++ let tool_path = bin_path.join(tool); ++ if !tool_path.exists() { return None }; ++ ++ let mut tool = MsvcTool::new(tool_path); ++ tool.path.push(host_dylib_path); ++ tool.libs.push(lib_path); ++ tool.include.push(include_path); ++ ++ if let Some((atl_lib_path, atl_include_path)) = atl_paths(target, &bin_path) { ++ tool.libs.push(atl_lib_path); ++ tool.include.push(atl_include_path); ++ } ++ ++ otry!(add_sdks(&mut tool, target)); ++ ++ Some(tool.into_tool()) ++ } ++ ++ fn vs15_vc_paths(target: &str, instance: &SetupInstance) -> Option<(PathBuf, PathBuf, PathBuf, PathBuf)> { ++ let instance_path: PathBuf = otry!(instance.installation_path().ok()).into(); ++ let version_path = instance_path.join(r"VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"); ++ let mut version_file = otry!(File::open(version_path).ok()); ++ let mut version = String::new(); ++ otry!(version_file.read_to_string(&mut version).ok()); ++ let version = version.trim(); ++ let host = match host_arch() { ++ X86 => "X86", ++ X86_64 => "X64", ++ _ => return None, ++ }; ++ let target = otry!(lib_subdir(target)); ++ // The directory layout here is MSVC/bin/Host$host/$target/ ++ let path = instance_path.join(r"VC\Tools\MSVC").join(version); ++ // This is the path to the toolchain for a particular target, running ++ // on a given host ++ let bin_path = path.join("bin").join(&format!("Host{}", host)).join(&target); ++ // But! we also need PATH to contain the target directory for the host ++ // architecture, because it contains dlls like mspdb140.dll compiled for ++ // the host architecture. ++ let host_dylib_path = path.join("bin").join(&format!("Host{}", host)).join(&host.to_lowercase()); ++ let lib_path = path.join("lib").join(&target); ++ let include_path = path.join("include"); ++ Some((bin_path, host_dylib_path, lib_path, include_path)) ++ } ++ ++ fn atl_paths(target: &str, path: &Path) -> Option<(PathBuf, PathBuf)> { ++ let atl_path = path.join("atlfmc"); ++ let sub = otry!(lib_subdir(target)); ++ if atl_path.exists() { ++ Some((atl_path.join("lib").join(sub), atl_path.join("include"))) ++ } else { ++ None ++ } ++ } ++ ++ // For MSVC 14 we need to find the Universal CRT as well as either ++ // the Windows 10 SDK or Windows 8.1 SDK. ++ pub fn find_msvc_14(tool: &str, target: &str) -> Option { ++ let vcdir = otry!(get_vc_dir("14.0")); ++ let mut tool = otry!(get_tool(tool, &vcdir, target)); ++ otry!(add_sdks(&mut tool, target)); ++ Some(tool.into_tool()) ++ } ++ ++ fn add_sdks(tool: &mut MsvcTool, target: &str) -> Option<()> { ++ let sub = otry!(lib_subdir(target)); ++ let (ucrt, ucrt_version) = otry!(get_ucrt_dir()); ++ ++ tool.path.push(ucrt.join("bin").join(&ucrt_version).join(sub)); ++ ++ let ucrt_include = ucrt.join("include").join(&ucrt_version); ++ tool.include.push(ucrt_include.join("ucrt")); ++ ++ let ucrt_lib = ucrt.join("lib").join(&ucrt_version); ++ tool.libs.push(ucrt_lib.join("ucrt").join(sub)); ++ ++ if let Some((sdk, version)) = get_sdk10_dir() { ++ tool.path.push(sdk.join("bin").join(sub)); ++ let sdk_lib = sdk.join("lib").join(&version); ++ tool.libs.push(sdk_lib.join("um").join(sub)); ++ let sdk_include = sdk.join("include").join(&version); ++ tool.include.push(sdk_include.join("um")); ++ tool.include.push(sdk_include.join("winrt")); ++ tool.include.push(sdk_include.join("shared")); ++ } else if let Some(sdk) = get_sdk81_dir() { ++ tool.path.push(sdk.join("bin").join(sub)); ++ let sdk_lib = sdk.join("lib").join("winv6.3"); ++ tool.libs.push(sdk_lib.join("um").join(sub)); ++ let sdk_include = sdk.join("include"); ++ tool.include.push(sdk_include.join("um")); ++ tool.include.push(sdk_include.join("winrt")); ++ tool.include.push(sdk_include.join("shared")); ++ } ++ ++ Some(()) ++ } ++ ++ // For MSVC 12 we need to find the Windows 8.1 SDK. ++ pub fn find_msvc_12(tool: &str, target: &str) -> Option { ++ let vcdir = otry!(get_vc_dir("12.0")); ++ let mut tool = otry!(get_tool(tool, &vcdir, target)); ++ let sub = otry!(lib_subdir(target)); ++ let sdk81 = otry!(get_sdk81_dir()); ++ tool.path.push(sdk81.join("bin").join(sub)); ++ let sdk_lib = sdk81.join("lib").join("winv6.3"); ++ tool.libs.push(sdk_lib.join("um").join(sub)); ++ let sdk_include = sdk81.join("include"); ++ tool.include.push(sdk_include.join("shared")); ++ tool.include.push(sdk_include.join("um")); ++ tool.include.push(sdk_include.join("winrt")); ++ Some(tool.into_tool()) ++ } ++ ++ // For MSVC 11 we need to find the Windows 8 SDK. ++ pub fn find_msvc_11(tool: &str, target: &str) -> Option { ++ 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) { ++ 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 { ++ 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 { ++ 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::>(); ++ 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 { ++ 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 { ++ 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 ++ } ++ ++ pub fn has_msbuild_version(version: &str) -> bool { ++ match version { ++ "15.0" => { ++ find_msbuild_vs15("x86_64-pc-windows-msvc").is_some() || ++ find_msbuild_vs15("i686-pc-windows-msvc").is_some() ++ } ++ "12.0" | "14.0" => { ++ LOCAL_MACHINE.open( ++ &OsString::from(format!("SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\{}", ++ version))).is_ok() ++ } ++ _ => false ++ } ++ } ++ ++ // see http://stackoverflow.com/questions/328017/path-to-msbuild ++ pub fn find_msbuild(target: &str) -> Option { ++ // VS 15 (2017) changed how to locate msbuild ++ if let Some(r) = find_msbuild_vs15(target) { ++ return Some(r); ++ } else { ++ find_old_msbuild(target) ++ } ++ } ++ ++ fn find_msbuild_vs15(target: &str) -> Option { ++ // Seems like this could also go through SetupConfiguration, ++ // or that find_msvc_15 could just use this registry key ++ // instead of the COM interface. ++ let key = r"SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7"; ++ LOCAL_MACHINE.open(key.as_ref()) ++ .ok() ++ .and_then(|key| { ++ key.query_str("15.0").ok() ++ }) ++ .map(|path| { ++ let path = PathBuf::from(path).join(r"MSBuild\15.0\Bin\MSBuild.exe"); ++ let mut tool = Tool::new(path); ++ if target.contains("x86_64") { ++ tool.env.push(("Platform".into(), "X64".into())); ++ } ++ tool ++ }) ++ } ++ ++ fn find_old_msbuild(target: &str) -> Option { ++ 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 --cc vendor/cc-1.0.0/tests/cc_env.rs index 000000000,000000000..642200d07 new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/tests/cc_env.rs @@@ -1,0 -1,0 +1,49 @@@ ++extern crate tempdir; ++extern crate cc; ++ ++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 --cc vendor/cc-1.0.0/tests/support/mod.rs index 000000000,000000000..428854625 new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/tests/support/mod.rs @@@ -1,0 -1,0 +1,112 @@@ ++#![allow(dead_code)] ++ ++use std::env; ++use std::ffi::OsStr; ++use std::fs::{self, File}; ++use std::io::prelude::*; ++use std::path::PathBuf; ++ ++use cc; ++use tempdir::TempDir; ++ ++pub struct Test { ++ pub td: TempDir, ++ pub gcc: PathBuf, ++ pub msvc: bool, ++} ++ ++pub struct Execution { ++ args: Vec, ++} ++ ++impl Test { ++ pub fn new() -> Test { ++ let mut gcc = PathBuf::from(env::current_exe().unwrap()); ++ gcc.pop(); ++ if gcc.ends_with("deps") { ++ gcc.pop(); ++ } ++ gcc.push(format!("gcc-shim{}", env::consts::EXE_SUFFIX)); ++ Test { ++ td: TempDir::new("gcc-test").unwrap(), ++ gcc: gcc, ++ msvc: false, ++ } ++ } ++ ++ pub fn gnu() -> Test { ++ let t = Test::new(); ++ t.shim("cc").shim("c++").shim("ar"); ++ t ++ } ++ ++ pub fn msvc() -> Test { ++ let mut t = Test::new(); ++ t.shim("cl").shim("lib.exe"); ++ t.msvc = true; ++ t ++ } ++ ++ pub fn shim(&self, name: &str) -> &Test { ++ let fname = format!("{}{}", name, env::consts::EXE_SUFFIX); ++ fs::hard_link(&self.gcc, self.td.path().join(&fname)) ++ .or_else(|_| fs::copy(&self.gcc, self.td.path().join(&fname)).map(|_| ())) ++ .unwrap(); ++ self ++ } ++ ++ pub fn gcc(&self) -> cc::Build { ++ let mut cfg = cc::Build::new(); ++ let mut path = env::split_paths(&env::var_os("PATH").unwrap()).collect::>(); ++ 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>(&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>(&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 --cc vendor/cc-1.0.0/tests/test.rs index 000000000,000000000..b8f1abf1e new file mode 100644 --- /dev/null +++ b/vendor/cc-1.0.0/tests/test.rs @@@ -1,0 -1,0 +1,338 @@@ ++extern crate cc; ++extern crate tempdir; ++ ++use support::Test; ++ ++mod support; ++ ++#[test] ++fn gnu_smoke() { ++ let test = Test::gnu(); ++ test.gcc() ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0) ++ .must_have("-O2") ++ .must_have("foo.c") ++ .must_not_have("-g") ++ .must_have("-c") ++ .must_have("-ffunction-sections") ++ .must_have("-fdata-sections"); ++ test.cmd(1).must_have(test.td.path().join("foo.o")); ++} ++ ++#[test] ++fn gnu_opt_level_1() { ++ let test = Test::gnu(); ++ test.gcc() ++ .opt_level(1) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0) ++ .must_have("-O1") ++ .must_not_have("-O2"); ++} ++ ++#[test] ++fn gnu_opt_level_s() { ++ let test = Test::gnu(); ++ test.gcc() ++ .opt_level_str("s") ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0) ++ .must_have("-Os") ++ .must_not_have("-O1") ++ .must_not_have("-O2") ++ .must_not_have("-O3") ++ .must_not_have("-Oz"); ++} ++ ++#[test] ++fn gnu_debug() { ++ let test = Test::gnu(); ++ test.gcc() ++ .debug(true) ++ .file("foo.c") ++ .compile("foo"); ++ test.cmd(0).must_have("-g"); ++} ++ ++#[test] ++fn gnu_warnings_into_errors() { ++ let test = Test::gnu(); ++ test.gcc() ++ .warnings_into_errors(true) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_have("-Werror"); ++} ++ ++#[test] ++fn gnu_warnings() { ++ let test = Test::gnu(); ++ test.gcc() ++ .warnings(true) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_have("-Wall") ++ .must_have("-Wextra"); ++} ++ ++#[test] ++fn gnu_x86_64() { ++ for vendor in &["unknown-linux-gnu", "apple-darwin"] { ++ let target = format!("x86_64-{}", vendor); ++ let test = Test::gnu(); ++ test.gcc() ++ .target(&target) ++ .host(&target) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0) ++ .must_have("-fPIC") ++ .must_have("-m64"); ++ } ++} ++ ++#[test] ++fn gnu_x86_64_no_pic() { ++ for vendor in &["unknown-linux-gnu", "apple-darwin"] { ++ let target = format!("x86_64-{}", vendor); ++ let test = Test::gnu(); ++ test.gcc() ++ .pic(false) ++ .target(&target) ++ .host(&target) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_not_have("-fPIC"); ++ } ++} ++ ++#[test] ++fn gnu_i686() { ++ for vendor in &["unknown-linux-gnu", "apple-darwin"] { ++ let target = format!("i686-{}", vendor); ++ let test = Test::gnu(); ++ test.gcc() ++ .target(&target) ++ .host(&target) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0) ++ .must_have("-m32"); ++ } ++} ++ ++#[test] ++fn gnu_i686_pic() { ++ for vendor in &["unknown-linux-gnu", "apple-darwin"] { ++ let target = format!("i686-{}", vendor); ++ let test = Test::gnu(); ++ test.gcc() ++ .pic(true) ++ .target(&target) ++ .host(&target) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_have("-fPIC"); ++ } ++} ++ ++#[test] ++fn gnu_set_stdlib() { ++ let test = Test::gnu(); ++ test.gcc() ++ .cpp_set_stdlib(Some("foo")) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_not_have("-stdlib=foo"); ++} ++ ++#[test] ++fn gnu_include() { ++ let test = Test::gnu(); ++ test.gcc() ++ .include("foo/bar") ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_have("-I").must_have("foo/bar"); ++} ++ ++#[test] ++fn gnu_define() { ++ let test = Test::gnu(); ++ test.gcc() ++ .define("FOO", "bar") ++ .define("BAR", None) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_have("-DFOO=bar").must_have("-DBAR"); ++} ++ ++#[test] ++fn gnu_compile_assembly() { ++ let test = Test::gnu(); ++ test.gcc() ++ .file("foo.S") ++ .compile("foo"); ++ test.cmd(0).must_have("foo.S"); ++} ++ ++#[test] ++fn gnu_shared() { ++ let test = Test::gnu(); ++ test.gcc() ++ .file("foo.c") ++ .shared_flag(true) ++ .static_flag(false) ++ .compile("foo"); ++ ++ test.cmd(0) ++ .must_have("-shared") ++ .must_not_have("-static"); ++} ++ ++#[test] ++fn gnu_flag_if_supported() { ++ if cfg!(windows) { ++ return ++ } ++ let test = Test::gnu(); ++ test.gcc() ++ .file("foo.c") ++ .flag_if_supported("-Wall") ++ .flag_if_supported("-Wflag-does-not-exist") ++ .flag_if_supported("-std=c++11") ++ .compile("foo"); ++ ++ test.cmd(0) ++ .must_have("-Wall") ++ .must_not_have("-Wflag-does-not-exist") ++ .must_not_have("-std=c++11"); ++} ++ ++#[test] ++fn gnu_flag_if_supported_cpp() { ++ if cfg!(windows) { ++ return ++ } ++ let test = Test::gnu(); ++ test.gcc() ++ .cpp(true) ++ .file("foo.cpp") ++ .flag_if_supported("-std=c++11") ++ .compile("foo"); ++ ++ test.cmd(0) ++ .must_have("-std=c++11"); ++} ++ ++#[test] ++fn gnu_static() { ++ let test = Test::gnu(); ++ test.gcc() ++ .file("foo.c") ++ .shared_flag(false) ++ .static_flag(true) ++ .compile("foo"); ++ ++ test.cmd(0) ++ .must_have("-static") ++ .must_not_have("-shared"); ++} ++ ++#[test] ++fn msvc_smoke() { ++ let test = Test::msvc(); ++ test.gcc() ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0) ++ .must_have("/O2") ++ .must_have("foo.c") ++ .must_not_have("/Z7") ++ .must_have("/c") ++ .must_have("/MD"); ++ test.cmd(1).must_have(test.td.path().join("foo.o")); ++} ++ ++#[test] ++fn msvc_opt_level_0() { ++ let test = Test::msvc(); ++ test.gcc() ++ .opt_level(0) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_not_have("/O2"); ++} ++ ++#[test] ++fn msvc_debug() { ++ let test = Test::msvc(); ++ test.gcc() ++ .debug(true) ++ .file("foo.c") ++ .compile("foo"); ++ test.cmd(0).must_have("/Z7"); ++} ++ ++#[test] ++fn msvc_include() { ++ let test = Test::msvc(); ++ test.gcc() ++ .include("foo/bar") ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_have("/I").must_have("foo/bar"); ++} ++ ++#[test] ++fn msvc_define() { ++ let test = Test::msvc(); ++ test.gcc() ++ .define("FOO", "bar") ++ .define("BAR", None) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_have("/DFOO=bar").must_have("/DBAR"); ++} ++ ++#[test] ++fn msvc_static_crt() { ++ let test = Test::msvc(); ++ test.gcc() ++ .static_crt(true) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_have("/MT"); ++} ++ ++#[test] ++fn msvc_no_static_crt() { ++ let test = Test::msvc(); ++ test.gcc() ++ .static_crt(false) ++ .file("foo.c") ++ .compile("foo"); ++ ++ test.cmd(0).must_have("/MD"); ++} diff --cc vendor/cmake-0.1.26/.cargo-checksum.json index 000000000,000000000..d0662d60e new file mode 100644 --- /dev/null +++ b/vendor/cmake-0.1.26/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"357c07e7a1fc95732793c1edb5901e1a1f305cfcf63a90eb12dbd22bdb6b789d"} diff --cc vendor/cmake-0.1.26/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/cmake-0.1.26/.cargo-ok diff --cc vendor/cmake-0.1.26/.travis.yml index 000000000,000000000..bcd71cbe8 new file mode 100644 --- /dev/null +++ b/vendor/cmake-0.1.26/.travis.yml @@@ -1,0 -1,0 +1,20 @@@ ++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: "IA467qqr1j0BpyTqG6hO8Kpt+EUDEjO1pBVhu4+L76/dygkQIwROgqdT7uXZqBPMjU6Rbi0wzGXXHJjbCWVTCjh7U/Q0bK2svtR8DKtM0o1Un/YftSUFt2p/WoiJ9PrkUjKh1rHuoyijpUqAls0JfIz8OdC45egT2SWDufljo+s=" ++ ++notifications: ++ email: ++ on_success: never diff --cc vendor/cmake-0.1.26/Cargo.toml index 000000000,000000000..bf60a8bb9 new file mode 100644 --- /dev/null +++ b/vendor/cmake-0.1.26/Cargo.toml @@@ -1,0 -1,0 +1,25 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "cmake" ++version = "0.1.26" ++authors = ["Alex Crichton "] ++description = "A build dependency for running `cmake` to build a native library\n" ++homepage = "https://github.com/alexcrichton/cmake-rs" ++documentation = "http://alexcrichton.com/cmake-rs" ++readme = "README.md" ++keywords = ["build-dependencies"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/cmake-rs" ++[dependencies.cc] ++version = "1.0" diff --cc vendor/cmake-0.1.26/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/cmake-0.1.26/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/cmake-0.1.26/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/cmake-0.1.26/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/cmake-0.1.26/README.md index 000000000,000000000..8b2586eb0 new file mode 100644 --- /dev/null +++ b/vendor/cmake-0.1.26/README.md @@@ -1,0 -1,0 +1,22 @@@ ++# cmake ++ ++[![Build Status](https://travis-ci.org/alexcrichton/cmake-rs.svg?branch=master)](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 --cc vendor/cmake-0.1.26/src/lib.rs index 000000000,000000000..36b0c657d new file mode 100644 --- /dev/null +++ b/vendor/cmake-0.1.26/src/lib.rs @@@ -1,0 -1,0 +1,600 @@@ ++//! 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 cc; ++ ++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; ++ ++/// Builder style configuration for a pending CMake build. ++pub struct Config { ++ path: PathBuf, ++ generator: Option, ++ cflags: OsString, ++ cxxflags: OsString, ++ defines: Vec<(OsString, OsString)>, ++ deps: Vec, ++ target: Option, ++ host: Option, ++ out_dir: Option, ++ profile: Option, ++ build_args: Vec, ++ cmake_target: Option, ++ env: Vec<(OsString, OsString)>, ++ static_crt: Option, ++} ++ ++/// 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>(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>(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, ++ env: Vec::new(), ++ static_crt: None, ++ } ++ } ++ ++ /// Sets the build-tool generator (`-G`) for this compilation. ++ pub fn generator>(&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>(&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>(&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(&mut self, k: K, v: V) -> &mut Config ++ where K: AsRef, V: AsRef ++ { ++ 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>(&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 ++ } ++ ++ /// Configures whether the /MT flag or the /MD flag will be passed to msvc build tools. ++ /// ++ /// This option defaults to `false`, and affect only msvc targets. ++ pub fn static_crt(&mut self, static_crt: bool) -> &mut Config { ++ self.static_crt = Some(static_crt); ++ self ++ } ++ ++ /// Add an argument to the final `cmake` build step ++ pub fn build_arg>(&mut self, arg: A) -> &mut Config { ++ self.build_args.push(arg.as_ref().to_owned()); ++ self ++ } ++ ++ /// Configure an environment variable for the `cmake` processes spawned by ++ /// this crate in the `build` step. ++ pub fn env(&mut self, key: K, value: V) -> &mut Config ++ where K: AsRef, ++ V: AsRef, ++ { ++ self.env.push((key.as_ref().to_owned(), value.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 mut c_cfg = cc::Build::new(); ++ c_cfg.cargo_metadata(false) ++ .opt_level(0) ++ .debug(false) ++ .target(&target) ++ .warnings(false) ++ .host(&host); ++ let mut cxx_cfg = cc::Build::new(); ++ cxx_cfg.cargo_metadata(false) ++ .cpp(true) ++ .opt_level(0) ++ .debug(false) ++ .target(&target) ++ .warnings(false) ++ .host(&host); ++ if let Some(static_crt) = self.static_crt { ++ c_cfg.static_crt(static_crt); ++ cxx_cfg.static_crt(static_crt); ++ } ++ let c_compiler = c_cfg.get_compiler(); ++ let cxx_compiler = cxx_cfg.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. ++ // This also guarantees that NMake generator isn't chosen implicitly. ++ if self.generator.is_none() { ++ cmd.arg("-G").arg(self.visual_studio_generator(&target)); ++ } ++ } else if target.contains("redox") { ++ if !self.defined("CMAKE_SYSTEM_NAME") { ++ cmd.arg("-DCMAKE_SYSTEM_NAME=Generic"); ++ } ++ } ++ let mut is_ninja = false; ++ if let Some(ref generator) = self.generator { ++ cmd.arg("-G").arg(generator); ++ is_ninja = generator.to_string_lossy().contains("Ninja"); ++ } ++ let profile = self.profile.clone().unwrap_or_else(|| { ++ match &getenv_unwrap("PROFILE")[..] { ++ "bench" | "release" => "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 build_type = self.defines.iter().find(|&&(ref a, _)| { ++ a == "CMAKE_BUILD_TYPE" ++ }).map(|x| x.1.to_str().unwrap()).unwrap_or(&profile); ++ let build_type_upcase = build_type.chars() ++ .flat_map(|c| c.to_uppercase()) ++ .collect::(); ++ ++ { ++ // let cmake deal with optimization/debuginfo ++ let skip_arg = |arg: &OsStr| { ++ match arg.to_str() { ++ Some(s) => { ++ s.starts_with("-O") || s.starts_with("/O") || s == "-g" ++ } ++ None => false, ++ } ++ }; ++ let mut set_compiler = |kind: &str, ++ compiler: &cc::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() { ++ if skip_arg(arg) { ++ continue ++ } ++ flagsflag.push(" "); ++ flagsflag.push(arg); ++ } ++ cmd.arg(flagsflag); ++ } ++ ++ // The visual studio generator apparently doesn't respect ++ // `CMAKE_C_FLAGS` but does respect `CMAKE_C_FLAGS_RELEASE` and ++ // such. We need to communicate /MD vs /MT, so set those vars ++ // here. ++ // ++ // Note that for other generators, though, this *overrides* ++ // things like the optimization flags, which is bad. ++ if self.generator.is_none() && msvc { ++ let flag_var_alt = format!("CMAKE_{}_FLAGS_{}", kind, ++ build_type_upcase); ++ if !self.defined(&flag_var_alt) { ++ let mut flagsflag = OsString::from("-D"); ++ flagsflag.push(&flag_var_alt); ++ flagsflag.push("="); ++ flagsflag.push(extra); ++ for arg in compiler.args() { ++ if skip_arg(arg) { ++ continue ++ } ++ 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 specify this on Windows only if we use MSVC with Ninja, ++ // as it's not needed for MSVC with Visual Studio generators and ++ // for MinGW it doesn't really vary. ++ if !self.defined("CMAKE_TOOLCHAIN_FILE") ++ && !self.defined(&tool_var) ++ && (env::consts::FAMILY != "windows" || (msvc && is_ninja)) { ++ let mut ccompiler = OsString::from("-D"); ++ ccompiler.push(&tool_var); ++ ccompiler.push("="); ++ ccompiler.push(find_exe(compiler.path())); ++ #[cfg(windows)] { ++ // CMake doesn't like unescaped `\`s in compiler paths ++ // so we either have to escape them or replace with `/`s. ++ use std::os::windows::ffi::{OsStrExt, OsStringExt}; ++ let wchars = ccompiler.encode_wide().map(|wchar| { ++ if wchar == b'\\' as u16 { '/' as u16 } else { wchar } ++ }).collect::>(); ++ ccompiler = OsString::from_wide(&wchars); ++ } ++ 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)); ++ } ++ } ++ ++ for &(ref k, ref v) in c_compiler.env().iter().chain(&self.env) { ++ cmd.env(k, v); ++ } ++ ++ run(cmd.env("CMAKE_PREFIX_PATH", cmake_prefix_path), "cmake"); ++ ++ let mut parallel_args = Vec::new(); ++ if let Ok(s) = env::var("NUM_JOBS") { ++ match self.generator.as_ref().map(|g| g.to_string_lossy()) { ++ Some(ref g) if g.contains("Ninja") => { ++ parallel_args.push(format!("-j{}", s)); ++ } ++ Some(ref g) if g.contains("Visual Studio") => { ++ parallel_args.push(format!("/m:{}", s)); ++ } ++ Some(ref g) if g.contains("NMake") => { ++ // NMake creates `Makefile`s, but doesn't understand `-jN`. ++ } ++ _ => if fs::metadata(&dst.join("build/Makefile")).is_ok() { ++ // This looks like `make`, let's hope it understands `-jN`. ++ parallel_args.push(format!("-j{}", s)); ++ } ++ } ++ } ++ ++ // And build! ++ let target = self.cmake_target.clone().unwrap_or("install".to_string()); ++ let mut cmd = Command::new("cmake"); ++ for &(ref k, ref v) in c_compiler.env().iter().chain(&self.env) { ++ cmd.env(k, v); ++ } ++ run(cmd.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 { ++ use cc::windows_registry::{find_vs_version, VsVers}; ++ ++ let base = match find_vs_version() { ++ Ok(VsVers::Vs15) => "Visual Studio 15 2017", ++ Ok(VsVers::Vs14) => "Visual Studio 14 2015", ++ Ok(VsVers::Vs12) => "Visual Studio 12 2013", ++ Ok(_) => panic!("Visual studio version detected but this crate \ ++ doesn't know how to generate cmake files for it, \ ++ can the `cmake` crate be updated?"), ++ Err(msg) => panic!(msg), ++ }; ++ if target.contains("i686") { ++ base.to_string() ++ } else if target.contains("x86_64") { ++ format!("{} Win64", base) ++ } else { ++ panic!("unsupported msvc target: {}", target); ++ } ++ } ++ ++ 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 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.starts_with("CMAKE_HOME_DIRECTORY") { ++ let needs_cleanup = match line.split('=').next_back() { ++ Some(cmake_home) => { ++ fs::canonicalize(cmake_home) ++ .ok() ++ .map(|cmake_home| cmake_home != path) ++ .unwrap_or(true) ++ }, ++ None => true ++ }; ++ if needs_cleanup { ++ 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 --cc vendor/commoncrypto-0.2.0/.cargo-checksum.json index 000000000,000000000..05b5c1366 new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-0.2.0/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"} diff --cc vendor/commoncrypto-0.2.0/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-0.2.0/.cargo-ok diff --cc vendor/commoncrypto-0.2.0/Cargo.toml index 000000000,000000000..cb62f9b59 new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-0.2.0/Cargo.toml @@@ -1,0 -1,0 +1,20 @@@ ++[package] ++name = "commoncrypto" ++version = "0.2.0" ++authors = ["Mark Lee"] ++description = "Idiomatic Rust wrappers for Mac OS X's CommonCrypto library" ++documentation = "https://docs.rs/commoncrypto" ++repository = "https://github.com/malept/rust-commoncrypto" ++keywords = ["crypto", "hash", "digest", "osx", "commoncrypto"] ++license = "MIT" ++ ++[features] ++lint = ["clippy"] ++ ++[dependencies] ++commoncrypto-sys = { version = "0.2.0", path = "../commoncrypto-sys" } ++ ++clippy = { version = "0.0", optional = true } ++ ++[dev-dependencies] ++hex = "0.2" diff --cc vendor/commoncrypto-0.2.0/src/hash.rs index 000000000,000000000..a30ee4d15 new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-0.2.0/src/hash.rs @@@ -1,0 -1,0 +1,127 @@@ ++// Copyright (c) 2016 Mark Lee ++// ++// 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. ++ ++//! Idiomatic Rust wrapper for `CommonCrypto`'s `CCDigestCtx` struct. ++ ++use commoncrypto_sys::{CCDigestCreate, CCDigestCtx, CCDigestDestroy, CCDigestFinal, ++ CCDigestGetOutputSizeFromRef, CCDigestReset, CCDigestUpdate}; ++use std::io; ++ ++pub use commoncrypto_sys::CCDigestAlgorithm; ++ ++const MAX_DIGEST_SIZE: usize = 64; ++ ++macro_rules! err_from_ccdigest_retval{ ++ ($func_name: expr, $val: expr) => { ++ Err(io::Error::new(io::ErrorKind::Other, ++ format!("{} returned nonzero: {}", $func_name, $val))) ++ } ++} ++ ++#[derive(PartialEq, Copy, Clone, Debug)] ++enum State { ++ Reset, ++ Updated, ++ Finalized, ++} ++ ++/// Generates cryptographic hashes. ++#[derive(Debug)] ++pub struct Hasher { ++ ctx: *mut CCDigestCtx, ++ state: State, ++} ++ ++impl Hasher { ++ /// Creates a new `Hasher` which will use the given cryptographic `algorithm`. ++ pub fn new(algorithm: CCDigestAlgorithm) -> Hasher { ++ let ctx: *mut CCDigestCtx; ++ unsafe { ++ ctx = CCDigestCreate(algorithm); ++ } ++ Hasher { ++ ctx: ctx, ++ state: State::Reset, ++ } ++ } ++ ++ fn init(&mut self) { ++ match self.state { ++ State::Reset => return, ++ State::Updated => { ++ let _ = self.finish(); ++ } ++ State::Finalized => (), ++ } ++ unsafe { CCDigestReset(self.ctx) }; ++ self.state = State::Reset; ++ } ++ ++ /// Feeds data into the hasher. ++ pub fn update(&mut self, data: &[u8]) -> io::Result { ++ if self.state == State::Finalized { ++ self.init(); ++ } ++ let result = unsafe { CCDigestUpdate(self.ctx, data.as_ptr() as *mut _, data.len()) }; ++ if result == 0 { ++ self.state = State::Updated; ++ Ok(data.len()) ++ } else { ++ err_from_ccdigest_retval!("CCDigestCreate", result) ++ } ++ } ++ ++ /// Finalizes digest operations and produces the digest output. ++ pub fn finish(&mut self) -> io::Result> { ++ if self.state == State::Finalized { ++ self.init(); ++ } ++ let expected_len = unsafe { CCDigestGetOutputSizeFromRef(self.ctx) }; ++ let mut md = vec![0; MAX_DIGEST_SIZE]; ++ let result = unsafe { CCDigestFinal(self.ctx, md.as_mut_ptr()) }; ++ if result == 0 { ++ self.state = State::Finalized; ++ md.truncate(expected_len); ++ Ok(md) ++ } else { ++ err_from_ccdigest_retval!("CCDigestFinal", result) ++ } ++ } ++} ++ ++impl io::Write for Hasher { ++ #[inline] ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.update(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ Ok(()) ++ } ++} ++ ++impl Drop for Hasher { ++ fn drop(&mut self) { ++ if self.state != State::Finalized { ++ let _ = self.finish(); ++ } ++ unsafe { CCDigestDestroy(self.ctx) } ++ } ++} diff --cc vendor/commoncrypto-0.2.0/src/lib.rs index 000000000,000000000..3b58f915e new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-0.2.0/src/lib.rs @@@ -1,0 -1,0 +1,30 @@@ ++// Copyright (c) 2016 Mark Lee ++// ++// 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. ++ ++//! Idiomatic Rust wrappers for `CommonCrypto` structs. ++ ++#![warn(missing_docs)] ++ ++extern crate commoncrypto_sys; ++ ++#[warn(missing_docs)] ++pub mod hash; ++#[warn(missing_docs)] ++pub mod pbkdf2; diff --cc vendor/commoncrypto-0.2.0/src/pbkdf2.rs index 000000000,000000000..94cb937c6 new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-0.2.0/src/pbkdf2.rs @@@ -1,0 -1,0 +1,66 @@@ ++// Copyright (c) 2016 ++// ++// 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. ++ ++//! Idiomatic Rust wrapper for `CommonCrypto`'s `CCKeyDerivationPBKDF` function. ++ ++use commoncrypto_sys::{CCKeyDerivationPBKDF, CCPBKDFAlgorithm}; ++ ++use std::io; ++ ++pub use commoncrypto_sys::CCPseudoRandomAlgorithm; ++ ++macro_rules! err_from_cckeyderivationpbkdf_retval { ++ ($func_name: expr, $val: expr) => {{ ++ let kind = match $val { ++ // kCCParamError is the only one that's specifically noted ++ -43000 => io::ErrorKind::InvalidInput, ++ _ => io::ErrorKind::Other, ++ }; ++ ++ Err(io::Error::new(kind, format!("{} returned nonzero: {}", $func_name, $val))) ++ }} ++} ++ ++/// Derive a key from a password or passphrase and a salt ++pub fn pbkdf2(password: &[u8], ++ salt: &[u8], ++ prf: CCPseudoRandomAlgorithm, ++ rounds: u32, ++ key_len: usize) ++ -> io::Result> { ++ let mut pw_derived = vec![0u8; key_len]; ++ let result = unsafe { ++ CCKeyDerivationPBKDF(CCPBKDFAlgorithm::kCCPBKDF2, ++ password.as_ptr(), ++ password.len(), ++ salt.as_ptr(), ++ salt.len(), ++ prf, ++ rounds, ++ pw_derived.as_mut_ptr(), ++ pw_derived.len()) ++ }; ++ ++ if result == 0 { ++ Ok(pw_derived) ++ } else { ++ err_from_cckeyderivationpbkdf_retval!("CCKeyDerivationPBKDF", result) ++ } ++} diff --cc vendor/commoncrypto-0.2.0/tests/hash.rs index 000000000,000000000..bccc86c4c new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-0.2.0/tests/hash.rs @@@ -1,0 -1,0 +1,18 @@@ ++extern crate commoncrypto; ++extern crate hex; ++ ++use commoncrypto::hash::{CCDigestAlgorithm, Hasher}; ++use hex::ToHex; ++use std::io::Write; ++ ++const TO_HASH: &'static str = "The quick brown fox jumps over the lazy dog"; ++const TO_HASH_MD5: &'static str = "9e107d9d372bb6826bd81d3542a419d6"; ++ ++#[test] ++fn md5_hasher() { ++ let mut hasher = Hasher::new(CCDigestAlgorithm::kCCDigestMD5); ++ assert!(hasher.write_all(TO_HASH.as_bytes()).is_ok()); ++ let result = hasher.finish(); ++ assert!(result.is_ok()); ++ assert_eq!(result.expect("Hash failed").to_hex(), TO_HASH_MD5) ++} diff --cc vendor/commoncrypto-0.2.0/tests/pbkdf2.rs index 000000000,000000000..179c5aec6 new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-0.2.0/tests/pbkdf2.rs @@@ -1,0 -1,0 +1,16 @@@ ++extern crate commoncrypto; ++extern crate hex; ++ ++use commoncrypto::pbkdf2::{pbkdf2, CCPseudoRandomAlgorithm}; ++use hex::ToHex; ++ ++#[test] ++fn derive_pbkdf2() { ++ let derived = pbkdf2(b"password", ++ b"salt", ++ CCPseudoRandomAlgorithm::kCCPRFHmacAlgSHA1, ++ 1, ++ 20) ++ .unwrap(); ++ assert_eq!("0c60c80f961f0e71f3a9b524af6012062fe037a6", derived.to_hex()); ++} diff --cc vendor/commoncrypto-sys-0.2.0/.cargo-checksum.json index 000000000,000000000..6ad6734e2 new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-sys-0.2.0/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"} diff --cc vendor/commoncrypto-sys-0.2.0/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-sys-0.2.0/.cargo-ok diff --cc vendor/commoncrypto-sys-0.2.0/Cargo.toml index 000000000,000000000..309cc8684 new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-sys-0.2.0/Cargo.toml @@@ -1,0 -1,0 +1,20 @@@ ++[package] ++name = "commoncrypto-sys" ++version = "0.2.0" ++authors = ["Mark Lee"] ++description = "FFI bindings to Mac OS X's CommonCrypto library" ++documentation = "https://docs.rs/commoncrypto-sys" ++repository = "https://github.com/malept/rust-commoncrypto" ++keywords = ["crypto", "hash", "digest", "osx", "commoncrypto"] ++license = "MIT" ++ ++[features] ++lint = ["clippy"] ++ ++[dependencies] ++libc = "0.2" ++ ++clippy = { version = "0.0", optional = true } ++ ++[dev-dependencies] ++hex = "0.2" diff --cc vendor/commoncrypto-sys-0.2.0/src/lib.rs index 000000000,000000000..dce335a3a new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-sys-0.2.0/src/lib.rs @@@ -1,0 -1,0 +1,237 @@@ ++// Copyright (c) 2016 Mark Lee ++// ++// 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. ++ ++//! Low-level bindings to OSX/macOS/iOS's `CommonCrypto` library. ++ ++#![warn(missing_docs)] ++ ++extern crate libc; ++ ++use libc::{c_int, c_uint}; ++ ++/// Total number of operations. ++const MD5_CBLOCK: usize = 64; ++/// Number of operations per round. ++const MD5_LBLOCK: usize = MD5_CBLOCK / 4; ++/// Number of bytes for an MD5 hash. ++pub const MD5_DIGEST_LENGTH: usize = 16; ++ ++const SHA_LBLOCK: usize = 16; ++/// Number of bytes for an SHA1 hash. ++pub const SHA1_DIGEST_LENGTH: usize = 20; ++/// Number of bytes for an SHA256 hash. ++pub const SHA256_DIGEST_LENGTH: usize = 32; ++/// Number of bytes for an SHA384 hash. ++pub const SHA384_DIGEST_LENGTH: usize = 48; ++/// Number of bytes for an SHA512 hash. ++pub const SHA512_DIGEST_LENGTH: usize = 64; ++ ++/// Struct used to generate MD5 hashes. ++#[allow(non_camel_case_types, non_snake_case)] ++#[derive(Clone, Debug, Default, PartialEq)] ++#[repr(C)] ++pub struct CC_MD5_CTX { ++ A: c_uint, ++ B: c_uint, ++ C: c_uint, ++ D: c_uint, ++ Nl: c_uint, ++ Nh: c_uint, ++ data: [c_uint; MD5_LBLOCK], ++ num: c_uint, ++} ++ ++/// Struct used to generate SHA1 hashes. ++#[allow(non_camel_case_types, non_snake_case)] ++#[derive(Clone, Debug, Default, PartialEq)] ++#[repr(C)] ++pub struct CC_SHA_CTX { ++ h0: c_uint, ++ h1: c_uint, ++ h2: c_uint, ++ h3: c_uint, ++ h4: c_uint, ++ Nl: c_uint, ++ Nh: c_uint, ++ data: [c_uint; SHA_LBLOCK], ++ num: c_uint, ++} ++ ++macro_rules! cc_sha2_struct { ++ ($ctx_name: ident, $ty: ty) => { ++ /// Struct used to generate SHA2 hashes with the given bits. ++ #[allow(non_camel_case_types, non_snake_case)] ++ #[derive(Clone, Debug, Default, PartialEq)] ++ #[repr(C)] ++ pub struct $ctx_name { ++ count: [$ty; 2], ++ hash: [$ty; 8], ++ wbuf: [$ty; 16], ++ } ++ } ++} ++ ++cc_sha2_struct!(CC_SHA256_CTX, u32); ++cc_sha2_struct!(CC_SHA512_CTX, u64); ++ ++/// Digest algorithm used in `CCDigest*()` functions. ++#[repr(C)] ++pub enum CCDigestAlgorithm { ++ /// No digest algorithm ++ kCCDigestNone = 0, ++ /// MD2 ++ kCCDigestMD2 = 1, ++ /// MD4 ++ kCCDigestMD4 = 2, ++ /// MD5 ++ kCCDigestMD5 = 3, ++ /// RIPEMD-128 ++ kCCDigestRMD128 = 4, ++ /// RIPEMD-160 ++ kCCDigestRMD160 = 5, ++ /// RIPEMD-256 ++ kCCDigestRMD256 = 6, ++ /// RIPEMD-320 ++ kCCDigestRMD320 = 7, ++ /// SHA1 ++ kCCDigestSHA1 = 8, ++ /// SHA224 ++ kCCDigestSHA224 = 9, ++ /// SHA256 ++ kCCDigestSHA256 = 10, ++ /// SHA384 ++ kCCDigestSHA384 = 11, ++ /// SHA512 ++ kCCDigestSHA512 = 12, ++ /// Skein, 128 bit (Deprecated in iPhoneOS 6.0 and MacOSX10.9) ++ kCCDigestSkein128 = 13, ++ /// Skein, 160 bit (Deprecated in iPhoneOS 6.0 and MacOSX10.9) ++ kCCDigestSkein160 = 14, ++ /// Skein, 224 bit (Deprecated in iPhoneOS 6.0 and MacOSX10.9) ++ kCCDigestSkein224 = 16, ++ /// Skein, 256 bit (Deprecated in iPhoneOS 6.0 and MacOSX10.9) ++ kCCDigestSkein256 = 17, ++ /// Skein, 384 bit (Deprecated in iPhoneOS 6.0 and MacOSX10.9) ++ kCCDigestSkein384 = 18, ++ /// Skein, 512 bit (Deprecated in iPhoneOS 6.0 and MacOSX10.9) ++ kCCDigestSkein512 = 19, ++} ++ ++const CC_DIGEST_SIZE: usize = 1032; ++ ++/// Context used in `CCDigest*()` functions. ++#[allow(non_camel_case_types, non_snake_case)] ++#[repr(C)] ++pub struct CCDigestCtx { ++ context: [u8; CC_DIGEST_SIZE], ++} ++ ++/// Algorithm for use with `CCKeyDerivationPBKDF()`. ++#[repr(C)] ++pub enum CCPBKDFAlgorithm { ++ /// PBKDF2 ++ kCCPBKDF2 = 2, ++} ++ ++/// Pseudo-random algorithm to use with `CCKeyDerivationPBKDF()`. ++#[repr(C)] ++pub enum CCPseudoRandomAlgorithm { ++ /// SHA-1 ++ kCCPRFHmacAlgSHA1 = 1, ++ /// SHA-224 ++ kCCPRFHmacAlgSHA224 = 2, ++ /// SHA-256 ++ kCCPRFHmacAlgSHA256 = 3, ++ /// SHA-384 ++ kCCPRFHmacAlgSHA384 = 4, ++ /// SHA-512 ++ kCCPRFHmacAlgSHA512 = 5, ++} ++ ++extern "C" { ++ /// Initializes MD5 hasher. See `man 3cc CC_MD5` for details. ++ pub fn CC_MD5_Init(ctx: *mut CC_MD5_CTX) -> c_int; ++ /// Appends data to be hashed. See `man 3cc CC_MD5` for details. ++ pub fn CC_MD5_Update(ctx: *mut CC_MD5_CTX, data: *const u8, n: usize) -> c_int; ++ /// Generates MD5 hash. See `man 3cc CC_MD5` for details. ++ pub fn CC_MD5_Final(md: *mut u8, ctx: *mut CC_MD5_CTX) -> c_int; ++ /// Initializes SHA1 hasher. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA1_Init(ctx: *mut CC_SHA_CTX) -> c_int; ++ /// Appends data to be hashed. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA1_Update(ctx: *mut CC_SHA_CTX, data: *const u8, n: usize) -> c_int; ++ /// Generates SHA1 hash. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA1_Final(md: *mut u8, ctx: *mut CC_SHA_CTX) -> c_int; ++ /// Initializes SHA256 hasher. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA256_Init(ctx: *mut CC_SHA256_CTX) -> c_int; ++ /// Appends data to be hashed. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA256_Update(ctx: *mut CC_SHA256_CTX, data: *const u8, n: usize) -> c_int; ++ /// Generates SHA256 hash. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA256_Final(md: *mut u8, ctx: *mut CC_SHA256_CTX) -> c_int; ++ /// Initializes SHA384 hasher. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA384_Init(ctx: *mut CC_SHA512_CTX) -> c_int; ++ /// Appends data to be hashed. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA384_Update(ctx: *mut CC_SHA512_CTX, data: *const u8, n: usize) -> c_int; ++ /// Generates SHA384 hash. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA384_Final(md: *mut u8, ctx: *mut CC_SHA512_CTX) -> c_int; ++ /// Initializes SHA512 hasher. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA512_Init(ctx: *mut CC_SHA512_CTX) -> c_int; ++ /// Appends data to be hashed. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA512_Update(ctx: *mut CC_SHA512_CTX, data: *const u8, n: usize) -> c_int; ++ /// Generates SHA512 hash. See `man 3cc CC_SHA` for details. ++ pub fn CC_SHA512_Final(md: *mut u8, ctx: *mut CC_SHA512_CTX) -> c_int; ++ /// Generic digest hasher. ++ pub fn CCDigest(algorithm: CCDigestAlgorithm, ++ data: *const u8, ++ length: usize, ++ output: *mut u8) ++ -> c_int; ++ /// Allocate and initialize a `CCDigestCtx` for a digest. ++ pub fn CCDigestCreate(algorithm: CCDigestAlgorithm) -> *mut CCDigestCtx; ++ /// Continue to digest data. Returns `0` on success. ++ pub fn CCDigestUpdate(ctx: *mut CCDigestCtx, data: *const u8, length: usize) -> c_int; ++ /// Conclude digest operations and produce the digest output. Returns `0` on success. ++ pub fn CCDigestFinal(ctx: *mut CCDigestCtx, output: *mut u8) -> c_int; ++ /// Clear and free a `CCDigestCtx`. ++ pub fn CCDigestDestroy(ctx: *mut CCDigestCtx); ++ /// Clear and re-initialize a `CCDigestCtx` for the same algorithm. ++ pub fn CCDigestReset(ctx: *mut CCDigestCtx); ++ /// Produce the digest output result for the bytes currently processed. Returns `0` on success. ++ pub fn CCDigestGetDigest(ctx: *mut CCDigestCtx, output: *mut u8) -> c_int; ++ /// Provides the block size of the digest algorithm. Returns `0` on failure. ++ pub fn CCDigestGetBlockSize(algorithm: CCDigestAlgorithm) -> usize; ++ /// Provides the digest output size of the digest algorithm. Returns `0` on failure. ++ pub fn CCDigestGetOutputSize(algorithm: CCDigestAlgorithm) -> usize; ++ /// Provides the block size of the digest algorithm. Returns `0` on failure. ++ pub fn CCDigestGetBlockSizeFromRef(ctx: *mut CCDigestCtx) -> usize; ++ /// Provides the digest output size of the digest algorithm. Returns `0` on failure. ++ pub fn CCDigestGetOutputSizeFromRef(ctx: *mut CCDigestCtx) -> usize; ++ ++ /// Derive a key from a user-supplied password via PBKDF2. ++ pub fn CCKeyDerivationPBKDF(algorithm: CCPBKDFAlgorithm, ++ password: *const u8, ++ passwordLen: usize, ++ salt: *const u8, ++ saltLen: usize, ++ prf: CCPseudoRandomAlgorithm, ++ rounds: u32, ++ derivedKey: *mut u8, ++ derivedKeyLen: usize) ++ -> c_int; ++} diff --cc vendor/commoncrypto-sys-0.2.0/tests/hash.rs index 000000000,000000000..b41ea5497 new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-sys-0.2.0/tests/hash.rs @@@ -1,0 -1,0 +1,138 @@@ ++extern crate commoncrypto_sys; ++extern crate hex; ++ ++use hex::ToHex; ++ ++const TO_HASH: &'static str = "The quick brown fox jumps over the lazy dog"; ++const TO_HASH_MD5: &'static str = "9e107d9d372bb6826bd81d3542a419d6"; ++const TO_HASH_SHA1: &'static str = "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"; ++const TO_HASH_SHA256: &'static str = "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"; ++const TO_HASH_SHA384: &'static str = "ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1"; ++const TO_HASH_SHA512: &'static str = "07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6"; ++ ++macro_rules! test_cc_hash { ++ ( ++ $test_name: ident, ++ $ctx_ty: ident, ++ $digest_len: ident, ++ $init_func: ident, ++ $update_func: ident, ++ $final_func: ident, ++ $expected_hash: ident ++ ) => { ++ #[test] ++ fn $test_name() { ++ let mut ctx = commoncrypto_sys::$ctx_ty::default(); ++ let mut md = [0u8; commoncrypto_sys::$digest_len]; ++ unsafe { ++ assert_eq!(commoncrypto_sys::$init_func(&mut ctx), 1); ++ assert_eq!(commoncrypto_sys::$update_func(&mut ctx, TO_HASH.as_ptr(), TO_HASH.len()), 1); ++ assert_eq!(commoncrypto_sys::$final_func(md.as_mut_ptr(), &mut ctx), 1); ++ } ++ assert_eq!(md.to_vec().to_hex(), $expected_hash); ++ } ++ } ++} ++ ++macro_rules! test_ccdigest { ++ ( ++ $test_name: ident, ++ $algorithm: ident, ++ $digest_len: ident, ++ $expected_hash: ident ++ ) => { ++ #[test] ++ fn $test_name() { ++ let mut md = [0u8; commoncrypto_sys::$digest_len]; ++ unsafe { ++ assert_eq!(commoncrypto_sys::CCDigest(commoncrypto_sys::CCDigestAlgorithm::$algorithm, ++ TO_HASH.as_ptr(), ++ TO_HASH.len(), ++ md.as_mut_ptr()), 0) ++ } ++ assert_eq!(md.to_vec().to_hex(), $expected_hash); ++ } ++ } ++} ++ ++macro_rules! test_ccdigestgetoutputsize { ++ ( ++ $test_name: ident, ++ $algorithm: ident, ++ $expected_digest_len: ident ++ ) => { ++ #[test] ++ fn $test_name() { ++ unsafe { ++ assert_eq!(commoncrypto_sys::CCDigestGetOutputSize(commoncrypto_sys::CCDigestAlgorithm::$algorithm), ++ commoncrypto_sys::$expected_digest_len); ++ } ++ } ++ } ++} ++ ++test_cc_hash!(md5_hash, ++ CC_MD5_CTX, ++ MD5_DIGEST_LENGTH, ++ CC_MD5_Init, ++ CC_MD5_Update, ++ CC_MD5_Final, ++ TO_HASH_MD5); ++test_cc_hash!(sha1_hash, ++ CC_SHA_CTX, ++ SHA1_DIGEST_LENGTH, ++ CC_SHA1_Init, ++ CC_SHA1_Update, ++ CC_SHA1_Final, ++ TO_HASH_SHA1); ++test_cc_hash!(sha256_hash, ++ CC_SHA256_CTX, ++ SHA256_DIGEST_LENGTH, ++ CC_SHA256_Init, ++ CC_SHA256_Update, ++ CC_SHA256_Final, ++ TO_HASH_SHA256); ++test_cc_hash!(sha384_hash, ++ CC_SHA512_CTX, ++ SHA384_DIGEST_LENGTH, ++ CC_SHA384_Init, ++ CC_SHA384_Update, ++ CC_SHA384_Final, ++ TO_HASH_SHA384); ++test_cc_hash!(sha512_hash, ++ CC_SHA512_CTX, ++ SHA512_DIGEST_LENGTH, ++ CC_SHA512_Init, ++ CC_SHA512_Update, ++ CC_SHA512_Final, ++ TO_HASH_SHA512); ++ ++test_ccdigest!(md5_ccdigest, kCCDigestMD5, MD5_DIGEST_LENGTH, TO_HASH_MD5); ++test_ccdigest!(sha1_ccdigest, ++ kCCDigestSHA1, ++ SHA1_DIGEST_LENGTH, ++ TO_HASH_SHA1); ++test_ccdigest!(sha256_ccdigest, ++ kCCDigestSHA256, ++ SHA256_DIGEST_LENGTH, ++ TO_HASH_SHA256); ++test_ccdigest!(sha384_ccdigest, ++ kCCDigestSHA384, ++ SHA384_DIGEST_LENGTH, ++ TO_HASH_SHA384); ++test_ccdigest!(sha512_ccdigest, ++ kCCDigestSHA512, ++ SHA512_DIGEST_LENGTH, ++ TO_HASH_SHA512); ++ ++test_ccdigestgetoutputsize!(md5_ccdigestoutputsize, kCCDigestMD5, MD5_DIGEST_LENGTH); ++test_ccdigestgetoutputsize!(sha1_ccdigestoutputsize, kCCDigestSHA1, SHA1_DIGEST_LENGTH); ++test_ccdigestgetoutputsize!(sha256_ccdigestoutputsize, ++ kCCDigestSHA256, ++ SHA256_DIGEST_LENGTH); ++test_ccdigestgetoutputsize!(sha384_ccdigestoutputsize, ++ kCCDigestSHA384, ++ SHA384_DIGEST_LENGTH); ++test_ccdigestgetoutputsize!(sha512_ccdigestoutputsize, ++ kCCDigestSHA512, ++ SHA512_DIGEST_LENGTH); diff --cc vendor/commoncrypto-sys-0.2.0/tests/pbkdf2.rs index 000000000,000000000..743a49a83 new file mode 100644 --- /dev/null +++ b/vendor/commoncrypto-sys-0.2.0/tests/pbkdf2.rs @@@ -1,0 -1,0 +1,48 @@@ ++extern crate commoncrypto_sys; ++extern crate hex; ++ ++use hex::{ToHex, FromHex}; ++ ++// These password, salts, rounds and derived key values come from the test ++// vectors stated in RFC 6070 ++const PASSWORD: &'static str = "password"; ++const SALT: &'static str = "salt"; ++ ++const DERIVED1: &'static str = "0c60c80f961f0e71f3a9b524af6012062fe037a6"; ++const DERIVED4096: &'static str = "4b007901b765489abead49d926f721d065a429c1"; ++ ++macro_rules! test_pbkdf2 { ++ ( ++ $test_name: ident, ++ $prf_algorithm: ident, ++ $pw: ident, ++ $salt: ident, ++ $rounds: expr, ++ $expected_dkey: ident ++ ) => { ++ #[test] ++ fn $test_name() { ++ let derived_len = Vec::::from_hex($expected_dkey).expect("dkey from hex").len(); ++ let mut pw_derived = vec![0u8; derived_len]; ++ unsafe { ++ assert_eq!(0, commoncrypto_sys::CCKeyDerivationPBKDF( ++ commoncrypto_sys::CCPBKDFAlgorithm::kCCPBKDF2, ++ $pw.as_ptr(), $pw.len(), ++ $salt.as_ptr(), $salt.len(), ++ commoncrypto_sys::CCPseudoRandomAlgorithm::$prf_algorithm, ++ $rounds, ++ pw_derived.as_mut_ptr(), pw_derived.len() ++ )); ++ } ++ assert_eq!($expected_dkey, pw_derived.to_hex()); ++ } ++ } ++} ++ ++test_pbkdf2!(pbkdf2_1, kCCPRFHmacAlgSHA1, PASSWORD, SALT, 1, DERIVED1); ++test_pbkdf2!(pbkdf2_4096, ++ kCCPRFHmacAlgSHA1, ++ PASSWORD, ++ SALT, ++ 4096, ++ DERIVED4096); diff --cc vendor/crossbeam-0.3.0/.cargo-checksum.json index 000000000,000000000..4f7015125 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"8837ab96533202c5b610ed44bc7f4183e7957c1c8f56e8cc78bb098593c8ba0a"} diff --cc vendor/crossbeam-0.3.0/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/.cargo-ok diff --cc vendor/crossbeam-0.3.0/.travis.yml index 000000000,000000000..7e692baaf new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/.travis.yml @@@ -1,0 -1,0 +1,36 @@@ ++language: rust ++# necessary for `travis-cargo coveralls --no-sudo` ++addons: ++ apt: ++ packages: ++ - libcurl4-openssl-dev ++ - libelf-dev ++ - libdw-dev ++ ++# run builds for all the trains (and more) ++rust: ++ - nightly ++ - beta ++ - stable ++ ++# load travis-cargo ++before_script: ++ - | ++ pip install 'travis-cargo<0.2' --user && ++ export PATH=$HOME/.local/bin:$PATH ++ ++# the main build ++script: ++ - | ++ travis-cargo build && ++ travis-cargo test && ++ travis-cargo test -- --release && ++ travis-cargo run -- --bin bench --release && ++ travis-cargo --only stable doc ++env: ++ global: ++ # override the default `--features unstable` used for the nightly branch (optional) ++ - TRAVIS_CARGO_NIGHTLY_FEATURE=nightly ++notifications: ++ email: ++ on_success: never diff --cc vendor/crossbeam-0.3.0/CHANGELOG.md index 000000000,000000000..adea6000e new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/CHANGELOG.md @@@ -1,0 -1,0 +1,22 @@@ ++# Version 0.3 ++ ++- Introduced `ScopedThreadBuilder` with the ability to name threads and set stack size ++- `Worker` methods in the Chase-Lev deque don't require mutable access anymore ++- Fixed a bug when unblocking `pop()` in `MsQueue` ++- Implemented `Drop` for `MsQueue`, `SegQueue`, and `TreiberStack` ++- Implemented `Default` for `TreiberStack` ++- Added `is_empty` to `SegQueue` ++- Renamed `mem::epoch` to `epoch` ++- Other bug fixes ++ ++# Version 0.2 ++ ++- Changed existing non-blocking `pop` methods to `try_pop` ++- Added blocking `pop` support to Michael-Scott queue ++- Added Chase-Lev work-stealing deque ++ ++# Version 0.1 ++ ++- Added [epoch-based memory management](http://aturon.github.io/blog/2015/08/27/epoch/) ++- Added Michael-Scott queue ++- Added Segmented array queue diff --cc vendor/crossbeam-0.3.0/Cargo.toml index 000000000,000000000..bd18ada8c new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/Cargo.toml @@@ -1,0 -1,0 +1,27 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "crossbeam" ++version = "0.3.0" ++authors = ["Aaron Turon "] ++description = "Support for lock-free data structures, synchronizers, and parallel programming" ++documentation = "https://docs.rs/crossbeam" ++readme = "README.md" ++categories = ["concurrency", "data-structures"] ++license = "Apache-2.0/MIT" ++repository = "https://github.com/crossbeam-rs/crossbeam" ++[dev-dependencies.rand] ++version = "0.3" ++ ++[features] ++nightly = [] diff --cc vendor/crossbeam-0.3.0/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/crossbeam-0.3.0/LICENSE-MIT index 000000000,000000000..e69282e38 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++Copyright (c) 2015 The Rust Project Developers ++ ++Permission is hereby granted, free of charge, to any ++person obtaining a copy of this software and associated ++documentation files (the "Software"), to deal in the ++Software without restriction, including without ++limitation the rights to use, copy, modify, merge, ++publish, distribute, sublicense, and/or sell copies of ++the Software, and to permit persons to whom the Software ++is furnished to do so, subject to the following ++conditions: ++ ++The above copyright notice and this permission notice ++shall be included in all copies or substantial portions ++of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ++ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED ++TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A ++PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT ++SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY ++CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR ++IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ++DEALINGS IN THE SOFTWARE. diff --cc vendor/crossbeam-0.3.0/README.md index 000000000,000000000..83c852e6d new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/README.md @@@ -1,0 -1,0 +1,37 @@@ ++# Crossbeam: support for concurrent and parallel programming ++ ++[![Build Status](https://travis-ci.org/crossbeam-rs/crossbeam.svg?branch=master)](https://travis-ci.org/crossbeam-rs/crossbeam) ++ ++This crate is an early work in progress. The focus for the moment is ++concurrency: ++ ++- **Non-blocking data structures**. These data structures allow for high ++performance, highly-concurrent access, much superior to wrapping with a ++`Mutex`. Ultimately the goal is to include stacks, queues, deques, bags, sets ++and maps. ++ ++- **Memory management**. Because non-blocking data structures avoid global ++synchronization, it is not easy to tell when internal data can be safely ++freed. The `mem` module provides generic, easy to use, and high-performance APIs ++for managing memory in these cases. ++ ++- **Synchronization**. The standard library provides a few synchronization ++primitives (locks, barriers, etc) but this crate seeks to expand that set to ++include more advanced/niche primitives, as well as userspace alternatives. ++ ++- **Scoped thread API**. Finally, the crate provides a "scoped" thread API, ++making it possible to spawn threads that share stack data with their parents. ++ ++# Usage ++ ++To use Crossbeam, add this to your `Cargo.toml`: ++ ++```toml ++[dependencies] ++crossbeam = "0.3.0" ++``` ++ ++For examples of what Crossbeam is capable of, see the ++[documentation][docs]. ++ ++[docs]: https://docs.rs/crate/crossbeam/ diff --cc vendor/crossbeam-0.3.0/src/bin/bench.rs index 000000000,000000000..74090e8f3 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/bin/bench.rs @@@ -1,0 -1,0 +1,159 @@@ ++extern crate crossbeam; ++ ++use std::collections::VecDeque; ++use std::sync::Mutex; ++use std::sync::mpsc::channel; ++use std::time::Duration; ++ ++use crossbeam::scope; ++use crossbeam::sync::MsQueue; ++use crossbeam::sync::SegQueue; ++ ++use extra_impls::mpsc_queue::Queue as MpscQueue; ++ ++mod extra_impls; ++ ++const COUNT: u64 = 10000000; ++const THREADS: u64 = 2; ++ ++fn time(f: F) -> Duration { ++ let start = ::std::time::Instant::now(); ++ f(); ++ start.elapsed() ++} ++ ++fn nanos(d: Duration) -> f64 { ++ d.as_secs() as f64 * 1000000000f64 + (d.subsec_nanos() as f64) ++} ++ ++trait Queue { ++ fn push(&self, T); ++ fn try_pop(&self) -> Option; ++} ++ ++impl Queue for MsQueue { ++ fn push(&self, t: T) { self.push(t) } ++ fn try_pop(&self) -> Option { self.try_pop() } ++} ++ ++impl Queue for SegQueue { ++ fn push(&self, t: T) { self.push(t) } ++ fn try_pop(&self) -> Option { self.try_pop() } ++} ++ ++impl Queue for MpscQueue { ++ fn push(&self, t: T) { self.push(t) } ++ fn try_pop(&self) -> Option { ++ use extra_impls::mpsc_queue::*; ++ ++ loop { ++ match self.pop() { ++ Data(t) => return Some(t), ++ Empty => return None, ++ Inconsistent => (), ++ } ++ } ++ } ++} ++ ++impl Queue for Mutex> { ++ fn push(&self, t: T) { self.lock().unwrap().push_back(t) } ++ fn try_pop(&self) -> Option { self.lock().unwrap().pop_front() } ++} ++ ++fn bench_queue_mpsc + Sync>(q: Q) -> f64 { ++ let d = time(|| { ++ scope(|scope| { ++ for _i in 0..THREADS { ++ let qr = &q; ++ scope.spawn(move || { ++ for x in 0..COUNT { ++ let _ = qr.push(x); ++ } ++ }); ++ } ++ ++ let mut count = 0; ++ while count < COUNT*THREADS { ++ if q.try_pop().is_some() { ++ count += 1; ++ } ++ } ++ }); ++ }); ++ ++ nanos(d) / ((COUNT * THREADS) as f64) ++} ++ ++fn bench_queue_mpmc + Sync>(q: Q) -> f64 { ++ use std::sync::atomic::AtomicUsize; ++ use std::sync::atomic::Ordering::Relaxed; ++ ++ let prod_count = AtomicUsize::new(0); ++ ++ let d = time(|| { ++ scope(|scope| { ++ for _i in 0..THREADS { ++ let qr = &q; ++ let pcr = &prod_count; ++ scope.spawn(move || { ++ for _x in 0..COUNT { ++ qr.push(true); ++ } ++ if pcr.fetch_add(1, Relaxed) == (THREADS as usize) - 1 { ++ for _x in 0..THREADS { ++ qr.push(false) ++ } ++ } ++ }); ++ scope.spawn(move || { ++ loop { ++ if let Some(false) = qr.try_pop() { break } ++ } ++ }); ++ } ++ ++ ++ }); ++ }); ++ ++ nanos(d) / ((COUNT * THREADS) as f64) ++} ++ ++fn bench_chan_mpsc() -> f64 { ++ let (tx, rx) = channel(); ++ ++ let d = time(|| { ++ scope(|scope| { ++ for _i in 0..THREADS { ++ let my_tx = tx.clone(); ++ ++ scope.spawn(move || { ++ for x in 0..COUNT { ++ let _ = my_tx.send(x); ++ } ++ }); ++ } ++ ++ for _i in 0..COUNT*THREADS { ++ let _ = rx.recv().unwrap(); ++ } ++ }); ++ }); ++ ++ nanos(d) / ((COUNT * THREADS) as f64) ++} ++ ++fn main() { ++ println!("MSQ mpsc: {}", bench_queue_mpsc(MsQueue::new())); ++ println!("chan mpsc: {}", bench_chan_mpsc()); ++ println!("mpsc mpsc: {}", bench_queue_mpsc(MpscQueue::new())); ++ println!("Seg mpsc: {}", bench_queue_mpsc(SegQueue::new())); ++ ++ println!("MSQ mpmc: {}", bench_queue_mpmc(MsQueue::new())); ++ println!("Seg mpmc: {}", bench_queue_mpmc(SegQueue::new())); ++ ++// println!("queue_mpsc: {}", bench_queue_mpsc()); ++// println!("queue_mpmc: {}", bench_queue_mpmc()); ++// println!("mutex_mpmc: {}", bench_mutex_mpmc()); ++} diff --cc vendor/crossbeam-0.3.0/src/bin/extra_impls/mod.rs index 000000000,000000000..485946a9f new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/bin/extra_impls/mod.rs @@@ -1,0 -1,0 +1,1 @@@ ++pub mod mpsc_queue; diff --cc vendor/crossbeam-0.3.0/src/bin/extra_impls/mpsc_queue.rs index 000000000,000000000..3bff5dc6c new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/bin/extra_impls/mpsc_queue.rs @@@ -1,0 -1,0 +1,155 @@@ ++/* Copyright (c) 2010-2011 Dmitry Vyukov. All rights reserved. ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions are met: ++ * ++ * 1. Redistributions of source code must retain the above copyright notice, ++ * this list of conditions and the following disclaimer. ++ * ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY DMITRY VYUKOV "AS IS" AND ANY EXPRESS OR IMPLIED ++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT ++ * SHALL DMITRY VYUKOV OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ++ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ++ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE ++ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ++ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ * ++ * The views and conclusions contained in the software and documentation are ++ * those of the authors and should not be interpreted as representing official ++ * policies, either expressed or implied, of Dmitry Vyukov. ++ */ ++ ++//! A mostly lock-free multi-producer, single consumer queue. ++//! ++//! This module contains an implementation of a concurrent MPSC queue. This ++//! queue can be used to share data between threads, and is also used as the ++//! building block of channels in rust. ++//! ++//! Note that the current implementation of this queue has a caveat of the `pop` ++//! method, and see the method for more information about it. Due to this ++//! caveat, this queue may not be appropriate for all use-cases. ++ ++// http://www.1024cores.net/home/lock-free-algorithms ++// /queues/non-intrusive-mpsc-node-based-queue ++ ++pub use self::PopResult::*; ++ ++use std::fmt; ++use std::ptr; ++use std::cell::UnsafeCell; ++ ++use std::sync::atomic::{AtomicPtr, Ordering}; ++ ++/// A result of the `pop` function. ++#[derive(Debug)] ++pub enum PopResult { ++ /// Some data has been popped ++ Data(T), ++ /// The queue is empty ++ Empty, ++ /// The queue is in an inconsistent state. Popping data should succeed, but ++ /// some pushers have yet to make enough progress in order allow a pop to ++ /// succeed. It is recommended that a pop() occur "in the near future" in ++ /// order to see if the sender has made progress or not ++ Inconsistent, ++} ++ ++#[derive(Debug)] ++struct Node { ++ next: AtomicPtr>, ++ value: Option, ++} ++ ++/// The multi-producer single-consumer structure. This is not cloneable, but it ++/// may be safely shared so long as it is guaranteed that there is only one ++/// popper at a time (many pushers are allowed). ++pub struct Queue { ++ head: AtomicPtr>, ++ tail: UnsafeCell<*mut Node>, ++} ++ ++impl fmt::Debug for Queue { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "Queue {{ ... }}") ++ } ++} ++ ++unsafe impl Send for Queue { } ++unsafe impl Sync for Queue { } ++ ++impl Node { ++ unsafe fn new(v: Option) -> *mut Node { ++ Box::into_raw(Box::new(Node { ++ next: AtomicPtr::new(ptr::null_mut()), ++ value: v, ++ })) ++ } ++} ++ ++impl Queue { ++ /// Creates a new queue that is safe to share among multiple producers and ++ /// one consumer. ++ pub fn new() -> Queue { ++ let stub = unsafe { Node::new(None) }; ++ Queue { ++ head: AtomicPtr::new(stub), ++ tail: UnsafeCell::new(stub), ++ } ++ } ++ ++ /// Pushes a new value onto this queue. ++ pub fn push(&self, t: T) { ++ unsafe { ++ let n = Node::new(Some(t)); ++ let prev = self.head.swap(n, Ordering::AcqRel); ++ (*prev).next.store(n, Ordering::Release); ++ } ++ } ++ ++ /// Pops some data from this queue. ++ /// ++ /// Note that the current implementation means that this function cannot ++ /// return `Option`. It is possible for this queue to be in an ++ /// inconsistent state where many pushes have succeeded and completely ++ /// finished, but pops cannot return `Some(t)`. This inconsistent state ++ /// happens when a pusher is pre-empted at an inopportune moment. ++ /// ++ /// This inconsistent state means that this queue does indeed have data, but ++ /// it does not currently have access to it at this time. ++ pub fn pop(&self) -> PopResult { ++ unsafe { ++ let tail = *self.tail.get(); ++ let next = (*tail).next.load(Ordering::Acquire); ++ ++ if !next.is_null() { ++ *self.tail.get() = next; ++ assert!((*tail).value.is_none()); ++ assert!((*next).value.is_some()); ++ let ret = (*next).value.take().unwrap(); ++ let _ = Box::from_raw(tail); ++ return Data(ret); ++ } ++ ++ if self.head.load(Ordering::Acquire) == tail {Empty} else {Inconsistent} ++ } ++ } ++} ++ ++impl Drop for Queue { ++ fn drop(&mut self) { ++ unsafe { ++ let mut cur = *self.tail.get(); ++ while !cur.is_null() { ++ let next = (*cur).next.load(Ordering::Relaxed); ++ let _ = Box::from_raw(cur); ++ cur = next; ++ } ++ } ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/bin/stress-msq.rs index 000000000,000000000..7de749642 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/bin/stress-msq.rs @@@ -1,0 -1,0 +1,36 @@@ ++extern crate crossbeam; ++ ++use crossbeam::sync::MsQueue; ++use crossbeam::scope; ++ ++use std::sync::Arc; ++ ++const DUP: usize = 4; ++const THREADS: u32 = 2; ++const COUNT: u64 = 100000; ++ ++fn main() { ++ scope(|s| { ++ for _i in 0..DUP { ++ let q = Arc::new(MsQueue::new()); ++ let qs = q.clone(); ++ ++ s.spawn(move || { ++ for i in 1..COUNT { qs.push(i) } ++ }); ++ ++ for _i in 0..THREADS { ++ let qr = q.clone(); ++ s.spawn(move || { ++ let mut cur: u64 = 0; ++ for _j in 0..COUNT { ++ if let Some(new) = qr.try_pop() { ++ assert!(new > cur); ++ cur = new; ++ } ++ } ++ }); ++ } ++ } ++ }); ++} diff --cc vendor/crossbeam-0.3.0/src/cache_padded.rs index 000000000,000000000..021c32796 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/cache_padded.rs @@@ -1,0 -1,0 +1,149 @@@ ++use std::marker; ++use std::cell::UnsafeCell; ++use std::fmt; ++use std::mem; ++use std::ptr; ++use std::ops::{Deref, DerefMut}; ++ ++// For now, treat this as an arch-independent constant. ++const CACHE_LINE: usize = 32; ++ ++#[cfg_attr(feature = "nightly", ++ repr(simd))] ++#[derive(Debug)] ++struct Padding(u64, u64, u64, u64); ++ ++/// Pad `T` to the length of a cacheline. ++/// ++/// Sometimes concurrent programming requires a piece of data to be padded out ++/// to the size of a cacheline to avoid "false sharing": cachelines being ++/// invalidated due to unrelated concurrent activity. Use the `CachePadded` type ++/// when you want to *avoid* cache locality. ++/// ++/// At the moment, cache lines are assumed to be 32 * sizeof(usize) on all ++/// architectures. ++/// ++/// **Warning**: the wrapped data is never dropped; move out using `ptr::read` ++/// if you need to run dtors. ++pub struct CachePadded { ++ data: UnsafeCell<[usize; CACHE_LINE]>, ++ _marker: ([Padding; 0], marker::PhantomData), ++} ++ ++impl fmt::Debug for CachePadded { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "CachePadded {{ ... }}") ++ } ++} ++ ++unsafe impl Send for CachePadded {} ++unsafe impl Sync for CachePadded {} ++ ++/// Types for which mem::zeroed() is safe. ++/// ++/// If a type `T: ZerosValid`, then a sequence of zeros the size of `T` must be ++/// a valid member of the type `T`. ++pub unsafe trait ZerosValid {} ++ ++#[cfg(feature = "nightly")] ++unsafe impl ZerosValid for .. {} ++ ++macro_rules! zeros_valid { ($( $T:ty )*) => ($( ++ unsafe impl ZerosValid for $T {} ++)*)} ++ ++zeros_valid!(u8 u16 u32 u64 usize); ++zeros_valid!(i8 i16 i32 i64 isize); ++ ++unsafe impl ZerosValid for ::std::sync::atomic::AtomicUsize {} ++unsafe impl ZerosValid for ::std::sync::atomic::AtomicPtr {} ++ ++impl CachePadded { ++ /// A const fn equivalent to mem::zeroed(). ++ #[cfg(not(feature = "nightly"))] ++ pub fn zeroed() -> CachePadded { ++ CachePadded { ++ data: UnsafeCell::new(([0; CACHE_LINE])), ++ _marker: ([], marker::PhantomData), ++ } ++ } ++ ++ /// A const fn equivalent to mem::zeroed(). ++ #[cfg(feature = "nightly")] ++ pub const fn zeroed() -> CachePadded { ++ CachePadded { ++ data: UnsafeCell::new(([0; CACHE_LINE])), ++ _marker: ([], marker::PhantomData), ++ } ++ } ++} ++ ++#[inline] ++/// Assert that the size and alignment of `T` are consistent with `CachePadded`. ++fn assert_valid() { ++ assert!(mem::size_of::() <= mem::size_of::>()); ++ assert!(mem::align_of::() <= mem::align_of::>()); ++} ++ ++impl CachePadded { ++ /// Wrap `t` with cacheline padding. ++ /// ++ /// **Warning**: the wrapped data is never dropped; move out using ++ /// `ptr:read` if you need to run dtors. ++ pub fn new(t: T) -> CachePadded { ++ assert_valid::(); ++ let ret = CachePadded { ++ data: UnsafeCell::new(([0; CACHE_LINE])), ++ _marker: ([], marker::PhantomData), ++ }; ++ unsafe { ++ let p: *mut T = mem::transmute(&ret.data); ++ ptr::write(p, t); ++ } ++ ret ++ } ++} ++ ++impl Deref for CachePadded { ++ type Target = T; ++ fn deref(&self) -> &T { ++ assert_valid::(); ++ unsafe { mem::transmute(&self.data) } ++ } ++} ++ ++impl DerefMut for CachePadded { ++ fn deref_mut(&mut self) -> &mut T { ++ assert_valid::(); ++ unsafe { mem::transmute(&mut self.data) } ++ } ++} ++ ++// FIXME: support Drop by pulling out a version usable for statics ++/* ++impl Drop for CachePadded { ++ fn drop(&mut self) { ++ assert_valid::(); ++ let p: *mut T = mem::transmute(&self.data); ++ mem::drop(ptr::read(p)); ++ } ++} ++*/ ++ ++#[cfg(test)] ++mod test { ++ use super::*; ++ ++ #[test] ++ fn cache_padded_store_u64() { ++ let x: CachePadded = CachePadded::new(17); ++ assert_eq!(*x, 17); ++ } ++ ++ #[test] ++ fn cache_padded_store_pair() { ++ let x: CachePadded<(u64, u64)> = CachePadded::new((17, 37)); ++ assert_eq!(x.0, 17); ++ assert_eq!(x.1, 37); ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/epoch/atomic.rs index 000000000,000000000..1d8e7cec5 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/epoch/atomic.rs @@@ -1,0 -1,0 +1,181 @@@ ++use std::marker::PhantomData; ++use std::mem; ++use std::ptr; ++use std::sync::atomic::{self, Ordering}; ++ ++use super::{Owned, Shared, Guard}; ++ ++/// Like `std::sync::atomic::AtomicPtr`. ++/// ++/// Provides atomic access to a (nullable) pointer of type `T`, interfacing with ++/// the `Owned` and `Shared` types. ++#[derive(Debug)] ++pub struct Atomic { ++ ptr: atomic::AtomicPtr, ++ _marker: PhantomData<*const ()>, ++} ++ ++unsafe impl Send for Atomic {} ++unsafe impl Sync for Atomic {} ++ ++fn opt_shared_into_raw(val: Option>) -> *mut T { ++ val.map(|p| p.as_raw()).unwrap_or(ptr::null_mut()) ++} ++ ++fn opt_owned_as_raw(val: &Option>) -> *mut T { ++ val.as_ref().map(Owned::as_raw).unwrap_or(ptr::null_mut()) ++} ++ ++fn opt_owned_into_raw(val: Option>) -> *mut T { ++ let ptr = val.as_ref().map(Owned::as_raw).unwrap_or(ptr::null_mut()); ++ mem::forget(val); ++ ptr ++} ++ ++impl Atomic { ++ /// Create a new, null atomic pointer. ++ #[cfg(feature = "nightly")] ++ pub const fn null() -> Atomic { ++ Atomic { ++ ptr: atomic::AtomicPtr::new(0 as *mut _), ++ _marker: PhantomData ++ } ++ } ++ ++ #[cfg(not(feature = "nightly"))] ++ pub fn null() -> Atomic { ++ Atomic { ++ ptr: atomic::AtomicPtr::new(0 as *mut _), ++ _marker: PhantomData ++ } ++ } ++ ++ /// Create a new atomic pointer ++ pub fn new(data: T) -> Atomic { ++ Atomic { ++ ptr: atomic::AtomicPtr::new(Box::into_raw(Box::new(data))), ++ _marker: PhantomData ++ } ++ } ++ ++ /// Do an atomic load with the given memory ordering. ++ /// ++ /// In order to perform the load, we must pass in a borrow of a ++ /// `Guard`. This is a way of guaranteeing that the thread has pinned the ++ /// epoch for the entire lifetime `'a`. In return, you get an optional ++ /// `Shared` pointer back (`None` if the `Atomic` is currently null), with ++ /// lifetime tied to the guard. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `ord` is `Release` or `AcqRel`. ++ pub fn load<'a>(&self, ord: Ordering, _: &'a Guard) -> Option> { ++ unsafe { Shared::from_raw(self.ptr.load(ord)) } ++ } ++ ++ /// Do an atomic store with the given memory ordering. ++ /// ++ /// Transfers ownership of the given `Owned` pointer, if any. Since no ++ /// lifetime information is acquired, no `Guard` value is needed. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `ord` is `Acquire` or `AcqRel`. ++ pub fn store(&self, val: Option>, ord: Ordering) { ++ self.ptr.store(opt_owned_into_raw(val), ord) ++ } ++ ++ /// Do an atomic store with the given memory ordering, immediately yielding ++ /// a shared reference to the pointer that was stored. ++ /// ++ /// Transfers ownership of the given `Owned` pointer, yielding a `Shared` ++ /// reference to it. Since the reference is valid only for the curent epoch, ++ /// it's lifetime is tied to a `Guard` value. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `ord` is `Acquire` or `AcqRel`. ++ pub fn store_and_ref<'a>(&self, val: Owned, ord: Ordering, _: &'a Guard) ++ -> Shared<'a, T> ++ { ++ unsafe { ++ let shared = Shared::from_owned(val); ++ self.store_shared(Some(shared), ord); ++ shared ++ } ++ } ++ ++ /// Do an atomic store of a `Shared` pointer with the given memory ordering. ++ /// ++ /// This operation does not require a guard, because it does not yield any ++ /// new information about the lifetime of a pointer. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `ord` is `Acquire` or `AcqRel`. ++ pub fn store_shared(&self, val: Option>, ord: Ordering) { ++ self.ptr.store(opt_shared_into_raw(val), ord) ++ } ++ ++ /// Do a compare-and-set from a `Shared` to an `Owned` pointer with the ++ /// given memory ordering. ++ /// ++ /// As with `store`, this operation does not require a guard; it produces no new ++ /// lifetime information. The `Result` indicates whether the CAS succeeded; if ++ /// not, ownership of the `new` pointer is returned to the caller. ++ pub fn cas(&self, old: Option>, new: Option>, ord: Ordering) ++ -> Result<(), Option>> ++ { ++ if self.ptr.compare_and_swap(opt_shared_into_raw(old), ++ opt_owned_as_raw(&new), ++ ord) == opt_shared_into_raw(old) ++ { ++ mem::forget(new); ++ Ok(()) ++ } else { ++ Err(new) ++ } ++ } ++ ++ /// Do a compare-and-set from a `Shared` to an `Owned` pointer with the ++ /// given memory ordering, immediatley acquiring a new `Shared` reference to ++ /// the previously-owned pointer if successful. ++ /// ++ /// This operation is analogous to `store_and_ref`. ++ pub fn cas_and_ref<'a>(&self, old: Option>, new: Owned, ++ ord: Ordering, _: &'a Guard) ++ -> Result, Owned> ++ { ++ if self.ptr.compare_and_swap(opt_shared_into_raw(old), new.as_raw(), ord) ++ == opt_shared_into_raw(old) ++ { ++ Ok(unsafe { Shared::from_owned(new) }) ++ } else { ++ Err(new) ++ } ++ } ++ ++ /// Do a compare-and-set from a `Shared` to another `Shared` pointer with ++ /// the given memory ordering. ++ /// ++ /// The boolean return value is `true` when the CAS is successful. ++ pub fn cas_shared(&self, old: Option>, new: Option>, ord: Ordering) ++ -> bool ++ { ++ self.ptr.compare_and_swap(opt_shared_into_raw(old), ++ opt_shared_into_raw(new), ++ ord) == opt_shared_into_raw(old) ++ } ++ ++ /// Do an atomic swap with an `Owned` pointer with the given memory ordering. ++ pub fn swap<'a>(&self, new: Option>, ord: Ordering, _: &'a Guard) ++ -> Option> { ++ unsafe { Shared::from_raw(self.ptr.swap(opt_owned_into_raw(new), ord)) } ++ } ++ ++ /// Do an atomic swap with a `Shared` pointer with the given memory ordering. ++ pub fn swap_shared<'a>(&self, new: Option>, ord: Ordering, _: &'a Guard) ++ -> Option> { ++ unsafe { Shared::from_raw(self.ptr.swap(opt_shared_into_raw(new), ord)) } ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/epoch/garbage.rs index 000000000,000000000..9b66653ea new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/epoch/garbage.rs @@@ -1,0 -1,0 +1,144 @@@ ++// Data structures for storing garbage to be freed later (once the ++// epochs have sufficiently advanced). ++// ++// In general, we try to manage the garbage thread locally whenever ++// possible. Each thread keep track of three bags of garbage. But if a ++// thread is exiting, these bags must be moved into the global garbage ++// bags. ++ ++use std::ptr; ++use std::mem; ++use std::sync::atomic::AtomicPtr; ++use std::sync::atomic::Ordering::{Relaxed, Release, Acquire}; ++ ++use ZerosValid; ++ ++/// One item of garbage. ++/// ++/// Stores enough information to do a deallocation. ++#[derive(Debug)] ++struct Item { ++ ptr: *mut u8, ++ free: unsafe fn(*mut u8), ++} ++ ++/// A single, thread-local bag of garbage. ++#[derive(Debug)] ++pub struct Bag(Vec); ++ ++impl Bag { ++ fn new() -> Bag { ++ Bag(vec![]) ++ } ++ ++ fn insert(&mut self, elem: *mut T) { ++ let size = mem::size_of::(); ++ if size > 0 { ++ self.0.push(Item { ++ ptr: elem as *mut u8, ++ free: free::, ++ }) ++ } ++ unsafe fn free(t: *mut u8) { ++ drop(Vec::from_raw_parts(t as *mut T, 0, 1)); ++ } ++ } ++ ++ fn len(&self) -> usize { ++ self.0.len() ++ } ++ ++ /// Deallocate all garbage in the bag ++ pub unsafe fn collect(&mut self) { ++ let mut data = mem::replace(&mut self.0, Vec::new()); ++ for item in data.iter() { ++ (item.free)(item.ptr); ++ } ++ data.truncate(0); ++ self.0 = data; ++ } ++} ++ ++// needed because the bags store raw pointers. ++unsafe impl Send for Bag {} ++unsafe impl Sync for Bag {} ++ ++/// A thread-local set of garbage bags. ++#[derive(Debug)] ++pub struct Local { ++ /// Garbage added at least one epoch behind the current local epoch ++ pub old: Bag, ++ /// Garbage added in the current local epoch or earlier ++ pub cur: Bag, ++ /// Garbage added in the current *global* epoch ++ pub new: Bag, ++} ++ ++impl Local { ++ pub fn new() -> Local { ++ Local { ++ old: Bag::new(), ++ cur: Bag::new(), ++ new: Bag::new(), ++ } ++ } ++ ++ pub fn insert(&mut self, elem: *mut T) { ++ self.new.insert(elem) ++ } ++ ++ /// Collect one epoch of garbage, rotating the local garbage bags. ++ pub unsafe fn collect(&mut self) { ++ let ret = self.old.collect(); ++ mem::swap(&mut self.old, &mut self.cur); ++ mem::swap(&mut self.cur, &mut self.new); ++ ret ++ } ++ ++ pub fn size(&self) -> usize { ++ self.old.len() + self.cur.len() + self.new.len() ++ } ++} ++ ++/// A concurrent garbage bag, currently based on Treiber's stack. ++/// ++/// The elements are themselves owned `Bag`s. ++#[derive(Debug)] ++pub struct ConcBag { ++ head: AtomicPtr, ++} ++ ++unsafe impl ZerosValid for ConcBag {} ++ ++#[derive(Debug)] ++struct Node { ++ data: Bag, ++ next: AtomicPtr, ++} ++ ++impl ConcBag { ++ pub fn insert(&self, t: Bag){ ++ let n = Box::into_raw(Box::new( ++ Node { data: t, next: AtomicPtr::new(ptr::null_mut()) })); ++ loop { ++ let head = self.head.load(Acquire); ++ unsafe { (*n).next.store(head, Relaxed) }; ++ if self.head.compare_and_swap(head, n, Release) == head { break } ++ } ++ } ++ ++ pub unsafe fn collect(&self) { ++ // check to avoid xchg instruction ++ // when no garbage exists ++ let mut head = self.head.load(Relaxed); ++ if head != ptr::null_mut() { ++ head = self.head.swap(ptr::null_mut(), Acquire); ++ ++ while head != ptr::null_mut() { ++ let mut n = Box::from_raw(head); ++ n.data.collect(); ++ head = n.next.load(Relaxed); ++ } ++ } ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/epoch/global.rs index 000000000,000000000..21d993b6e new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/epoch/global.rs @@@ -1,0 -1,0 +1,95 @@@ ++// Definition of global epoch state. The `get` function is the way to ++// access this data externally (until const fn is stabilized...). ++ ++use std::sync::atomic::AtomicUsize; ++ ++use CachePadded; ++use epoch::garbage; ++use epoch::participants::Participants; ++ ++/// Global epoch state ++#[derive(Debug)] ++pub struct EpochState { ++ /// Current global epoch ++ pub epoch: CachePadded, ++ ++ // FIXME: move this into the `garbage` module, rationalize API ++ /// Global garbage bags ++ pub garbage: [CachePadded; 3], ++ ++ /// Participant list ++ pub participants: Participants, ++} ++ ++unsafe impl Send for EpochState {} ++unsafe impl Sync for EpochState {} ++ ++pub use self::imp::get; ++ ++#[cfg(not(feature = "nightly"))] ++mod imp { ++ use std::mem; ++ use std::sync::atomic::{self, AtomicUsize}; ++ use std::sync::atomic::Ordering::Relaxed; ++ ++ use super::EpochState; ++ use CachePadded; ++ use epoch::participants::Participants; ++ ++ impl EpochState { ++ fn new() -> EpochState { ++ EpochState { ++ epoch: CachePadded::zeroed(), ++ garbage: [CachePadded::zeroed(), ++ CachePadded::zeroed(), ++ CachePadded::zeroed()], ++ participants: Participants::new(), ++ } ++ } ++ } ++ ++ static EPOCH: AtomicUsize = atomic::ATOMIC_USIZE_INIT; ++ ++ pub fn get() -> &'static EpochState { ++ let mut addr = EPOCH.load(Relaxed); ++ ++ if addr == 0 { ++ let boxed = Box::new(EpochState::new()); ++ let raw = Box::into_raw(boxed); ++ ++ addr = EPOCH.compare_and_swap(0, raw as usize, Relaxed); ++ if addr != 0 { ++ let boxed = unsafe { Box::from_raw(raw) }; ++ mem::drop(boxed); ++ } else { ++ addr = raw as usize; ++ } ++ } ++ ++ unsafe { ++ &*(addr as *mut EpochState) ++ } ++ } ++} ++ ++#[cfg(feature = "nightly")] ++mod imp { ++ use super::EpochState; ++ use CachePadded; ++ use epoch::participants::Participants; ++ ++ impl EpochState { ++ const fn new() -> EpochState { ++ EpochState { ++ epoch: CachePadded::zeroed(), ++ garbage: [CachePadded::zeroed(), ++ CachePadded::zeroed(), ++ CachePadded::zeroed()], ++ participants: Participants::new(), ++ } ++ } ++ } ++ ++ static EPOCH: EpochState = EpochState::new(); ++ pub fn get() -> &'static EpochState { &EPOCH } ++} diff --cc vendor/crossbeam-0.3.0/src/epoch/guard.rs index 000000000,000000000..4347cdff1 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/epoch/guard.rs @@@ -1,0 -1,0 +1,56 @@@ ++use std::marker; ++ ++use super::{local, Shared}; ++ ++/// An RAII-style guard for pinning the current epoch. ++/// ++/// A guard must be acquired before most operations on an `Atomic` pointer. On ++/// destruction, it unpins the epoch. ++#[must_use] ++#[derive(Debug)] ++pub struct Guard { ++ _marker: marker::PhantomData<*mut ()>, // !Send and !Sync ++} ++ ++/// Pin the current epoch. ++/// ++/// Threads generally pin before interacting with a lock-free data ++/// structure. Pinning requires a full memory barrier, so is somewhat ++/// expensive. It is rentrant -- you can safely acquire nested guards, and only ++/// the first guard requires a barrier. Thus, in cases where you expect to ++/// perform several lock-free operations in quick succession, you may consider ++/// pinning around the entire set of operations. ++pub fn pin() -> Guard { ++ local::with_participant(|p| { ++ let entered = p.enter(); ++ ++ let g = Guard { ++ _marker: marker::PhantomData, ++ }; ++ ++ if entered && p.should_gc() { ++ p.try_collect(&g); ++ } ++ ++ g ++ }) ++} ++ ++impl Guard { ++ /// Assert that the value is no longer reachable from a lock-free data ++ /// structure and should be collected when sufficient epochs have passed. ++ pub unsafe fn unlinked(&self, val: Shared) { ++ local::with_participant(|p| p.reclaim(val.as_raw())) ++ } ++ ++ /// Move the thread-local garbage into the global set of garbage. ++ pub fn migrate_garbage(&self) { ++ local::with_participant(|p| p.migrate_garbage()) ++ } ++} ++ ++impl Drop for Guard { ++ fn drop(&mut self) { ++ local::with_participant(|p| p.exit()); ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/epoch/local.rs index 000000000,000000000..98fdb6013 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/epoch/local.rs @@@ -1,0 -1,0 +1,38 @@@ ++// Manage the thread-local state, providing access to a `Participant` record. ++ ++use std::sync::atomic::Ordering::Relaxed; ++ ++use epoch::participant::Participant; ++use epoch::global; ++ ++#[derive(Debug)] ++struct LocalEpoch { ++ participant: *const Participant, ++} ++ ++impl LocalEpoch { ++ fn new() -> LocalEpoch { ++ LocalEpoch { participant: global::get().participants.enroll() } ++ } ++ ++ fn get(&self) -> &Participant { ++ unsafe { &*self.participant } ++ } ++} ++ ++// FIXME: avoid leaking when all threads have exited ++impl Drop for LocalEpoch { ++ fn drop(&mut self) { ++ let p = self.get(); ++ p.enter(); ++ p.migrate_garbage(); ++ p.exit(); ++ p.active.store(false, Relaxed); ++ } ++} ++ ++thread_local!(static LOCAL_EPOCH: LocalEpoch = LocalEpoch::new() ); ++ ++pub fn with_participant(f: F) -> T where F: FnOnce(&Participant) -> T { ++ LOCAL_EPOCH.with(|e| f(e.get())) ++} diff --cc vendor/crossbeam-0.3.0/src/epoch/mod.rs index 000000000,000000000..17615fc15 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/epoch/mod.rs @@@ -1,0 -1,0 +1,265 @@@ ++//! Epoch-based memory management ++//! ++//! This module provides fast, easy to use memory management for lock free data ++//! structures. It's inspired by [Keir Fraser's *epoch-based ++//! reclamation*](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-579.pdf). ++//! ++//! The basic problem this is solving is the fact that when one thread has ++//! removed a node from a data structure, other threads may still have pointers ++//! to that node (in the form of snapshots that will be validated through things ++//! like compare-and-swap), so the memory cannot be immediately freed. Put differently: ++//! ++//! 1. There are two sources of reachability at play -- the data structure, and ++//! the snapshots in threads accessing it. Before we delete a node, we need to know ++//! that it cannot be reached in either of these ways. ++//! ++//! 2. Once a node has been unlinked from the data structure, no *new* snapshots ++//! reaching it will be created. ++//! ++//! Using the epoch scheme is fairly straightforward, and does not require ++//! understanding any of the implementation details: ++//! ++//! - When operating on a shared data structure, a thread must "pin the current ++//! epoch", which is done by calling `pin()`. This function returns a `Guard` ++//! which unpins the epoch when destroyed. ++//! ++//! - When the thread subsequently reads from a lock-free data structure, the ++//! pointers it extracts act like references with lifetime tied to the ++//! `Guard`. This allows threads to safely read from snapshotted data, being ++//! guaranteed that the data will remain allocated until they exit the epoch. ++//! ++//! To put the `Guard` to use, Crossbeam provides a set of three pointer types meant to work together: ++//! ++//! - `Owned`, akin to `Box`, which points to uniquely-owned data that has ++//! not yet been published in a concurrent data structure. ++//! ++//! - `Shared<'a, T>`, akin to `&'a T`, which points to shared data that may or may ++//! not be reachable from a data structure, but it guaranteed not to be freed ++//! during lifetime `'a`. ++//! ++//! - `Atomic`, akin to `std::sync::atomic::AtomicPtr`, which provides atomic ++//! updates to a pointer using the `Owned` and `Shared` types, and connects them ++//! to a `Guard`. ++//! ++//! Each of these types provides further documentation on usage. ++//! ++//! # Example ++//! ++//! ``` ++//! use std::sync::atomic::Ordering::{Acquire, Release, Relaxed}; ++//! use std::ptr; ++//! ++//! use crossbeam::epoch::{self, Atomic, Owned}; ++//! ++//! struct TreiberStack { ++//! head: Atomic>, ++//! } ++//! ++//! struct Node { ++//! data: T, ++//! next: Atomic>, ++//! } ++//! ++//! impl TreiberStack { ++//! fn new() -> TreiberStack { ++//! TreiberStack { ++//! head: Atomic::null() ++//! } ++//! } ++//! ++//! fn push(&self, t: T) { ++//! // allocate the node via Owned ++//! let mut n = Owned::new(Node { ++//! data: t, ++//! next: Atomic::null(), ++//! }); ++//! ++//! // become active ++//! let guard = epoch::pin(); ++//! ++//! loop { ++//! // snapshot current head ++//! let head = self.head.load(Relaxed, &guard); ++//! ++//! // update `next` pointer with snapshot ++//! n.next.store_shared(head, Relaxed); ++//! ++//! // if snapshot is still good, link in the new node ++//! match self.head.cas_and_ref(head, n, Release, &guard) { ++//! Ok(_) => return, ++//! Err(owned) => n = owned, ++//! } ++//! } ++//! } ++//! ++//! fn pop(&self) -> Option { ++//! // become active ++//! let guard = epoch::pin(); ++//! ++//! loop { ++//! // take a snapshot ++//! match self.head.load(Acquire, &guard) { ++//! // the stack is non-empty ++//! Some(head) => { ++//! // read through the snapshot, *safely*! ++//! let next = head.next.load(Relaxed, &guard); ++//! ++//! // if snapshot is still good, update from `head` to `next` ++//! if self.head.cas_shared(Some(head), next, Release) { ++//! unsafe { ++//! // mark the node as unlinked ++//! guard.unlinked(head); ++//! ++//! // extract out the data from the now-unlinked node ++//! return Some(ptr::read(&(*head).data)) ++//! } ++//! } ++//! } ++//! ++//! // we observed the stack empty ++//! None => return None ++//! } ++//! } ++//! } ++//! } ++//! ``` ++ ++// FIXME: document implementation details ++ ++mod atomic; ++mod garbage; ++mod global; ++mod guard; ++mod local; ++mod participant; ++mod participants; ++ ++pub use self::atomic::Atomic; ++pub use self::guard::{pin, Guard}; ++ ++use std::ops::{Deref, DerefMut}; ++use std::ptr; ++use std::mem; ++ ++/// Like `Box`: an owned, heap-allocated data value of type `T`. ++#[derive(Debug)] ++pub struct Owned { ++ data: Box, ++} ++ ++impl Owned { ++ /// Move `t` to a new heap allocation. ++ pub fn new(t: T) -> Owned { ++ Owned { data: Box::new(t) } ++ } ++ ++ fn as_raw(&self) -> *mut T { ++ self.deref() as *const _ as *mut _ ++ } ++ ++ /// Move data out of the owned box, deallocating the box. ++ pub fn into_inner(self) -> T { ++ *self.data ++ } ++} ++ ++impl Deref for Owned { ++ type Target = T; ++ fn deref(&self) -> &T { ++ &self.data ++ } ++} ++ ++impl DerefMut for Owned { ++ fn deref_mut(&mut self) -> &mut T { ++ &mut self.data ++ } ++} ++ ++#[derive(PartialEq, Eq)] ++/// Like `&'a T`: a shared reference valid for lifetime `'a`. ++#[derive(Debug)] ++pub struct Shared<'a, T: 'a> { ++ data: &'a T, ++} ++ ++impl<'a, T> Copy for Shared<'a, T> {} ++impl<'a, T> Clone for Shared<'a, T> { ++ fn clone(&self) -> Shared<'a, T> { ++ Shared { data: self.data } ++ } ++} ++ ++impl<'a, T> Deref for Shared<'a, T> { ++ type Target = &'a T; ++ fn deref(&self) -> &&'a T { ++ &self.data ++ } ++} ++ ++impl<'a, T> Shared<'a, T> { ++ unsafe fn from_raw(raw: *mut T) -> Option> { ++ if raw == ptr::null_mut() { None } ++ else { ++ Some(Shared { ++ data: mem::transmute::<*mut T, &T>(raw) ++ }) ++ } ++ } ++ ++ unsafe fn from_ref(r: &T) -> Shared<'a, T> { ++ Shared { data: mem::transmute(r) } ++ } ++ ++ unsafe fn from_owned(owned: Owned) -> Shared<'a, T> { ++ let ret = Shared::from_ref(owned.deref()); ++ mem::forget(owned); ++ ret ++ } ++ ++ pub fn as_raw(&self) -> *mut T { ++ self.data as *const _ as *mut _ ++ } ++} ++ ++ ++#[cfg(test)] ++mod test { ++ use std::sync::atomic::Ordering; ++ use super::*; ++ use epoch; ++ ++ #[test] ++ fn test_no_drop() { ++ static mut DROPS: i32 = 0; ++ struct Test; ++ impl Drop for Test { ++ fn drop(&mut self) { ++ unsafe { ++ DROPS += 1; ++ } ++ } ++ } ++ let g = pin(); ++ ++ let x = Atomic::null(); ++ x.store(Some(Owned::new(Test)), Ordering::Relaxed); ++ x.store_and_ref(Owned::new(Test), Ordering::Relaxed, &g); ++ let y = x.load(Ordering::Relaxed, &g); ++ let z = x.cas_and_ref(y, Owned::new(Test), Ordering::Relaxed, &g).ok(); ++ let _ = x.cas(z, Some(Owned::new(Test)), Ordering::Relaxed); ++ x.swap(Some(Owned::new(Test)), Ordering::Relaxed, &g); ++ ++ unsafe { ++ assert_eq!(DROPS, 0); ++ } ++ } ++ ++ #[test] ++ fn test_new() { ++ let guard = epoch::pin(); ++ let my_atomic = Atomic::new(42); ++ ++ assert_eq!(**my_atomic.load(Ordering::Relaxed, &guard).unwrap(), 42); ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/epoch/participant.rs index 000000000,000000000..2ec07775b new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/epoch/participant.rs @@@ -1,0 -1,0 +1,133 @@@ ++// Manages a single participant in the epoch scheme. This is where all ++// of the actual epoch management logic happens! ++ ++use std::mem; ++use std::cell::UnsafeCell; ++use std::fmt; ++use std::sync::atomic::{self, AtomicUsize, AtomicBool}; ++use std::sync::atomic::Ordering::{Relaxed, Acquire, Release, SeqCst}; ++ ++use epoch::{Atomic, Guard, garbage, global}; ++use epoch::participants::ParticipantNode; ++ ++/// Thread-local data for epoch participation. ++pub struct Participant { ++ /// The local epoch. ++ epoch: AtomicUsize, ++ ++ /// Number of pending uses of `epoch::pin()`; keeping a count allows for ++ /// reentrant use of epoch management. ++ in_critical: AtomicUsize, ++ ++ /// Thread-local garbage tracking ++ garbage: UnsafeCell, ++ ++ /// Is the thread still active? Becomes `false` when the thread exits. This ++ /// is ultimately used to free `Participant` records. ++ pub active: AtomicBool, ++ ++ /// The participant list is coded intrusively; here's the `next` pointer. ++ pub next: Atomic, ++} ++ ++impl fmt::Debug for Participant { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "Participant {{ ... }}") ++ } ++} ++ ++unsafe impl Sync for Participant {} ++ ++const GC_THRESH: usize = 32; ++ ++impl Participant { ++ pub fn new() -> Participant { ++ Participant { ++ epoch: AtomicUsize::new(0), ++ in_critical: AtomicUsize::new(0), ++ active: AtomicBool::new(true), ++ garbage: UnsafeCell::new(garbage::Local::new()), ++ next: Atomic::null(), ++ } ++ } ++ ++ /// Enter a critical section. ++ /// ++ /// This method is reentrant, allowing for nested critical sections. ++ /// ++ /// Returns `true` is this is the first entry on the stack (as opposed to a ++ /// re-entrant call). ++ pub fn enter(&self) -> bool { ++ let new_count = self.in_critical.load(Relaxed) + 1; ++ self.in_critical.store(new_count, Relaxed); ++ if new_count > 1 { return false } ++ ++ atomic::fence(SeqCst); ++ ++ let global_epoch = global::get().epoch.load(Relaxed); ++ if global_epoch != self.epoch.load(Relaxed) { ++ self.epoch.store(global_epoch, Relaxed); ++ unsafe { (*self.garbage.get()).collect(); } ++ } ++ ++ true ++ } ++ ++ /// Exit the current (nested) critical section. ++ pub fn exit(&self) { ++ let new_count = self.in_critical.load(Relaxed) - 1; ++ self.in_critical.store( ++ new_count, ++ if new_count > 0 { Relaxed } else { Release }); ++ } ++ ++ /// Begin the reclamation process for a piece of data. ++ pub unsafe fn reclaim(&self, data: *mut T) { ++ (*self.garbage.get()).insert(data); ++ } ++ ++ /// Attempt to collect garbage by moving the global epoch forward. ++ /// ++ /// Returns `true` on success. ++ pub fn try_collect(&self, guard: &Guard) -> bool { ++ let cur_epoch = global::get().epoch.load(SeqCst); ++ ++ for p in global::get().participants.iter(guard) { ++ if p.in_critical.load(Relaxed) > 0 && p.epoch.load(Relaxed) != cur_epoch { ++ return false ++ } ++ } ++ ++ let new_epoch = cur_epoch.wrapping_add(1); ++ atomic::fence(Acquire); ++ if global::get().epoch.compare_and_swap(cur_epoch, new_epoch, SeqCst) != cur_epoch { ++ return false ++ } ++ ++ unsafe { ++ (*self.garbage.get()).collect(); ++ global::get().garbage[new_epoch.wrapping_add(1) % 3].collect(); ++ } ++ self.epoch.store(new_epoch, Release); ++ ++ true ++ } ++ ++ /// Move the current thread-local garbage into the global garbage bags. ++ pub fn migrate_garbage(&self) { ++ let cur_epoch = self.epoch.load(Relaxed); ++ let local = unsafe { mem::replace(&mut *self.garbage.get(), garbage::Local::new()) }; ++ global::get().garbage[cur_epoch.wrapping_sub(1) % 3].insert(local.old); ++ global::get().garbage[cur_epoch % 3].insert(local.cur); ++ global::get().garbage[global::get().epoch.load(Relaxed) % 3].insert(local.new); ++ } ++ ++ /// How much garbage is this participant currently storing? ++ pub fn garbage_size(&self) -> usize { ++ unsafe { (*self.garbage.get()).size() } ++ } ++ /// Is this participant past its local GC threshhold? ++ pub fn should_gc(&self) -> bool { ++ self.garbage_size() >= GC_THRESH ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/epoch/participants.rs index 000000000,000000000..7bd79f378 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/epoch/participants.rs @@@ -1,0 -1,0 +1,120 @@@ ++// Manages the global participant list, which is an intrustive list in ++// which items are lazily removed on traversal (after being ++// "logically" deleted by becoming inactive.) ++ ++use std::mem; ++use std::ops::{Deref, DerefMut}; ++use std::sync::atomic::Ordering::{Relaxed, Acquire, Release}; ++ ++use epoch::{Atomic, Owned, Guard}; ++use epoch::participant::Participant; ++use CachePadded; ++ ++/// Global, threadsafe list of threads participating in epoch management. ++#[derive(Debug)] ++pub struct Participants { ++ head: Atomic ++} ++ ++#[derive(Debug)] ++pub struct ParticipantNode(CachePadded); ++ ++impl ParticipantNode { ++ pub fn new() -> ParticipantNode { ++ ParticipantNode(CachePadded::new(Participant::new())) ++ } ++} ++ ++impl Deref for ParticipantNode { ++ type Target = Participant; ++ fn deref(&self) -> &Participant { ++ &self.0 ++ } ++} ++ ++impl DerefMut for ParticipantNode { ++ fn deref_mut(&mut self) -> &mut Participant { ++ &mut self.0 ++ } ++} ++ ++impl Participants { ++ #[cfg(not(feature = "nightly"))] ++ pub fn new() -> Participants { ++ Participants { head: Atomic::null() } ++ } ++ ++ #[cfg(feature = "nightly")] ++ pub const fn new() -> Participants { ++ Participants { head: Atomic::null() } ++ } ++ ++ /// Enroll a new thread in epoch management by adding a new `Particpant` ++ /// record to the global list. ++ pub fn enroll(&self) -> *const Participant { ++ let mut participant = Owned::new(ParticipantNode::new()); ++ ++ // we ultimately use epoch tracking to free Participant nodes, but we ++ // can't actually enter an epoch here, so fake it; we know the node ++ // can't be removed until marked inactive anyway. ++ let fake_guard = (); ++ let g: &'static Guard = unsafe { mem::transmute(&fake_guard) }; ++ loop { ++ let head = self.head.load(Relaxed, g); ++ participant.next.store_shared(head, Relaxed); ++ match self.head.cas_and_ref(head, participant, Release, g) { ++ Ok(shared) => { ++ let shared: &Participant = &shared; ++ return shared; ++ } ++ Err(owned) => { ++ participant = owned; ++ } ++ } ++ } ++ } ++ ++ pub fn iter<'a>(&'a self, g: &'a Guard) -> Iter<'a> { ++ Iter { ++ guard: g, ++ next: &self.head, ++ needs_acq: true, ++ } ++ } ++} ++ ++#[derive(Debug)] ++pub struct Iter<'a> { ++ // pin to an epoch so that we can free inactive nodes ++ guard: &'a Guard, ++ next: &'a Atomic, ++ ++ // an Acquire read is needed only for the first read, due to release ++ // sequences ++ needs_acq: bool, ++} ++ ++impl<'a> Iterator for Iter<'a> { ++ type Item = &'a Participant; ++ fn next(&mut self) -> Option<&'a Participant> { ++ let mut cur = if self.needs_acq { ++ self.needs_acq = false; ++ self.next.load(Acquire, self.guard) ++ } else { ++ self.next.load(Relaxed, self.guard) ++ }; ++ ++ while let Some(n) = cur { ++ // attempt to clean up inactive nodes ++ if !n.active.load(Relaxed) { ++ cur = n.next.load(Relaxed, self.guard); ++ // TODO: actually reclaim inactive participants! ++ } else { ++ self.next = &n.next; ++ return Some(&n) ++ } ++ } ++ ++ None ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/lib.rs index 000000000,000000000..fbaee22dd new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/lib.rs @@@ -1,0 -1,0 +1,68 @@@ ++//! Support for concurrent and parallel programming. ++//! ++//! This crate is an early work in progress. The focus for the moment is ++//! concurrency: ++//! ++//! - **Non-blocking data structures**. These data structures allow for high ++//! performance, highly-concurrent access, much superior to wrapping with a ++//! `Mutex`. Ultimately the goal is to include stacks, queues, deques, bags, ++//! sets and maps. These live in the `sync` module. ++//! ++//! - **Memory management**. Because non-blocking data structures avoid global ++//! synchronization, it is not easy to tell when internal data can be safely ++//! freed. The `mem` module provides generic, easy to use, and high-performance ++//! APIs for managing memory in these cases. These live in the `mem` module. ++//! ++//! - **Synchronization**. The standard library provides a few synchronization ++//! primitives (locks, barriers, etc) but this crate seeks to expand that set ++//! to include more advanced/niche primitives, as well as userspace ++//! alternatives. These live in the `sync` module. ++//! ++//! - **Scoped thread API**. Finally, the crate provides a "scoped" thread API, ++//! making it possible to spawn threads that share stack data with their ++//! parents. This functionality is exported at the top-level. ++ ++//#![deny(missing_docs)] ++ ++#![cfg_attr(feature = "nightly", ++ feature(const_fn, repr_simd, optin_builtin_traits))] ++ ++use std::thread; ++use std::io; ++ ++pub use scoped::{scope, Scope, ScopedJoinHandle}; ++ ++pub mod epoch; ++pub mod sync; ++mod scoped; ++ ++mod cache_padded; ++pub use self::cache_padded::{CachePadded, ZerosValid}; ++ ++#[doc(hidden)] ++trait FnBox { ++ fn call_box(self: Box); ++} ++ ++impl FnBox for F { ++ fn call_box(self: Box) { (*self)() } ++} ++ ++/// Like `std::thread::spawn`, but without the closure bounds. ++pub unsafe fn spawn_unsafe<'a, F>(f: F) -> thread::JoinHandle<()> where F: FnOnce() + Send + 'a { ++ let builder = thread::Builder::new(); ++ builder_spawn_unsafe(builder, f).unwrap() ++} ++ ++/// Like `std::thread::Builder::spawn`, but without the closure bounds. ++pub unsafe fn builder_spawn_unsafe<'a, F>(builder: thread::Builder, f: F) ++ -> io::Result> ++ where F: FnOnce() + Send + 'a ++{ ++ use std::mem; ++ ++ let closure: Box = Box::new(f); ++ let closure: Box = mem::transmute(closure); ++ builder.spawn(move || closure.call_box()) ++} ++ diff --cc vendor/crossbeam-0.3.0/src/scoped.rs index 000000000,000000000..81ea85fa3 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/scoped.rs @@@ -1,0 -1,0 +1,314 @@@ ++use std::cell::RefCell; ++use std::fmt; ++use std::mem; ++use std::rc::Rc; ++use std::sync::atomic::Ordering; ++use std::sync::Arc; ++use std::thread; ++use std::io; ++ ++use {builder_spawn_unsafe, FnBox}; ++use sync::AtomicOption; ++ ++pub struct Scope<'a> { ++ dtors: RefCell>> ++} ++ ++struct DtorChain<'a> { ++ dtor: Box, ++ next: Option>> ++} ++ ++enum JoinState { ++ Running(thread::JoinHandle<()>), ++ Joined, ++} ++ ++impl JoinState { ++ fn join(&mut self) { ++ let mut state = JoinState::Joined; ++ mem::swap(self, &mut state); ++ if let JoinState::Running(handle) = state { ++ let res = handle.join(); ++ ++ if !thread::panicking() { res.unwrap(); } ++ } ++ } ++} ++ ++/// A handle to a scoped thread ++pub struct ScopedJoinHandle { ++ inner: Rc>, ++ packet: Arc>, ++ thread: thread::Thread, ++} ++ ++/// Create a new `scope`, for deferred destructors. ++/// ++/// Scopes, in particular, support [*scoped thread spawning*](struct.Scope.html#method.spawn). ++/// ++/// # Examples ++/// ++/// Creating and using a scope: ++/// ++/// ``` ++/// crossbeam::scope(|scope| { ++/// scope.defer(|| println!("Exiting scope")); ++/// scope.spawn(|| println!("Running child thread in scope")) ++/// }); ++/// // Prints messages in the reverse order written ++/// ``` ++pub fn scope<'a, F, R>(f: F) -> R where F: FnOnce(&Scope<'a>) -> R { ++ let mut scope = Scope { dtors: RefCell::new(None) }; ++ let ret = f(&scope); ++ scope.drop_all(); ++ ret ++} ++ ++impl<'a> fmt::Debug for Scope<'a> { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "Scope {{ ... }}") ++ } ++} ++ ++impl fmt::Debug for ScopedJoinHandle { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "ScopedJoinHandle {{ ... }}") ++ } ++} ++ ++impl<'a> Scope<'a> { ++ // This method is carefully written in a transactional style, so ++ // that it can be called directly and, if any dtor panics, can be ++ // resumed in the unwinding this causes. By initially running the ++ // method outside of any destructor, we avoid any leakage problems ++ // due to @rust-lang/rust#14875. ++ fn drop_all(&mut self) { ++ loop { ++ // use a separate scope to ensure that the RefCell borrow ++ // is relinquished before running `dtor` ++ let dtor = { ++ let mut dtors = self.dtors.borrow_mut(); ++ if let Some(mut node) = dtors.take() { ++ *dtors = node.next.take().map(|b| *b); ++ node.dtor ++ } else { ++ return ++ } ++ }; ++ dtor.call_box() ++ } ++ } ++ ++ /// Schedule code to be executed when exiting the scope. ++ /// ++ /// This is akin to having a destructor on the stack, except that it is ++ /// *guaranteed* to be run. ++ pub fn defer(&self, f: F) where F: FnOnce() + 'a { ++ let mut dtors = self.dtors.borrow_mut(); ++ *dtors = Some(DtorChain { ++ dtor: Box::new(f), ++ next: dtors.take().map(Box::new) ++ }); ++ } ++ ++ /// Create a scoped thread. ++ /// ++ /// `spawn` is similar to the [`spawn`][spawn] function in Rust's standard library. The ++ /// difference is that this thread is scoped, meaning that it's guaranteed to terminate ++ /// before the current stack frame goes away, allowing you to reference the parent stack frame ++ /// directly. This is ensured by having the parent thread join on the child thread before the ++ /// scope exits. ++ /// ++ /// [spawn]: http://doc.rust-lang.org/std/thread/fn.spawn.html ++ /// ++ /// # Examples ++ /// ++ /// A basic scoped thread: ++ /// ++ /// ``` ++ /// crossbeam::scope(|scope| { ++ /// scope.spawn(|| { ++ /// println!("Hello from a scoped thread!"); ++ /// }); ++ /// }); ++ /// ``` ++ /// ++ /// When writing concurrent Rust programs, you'll sometimes see a pattern like this, using ++ /// [`std::thread::spawn`][spawn]: ++ /// ++ /// ```ignore ++ /// let array = [1, 2, 3]; ++ /// let mut guards = vec![]; ++ /// ++ /// for i in &array { ++ /// let guard = std::thread::spawn(move || { ++ /// println!("element: {}", i); ++ /// }); ++ /// ++ /// guards.push(guard); ++ /// } ++ /// ++ /// for guard in guards { ++ /// guard.join().unwrap(); ++ /// } ++ /// ``` ++ /// ++ /// The basic pattern is: ++ /// ++ /// 1. Iterate over some collection. ++ /// 2. Spin up a thread to operate on each part of the collection. ++ /// 3. Join all the threads. ++ /// ++ /// However, this code actually gives an error: ++ /// ++ /// ```text ++ /// error: `array` does not live long enough ++ /// for i in &array { ++ /// ^~~~~ ++ /// in expansion of for loop expansion ++ /// note: expansion site ++ /// note: reference must be valid for the static lifetime... ++ /// note: ...but borrowed value is only valid for the block suffix following statement 0 at ... ++ /// let array = [1, 2, 3]; ++ /// let mut guards = vec![]; ++ /// ++ /// for i in &array { ++ /// let guard = std::thread::spawn(move || { ++ /// println!("element: {}", i); ++ /// ... ++ /// error: aborting due to previous error ++ /// ``` ++ /// ++ /// Because [`std::thread::spawn`][spawn] doesn't know about this scope, it requires a ++ /// `'static` lifetime. One way of giving it a proper lifetime is to use an [`Arc`][arc]: ++ /// ++ /// [arc]: http://doc.rust-lang.org/stable/std/sync/struct.Arc.html ++ /// ++ /// ``` ++ /// use std::sync::Arc; ++ /// ++ /// let array = Arc::new([1, 2, 3]); ++ /// let mut guards = vec![]; ++ /// ++ /// for i in 0..array.len() { ++ /// let a = array.clone(); ++ /// ++ /// let guard = std::thread::spawn(move || { ++ /// println!("element: {}", a[i]); ++ /// }); ++ /// ++ /// guards.push(guard); ++ /// } ++ /// ++ /// for guard in guards { ++ /// guard.join().unwrap(); ++ /// } ++ /// ``` ++ /// ++ /// But this introduces unnecessary allocation, as `Arc` puts its data on the heap, and we ++ /// also end up dealing with reference counts. We know that we're joining the threads before ++ /// our function returns, so just taking a reference _should_ be safe. Rust can't know that, ++ /// though. ++ /// ++ /// Enter scoped threads. Here's our original example, using `spawn` from crossbeam rather ++ /// than from `std::thread`: ++ /// ++ /// ``` ++ /// let array = [1, 2, 3]; ++ /// ++ /// crossbeam::scope(|scope| { ++ /// for i in &array { ++ /// scope.spawn(move || { ++ /// println!("element: {}", i); ++ /// }); ++ /// } ++ /// }); ++ /// ``` ++ /// ++ /// Much more straightforward. ++ pub fn spawn(&self, f: F) -> ScopedJoinHandle where ++ F: FnOnce() -> T + Send + 'a, T: Send + 'a ++ { ++ self.builder().spawn(f).unwrap() ++ } ++ ++ /// Generates the base configuration for spawning a scoped thread, from which configuration ++ /// methods can be chained. ++ pub fn builder<'s>(&'s self) -> ScopedThreadBuilder<'s, 'a> { ++ ScopedThreadBuilder { ++ scope: self, ++ builder: thread::Builder::new(), ++ } ++ } ++} ++ ++/// Scoped thread configuration. Provides detailed control over the properties and behavior of new ++/// scoped threads. ++pub struct ScopedThreadBuilder<'s, 'a: 's> { ++ scope: &'s Scope<'a>, ++ builder: thread::Builder, ++} ++ ++impl<'s, 'a: 's> ScopedThreadBuilder<'s, 'a> { ++ /// Names the thread-to-be. Currently the name is used for identification only in panic ++ /// messages. ++ pub fn name(mut self, name: String) -> ScopedThreadBuilder<'s, 'a> { ++ self.builder = self.builder.name(name); ++ self ++ } ++ ++ /// Sets the size of the stack for the new thread. ++ pub fn stack_size(mut self, size: usize) -> ScopedThreadBuilder<'s, 'a> { ++ self.builder = self.builder.stack_size(size); ++ self ++ } ++ ++ /// Spawns a new thread, and returns a join handle for it. ++ pub fn spawn(self, f: F) -> io::Result> ++ where F: FnOnce() -> T + Send + 'a, T: Send + 'a ++ { ++ let their_packet = Arc::new(AtomicOption::new()); ++ let my_packet = their_packet.clone(); ++ ++ let join_handle = try!(unsafe { ++ builder_spawn_unsafe(self.builder, move || { ++ their_packet.swap(f(), Ordering::Relaxed); ++ }) ++ }); ++ ++ let thread = join_handle.thread().clone(); ++ let deferred_handle = Rc::new(RefCell::new(JoinState::Running(join_handle))); ++ let my_handle = deferred_handle.clone(); ++ ++ self.scope.defer(move || { ++ let mut state = deferred_handle.borrow_mut(); ++ state.join(); ++ }); ++ ++ Ok(ScopedJoinHandle { ++ inner: my_handle, ++ packet: my_packet, ++ thread: thread, ++ }) ++ } ++} ++ ++impl ScopedJoinHandle { ++ /// Join the scoped thread, returning the result it produced. ++ pub fn join(self) -> T { ++ self.inner.borrow_mut().join(); ++ self.packet.take(Ordering::Relaxed).unwrap() ++ } ++ ++ /// Get the underlying thread handle. ++ pub fn thread(&self) -> &thread::Thread { ++ &self.thread ++ } ++} ++ ++impl<'a> Drop for Scope<'a> { ++ fn drop(&mut self) { ++ self.drop_all() ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/sync/arc_cell.rs index 000000000,000000000..e26d45a94 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/sync/arc_cell.rs @@@ -1,0 -1,0 +1,90 @@@ ++use std::marker::PhantomData; ++use std::mem; ++use std::sync::Arc; ++use std::sync::atomic::{AtomicUsize, Ordering}; ++ ++/// A type providing atomic storage and retrieval of an `Arc`. ++#[derive(Debug)] ++pub struct ArcCell(AtomicUsize, PhantomData>); ++ ++impl Drop for ArcCell { ++ fn drop(&mut self) { ++ self.take(); ++ } ++} ++ ++impl ArcCell { ++ /// Creates a new `ArcCell`. ++ pub fn new(t: Arc) -> ArcCell { ++ ArcCell(AtomicUsize::new(unsafe { mem::transmute(t) }), PhantomData) ++ } ++ ++ fn take(&self) -> Arc { ++ loop { ++ match self.0.swap(0, Ordering::Acquire) { ++ 0 => {} ++ n => return unsafe { mem::transmute(n) } ++ } ++ } ++ } ++ ++ fn put(&self, t: Arc) { ++ debug_assert_eq!(self.0.load(Ordering::SeqCst), 0); ++ self.0.store(unsafe { mem::transmute(t) }, Ordering::Release); ++ } ++ ++ /// Stores a new value in the `ArcCell`, returning the previous ++ /// value. ++ pub fn set(&self, t: Arc) -> Arc { ++ let old = self.take(); ++ self.put(t); ++ old ++ } ++ ++ /// Returns a copy of the value stored by the `ArcCell`. ++ pub fn get(&self) -> Arc { ++ let t = self.take(); ++ // NB: correctness here depends on Arc's clone impl not panicking ++ let out = t.clone(); ++ self.put(t); ++ out ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use std::sync::Arc; ++ use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering}; ++ ++ use super::*; ++ ++ #[test] ++ fn basic() { ++ let r = ArcCell::new(Arc::new(0)); ++ assert_eq!(*r.get(), 0); ++ assert_eq!(*r.set(Arc::new(1)), 0); ++ assert_eq!(*r.get(), 1); ++ } ++ ++ #[test] ++ fn drop_runs() { ++ static DROPS: AtomicUsize = ATOMIC_USIZE_INIT; ++ ++ struct Foo; ++ ++ impl Drop for Foo { ++ fn drop(&mut self) { ++ DROPS.fetch_add(1, Ordering::SeqCst); ++ } ++ } ++ ++ let r = ArcCell::new(Arc::new(Foo)); ++ let _f = r.get(); ++ r.get(); ++ r.set(Arc::new(Foo)); ++ drop(_f); ++ assert_eq!(DROPS.load(Ordering::SeqCst), 1); ++ drop(r); ++ assert_eq!(DROPS.load(Ordering::SeqCst), 2); ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/sync/atomic_option.rs index 000000000,000000000..b67460670 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/sync/atomic_option.rs @@@ -1,0 -1,0 +1,38 @@@ ++use std::sync::atomic::{AtomicPtr, Ordering}; ++use std::ptr; ++ ++unsafe impl Send for AtomicOption {} ++unsafe impl Sync for AtomicOption {} ++ ++#[derive(Debug)] ++pub struct AtomicOption { ++ inner: AtomicPtr, ++} ++ ++impl AtomicOption { ++ pub fn new() -> AtomicOption { ++ AtomicOption { inner: AtomicPtr::new(ptr::null_mut()) } ++ } ++ ++ fn swap_inner(&self, ptr: *mut T, order: Ordering) -> Option> { ++ let old = self.inner.swap(ptr, order); ++ if old.is_null() { ++ None ++ } else { ++ Some(unsafe { Box::from_raw(old) }) ++ } ++ } ++ ++ // allows re-use of allocation ++ pub fn swap_box(&self, t: Box, order: Ordering) -> Option> { ++ self.swap_inner(Box::into_raw(t), order) ++ } ++ ++ pub fn swap(&self, t: T, order: Ordering) -> Option { ++ self.swap_box(Box::new(t), order).map(|old| *old) ++ } ++ ++ pub fn take(&self, order: Ordering) -> Option { ++ self.swap_inner(ptr::null_mut(), order).map(|old| *old) ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/sync/chase_lev.rs index 000000000,000000000..7f6aa0915 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/sync/chase_lev.rs @@@ -1,0 -1,0 +1,605 @@@ ++// Copyright 2013 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! A lock-free concurrent work-stealing deque ++//! ++//! This module contains a hybrid implementation of the Chase-Lev work stealing deque ++//! described in ["Dynamic Circular Work-Stealing Deque"][chase_lev] and the improved version ++//! described in ["Correct and Efficient Work-Stealing for Weak Memory Models"][weak_chase_lev]. ++//! The implementation is heavily based on the pseudocode found in the papers. ++//! ++//! # Example ++//! ++//! ``` ++//! use crossbeam::sync::chase_lev; ++//! let (worker, stealer) = chase_lev::deque(); ++//! ++//! // Only the worker may push/try_pop ++//! worker.push(1); ++//! worker.try_pop(); ++//! ++//! // Stealers take data from the other end of the deque ++//! worker.push(1); ++//! stealer.steal(); ++//! ++//! // Stealers can be cloned to have many stealers stealing in parallel ++//! worker.push(1); ++//! let stealer2 = stealer.clone(); ++//! stealer2.steal(); ++//! ``` ++//! ++//! [chase_lev]: http://neteril.org/~jeremie/Dynamic_Circular_Work_Queue.pdf ++//! [weak_chase_lev]: http://www.di.ens.fr/~zappa/readings/ppopp13.pdf ++ ++use std::cell::UnsafeCell; ++use std::fmt; ++use std::mem; ++use std::ptr; ++use std::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst}; ++use std::sync::atomic::{AtomicIsize, fence}; ++use std::sync::Arc; ++use std::marker::PhantomData; ++use std::cell::Cell; ++ ++use epoch::{self, Atomic, Shared, Owned}; ++ ++// Once the queue is less than 1/K full, then it will be downsized. Note that ++// the deque requires that this number be less than 2. ++const K: isize = 4; ++ ++// Minimum number of bits that a buffer size should be. No buffer will resize to ++// under this value, and all deques will initially contain a buffer of this ++// size. ++// ++// The size in question is 1 << MIN_BITS ++const MIN_BITS: u32 = 7; ++ ++#[derive(Debug)] ++struct Deque { ++ bottom: AtomicIsize, ++ top: AtomicIsize, ++ array: Atomic>, ++} ++ ++// FIXME: can these constraints be relaxed? ++unsafe impl Send for Deque {} ++unsafe impl Sync for Deque {} ++ ++/// Worker half of the work-stealing deque. This worker has exclusive access to ++/// one side of the deque, and uses `push` and `try_pop` method to manipulate it. ++/// ++/// There may only be one worker per deque, so `Worker` does not implement ++/// `Clone` or `Copy`. ++#[derive(Debug)] ++pub struct Worker { ++ deque: Arc>, ++ ++ // Marker so that the Worker is Send but not Sync. The worker can only be ++ // accessed from a single thread at once. Ideally we would use a negative ++ // impl here but these are not stable yet. ++ marker: PhantomData>, ++} ++ ++/// The stealing half of the work-stealing deque. Stealers have access to the ++/// opposite end of the deque from the worker, and they only have access to the ++/// `steal` method. ++/// ++/// Stealers can be cloned to have more than one handle active at a time. ++#[derive(Debug)] ++pub struct Stealer { ++ deque: Arc>, ++} ++ ++/// When stealing some data, this is an enumeration of the possible outcomes. ++#[derive(PartialEq, Eq, Debug)] ++pub enum Steal { ++ /// The deque was empty at the time of stealing ++ Empty, ++ /// The stealer lost the race for stealing data, and a retry may return more ++ /// data. ++ Abort, ++ /// The stealer has successfully stolen some data. ++ Data(T), ++} ++ ++// An internal buffer used by the chase-lev deque. This structure is actually ++// implemented as a circular buffer, and is used as the intermediate storage of ++// the data in the deque. ++// ++// This Vec always has a length of 0, the backing buffer is just used by the ++// code below. ++struct Buffer { ++ storage: UnsafeCell>, ++ log_size: u32, ++} ++ ++impl fmt::Debug for Buffer { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "Buffer {{ ... }}") ++ } ++} ++ ++impl Worker { ++ /// Pushes data onto the front of this work queue. ++ pub fn push(&self, t: T) { ++ unsafe { self.deque.push(t) } ++ } ++ ++ /// Pops data off the front of the work queue, returning `None` on an empty ++ /// queue. ++ pub fn try_pop(&self) -> Option { ++ unsafe { self.deque.try_pop() } ++ } ++} ++ ++impl Stealer { ++ /// Steals work off the end of the queue (opposite of the worker's end) ++ pub fn steal(&self) -> Steal { ++ self.deque.steal() ++ } ++} ++ ++impl Clone for Stealer { ++ fn clone(&self) -> Stealer { ++ Stealer { deque: self.deque.clone() } ++ } ++} ++ ++/// Creates a new empty deque ++pub fn deque() -> (Worker, Stealer) { ++ let a = Arc::new(Deque::new()); ++ let b = a.clone(); ++ (Worker { deque: a, marker: PhantomData }, Stealer { deque: b }) ++} ++ ++// Almost all of this code can be found directly in the paper so I'm not ++// personally going to heavily comment what's going on here. ++ ++impl Deque { ++ fn new() -> Deque { ++ let array = Atomic::null(); ++ array.store(Some(Owned::new(Buffer::new(MIN_BITS))), SeqCst); ++ Deque { ++ bottom: AtomicIsize::new(0), ++ top: AtomicIsize::new(0), ++ array: array, ++ } ++ } ++ ++ unsafe fn push(&self, data: T) { ++ let guard = epoch::pin(); ++ ++ let mut b = self.bottom.load(Relaxed); ++ let t = self.top.load(Acquire); ++ let mut a = self.array.load(Relaxed, &guard).unwrap(); ++ ++ let size = b - t; ++ if size >= (a.size() as isize) - 1 { ++ // You won't find this code in the chase-lev deque paper. This is ++ // alluded to in a small footnote, however. We always free a buffer ++ // when growing in order to prevent leaks. ++ a = self.swap_buffer(a, a.resize(b, t, 1), &guard); ++ ++ // reload the bottom counter, since swap_buffer modifies it. ++ b = self.bottom.load(Relaxed); ++ } ++ a.put(b, data); ++ fence(Release); ++ self.bottom.store(b + 1, Relaxed); ++ } ++ ++ unsafe fn try_pop(&self) -> Option { ++ let guard = epoch::pin(); ++ ++ let b = self.bottom.load(Relaxed); ++ let a = self.array.load(Relaxed, &guard).unwrap(); ++ self.bottom.store(b - 1, Relaxed); ++ fence(SeqCst); // the store to bottom must occur before loading top. ++ let t = self.top.load(Relaxed); ++ ++ let size = b - t; ++ ++ if size <= 0 { ++ // empty queue. revert the decrement of bottom. ++ self.bottom.store(b, Relaxed); ++ None ++ } else if size >= 2 { ++ // non-racy case. return the data ++ let data = a.get(b - 1); ++ self.maybe_shrink(b - 1, t, &guard); ++ Some(data) ++ } else { ++ // racy case. race against steals. ++ let success = self.top.compare_and_swap(t, t + 1, SeqCst) == t; ++ ++ // set the queue to a canonically empty state. ++ self.bottom.store(b, Relaxed); ++ ++ if success { ++ Some(a.get(t)) ++ } else { ++ None ++ } ++ } ++ } ++ ++ fn steal(&self) -> Steal { ++ let guard = epoch::pin(); ++ ++ let t = self.top.load(Relaxed); ++ fence(SeqCst); // top must be loaded before bottom. ++ let b = self.bottom.load(Acquire); ++ ++ let size = b - t; ++ if size <= 0 { ++ return Steal::Empty ++ } ++ ++ unsafe { ++ // while the paper uses a "consume" ordering here, the closest thing we have ++ // available is Acquire, which is strictly stronger. ++ let a = self.array.load(Acquire, &guard).unwrap(); ++ let data = a.get(t); ++ // we may be racing against other steals and a pop. ++ if self.top.compare_and_swap(t, t + 1, SeqCst) == t { ++ Steal::Data(data) ++ } else { ++ mem::forget(data); // someone else stole this value ++ Steal::Abort ++ } ++ } ++ } ++ ++ // potentially shrink the array. This can be called only from the worker. ++ unsafe fn maybe_shrink(&self, b: isize, t: isize, guard: &epoch::Guard) { ++ let a = self.array.load(SeqCst, guard).unwrap(); ++ let size = b - t; ++ if size < (a.size() as isize) / K && size > (1 << MIN_BITS) { ++ self.swap_buffer(a, a.resize(b, t, -1), guard); ++ } ++ } ++ ++ // Helper routine not mentioned in the paper which is used in growing and ++ // shrinking buffers to swap in a new buffer into place. ++ // ++ // As a bit of a recap, stealers can continue using buffers after this ++ // method has called 'unlinked' on it. The continued usage is simply a read ++ // followed by a forget, but we must make sure that the memory can continue ++ // to be read after we flag this buffer for reclamation. All stealers, ++ // however, have their own epoch pinned during this time so the buffer will ++ // just naturally be free'd once all concurrent stealers have exited. ++ // ++ // This method may only be called safely from the workers due to the way it modifies ++ // the array pointer. ++ unsafe fn swap_buffer<'a>(&self, ++ old: Shared<'a, Buffer>, ++ buf: Buffer, ++ guard: &'a epoch::Guard) ++ -> Shared<'a, Buffer> { ++ let newbuf = Owned::new(buf); ++ let newbuf = self.array.store_and_ref(newbuf, Release, &guard); ++ guard.unlinked(old); ++ ++ newbuf ++ } ++} ++ ++ ++impl Drop for Deque { ++ fn drop(&mut self) { ++ let guard = epoch::pin(); ++ ++ // Arc enforces that we have truly exclusive access here. ++ ++ let t = self.top.load(Relaxed); ++ let b = self.bottom.load(Relaxed); ++ let a = self.array.swap(None, Relaxed, &guard).unwrap(); ++ // Free whatever is leftover in the dequeue, then free the backing ++ // memory itself ++ unsafe { ++ for i in t..b { ++ drop(a.get(i)); ++ } ++ guard.unlinked(a); ++ } ++ } ++} ++ ++impl Buffer { ++ fn new(log_size: u32) -> Buffer { ++ Buffer { ++ storage: UnsafeCell::new(Vec::with_capacity(1 << log_size)), ++ log_size: log_size, ++ } ++ } ++ ++ fn size(&self) -> usize { ++ unsafe { (*self.storage.get()).capacity() } ++ } ++ ++ fn mask(&self) -> isize { ++ unsafe { ++ ((*self.storage.get()).capacity() - 1) as isize ++ } ++ } ++ ++ unsafe fn elem(&self, i: isize) -> *mut T { ++ (*self.storage.get()).as_mut_ptr().offset(i & self.mask()) ++ } ++ ++ // This does not protect against loading duplicate values of the same cell, ++ // nor does this clear out the contents contained within. Hence, this is a ++ // very unsafe method which the caller needs to treat specially in case a ++ // race is lost. ++ unsafe fn get(&self, i: isize) -> T { ++ ptr::read(self.elem(i)) ++ } ++ ++ // Unsafe because this unsafely overwrites possibly uninitialized or ++ // initialized data. ++ unsafe fn put(&self, i: isize, t: T) { ++ ptr::write(self.elem(i), t); ++ } ++ ++ // Again, unsafe because this has incredibly dubious ownership violations. ++ // It is assumed that this buffer is immediately dropped. ++ unsafe fn resize(&self, b: isize, t: isize, delta: i32) -> Buffer { ++ let buf = Buffer::new(((self.log_size as i32) + delta) as u32); ++ for i in t..b { ++ buf.put(i, self.get(i)); ++ } ++ return buf; ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ extern crate rand; ++ ++ use super::{deque, Worker, Stealer, Steal}; ++ ++ use std::thread; ++ use std::sync::Arc; ++ use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, ++ AtomicUsize, ATOMIC_USIZE_INIT}; ++ use std::sync::atomic::Ordering::SeqCst; ++ ++ use self::rand::Rng; ++ ++ #[test] ++ fn smoke() { ++ let (w, s) = deque(); ++ assert_eq!(w.try_pop(), None); ++ assert_eq!(s.steal(), Steal::Empty); ++ w.push(1); ++ assert_eq!(w.try_pop(), Some(1)); ++ w.push(1); ++ assert_eq!(s.steal(), Steal::Data(1)); ++ w.push(1); ++ assert_eq!(s.clone().steal(), Steal::Data(1)); ++ } ++ ++ #[test] ++ fn stealpush() { ++ static AMT: isize = 100000; ++ let (w, s) = deque(); ++ let t = thread::spawn(move || { ++ let mut left = AMT; ++ while left > 0 { ++ match s.steal() { ++ Steal::Data(i) => { ++ assert_eq!(i, 1); ++ left -= 1; ++ } ++ Steal::Abort | Steal::Empty => {} ++ } ++ } ++ }); ++ ++ for _ in 0..AMT { ++ w.push(1); ++ } ++ ++ t.join().unwrap(); ++ } ++ ++ #[test] ++ fn stealpush_large() { ++ static AMT: isize = 100000; ++ let (w, s) = deque(); ++ let t = thread::spawn(move || { ++ let mut left = AMT; ++ while left > 0 { ++ match s.steal() { ++ Steal::Data((1, 10)) => { left -= 1; } ++ Steal::Data(..) => panic!(), ++ Steal::Abort | Steal::Empty => {} ++ } ++ } ++ }); ++ ++ for _ in 0..AMT { ++ w.push((1, 10)); ++ } ++ ++ t.join().unwrap(); ++ } ++ ++ fn stampede(w: Worker>, ++ s: Stealer>, ++ nthreads: isize, ++ amt: usize) { ++ for _ in 0..amt { ++ w.push(Box::new(20)); ++ } ++ let remaining = Arc::new(AtomicUsize::new(amt)); ++ ++ let threads = (0..nthreads).map(|_| { ++ let remaining = remaining.clone(); ++ let s = s.clone(); ++ thread::spawn(move || { ++ while remaining.load(SeqCst) > 0 { ++ match s.steal() { ++ Steal::Data(val) => { ++ if *val == 20 { ++ remaining.fetch_sub(1, SeqCst); ++ } else { ++ panic!() ++ } ++ } ++ Steal::Abort | Steal::Empty => {} ++ } ++ } ++ }) ++ }).collect::>(); ++ ++ while remaining.load(SeqCst) > 0 { ++ if let Some(val) = w.try_pop() { ++ if *val == 20 { ++ remaining.fetch_sub(1, SeqCst); ++ } else { ++ panic!() ++ } ++ } ++ } ++ ++ for thread in threads.into_iter() { ++ thread.join().unwrap(); ++ } ++ } ++ ++ #[test] ++ fn run_stampede() { ++ let (w, s) = deque(); ++ stampede(w, s, 8, 10000); ++ } ++ ++ #[test] ++ fn many_stampede() { ++ static AMT: usize = 4; ++ let threads = (0..AMT).map(|_| { ++ let (w, s) = deque(); ++ thread::spawn(|| { ++ stampede(w, s, 4, 10000); ++ }) ++ }).collect::>(); ++ ++ for thread in threads.into_iter() { ++ thread.join().unwrap(); ++ } ++ } ++ ++ #[test] ++ fn stress() { ++ static AMT: isize = 100000; ++ static NTHREADS: isize = 8; ++ static DONE: AtomicBool = ATOMIC_BOOL_INIT; ++ static HITS: AtomicUsize = ATOMIC_USIZE_INIT; ++ let (w, s) = deque(); ++ ++ let threads = (0..NTHREADS).map(|_| { ++ let s = s.clone(); ++ thread::spawn(move || { ++ loop { ++ match s.steal() { ++ Steal::Data(2) => { HITS.fetch_add(1, SeqCst); } ++ Steal::Data(..) => panic!(), ++ _ if DONE.load(SeqCst) => break, ++ _ => {} ++ } ++ } ++ }) ++ }).collect::>(); ++ ++ let mut rng = rand::thread_rng(); ++ let mut expected = 0; ++ while expected < AMT { ++ if rng.gen_range(0, 3) == 2 { ++ match w.try_pop() { ++ None => {} ++ Some(2) => { HITS.fetch_add(1, SeqCst); }, ++ Some(_) => panic!(), ++ } ++ } else { ++ expected += 1; ++ w.push(2); ++ } ++ } ++ ++ while HITS.load(SeqCst) < AMT as usize { ++ match w.try_pop() { ++ None => {} ++ Some(2) => { HITS.fetch_add(1, SeqCst); }, ++ Some(_) => panic!(), ++ } ++ } ++ DONE.store(true, SeqCst); ++ ++ for thread in threads.into_iter() { ++ thread.join().unwrap(); ++ } ++ ++ assert_eq!(HITS.load(SeqCst), expected as usize); ++ } ++ ++ #[test] ++ fn no_starvation() { ++ static AMT: isize = 10000; ++ static NTHREADS: isize = 4; ++ static DONE: AtomicBool = ATOMIC_BOOL_INIT; ++ let (w, s) = deque(); ++ ++ let (threads, hits): (Vec<_>, Vec<_>) = (0..NTHREADS).map(|_| { ++ let s = s.clone(); ++ let ctr = Arc::new(AtomicUsize::new(0)); ++ let ctr2 = ctr.clone(); ++ (thread::spawn(move || { ++ loop { ++ match s.steal() { ++ Steal::Data((1, 2)) => { ctr.fetch_add(1, SeqCst); } ++ Steal::Data(..) => panic!(), ++ _ if DONE.load(SeqCst) => break, ++ _ => {} ++ } ++ } ++ }), ctr2) ++ }).unzip(); ++ ++ let mut rng = rand::thread_rng(); ++ let mut myhit = false; ++ 'outer: loop { ++ for _ in 0..rng.gen_range(0, AMT) { ++ if !myhit && rng.gen_range(0, 3) == 2 { ++ match w.try_pop() { ++ None => {} ++ Some((1, 2)) => myhit = true, ++ Some(_) => panic!(), ++ } ++ } else { ++ w.push((1, 2)); ++ } ++ } ++ ++ for slot in hits.iter() { ++ let amt = slot.load(SeqCst); ++ if amt == 0 { continue 'outer; } ++ } ++ if myhit { ++ break ++ } ++ } ++ ++ DONE.store(true, SeqCst); ++ ++ for thread in threads.into_iter() { ++ thread.join().unwrap(); ++ } ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/sync/mod.rs index 000000000,000000000..bdb59cfe4 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/sync/mod.rs @@@ -1,0 -1,0 +1,14 @@@ ++//! Synchronization primitives. ++ ++pub use self::ms_queue::MsQueue; ++pub use self::atomic_option::AtomicOption; ++pub use self::treiber_stack::TreiberStack; ++pub use self::seg_queue::SegQueue; ++pub use self::arc_cell::ArcCell; ++ ++mod atomic_option; ++mod ms_queue; ++mod treiber_stack; ++mod seg_queue; ++pub mod chase_lev; ++mod arc_cell; diff --cc vendor/crossbeam-0.3.0/src/sync/ms_queue.rs index 000000000,000000000..863741e19 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/sync/ms_queue.rs @@@ -1,0 -1,0 +1,526 @@@ ++use std::sync::atomic::Ordering::{Acquire, Release, Relaxed}; ++use std::sync::atomic::AtomicBool; ++use std::{ptr, mem}; ++use std::thread::{self, Thread}; ++ ++use epoch::{self, Atomic, Owned, Shared}; ++use CachePadded; ++ ++/// A Michael-Scott lock-free queue, with support for blocking `pop`s. ++/// ++/// Usable with any number of producers and consumers. ++// The representation here is a singly-linked list, with a sentinel ++// node at the front. In general the `tail` pointer may lag behind the ++// actual tail. Non-sentinel nodes are either all `Data` or all ++// `Blocked` (requests for data from blocked threads). ++#[derive(Debug)] ++pub struct MsQueue { ++ head: CachePadded>>, ++ tail: CachePadded>>, ++} ++ ++#[derive(Debug)] ++struct Node { ++ payload: Payload, ++ next: Atomic>, ++} ++ ++#[derive(Debug)] ++enum Payload { ++ /// A node with actual data that can be popped. ++ Data(T), ++ /// A node representing a blocked request for data. ++ Blocked(*mut Signal), ++} ++ ++/// A blocked request for data, which includes a slot to write the data. ++#[derive(Debug)] ++struct Signal { ++ /// Thread to unpark when data is ready. ++ thread: Thread, ++ /// The actual data, when available. ++ data: Option, ++ /// Is the data ready? Needed to cope with spurious wakeups. ++ ready: AtomicBool, ++} ++ ++impl Node { ++ fn is_data(&self) -> bool { ++ if let Payload::Data(_) = self.payload { true } else { false } ++ } ++} ++ ++// Any particular `T` should never accessed concurrently, so no need ++// for Sync. ++unsafe impl Sync for MsQueue {} ++unsafe impl Send for MsQueue {} ++ ++impl MsQueue { ++ /// Create a new, empty queue. ++ pub fn new() -> MsQueue { ++ let q = MsQueue { ++ head: CachePadded::new(Atomic::null()), ++ tail: CachePadded::new(Atomic::null()), ++ }; ++ let sentinel = Owned::new(Node { ++ payload: Payload::Data(unsafe { mem::uninitialized() }), ++ next: Atomic::null(), ++ }); ++ let guard = epoch::pin(); ++ let sentinel = q.head.store_and_ref(sentinel, Relaxed, &guard); ++ q.tail.store_shared(Some(sentinel), Relaxed); ++ q ++ } ++ ++ #[inline(always)] ++ /// Attempt to atomically place `n` into the `next` pointer of `onto`. ++ /// ++ /// If unsuccessful, returns ownership of `n`, possibly updating ++ /// the queue's `tail` pointer. ++ fn push_internal(&self, ++ guard: &epoch::Guard, ++ onto: Shared>, ++ n: Owned>) ++ -> Result<(), Owned>> ++ { ++ // is `onto` the actual tail? ++ if let Some(next) = onto.next.load(Acquire, guard) { ++ // if not, try to "help" by moving the tail pointer forward ++ self.tail.cas_shared(Some(onto), Some(next), Release); ++ Err(n) ++ } else { ++ // looks like the actual tail; attempt to link in `n` ++ onto.next.cas_and_ref(None, n, Release, guard).map(|shared| { ++ // try to move the tail pointer forward ++ self.tail.cas_shared(Some(onto), Some(shared), Release); ++ }) ++ } ++ } ++ ++ /// Add `t` to the back of the queue, possibly waking up threads ++ /// blocked on `pop`. ++ pub fn push(&self, t: T) { ++ /// We may or may not need to allocate a node; once we do, ++ /// we cache that allocation. ++ enum Cache { ++ Data(T), ++ Node(Owned>), ++ } ++ ++ impl Cache { ++ /// Extract the node if cached, or allocate if not. ++ fn into_node(self) -> Owned> { ++ match self { ++ Cache::Data(t) => { ++ Owned::new(Node { ++ payload: Payload::Data(t), ++ next: Atomic::null() ++ }) ++ } ++ Cache::Node(n) => n ++ } ++ } ++ ++ /// Extract the data from the cache, deallocating any cached node. ++ fn into_data(self) -> T { ++ match self { ++ Cache::Data(t) => t, ++ Cache::Node(node) => { ++ match node.into_inner().payload { ++ Payload::Data(t) => t, ++ _ => unreachable!(), ++ } ++ } ++ } ++ } ++ } ++ ++ let mut cache = Cache::Data(t); // don't allocate up front ++ let guard = epoch::pin(); ++ ++ loop { ++ // We push onto the tail, so we'll start optimistically by looking ++ // there first. ++ let tail = self.tail.load(Acquire, &guard).unwrap(); ++ ++ // Is the queue in Data mode (empty queues can be viewed as either mode)? ++ if tail.is_data() || ++ self.head.load(Relaxed, &guard).unwrap().as_raw() == tail.as_raw() ++ { ++ // Attempt to push onto the `tail` snapshot; fails if ++ // `tail.next` has changed, which will always be the case if the ++ // queue has transitioned to blocking mode. ++ match self.push_internal(&guard, tail, cache.into_node()) { ++ Ok(_) => return, ++ Err(n) => { ++ // replace the cache, retry whole thing ++ cache = Cache::Node(n) ++ } ++ } ++ } else { ++ // Queue is in blocking mode. Attempt to unblock a thread. ++ let head = self.head.load(Acquire, &guard).unwrap(); ++ // Get a handle on the first blocked node. Racy, so queue might ++ // be empty or in data mode by the time we see it. ++ let request = head.next.load(Acquire, &guard).and_then(|next| { ++ match next.payload { ++ Payload::Blocked(signal) => Some((next, signal)), ++ Payload::Data(_) => None, ++ } ++ }); ++ if let Some((blocked_node, signal)) = request { ++ // race to dequeue the node ++ if self.head.cas_shared(Some(head), Some(blocked_node), Release) { ++ unsafe { ++ // signal the thread ++ (*signal).data = Some(cache.into_data()); ++ let thread = (*signal).thread.clone(); ++ ++ (*signal).ready.store(true, Release); ++ thread.unpark(); ++ guard.unlinked(head); ++ return; ++ } ++ } ++ } ++ } ++ } ++ } ++ ++ #[inline(always)] ++ // Attempt to pop a data node. `Ok(None)` if queue is empty or in blocking ++ // mode; `Err(())` if lost race to pop. ++ fn pop_internal(&self, guard: &epoch::Guard) -> Result, ()> { ++ let head = self.head.load(Acquire, guard).unwrap(); ++ if let Some(next) = head.next.load(Acquire, guard) { ++ if let Payload::Data(ref t) = next.payload { ++ unsafe { ++ if self.head.cas_shared(Some(head), Some(next), Release) { ++ guard.unlinked(head); ++ Ok(Some(ptr::read(t))) ++ } else { ++ Err(()) ++ } ++ } ++ } else { ++ Ok(None) ++ } ++ } else { ++ Ok(None) ++ } ++ } ++ ++ /// Check if this queue is empty. ++ pub fn is_empty(&self) -> bool { ++ let guard = epoch::pin(); ++ let head = self.head.load(Acquire, &guard).unwrap(); ++ ++ if let Some(next) = head.next.load(Acquire, &guard) { ++ if let Payload::Data(_) = next.payload { ++ false ++ } else { ++ true ++ } ++ } else { ++ true ++ } ++ } ++ ++ /// Attempt to dequeue from the front. ++ /// ++ /// Returns `None` if the queue is observed to be empty. ++ pub fn try_pop(&self) -> Option { ++ let guard = epoch::pin(); ++ loop { ++ if let Ok(r) = self.pop_internal(&guard) { ++ return r; ++ } ++ } ++ } ++ ++ /// Dequeue an element from the front of the queue, blocking if the queue is ++ /// empty. ++ pub fn pop(&self) -> T { ++ let guard = epoch::pin(); ++ ++ // Fast path: keep retrying until we observe that the queue has no data, ++ // avoiding the allocation of a blocked node. ++ loop { ++ match self.pop_internal(&guard) { ++ Ok(Some(r)) => { ++ return r; ++ } ++ Ok(None) => { ++ break; ++ } ++ Err(()) => {} ++ } ++ } ++ ++ // The signal gets to live on the stack, since this stack frame will be ++ // blocked until receiving the signal. ++ let mut signal = Signal { ++ thread: thread::current(), ++ data: None, ++ ready: AtomicBool::new(false), ++ }; ++ ++ // Go ahead and allocate the blocked node; chances are, we'll need it. ++ let mut node = Owned::new(Node { ++ payload: Payload::Blocked(&mut signal), ++ next: Atomic::null(), ++ }); ++ ++ loop { ++ // try a normal pop ++ if let Ok(Some(r)) = self.pop_internal(&guard) { ++ return r; ++ } ++ ++ // At this point, we believe the queue is empty/blocked. ++ // Snapshot the tail, onto which we want to push a blocked node. ++ let tail = self.tail.load(Acquire, &guard).unwrap(); ++ ++ // Double-check that we're in blocking mode ++ if tail.is_data() { ++ // The current tail is in data mode, so we probably need to abort. ++ // BUT, it might be the sentinel, so check for that first. ++ let head = self.head.load(Relaxed, &guard).unwrap(); ++ if tail.is_data() && tail.as_raw() != head.as_raw() { continue; } ++ } ++ ++ // At this point, the tail snapshot is either a blocked node deep in ++ // the queue, the sentinel, or no longer accessible from the queue. ++ // In *ALL* of these cases, if we succeed in pushing onto the ++ // snapshot, we know we are maintaining the core invariant: all ++ // reachable, non-sentinel nodes have the same payload mode, in this ++ // case, blocked. ++ match self.push_internal(&guard, tail, node) { ++ Ok(()) => { ++ while !signal.ready.load(Acquire) { ++ thread::park(); ++ } ++ return signal.data.unwrap(); ++ } ++ Err(n) => { ++ node = n; ++ } ++ } ++ } ++ } ++} ++ ++impl Drop for MsQueue { ++ fn drop(&mut self) { ++ while self.try_pop().is_some() {} ++ ++ // Destroy the remaining sentinel node. ++ let guard = epoch::pin(); ++ let sentinel = self.head.load(Relaxed, &guard).unwrap().as_raw(); ++ unsafe { ++ drop(Vec::from_raw_parts(sentinel, 0, 1)); ++ } ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ const CONC_COUNT: i64 = 1000000; ++ ++ use scope; ++ use super::*; ++ ++ #[test] ++ fn push_try_pop_1() { ++ let q: MsQueue = MsQueue::new(); ++ assert!(q.is_empty()); ++ q.push(37); ++ assert!(!q.is_empty()); ++ assert_eq!(q.try_pop(), Some(37)); ++ assert!(q.is_empty()); ++ } ++ ++ #[test] ++ fn push_try_pop_2() { ++ let q: MsQueue = MsQueue::new(); ++ assert!(q.is_empty()); ++ q.push(37); ++ q.push(48); ++ assert_eq!(q.try_pop(), Some(37)); ++ assert!(!q.is_empty()); ++ assert_eq!(q.try_pop(), Some(48)); ++ assert!(q.is_empty()); ++ } ++ ++ #[test] ++ fn push_try_pop_many_seq() { ++ let q: MsQueue = MsQueue::new(); ++ assert!(q.is_empty()); ++ for i in 0..200 { ++ q.push(i) ++ } ++ assert!(!q.is_empty()); ++ for i in 0..200 { ++ assert_eq!(q.try_pop(), Some(i)); ++ } ++ assert!(q.is_empty()); ++ } ++ ++ #[test] ++ fn push_pop_1() { ++ let q: MsQueue = MsQueue::new(); ++ assert!(q.is_empty()); ++ q.push(37); ++ assert!(!q.is_empty()); ++ assert_eq!(q.pop(), 37); ++ assert!(q.is_empty()); ++ } ++ ++ #[test] ++ fn push_pop_2() { ++ let q: MsQueue = MsQueue::new(); ++ q.push(37); ++ q.push(48); ++ assert_eq!(q.pop(), 37); ++ assert_eq!(q.pop(), 48); ++ } ++ ++ #[test] ++ fn push_pop_many_seq() { ++ let q: MsQueue = MsQueue::new(); ++ assert!(q.is_empty()); ++ for i in 0..200 { ++ q.push(i) ++ } ++ assert!(!q.is_empty()); ++ for i in 0..200 { ++ assert_eq!(q.pop(), i); ++ } ++ assert!(q.is_empty()); ++ } ++ ++ #[test] ++ fn push_try_pop_many_spsc() { ++ let q: MsQueue = MsQueue::new(); ++ assert!(q.is_empty()); ++ ++ scope(|scope| { ++ scope.spawn(|| { ++ let mut next = 0; ++ ++ while next < CONC_COUNT { ++ if let Some(elem) = q.try_pop() { ++ assert_eq!(elem, next); ++ next += 1; ++ } ++ } ++ }); ++ ++ for i in 0..CONC_COUNT { ++ q.push(i) ++ } ++ }); ++ } ++ ++ #[test] ++ fn push_try_pop_many_spmc() { ++ fn recv(_t: i32, q: &MsQueue) { ++ let mut cur = -1; ++ for _i in 0..CONC_COUNT { ++ if let Some(elem) = q.try_pop() { ++ assert!(elem > cur); ++ cur = elem; ++ ++ if cur == CONC_COUNT - 1 { break } ++ } ++ } ++ } ++ ++ let q: MsQueue = MsQueue::new(); ++ assert!(q.is_empty()); ++ let qr = &q; ++ scope(|scope| { ++ for i in 0..3 { ++ scope.spawn(move || recv(i, qr)); ++ } ++ ++ scope.spawn(|| { ++ for i in 0..CONC_COUNT { ++ q.push(i); ++ } ++ }) ++ }); ++ } ++ ++ #[test] ++ fn push_try_pop_many_mpmc() { ++ enum LR { Left(i64), Right(i64) } ++ ++ let q: MsQueue = MsQueue::new(); ++ assert!(q.is_empty()); ++ ++ scope(|scope| { ++ for _t in 0..2 { ++ scope.spawn(|| { ++ for i in CONC_COUNT-1..CONC_COUNT { ++ q.push(LR::Left(i)) ++ } ++ }); ++ scope.spawn(|| { ++ for i in CONC_COUNT-1..CONC_COUNT { ++ q.push(LR::Right(i)) ++ } ++ }); ++ scope.spawn(|| { ++ let mut vl = vec![]; ++ let mut vr = vec![]; ++ for _i in 0..CONC_COUNT { ++ match q.try_pop() { ++ Some(LR::Left(x)) => vl.push(x), ++ Some(LR::Right(x)) => vr.push(x), ++ _ => {} ++ } ++ } ++ ++ let mut vl2 = vl.clone(); ++ let mut vr2 = vr.clone(); ++ vl2.sort(); ++ vr2.sort(); ++ ++ assert_eq!(vl, vl2); ++ assert_eq!(vr, vr2); ++ }); ++ } ++ }); ++ } ++ ++ #[test] ++ fn push_pop_many_spsc() { ++ let q: MsQueue = MsQueue::new(); ++ ++ scope(|scope| { ++ scope.spawn(|| { ++ let mut next = 0; ++ while next < CONC_COUNT { ++ assert_eq!(q.pop(), next); ++ next += 1; ++ } ++ }); ++ ++ for i in 0..CONC_COUNT { ++ q.push(i) ++ } ++ }); ++ assert!(q.is_empty()); ++ } ++ ++ #[test] ++ fn is_empty_dont_pop() { ++ let q: MsQueue = MsQueue::new(); ++ q.push(20); ++ q.push(20); ++ assert!(!q.is_empty()); ++ assert!(!q.is_empty()); ++ assert!(q.try_pop().is_some()); ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/sync/seg_queue.rs index 000000000,000000000..6135cabd5 new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/sync/seg_queue.rs @@@ -1,0 -1,0 +1,289 @@@ ++use std::sync::atomic::Ordering::{Acquire, Release, Relaxed}; ++use std::sync::atomic::{AtomicBool, AtomicUsize}; ++use std::fmt; ++use std::{ptr, mem}; ++use std::cmp; ++use std::cell::UnsafeCell; ++ ++use epoch::{self, Atomic, Owned}; ++ ++const SEG_SIZE: usize = 32; ++ ++/// A Michael-Scott queue that allocates "segments" (arrays of nodes) ++/// for efficiency. ++/// ++/// Usable with any number of producers and consumers. ++#[derive(Debug)] ++pub struct SegQueue { ++ head: Atomic>, ++ tail: Atomic>, ++} ++ ++struct Segment { ++ low: AtomicUsize, ++ data: [UnsafeCell<(T, AtomicBool)>; SEG_SIZE], ++ high: AtomicUsize, ++ next: Atomic>, ++} ++ ++impl fmt::Debug for Segment { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "Segment {{ ... }}") ++ } ++} ++ ++unsafe impl Sync for Segment {} ++ ++impl Segment { ++ fn new() -> Segment { ++ let rqueue = Segment { ++ data: unsafe { mem::uninitialized() }, ++ low: AtomicUsize::new(0), ++ high: AtomicUsize::new(0), ++ next: Atomic::null(), ++ }; ++ for val in rqueue.data.iter() { ++ unsafe { ++ (*val.get()).1 = AtomicBool::new(false); ++ } ++ } ++ rqueue ++ } ++} ++ ++impl SegQueue { ++ /// Create a new, empty queue. ++ pub fn new() -> SegQueue { ++ let q = SegQueue { ++ head: Atomic::null(), ++ tail: Atomic::null(), ++ }; ++ let sentinel = Owned::new(Segment::new()); ++ let guard = epoch::pin(); ++ let sentinel = q.head.store_and_ref(sentinel, Relaxed, &guard); ++ q.tail.store_shared(Some(sentinel), Relaxed); ++ q ++ } ++ ++ /// Add `t` to the back of the queue. ++ pub fn push(&self, t: T) { ++ let guard = epoch::pin(); ++ loop { ++ let tail = self.tail.load(Acquire, &guard).unwrap(); ++ if tail.high.load(Relaxed) >= SEG_SIZE { continue } ++ let i = tail.high.fetch_add(1, Relaxed); ++ unsafe { ++ if i < SEG_SIZE { ++ let cell = (*tail).data.get_unchecked(i).get(); ++ ptr::write(&mut (*cell).0, t); ++ (*cell).1.store(true, Release); ++ ++ if i + 1 == SEG_SIZE { ++ let tail = tail.next.store_and_ref(Owned::new(Segment::new()), Release, &guard); ++ self.tail.store_shared(Some(tail), Release); ++ } ++ ++ return ++ } ++ } ++ } ++ } ++ ++ /// Judge if the queue is empty. ++ /// ++ /// Returns `true` if the queue is empty. ++ pub fn is_empty(&self) -> bool { ++ let guard = epoch::pin(); ++ let head = self.head.load(Acquire, &guard).unwrap(); ++ let tail = self.tail.load(Acquire, &guard).unwrap(); ++ if head.as_raw() != tail.as_raw() { ++ return false; ++ } ++ ++ let low = head.low.load(Relaxed); ++ low >= cmp::min(head.high.load(Relaxed), SEG_SIZE) ++ } ++ ++ /// Attempt to dequeue from the front. ++ /// ++ /// Returns `None` if the queue is observed to be empty. ++ pub fn try_pop(&self) -> Option { ++ let guard = epoch::pin(); ++ loop { ++ let head = self.head.load(Acquire, &guard).unwrap(); ++ loop { ++ let low = head.low.load(Relaxed); ++ if low >= cmp::min(head.high.load(Relaxed), SEG_SIZE) { break } ++ if head.low.compare_and_swap(low, low+1, Relaxed) == low { ++ unsafe { ++ let cell = (*head).data.get_unchecked(low).get(); ++ loop { ++ if (*cell).1.load(Acquire) { break } ++ } ++ if low + 1 == SEG_SIZE { ++ loop { ++ if let Some(next) = head.next.load(Acquire, &guard) { ++ self.head.store_shared(Some(next), Release); ++ guard.unlinked(head); ++ break ++ } ++ } ++ } ++ return Some(ptr::read(&(*cell).0)) ++ } ++ } ++ } ++ if head.next.load(Relaxed, &guard).is_none() { return None } ++ } ++ } ++} ++ ++impl Drop for SegQueue { ++ fn drop(&mut self) { ++ while self.try_pop().is_some() {} ++ ++ // Destroy the remaining sentinel segment. ++ let guard = epoch::pin(); ++ let sentinel = self.head.load(Relaxed, &guard).unwrap().as_raw(); ++ unsafe { ++ drop(Vec::from_raw_parts(sentinel, 0, 1)); ++ } ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ const CONC_COUNT: i64 = 1000000; ++ ++ use scope; ++ use super::*; ++ ++ #[test] ++ fn push_pop_1() { ++ let q: SegQueue = SegQueue::new(); ++ q.push(37); ++ assert_eq!(q.try_pop(), Some(37)); ++ } ++ ++ #[test] ++ fn push_pop_2() { ++ let q: SegQueue = SegQueue::new(); ++ q.push(37); ++ q.push(48); ++ assert_eq!(q.try_pop(), Some(37)); ++ assert_eq!(q.try_pop(), Some(48)); ++ } ++ ++ #[test] ++ fn push_pop_empty_check() { ++ let q: SegQueue = SegQueue::new(); ++ assert_eq!(q.is_empty(), true); ++ q.push(42); ++ assert_eq!(q.is_empty(), false); ++ assert_eq!(q.try_pop(), Some(42)); ++ assert_eq!(q.is_empty(), true); ++ } ++ ++ #[test] ++ fn push_pop_many_seq() { ++ let q: SegQueue = SegQueue::new(); ++ for i in 0..200 { ++ q.push(i) ++ } ++ for i in 0..200 { ++ assert_eq!(q.try_pop(), Some(i)); ++ } ++ } ++ ++ #[test] ++ fn push_pop_many_spsc() { ++ let q: SegQueue = SegQueue::new(); ++ ++ scope(|scope| { ++ scope.spawn(|| { ++ let mut next = 0; ++ ++ while next < CONC_COUNT { ++ if let Some(elem) = q.try_pop() { ++ assert_eq!(elem, next); ++ next += 1; ++ } ++ } ++ }); ++ ++ for i in 0..CONC_COUNT { ++ q.push(i) ++ } ++ }); ++ } ++ ++ #[test] ++ fn push_pop_many_spmc() { ++ fn recv(_t: i32, q: &SegQueue) { ++ let mut cur = -1; ++ for _i in 0..CONC_COUNT { ++ if let Some(elem) = q.try_pop() { ++ assert!(elem > cur); ++ cur = elem; ++ ++ if cur == CONC_COUNT - 1 { break } ++ } ++ } ++ } ++ ++ let q: SegQueue = SegQueue::new(); ++ let qr = &q; ++ scope(|scope| { ++ for i in 0..3 { ++ scope.spawn(move || recv(i, qr)); ++ } ++ ++ scope.spawn(|| { ++ for i in 0..CONC_COUNT { ++ q.push(i); ++ } ++ }) ++ }); ++ } ++ ++ #[test] ++ fn push_pop_many_mpmc() { ++ enum LR { Left(i64), Right(i64) } ++ ++ let q: SegQueue = SegQueue::new(); ++ ++ scope(|scope| { ++ for _t in 0..2 { ++ scope.spawn(|| { ++ for i in CONC_COUNT-1..CONC_COUNT { ++ q.push(LR::Left(i)) ++ } ++ }); ++ scope.spawn(|| { ++ for i in CONC_COUNT-1..CONC_COUNT { ++ q.push(LR::Right(i)) ++ } ++ }); ++ scope.spawn(|| { ++ let mut vl = vec![]; ++ let mut vr = vec![]; ++ for _i in 0..CONC_COUNT { ++ match q.try_pop() { ++ Some(LR::Left(x)) => vl.push(x), ++ Some(LR::Right(x)) => vr.push(x), ++ _ => {} ++ } ++ } ++ ++ let mut vl2 = vl.clone(); ++ let mut vr2 = vr.clone(); ++ vl2.sort(); ++ vr2.sort(); ++ ++ assert_eq!(vl, vl2); ++ assert_eq!(vr, vr2); ++ }); ++ } ++ }); ++ } ++} diff --cc vendor/crossbeam-0.3.0/src/sync/treiber_stack.rs index 000000000,000000000..0c5f9096b new file mode 100644 --- /dev/null +++ b/vendor/crossbeam-0.3.0/src/sync/treiber_stack.rs @@@ -1,0 -1,0 +1,110 @@@ ++use std::sync::atomic::Ordering::{Acquire, Release, Relaxed}; ++use std::ptr; ++ ++use epoch::{self, Atomic, Owned}; ++ ++/// Treiber's lock-free stack. ++/// ++/// Usable with any number of producers and consumers. ++#[derive(Debug)] ++pub struct TreiberStack { ++ head: Atomic>, ++} ++ ++#[derive(Debug)] ++struct Node { ++ data: T, ++ next: Atomic>, ++} ++ ++impl TreiberStack { ++ /// Create a new, empty stack. ++ pub fn new() -> TreiberStack { ++ TreiberStack { head: Atomic::null() } ++ } ++ ++ /// Push `t` on top of the stack. ++ pub fn push(&self, t: T) { ++ let mut n = Owned::new(Node { ++ data: t, ++ next: Atomic::null(), ++ }); ++ let guard = epoch::pin(); ++ loop { ++ let head = self.head.load(Relaxed, &guard); ++ n.next.store_shared(head, Relaxed); ++ match self.head.cas_and_ref(head, n, Release, &guard) { ++ Ok(_) => break, ++ Err(owned) => n = owned, ++ } ++ } ++ } ++ ++ /// Attempt to pop the top element of the stack. ++ /// **Deprecated method**, use try_pop ++ /// ++ /// Returns `None` if the stack is observed to be empty. ++ #[cfg_attr(any(feature="beta", feature="nightly"), deprecated(note="The pop method has been renamed to try_pop for consistency with other collections."))] ++ pub fn pop(&self) -> Option { ++ self.try_pop() ++ } ++ ++ /// Attempt to pop the top element of the stack. ++ /// ++ /// Returns `None` if the stack is observed to be empty. ++ pub fn try_pop(&self) -> Option { ++ let guard = epoch::pin(); ++ loop { ++ match self.head.load(Acquire, &guard) { ++ Some(head) => { ++ let next = head.next.load(Relaxed, &guard); ++ if self.head.cas_shared(Some(head), next, Release) { ++ unsafe { ++ guard.unlinked(head); ++ return Some(ptr::read(&(*head).data)); ++ } ++ } ++ } ++ None => return None, ++ } ++ } ++ } ++ ++ /// Check if this queue is empty. ++ pub fn is_empty(&self) -> bool { ++ let guard = epoch::pin(); ++ self.head.load(Acquire, &guard).is_none() ++ } ++} ++ ++impl Drop for TreiberStack { ++ fn drop(&mut self) { ++ while self.try_pop().is_some() {} ++ } ++} ++ ++impl Default for TreiberStack { ++ fn default() -> Self { ++ TreiberStack::new() ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use super::*; ++ ++ #[test] ++ fn is_empty() { ++ let q: TreiberStack = TreiberStack::new(); ++ assert!(q.is_empty()); ++ q.push(20); ++ q.push(20); ++ assert!(!q.is_empty()); ++ assert!(!q.is_empty()); ++ assert!(q.try_pop().is_some()); ++ assert!(q.try_pop().is_some()); ++ assert!(q.is_empty()); ++ q.push(25); ++ assert!(!q.is_empty()); ++ } ++} diff --cc vendor/crypto-hash-0.3.0/.cargo-checksum.json index 000000000,000000000..100654e14 new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"34903878eec1694faf53cae8473a088df333181de421d4d3d48061d6559fe602"} diff --cc vendor/crypto-hash-0.3.0/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/.cargo-ok diff --cc vendor/crypto-hash-0.3.0/CONTRIBUTING.md index 000000000,000000000..1b33a9ec1 new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/CONTRIBUTING.md @@@ -1,0 -1,0 +1,77 @@@ ++# Contributing to `crypto-hash` ++ ++`crypto-hash` is a part of the Rust ecosystem. As such, all contributions to this project follow the ++[Rust language's code of conduct](https://www.rust-lang.org/conduct.html) where appropriate. ++ ++This project is hosted at [GitHub](https://github.com/malept/crypto-hash). Both pull requests and ++issues of many different kinds are accepted. ++ ++## Filing Issues ++ ++Issues include bugs, questions, feedback, and feature requests. Before you file a new issue, please ++make sure that your issue has not already been filed by someone else. ++ ++### Filing Bugs ++ ++When filing a bug, please include the following information: ++ ++* Operating system and version. If on Linux, please also include the distribution name. ++* System architecture. Examples include: x86-64, x86, and ARMv7. ++* Rust version that compiled `crypto-hash`. ++* The version (and/or git revision) of `crypto-hash`. ++* A detailed list of steps to reproduce the bug. A minimal testcase would be very helpful, ++ if possible. ++* If there any any error messages in the console, copying them in the bug summary will be ++ very helpful. ++ ++## Adding a new implementation ++ ++If you are requesting or adding a new library source for hash algorithms, please make sure that it ++supports all of the existing algorithms. For example, while the creator of this project supports the ++efforts of the team writing LibreSSL, it does not support the MD5 algorithm. ++ ++## Adding a new hash algorithm ++ ++If you are requesting or adding a wrapper for a new hash algorithm, please make sure that it is ++available in all of the supported implementations listed in the README. ++ ++## Filing Pull Requests ++ ++Here are some things to keep in mind as you file a pull request to fix a bug, add a new feature, ++etc.: ++ ++* Travis CI (for Linux and OS X) and AppVeyor (for Windows) are used to make sure that the project ++ builds as expected on the supported platforms, using the current stable and beta versions of Rust. ++ Make sure the testsuite passes locally by running `cargo test`. ++* Unless it's impractical, please write tests for your changes. This will help spot regressions ++ much easier. ++* If your PR changes the behavior of an existing feature, or adds a new feature, please add/edit ++ the `rustdoc` inline documentation. ++* Please ensure that your changes follow the [rustfmt](https://github.com/rust-lang-nursery/rustfmt) ++ coding standard, and do not produce any warnings when running the ++ [clippy](https://github.com/Manishearth/rust-clippy) linter. ++* If you are contributing a nontrivial change, please add an entry to `NEWS.md`. The format is ++ similar to the one described at [Keep a Changelog](http://keepachangelog.com/). ++* Please make sure your commits are rebased onto the latest commit in the master branch, and that ++ you limit/squash the number of commits created to a "feature"-level. For instance: ++ ++bad: ++ ++``` ++commit 1: add foo algorithm ++commit 2: run rustfmt ++commit 3: add test ++commit 4: add docs ++commit 5: add bar ++commit 6: add test + docs ++``` ++ ++good: ++ ++``` ++commit 1: add foo algorithm ++commit 2: add bar ++``` ++ ++If you are continuing the work of another person's PR and need to rebase/squash, please retain the ++attribution of the original author(s) and continue the work in subsequent commits. diff --cc vendor/crypto-hash-0.3.0/Cargo.toml index 000000000,000000000..cb9cf23f2 new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/Cargo.toml @@@ -1,0 -1,0 +1,31 @@@ ++[package] ++name = "crypto-hash" ++version = "0.3.0" ++authors = ["Mark Lee"] ++description = "A wrapper for OS-level cryptographic hash functions" ++documentation = "https://docs.rs/crypto-hash" ++repository = "https://github.com/malept/crypto-hash" ++readme = "README.md" ++keywords = ["crypto", "hash", "digest"] ++license = "MIT" ++exclude = [ ++ ".*.yml", ++ "ci/*" ++] ++ ++[badges] ++travis-ci = { repository = "malept/crypto-hash" } ++appveyor = { repository = "malept/crypto-hash" } ++ ++[dependencies] ++hex = "0.2" ++ ++[target.'cfg(target_os = "macos")'.dependencies] ++commoncrypto = "0.2" ++ ++[target.'cfg(target_os = "windows")'.dependencies] ++advapi32-sys = "0.2" ++winapi = "0.2" ++ ++[target.'cfg(not(any(target_os = "windows", target_os = "macos")))'.dependencies] ++openssl = "0.9" diff --cc vendor/crypto-hash-0.3.0/LICENSE index 000000000,000000000..e3eb5500c new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/LICENSE @@@ -1,0 -1,0 +1,19 @@@ ++Copyright (c) 2015, 2016 Mark Lee ++ ++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 --cc vendor/crypto-hash-0.3.0/Makefile index 000000000,000000000..c675b5ee3 new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/Makefile @@@ -1,0 -1,0 +1,29 @@@ ++CARGO ?= cargo ++CARGO_BUILD_TEST = $(CARGO) test --no-run ++KCOV ?= kcov ++TEST_APP = debug/crypto_hash-* ++WIN_TARGET = x86_64-pc-windows-gnu ++ ++build-test: ++ $(CARGO_BUILD_TEST) ++ ++check-i686: ++ PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig \ ++ PKG_CONFIG_ALLOW_CROSS=1 \ ++ $(CARGO) test --target i686-unknown-linux-gnu --verbose ++ ++check-wine64: ++ $(CARGO_BUILD_TEST) --target $(WIN_TARGET) ++ WINEPREFIX=$(HOME)/.local/share/wineprefixes/wine64 wine64 target/$(WIN_TARGET)/$(TEST_APP) ++ ++cov: build-test ++ $(KCOV) --exclude-pattern=/.multirust,test.rs target/cov target/$(TEST_APP) ++ ++debug: build-test ++ rust-gdb target/$(TEST_APP) ++ ++fmt: ++ $(CARGO) fmt ++ ++lint: ++ $(CARGO) clippy --features=lint -- -Wclippy-pedantic diff --cc vendor/crypto-hash-0.3.0/NEWS.md index 000000000,000000000..50c808f18 new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/NEWS.md @@@ -1,0 -1,0 +1,49 @@@ ++# Changes by Version ++ ++## Unreleased ++ ++## [0.3.0] - 2017-06-18 ++ ++### Changed ++ ++* Upgrade to `commoncrypto` 0.2.x ++* Function signatures for `digest` and `hex_digest` changed to use `&[u8]`, per Clippy ++ ++## [0.2.1] - 2016-12-12 ++ ++### Changed ++ ++* Move CommonCrypto implementation to its own crate ++ ++## [0.2.0] - 2016-11-06 ++ ++### Added ++ ++* SHA-1 algorithm ++ ++### Changed ++ ++* Upgrade rust-openssl to 0.9 ++ ++## [0.1.0] - 2016-06-26 ++ ++This release signifies the minimum amount of algorithms and implementations necessary for ++[HTTP digest authentication](https://tools.ietf.org/html/rfc7616). ++ ++### Added ++ ++Algorithms: ++ ++* MD5 ++* SHA256 ++* SHA512 ++ ++Implementations: ++ ++* CommonCrypto (OS X) ++* CryptoAPI (Windows) ++* OpenSSL (Linux/BSD/etc.) ++ ++[0.2.1]: https://github.com/malept/crypto-hash/compare/v0.2.0...v0.2.1 ++[0.2.0]: https://github.com/malept/crypto-hash/compare/v0.1.0...v0.2.0 ++[0.1.0]: https://github.com/malept/crypto-hash/releases/tag/v0.1.0 diff --cc vendor/crypto-hash-0.3.0/README.md index 000000000,000000000..64ac37532 new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/README.md @@@ -1,0 -1,0 +1,54 @@@ ++# `crypto-hash` ++ ++[![Linux/OS X Status](https://travis-ci.org/malept/crypto-hash.svg?branch=master)](https://travis-ci.org/malept/crypto-hash) ++[![Windows status](https://ci.appveyor.com/api/projects/status/xwc9nb4633b5n67r?svg=true)](https://ci.appveyor.com/project/malept/crypto-hash) ++[![Crates.io](https://img.shields.io/crates/v/crypto-hash.svg?maxAge=2592000)](https://crates.io/crates/crypto-hash) ++ ++`crypto-hash` is a Rust wrapper around OS-level implementations of cryptographic hash functions. ++ ++The purpose of this crate is to provide access to hash algorithms with as few dependencies as ++possible. This means that when possible, the library uses the hashing functions that are provided by ++the given operating system's bundled cryptographic libraries. ++ ++## Supported Implementations ++ ++By operating system: ++ ++* Windows: CryptoAPI ++* OS X: [CommonCrypto](https://crates.io/crates/commoncrypto) ++* Linux/BSD/etc.: [OpenSSL](https://crates.io/crates/openssl) ++ ++## Supported Algorithms ++ ++* MD5 ++* SHA1 ++* SHA256 ++* SHA512 ++ ++## Usage ++ ++Add `crypto-hash` to your project's `Cargo.toml`. For more details, consult the ++[Cargo guide](http://doc.crates.io/guide.html#adding-dependencies). ++ ++Example: ++ ++```rust ++use crypto_hash::{Algorithm, hex_digest}; ++ ++let digest = hex_digest(Algorithm::SHA256, b"crypto-hash".to_vec()); ++``` ++ ++For more examples, consult the [documentation](https://malept.github.io/crypto-hash/). ++ ++## [Release Notes](https://github.com/malept/crypto-hash/blob/master/NEWS.md) ++ ++## [Contributing](https://github.com/malept/crypto-hash/blob/master/CONTRIBUTING.md) ++ ++## Acknowledgements ++ ++This crate was inspired by [rust-native-tls](https://github.com/sfackler/rust-native-tls) and ++[crypto-bench](https://github.com/briansmith/crypto-bench). ++ ++## Legal ++ ++`crypto-hash` is copyrighted under the terms of the MIT license. See LICENSE for details. diff --cc vendor/crypto-hash-0.3.0/src/imp/commoncrypto.rs index 000000000,000000000..310dc8018 new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/src/imp/commoncrypto.rs @@@ -1,0 -1,0 +1,81 @@@ ++// Copyright (c) 2016 Mark Lee ++// ++// 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. ++ ++//! A cryptographic hash generator dependent upon OSX's `CommonCrypto`. ++ ++use commoncrypto::hash; ++use std::io; ++use super::Algorithm; ++ ++/// Generator of digests using a cryptographic hash function. ++/// ++/// # Examples ++/// ++/// ```rust ++/// use crypto_hash::{Algorithm, Hasher}; ++/// use std::io::Write; ++/// ++/// let mut hasher = Hasher::new(Algorithm::SHA256); ++/// hasher.write_all(b"crypto"); ++/// hasher.write_all(b"-"); ++/// hasher.write_all(b"hash"); ++/// let result = hasher.finish(); ++/// let expected = ++/// b"\xfd\x1a\xfb`\"\xcdMG\xc8\x90\x96\x1cS9(\xea\xcf\xe8!\x9f\x1b%$\xf7\xfb*a\x84}\xdf\x8c'" ++/// .to_vec(); ++/// assert_eq!(expected, result) ++/// ``` ++#[derive(Debug)] ++pub struct Hasher(hash::Hasher); ++ ++impl Hasher { ++ /// Create a new `Hasher` for the given `Algorithm`. ++ pub fn new(algorithm: Algorithm) -> Hasher { ++ let cc_algorithm = match algorithm { ++ Algorithm::MD5 => hash::CCDigestAlgorithm::kCCDigestMD5, ++ Algorithm::SHA1 => hash::CCDigestAlgorithm::kCCDigestSHA1, ++ Algorithm::SHA256 => hash::CCDigestAlgorithm::kCCDigestSHA256, ++ Algorithm::SHA512 => hash::CCDigestAlgorithm::kCCDigestSHA512, ++ }; ++ ++ Hasher(hash::Hasher::new(cc_algorithm)) ++ } ++ ++ /// Generate a digest from the data written to the `Hasher`. ++ pub fn finish(&mut self) -> Vec { ++ let Hasher(ref mut hasher) = *self; ++ match hasher.finish() { ++ Ok(digest) => digest, ++ Err(error) => panic!("CommonCrypto error: {}", error), ++ } ++ } ++} ++ ++impl io::Write for Hasher { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ let Hasher(ref mut hasher) = *self; ++ hasher.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ let Hasher(ref mut hasher) = *self; ++ hasher.flush() ++ } ++} diff --cc vendor/crypto-hash-0.3.0/src/imp/cryptoapi.rs index 000000000,000000000..bb693186a new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/src/imp/cryptoapi.rs @@@ -1,0 -1,0 +1,154 @@@ ++// Copyright (c) 2016 Mark Lee ++// ++// 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. ++ ++//! A cryptographic hash generator dependent upon Windows's `CryptoAPI`. ++//! ++//! Originally based on: ++//! https://github.com/rust-lang/cargo/blob/0.10.0/src/cargo/util/sha256.rs ++//! which is copyright (c) 2014 The Rust Project Developers under the MIT license. ++ ++use advapi32::{CryptAcquireContextW, CryptCreateHash, CryptDestroyHash, CryptGetHashParam, ++ CryptHashData, CryptReleaseContext}; ++use std::io; ++use std::ptr; ++use super::Algorithm; ++use winapi::{CALG_MD5, CALG_SHA1, CALG_SHA_256, CALG_SHA_512, CRYPT_SILENT, CRYPT_VERIFYCONTEXT, ++ DWORD, HCRYPTHASH, HCRYPTPROV, HP_HASHVAL, PROV_RSA_AES}; ++ ++macro_rules! call { ++ ($e: expr) => ({ ++ if $e == 0 { ++ panic!("failed {}: {}", stringify!($e), io::Error::last_os_error()) ++ } ++ }) ++} ++ ++macro_rules! finish_algorithm { ++ ($func_name: ident, $size: ident) => { ++ fn $func_name(&mut self) -> Vec { ++ let mut len = $size as u32; ++ let mut hash = [0u8; $size]; ++ call!(unsafe { ++ CryptGetHashParam(self.hcrypthash, HP_HASHVAL, hash.as_mut_ptr(), &mut len, 0) ++ }); ++ assert_eq!(len as usize, hash.len()); ++ hash.to_vec() ++ } ++ } ++} ++ ++const MD5_LENGTH: usize = 16; ++const SHA1_LENGTH: usize = 20; ++const SHA256_LENGTH: usize = 32; ++const SHA512_LENGTH: usize = 64; ++ ++/// Generator of digests using a cryptographic hash function. ++/// ++/// # Examples ++/// ++/// ```rust ++/// use crypto_hash::{Algorithm, Hasher}; ++/// use std::io::Write; ++/// ++/// let mut hasher = Hasher::new(Algorithm::SHA256); ++/// hasher.write_all(b"crypto"); ++/// hasher.write_all(b"-"); ++/// hasher.write_all(b"hash"); ++/// let result = hasher.finish(); ++/// let expected = ++/// b"\xfd\x1a\xfb`\"\xcdMG\xc8\x90\x96\x1cS9(\xea\xcf\xe8!\x9f\x1b%$\xf7\xfb*a\x84}\xdf\x8c'" ++/// .to_vec(); ++/// assert_eq!(expected, result) ++/// ``` ++pub struct Hasher { ++ algorithm: Algorithm, ++ hcryptprov: HCRYPTPROV, ++ hcrypthash: HCRYPTHASH, ++} ++ ++impl Hasher { ++ /// Create a new `Hasher` for the given `Algorithm`. ++ pub fn new(algorithm: Algorithm) -> Hasher { ++ let mut hcp = 0; ++ call!(unsafe { ++ CryptAcquireContextW(&mut hcp, ++ ptr::null(), ++ ptr::null(), ++ PROV_RSA_AES, ++ CRYPT_VERIFYCONTEXT | CRYPT_SILENT) ++ }); ++ ++ let hash_type = match algorithm { ++ Algorithm::MD5 => CALG_MD5, ++ Algorithm::SHA1 => CALG_SHA1, ++ Algorithm::SHA256 => CALG_SHA_256, ++ Algorithm::SHA512 => CALG_SHA_512, ++ }; ++ ++ let mut ret = Hasher { ++ algorithm: algorithm, ++ hcryptprov: hcp, ++ hcrypthash: 0, ++ }; ++ ++ call!(unsafe { CryptCreateHash(ret.hcryptprov, hash_type, 0, 0, &mut ret.hcrypthash) }); ++ ret ++ } ++ ++ /// Generate a digest from the data written to the `Hasher`. ++ pub fn finish(&mut self) -> Vec { ++ match self.algorithm { ++ Algorithm::MD5 => self.finish_md5(), ++ Algorithm::SHA1 => self.finish_sha1(), ++ Algorithm::SHA256 => self.finish_sha256(), ++ Algorithm::SHA512 => self.finish_sha512(), ++ } ++ } ++ ++ finish_algorithm!(finish_md5, MD5_LENGTH); ++ finish_algorithm!(finish_sha1, SHA1_LENGTH); ++ finish_algorithm!(finish_sha256, SHA256_LENGTH); ++ finish_algorithm!(finish_sha512, SHA512_LENGTH); ++} ++ ++impl io::Write for Hasher { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ call!(unsafe { ++ CryptHashData(self.hcrypthash, ++ buf.as_ptr() as *mut _, ++ buf.len() as DWORD, ++ 0) ++ }); ++ Ok(buf.len()) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ Ok(()) ++ } ++} ++ ++impl Drop for Hasher { ++ fn drop(&mut self) { ++ if self.hcrypthash != 0 { ++ call!(unsafe { CryptDestroyHash(self.hcrypthash) }); ++ } ++ call!(unsafe { CryptReleaseContext(self.hcryptprov, 0) }); ++ } ++} diff --cc vendor/crypto-hash-0.3.0/src/imp/openssl.rs index 000000000,000000000..ba573c4c9 new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/src/imp/openssl.rs @@@ -1,0 -1,0 +1,85 @@@ ++// Copyright (c) 2015, 2016 Mark Lee ++// ++// 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. ++ ++//! A cryptographic hash digest generator dependent upon `OpenSSL`. ++ ++#![warn(missing_docs)] ++ ++use openssl::hash; ++use std::io; ++use super::Algorithm; ++ ++/// Generator of digests using a cryptographic hash function. ++/// ++/// # Examples ++/// ++/// ```rust ++/// use crypto_hash::{Algorithm, Hasher}; ++/// use std::io::Write; ++/// ++/// let mut hasher = Hasher::new(Algorithm::SHA256); ++/// hasher.write_all(b"crypto"); ++/// hasher.write_all(b"-"); ++/// hasher.write_all(b"hash"); ++/// let result = hasher.finish(); ++/// let expected = ++/// b"\xfd\x1a\xfb`\"\xcdMG\xc8\x90\x96\x1cS9(\xea\xcf\xe8!\x9f\x1b%$\xf7\xfb*a\x84}\xdf\x8c'" ++/// .to_vec(); ++/// assert_eq!(expected, result) ++/// ``` ++pub struct Hasher(hash::Hasher); ++ ++impl Hasher { ++ /// Create a new `Hasher` for the given `Algorithm`. ++ pub fn new(algorithm: Algorithm) -> Hasher { ++ let hash_type = match algorithm { ++ Algorithm::MD5 => hash::MessageDigest::md5(), ++ Algorithm::SHA1 => hash::MessageDigest::sha1(), ++ Algorithm::SHA256 => hash::MessageDigest::sha256(), ++ Algorithm::SHA512 => hash::MessageDigest::sha512(), ++ }; ++ ++ match hash::Hasher::new(hash_type) { ++ Ok(hasher) => Hasher(hasher), ++ Err(error_stack) => panic!("OpenSSL error(s): {}", error_stack), ++ } ++ } ++ ++ /// Generate a digest from the data written to the `Hasher`. ++ pub fn finish(&mut self) -> Vec { ++ let Hasher(ref mut hasher) = *self; ++ match hasher.finish2() { ++ Ok(digest) => digest.to_vec(), ++ Err(error_stack) => panic!("OpenSSL error(s): {}", error_stack), ++ } ++ } ++} ++ ++impl io::Write for Hasher { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ let Hasher(ref mut hasher) = *self; ++ hasher.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ let Hasher(ref mut hasher) = *self; ++ hasher.flush() ++ } ++} diff --cc vendor/crypto-hash-0.3.0/src/lib.rs index 000000000,000000000..3e6f6cd7c new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/src/lib.rs @@@ -1,0 -1,0 +1,122 @@@ ++// Copyright (c) 2015, 2016, 2017 Mark Lee ++// ++// 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. ++ ++//! A set of [cryptographic hash ++//! functions](https://en.wikipedia.org/wiki/Cryptographic_hash_function) provided by the operating ++//! system, when available. ++//! ++//! The purpose of this crate is to provide access to hash algorithms with as few dependencies as ++//! possible. This means that when possible, the library uses the hashing functions that are ++//! provided by the given operating system's bundled cryptographic libraries. ++//! ++//! # Supported Implementations ++//! ++//! By operating system: ++//! ++//! * Windows: `CryptoAPI` ++//! * Mac OS X: `CommonCrypto` ++//! * Linux/BSD/etc.: `OpenSSL` ++//! ++//! # Supported Algorithms ++//! ++//! * MD5 ++//! * SHA1 ++//! * SHA256 ++//! * SHA512 ++ ++#![warn(missing_docs)] ++ ++#[cfg(target_os = "windows")] ++extern crate advapi32; ++#[cfg(target_os = "macos")] ++extern crate commoncrypto; ++extern crate hex; ++#[cfg(not(any(target_os = "macos", target_os = "windows")))] ++extern crate openssl; ++#[cfg(target_os = "windows")] ++extern crate winapi; ++ ++use hex::ToHex; ++use std::io::Write; ++ ++#[cfg(target_os = "macos")] ++#[path = "imp/commoncrypto.rs"] ++mod imp; ++#[cfg(target_os = "windows")] ++#[path = "imp/cryptoapi.rs"] ++mod imp; ++#[cfg(not(any(target_os = "macos", target_os = "windows")))] ++#[path = "imp/openssl.rs"] ++mod imp; ++ ++mod test; ++ ++pub use imp::Hasher; ++ ++/// Available cryptographic hash functions. ++#[derive(Clone, Debug)] ++pub enum Algorithm { ++ /// Popular message digest algorithm, only available for backwards compatibility purposes. ++ MD5, ++ /// SHA-1 algorithm from NIST FIPS, only available for backwards compatibility purposes. ++ SHA1, ++ /// SHA-2 family algorithm (256 bits). ++ SHA256, ++ /// SHA-2 family algorithm (512 bits). ++ SHA512, ++} ++ ++/// Helper function for `Hasher` which generates a cryptographic digest from the given ++/// data and algorithm. ++/// ++/// # Examples ++/// ++/// ```rust ++/// use crypto_hash::{Algorithm, digest}; ++/// ++/// let data = b"crypto-hash"; ++/// let result = digest(Algorithm::SHA256, data); ++/// let expected = ++/// b"\xfd\x1a\xfb`\"\xcdMG\xc8\x90\x96\x1cS9(\xea\xcf\xe8!\x9f\x1b%$\xf7\xfb*a\x84}\xdf\x8c'" ++/// .to_vec(); ++/// assert_eq!(expected, result) ++/// ``` ++pub fn digest(algorithm: Algorithm, data: &[u8]) -> Vec { ++ let mut hasher = imp::Hasher::new(algorithm); ++ hasher.write_all(data).expect("Could not write hash data"); ++ hasher.finish() ++} ++ ++/// Helper function for `Hasher` which generates a cryptographic digest serialized in ++/// hexadecimal from the given data and algorithm. ++/// ++/// # Examples ++/// ++/// ```rust ++/// use crypto_hash::{Algorithm, hex_digest}; ++/// ++/// let data = b"crypto-hash"; ++/// let result = hex_digest(Algorithm::SHA256, data); ++/// let expected = "fd1afb6022cd4d47c890961c533928eacfe8219f1b2524f7fb2a61847ddf8c27"; ++/// assert_eq!(expected, result) ++/// ``` ++pub fn hex_digest(algorithm: Algorithm, data: &[u8]) -> String { ++ digest(algorithm, data).to_hex() ++} diff --cc vendor/crypto-hash-0.3.0/src/test.rs index 000000000,000000000..31920c4eb new file mode 100644 --- /dev/null +++ b/vendor/crypto-hash-0.3.0/src/test.rs @@@ -1,0 -1,0 +1,79 @@@ ++// Copyright (c) 2016, 2017 Mark Lee ++// ++// 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. ++ ++#![cfg(test)] ++ ++use hex::ToHex; ++use std::io::Write; ++use super::{Algorithm, Hasher, hex_digest}; ++ ++// From Wikipedia ++const MD5_EMPTY_STRING: &'static str = "d41d8cd98f00b204e9800998ecf8427e"; ++const SHA1_EMPTY_STRING: &'static str = "da39a3ee5e6b4b0d3255bfef95601890afd80709"; ++const SHA256_EMPTY_STRING: &'static str = concat!("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649", ++ "b934ca495991b7852b855"); ++const SHA512_EMPTY_STRING: &'static str = concat!("cf83e1357eefb8bdf1542850d66d8007d620e4050b5", ++ "715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318", ++ "d2877eec2f63b931bd47417a81a538327af927da3e"); ++const TO_HASH: &'static str = "The quick brown fox jumps over the lazy dog"; ++const TO_HASH_MD5: &'static str = "9e107d9d372bb6826bd81d3542a419d6"; ++ ++#[test] ++fn md5_empty_string() { ++ assert_hex_hashed_empty_string(Algorithm::MD5, MD5_EMPTY_STRING) ++} ++ ++#[test] ++fn sha1_empty_string() { ++ assert_hex_hashed_empty_string(Algorithm::SHA1, SHA1_EMPTY_STRING) ++} ++ ++#[test] ++fn sha256_empty_string() { ++ // From Wikipedia ++ assert_hex_hashed_empty_string(Algorithm::SHA256, SHA256_EMPTY_STRING) ++} ++ ++#[test] ++fn sha512_empty_string() { ++ assert_hex_hashed_empty_string(Algorithm::SHA512, SHA512_EMPTY_STRING) ++} ++ ++#[test] ++fn hasher_sans_write() { ++ let mut hasher = Hasher::new(Algorithm::MD5); ++ let actual = hasher.finish().to_hex(); ++ assert_eq!(MD5_EMPTY_STRING, actual) ++} ++ ++#[test] ++fn hasher_with_write() { ++ let mut hasher = Hasher::new(Algorithm::MD5); ++ hasher ++ .write_all(TO_HASH.as_bytes()) ++ .expect("Could not write to hasher"); ++ let actual = hasher.finish().to_hex(); ++ assert_eq!(TO_HASH_MD5, actual) ++} ++ ++fn assert_hex_hashed_empty_string(algorithm: Algorithm, expected: &str) { ++ let vec = vec![]; ++ assert_eq!(expected, hex_digest(algorithm, vec.as_slice()).as_str()) ++} diff --cc vendor/curl-sys-0.3.15/.cargo-checksum.json index 000000000,000000000..5944e1e3b new file mode 100644 --- /dev/null +++ b/vendor/curl-sys-0.3.15/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"4bee31aa3a079d5f3ff9579ea4dcfb1b1a17a40886f5f467436d383e78134b55"} diff --cc vendor/curl-sys-0.3.15/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/curl-sys-0.3.15/.cargo-ok diff --cc vendor/curl-sys-0.3.15/Cargo.toml index 000000000,000000000..3ed68c8e6 new file mode 100644 --- /dev/null +++ b/vendor/curl-sys-0.3.15/Cargo.toml @@@ -1,0 -1,0 +1,48 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "curl-sys" ++version = "0.3.15" ++authors = ["Carl Lerche ", "Alex Crichton "] ++build = "build.rs" ++links = "curl" ++description = "Native bindings to the libcurl library" ++documentation = "https://docs.rs/curl-sys" ++categories = ["external-ffi-bindings"] ++license = "MIT" ++repository = "https://github.com/alexcrichton/curl-rust" ++ ++[lib] ++name = "curl_sys" ++path = "lib.rs" ++[dependencies.libz-sys] ++version = ">= 0" ++ ++[dependencies.libc] ++version = "0.2" ++[build-dependencies.cc] ++version = "1.0" ++ ++[build-dependencies.pkg-config] ++version = "0.3" ++[target."cfg(target_env = \"msvc\")".build-dependencies.vcpkg] ++version = "0.2" ++[target."cfg(all(unix, not(target_os = \"macos\")))".dependencies.openssl-sys] ++version = "0.9" ++[target."cfg(windows)".dependencies.winapi] ++version = "0.2" ++[badges.travis-ci] ++repository = "alexcrichton/curl-rust" ++ ++[badges.appveyor] ++repository = "alexcrichton/curl-rust" diff --cc vendor/curl-sys-0.3.15/build.rs index 000000000,000000000..a06719da0 new file mode 100644 --- /dev/null +++ b/vendor/curl-sys-0.3.15/build.rs @@@ -1,0 -1,0 +1,411 @@@ ++extern crate pkg_config; ++#[cfg(target_env = "msvc")] ++extern crate vcpkg; ++extern crate cc; ++ ++use std::env; ++use std::ffi::OsString; ++use std::fs; ++use std::path::{PathBuf, Path}; ++use std::process::Command; ++use std::io::ErrorKind; ++ ++macro_rules! t { ++ ($e:expr) => (match $e { ++ Ok(t) => t, ++ Err(e) => panic!("{} return the error {}", stringify!($e), e), ++ }) ++} ++ ++fn main() { ++ let target = env::var("TARGET").unwrap(); ++ let host = env::var("HOST").unwrap(); ++ let src = env::current_dir().unwrap(); ++ let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); ++ let windows = target.contains("windows"); ++ ++ // OSX and Haiku ships libcurl by default, so we just use that version ++ // unconditionally. ++ if target.contains("apple") || target.contains("haiku") { ++ return println!("cargo:rustc-flags=-l curl"); ++ } ++ ++ // Illumos/Solaris requires explicit linking with libnsl ++ if target.contains("solaris") { ++ println!("cargo:rustc-flags=-l nsl"); ++ } ++ ++ // Next, fall back and try to use pkg-config if its available. ++ if !target.contains("windows") { ++ match pkg_config::find_library("libcurl") { ++ Ok(lib) => { ++ for path in lib.include_paths.iter() { ++ println!("cargo:include={}", path.display()); ++ } ++ return ++ } ++ Err(e) => println!("Couldn't find libcurl from \ ++ pkgconfig ({:?}), compiling it from source...", e), ++ } ++ } ++ ++ if try_vcpkg() { ++ return; ++ } ++ ++ if !Path::new("curl/.git").exists() { ++ let _ = Command::new("git").args(&["submodule", "update", "--init"]) ++ .status(); ++ } ++ ++ println!("cargo:rustc-link-search=native={}/lib", dst.display()); ++ println!("cargo:rustc-link-lib=static=curl"); ++ println!("cargo:root={}", dst.display()); ++ println!("cargo:include={}/include", dst.display()); ++ if windows { ++ println!("cargo:rustc-link-lib=ws2_32"); ++ println!("cargo:rustc-link-lib=crypt32"); ++ } ++ ++ // MSVC builds are just totally different ++ if target.contains("msvc") { ++ return build_msvc(&target); ++ } ++ ++ let openssl_root = register_dep("OPENSSL"); ++ let zlib_root = register_dep("Z"); ++ let nghttp2_root = register_dep("NGHTTP2"); ++ ++ let cfg = cc::Build::new(); ++ let compiler = cfg.get_compiler(); ++ ++ let _ = fs::create_dir(&dst.join("build")); ++ ++ let mut cmd = Command::new("sh"); ++ let mut cflags = OsString::new(); ++ for arg in compiler.args() { ++ cflags.push(arg); ++ cflags.push(" "); ++ } ++ ++ // Can't run ./configure directly on msys2 b/c we're handing in ++ // Windows-style paths (those starting with C:\), but it chokes on those. ++ // For that reason we build up a shell script with paths converted to ++ // posix versions hopefully... ++ // ++ // Also apparently the buildbots choke unless we manually set LD, who knows ++ // why?! ++ cmd.env("CC", compiler.path()) ++ .env("CFLAGS", cflags) ++ .env("LD", &which("ld").unwrap()) ++ .env("VERBOSE", "1") ++ .current_dir(&dst.join("build")) ++ .arg(msys_compatible(&src.join("curl/configure"))); ++ ++ // For now this build script doesn't support paths with spaces in them. This ++ // is arguably a but in curl's configure script, but we could also try to ++ // paper over it by using a tmp directory which *doesn't* have spaces in it. ++ // As of now though that's not implemented so just give a nicer error for ++ // the time being. ++ let wants_space_error = windows && ++ (dst.to_str().map(|s| s.contains(" ")).unwrap_or(false) || ++ src.to_str().map(|s| s.contains(" ")).unwrap_or(false)); ++ if wants_space_error { ++ panic!("\n\nunfortunately ./configure of libcurl is known to \ ++ fail if there's a space in the path to the current \ ++ directory\n\n\ ++ there's a space in either\n {}\n {}\nand this will cause the \ ++ build to fail\n\n\ ++ the MSVC build should work with a directory that has \ ++ spaces in it, and it would also work to move this to a \ ++ different directory without spaces\n\n", ++ src.display(), dst.display()) ++ } ++ ++ if windows { ++ cmd.arg("--with-winssl"); ++ } else { ++ cmd.arg("--without-ca-bundle"); ++ cmd.arg("--without-ca-path"); ++ } ++ if let Some(root) = openssl_root { ++ cmd.arg(format!("--with-ssl={}", msys_compatible(&root))); ++ } ++ if let Some(root) = zlib_root { ++ cmd.arg(format!("--with-zlib={}", msys_compatible(&root))); ++ } ++ cmd.arg("--enable-static=yes"); ++ cmd.arg("--enable-shared=no"); ++ match &env::var("PROFILE").unwrap()[..] { ++ "bench" | "release" => { ++ cmd.arg("--enable-optimize"); ++ } ++ _ => { ++ cmd.arg("--enable-debug"); ++ cmd.arg("--disable-optimize"); ++ } ++ } ++ cmd.arg(format!("--prefix={}", msys_compatible(&dst))); ++ ++ if target != host && ++ (!target.contains("windows") || !host.contains("windows")) { ++ // NOTE GNU terminology ++ // BUILD = machine where we are (cross) compiling curl ++ // HOST = machine where the compiled curl will be used ++ // TARGET = only relevant when compiling compilers ++ if target.contains("windows") { ++ // curl's configure can't parse `-windows-` triples when used ++ // as `--host`s. In those cases we use this combination of ++ // `host` and `target` that appears to do the right thing. ++ cmd.arg(format!("--host={}", host)); ++ cmd.arg(format!("--target={}", target)); ++ } else { ++ cmd.arg(format!("--build={}", host)); ++ cmd.arg(format!("--host={}", target)); ++ } ++ } ++ ++ if let Some(root) = nghttp2_root { ++ cmd.arg(format!("--with-nghttp2={}", msys_compatible(&root))); ++ } else { ++ cmd.arg("--without-nghttp2"); ++ } ++ ++ cmd.arg("--without-librtmp"); ++ cmd.arg("--without-libidn"); ++ cmd.arg("--without-libssh2"); ++ cmd.arg("--without-libpsl"); ++ cmd.arg("--disable-ldap"); ++ cmd.arg("--disable-ldaps"); ++ cmd.arg("--disable-ftp"); ++ cmd.arg("--disable-rtsp"); ++ cmd.arg("--disable-dict"); ++ cmd.arg("--disable-telnet"); ++ cmd.arg("--disable-tftp"); ++ cmd.arg("--disable-pop3"); ++ cmd.arg("--disable-imap"); ++ cmd.arg("--disable-smtp"); ++ cmd.arg("--disable-gopher"); ++ cmd.arg("--disable-manual"); ++ cmd.arg("--disable-smb"); ++ cmd.arg("--disable-sspi"); ++ cmd.arg("--disable-manual"); ++ cmd.arg("--disable-unix-sockets"); ++ cmd.arg("--disable-versioned-symbols"); ++ cmd.arg("--enable-hidden-symbols"); ++ cmd.arg("--disable-libcurl-option"); ++ ++ run(&mut cmd, "sh"); ++ run(make() ++ .arg(&format!("-j{}", env::var("NUM_JOBS").unwrap())) ++ .current_dir(&dst.join("build")), "make"); ++ run(make() ++ .arg("install") ++ .current_dir(&dst.join("build")), "make"); ++} ++ ++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 fail(s: &str) -> ! { ++ panic!("\n{}\n\nbuild script failed, must exit now", s) ++} ++ ++fn make() -> Command { ++ let cmd = if cfg!(target_os = "freebsd") {"gmake"} else {"make"}; ++ let mut cmd = Command::new(cmd); ++ // We're using the MSYS make which doesn't work with the mingw32-make-style ++ // MAKEFLAGS, so remove that from the env if present. ++ if cfg!(windows) { ++ cmd.env_remove("MAKEFLAGS").env_remove("MFLAGS"); ++ } ++ return cmd ++} ++ ++fn which(cmd: &str) -> Option { ++ let cmd = format!("{}{}", cmd, env::consts::EXE_SUFFIX); ++ let paths = env::var_os("PATH").unwrap(); ++ env::split_paths(&paths).map(|p| p.join(&cmd)).find(|p| { ++ fs::metadata(p).is_ok() ++ }) ++} ++ ++fn msys_compatible(path: &Path) -> String { ++ let path = path.to_str().unwrap(); ++ if !cfg!(windows) { ++ return path.to_string() ++ } ++ path.replace("C:\\", "/c/") ++ .replace("\\", "/") ++} ++ ++fn register_dep(dep: &str) -> Option { ++ if let Some(s) = env::var_os(&format!("DEP_{}_ROOT", dep)) { ++ prepend("PKG_CONFIG_PATH", Path::new(&s).join("lib/pkgconfig")); ++ return Some(s.into()) ++ } ++ if let Some(s) = env::var_os(&format!("DEP_{}_INCLUDE", dep)) { ++ let root = Path::new(&s).parent().unwrap(); ++ env::set_var(&format!("DEP_{}_ROOT", dep), root); ++ let path = root.join("lib/pkgconfig"); ++ if path.exists() { ++ prepend("PKG_CONFIG_PATH", path); ++ return Some(root.to_path_buf()) ++ } ++ } ++ ++ return None; ++ ++ fn prepend(var: &str, val: PathBuf) { ++ let prefix = env::var(var).unwrap_or(String::new()); ++ let mut v = vec![val]; ++ v.extend(env::split_paths(&prefix)); ++ env::set_var(var, &env::join_paths(v).unwrap()); ++ } ++} ++ ++fn build_msvc(target: &str) { ++ let cmd = cc::windows_registry::find(target, "nmake.exe"); ++ let mut cmd = cmd.unwrap_or(Command::new("nmake.exe")); ++ let src = env::current_dir().unwrap(); ++ let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); ++ let machine = if target.starts_with("x86_64") { ++ "x64" ++ } else if target.starts_with("i686") { ++ "x86" ++ } else { ++ panic!("unknown msvc target: {}", target); ++ }; ++ ++ t!(fs::create_dir_all(dst.join("include/curl"))); ++ t!(fs::create_dir_all(dst.join("lib"))); ++ ++ drop(fs::remove_dir_all(&dst.join("build"))); ++ cp_r(&src.join("curl"), &dst.join("build")); ++ cmd.current_dir(dst.join("build/winbuild")); ++ cmd.arg("/f").arg("Makefile.vc") ++ .arg("MODE=static") ++ .arg("ENABLE_IDN=yes") ++ .arg("DEBUG=no") ++ .arg("GEN_PDB=no") ++ .arg("ENABLE_WINSSL=yes") ++ .arg("ENABLE_SSPI=yes") ++ .arg(format!("MACHINE={}", machine)); ++ ++ // These env vars are intended for `make` usually, not nmake, so remove them ++ // unconditionally ++ cmd.env_remove("MAKEFLAGS") ++ .env_remove("MFLAGS"); ++ ++ let features = env::var("CARGO_CFG_TARGET_FEATURE") ++ .unwrap_or(String::new()); ++ if features.contains("crt-static") { ++ cmd.arg("RTLIBCFG=static"); ++ } ++ ++ if let Some(inc) = env::var_os("DEP_Z_ROOT") { ++ let inc = PathBuf::from(inc); ++ let mut s = OsString::from("WITH_DEVEL="); ++ s.push(&inc); ++ cmd.arg("WITH_ZLIB=static").arg(s); ++ ++ // the build system for curl expects this library to be called ++ // zlib_a.lib, so make sure it's named correctly (where libz-sys just ++ // produces zlib.lib) ++ let _ = fs::remove_file(&inc.join("lib/zlib_a.lib")); ++ t!(fs::copy(inc.join("lib/zlib.lib"), inc.join("lib/zlib_a.lib"))); ++ } ++ run(&mut cmd, "nmake"); ++ ++ let name = format!("libcurl-vc-{}-release-static-zlib-static-\ ++ ipv6-sspi-winssl", machine); ++ let libs = dst.join("build/builds").join(name); ++ ++ t!(fs::copy(libs.join("lib/libcurl_a.lib"), dst.join("lib/curl.lib"))); ++ for f in t!(fs::read_dir(libs.join("include/curl"))) { ++ let path = t!(f).path(); ++ let dst = dst.join("include/curl").join(path.file_name().unwrap()); ++ t!(fs::copy(path, dst)); ++ } ++ t!(fs::remove_dir_all(dst.join("build/builds"))); ++ println!("cargo:rustc-link-lib=wldap32"); ++ println!("cargo:rustc-link-lib=advapi32"); ++ println!("cargo:rustc-link-lib=normaliz"); ++} ++ ++#[cfg(not(target_env = "msvc"))] ++fn try_vcpkg() -> bool { ++ false ++} ++ ++#[cfg(target_env = "msvc")] ++fn try_vcpkg() -> bool { ++ ++ // the import library for the dll is called libcurl_imp ++ let mut successful_probe_details = ++ match vcpkg::Config::new().lib_names("libcurl_imp", "libcurl") ++ .emit_includes(true).probe("curl") { ++ Ok(details) => Some(details), ++ Err(e) => { ++ println!("first run of vcpkg did not find libcurl: {}", e); ++ None ++ } ++ }; ++ ++ if successful_probe_details.is_none() { ++ match vcpkg::Config::new().lib_name("libcurl") ++ .emit_includes(true).probe("curl") { ++ Ok(details) => successful_probe_details = Some(details), ++ Err(e) => println!("second run of vcpkg did not find libcurl: {}", e), ++ } ++ } ++ ++ if successful_probe_details.is_some() { ++ // Found libcurl which depends on openssl, libssh2 and zlib ++ // in the a default vcpkg installation. Probe for them ++ // but do not fail if they are not present as we may be working ++ // with a customized vcpkg installation. ++ vcpkg::Config::new() ++ .lib_name("libeay32") ++ .lib_name("ssleay32") ++ .probe("openssl").ok(); ++ ++ vcpkg::probe_package("libssh2").ok(); ++ ++ vcpkg::Config::new() ++ .lib_names("zlib", "zlib1") ++ .probe("zlib").ok(); ++ ++ println!("cargo:rustc-link-lib=crypt32"); ++ println!("cargo:rustc-link-lib=gdi32"); ++ println!("cargo:rustc-link-lib=user32"); ++ println!("cargo:rustc-link-lib=wldap32"); ++ return true; ++ } ++ false ++} ++ ++fn cp_r(src: &Path, dst: &Path) { ++ t!(fs::create_dir(dst)); ++ for e in t!(src.read_dir()).map(|e| t!(e)) { ++ let src = e.path(); ++ let dst = dst.join(e.file_name()); ++ if t!(e.file_type()).is_dir() { ++ cp_r(&src, &dst); ++ } else { ++ t!(fs::copy(&src, &dst)); ++ } ++ } ++} diff --cc vendor/curl-sys-0.3.15/lib.rs index 000000000,000000000..9b9490086 new file mode 100644 --- /dev/null +++ b/vendor/curl-sys-0.3.15/lib.rs @@@ -1,0 -1,0 +1,1049 @@@ ++#![allow(bad_style)] ++#![doc(html_root_url = "https://docs.rs/curl-sys/0.3")] ++ ++extern crate libc; ++#[cfg(not(target_env = "msvc"))] ++extern crate libz_sys; ++#[cfg(all(unix, not(target_os = "macos")))] ++extern crate openssl_sys; ++#[cfg(windows)] ++extern crate winapi; ++ ++use libc::{c_int, c_char, c_uint, c_short, c_long, c_double, c_void, size_t, time_t}; ++use libc::c_ulong; ++ ++#[cfg(unix)] ++use libc::fd_set; ++#[cfg(windows)] ++use winapi::fd_set; ++ ++#[cfg(target_env = "msvc")] ++#[doc(hidden)] ++pub type __enum_ty = libc::c_int; ++#[cfg(not(target_env = "msvc"))] ++#[doc(hidden)] ++pub type __enum_ty = libc::c_uint; ++ ++pub type CURLINFO = __enum_ty; ++pub type CURLoption = __enum_ty; ++pub type CURLcode = __enum_ty; ++pub type CURLversion = __enum_ty; ++pub type curl_off_t = i64; ++ ++pub enum CURL {} ++ ++#[cfg(unix)] ++pub type curl_socket_t = libc::c_int; ++#[cfg(unix)] ++pub const CURL_SOCKET_BAD: curl_socket_t = -1; ++#[cfg(all(windows, target_pointer_width = "32"))] ++pub type curl_socket_t = libc::c_uint; ++#[cfg(all(windows, target_pointer_width = "64"))] ++pub type curl_socket_t = u64; ++#[cfg(windows)] ++pub const CURL_SOCKET_BAD: curl_socket_t = !0; ++ ++pub enum curl_httppost { ++ // Note that this changed in some versions of libcurl, so we currently don't ++ // bind the fields as they're apparently not stable. ++ // pub next: *mut curl_httppost, ++ // pub name: *mut c_char, ++ // pub namelength: c_long, ++ // pub contents: *mut c_char, ++ // pub contentslength: c_long, ++ // pub buffer: *mut c_char, ++ // pub bufferlength: c_long, ++ // pub contenttype: *mut c_char, ++ // pub contentheader: *mut curl_slist, ++ // pub more: *mut curl_httppost, ++ // pub flags: c_long, ++ // pub showfilename: *mut c_char, ++ // pub userp: *mut c_void, ++} ++ ++// pub const HTTPPOST_FILENAME: c_long = 1 << 0; ++// pub const HTTPPOST_READFILE: c_long = 1 << 1; ++// pub const HTTPPOST_PTRNAME: c_long = 1 << 2; ++// pub const HTTPPOST_PTRCONTENTS: c_long = 1 << 3; ++// pub const HTTPPOST_BUFFER: c_long = 1 << 4; ++// pub const HTTPPOST_PTRBUFFER: c_long = 1 << 5; ++// pub const HTTPPOST_CALLBACK: c_long = 1 << 6; ++ ++pub type curl_progress_callback = extern fn(*mut c_void, ++ c_double, ++ c_double, ++ c_double, ++ c_double) -> c_int; ++// pub type curl_xferinfo_callback = extern fn(*mut c_void, ++// curl_off_t, ++// curl_off_t, ++// curl_off_t, ++// curl_off_t) -> c_int; ++ ++pub const CURL_WRITEFUNC_PAUSE: size_t = 0x10000001; ++ ++pub type curl_write_callback = extern fn(*mut c_char, ++ size_t, ++ size_t, ++ *mut c_void) -> size_t; ++ ++pub type curlfiletype = __enum_ty; ++pub const CURLFILETYPE_FILE: curlfiletype = 0; ++pub const CURLFILETYPE_DIRECTORY: curlfiletype = 1; ++pub const CURLFILETYPE_SYMLINK: curlfiletype = 2; ++pub const CURLFILETYPE_DEVICE_BLOCK: curlfiletype = 3; ++pub const CURLFILETYPE_DEVICE_CHAR: curlfiletype = 4; ++pub const CURLFILETYPE_NAMEDPIPE: curlfiletype = 5; ++pub const CURLFILETYPE_SOCKET: curlfiletype = 6; ++pub const CURLFILETYPE_DOOR: curlfiletype = 7; ++pub const CURLFILETYPE_UNKNOWN: curlfiletype = 8; ++ ++pub const CURLFINFOFLAG_KNOWN_FILENAME: c_uint = 1 << 0; ++pub const CURLFINFOFLAG_KNOWN_FILETYPE: c_uint = 1 << 1; ++pub const CURLFINFOFLAG_KNOWN_TIME: c_uint = 1 << 2; ++pub const CURLFINFOFLAG_KNOWN_PERM: c_uint = 1 << 3; ++pub const CURLFINFOFLAG_KNOWN_UID: c_uint = 1 << 4; ++pub const CURLFINFOFLAG_KNOWN_GID: c_uint = 1 << 5; ++pub const CURLFINFOFLAG_KNOWN_SIZE: c_uint = 1 << 6; ++pub const CURLFINFOFLAG_KNOWN_HLINKCOUNT: c_uint = 1 << 7; ++ ++#[repr(C)] ++pub struct curl_fileinfo { ++ pub filename: *mut c_char, ++ pub filetype: curlfiletype, ++ pub time: time_t, ++ pub perm: c_uint, ++ pub uid: c_int, ++ pub gid: c_int, ++ pub size: curl_off_t, ++ pub hardlinks: c_long, ++ ++ pub strings_time: *mut c_char, ++ pub strings_perm: *mut c_char, ++ pub strings_user: *mut c_char, ++ pub strings_group: *mut c_char, ++ pub strings_target: *mut c_char, ++ ++ pub flags: c_uint, ++ pub b_data: *mut c_char, ++ pub b_size: size_t, ++ pub b_used: size_t, ++} ++ ++pub const CURL_CHUNK_BGN_FUNC_OK: c_long = 0; ++pub const CURL_CHUNK_BGN_FUNC_FAIL: c_long = 1; ++pub const CURL_CHUNK_BGN_FUNC_SKIP: c_long = 2; ++pub type curl_chunk_bgn_callback = extern fn(*const c_void, ++ *mut c_void, ++ c_int) -> c_long; ++ ++pub const CURL_CHUNK_END_FUNC_OK: c_long = 0; ++pub const CURL_CHUNK_END_FUNC_FAIL: c_long = 1; ++pub type curl_chunk_end_callback = extern fn(*mut c_void) -> c_long; ++ ++pub const CURL_FNMATCHFUNC_MATCH: c_int = 0; ++pub const CURL_FNMATCHFUNC_NOMATCH: c_int = 1; ++pub const CURL_FNMATCHFUNC_FAIL: c_int = 2; ++pub type curl_fnmatch_callback = extern fn(*mut c_void, ++ *const c_char, ++ *const c_char) -> c_int; ++ ++pub const CURL_SEEKFUNC_OK: c_int = 0; ++pub const CURL_SEEKFUNC_FAIL: c_int = 1; ++pub const CURL_SEEKFUNC_CANTSEEK: c_int = 2; ++pub type curl_seek_callback = extern fn(*mut c_void, ++ curl_off_t, ++ c_int) -> c_int; ++ ++pub const CURL_READFUNC_ABORT: size_t = 0x10000000; ++pub const CURL_READFUNC_PAUSE: size_t = 0x10000001; ++pub type curl_read_callback = extern fn(*mut c_char, ++ size_t, ++ size_t, ++ *mut c_void) -> size_t; ++ ++// pub const CURL_SOCKOPT_OK: c_int = 0; ++// pub const CURL_SOCKOPT_ERROR: c_int = 1; ++// pub const CURL_SOCKOPT_ALREADY_CONNECTED: c_int = 2; ++// pub type curl_sockopt_callback = extern fn(*mut c_void, ++// curl_socket_t, ++// curlsocktype) -> c_int; ++ ++pub type curlioerr = __enum_ty; ++pub const CURLIOE_OK: curlioerr = 0; ++pub const CURLIOE_UNKNOWNCMD: curlioerr = 1; ++pub const CURLIOE_FAILRESTART: curlioerr = 2; ++ ++pub type curliocmd = __enum_ty; ++pub const CURLIOCMD_NOP: curliocmd = 0; ++pub const CURLIOCMD_RESTARTREAD: curliocmd = 1; ++ ++pub type curl_ioctl_callback = extern fn(*mut CURL, c_int, *mut c_void) -> curlioerr; ++ ++pub type curl_malloc_callback = extern fn(size_t) -> *mut c_void; ++pub type curl_free_callback = extern fn(*mut c_void); ++pub type curl_realloc_callback = extern fn(*mut c_void, size_t) -> *mut c_void; ++pub type curl_strdup_callback = extern fn(*const c_char) -> *mut c_char; ++pub type curl_calloc_callback = extern fn(size_t, size_t) -> *mut c_void; ++ ++pub type curl_infotype = __enum_ty; ++pub const CURLINFO_TEXT: curl_infotype = 0; ++pub const CURLINFO_HEADER_IN: curl_infotype = 1; ++pub const CURLINFO_HEADER_OUT: curl_infotype = 2; ++pub const CURLINFO_DATA_IN: curl_infotype = 3; ++pub const CURLINFO_DATA_OUT: curl_infotype = 4; ++pub const CURLINFO_SSL_DATA_IN: curl_infotype = 5; ++pub const CURLINFO_SSL_DATA_OUT: curl_infotype = 6; ++ ++pub type curl_debug_callback = extern fn(*mut CURL, ++ curl_infotype, ++ *mut c_char, ++ size_t, ++ *mut c_void) -> c_int; ++ ++pub const CURLE_OK: CURLcode = 0; ++pub const CURLE_UNSUPPORTED_PROTOCOL: CURLcode = 1; ++pub const CURLE_FAILED_INIT: CURLcode = 2; ++pub const CURLE_URL_MALFORMAT: CURLcode = 3; ++// pub const CURLE_NOT_BUILT_IN: CURLcode = 4; ++pub const CURLE_COULDNT_RESOLVE_PROXY: CURLcode = 5; ++pub const CURLE_COULDNT_RESOLVE_HOST: CURLcode = 6; ++pub const CURLE_COULDNT_CONNECT: CURLcode = 7; ++pub const CURLE_FTP_WEIRD_SERVER_REPLY: CURLcode = 8; ++pub const CURLE_REMOTE_ACCESS_DENIED: CURLcode = 9; ++// pub const CURLE_FTP_ACCEPT_FAILED: CURLcode = 10; ++pub const CURLE_FTP_WEIRD_PASS_REPLY: CURLcode = 11; ++// pub const CURLE_FTP_ACCEPT_TIMEOUT: CURLcode = 12; ++pub const CURLE_FTP_WEIRD_PASV_REPLY: CURLcode = 13; ++pub const CURLE_FTP_WEIRD_227_FORMAT: CURLcode = 14; ++pub const CURLE_FTP_CANT_GET_HOST: CURLcode = 15; ++pub const CURLE_OBSOLETE16: CURLcode = 16; ++pub const CURLE_FTP_COULDNT_SET_TYPE: CURLcode = 17; ++pub const CURLE_PARTIAL_FILE: CURLcode = 18; ++pub const CURLE_FTP_COULDNT_RETR_FILE: CURLcode = 19; ++pub const CURLE_OBSOLETE20: CURLcode = 20; ++pub const CURLE_QUOTE_ERROR: CURLcode = 21; ++pub const CURLE_HTTP_RETURNED_ERROR: CURLcode = 22; ++pub const CURLE_WRITE_ERROR: CURLcode = 23; ++pub const CURLE_OBSOLETE24: CURLcode = 24; ++pub const CURLE_UPLOAD_FAILED: CURLcode = 25; ++pub const CURLE_READ_ERROR: CURLcode = 26; ++pub const CURLE_OUT_OF_MEMORY: CURLcode = 27; ++pub const CURLE_OPERATION_TIMEDOUT: CURLcode = 28; ++pub const CURLE_OBSOLETE29: CURLcode = 29; ++pub const CURLE_FTP_PORT_FAILED: CURLcode = 30; ++pub const CURLE_FTP_COULDNT_USE_REST: CURLcode = 31; ++pub const CURLE_OBSOLETE32: CURLcode = 32; ++pub const CURLE_RANGE_ERROR: CURLcode = 33; ++pub const CURLE_HTTP_POST_ERROR: CURLcode = 34; ++pub const CURLE_SSL_CONNECT_ERROR: CURLcode = 35; ++pub const CURLE_BAD_DOWNLOAD_RESUME: CURLcode = 36; ++pub const CURLE_FILE_COULDNT_READ_FILE: CURLcode = 37; ++pub const CURLE_LDAP_CANNOT_BIND: CURLcode = 38; ++pub const CURLE_LDAP_SEARCH_FAILED: CURLcode = 39; ++pub const CURLE_OBSOLETE40: CURLcode = 40; ++pub const CURLE_FUNCTION_NOT_FOUND: CURLcode = 41; ++pub const CURLE_ABORTED_BY_CALLBACK: CURLcode = 42; ++pub const CURLE_BAD_FUNCTION_ARGUMENT: CURLcode = 43; ++pub const CURLE_OBSOLETE44: CURLcode = 44; ++pub const CURLE_INTERFACE_FAILED: CURLcode = 45; ++pub const CURLE_OBSOLETE46: CURLcode = 46; ++pub const CURLE_TOO_MANY_REDIRECTS : CURLcode = 47; ++pub const CURLE_UNKNOWN_OPTION: CURLcode = 48; ++pub const CURLE_TELNET_OPTION_SYNTAX : CURLcode = 49; ++pub const CURLE_OBSOLETE50: CURLcode = 50; ++pub const CURLE_PEER_FAILED_VERIFICATION: CURLcode = 51; ++pub const CURLE_GOT_NOTHING: CURLcode = 52; ++pub const CURLE_SSL_ENGINE_NOTFOUND: CURLcode = 53; ++pub const CURLE_SSL_ENGINE_SETFAILED: CURLcode = 54; ++pub const CURLE_SEND_ERROR: CURLcode = 55; ++pub const CURLE_RECV_ERROR: CURLcode = 56; ++pub const CURLE_OBSOLETE57: CURLcode = 57; ++pub const CURLE_SSL_CERTPROBLEM: CURLcode = 58; ++pub const CURLE_SSL_CIPHER: CURLcode = 59; ++pub const CURLE_SSL_CACERT: CURLcode = 60; ++pub const CURLE_BAD_CONTENT_ENCODING: CURLcode = 61; ++pub const CURLE_LDAP_INVALID_URL: CURLcode = 62; ++pub const CURLE_FILESIZE_EXCEEDED: CURLcode = 63; ++pub const CURLE_USE_SSL_FAILED: CURLcode = 64; ++pub const CURLE_SEND_FAIL_REWIND: CURLcode = 65; ++pub const CURLE_SSL_ENGINE_INITFAILED: CURLcode = 66; ++pub const CURLE_LOGIN_DENIED: CURLcode = 67; ++pub const CURLE_TFTP_NOTFOUND: CURLcode = 68; ++pub const CURLE_TFTP_PERM: CURLcode = 69; ++pub const CURLE_REMOTE_DISK_FULL: CURLcode = 70; ++pub const CURLE_TFTP_ILLEGAL: CURLcode = 71; ++pub const CURLE_TFTP_UNKNOWNID: CURLcode = 72; ++pub const CURLE_REMOTE_FILE_EXISTS: CURLcode = 73; ++pub const CURLE_TFTP_NOSUCHUSER: CURLcode = 74; ++pub const CURLE_CONV_FAILED: CURLcode = 75; ++pub const CURLE_CONV_REQD: CURLcode = 76; ++pub const CURLE_SSL_CACERT_BADFILE: CURLcode = 77; ++pub const CURLE_REMOTE_FILE_NOT_FOUND: CURLcode = 78; ++pub const CURLE_SSH: CURLcode = 79; ++pub const CURLE_SSL_SHUTDOWN_FAILED: CURLcode = 80; ++pub const CURLE_AGAIN: CURLcode = 81; ++pub const CURLE_SSL_CRL_BADFILE: CURLcode = 82; ++pub const CURLE_SSL_ISSUER_ERROR: CURLcode = 83; ++pub const CURLE_FTP_PRET_FAILED: CURLcode = 84; ++pub const CURLE_RTSP_CSEQ_ERROR: CURLcode = 85; ++pub const CURLE_RTSP_SESSION_ERROR: CURLcode = 86; ++pub const CURLE_FTP_BAD_FILE_LIST: CURLcode = 87; ++pub const CURLE_CHUNK_FAILED: CURLcode = 88; ++// pub const CURLE_NO_CONNECTION_AVAILABLE: CURLcode = 89; ++ ++pub type curl_conv_callback = extern fn(*mut c_char, size_t) -> CURLcode; ++pub type curl_ssl_ctx_callback = extern fn(*mut CURL, ++ *mut c_void, ++ *mut c_void) -> CURLcode; ++ ++pub type curl_proxytype = __enum_ty; ++pub const CURLPROXY_HTTP: curl_proxytype = 0; ++pub const CURLPROXY_HTTP_1_0: curl_proxytype = 1; ++pub const CURLPROXY_SOCKS4: curl_proxytype = 4; ++pub const CURLPROXY_SOCKS5: curl_proxytype = 5; ++pub const CURLPROXY_SOCKS4A: curl_proxytype = 6; ++pub const CURLPROXY_SOCKS5_HOSTNAME: curl_proxytype = 7; ++ ++pub const CURLAUTH_NONE: c_ulong = 0; ++pub const CURLAUTH_BASIC: c_ulong = 1 << 0; ++pub const CURLAUTH_DIGEST: c_ulong = 1 << 1; ++pub const CURLAUTH_GSSNEGOTIATE: c_ulong = 1 << 2; ++pub const CURLAUTH_NTLM: c_ulong = 1 << 3; ++pub const CURLAUTH_DIGEST_IE: c_ulong = 1 << 4; ++pub const CURLAUTH_NTLM_WB: c_ulong = 1 << 5; ++// pub const CURLAUTH_ONLY: c_ulong = 1 << 31; ++pub const CURLAUTH_ANY: c_ulong = !CURLAUTH_DIGEST_IE; ++pub const CURLAUTH_ANYSAFE: c_ulong = !(CURLAUTH_BASIC | CURLAUTH_DIGEST_IE); ++ ++// pub const CURLSSH_AUTH_ANY: c_ulong = !0; ++// pub const CURLSSH_AUTH_NONE: c_ulong = 0; ++// pub const CURLSSH_AUTH_PUBLICKEY: c_ulong = 1 << 0; ++// pub const CURLSSH_AUTH_PASSWORD: c_ulong = 1 << 1; ++// pub const CURLSSH_AUTH_HOST: c_ulong = 1 << 2; ++// pub const CURLSSH_AUTH_KEYBOARD: c_ulong = 1 << 3; ++// pub const CURLSSH_AUTH_AGENT: c_ulong = 1 << 4; ++// pub const CURLSSH_AUTH_DEFAULT: c_ulong = CURLSSH_AUTH_ANY; ++ ++pub const CURLGSSAPI_DELEGATION_NONE: c_ulong = 0; ++pub const CURLGSSAPI_DELEGATION_POLICY_FLAG: c_ulong = 1 << 0; ++pub const CURLGSSAPI_DELEGATION_FLAG: c_ulong = 1 << 1; ++ ++// pub type curl_khtype = __enum_ty; ++// pub const CURLKHTYPE_UNKNOWN: curl_khtype = 0; ++// pub const CURLKHTYPE_RSA1: curl_khtype = 1; ++// pub const CURLKHTYPE_RSA: curl_khtype = 2; ++// pub const CURLKHTYPE_DSS: curl_khtype = 3; ++ ++// #[repr(C)] ++// pub struct curl_khkey { ++// pub key: *const c_char, ++// pub len: size_t, ++// pub keytype: curl_khtype, ++// } ++ ++// pub type curl_khstat = __enum_ty; ++// pub const CURLKHSTAT_FINE_ADD_TO_FILE: curl_khstat = 0; ++// pub const CURLKHSTAT_FINE: curl_khstat = 1; ++// pub const CURLKHSTAT_REJECT: curl_khstat = 2; ++// pub const CURLKHSTAT_DEFER: curl_khstat = 3; ++// ++// pub type curl_khmatch = __enum_ty; ++// pub const CURLKHMATCH_OK: curl_khmatch = 0; ++// pub const CURLKHMATCH_MISMATCH: curl_khmatch = 1; ++// pub const CURLKHMATCH_MISSING: curl_khmatch = 2; ++ ++// pub type curl_sshkeycallback = extern fn(*mut CURL, ++// *const curl_khkey, ++// *const curl_khkey, ++// curl_khmatch, ++// *mut c_void) -> c_int; ++ ++pub const CURL_NETRC_IGNORED: c_ulong = 0; ++pub const CURL_NETRC_OPTIONAL: c_ulong = 1; ++pub const CURL_NETRC_REQUIRED: c_ulong = 2; ++ ++pub type curl_usessl = __enum_ty; ++pub const CURLUSESSL_NONE: curl_usessl = 0; ++pub const CURLUSESSL_TRY: curl_usessl = 1; ++pub const CURLUSESSL_CONTROL: curl_usessl = 2; ++pub const CURLUSESSL_ALL: curl_usessl = 3; ++ ++pub const CURLPROTO_HTTP: c_int = 1 << 0; ++pub const CURLPROTO_HTTPS: c_int = 1 << 1; ++pub const CURLPROTO_FILE: c_int = 1 << 10; ++ ++pub const CURLOPTTYPE_LONG: CURLoption = 0; ++pub const CURLOPTTYPE_OBJECTPOINT: CURLoption = 10_000; ++pub const CURLOPTTYPE_FUNCTIONPOINT: CURLoption = 20_000; ++pub const CURLOPTTYPE_OFF_T: CURLoption = 30_000; ++ ++pub const CURLOPT_FILE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 1; ++pub const CURLOPT_URL: CURLoption = CURLOPTTYPE_OBJECTPOINT + 2; ++pub const CURLOPT_PORT: CURLoption = CURLOPTTYPE_LONG + 3; ++pub const CURLOPT_PROXY: CURLoption = CURLOPTTYPE_OBJECTPOINT + 4; ++pub const CURLOPT_USERPWD: CURLoption = CURLOPTTYPE_OBJECTPOINT + 5; ++pub const CURLOPT_PROXYUSERPWD: CURLoption = CURLOPTTYPE_OBJECTPOINT + 6; ++pub const CURLOPT_RANGE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 7; ++pub const CURLOPT_INFILE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 9; ++pub const CURLOPT_ERRORBUFFER: CURLoption = CURLOPTTYPE_OBJECTPOINT + 10; ++pub const CURLOPT_WRITEFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 11; ++pub const CURLOPT_READFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 12; ++pub const CURLOPT_TIMEOUT: CURLoption = CURLOPTTYPE_LONG + 13; ++pub const CURLOPT_INFILESIZE: CURLoption = CURLOPTTYPE_LONG + 14; ++pub const CURLOPT_POSTFIELDS: CURLoption = CURLOPTTYPE_OBJECTPOINT + 15; ++pub const CURLOPT_REFERER: CURLoption = CURLOPTTYPE_OBJECTPOINT + 16; ++pub const CURLOPT_FTPPORT: CURLoption = CURLOPTTYPE_OBJECTPOINT + 17; ++pub const CURLOPT_USERAGENT: CURLoption = CURLOPTTYPE_OBJECTPOINT + 18; ++pub const CURLOPT_LOW_SPEED_LIMIT: CURLoption = CURLOPTTYPE_LONG + 19; ++pub const CURLOPT_LOW_SPEED_TIME: CURLoption = CURLOPTTYPE_LONG + 20; ++pub const CURLOPT_RESUME_FROM: CURLoption = CURLOPTTYPE_LONG + 21; ++pub const CURLOPT_COOKIE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 22; ++pub const CURLOPT_HTTPHEADER: CURLoption = CURLOPTTYPE_OBJECTPOINT + 23; ++pub const CURLOPT_HTTPPOST: CURLoption = CURLOPTTYPE_OBJECTPOINT + 24; ++pub const CURLOPT_SSLCERT: CURLoption = CURLOPTTYPE_OBJECTPOINT + 25; ++pub const CURLOPT_KEYPASSWD: CURLoption = CURLOPTTYPE_OBJECTPOINT + 26; ++pub const CURLOPT_CRLF: CURLoption = CURLOPTTYPE_LONG + 27; ++pub const CURLOPT_QUOTE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 28; ++pub const CURLOPT_WRITEHEADER: CURLoption = CURLOPTTYPE_OBJECTPOINT + 29; ++pub const CURLOPT_COOKIEFILE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 31; ++pub const CURLOPT_SSLVERSION: CURLoption = CURLOPTTYPE_LONG + 32; ++pub const CURLOPT_TIMECONDITION: CURLoption = CURLOPTTYPE_LONG + 33; ++pub const CURLOPT_TIMEVALUE: CURLoption = CURLOPTTYPE_LONG + 34; ++pub const CURLOPT_CUSTOMREQUEST: CURLoption = CURLOPTTYPE_OBJECTPOINT + 36; ++pub const CURLOPT_STDERR: CURLoption = CURLOPTTYPE_OBJECTPOINT + 37; ++pub const CURLOPT_POSTQUOTE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 39; ++pub const CURLOPT_WRITEINFO: CURLoption = CURLOPTTYPE_OBJECTPOINT + 40; ++pub const CURLOPT_VERBOSE: CURLoption = CURLOPTTYPE_LONG + 41; ++pub const CURLOPT_HEADER: CURLoption = CURLOPTTYPE_LONG + 42; ++pub const CURLOPT_NOPROGRESS: CURLoption = CURLOPTTYPE_LONG + 43; ++pub const CURLOPT_NOBODY: CURLoption = CURLOPTTYPE_LONG + 44; ++pub const CURLOPT_FAILONERROR: CURLoption = CURLOPTTYPE_LONG + 45; ++pub const CURLOPT_UPLOAD: CURLoption = CURLOPTTYPE_LONG + 46; ++pub const CURLOPT_POST: CURLoption = CURLOPTTYPE_LONG + 47; ++pub const CURLOPT_DIRLISTONLY: CURLoption = CURLOPTTYPE_LONG + 48; ++pub const CURLOPT_APPEND: CURLoption = CURLOPTTYPE_LONG + 50; ++pub const CURLOPT_NETRC: CURLoption = CURLOPTTYPE_LONG + 51; ++pub const CURLOPT_FOLLOWLOCATION: CURLoption = CURLOPTTYPE_LONG + 52; ++pub const CURLOPT_TRANSFERTEXT: CURLoption = CURLOPTTYPE_LONG + 53; ++pub const CURLOPT_PUT: CURLoption = CURLOPTTYPE_LONG + 54; ++pub const CURLOPT_PROGRESSFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 56; ++pub const CURLOPT_PROGRESSDATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 57; ++pub const CURLOPT_AUTOREFERER: CURLoption = CURLOPTTYPE_LONG + 58; ++pub const CURLOPT_PROXYPORT: CURLoption = CURLOPTTYPE_LONG + 59; ++pub const CURLOPT_POSTFIELDSIZE: CURLoption = CURLOPTTYPE_LONG + 60; ++pub const CURLOPT_HTTPPROXYTUNNEL: CURLoption = CURLOPTTYPE_LONG + 61; ++pub const CURLOPT_INTERFACE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 62; ++pub const CURLOPT_KRBLEVEL: CURLoption = CURLOPTTYPE_OBJECTPOINT + 63; ++pub const CURLOPT_SSL_VERIFYPEER: CURLoption = CURLOPTTYPE_LONG + 64; ++pub const CURLOPT_CAINFO: CURLoption = CURLOPTTYPE_OBJECTPOINT + 65; ++pub const CURLOPT_MAXREDIRS: CURLoption = CURLOPTTYPE_LONG + 68; ++pub const CURLOPT_FILETIME: CURLoption = CURLOPTTYPE_LONG + 69; ++pub const CURLOPT_TELNETOPTIONS: CURLoption = CURLOPTTYPE_OBJECTPOINT + 70; ++pub const CURLOPT_MAXCONNECTS: CURLoption = CURLOPTTYPE_LONG + 71; ++pub const CURLOPT_CLOSEPOLICY: CURLoption = CURLOPTTYPE_LONG + 72; ++pub const CURLOPT_FRESH_CONNECT: CURLoption = CURLOPTTYPE_LONG + 74; ++pub const CURLOPT_FORBID_REUSE: CURLoption = CURLOPTTYPE_LONG + 75; ++pub const CURLOPT_RANDOM_FILE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 76; ++pub const CURLOPT_EGDSOCKET: CURLoption = CURLOPTTYPE_OBJECTPOINT + 77; ++pub const CURLOPT_CONNECTTIMEOUT: CURLoption = CURLOPTTYPE_LONG + 78; ++pub const CURLOPT_HEADERFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 79; ++pub const CURLOPT_HTTPGET: CURLoption = CURLOPTTYPE_LONG + 80; ++pub const CURLOPT_SSL_VERIFYHOST: CURLoption = CURLOPTTYPE_LONG + 81; ++pub const CURLOPT_COOKIEJAR: CURLoption = CURLOPTTYPE_OBJECTPOINT + 82; ++pub const CURLOPT_SSL_CIPHER_LIST: CURLoption = CURLOPTTYPE_OBJECTPOINT + 83; ++pub const CURLOPT_HTTP_VERSION: CURLoption = CURLOPTTYPE_LONG + 84; ++pub const CURLOPT_FTP_USE_EPSV: CURLoption = CURLOPTTYPE_LONG + 85; ++pub const CURLOPT_SSLCERTTYPE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 86; ++pub const CURLOPT_SSLKEY: CURLoption = CURLOPTTYPE_OBJECTPOINT + 87; ++pub const CURLOPT_SSLKEYTYPE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 88; ++pub const CURLOPT_SSLENGINE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 89; ++pub const CURLOPT_SSLENGINE_DEFAULT: CURLoption = CURLOPTTYPE_LONG + 90; ++pub const CURLOPT_DNS_USE_GLOBAL_CACHE: CURLoption = CURLOPTTYPE_LONG + 91; ++pub const CURLOPT_DNS_CACHE_TIMEOUT: CURLoption = CURLOPTTYPE_LONG + 92; ++pub const CURLOPT_PREQUOTE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 93; ++pub const CURLOPT_DEBUGFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 94; ++pub const CURLOPT_DEBUGDATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 95; ++pub const CURLOPT_COOKIESESSION: CURLoption = CURLOPTTYPE_LONG + 96; ++pub const CURLOPT_CAPATH: CURLoption = CURLOPTTYPE_OBJECTPOINT + 97; ++pub const CURLOPT_BUFFERSIZE: CURLoption = CURLOPTTYPE_LONG + 98; ++pub const CURLOPT_NOSIGNAL: CURLoption = CURLOPTTYPE_LONG + 99; ++pub const CURLOPT_SHARE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 100; ++pub const CURLOPT_PROXYTYPE: CURLoption = CURLOPTTYPE_LONG + 101; ++pub const CURLOPT_ACCEPT_ENCODING: CURLoption = CURLOPTTYPE_OBJECTPOINT + 102; ++pub const CURLOPT_PRIVATE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 103; ++pub const CURLOPT_HTTP200ALIASES: CURLoption = CURLOPTTYPE_OBJECTPOINT + 104; ++pub const CURLOPT_UNRESTRICTED_AUTH: CURLoption = CURLOPTTYPE_LONG + 105; ++pub const CURLOPT_FTP_USE_EPRT: CURLoption = CURLOPTTYPE_LONG + 106; ++pub const CURLOPT_HTTPAUTH: CURLoption = CURLOPTTYPE_LONG + 107; ++pub const CURLOPT_SSL_CTX_FUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 108; ++pub const CURLOPT_SSL_CTX_DATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 109; ++pub const CURLOPT_FTP_CREATE_MISSING_DIRS: CURLoption = CURLOPTTYPE_LONG + 110; ++pub const CURLOPT_PROXYAUTH: CURLoption = CURLOPTTYPE_LONG + 111; ++pub const CURLOPT_FTP_RESPONSE_TIMEOUT: CURLoption = CURLOPTTYPE_LONG + 112; ++pub const CURLOPT_IPRESOLVE: CURLoption = CURLOPTTYPE_LONG + 113; ++pub const CURLOPT_MAXFILESIZE: CURLoption = CURLOPTTYPE_LONG + 114; ++pub const CURLOPT_INFILESIZE_LARGE: CURLoption = CURLOPTTYPE_OFF_T + 115; ++pub const CURLOPT_RESUME_FROM_LARGE: CURLoption = CURLOPTTYPE_OFF_T + 116; ++pub const CURLOPT_MAXFILESIZE_LARGE: CURLoption = CURLOPTTYPE_OFF_T + 117; ++pub const CURLOPT_NETRC_FILE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 118; ++pub const CURLOPT_USE_SSL: CURLoption = CURLOPTTYPE_LONG + 119; ++pub const CURLOPT_POSTFIELDSIZE_LARGE: CURLoption = CURLOPTTYPE_OFF_T + 120; ++pub const CURLOPT_TCP_NODELAY: CURLoption = CURLOPTTYPE_LONG + 121; ++pub const CURLOPT_FTPSSLAUTH: CURLoption = CURLOPTTYPE_LONG + 129; ++pub const CURLOPT_IOCTLFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 130; ++pub const CURLOPT_IOCTLDATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 131; ++pub const CURLOPT_FTP_ACCOUNT: CURLoption = CURLOPTTYPE_OBJECTPOINT + 134; ++pub const CURLOPT_COOKIELIST: CURLoption = CURLOPTTYPE_OBJECTPOINT + 135; ++pub const CURLOPT_IGNORE_CONTENT_LENGTH: CURLoption = CURLOPTTYPE_LONG + 136; ++pub const CURLOPT_FTP_SKIP_PASV_IP: CURLoption = CURLOPTTYPE_LONG + 137; ++pub const CURLOPT_FTP_FILEMETHOD: CURLoption = CURLOPTTYPE_LONG + 138; ++pub const CURLOPT_LOCALPORT: CURLoption = CURLOPTTYPE_LONG + 139; ++pub const CURLOPT_LOCALPORTRANGE: CURLoption = CURLOPTTYPE_LONG + 140; ++pub const CURLOPT_CONNECT_ONLY: CURLoption = CURLOPTTYPE_LONG + 141; ++pub const CURLOPT_CONV_FROM_NETWORK_FUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 142; ++pub const CURLOPT_CONV_TO_NETWORK_FUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 143; ++pub const CURLOPT_CONV_FROM_UTF8_FUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 144; ++pub const CURLOPT_MAX_SEND_SPEED_LARGE: CURLoption = CURLOPTTYPE_OFF_T + 145; ++pub const CURLOPT_MAX_RECV_SPEED_LARGE: CURLoption = CURLOPTTYPE_OFF_T + 146; ++pub const CURLOPT_FTP_ALTERNATIVE_TO_USER: CURLoption = CURLOPTTYPE_OBJECTPOINT + 147; ++pub const CURLOPT_SOCKOPTFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 148; ++pub const CURLOPT_SOCKOPTDATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 149; ++pub const CURLOPT_SSL_SESSIONID_CACHE: CURLoption = CURLOPTTYPE_LONG + 150; ++pub const CURLOPT_SSH_AUTH_TYPES: CURLoption = CURLOPTTYPE_LONG + 151; ++pub const CURLOPT_SSH_PUBLIC_KEYFILE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 152; ++pub const CURLOPT_SSH_PRIVATE_KEYFILE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 153; ++pub const CURLOPT_FTP_SSL_CCC: CURLoption = CURLOPTTYPE_LONG + 154; ++pub const CURLOPT_TIMEOUT_MS: CURLoption = CURLOPTTYPE_LONG + 155; ++pub const CURLOPT_CONNECTTIMEOUT_MS: CURLoption = CURLOPTTYPE_LONG + 156; ++pub const CURLOPT_HTTP_TRANSFER_DECODING: CURLoption = CURLOPTTYPE_LONG + 157; ++pub const CURLOPT_HTTP_CONTENT_DECODING: CURLoption = CURLOPTTYPE_LONG + 158; ++pub const CURLOPT_NEW_FILE_PERMS: CURLoption = CURLOPTTYPE_LONG + 159; ++pub const CURLOPT_NEW_DIRECTORY_PERMS: CURLoption = CURLOPTTYPE_LONG + 160; ++pub const CURLOPT_POSTREDIR: CURLoption = CURLOPTTYPE_LONG + 161; ++pub const CURLOPT_SSH_HOST_PUBLIC_KEY_MD5: CURLoption = CURLOPTTYPE_OBJECTPOINT + 162; ++pub const CURLOPT_OPENSOCKETFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 163; ++pub const CURLOPT_OPENSOCKETDATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 164; ++pub const CURLOPT_COPYPOSTFIELDS: CURLoption = CURLOPTTYPE_OBJECTPOINT + 165; ++pub const CURLOPT_PROXY_TRANSFER_MODE: CURLoption = CURLOPTTYPE_LONG + 166; ++pub const CURLOPT_SEEKFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 167; ++pub const CURLOPT_SEEKDATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 168; ++pub const CURLOPT_CRLFILE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 169; ++pub const CURLOPT_ISSUERCERT: CURLoption = CURLOPTTYPE_OBJECTPOINT + 170; ++pub const CURLOPT_ADDRESS_SCOPE: CURLoption = CURLOPTTYPE_LONG + 171; ++pub const CURLOPT_CERTINFO: CURLoption = CURLOPTTYPE_LONG + 172; ++pub const CURLOPT_USERNAME: CURLoption = CURLOPTTYPE_OBJECTPOINT + 173; ++pub const CURLOPT_PASSWORD: CURLoption = CURLOPTTYPE_OBJECTPOINT + 174; ++pub const CURLOPT_PROXYUSERNAME: CURLoption = CURLOPTTYPE_OBJECTPOINT + 175; ++pub const CURLOPT_PROXYPASSWORD: CURLoption = CURLOPTTYPE_OBJECTPOINT + 176; ++pub const CURLOPT_NOPROXY: CURLoption = CURLOPTTYPE_OBJECTPOINT + 177; ++pub const CURLOPT_TFTP_BLKSIZE: CURLoption = CURLOPTTYPE_LONG + 178; ++pub const CURLOPT_SOCKS5_GSSAPI_SERVICE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 179; ++pub const CURLOPT_SOCKS5_GSSAPI_NEC: CURLoption = CURLOPTTYPE_LONG + 180; ++pub const CURLOPT_PROTOCOLS: CURLoption = CURLOPTTYPE_LONG + 181; ++pub const CURLOPT_REDIR_PROTOCOLS: CURLoption = CURLOPTTYPE_LONG + 182; ++pub const CURLOPT_SSH_KNOWNHOSTS: CURLoption = CURLOPTTYPE_OBJECTPOINT + 183; ++pub const CURLOPT_SSH_KEYFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 184; ++pub const CURLOPT_SSH_KEYDATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 185; ++pub const CURLOPT_MAIL_FROM: CURLoption = CURLOPTTYPE_OBJECTPOINT + 186; ++pub const CURLOPT_MAIL_RCPT: CURLoption = CURLOPTTYPE_OBJECTPOINT + 187; ++pub const CURLOPT_FTP_USE_PRET: CURLoption = CURLOPTTYPE_LONG + 188; ++pub const CURLOPT_RTSP_REQUEST: CURLoption = CURLOPTTYPE_LONG + 189; ++pub const CURLOPT_RTSP_SESSION_ID: CURLoption = CURLOPTTYPE_OBJECTPOINT + 190; ++pub const CURLOPT_RTSP_STREAM_URI: CURLoption = CURLOPTTYPE_OBJECTPOINT + 191; ++pub const CURLOPT_RTSP_TRANSPORT: CURLoption = CURLOPTTYPE_OBJECTPOINT + 192; ++pub const CURLOPT_RTSP_CLIENT_CSEQ: CURLoption = CURLOPTTYPE_LONG + 193; ++pub const CURLOPT_RTSP_SERVER_CSEQ: CURLoption = CURLOPTTYPE_LONG + 194; ++pub const CURLOPT_INTERLEAVEDATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 195; ++pub const CURLOPT_INTERLEAVEFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 196; ++pub const CURLOPT_WILDCARDMATCH: CURLoption = CURLOPTTYPE_LONG + 197; ++pub const CURLOPT_CHUNK_BGN_FUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 198; ++pub const CURLOPT_CHUNK_END_FUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 199; ++pub const CURLOPT_FNMATCH_FUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 200; ++pub const CURLOPT_CHUNK_DATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 201; ++pub const CURLOPT_FNMATCH_DATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 202; ++pub const CURLOPT_RESOLVE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 203; ++pub const CURLOPT_TLSAUTH_USERNAME: CURLoption = CURLOPTTYPE_OBJECTPOINT + 204; ++pub const CURLOPT_TLSAUTH_PASSWORD: CURLoption = CURLOPTTYPE_OBJECTPOINT + 205; ++pub const CURLOPT_TLSAUTH_TYPE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 206; ++pub const CURLOPT_TRANSFER_ENCODING: CURLoption = CURLOPTTYPE_LONG + 207; ++pub const CURLOPT_CLOSESOCKETFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 208; ++pub const CURLOPT_CLOSESOCKETDATA: CURLoption = CURLOPTTYPE_OBJECTPOINT + 209; ++pub const CURLOPT_GSSAPI_DELEGATION: CURLoption = CURLOPTTYPE_LONG + 210; ++// pub const CURLOPT_DNS_SERVERS: CURLoption = CURLOPTTYPE_OBJECTPOINT + 211; ++// pub const CURLOPT_ACCEPTTIMEOUT_MS: CURLoption = CURLOPTTYPE_LONG + 212; ++pub const CURLOPT_TCP_KEEPALIVE: CURLoption = CURLOPTTYPE_LONG + 213; ++pub const CURLOPT_TCP_KEEPIDLE: CURLoption = CURLOPTTYPE_LONG + 214; ++pub const CURLOPT_TCP_KEEPINTVL: CURLoption = CURLOPTTYPE_LONG + 215; ++pub const CURLOPT_SSL_OPTIONS: CURLoption = CURLOPTTYPE_LONG + 216; ++// pub const CURLOPT_MAIL_AUTH: CURLoption = CURLOPTTYPE_OBJECTPOINT + 217; ++// pub const CURLOPT_SASL_IR: CURLoption = CURLOPTTYPE_LONG + 218; ++// pub const CURLOPT_XFERINFOFUNCTION: CURLoption = CURLOPTTYPE_FUNCTIONPOINT + 219; ++// pub const CURLOPT_XOAUTH2_BEARER: CURLoption = CURLOPTTYPE_OBJECTPOINT + 220; ++// pub const CURLOPT_DNS_INTERFACE: CURLoption = CURLOPTTYPE_OBJECTPOINT + 221; ++// pub const CURLOPT_DNS_LOCAL_IP4: CURLoption = CURLOPTTYPE_OBJECTPOINT + 222; ++// pub const CURLOPT_DNS_LOCAL_IP6: CURLoption = CURLOPTTYPE_OBJECTPOINT + 223; ++// pub const CURLOPT_LOGIN_OPTIONS: CURLoption = CURLOPTTYPE_OBJECTPOINT + 224; ++pub const CURLOPT_UNIX_SOCKET_PATH: CURLoption = CURLOPTTYPE_OBJECTPOINT + 231; ++ ++pub const CURL_IPRESOLVE_WHATEVER: c_int = 0; ++pub const CURL_IPRESOLVE_V4: c_int = 1; ++pub const CURL_IPRESOLVE_V6: c_int = 2; ++ ++pub const CURLSSLOPT_ALLOW_BEAST: c_long = 1 << 0; ++pub const CURLSSLOPT_NO_REVOKE: c_long = 1 << 1; ++ ++/// These enums are for use with the CURLOPT_HTTP_VERSION option. ++/// ++/// Setting this means we don't care, and that we'd like the library to choose ++/// the best possible for us! ++pub const CURL_HTTP_VERSION_NONE: c_int = 0; ++/// Please use HTTP 1.0 in the request ++pub const CURL_HTTP_VERSION_1_0: c_int = 1; ++/// Please use HTTP 1.1 in the request ++pub const CURL_HTTP_VERSION_1_1: c_int = 2; ++/// Please use HTTP 2 in the request ++/// (Added in CURL 7.33.0) ++pub const CURL_HTTP_VERSION_2_0: c_int = 3; ++/// Use version 2 for HTTPS, version 1.1 for HTTP ++/// (Added in CURL 7.47.0) ++pub const CURL_HTTP_VERSION_2TLS: c_int = 4; ++/// Please use HTTP 2 without HTTP/1.1 Upgrade ++/// (Added in CURL 7.49.0) ++pub const CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE: c_int = 5; ++ ++// Note that the type here is wrong, it's just intended to just be an enum. ++pub const CURL_SSLVERSION_DEFAULT: CURLoption = 0; ++pub const CURL_SSLVERSION_TLSv1: CURLoption = 1; ++pub const CURL_SSLVERSION_SSLv2: CURLoption = 2; ++pub const CURL_SSLVERSION_SSLv3: CURLoption = 3; ++// pub const CURL_SSLVERSION_TLSv1_0: CURLoption = 4; ++// pub const CURL_SSLVERSION_TLSv1_1: CURLoption = 5; ++// pub const CURL_SSLVERSION_TLSv1_2: CURLoption = 6; ++ ++pub const CURLOPT_READDATA: CURLoption = CURLOPT_INFILE; ++pub const CURLOPT_WRITEDATA: CURLoption = CURLOPT_FILE; ++pub const CURLOPT_HEADERDATA: CURLoption = CURLOPT_WRITEHEADER; ++ ++pub type curl_TimeCond = __enum_ty; ++pub const CURL_TIMECOND_NONE: curl_TimeCond = 0; ++pub const CURL_TIMECOND_IFMODSINCE: curl_TimeCond = 1; ++pub const CURL_TIMECOND_IFUNMODSINCE: curl_TimeCond = 2; ++pub const CURL_TIMECOND_LASTMOD: curl_TimeCond = 3; ++ ++pub type CURLformoption = __enum_ty; ++pub const CURLFORM_NOTHING: CURLformoption = 0; ++pub const CURLFORM_COPYNAME: CURLformoption = 1; ++pub const CURLFORM_PTRNAME: CURLformoption = 2; ++pub const CURLFORM_NAMELENGTH: CURLformoption = 3; ++pub const CURLFORM_COPYCONTENTS: CURLformoption = 4; ++pub const CURLFORM_PTRCONTENTS: CURLformoption = 5; ++pub const CURLFORM_CONTENTSLENGTH: CURLformoption = 6; ++pub const CURLFORM_FILECONTENT: CURLformoption = 7; ++pub const CURLFORM_ARRAY: CURLformoption = 8; ++pub const CURLFORM_OBSOLETE: CURLformoption = 9; ++pub const CURLFORM_FILE: CURLformoption = 10; ++pub const CURLFORM_BUFFER: CURLformoption = 11; ++pub const CURLFORM_BUFFERPTR: CURLformoption = 12; ++pub const CURLFORM_BUFFERLENGTH: CURLformoption = 13; ++pub const CURLFORM_CONTENTTYPE: CURLformoption = 14; ++pub const CURLFORM_CONTENTHEADER: CURLformoption = 15; ++pub const CURLFORM_FILENAME: CURLformoption = 16; ++pub const CURLFORM_END: CURLformoption = 17; ++pub const CURLFORM_STREAM: CURLformoption = 19; ++ ++pub type CURLFORMcode = __enum_ty; ++pub const CURL_FORMADD_OK: CURLFORMcode = 0; ++pub const CURL_FORMADD_MEMORY: CURLFORMcode = 1; ++pub const CURL_FORMADD_OPTION_TWICE: CURLFORMcode = 2; ++pub const CURL_FORMADD_NULL: CURLFORMcode = 3; ++pub const CURL_FORMADD_UNKNOWN_OPTION: CURLFORMcode = 4; ++pub const CURL_FORMADD_INCOMPLETE: CURLFORMcode = 5; ++pub const CURL_FORMADD_ILLEGAL_ARRAY: CURLFORMcode = 6; ++pub const CURL_FORMADD_DISABLED: CURLFORMcode = 7; ++ ++#[repr(C)] ++pub struct curl_forms { ++ pub option: CURLformoption, ++ pub value: *const c_char, ++} ++ ++pub type curl_formget_callback = extern fn(*mut c_void, ++ *const c_char, ++ size_t) -> size_t; ++ ++#[repr(C)] ++pub struct curl_slist { ++ pub data: *mut c_char, ++ pub next: *mut curl_slist, ++} ++ ++#[repr(C)] ++pub struct curl_certinfo { ++ pub num_of_certs: c_int, ++ pub certinfo: *mut *mut curl_slist, ++} ++ ++// pub type curl_sslbackend = __enum_ty; ++// pub const CURLSSLBACKEND_NONE: curl_sslbackend = 0; ++// pub const CURLSSLBACKEND_OPENSSL: curl_sslbackend = 1; ++// pub const CURLSSLBACKEND_GNUTLS: curl_sslbackend = 2; ++// pub const CURLSSLBACKEND_NSS: curl_sslbackend = 3; ++// pub const CURLSSLBACKEND_QSOSSL: curl_sslbackend = 4; ++// pub const CURLSSLBACKEND_GSKIT: curl_sslbackend = 5; ++// pub const CURLSSLBACKEND_POLARSSL: curl_sslbackend = 6; ++// pub const CURLSSLBACKEND_CYASSL: curl_sslbackend = 7; ++// pub const CURLSSLBACKEND_SCHANNEL: curl_sslbackend = 8; ++// pub const CURLSSLBACKEND_DARWINSSL: curl_sslbackend = 9; ++ ++// #[repr(C)] ++// pub struct curl_tlssessioninfo { ++// pub backend: curl_sslbackend, ++// pub internals: *mut c_void, ++// } ++ ++pub const CURLINFO_STRING: CURLINFO = 0x100000; ++pub const CURLINFO_LONG: CURLINFO = 0x200000; ++pub const CURLINFO_DOUBLE: CURLINFO = 0x300000; ++pub const CURLINFO_SLIST: CURLINFO = 0x400000; ++pub const CURLINFO_MASK: CURLINFO = 0x0fffff; ++pub const CURLINFO_TYPEMASK: CURLINFO = 0xf00000; ++ ++pub const CURLINFO_EFFECTIVE_URL: CURLINFO = CURLINFO_STRING + 1; ++pub const CURLINFO_RESPONSE_CODE: CURLINFO = CURLINFO_LONG + 2; ++pub const CURLINFO_TOTAL_TIME: CURLINFO = CURLINFO_DOUBLE + 3; ++pub const CURLINFO_NAMELOOKUP_TIME: CURLINFO = CURLINFO_DOUBLE + 4; ++pub const CURLINFO_CONNECT_TIME: CURLINFO = CURLINFO_DOUBLE + 5; ++pub const CURLINFO_PRETRANSFER_TIME: CURLINFO = CURLINFO_DOUBLE + 6; ++pub const CURLINFO_SIZE_UPLOAD: CURLINFO = CURLINFO_DOUBLE + 7; ++pub const CURLINFO_SIZE_DOWNLOAD: CURLINFO = CURLINFO_DOUBLE + 8; ++pub const CURLINFO_SPEED_DOWNLOAD: CURLINFO = CURLINFO_DOUBLE + 9; ++pub const CURLINFO_SPEED_UPLOAD: CURLINFO = CURLINFO_DOUBLE + 10; ++pub const CURLINFO_HEADER_SIZE: CURLINFO = CURLINFO_LONG + 11; ++pub const CURLINFO_REQUEST_SIZE: CURLINFO = CURLINFO_LONG + 12; ++pub const CURLINFO_SSL_VERIFYRESULT: CURLINFO = CURLINFO_LONG + 13; ++pub const CURLINFO_FILETIME: CURLINFO = CURLINFO_LONG + 14; ++pub const CURLINFO_CONTENT_LENGTH_DOWNLOAD: CURLINFO = CURLINFO_DOUBLE + 15; ++pub const CURLINFO_CONTENT_LENGTH_UPLOAD: CURLINFO = CURLINFO_DOUBLE + 16; ++pub const CURLINFO_STARTTRANSFER_TIME: CURLINFO = CURLINFO_DOUBLE + 17; ++pub const CURLINFO_CONTENT_TYPE: CURLINFO = CURLINFO_STRING + 18; ++pub const CURLINFO_REDIRECT_TIME: CURLINFO = CURLINFO_DOUBLE + 19; ++pub const CURLINFO_REDIRECT_COUNT: CURLINFO = CURLINFO_LONG + 20; ++pub const CURLINFO_PRIVATE: CURLINFO = CURLINFO_STRING + 21; ++pub const CURLINFO_HTTP_CONNECTCODE: CURLINFO = CURLINFO_LONG + 22; ++pub const CURLINFO_HTTPAUTH_AVAIL: CURLINFO = CURLINFO_LONG + 23; ++pub const CURLINFO_PROXYAUTH_AVAIL: CURLINFO = CURLINFO_LONG + 24; ++pub const CURLINFO_OS_ERRNO: CURLINFO = CURLINFO_LONG + 25; ++pub const CURLINFO_NUM_CONNECTS: CURLINFO = CURLINFO_LONG + 26; ++pub const CURLINFO_SSL_ENGINES: CURLINFO = CURLINFO_SLIST + 27; ++pub const CURLINFO_COOKIELIST: CURLINFO = CURLINFO_SLIST + 28; ++pub const CURLINFO_LASTSOCKET: CURLINFO = CURLINFO_LONG + 29; ++pub const CURLINFO_FTP_ENTRY_PATH: CURLINFO = CURLINFO_STRING + 30; ++pub const CURLINFO_REDIRECT_URL: CURLINFO = CURLINFO_STRING + 31; ++pub const CURLINFO_PRIMARY_IP: CURLINFO = CURLINFO_STRING + 32; ++pub const CURLINFO_APPCONNECT_TIME: CURLINFO = CURLINFO_DOUBLE + 33; ++pub const CURLINFO_CERTINFO: CURLINFO = CURLINFO_SLIST + 34; ++pub const CURLINFO_CONDITION_UNMET: CURLINFO = CURLINFO_LONG + 35; ++pub const CURLINFO_RTSP_SESSION_ID: CURLINFO = CURLINFO_STRING + 36; ++pub const CURLINFO_RTSP_CLIENT_CSEQ: CURLINFO = CURLINFO_LONG + 37; ++pub const CURLINFO_RTSP_SERVER_CSEQ: CURLINFO = CURLINFO_LONG + 38; ++pub const CURLINFO_RTSP_CSEQ_RECV: CURLINFO = CURLINFO_LONG + 39; ++pub const CURLINFO_PRIMARY_PORT: CURLINFO = CURLINFO_LONG + 40; ++pub const CURLINFO_LOCAL_IP: CURLINFO = CURLINFO_STRING + 41; ++pub const CURLINFO_LOCAL_PORT: CURLINFO = CURLINFO_LONG + 42; ++// pub const CURLINFO_TLS_SESSION: CURLINFO = CURLINFO_SLIST + 43; ++ ++pub type curl_closepolicy = __enum_ty; ++pub const CURLCLOSEPOLICY_NONE: curl_closepolicy = 0; ++pub const CURLCLOSEPOLICY_OLDEST: curl_closepolicy = 1; ++pub const CURLCLOSEPOLICY_LEAST_RECENTLY_USED: curl_closepolicy = 2; ++pub const CURLCLOSEPOLICY_LEAST_TRAFFIC: curl_closepolicy = 3; ++pub const CURLCLOSEPOLICY_SLOWEST: curl_closepolicy = 4; ++pub const CURLCLOSEPOLICY_CALLBACK: curl_closepolicy = 5; ++ ++pub const CURL_GLOBAL_SSL: c_long = 1 << 0; ++pub const CURL_GLOBAL_WIN32: c_long = 1 << 1; ++pub const CURL_GLOBAL_ALL: c_long = CURL_GLOBAL_SSL | CURL_GLOBAL_WIN32; ++pub const CURL_GLOBAL_NOTHING: c_long = 0; ++pub const CURL_GLOBAL_DEFAULT: c_long = CURL_GLOBAL_ALL; ++// pub const CURL_GLOBAL_ACK_EINTR: c_long = 1 << 2; ++ ++pub type curl_lock_data = __enum_ty; ++pub const CURL_LOCK_DATA_NONE: curl_lock_data = 0; ++pub const CURL_LOCK_DATA_SHARE: curl_lock_data = 1; ++pub const CURL_LOCK_DATA_COOKIE: curl_lock_data = 2; ++pub const CURL_LOCK_DATA_DNS: curl_lock_data = 3; ++pub const CURL_LOCK_DATA_SSL_SESSION: curl_lock_data = 4; ++pub const CURL_LOCK_DATA_CONNECT: curl_lock_data = 5; ++ ++pub type curl_lock_access = __enum_ty; ++pub const CURL_LOCK_ACCESS_NONE: curl_lock_access = 0; ++pub const CURL_LOCK_ACCESS_SHARED: curl_lock_access = 1; ++pub const CURL_LOCK_ACCESS_SINGLE: curl_lock_access = 2; ++ ++pub type curl_lock_function = extern fn(*mut CURL, ++ curl_lock_data, ++ curl_lock_access, ++ *mut c_void); ++pub type curl_unlock_function = extern fn(*mut CURL, ++ curl_lock_data, ++ *mut c_void); ++ ++pub enum CURLSH {} ++ ++pub type CURLSHcode = __enum_ty; ++pub const CURLSHE_OK: CURLSHcode = 0; ++pub const CURLSHE_BAD_OPTION: CURLSHcode = 1; ++pub const CURLSHE_IN_USE: CURLSHcode = 2; ++pub const CURLSHE_INVALID: CURLSHcode = 3; ++pub const CURLSHE_NOMEM: CURLSHcode = 4; ++// pub const CURLSHE_NOT_BUILT_IN: CURLSHcode = 5; ++ ++pub type CURLSHoption = __enum_ty; ++pub const CURLSHOPT_NONE: CURLSHoption = 0; ++pub const CURLSHOPT_SHARE: CURLSHoption = 1; ++pub const CURLSHOPT_UNSHARE: CURLSHoption = 2; ++pub const CURLSHOPT_LOCKFUNC: CURLSHoption = 3; ++pub const CURLSHOPT_UNLOCKFUNC: CURLSHoption = 4; ++pub const CURLSHOPT_USERDATA: CURLSHoption = 5; ++ ++pub const CURLVERSION_FIRST: CURLversion = 0; ++pub const CURLVERSION_SECOND: CURLversion = 1; ++pub const CURLVERSION_THIRD: CURLversion = 2; ++pub const CURLVERSION_FOURTH: CURLversion = 3; ++ ++#[repr(C)] ++pub struct curl_version_info_data { ++ pub age: CURLversion, ++ pub version: *const c_char, ++ pub version_num: c_uint, ++ pub host: *const c_char, ++ pub features: c_int, ++ pub ssl_version: *const c_char, ++ pub ssl_version_num: c_long, ++ pub libz_version: *const c_char, ++ pub protocols: *const *const c_char, ++ pub ares: *const c_char, ++ pub ares_num: c_int, ++ pub libidn: *const c_char, ++ pub iconv_ver_num: c_int, ++ pub libssh_version: *const c_char, ++} ++ ++pub const CURL_VERSION_IPV6: c_int = 1 << 0; ++pub const CURL_VERSION_KERBEROS4: c_int = 1 << 1; ++pub const CURL_VERSION_SSL: c_int = 1 << 2; ++pub const CURL_VERSION_LIBZ: c_int = 1 << 3; ++pub const CURL_VERSION_NTLM: c_int = 1 << 4; ++pub const CURL_VERSION_GSSNEGOTIATE: c_int = 1 << 5; ++pub const CURL_VERSION_DEBUG: c_int = 1 << 6; ++pub const CURL_VERSION_ASYNCHDNS: c_int = 1 << 7; ++pub const CURL_VERSION_SPNEGO: c_int = 1 << 8; ++pub const CURL_VERSION_LARGEFILE: c_int = 1 << 9; ++pub const CURL_VERSION_IDN: c_int = 1 << 10; ++pub const CURL_VERSION_SSPI: c_int = 1 << 11; ++pub const CURL_VERSION_CONV: c_int = 1 << 12; ++pub const CURL_VERSION_CURLDEBUG: c_int = 1 << 13; ++pub const CURL_VERSION_TLSAUTH_SRP: c_int = 1 << 14; ++pub const CURL_VERSION_NTLM_WB: c_int = 1 << 15; ++// pub const CURL_VERSION_HTTP2: c_int = 1 << 16; ++pub const CURL_VERSION_UNIX_SOCKETS: c_int = 1 << 19; ++ ++pub const CURLPAUSE_RECV: c_int = 1 << 0; ++pub const CURLPAUSE_RECV_CONT: c_int = 0; ++pub const CURLPAUSE_SEND: c_int = 1 << 2; ++pub const CURLPAUSE_SEND_CONT: c_int = 0; ++ ++pub enum CURLM {} ++ ++pub type CURLMcode = c_int; ++pub const CURLM_CALL_MULTI_PERFORM: CURLMcode = -1; ++pub const CURLM_OK: CURLMcode = 0; ++pub const CURLM_BAD_HANDLE: CURLMcode = 1; ++pub const CURLM_BAD_EASY_HANDLE: CURLMcode = 2; ++pub const CURLM_OUT_OF_MEMORY: CURLMcode = 3; ++pub const CURLM_INTERNAL_ERROR: CURLMcode = 4; ++pub const CURLM_BAD_SOCKET: CURLMcode = 5; ++pub const CURLM_UNKNOWN_OPTION: CURLMcode = 6; ++// pub const CURLM_ADDED_ALREADY: CURLMcode = 7; ++ ++pub type CURLMSG = __enum_ty; ++pub const CURLMSG_NONE: CURLMSG = 0; ++pub const CURLMSG_DONE: CURLMSG = 1; ++ ++#[repr(C)] ++pub struct CURLMsg { ++ pub msg: CURLMSG, ++ pub easy_handle: *mut CURL, ++ pub data: *mut c_void, ++} ++ ++pub const CURL_WAIT_POLLIN: c_short = 0x1; ++pub const CURL_WAIT_POLLPRI: c_short = 0x2; ++pub const CURL_WAIT_POLLOUT: c_short = 0x4; ++ ++#[repr(C)] ++pub struct curl_waitfd { ++ pub fd: curl_socket_t, ++ pub events: c_short, ++ pub revents: c_short, ++} ++ ++pub const CURL_POLL_NONE: c_int = 0; ++pub const CURL_POLL_IN: c_int = 1; ++pub const CURL_POLL_OUT: c_int = 2; ++pub const CURL_POLL_INOUT: c_int = 3; ++pub const CURL_POLL_REMOVE: c_int = 4; ++pub const CURL_CSELECT_IN: c_int = 1; ++pub const CURL_CSELECT_OUT: c_int = 2; ++pub const CURL_CSELECT_ERR: c_int = 4; ++pub const CURL_SOCKET_TIMEOUT: curl_socket_t = CURL_SOCKET_BAD; ++ ++pub type curl_socket_callback = extern fn(*mut CURL, ++ curl_socket_t, ++ c_int, ++ *mut c_void, ++ *mut c_void) -> c_int; ++pub type curl_multi_timer_callback = extern fn(*mut CURLM, ++ c_long, ++ *mut c_void) -> c_int; ++ ++pub type CURLMoption = __enum_ty; ++pub const CURLMOPT_SOCKETFUNCTION: CURLMoption = CURLOPTTYPE_FUNCTIONPOINT + 1; ++pub const CURLMOPT_SOCKETDATA: CURLMoption = CURLOPTTYPE_OBJECTPOINT + 2; ++pub const CURLMOPT_PIPELINING: CURLMoption = CURLOPTTYPE_LONG + 3; ++pub const CURLMOPT_TIMERFUNCTION: CURLMoption = CURLOPTTYPE_FUNCTIONPOINT + 4; ++pub const CURLMOPT_TIMERDATA: CURLMoption = CURLOPTTYPE_OBJECTPOINT + 5; ++// pub const CURLMOPT_MAXCONNECTS: CURLMoption = CURLOPTTYPE_LONG + 6; ++// pub const CURLMOPT_MAX_HOST_CONNECTIONS: CURLMoption = CURLOPTTYPE_LONG + 7; ++// pub const CURLMOPT_MAX_PIPELINE_LENGTH: CURLMoption = CURLOPTTYPE_LONG + 8; ++// pub const CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE: CURLMoption = CURLOPTTYPE_OFF_T + 9; ++// pub const CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE: CURLMoption = CURLOPTTYPE_OFF_T + 10; ++// pub const CURLMOPT_PIPELINING_SITE_BL: CURLMoption = CURLOPTTYPE_OBJECTPOINT + 11; ++// pub const CURLMOPT_PIPELINING_SERVER_BL: CURLMoption = CURLOPTTYPE_OBJECTPOINT + 12; ++// pub const CURLMOPT_MAX_TOTAL_CONNECTIONS: CURLMoption = CURLOPTTYPE_LONG + 13; ++ ++pub const CURL_ERROR_SIZE: usize = 256; ++ ++pub type curl_opensocket_callback = extern fn(*mut c_void, ++ curlsocktype, ++ *mut curl_sockaddr) -> curl_socket_t; ++pub type curlsocktype = __enum_ty; ++pub const CURLSOCKTYPE_IPCXN: curlsocktype = 0; ++pub const CURLSOCKTYPE_ACCEPT: curlsocktype = 1; ++pub const CURLSOCKTYPE_LAST: curlsocktype = 2; ++ ++#[repr(C)] ++pub struct curl_sockaddr { ++ pub family: c_int, ++ pub socktype: c_int, ++ pub protocol: c_int, ++ pub addrlen: c_uint, ++ #[cfg(unix)] ++ pub addr: libc::sockaddr, ++ #[cfg(windows)] ++ pub addr: winapi::SOCKADDR, ++} ++ ++extern { ++ pub fn curl_formadd(httppost: *mut *mut curl_httppost, ++ last_post: *mut *mut curl_httppost, ++ ...) -> CURLFORMcode; ++ pub fn curl_formget(form: *mut curl_httppost, ++ arg: *mut c_void, ++ append: curl_formget_callback) -> c_int; ++ pub fn curl_formfree(form: *mut curl_httppost); ++ ++ pub fn curl_version() -> *mut c_char; ++ ++ pub fn curl_easy_escape(handle: *mut CURL, ++ string: *const c_char, ++ length: c_int) -> *mut c_char; ++ pub fn curl_easy_unescape(handle: *mut CURL, ++ string: *const c_char, ++ length: c_int, ++ outlength: *mut c_int) -> *mut c_char; ++ pub fn curl_free(p: *mut c_void); ++ ++ pub fn curl_global_init(flags: c_long) -> CURLcode; ++ pub fn curl_global_init_mem(flags: c_long, ++ m: curl_malloc_callback, ++ f: curl_free_callback, ++ r: curl_realloc_callback, ++ s: curl_strdup_callback, ++ c: curl_calloc_callback) -> CURLcode; ++ pub fn curl_global_cleanup(); ++ ++ pub fn curl_slist_append(list: *mut curl_slist, ++ val: *const c_char) -> *mut curl_slist; ++ pub fn curl_slist_free_all(list: *mut curl_slist); ++ ++ pub fn curl_getdate(p: *const c_char, _: *const time_t) -> time_t; ++ ++ pub fn curl_share_init() -> *mut CURLSH; ++ pub fn curl_share_setopt(sh: *mut CURLSH, ++ opt: CURLSHoption, ++ ...) -> CURLSHcode; ++ pub fn curl_share_cleanup(sh: *mut CURLSH) -> CURLSHcode; ++ ++ pub fn curl_version_info(t: CURLversion) -> *mut curl_version_info_data; ++ ++ pub fn curl_easy_strerror(code: CURLcode) -> *const c_char; ++ pub fn curl_share_strerror(code: CURLSHcode) -> *const c_char; ++ pub fn curl_easy_pause(handle: *mut CURL, bitmask: c_int) -> CURLcode; ++ ++ pub fn curl_easy_init() -> *mut CURL; ++ pub fn curl_easy_setopt(curl: *mut CURL, option: CURLoption, ...) -> CURLcode; ++ pub fn curl_easy_perform(curl: *mut CURL) -> CURLcode; ++ pub fn curl_easy_cleanup(curl: *mut CURL); ++ pub fn curl_easy_getinfo(curl: *mut CURL, info: CURLINFO, ...) -> CURLcode; ++ pub fn curl_easy_duphandle(curl: *mut CURL) -> *mut CURL; ++ pub fn curl_easy_reset(curl: *mut CURL); ++ pub fn curl_easy_recv(curl: *mut CURL, ++ buffer: *mut c_void, ++ buflen: size_t, ++ n: *mut size_t) -> CURLcode; ++ pub fn curl_easy_send(curl: *mut CURL, ++ buffer: *const c_void, ++ buflen: size_t, ++ n: *mut size_t) -> CURLcode; ++ ++ pub fn curl_multi_init() -> *mut CURLM; ++ pub fn curl_multi_add_handle(multi_handle: *mut CURLM, ++ curl_handle: *mut CURL) -> CURLMcode; ++ pub fn curl_multi_remove_handle(multi_handle: *mut CURLM, ++ curl_handle: *mut CURL) -> CURLMcode; ++ pub fn curl_multi_fdset(multi_handle: *mut CURLM, ++ read_fd_set: *mut fd_set, ++ write_fd_set: *mut fd_set, ++ exc_fd_set: *mut fd_set, ++ max_fd: *mut c_int) -> CURLMcode; ++ pub fn curl_multi_wait(multi_handle: *mut CURLM, ++ extra_fds: *mut curl_waitfd, ++ extra_nfds: c_uint, ++ timeout_ms: c_int, ++ ret: *mut c_int) -> CURLMcode; ++ pub fn curl_multi_perform(multi_handle: *mut CURLM, ++ running_handles: *mut c_int) -> CURLMcode; ++ pub fn curl_multi_cleanup(multi_handle: *mut CURLM) -> CURLMcode; ++ pub fn curl_multi_info_read(multi_handle: *mut CURLM, ++ msgs_in_queue: *mut c_int) -> *mut CURLMsg; ++ pub fn curl_multi_strerror(code: CURLMcode) -> *const c_char; ++ pub fn curl_multi_socket(multi_handle: *mut CURLM, ++ s: curl_socket_t, ++ running_handles: *mut c_int) -> CURLMcode; ++ pub fn curl_multi_socket_action(multi_handle: *mut CURLM, ++ s: curl_socket_t, ++ ev_bitmask: c_int, ++ running_handles: *mut c_int) -> CURLMcode; ++ pub fn curl_multi_socket_all(multi_handle: *mut CURLM, ++ running_handles: *mut c_int) -> CURLMcode; ++ pub fn curl_multi_timeout(multi_handle: *mut CURLM, ++ milliseconds: *mut c_long) -> CURLMcode; ++ pub fn curl_multi_setopt(multi_handle: *mut CURLM, ++ option: CURLMoption, ++ ...) -> CURLMcode; ++ pub fn curl_multi_assign(multi_handle: *mut CURLM, ++ sockfd: curl_socket_t, ++ sockp: *mut c_void) -> CURLMcode; ++} diff --cc vendor/dtoa-0.4.2/.cargo-checksum.json index 000000000,000000000..03f5daad8 new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"} diff --cc vendor/dtoa-0.4.2/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/.cargo-ok diff --cc vendor/dtoa-0.4.2/.travis.yml index 000000000,000000000..0e4e98974 new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/.travis.yml @@@ -1,0 -1,0 +1,6 @@@ ++sudo: false ++ ++language: rust ++ ++rust: ++ - nightly diff --cc vendor/dtoa-0.4.2/Cargo.toml index 000000000,000000000..d61e1defd new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/Cargo.toml @@@ -1,0 -1,0 +1,23 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "dtoa" ++version = "0.4.2" ++authors = ["David Tolnay "] ++exclude = ["performance.png"] ++description = "Fast functions for printing floating-point primitives to an io::Write" ++documentation = "https://github.com/dtolnay/dtoa" ++readme = "README.md" ++categories = ["value-formatting"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/dtolnay/dtoa" diff --cc vendor/dtoa-0.4.2/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/dtoa-0.4.2/LICENSE-MIT index 000000000,000000000..d1c35df03 new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++Copyright (c) 2016 Itoa 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 --cc vendor/dtoa-0.4.2/README.md index 000000000,000000000..2f26b68a5 new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/README.md @@@ -1,0 -1,0 +1,69 @@@ ++dtoa ++==== ++ ++[![Build Status](https://api.travis-ci.org/dtolnay/dtoa.svg?branch=master)](https://travis-ci.org/dtolnay/dtoa) ++[![Latest Version](https://img.shields.io/crates/v/dtoa.svg)](https://crates.io/crates/dtoa) ++ ++This crate provides fast functions for printing floating-point primitives to an ++[`io::Write`](https://doc.rust-lang.org/std/io/trait.Write.html). The ++implementation is a straightforward Rust port of [Milo ++Yip](https://github.com/miloyip)'s C++ implementation ++[dtoa.h](https://github.com/miloyip/rapidjson/blob/master/include/rapidjson/internal/dtoa.h). ++The original C++ code of each function is included in comments. ++ ++See also [`itoa`](https://github.com/dtolnay/itoa) for printing integer ++primitives. ++ ++## Performance (lower is better) ++ ++![performance](https://raw.githubusercontent.com/dtolnay/dtoa/master/performance.png) ++ ++## Functions ++ ++```rust ++extern crate dtoa; ++ ++// write to a vector or other io::Write ++let mut buf = Vec::new(); ++dtoa::write(&mut buf, 2.71828f64)?; ++println!("{:?}", buf); ++ ++// write to a stack buffer ++let mut bytes = [b'\0'; 20]; ++let n = dtoa::write(&mut bytes[..], 2.71828f64)?; ++println!("{:?}", &bytes[..n]); ++``` ++ ++The function signature is: ++ ++```rust ++fn write(writer: W, value: V) -> io::Result<()> ++``` ++ ++where `dtoa::Floating` is implemented for `f32` and `f64`. The return value ++gives the number of bytes written. ++ ++## Dependency ++ ++Dtoa is available on [crates.io](https://crates.io/crates/dtoa). Use the ++following in `Cargo.toml`: ++ ++```toml ++[dependencies] ++dtoa = "0.4" ++``` ++ ++## 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 dtoa by you, as defined in the Apache-2.0 license, shall be ++dual licensed as above, without any additional terms or conditions. diff --cc vendor/dtoa-0.4.2/benches/bench.rs index 000000000,000000000..ec5795356 new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/benches/bench.rs @@@ -1,0 -1,0 +1,54 @@@ ++#![feature(test)] ++ ++extern crate dtoa; ++extern crate test; ++ ++macro_rules! benches { ++ ($($name:ident($value:expr),)*) => { ++ mod bench_dtoa { ++ use test::{Bencher, black_box}; ++ $( ++ #[bench] ++ fn $name(b: &mut Bencher) { ++ use dtoa; ++ ++ let mut buf = Vec::with_capacity(20); ++ ++ b.iter(|| { ++ buf.clear(); ++ dtoa::write(&mut buf, black_box($value)).unwrap() ++ }); ++ } ++ )* ++ } ++ ++ mod bench_fmt { ++ use test::{Bencher, black_box}; ++ $( ++ #[bench] ++ fn $name(b: &mut Bencher) { ++ use std::io::Write; ++ ++ let mut buf = Vec::with_capacity(20); ++ ++ b.iter(|| { ++ buf.clear(); ++ write!(&mut buf, "{}", black_box($value)).unwrap() ++ }); ++ } ++ )* ++ } ++ } ++} ++ ++benches!( ++ bench_0_f64(0f64), ++ bench_short_f64(0.1234f64), ++ bench_e_f64(2.718281828459045f64), ++ bench_max_f64(::std::f64::MAX), ++ ++ bench_0_f32(0f32), ++ bench_short_f32(0.1234f32), ++ bench_e_f32(2.718281828459045f32), ++ bench_max_f32(::std::f32::MAX), ++); diff --cc vendor/dtoa-0.4.2/src/diyfp.rs index 000000000,000000000..758dde67d new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/src/diyfp.rs @@@ -1,0 -1,0 +1,232 @@@ ++// Copyright 2016 Dtoa Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::ops; ++ ++#[derive(Copy, Clone, Debug)] ++pub struct DiyFp { ++ pub f: F, ++ pub e: E, ++} ++ ++impl DiyFp { ++ pub fn new(f: F, e: E) -> Self { ++ DiyFp { f: f, e: e } ++ } ++} ++ ++impl ops::Mul for DiyFp { ++ type Output = Self; ++ fn mul(self, rhs: Self) -> Self { ++ let mut tmp = self.f as u64 * rhs.f as u64; ++ tmp += 1u64 << 31; // mult_round ++ DiyFp { ++ f: (tmp >> 32) as u32, ++ e: self.e + rhs.e + 32, ++ } ++ } ++} ++ ++impl ops::Mul for DiyFp { ++ type Output = Self; ++ fn mul(self, rhs: Self) -> Self { ++ let m32 = 0xFFFFFFFFu64; ++ let a = self.f >> 32; ++ let b = self.f & m32; ++ let c = rhs.f >> 32; ++ let d = rhs.f & m32; ++ let ac = a * c; ++ let bc = b * c; ++ let ad = a * d; ++ let bd = b * d; ++ let mut tmp = (bd >> 32) + (ad & m32) + (bc & m32); ++ tmp += 1u64 << 31; // mult_round ++ DiyFp { ++ f: ac + (ad >> 32) + (bc >> 32) + (tmp >> 32), ++ e: self.e + rhs.e + 64, ++ } ++ } ++} ++ ++#[macro_export] ++macro_rules! diyfp {( ++ floating_type: $fty:ty, ++ significand_type: $sigty:ty, ++ exponent_type: $expty:ty, ++ ++ diy_significand_size: $diy_significand_size:expr, ++ significand_size: $significand_size:expr, ++ exponent_bias: $exponent_bias:expr, ++ mask_type: $mask_type:ty, ++ exponent_mask: $exponent_mask:expr, ++ significand_mask: $significand_mask:expr, ++ hidden_bit: $hidden_bit:expr, ++ cached_powers_f: $cached_powers_f:expr, ++ cached_powers_e: $cached_powers_e:expr, ++ min_power: $min_power:expr, ++) => { ++ ++type DiyFp = diyfp::DiyFp<$sigty, $expty>; ++ ++impl DiyFp { ++ // Preconditions: ++ // `d` must have a positive sign and must not be infinity or NaN. ++ /* ++ explicit DiyFp(double d) { ++ union { ++ double d; ++ uint64_t u64; ++ } u = { d }; ++ ++ int biased_e = static_cast((u.u64 & kDpExponentMask) >> kDpSignificandSize); ++ uint64_t significand = (u.u64 & kDpSignificandMask); ++ if (biased_e != 0) { ++ f = significand + kDpHiddenBit; ++ e = biased_e - kDpExponentBias; ++ } ++ else { ++ f = significand; ++ e = kDpMinExponent + 1; ++ } ++ } ++ */ ++ unsafe fn from(d: $fty) -> Self { ++ let u: $mask_type = mem::transmute(d); ++ ++ let biased_e = ((u & $exponent_mask) >> $significand_size) as $expty; ++ let significand = u & $significand_mask; ++ if biased_e != 0 { ++ DiyFp { ++ f: significand + $hidden_bit, ++ e: biased_e - $exponent_bias - $significand_size, ++ } ++ } else { ++ DiyFp { ++ f: significand, ++ e: 1 - $exponent_bias - $significand_size, ++ } ++ } ++ } ++ ++ // Normalizes so that the highest bit of the diy significand is 1. ++ /* ++ DiyFp Normalize() const { ++ DiyFp res = *this; ++ while (!(res.f & (static_cast(1) << 63))) { ++ res.f <<= 1; ++ res.e--; ++ } ++ return res; ++ } ++ */ ++ fn normalize(self) -> DiyFp { ++ let mut res = self; ++ while (res.f & (1 << ($diy_significand_size - 1))) == 0 { ++ res.f <<= 1; ++ res.e -= 1; ++ } ++ res ++ } ++ ++ // Normalizes so that the highest bit of the diy significand is 1. ++ // ++ // Precondition: ++ // `self.f` must be no more than 2 bits longer than the f64 significand. ++ /* ++ DiyFp NormalizeBoundary() const { ++ DiyFp res = *this; ++ while (!(res.f & (kDpHiddenBit << 1))) { ++ res.f <<= 1; ++ res.e--; ++ } ++ res.f <<= (kDiySignificandSize - kDpSignificandSize - 2); ++ res.e = res.e - (kDiySignificandSize - kDpSignificandSize - 2); ++ return res; ++ } ++ */ ++ fn normalize_boundary(self) -> DiyFp { ++ let mut res = self; ++ while (res.f & $hidden_bit << 1) == 0 { ++ res.f <<= 1; ++ res.e -= 1; ++ } ++ res.f <<= $diy_significand_size - $significand_size - 2; ++ res.e -= $diy_significand_size - $significand_size - 2; ++ res ++ } ++ ++ // Normalizes `self - e` and `self + e` where `e` is half of the least ++ // significant digit of `self`. The plus is normalized so that the highest ++ // bit of the diy significand is 1. The minus is normalized so that it has ++ // the same exponent as the plus. ++ // ++ // Preconditions: ++ // `self` must have been returned directly from `DiyFp::from_f64`. ++ // `self.f` must not be zero. ++ /* ++ void NormalizedBoundaries(DiyFp* minus, DiyFp* plus) const { ++ DiyFp pl = DiyFp((f << 1) + 1, e - 1).NormalizeBoundary(); ++ DiyFp mi = (f == kDpHiddenBit) ? DiyFp((f << 2) - 1, e - 2) : DiyFp((f << 1) - 1, e - 1); ++ mi.f <<= mi.e - pl.e; ++ mi.e = pl.e; ++ *plus = pl; ++ *minus = mi; ++ } ++ */ ++ fn normalized_boundaries(self) -> (DiyFp, DiyFp) { ++ let pl = DiyFp::new((self.f << 1) + 1, self.e - 1).normalize_boundary(); ++ let mut mi = if self.f == $hidden_bit { ++ DiyFp::new((self.f << 2) - 1, self.e - 2) ++ } else { ++ DiyFp::new((self.f << 1) - 1, self.e - 1) ++ }; ++ mi.f <<= mi.e - pl.e; ++ mi.e = pl.e; ++ (mi, pl) ++ } ++} ++ ++impl ops::Sub for DiyFp { ++ type Output = Self; ++ fn sub(self, rhs: Self) -> Self { ++ DiyFp { ++ f: self.f - rhs.f, ++ e: self.e, ++ } ++ } ++} ++ ++/* ++inline DiyFp GetCachedPower(int e, int* K) { ++ //int k = static_cast(ceil((-61 - e) * 0.30102999566398114)) + 374; ++ double dk = (-61 - e) * 0.30102999566398114 + 347; // dk must be positive, so can do ceiling in positive ++ int k = static_cast(dk); ++ if (dk - k > 0.0) ++ k++; ++ ++ unsigned index = static_cast((k >> 3) + 1); ++ *K = -(-348 + static_cast(index << 3)); // decimal exponent no need lookup table ++ ++ return GetCachedPowerByIndex(index); ++} ++*/ ++#[inline] ++fn get_cached_power(e: $expty) -> (DiyFp, isize) { ++ let dk = (3 - $diy_significand_size - e) as f64 * 0.30102999566398114f64 - ($min_power + 1) as f64; ++ let mut k = dk as isize; ++ if dk - k as f64 > 0.0 { ++ k += 1; ++ } ++ ++ let index = ((k >> 3) + 1) as usize; ++ let k = -($min_power + (index << 3) as isize); ++ ++ (DiyFp::new($cached_powers_f[index], $cached_powers_e[index] as $expty), k) ++} ++ ++}} diff --cc vendor/dtoa-0.4.2/src/dtoa.rs index 000000000,000000000..5c10833d1 new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/src/dtoa.rs @@@ -1,0 -1,0 +1,479 @@@ ++// Copyright 2016 Dtoa Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++#[macro_export] ++macro_rules! dtoa {( ++ floating_type: $fty:ty, ++ significand_type: $sigty:ty, ++ exponent_type: $expty:ty, ++ $($diyfp_param:ident: $diyfp_value:tt,)* ++) => { ++ ++diyfp! { ++ floating_type: $fty, ++ significand_type: $sigty, ++ exponent_type: $expty, ++ $($diyfp_param: $diyfp_value,)* ++}; ++ ++/* ++inline void GrisuRound(char* buffer, int len, uint64_t delta, uint64_t rest, uint64_t ten_kappa, uint64_t wp_w) { ++ while (rest < wp_w && delta - rest >= ten_kappa && ++ (rest + ten_kappa < wp_w || /// closer ++ wp_w - rest > rest + ten_kappa - wp_w)) { ++ buffer[len - 1]--; ++ rest += ten_kappa; ++ } ++} ++*/ ++ ++#[inline] ++unsafe fn grisu_round(buffer: *mut u8, len: isize, delta: $sigty, mut rest: $sigty, ten_kappa: $sigty, wp_w: $sigty) { ++ while rest < wp_w && delta - rest >= ten_kappa && ++ (rest + ten_kappa < wp_w || // closer ++ wp_w - rest > rest + ten_kappa - wp_w) { ++ *buffer.offset(len - 1) -= 1; ++ rest += ten_kappa; ++ } ++} ++ ++/* ++inline unsigned CountDecimalDigit32(uint32_t n) { ++ // Simple pure C++ implementation was faster than __builtin_clz version in this situation. ++ if (n < 10) return 1; ++ if (n < 100) return 2; ++ if (n < 1000) return 3; ++ if (n < 10000) return 4; ++ if (n < 100000) return 5; ++ if (n < 1000000) return 6; ++ if (n < 10000000) return 7; ++ if (n < 100000000) return 8; ++ // Will not reach 10 digits in DigitGen() ++ //if (n < 1000000000) return 9; ++ //return 10; ++ return 9; ++} ++*/ ++ ++#[inline] ++fn count_decimal_digit32(n: u32) -> usize { ++ if n < 10 { 1 } ++ else if n < 100 { 2 } ++ else if n < 1000 { 3 } ++ else if n < 10000 { 4 } ++ else if n < 100000 { 5 } ++ else if n < 1000000 { 6 } ++ else if n < 10000000 { 7 } ++ else if n < 100000000 { 8 } ++ // Will not reach 10 digits in digit_gen() ++ else { 9 } ++} ++ ++/* ++inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buffer, int* len, int* K) { ++ static const uint32_t kPow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; ++ const DiyFp one(uint64_t(1) << -Mp.e, Mp.e); ++ const DiyFp wp_w = Mp - W; ++ uint32_t p1 = static_cast(Mp.f >> -one.e); ++ uint64_t p2 = Mp.f & (one.f - 1); ++ unsigned kappa = CountDecimalDigit32(p1); // kappa in [0, 9] ++ *len = 0; ++*/ ++ ++// Returns length and k. ++#[inline] ++unsafe fn digit_gen(w: DiyFp, mp: DiyFp, mut delta: $sigty, buffer: *mut u8, mut k: isize) -> (isize, isize) { ++ static POW10: [$sigty; 10] = [ 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 ]; ++ let one = DiyFp::new(1 << -mp.e, mp.e); ++ let wp_w = mp - w; ++ let mut p1 = (mp.f >> -one.e) as u32; ++ let mut p2 = mp.f & (one.f - 1); ++ let mut kappa = count_decimal_digit32(p1); // kappa in [0, 9] ++ let mut len = 0; ++ ++ /* ++ while (kappa > 0) { ++ uint32_t d = 0; ++ switch (kappa) { ++ case 9: d = p1 / 100000000; p1 %= 100000000; break; ++ case 8: d = p1 / 10000000; p1 %= 10000000; break; ++ case 7: d = p1 / 1000000; p1 %= 1000000; break; ++ case 6: d = p1 / 100000; p1 %= 100000; break; ++ case 5: d = p1 / 10000; p1 %= 10000; break; ++ case 4: d = p1 / 1000; p1 %= 1000; break; ++ case 3: d = p1 / 100; p1 %= 100; break; ++ case 2: d = p1 / 10; p1 %= 10; break; ++ case 1: d = p1; p1 = 0; break; ++ default:; ++ } ++ if (d || *len) ++ buffer[(*len)++] = static_cast('0' + static_cast(d)); ++ kappa--; ++ uint64_t tmp = (static_cast(p1) << -one.e) + p2; ++ if (tmp <= delta) { ++ *K += kappa; ++ GrisuRound(buffer, *len, delta, tmp, static_cast(kPow10[kappa]) << -one.e, wp_w.f); ++ return; ++ } ++ } ++ */ ++ while kappa > 0 { ++ let mut d = 0u32; ++ match kappa { ++ 9 => { d = p1 / 100000000; p1 %= 100000000; } ++ 8 => { d = p1 / 10000000; p1 %= 10000000; } ++ 7 => { d = p1 / 1000000; p1 %= 1000000; } ++ 6 => { d = p1 / 100000; p1 %= 100000; } ++ 5 => { d = p1 / 10000; p1 %= 10000; } ++ 4 => { d = p1 / 1000; p1 %= 1000; } ++ 3 => { d = p1 / 100; p1 %= 100; } ++ 2 => { d = p1 / 10; p1 %= 10; } ++ 1 => { d = p1; p1 = 0; } ++ _ => {} ++ } ++ if d != 0 || len != 0 { ++ *buffer.offset(len) = b'0' + d as u8; ++ len += 1; ++ } ++ kappa -= 1; ++ let tmp = (p1 as $sigty << -one.e) + p2; ++ if tmp <= delta { ++ k += kappa as isize; ++ grisu_round(buffer, len, delta, tmp, POW10[kappa] << -one.e, wp_w.f); ++ return (len, k); ++ } ++ } ++ ++ // kappa = 0 ++ /* ++ for (;;) { ++ p2 *= 10; ++ delta *= 10; ++ char d = static_cast(p2 >> -one.e); ++ if (d || *len) ++ buffer[(*len)++] = static_cast('0' + d); ++ p2 &= one.f - 1; ++ kappa--; ++ if (p2 < delta) { ++ *K += kappa; ++ int index = -static_cast(kappa); ++ GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * (index < 9 ? kPow10[-static_cast(kappa)] : 0)); ++ return; ++ } ++ } ++ */ ++ loop { ++ p2 *= 10; ++ delta *= 10; ++ let d = (p2 >> -one.e) as u8; ++ if d != 0 || len != 0 { ++ *buffer.offset(len) = b'0' + d; ++ len += 1; ++ } ++ p2 &= one.f - 1; ++ kappa = kappa.wrapping_sub(1); ++ if p2 < delta { ++ k += kappa as isize; ++ let index = -(kappa as isize); ++ grisu_round(buffer, len, delta, p2, one.f, wp_w.f * if index < 9 { POW10[-(kappa as isize) as usize] } else { 0 }); ++ return (len, k); ++ } ++ } ++} ++ ++/* ++inline void Grisu2(double value, char* buffer, int* length, int* K) { ++ const DiyFp v(value); ++ DiyFp w_m, w_p; ++ v.NormalizedBoundaries(&w_m, &w_p); ++ ++ const DiyFp c_mk = GetCachedPower(w_p.e, K); ++ const DiyFp W = v.Normalize() * c_mk; ++ DiyFp Wp = w_p * c_mk; ++ DiyFp Wm = w_m * c_mk; ++ Wm.f++; ++ Wp.f--; ++ DigitGen(W, Wp, Wp.f - Wm.f, buffer, length, K); ++} ++*/ ++ ++// Returns length and k. ++#[inline] ++unsafe fn grisu2(value: $fty, buffer: *mut u8) -> (isize, isize) { ++ let v = DiyFp::from(value); ++ let (w_m, w_p) = v.normalized_boundaries(); ++ ++ let (c_mk, k) = get_cached_power(w_p.e); ++ let w = v.normalize() * c_mk; ++ let mut wp = w_p * c_mk; ++ let mut wm = w_m * c_mk; ++ wm.f += 1; ++ wp.f -= 1; ++ digit_gen(w, wp, wp.f - wm.f, buffer, k) ++} ++ ++/* ++inline char* WriteExponent(int K, char* buffer) { ++ if (K < 0) { ++ *buffer++ = '-'; ++ K = -K; ++ } ++ ++ if (K >= 100) { ++ *buffer++ = static_cast('0' + static_cast(K / 100)); ++ K %= 100; ++ const char* d = GetDigitsLut() + K * 2; ++ *buffer++ = d[0]; ++ *buffer++ = d[1]; ++ } ++ else if (K >= 10) { ++ const char* d = GetDigitsLut() + K * 2; ++ *buffer++ = d[0]; ++ *buffer++ = d[1]; ++ } ++ else ++ *buffer++ = static_cast('0' + static_cast(K)); ++ ++ return buffer; ++} ++*/ ++ ++#[inline] ++unsafe fn write_exponent(mut k: isize, mut buffer: *mut u8) -> *mut u8 { ++ if k < 0 { ++ *buffer = b'-'; ++ buffer = buffer.offset(1); ++ k = -k; ++ } ++ ++ if k >= 100 { ++ *buffer = b'0' + (k / 100) as u8; ++ k %= 100; ++ let d = DEC_DIGITS_LUT.as_ptr().offset(k * 2); ++ ptr::copy_nonoverlapping(d, buffer.offset(1), 2); ++ buffer.offset(3) ++ } else if k >= 10 { ++ let d = DEC_DIGITS_LUT.as_ptr().offset(k * 2); ++ ptr::copy_nonoverlapping(d, buffer, 2); ++ buffer.offset(2) ++ } else { ++ *buffer = b'0' + k as u8; ++ buffer.offset(1) ++ } ++} ++ ++/* ++inline char* Prettify(char* buffer, int length, int k, int maxDecimalPlaces) { ++ const int kk = length + k; // 10^(kk-1) <= v < 10^kk ++*/ ++ ++#[inline] ++unsafe fn prettify(buffer: *mut u8, length: isize, k: isize) -> *mut u8 { ++ let kk = length + k; // 10^(kk-1) <= v < 10^kk ++ ++ /* ++ if (0 <= k && kk <= 21) { ++ // 1234e7 -> 12340000000 ++ for (int i = length; i < kk; i++) ++ buffer[i] = '0'; ++ buffer[kk] = '.'; ++ buffer[kk + 1] = '0'; ++ return &buffer[kk + 2]; ++ } ++ */ ++ if 0 <= k && kk <= 21 { ++ // 1234e7 -> 12340000000 ++ for i in length..kk { ++ *buffer.offset(i) = b'0'; ++ } ++ *buffer.offset(kk) = b'.'; ++ *buffer.offset(kk + 1) = b'0'; ++ buffer.offset(kk + 2) ++ } ++ ++ /* ++ else if (0 < kk && kk <= 21) { ++ // 1234e-2 -> 12.34 ++ std::memmove(&buffer[kk + 1], &buffer[kk], static_cast(length - kk)); ++ buffer[kk] = '.'; ++ if (0 > k + maxDecimalPlaces) { ++ // When maxDecimalPlaces = 2, 1.2345 -> 1.23, 1.102 -> 1.1 ++ // Remove extra trailing zeros (at least one) after truncation. ++ for (int i = kk + maxDecimalPlaces; i > kk + 1; i--) ++ if (buffer[i] != '0') ++ return &buffer[i + 1]; ++ return &buffer[kk + 2]; // Reserve one zero ++ } ++ else ++ return &buffer[length + 1]; ++ } ++ */ ++ else if 0 < kk && kk <= 21 { ++ // 1234e-2 -> 12.34 ++ ptr::copy(buffer.offset(kk), buffer.offset(kk + 1), (length - kk) as usize); ++ *buffer.offset(kk) = b'.'; ++ if 0 > k + MAX_DECIMAL_PLACES { ++ // When MAX_DECIMAL_PLACES = 2, 1.2345 -> 1.23, 1.102 -> 1.1 ++ // Remove extra trailing zeros (at least one) after truncation. ++ for i in (kk + 2 .. kk + MAX_DECIMAL_PLACES + 1).rev() { ++ if *buffer.offset(i) != b'0' { ++ return buffer.offset(i + 1); ++ } ++ } ++ buffer.offset(kk + 2) // Reserve one zero ++ } else { ++ buffer.offset(length + 1) ++ } ++ } ++ ++ /* ++ else if (-6 < kk && kk <= 0) { ++ // 1234e-6 -> 0.001234 ++ const int offset = 2 - kk; ++ std::memmove(&buffer[offset], &buffer[0], static_cast(length)); ++ buffer[0] = '0'; ++ buffer[1] = '.'; ++ for (int i = 2; i < offset; i++) ++ buffer[i] = '0'; ++ if (length - kk > maxDecimalPlaces) { ++ // When maxDecimalPlaces = 2, 0.123 -> 0.12, 0.102 -> 0.1 ++ // Remove extra trailing zeros (at least one) after truncation. ++ for (int i = maxDecimalPlaces + 1; i > 2; i--) ++ if (buffer[i] != '0') ++ return &buffer[i + 1]; ++ return &buffer[3]; // Reserve one zero ++ } ++ else ++ return &buffer[length + offset]; ++ } ++ */ ++ else if -6 < kk && kk <= 0 { ++ // 1234e-6 -> 0.001234 ++ let offset = 2 - kk; ++ ptr::copy(buffer, buffer.offset(offset), length as usize); ++ *buffer = b'0'; ++ *buffer.offset(1) = b'.'; ++ for i in 2..offset { ++ *buffer.offset(i) = b'0'; ++ } ++ if length - kk > MAX_DECIMAL_PLACES { ++ // When MAX_DECIMAL_PLACES = 2, 0.123 -> 0.12, 0.102 -> 0.1 ++ // Remove extra trailing zeros (at least one) after truncation. ++ for i in (3 .. MAX_DECIMAL_PLACES + 2).rev() { ++ if *buffer.offset(i) != b'0' { ++ return buffer.offset(i + 1); ++ } ++ } ++ buffer.offset(3) // Reserve one zero ++ } else { ++ buffer.offset(length + offset) ++ } ++ } ++ ++ /* ++ else if (kk < -maxDecimalPlaces) { ++ // Truncate to zero ++ buffer[0] = '0'; ++ buffer[1] = '.'; ++ buffer[2] = '0'; ++ return &buffer[3]; ++ } ++ */ ++ else if kk < -MAX_DECIMAL_PLACES { ++ *buffer = b'0'; ++ *buffer.offset(1) = b'.'; ++ *buffer.offset(2) = b'0'; ++ buffer.offset(3) ++ } ++ ++ /* ++ else if (length == 1) { ++ // 1e30 ++ buffer[1] = 'e'; ++ return WriteExponent(kk - 1, &buffer[2]); ++ } ++ */ ++ else if length == 1 { ++ // 1e30 ++ *buffer.offset(1) = b'e'; ++ write_exponent(kk - 1, buffer.offset(2)) ++ } ++ ++ /* ++ else { ++ // 1234e30 -> 1.234e33 ++ std::memmove(&buffer[2], &buffer[1], static_cast(length - 1)); ++ buffer[1] = '.'; ++ buffer[length + 1] = 'e'; ++ return WriteExponent(kk - 1, &buffer[0 + length + 2]); ++ } ++ */ ++ else { ++ // 1234e30 -> 1.234e33 ++ ptr::copy(buffer.offset(1), buffer.offset(2), (length - 1) as usize); ++ *buffer.offset(1) = b'.'; ++ *buffer.offset(length + 1) = b'e'; ++ write_exponent(kk - 1, buffer.offset(length + 2)) ++ } ++} ++ ++/* ++inline char* dtoa(double value, char* buffer, int maxDecimalPlaces = 324) { ++ RAPIDJSON_ASSERT(maxDecimalPlaces >= 1); ++ Double d(value); ++ if (d.IsZero()) { ++ if (d.Sign()) ++ *buffer++ = '-'; // -0.0, Issue #289 ++ buffer[0] = '0'; ++ buffer[1] = '.'; ++ buffer[2] = '0'; ++ return &buffer[3]; ++ } ++ else { ++ if (value < 0) { ++ *buffer++ = '-'; ++ value = -value; ++ } ++ int length, K; ++ Grisu2(value, buffer, &length, &K); ++ return Prettify(buffer, length, K, maxDecimalPlaces); ++ } ++} ++*/ ++ ++#[inline] ++unsafe fn dtoa(mut wr: W, mut value: $fty) -> io::Result { ++ if value == 0.0 { ++ if value.is_sign_negative() { ++ try!(wr.write_all(b"-0.0")); ++ Ok(4) ++ } else { ++ try!(wr.write_all(b"0.0")); ++ Ok(3) ++ } ++ } else { ++ let negative = value < 0.0; ++ if negative { ++ try!(wr.write_all(b"-")); ++ value = -value; ++ } ++ let mut buffer: [u8; 24] = mem::uninitialized(); ++ let buf_ptr = buffer.as_mut_ptr(); ++ let (length, k) = grisu2(value, buf_ptr); ++ let end = prettify(buf_ptr, length, k); ++ let len = end as usize - buf_ptr as usize; ++ try!(wr.write_all(slice::from_raw_parts(buf_ptr, len))); ++ if negative { ++ Ok(len + 1) ++ } else { ++ Ok(len) ++ } ++ } ++} ++ ++}} diff --cc vendor/dtoa-0.4.2/src/lib.rs index 000000000,000000000..a0f9454cd new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/src/lib.rs @@@ -1,0 -1,0 +1,148 @@@ ++// Copyright 2016 Dtoa Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++#![doc(html_root_url = "https://docs.rs/dtoa/0.4.2")] ++ ++#[macro_use] mod diyfp; ++#[macro_use] mod dtoa; ++ ++use std::{io, mem, ops, ptr, slice}; ++ ++#[inline] ++pub fn write(wr: W, value: V) -> io::Result { ++ value.write(wr) ++} ++ ++pub trait Floating { ++ fn write(self, W) -> io::Result; ++} ++ ++impl Floating for f32 { ++ fn write(self, wr: W) -> io::Result { ++ dtoa! { ++ floating_type: f32, ++ significand_type: u32, ++ exponent_type: i32, ++ ++ diy_significand_size: 32, ++ significand_size: 23, ++ exponent_bias: 0x7F, ++ mask_type: u32, ++ exponent_mask: 0x7F800000, ++ significand_mask: 0x007FFFFF, ++ hidden_bit: 0x00800000, ++ cached_powers_f: CACHED_POWERS_F_32, ++ cached_powers_e: CACHED_POWERS_E_32, ++ min_power: (-36), ++ }; ++ unsafe { dtoa(wr, self) } ++ } ++} ++ ++impl Floating for f64 { ++ fn write(self, wr: W) -> io::Result { ++ dtoa! { ++ floating_type: f64, ++ significand_type: u64, ++ exponent_type: isize, ++ ++ diy_significand_size: 64, ++ significand_size: 52, ++ exponent_bias: 0x3FF, ++ mask_type: u64, ++ exponent_mask: 0x7FF0000000000000, ++ significand_mask: 0x000FFFFFFFFFFFFF, ++ hidden_bit: 0x0010000000000000, ++ cached_powers_f: CACHED_POWERS_F_64, ++ cached_powers_e: CACHED_POWERS_E_64, ++ min_power: (-348), ++ }; ++ unsafe { dtoa(wr, self) } ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++const MAX_DECIMAL_PLACES: isize = 324; ++ ++static DEC_DIGITS_LUT: &'static [u8] = ++ b"0001020304050607080910111213141516171819\ ++ 2021222324252627282930313233343536373839\ ++ 4041424344454647484950515253545556575859\ ++ 6061626364656667686970717273747576777879\ ++ 8081828384858687888990919293949596979899"; ++ ++// 10^-36, 10^-28, ..., 10^52 ++static CACHED_POWERS_F_32: [u32; 12] = [ ++ 0xaa242499, 0xfd87b5f3, 0xbce50865, 0x8cbccc09, ++ 0xd1b71759, 0x9c400000, 0xe8d4a510, 0xad78ebc6, ++ 0x813f3979, 0xc097ce7c, 0x8f7e32ce, 0xd5d238a5, ++]; ++ ++static CACHED_POWERS_E_32: [i16; 12] = [ ++ -151, -125, -98, -71, -45, -18, 8, 35, 62, 88, 115, 141, ++]; ++ ++// 10^-348, 10^-340, ..., 10^340 ++static CACHED_POWERS_F_64: [u64; 87] = [ ++ 0xfa8fd5a0081c0288, 0xbaaee17fa23ebf76, ++ 0x8b16fb203055ac76, 0xcf42894a5dce35ea, ++ 0x9a6bb0aa55653b2d, 0xe61acf033d1a45df, ++ 0xab70fe17c79ac6ca, 0xff77b1fcbebcdc4f, ++ 0xbe5691ef416bd60c, 0x8dd01fad907ffc3c, ++ 0xd3515c2831559a83, 0x9d71ac8fada6c9b5, ++ 0xea9c227723ee8bcb, 0xaecc49914078536d, ++ 0x823c12795db6ce57, 0xc21094364dfb5637, ++ 0x9096ea6f3848984f, 0xd77485cb25823ac7, ++ 0xa086cfcd97bf97f4, 0xef340a98172aace5, ++ 0xb23867fb2a35b28e, 0x84c8d4dfd2c63f3b, ++ 0xc5dd44271ad3cdba, 0x936b9fcebb25c996, ++ 0xdbac6c247d62a584, 0xa3ab66580d5fdaf6, ++ 0xf3e2f893dec3f126, 0xb5b5ada8aaff80b8, ++ 0x87625f056c7c4a8b, 0xc9bcff6034c13053, ++ 0x964e858c91ba2655, 0xdff9772470297ebd, ++ 0xa6dfbd9fb8e5b88f, 0xf8a95fcf88747d94, ++ 0xb94470938fa89bcf, 0x8a08f0f8bf0f156b, ++ 0xcdb02555653131b6, 0x993fe2c6d07b7fac, ++ 0xe45c10c42a2b3b06, 0xaa242499697392d3, ++ 0xfd87b5f28300ca0e, 0xbce5086492111aeb, ++ 0x8cbccc096f5088cc, 0xd1b71758e219652c, ++ 0x9c40000000000000, 0xe8d4a51000000000, ++ 0xad78ebc5ac620000, 0x813f3978f8940984, ++ 0xc097ce7bc90715b3, 0x8f7e32ce7bea5c70, ++ 0xd5d238a4abe98068, 0x9f4f2726179a2245, ++ 0xed63a231d4c4fb27, 0xb0de65388cc8ada8, ++ 0x83c7088e1aab65db, 0xc45d1df942711d9a, ++ 0x924d692ca61be758, 0xda01ee641a708dea, ++ 0xa26da3999aef774a, 0xf209787bb47d6b85, ++ 0xb454e4a179dd1877, 0x865b86925b9bc5c2, ++ 0xc83553c5c8965d3d, 0x952ab45cfa97a0b3, ++ 0xde469fbd99a05fe3, 0xa59bc234db398c25, ++ 0xf6c69a72a3989f5c, 0xb7dcbf5354e9bece, ++ 0x88fcf317f22241e2, 0xcc20ce9bd35c78a5, ++ 0x98165af37b2153df, 0xe2a0b5dc971f303a, ++ 0xa8d9d1535ce3b396, 0xfb9b7cd9a4a7443c, ++ 0xbb764c4ca7a44410, 0x8bab8eefb6409c1a, ++ 0xd01fef10a657842c, 0x9b10a4e5e9913129, ++ 0xe7109bfba19c0c9d, 0xac2820d9623bf429, ++ 0x80444b5e7aa7cf85, 0xbf21e44003acdd2d, ++ 0x8e679c2f5e44ff8f, 0xd433179d9c8cb841, ++ 0x9e19db92b4e31ba9, 0xeb96bf6ebadf77d9, ++ 0xaf87023b9bf0ee6b, ++]; ++static CACHED_POWERS_E_64: [i16; 87] = [ ++ -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980, ++ -954, -927, -901, -874, -847, -821, -794, -768, -741, -715, ++ -688, -661, -635, -608, -582, -555, -529, -502, -475, -449, ++ -422, -396, -369, -343, -316, -289, -263, -236, -210, -183, ++ -157, -130, -103, -77, -50, -24, 3, 30, 56, 83, ++ 109, 136, 162, 189, 216, 242, 269, 295, 322, 348, ++ 375, 402, 428, 455, 481, 508, 534, 561, 588, 614, ++ 641, 667, 694, 720, 747, 774, 800, 827, 853, 880, ++ 907, 933, 960, 986, 1013, 1039, 1066, ++]; diff --cc vendor/dtoa-0.4.2/tests/test.rs index 000000000,000000000..4f92d7ee1 new file mode 100644 --- /dev/null +++ b/vendor/dtoa-0.4.2/tests/test.rs @@@ -1,0 -1,0 +1,38 @@@ ++extern crate dtoa; ++ ++use std::str; ++ ++#[test] ++fn test_f64() { ++ test_write(1.234e20f64, "123400000000000000000.0"); ++ test_write(1.234e21f64, "1.234e21"); ++ test_write(2.71828f64, "2.71828"); ++ test_write(0.0f64, "0.0"); ++ test_write(-0.0f64, "-0.0"); ++ test_write(1.1e128f64, "1.1e128"); ++ test_write(1.1e-64f64, "1.1e-64"); ++ test_write(2.718281828459045f64, "2.718281828459045"); ++ test_write(5e-324f64, "5e-324"); ++ test_write(::std::f64::MAX, "1.7976931348623157e308"); ++} ++ ++#[test] ++fn test_f32() { ++ test_write(1.234e20f32, "123400000000000000000.0"); ++ test_write(1.234e21f32, "1.234e21"); ++ test_write(2.71828f32, "2.71828"); ++ test_write(0.0f32, "0.0"); ++ test_write(-0.0f32, "-0.0"); ++ test_write(1.1e32f32, "1.1e32"); ++ test_write(1.1e-32f32, "1.1e-32"); ++ test_write(2.7182817f32, "2.7182817"); ++ test_write(1e-45f32, "1e-45"); ++ test_write(::std::f32::MAX, "3.4028235e38"); ++} ++ ++fn test_write(value: F, expected: &'static str) { ++ let mut buf = [b'\0'; 30]; ++ let len = dtoa::write(&mut buf[..], value).unwrap(); ++ let result = str::from_utf8(&buf[..len]).unwrap(); ++ assert_eq!(result, expected.to_string()); ++} diff --cc vendor/error-chain-0.11.0/.cargo-checksum.json index 000000000,000000000..d961353eb new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"} diff --cc vendor/error-chain-0.11.0/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/.cargo-ok diff --cc vendor/error-chain-0.11.0/.travis.yml index 000000000,000000000..6bbf37eb3 new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/.travis.yml @@@ -1,0 -1,0 +1,46 @@@ ++language: rust ++rust: ++- stable ++- beta ++- nightly ++# Oldest supported version for all features. ++# Use of https://github.com/rust-lang/rfcs/pull/16 ++- 1.14.0 ++# Oldest supported version as dependency, with no features, tests, or examples. ++- 1.10.0 ++ ++sudo: false ++cache: cargo ++addons: ++ apt: ++ packages: ++ - libcurl4-openssl-dev ++ - libelf-dev ++ - libdw-dev ++ ++before_script: ++- | ++ pip install 'travis-cargo<0.2' --user && ++ export PATH=$HOME/.local/bin:$PATH ++ ++script: ++- travis-cargo build -- $FEATURES ++- travis-cargo --skip 1.10.0 test -- $FEATURES ++ ++after_success: ++- travis-cargo --only stable doc ++- travis-cargo --only stable doc-upload ++ ++env: ++ global: ++ - secure: ncxJbvJM1vCZfcEftjsFKJMxxhKLgWKaR8Go9AMo0VB5fB2XVW/6NYO5bQEEYpOf1Nc/+2FbI2+Dkz0S/mJpUcNSfBgablCHgwU2sHse7KsoaqfHj2mf1E3exjzSHoP96hPGicC5zAjSXFjCgJPOUSGqqRaJ7z5AsJLhJT6LuK7QpvwPBZzklUN8T+n1sVmws8TNmRIbaniq/q6wYHANHcy6Dl59dx4sKwniUGiZdUhCiddVpoxbECSxc0A8mN2pk7/aW+WGxK3goBs5ZF7+JXF318F62pDcXQmR5CX6WdpenIcJ25g1Vg1WhQ4Ifpe17CN0bfxV8ShuzrQUThCDMffZCo9XySBtODdEowwK1UIpjnFLfIxjOs45Cd8o3tM2j0CfvtnjOz6BCdUU0qiwNPPNx0wFkx3ZiOfSh+FhBhvyPM12HN2tdN0esgVBItFmEci+sSIIXqjVL6DNiu5zTjbu0bs6COwlUWdmL6vmsZtq5tl7Cno9+C3szxRVAkShGydd04l9NYjqNEzTa1EPG50OsnVRKGdRiFzSxhc3BWExNKvcQ4v867t6/PpPkW6s4oXmYI3+De+8O7ExWc6a4alcrDXKlMs5fCb5Pcd4Ju9kowcjkoJo5yf2wW3Ox5R8SJpaEEpvyhx5O/qtIxjhHNzeo8Wsr/6gdNDv20r91TI= ++ - TRAVIS_CARGO_NIGHTLY_FEATURE="" ++ - RUSTFLAGS="-D warnings" ++ matrix: ++ - FEATURES=--features=backtrace ++ - FEATURES=--no-default-features ++ ++matrix: ++ exclude: ++ - env: FEATURES=--features=backtrace ++ rust: 1.10.0 diff --cc vendor/error-chain-0.11.0/CHANGELOG.md index 000000000,000000000..ed0f12e3a new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/CHANGELOG.md @@@ -1,0 -1,0 +1,120 @@@ ++# Unreleased ++ ++# 0.11.0 ++ ++- Change last rust version supported to 1.14 ++- [Cache whether RUST_BACKTRACE is enabled in a relaxed atomic static.](https://github.com/rust-lang-nursery/error-chain/pull/210) ++- [Mask the `quick_error` macro from the doc](https://github.com/rust-lang-nursery/error-chain/pull/210) ++- [Make generated `ErrorKind` enums non-exhaustive](https://github.com/rust-lang-nursery/error-chain/pull/193) ++- All 0.11.0-rc.2 changes ++ ++# 0.11.0-rc.2 ++ ++- [Make `ErrorChainIter`'s field private](https://github.com/rust-lang-nursery/error-chain/issues/178) ++- [Rename `ErrorChainIter` to `Iter`](https://github.com/rust-lang-nursery/error-chain/issues/168) ++- [Implement `Debug` for `ErrorChainIter`](https://github.com/rust-lang-nursery/error-chain/issues/169) ++- [Rename `ChainedError::display` to `display_chain`](https://github.com/rust-lang-nursery/error-chain/issues/180) ++- [Add a new method for `Error`: `chain_err`.](https://github.com/rust-lang-nursery/error-chain/pull/141) ++- [Allow `chain_err` to be used on `Option`](https://github.com/rust-lang-nursery/error-chain/pull/156) ++- [Add support for creating an error chain on boxed trait errors (`Box`)](https://github.com/rust-lang-nursery/error-chain/pull/156) ++- [Remove lint for unused doc comment.](https://github.com/rust-lang-nursery/error-chain/pull/199) ++- [Hide error_chain_processed macro from documentation.](https://github.com/rust-lang-nursery/error-chain/pull/212) ++ ++# 0.10.0 ++ ++- [Add a new constructor for `Error`: `with_chain`.](https://github.com/rust-lang-nursery/error-chain/pull/126) ++- [Add the `ensure!` macro.](https://github.com/rust-lang-nursery/error-chain/pull/135) ++ ++# 0.9.0 ++ ++- Revert [Add a `Sync` bound to errors](https://github.com/rust-lang-nursery/error-chain/pull/110) ++ ++# 0.8.1 ++ ++- Add crates.io category. ++ ++# 0.8.0 ++ ++- [Add a `Sync` bound to errors](https://github.com/rust-lang-nursery/error-chain/pull/110) ++- [Add `ChainedError::display` to format error chains](https://github.com/rust-lang-nursery/error-chain/pull/113) ++ ++# 0.7.2 ++ ++- Add `quick_main!` (#88). ++- `allow(unused)` for the `Result` wrapper. ++- Minimum rust version supported is now 1.10 on some conditions (#103). ++ ++# 0.7.1 ++ ++- [Add the `bail!` macro](https://github.com/rust-lang-nursery/error-chain/pull/76) ++ ++# 0.7.0 ++ ++- [Rollback several design changes to fix regressions](https://github.com/rust-lang-nursery/error-chain/pull/75) ++- New `Variant(Error) #[attrs]` for `links` and `foreign_links`. ++- Hide implementation details from the doc. ++- Always generate `Error::backtrace`. ++ ++# 0.6.2 ++ ++- Allow dead code. ++ ++# 0.6.1 ++ ++- Fix wrong trait constraint in ResultExt implementation (#66). ++ ++# 0.6.0 ++ ++- Conditional compilation for error variants. ++- Backtrace generation is now a feature. ++- More standard trait implementations for extra convenience. ++- Remove ChainErr. ++- Remove need to specify `ErrorKind` in `links {}`. ++- Add ResultExt trait. ++- Error.1 is a struct instead of a tuple. ++- Error is now a struct. ++- The declarations order is more flexible. ++- Way better error reporting when there is a syntax error in the macro call. ++- `Result` generation can be disabled. ++- At most one declaration of each type can be present. ++ ++# 0.5.0 ++ ++- [Only generate backtraces with RUST_BACKTRACE set](https://github.com/rust-lang-nursery/error-chain/pull/27) ++- [Fixup matching, disallow repeating "types" section](https://github.com/rust-lang-nursery/error-chain/pull/26) ++- [Fix tests on stable/beta](https://github.com/rust-lang-nursery/error-chain/pull/28) ++- [Only deploy docs when tagged](https://github.com/rust-lang-nursery/error-chain/pull/30) ++ ++Contributors: benaryorg, Brian Anderson, Georg Brandl ++ ++# 0.4.2 ++ ++- [Fix the resolution of the ErrorKind description method](https://github.com/rust-lang-nursery/error-chain/pull/24) ++ ++Contributors: Brian Anderson ++ ++# 0.4.1 (yanked) ++ ++- [Fix a problem with resolving methods of the standard Error type](https://github.com/rust-lang-nursery/error-chain/pull/22) ++ ++Contributors: Brian Anderson ++ ++# 0.4.0 (yanked) ++ ++- [Remove the foreign link description and forward to the foreign error](https://github.com/rust-lang-nursery/error-chain/pull/19) ++- [Allow missing sections](https://github.com/rust-lang-nursery/error-chain/pull/17) ++ ++Contributors: Brian Anderson, Taylor Cramer ++ ++# 0.3.0 ++ ++- [Forward Display implementation for foreign errors](https://github.com/rust-lang-nursery/error-chain/pull/13) ++ ++Contributors: Brian Anderson, Taylor Cramer ++ ++# 0.2.2 ++ ++- [Don't require `types` section in macro invocation](https://github.com/rust-lang-nursery/error-chain/pull/8) ++- [Add "quick start" to README](https://github.com/rust-lang-nursery/error-chain/pull/9) ++ ++Contributors: Brian Anderson, Jake Shadle, Nate Mara diff --cc vendor/error-chain-0.11.0/Cargo.toml index 000000000,000000000..6c4e0e498 new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/Cargo.toml @@@ -1,0 -1,0 +1,32 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "error-chain" ++version = "0.11.0" ++authors = ["Brian Anderson ", "Paul Colomiets ", "Colin Kiegel ", "Yamakaky "] ++description = "Yet another error boilerplate library." ++documentation = "https://docs.rs/error-chain" ++readme = "README.md" ++keywords = ["error"] ++categories = ["rust-patterns"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/rust-lang-nursery/error-chain" ++[dependencies.backtrace] ++version = "0.3" ++optional = true ++ ++[features] ++example_generated = [] ++default = ["backtrace", "example_generated"] ++[badges.travis-ci] ++repository = "rust-lang-nursery/error-chain" diff --cc vendor/error-chain-0.11.0/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/error-chain-0.11.0/LICENSE-MIT index 000000000,000000000..5f28864c8 new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/LICENSE-MIT @@@ -1,0 -1,0 +1,26 @@@ ++Copyright (c) 2017 The Error-Chain 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 --cc vendor/error-chain-0.11.0/README.md index 000000000,000000000..51e50533e new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/README.md @@@ -1,0 -1,0 +1,36 @@@ ++# error-chain - Consistent error handling for Rust ++ ++[![Build Status](https://api.travis-ci.org/rust-lang-nursery/error-chain.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/error-chain) ++[![Latest Version](https://img.shields.io/crates/v/error-chain.svg)](https://crates.io/crates/error-chain) ++[![License](https://img.shields.io/github/license/rust-lang-nursery/error-chain.svg)](https://github.com/rust-lang-nursery/error-chain) ++ ++`error-chain` makes it easy to take full advantage of Rust's error ++handling features without the overhead of maintaining boilerplate ++error types and conversions. It implements an opinionated strategy for ++defining your own error types, as well as conversions from others' ++error types. ++ ++[Documentation (crates.io)](https://docs.rs/error-chain). ++ ++[Documentation (master)](https://rust-lang-nursery.github.io/error-chain). ++ ++## Quick start ++ ++If you just want to set up your new project with error-chain, ++follow the [quickstart.rs] template, and read this [intro] ++to error-chain. ++ ++[quickstart.rs]: https://github.com/rust-lang-nursery/error-chain/blob/master/examples/quickstart.rs ++[intro]: http://brson.github.io/2016/11/30/starting-with-error-chain ++ ++## Supported Rust version ++ ++Please view the beginning of the [Travis configuration file](.travis.yml) ++to see the oldest supported Rust version. ++ ++Note that `error-chain` supports older versions of Rust when built with ++`default-features = false`. ++ ++## License ++ ++MIT/Apache-2.0 diff --cc vendor/error-chain-0.11.0/examples/all.rs index 000000000,000000000..ccc3ab703 new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/examples/all.rs @@@ -1,0 -1,0 +1,36 @@@ ++#[macro_use] ++extern crate error_chain; ++ ++pub mod inner { ++ error_chain!{} ++} ++ ++#[cfg(feature = "a_feature")] ++pub mod feature { ++ error_chain!{} ++} ++ ++error_chain! { ++ // Types generated by the macro. If empty or absent, it defaults to ++ // Error, ErrorKind, Result; ++ types { ++ // With custom names: ++ MyError, MyErrorKind, MyResult; ++ // Without the `Result` wrapper: ++ // Error, ErrorKind; ++ } ++ ++ // Automatic bindings to other error types generated by `error_chain!`. ++ links { ++ Inner(inner::Error, inner::ErrorKind); ++ // Attributes can be added at the end of the declaration. ++ Feature(feature::Error, feature::ErrorKind) #[cfg(feature = "a_feature")]; ++ } ++ ++ // Bindings to types implementing std::error::Error. ++ foreign_links { ++ Io(::std::io::Error); ++ } ++} ++ ++fn main() {} diff --cc vendor/error-chain-0.11.0/examples/chain_err.rs index 000000000,000000000..bd8effdaf new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/examples/chain_err.rs @@@ -1,0 -1,0 +1,69 @@@ ++//! Demonstrates usage of `Error::caused` method. This method enables chaining errors ++//! like `ResultExt::chain_err` but doesn't require the presence of a `Result` wrapper. ++ ++#[macro_use] ++extern crate error_chain; ++ ++use std::fs::File; ++ ++mod errors { ++ use std::io; ++ use super::LaunchStage; ++ ++ error_chain! { ++ foreign_links { ++ Io(io::Error) #[doc = "Error during IO"]; ++ } ++ ++ errors { ++ Launch(phase: LaunchStage) { ++ description("An error occurred during startup") ++ display("Startup aborted: {:?} did not complete successfully", phase) ++ } ++ ++ ConfigLoad(path: String) { ++ description("Config file not found") ++ display("Unable to read file `{}`", path) ++ } ++ } ++ } ++ ++ impl From for ErrorKind { ++ fn from(v: LaunchStage) -> Self { ++ ErrorKind::Launch(v) ++ } ++ } ++} ++ ++pub use errors::*; ++ ++#[derive(Debug, Clone, PartialEq, Eq)] ++pub enum LaunchStage { ++ ConfigLoad, ++ ConfigParse, ++ ConfigResolve, ++} ++ ++/// Read the service config from the file specified. ++fn load_config(rel_path: &str) -> Result<()> { ++ File::open(rel_path) ++ .map(|_| ()) ++ .chain_err(|| ErrorKind::ConfigLoad(rel_path.to_string())) ++} ++ ++/// Launch the service. ++fn launch(rel_path: &str) -> Result<()> { ++ load_config(rel_path).map_err(|e| match e { ++ e @ Error(ErrorKind::ConfigLoad(_), _) => { ++ e.chain_err(|| LaunchStage::ConfigLoad) ++ } ++ e => e.chain_err(|| "Unknown failure"), ++ }) ++} ++ ++fn main() { ++ let chain = launch("does_not_exist.json").unwrap_err(); ++ for err in chain.iter() { ++ println!("{}", err); ++ } ++} diff --cc vendor/error-chain-0.11.0/examples/doc.rs index 000000000,000000000..999ac9cef new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/examples/doc.rs @@@ -1,0 -1,0 +1,28 @@@ ++#![deny(missing_docs)] ++ ++//! This module is used to check that all generated items are documented. ++ ++#[macro_use] ++extern crate error_chain; ++ ++/// Inner module. ++pub mod inner { ++ error_chain!{} ++} ++ ++error_chain! { ++ links { ++ Inner(inner::Error, inner::ErrorKind) #[doc = "Doc"]; ++ } ++ foreign_links { ++ Io(::std::io::Error) #[doc = "Io"]; ++ } ++ errors { ++ /// Doc ++ Test2 { ++ ++ } ++ } ++} ++ ++fn main() {} diff --cc vendor/error-chain-0.11.0/examples/quickstart.rs index 000000000,000000000..2e3e2b5d3 new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/examples/quickstart.rs @@@ -1,0 -1,0 +1,80 @@@ ++// Simple and robust error handling with error-chain! ++// Use this as a template for new projects. ++ ++// `error_chain!` can recurse deeply ++#![recursion_limit = "1024"] ++ ++// Import the macro. Don't forget to add `error-chain` in your ++// `Cargo.toml`! ++#[macro_use] ++extern crate error_chain; ++ ++// We'll put our errors in an `errors` module, and other modules in ++// this crate will `use errors::*;` to get access to everything ++// `error_chain!` creates. ++mod errors { ++ // Create the Error, ErrorKind, ResultExt, and Result types ++ error_chain!{} ++} ++ ++// This only gives access within this module. Make this `pub use errors::*;` ++// instead if the types must be accessible from other modules (e.g., within ++// a `links` section). ++use errors::*; ++ ++fn main() { ++ if let Err(ref e) = run() { ++ use std::io::Write; ++ let stderr = &mut ::std::io::stderr(); ++ let errmsg = "Error writing to stderr"; ++ ++ writeln!(stderr, "error: {}", e).expect(errmsg); ++ ++ for e in e.iter().skip(1) { ++ writeln!(stderr, "caused by: {}", e).expect(errmsg); ++ } ++ ++ // The backtrace is not always generated. Try to run this example ++ // with `RUST_BACKTRACE=1`. ++ if let Some(backtrace) = e.backtrace() { ++ writeln!(stderr, "backtrace: {:?}", backtrace).expect(errmsg); ++ } ++ ++ ::std::process::exit(1); ++ } ++} ++ ++// The above main gives you maximum control over how the error is ++// formatted. If you don't care (i.e. you want to display the full ++// error during an assert) you can just call the `display_chain` method ++// on the error object ++#[allow(dead_code)] ++fn alternative_main() { ++ if let Err(ref e) = run() { ++ use std::io::Write; ++ use error_chain::ChainedError; // trait which holds `display_chain` ++ let stderr = &mut ::std::io::stderr(); ++ let errmsg = "Error writing to stderr"; ++ ++ writeln!(stderr, "{}", e.display_chain()).expect(errmsg); ++ ::std::process::exit(1); ++ } ++} ++ ++// Use this macro to auto-generate the main above. You may want to ++// set the `RUST_BACKTRACE` env variable to see a backtrace. ++// quick_main!(run); ++ ++ ++// Most functions will return the `Result` type, imported from the ++// `errors` module. It is a typedef of the standard `Result` type ++// for which the error type is always our own `Error`. ++fn run() -> Result<()> { ++ use std::fs::File; ++ ++ // This operation will fail ++ File::open("tretrete") ++ .chain_err(|| "unable to open tretrete file")?; ++ ++ Ok(()) ++} diff --cc vendor/error-chain-0.11.0/examples/size.rs index 000000000,000000000..ae360d66e new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/examples/size.rs @@@ -1,0 -1,0 +1,38 @@@ ++#[macro_use] ++extern crate error_chain; ++ ++use std::mem::{size_of, size_of_val}; ++ ++error_chain! { ++ errors { ++ AVariant ++ Another ++ } ++} ++ ++fn main() { ++ println!("Memory usage in bytes"); ++ println!("---------------------"); ++ println!("Result<()>: {}", size_of::>()); ++ println!(" (): {}", size_of::<()>()); ++ println!(" Error: {}", size_of::()); ++ println!(" ErrorKind: {}", size_of::()); ++ let msg = ErrorKind::Msg("test".into()); ++ println!(" ErrorKind::Msg: {}", size_of_val(&msg)); ++ println!(" String: {}", size_of::()); ++ println!(" State: {}", size_of::()); ++ #[cfg(feature = "backtrace")] ++ { ++ let state = error_chain::State { ++ next_error: None, ++ backtrace: None, ++ }; ++ println!(" State.next_error: {}", size_of_val(&state.next_error)); ++ println!(" State.backtrace: {}", size_of_val(&state.backtrace)); ++ } ++ #[cfg(not(feature = "backtrace"))] ++ { ++ let state = error_chain::State { next_error: None }; ++ println!(" State.next_error: {}", size_of_val(&state.next_error)); ++ } ++} diff --cc vendor/error-chain-0.11.0/src/bin/has_backtrace.rs index 000000000,000000000..c5dac058a new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/src/bin/has_backtrace.rs @@@ -1,0 -1,0 +1,18 @@@ ++//! Exits with exit code 0 if backtraces are disabled and 1 if they are enabled. ++//! Used by tests to make sure backtraces are available when they should be. Should not be used ++//! outside of the tests. ++ ++#[macro_use] ++extern crate error_chain; ++ ++error_chain! { ++ errors { ++ MyError ++ } ++} ++ ++fn main() { ++ let err = Error::from(ErrorKind::MyError); ++ let has_backtrace = err.backtrace().is_some(); ++ ::std::process::exit(has_backtrace as i32); ++} diff --cc vendor/error-chain-0.11.0/src/error_chain.rs index 000000000,000000000..cbd42cd67 new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/src/error_chain.rs @@@ -1,0 -1,0 +1,458 @@@ ++/// Prefer to use `error_chain` instead of this macro. ++#[doc(hidden)] ++#[macro_export] ++macro_rules! impl_error_chain_processed { ++ // Default values for `types`. ++ ( ++ types {} ++ $( $rest: tt )* ++ ) => { ++ impl_error_chain_processed! { ++ types { ++ Error, ErrorKind, ResultExt, Result; ++ } ++ $( $rest )* ++ } ++ }; ++ // With `Result` wrapper. ++ ( ++ types { ++ $error_name:ident, $error_kind_name:ident, ++ $result_ext_name:ident, $result_name:ident; ++ } ++ $( $rest: tt )* ++ ) => { ++ impl_error_chain_processed! { ++ types { ++ $error_name, $error_kind_name, ++ $result_ext_name; ++ } ++ $( $rest )* ++ } ++ /// Convenient wrapper around `std::Result`. ++ #[allow(unused)] ++ pub type $result_name = ::std::result::Result; ++ }; ++ // Without `Result` wrapper. ++ ( ++ types { ++ $error_name:ident, $error_kind_name:ident, ++ $result_ext_name:ident; ++ } ++ ++ links { ++ $( $link_variant:ident ( $link_error_path:path, $link_kind_path:path ) ++ $( #[$meta_links:meta] )*; ) * ++ } ++ ++ foreign_links { ++ $( $foreign_link_variant:ident ( $foreign_link_error_path:path ) ++ $( #[$meta_foreign_links:meta] )*; )* ++ } ++ ++ errors { ++ $( $error_chunks:tt ) * ++ } ++ ++ ) => { ++ /// The Error type. ++ /// ++ /// This tuple struct is made of two elements: ++ /// ++ /// - an `ErrorKind` which is used to determine the type of the error. ++ /// - An internal `State`, not meant for direct use outside of `error_chain` ++ /// internals, containing: ++ /// - a backtrace, generated when the error is created. ++ /// - an error chain, used for the implementation of `Error::cause()`. ++ #[derive(Debug)] ++ pub struct $error_name( ++ // The members must be `pub` for `links`. ++ /// The kind of the error. ++ pub $error_kind_name, ++ /// Contains the error chain and the backtrace. ++ #[doc(hidden)] ++ pub $crate::State, ++ ); ++ ++ impl $crate::ChainedError for $error_name { ++ type ErrorKind = $error_kind_name; ++ ++ fn new(kind: $error_kind_name, state: $crate::State) -> $error_name { ++ $error_name(kind, state) ++ } ++ ++ fn from_kind(kind: Self::ErrorKind) -> Self { ++ Self::from_kind(kind) ++ } ++ ++ fn with_chain(error: E, kind: K) ++ -> Self ++ where E: ::std::error::Error + Send + 'static, ++ K: Into ++ { ++ Self::with_chain(error, kind) ++ } ++ ++ fn kind(&self) -> &Self::ErrorKind { ++ self.kind() ++ } ++ ++ fn iter(&self) -> $crate::Iter { ++ $crate::Iter::new(Some(self)) ++ } ++ ++ fn chain_err(self, error: F) -> Self ++ where F: FnOnce() -> EK, ++ EK: Into<$error_kind_name> { ++ self.chain_err(error) ++ } ++ ++ fn backtrace(&self) -> Option<&$crate::Backtrace> { ++ self.backtrace() ++ } ++ ++ impl_extract_backtrace!($error_name ++ $error_kind_name ++ $([$link_error_path, $(#[$meta_links])*])*); ++ } ++ ++ #[allow(dead_code)] ++ impl $error_name { ++ /// Constructs an error from a kind, and generates a backtrace. ++ pub fn from_kind(kind: $error_kind_name) -> $error_name { ++ $error_name( ++ kind, ++ $crate::State::default(), ++ ) ++ } ++ ++ /// Constructs a chained error from another error and a kind, and generates a backtrace. ++ pub fn with_chain(error: E, kind: K) ++ -> $error_name ++ where E: ::std::error::Error + Send + 'static, ++ K: Into<$error_kind_name> ++ { ++ $error_name::with_boxed_chain(Box::new(error), kind) ++ } ++ ++ /// Construct a chained error from another boxed error and a kind, and generates a backtrace ++ pub fn with_boxed_chain(error: Box<::std::error::Error + Send>, kind: K) ++ -> $error_name ++ where K: Into<$error_kind_name> ++ { ++ $error_name( ++ kind.into(), ++ $crate::State::new::<$error_name>(error, ), ++ ) ++ } ++ ++ /// Returns the kind of the error. ++ pub fn kind(&self) -> &$error_kind_name { ++ &self.0 ++ } ++ ++ /// Iterates over the error chain. ++ pub fn iter(&self) -> $crate::Iter { ++ $crate::ChainedError::iter(self) ++ } ++ ++ /// Returns the backtrace associated with this error. ++ pub fn backtrace(&self) -> Option<&$crate::Backtrace> { ++ self.1.backtrace() ++ } ++ ++ /// Extends the error chain with a new entry. ++ pub fn chain_err(self, error: F) -> $error_name ++ where F: FnOnce() -> EK, EK: Into<$error_kind_name> { ++ $error_name::with_chain(self, Self::from_kind(error().into())) ++ } ++ } ++ ++ impl ::std::error::Error for $error_name { ++ fn description(&self) -> &str { ++ self.0.description() ++ } ++ ++ #[allow(unknown_lints, unused_doc_comment)] ++ fn cause(&self) -> Option<&::std::error::Error> { ++ match self.1.next_error { ++ Some(ref c) => Some(&**c), ++ None => { ++ match self.0 { ++ $( ++ $(#[$meta_foreign_links])* ++ $error_kind_name::$foreign_link_variant(ref foreign_err) => { ++ foreign_err.cause() ++ } ++ ) * ++ _ => None ++ } ++ } ++ } ++ } ++ } ++ ++ impl ::std::fmt::Display for $error_name { ++ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { ++ ::std::fmt::Display::fmt(&self.0, f) ++ } ++ } ++ ++ $( ++ $(#[$meta_links])* ++ impl From<$link_error_path> for $error_name { ++ fn from(e: $link_error_path) -> Self { ++ $error_name( ++ $error_kind_name::$link_variant(e.0), ++ e.1, ++ ) ++ } ++ } ++ ) * ++ ++ $( ++ $(#[$meta_foreign_links])* ++ impl From<$foreign_link_error_path> for $error_name { ++ fn from(e: $foreign_link_error_path) -> Self { ++ $error_name::from_kind( ++ $error_kind_name::$foreign_link_variant(e) ++ ) ++ } ++ } ++ ) * ++ ++ impl From<$error_kind_name> for $error_name { ++ fn from(e: $error_kind_name) -> Self { ++ $error_name::from_kind(e) ++ } ++ } ++ ++ impl<'a> From<&'a str> for $error_name { ++ fn from(s: &'a str) -> Self { ++ $error_name::from_kind(s.into()) ++ } ++ } ++ ++ impl From for $error_name { ++ fn from(s: String) -> Self { ++ $error_name::from_kind(s.into()) ++ } ++ } ++ ++ impl ::std::ops::Deref for $error_name { ++ type Target = $error_kind_name; ++ ++ fn deref(&self) -> &Self::Target { ++ &self.0 ++ } ++ } ++ ++ ++ // The ErrorKind type ++ // -------------- ++ ++ impl_error_chain_kind! { ++ /// The kind of an error. ++ #[derive(Debug)] ++ pub enum $error_kind_name { ++ ++ /// A convenient variant for String. ++ Msg(s: String) { ++ description(&s) ++ display("{}", s) ++ } ++ ++ $( ++ $(#[$meta_links])* ++ $link_variant(e: $link_kind_path) { ++ description(e.description()) ++ display("{}", e) ++ } ++ ) * ++ ++ $( ++ $(#[$meta_foreign_links])* ++ $foreign_link_variant(err: $foreign_link_error_path) { ++ description(::std::error::Error::description(err)) ++ display("{}", err) ++ } ++ ) * ++ ++ $($error_chunks)* ++ } ++ } ++ ++ $( ++ $(#[$meta_links])* ++ impl From<$link_kind_path> for $error_kind_name { ++ fn from(e: $link_kind_path) -> Self { ++ $error_kind_name::$link_variant(e) ++ } ++ } ++ ) * ++ ++ impl<'a> From<&'a str> for $error_kind_name { ++ fn from(s: &'a str) -> Self { ++ $error_kind_name::Msg(s.to_string()) ++ } ++ } ++ ++ impl From for $error_kind_name { ++ fn from(s: String) -> Self { ++ $error_kind_name::Msg(s) ++ } ++ } ++ ++ impl From<$error_name> for $error_kind_name { ++ fn from(e: $error_name) -> Self { ++ e.0 ++ } ++ } ++ ++ // The ResultExt trait defines the `chain_err` method. ++ ++ /// Additional methods for `Result`, for easy interaction with this crate. ++ pub trait $result_ext_name { ++ /// If the `Result` is an `Err` then `chain_err` evaluates the closure, ++ /// which returns *some type that can be converted to `ErrorKind`*, boxes ++ /// the original error to store as the cause, then returns a new error ++ /// containing the original error. ++ fn chain_err(self, callback: F) -> ::std::result::Result ++ where F: FnOnce() -> EK, ++ EK: Into<$error_kind_name>; ++ } ++ ++ impl $result_ext_name for ::std::result::Result where E: ::std::error::Error + Send + 'static { ++ fn chain_err(self, callback: F) -> ::std::result::Result ++ where F: FnOnce() -> EK, ++ EK: Into<$error_kind_name> { ++ self.map_err(move |e| { ++ let state = $crate::State::new::<$error_name>(Box::new(e), ); ++ $crate::ChainedError::new(callback().into(), state) ++ }) ++ } ++ } ++ ++ impl $result_ext_name for ::std::option::Option { ++ fn chain_err(self, callback: F) -> ::std::result::Result ++ where F: FnOnce() -> EK, ++ EK: Into<$error_kind_name> { ++ self.ok_or_else(move || { ++ $crate::ChainedError::from_kind(callback().into()) ++ }) ++ } ++ } ++ ++ ++ }; ++} ++ ++/// Internal macro used for reordering of the fields. ++#[doc(hidden)] ++#[macro_export] ++macro_rules! error_chain_processing { ++ ( ++ ({}, $b:tt, $c:tt, $d:tt) ++ types $content:tt ++ $( $tail:tt )* ++ ) => { ++ error_chain_processing! { ++ ($content, $b, $c, $d) ++ $($tail)* ++ } ++ }; ++ ( ++ ($a:tt, {}, $c:tt, $d:tt) ++ links $content:tt ++ $( $tail:tt )* ++ ) => { ++ error_chain_processing! { ++ ($a, $content, $c, $d) ++ $($tail)* ++ } ++ }; ++ ( ++ ($a:tt, $b:tt, {}, $d:tt) ++ foreign_links $content:tt ++ $( $tail:tt )* ++ ) => { ++ error_chain_processing! { ++ ($a, $b, $content, $d) ++ $($tail)* ++ } ++ }; ++ ( ++ ($a:tt, $b:tt, $c:tt, {}) ++ errors $content:tt ++ $( $tail:tt )* ++ ) => { ++ error_chain_processing! { ++ ($a, $b, $c, $content) ++ $($tail)* ++ } ++ }; ++ ( ($a:tt, $b:tt, $c:tt, $d:tt) ) => { ++ impl_error_chain_processed! { ++ types $a ++ links $b ++ foreign_links $c ++ errors $d ++ } ++ }; ++} ++ ++/// Macro for generating error types and traits. See crate level documentation for details. ++#[macro_export] ++macro_rules! error_chain { ++ ( $( $block_name:ident { $( $block_content:tt )* } )* ) => { ++ error_chain_processing! { ++ ({}, {}, {}, {}) ++ $($block_name { $( $block_content )* })* ++ } ++ }; ++} ++ ++/// Macro used to manage the `backtrace` feature. ++/// ++/// See ++/// https://www.reddit.com/r/rust/comments/57virt/hey_rustaceans_got_an_easy_question_ask_here/da5r4ti/?context=3 ++/// for more details. ++#[macro_export] ++#[doc(hidden)] ++#[cfg(feature = "backtrace")] ++macro_rules! impl_extract_backtrace { ++ ($error_name: ident ++ $error_kind_name: ident ++ $([$link_error_path: path, $(#[$meta_links: meta])*])*) => { ++ #[allow(unknown_lints, unused_doc_comment)] ++ fn extract_backtrace(e: &(::std::error::Error + Send + 'static)) ++ -> Option<::std::sync::Arc<$crate::Backtrace>> { ++ if let Some(e) = e.downcast_ref::<$error_name>() { ++ return e.1.backtrace.clone(); ++ } ++ $( ++ $( #[$meta_links] )* ++ { ++ if let Some(e) = e.downcast_ref::<$link_error_path>() { ++ return e.1.backtrace.clone(); ++ } ++ } ++ ) * ++ None ++ } ++ } ++} ++ ++/// Macro used to manage the `backtrace` feature. ++/// ++/// See ++/// https://www.reddit.com/r/rust/comments/57virt/hey_rustaceans_got_an_easy_question_ask_here/da5r4ti/?context=3 ++/// for more details. ++#[macro_export] ++#[doc(hidden)] ++#[cfg(not(feature = "backtrace"))] ++macro_rules! impl_extract_backtrace { ++ ($error_name: ident ++ $error_kind_name: ident ++ $([$link_error_path: path, $(#[$meta_links: meta])*])*) => {} ++} diff --cc vendor/error-chain-0.11.0/src/example_generated.rs index 000000000,000000000..413407cae new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/src/example_generated.rs @@@ -1,0 -1,0 +1,38 @@@ ++//! These modules show an example of code generated by the macro. **IT MUST NOT BE ++//! USED OUTSIDE THIS CRATE**. ++//! ++//! This is the basic error structure. You can see that `ErrorKind` ++//! has been populated in a variety of ways. All `ErrorKind`s get a ++//! `Msg` variant for basic errors. When strings are converted to ++//! `ErrorKind`s they become `ErrorKind::Msg`. The "links" defined in ++//! the macro are expanded to the `Inner` variant, and the ++//! "foreign links" to the `Io` variant. ++//! ++//! Both types come with a variety of `From` conversions as well: ++//! `Error` can be created from `ErrorKind`, `&str` and `String`, ++//! and the `links` and `foreign_links` error types. `ErrorKind` ++//! can be created from the corresponding `ErrorKind`s of the link ++//! types, as well as from `&str` and `String`. ++//! ++//! `into()` and `From::from` are used heavily to massage types into ++//! the right shape. Which one to use in any specific case depends on ++//! the influence of type inference, but there are some patterns that ++//! arise frequently. ++ ++/// Another code generated by the macro. ++pub mod inner { ++ error_chain!{} ++} ++ ++error_chain! { ++ links { ++ Inner(inner::Error, inner::ErrorKind) #[doc = "Link to another `ErrorChain`."]; ++ } ++ foreign_links { ++ Io(::std::io::Error) #[doc = "Link to a `std::error::Error` type."]; ++ } ++ errors { ++ #[doc = "A custom error kind."] ++ Custom ++ } ++} diff --cc vendor/error-chain-0.11.0/src/impl_error_chain_kind.rs index 000000000,000000000..d6c05c8a8 new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/src/impl_error_chain_kind.rs @@@ -1,0 -1,0 +1,541 @@@ ++// From https://github.com/tailhook/quick-error ++// Changes: ++// - replace `impl Error` by `impl Item::description` ++// - $imeta ++ ++#[macro_export] ++#[doc(hidden)] ++macro_rules! impl_error_chain_kind { ++ ( $(#[$meta:meta])* ++ pub enum $name:ident { $($chunks:tt)* } ++ ) => { ++ impl_error_chain_kind!(SORT [pub enum $name $(#[$meta])* ] ++ items [] buf [] ++ queue [ $($chunks)* ]); ++ }; ++ ( $(#[$meta:meta])* ++ enum $name:ident { $($chunks:tt)* } ++ ) => { ++ impl_error_chain_kind!(SORT [enum $name $(#[$meta])* ] ++ items [] buf [] ++ queue [ $($chunks)* ]); ++ }; ++ // Queue is empty, can do the work ++ (SORT [enum $name:ident $( #[$meta:meta] )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [ ] ++ queue [ ] ++ ) => { ++ impl_error_chain_kind!(ENUM_DEFINITION [enum $name $( #[$meta] )*] ++ body [] ++ queue [$($( #[$imeta] )* ++ => $iitem: $imode [$( $ivar: $ityp ),*] )*] ++ ); ++ impl_error_chain_kind!(IMPLEMENTATIONS $name {$( ++ $iitem: $imode [$(#[$imeta])*] [$( $ivar: $ityp ),*] {$( $ifuncs )*} ++ )*}); ++ $( ++ impl_error_chain_kind!(ERROR_CHECK $imode $($ifuncs)*); ++ )* ++ }; ++ (SORT [pub enum $name:ident $( #[$meta:meta] )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [ ] ++ queue [ ] ++ ) => { ++ impl_error_chain_kind!(ENUM_DEFINITION [pub enum $name $( #[$meta] )*] ++ body [] ++ queue [$($( #[$imeta] )* ++ => $iitem: $imode [$( $ivar: $ityp ),*] )*] ++ ); ++ impl_error_chain_kind!(IMPLEMENTATIONS $name {$( ++ $iitem: $imode [$(#[$imeta])*] [$( $ivar: $ityp ),*] {$( $ifuncs )*} ++ )*}); ++ $( ++ impl_error_chain_kind!(ERROR_CHECK $imode $($ifuncs)*); ++ )* ++ }; ++ // Add meta to buffer ++ (SORT [$( $def:tt )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [$( #[$bmeta:meta] )*] ++ queue [ #[$qmeta:meta] $( $tail:tt )*] ++ ) => { ++ impl_error_chain_kind!(SORT [$( $def )*] ++ items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*] ++ buf [$( #[$bmeta] )* #[$qmeta] ] ++ queue [$( $tail )*]); ++ }; ++ // Add ident to buffer ++ (SORT [$( $def:tt )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [$( #[$bmeta:meta] )*] ++ queue [ $qitem:ident $( $tail:tt )*] ++ ) => { ++ impl_error_chain_kind!(SORT [$( $def )*] ++ items [$( $(#[$imeta])* ++ => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*] ++ buf [$(#[$bmeta])* => $qitem : UNIT [ ] ] ++ queue [$( $tail )*]); ++ }; ++ // Flush buffer on meta after ident ++ (SORT [$( $def:tt )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [$( #[$bmeta:meta] )* ++ => $bitem:ident: $bmode:tt [$( $bvar:ident: $btyp:ty ),*] ] ++ queue [ #[$qmeta:meta] $( $tail:tt )*] ++ ) => { ++ impl_error_chain_kind!(SORT [$( $def )*] ++ enum [$( $(#[$emeta])* => $eitem $(( $($etyp),* ))* )* ++ $(#[$bmeta])* => $bitem: $bmode $(( $($btyp),* ))*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )* ++ $bitem: $bmode [$( $bvar:$btyp ),*] {} ] ++ buf [ #[$qmeta] ] ++ queue [$( $tail )*]); ++ }; ++ // Add tuple enum-variant ++ (SORT [$( $def:tt )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [$( #[$bmeta:meta] )* => $bitem:ident: UNIT [ ] ] ++ queue [($( $qvar:ident: $qtyp:ty ),+) $( $tail:tt )*] ++ ) => { ++ impl_error_chain_kind!(SORT [$( $def )*] ++ items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*] ++ buf [$( #[$bmeta] )* => $bitem: TUPLE [$( $qvar:$qtyp ),*] ] ++ queue [$( $tail )*] ++ ); ++ }; ++ // Add struct enum-variant - e.g. { descr: &'static str } ++ (SORT [$( $def:tt )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [$( #[$bmeta:meta] )* => $bitem:ident: UNIT [ ] ] ++ queue [{ $( $qvar:ident: $qtyp:ty ),+} $( $tail:tt )*] ++ ) => { ++ impl_error_chain_kind!(SORT [$( $def )*] ++ items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*] ++ buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),*] ] ++ queue [$( $tail )*]); ++ }; ++ // Add struct enum-variant, with excess comma - e.g. { descr: &'static str, } ++ (SORT [$( $def:tt )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [$( #[$bmeta:meta] )* => $bitem:ident: UNIT [ ] ] ++ queue [{$( $qvar:ident: $qtyp:ty ),+ ,} $( $tail:tt )*] ++ ) => { ++ impl_error_chain_kind!(SORT [$( $def )*] ++ items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*] ++ buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),*] ] ++ queue [$( $tail )*]); ++ }; ++ // Add braces and flush always on braces ++ (SORT [$( $def:tt )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [$( #[$bmeta:meta] )* ++ => $bitem:ident: $bmode:tt [$( $bvar:ident: $btyp:ty ),*] ] ++ queue [ {$( $qfuncs:tt )*} $( $tail:tt )*] ++ ) => { ++ impl_error_chain_kind!(SORT [$( $def )*] ++ items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )* ++ $(#[$bmeta])* => $bitem: $bmode [$( $bvar:$btyp ),*] {$( $qfuncs )*} ] ++ buf [ ] ++ queue [$( $tail )*]); ++ }; ++ // Flush buffer on double ident ++ (SORT [$( $def:tt )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [$( #[$bmeta:meta] )* ++ => $bitem:ident: $bmode:tt [$( $bvar:ident: $btyp:ty ),*] ] ++ queue [ $qitem:ident $( $tail:tt )*] ++ ) => { ++ impl_error_chain_kind!(SORT [$( $def )*] ++ items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )* ++ $(#[$bmeta])* => $bitem: $bmode [$( $bvar:$btyp ),*] {} ] ++ buf [ => $qitem : UNIT [ ] ] ++ queue [$( $tail )*]); ++ }; ++ // Flush buffer on end ++ (SORT [$( $def:tt )*] ++ items [$($( #[$imeta:meta] )* ++ => $iitem:ident: $imode:tt [$( $ivar:ident: $ityp:ty ),*] ++ {$( $ifuncs:tt )*} )* ] ++ buf [$( #[$bmeta:meta] )* ++ => $bitem:ident: $bmode:tt [$( $bvar:ident: $btyp:ty ),*] ] ++ queue [ ] ++ ) => { ++ impl_error_chain_kind!(SORT [$( $def )*] ++ items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )* ++ $(#[$bmeta])* => $bitem: $bmode [$( $bvar:$btyp ),*] {} ] ++ buf [ ] ++ queue [ ]); ++ }; ++ // Public enum (Queue Empty) ++ (ENUM_DEFINITION [pub enum $name:ident $( #[$meta:meta] )*] ++ body [$($( #[$imeta:meta] )* ++ => $iitem:ident ($(($( $ttyp:ty ),+))*) {$({$( $svar:ident: $styp:ty ),*})*} )* ] ++ queue [ ] ++ ) => { ++ $(#[$meta])* ++ pub enum $name { ++ $( ++ $(#[$imeta])* ++ $iitem $(($( $ttyp ),*))* $({$( $svar: $styp ),*})*, ++ )* ++ ++ #[doc(hidden)] ++ __Nonexhaustive {} ++ } ++ }; ++ // Private enum (Queue Empty) ++ (ENUM_DEFINITION [enum $name:ident $( #[$meta:meta] )*] ++ body [$($( #[$imeta:meta] )* ++ => $iitem:ident ($(($( $ttyp:ty ),+))*) {$({$( $svar:ident: $styp:ty ),*})*} )* ] ++ queue [ ] ++ ) => { ++ $(#[$meta])* ++ enum $name { ++ $( ++ $(#[$imeta])* ++ $iitem $(($( $ttyp ),*))* $({$( $svar: $styp ),*})*, ++ )* ++ } ++ }; ++ // Unit variant ++ (ENUM_DEFINITION [$( $def:tt )*] ++ body [$($( #[$imeta:meta] )* ++ => $iitem:ident ($(($( $ttyp:ty ),+))*) {$({$( $svar:ident: $styp:ty ),*})*} )* ] ++ queue [$( #[$qmeta:meta] )* ++ => $qitem:ident: UNIT [ ] $( $queue:tt )*] ++ ) => { ++ impl_error_chain_kind!(ENUM_DEFINITION [ $($def)* ] ++ body [$($( #[$imeta] )* => $iitem ($(($( $ttyp ),+))*) {$({$( $svar: $styp ),*})*} )* ++ $( #[$qmeta] )* => $qitem () {} ] ++ queue [ $($queue)* ] ++ ); ++ }; ++ // Tuple variant ++ (ENUM_DEFINITION [$( $def:tt )*] ++ body [$($( #[$imeta:meta] )* ++ => $iitem:ident ($(($( $ttyp:ty ),+))*) {$({$( $svar:ident: $styp:ty ),*})*} )* ] ++ queue [$( #[$qmeta:meta] )* ++ => $qitem:ident: TUPLE [$( $qvar:ident: $qtyp:ty ),+] $( $queue:tt )*] ++ ) => { ++ impl_error_chain_kind!(ENUM_DEFINITION [ $($def)* ] ++ body [$($( #[$imeta] )* => $iitem ($(($( $ttyp ),+))*) {$({$( $svar: $styp ),*})*} )* ++ $( #[$qmeta] )* => $qitem (($( $qtyp ),*)) {} ] ++ queue [ $($queue)* ] ++ ); ++ }; ++ // Struct variant ++ (ENUM_DEFINITION [$( $def:tt )*] ++ body [$($( #[$imeta:meta] )* ++ => $iitem:ident ($(($( $ttyp:ty ),+))*) {$({$( $svar:ident: $styp:ty ),*})*} )* ] ++ queue [$( #[$qmeta:meta] )* ++ => $qitem:ident: STRUCT [$( $qvar:ident: $qtyp:ty ),*] $( $queue:tt )*] ++ ) => { ++ impl_error_chain_kind!(ENUM_DEFINITION [ $($def)* ] ++ body [$($( #[$imeta] )* => $iitem ($(($( $ttyp ),+))*) {$({$( $svar: $styp ),*})*} )* ++ $( #[$qmeta] )* => $qitem () {{$( $qvar: $qtyp ),*}} ] ++ queue [ $($queue)* ] ++ ); ++ }; ++ (IMPLEMENTATIONS ++ $name:ident {$( ++ $item:ident: $imode:tt [$(#[$imeta:meta])*] [$( $var:ident: $typ:ty ),*] {$( $funcs:tt )*} ++ )*} ++ ) => { ++ #[allow(unknown_lints, unused, unused_doc_comment)] ++ impl ::std::fmt::Display for $name { ++ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) ++ -> ::std::fmt::Result ++ { ++ match *self { ++ $( ++ $(#[$imeta])* ++ impl_error_chain_kind!(ITEM_PATTERN ++ $name $item: $imode [$( ref $var ),*] ++ ) => { ++ let display_fn = impl_error_chain_kind!(FIND_DISPLAY_IMPL ++ $name $item: $imode ++ {$( $funcs )*}); ++ ++ display_fn(self, fmt) ++ } ++ )* ++ ++ _ => Ok(()) ++ } ++ } ++ } ++ /*#[allow(unused)] ++ impl ::std::error::Error for $name { ++ fn description(&self) -> &str { ++ match *self { ++ $( ++ impl_error_chain_kind!(ITEM_PATTERN ++ $name $item: $imode [$( ref $var ),*] ++ ) => { ++ impl_error_chain_kind!(FIND_DESCRIPTION_IMPL ++ $item: $imode self fmt [$( $var ),*] ++ {$( $funcs )*}) ++ } ++ )* ++ } ++ } ++ fn cause(&self) -> Option<&::std::error::Error> { ++ match *self { ++ $( ++ impl_error_chain_kind!(ITEM_PATTERN ++ $name $item: $imode [$( ref $var ),*] ++ ) => { ++ impl_error_chain_kind!(FIND_CAUSE_IMPL ++ $item: $imode [$( $var ),*] ++ {$( $funcs )*}) ++ } ++ )* ++ } ++ } ++ }*/ ++ #[allow(unknown_lints, unused, unused_doc_comment)] ++ impl $name { ++ /// A string describing the error kind. ++ pub fn description(&self) -> &str { ++ match *self { ++ $( ++ $(#[$imeta])* ++ impl_error_chain_kind!(ITEM_PATTERN ++ $name $item: $imode [$( ref $var ),*] ++ ) => { ++ impl_error_chain_kind!(FIND_DESCRIPTION_IMPL ++ $item: $imode self fmt [$( $var ),*] ++ {$( $funcs )*}) ++ } ++ )* ++ ++ _ => "", ++ } ++ } ++ } ++ $( ++ impl_error_chain_kind!(FIND_FROM_IMPL ++ $name $item: $imode [$( $var:$typ ),*] ++ {$( $funcs )*}); ++ )* ++ }; ++ (FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt ++ { display($self_:tt) -> ($( $exprs:tt )*) $( $tail:tt )*} ++ ) => { ++ |impl_error_chain_kind!(IDENT $self_): &$name, f: &mut ::std::fmt::Formatter| { ++ write!(f, $( $exprs )*) ++ } ++ }; ++ (FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt ++ { display($pattern:expr) $( $tail:tt )*} ++ ) => { ++ |_, f: &mut ::std::fmt::Formatter| { write!(f, $pattern) } ++ }; ++ (FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt ++ { display($pattern:expr, $( $exprs:tt )*) $( $tail:tt )*} ++ ) => { ++ |_, f: &mut ::std::fmt::Formatter| { write!(f, $pattern, $( $exprs )*) } ++ }; ++ (FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt ++ { $t:tt $( $tail:tt )*} ++ ) => { ++ impl_error_chain_kind!(FIND_DISPLAY_IMPL ++ $name $item: $imode ++ {$( $tail )*}) ++ }; ++ (FIND_DISPLAY_IMPL $name:ident $item:ident: $imode:tt ++ { } ++ ) => { ++ |self_: &$name, f: &mut ::std::fmt::Formatter| { ++ write!(f, "{}", self_.description()) ++ } ++ }; ++ (FIND_DESCRIPTION_IMPL $item:ident: $imode:tt $me:ident $fmt:ident ++ [$( $var:ident ),*] ++ { description($expr:expr) $( $tail:tt )*} ++ ) => { ++ $expr ++ }; ++ (FIND_DESCRIPTION_IMPL $item:ident: $imode:tt $me:ident $fmt:ident ++ [$( $var:ident ),*] ++ { $t:tt $( $tail:tt )*} ++ ) => { ++ impl_error_chain_kind!(FIND_DESCRIPTION_IMPL ++ $item: $imode $me $fmt [$( $var ),*] ++ {$( $tail )*}) ++ }; ++ (FIND_DESCRIPTION_IMPL $item:ident: $imode:tt $me:ident $fmt:ident ++ [$( $var:ident ),*] ++ { } ++ ) => { ++ stringify!($item) ++ }; ++ (FIND_CAUSE_IMPL $item:ident: $imode:tt ++ [$( $var:ident ),*] ++ { cause($expr:expr) $( $tail:tt )*} ++ ) => { ++ Some($expr) ++ }; ++ (FIND_CAUSE_IMPL $item:ident: $imode:tt ++ [$( $var:ident ),*] ++ { $t:tt $( $tail:tt )*} ++ ) => { ++ impl_error_chain_kind!(FIND_CAUSE_IMPL ++ $item: $imode [$( $var ),*] ++ { $($tail)* }) ++ }; ++ (FIND_CAUSE_IMPL $item:ident: $imode:tt ++ [$( $var:ident ),*] ++ { } ++ ) => { ++ None ++ }; ++ (FIND_FROM_IMPL $name:ident $item:ident: $imode:tt ++ [$( $var:ident: $typ:ty ),*] ++ { from() $( $tail:tt )*} ++ ) => { ++ $( ++ impl From<$typ> for $name { ++ fn from($var: $typ) -> $name { ++ $name::$item($var) ++ } ++ } ++ )* ++ impl_error_chain_kind!(FIND_FROM_IMPL ++ $name $item: $imode [$( $var:$typ ),*] ++ {$( $tail )*}); ++ }; ++ (FIND_FROM_IMPL $name:ident $item:ident: UNIT ++ [ ] ++ { from($ftyp:ty) $( $tail:tt )*} ++ ) => { ++ impl From<$ftyp> for $name { ++ fn from(_discarded_error: $ftyp) -> $name { ++ $name::$item ++ } ++ } ++ impl_error_chain_kind!(FIND_FROM_IMPL ++ $name $item: UNIT [ ] ++ {$( $tail )*}); ++ }; ++ (FIND_FROM_IMPL $name:ident $item:ident: TUPLE ++ [$( $var:ident: $typ:ty ),*] ++ { from($fvar:ident: $ftyp:ty) -> ($( $texpr:expr ),*) $( $tail:tt )*} ++ ) => { ++ impl From<$ftyp> for $name { ++ fn from($fvar: $ftyp) -> $name { ++ $name::$item($( $texpr ),*) ++ } ++ } ++ impl_error_chain_kind!(FIND_FROM_IMPL ++ $name $item: TUPLE [$( $var:$typ ),*] ++ { $($tail)* }); ++ }; ++ (FIND_FROM_IMPL $name:ident $item:ident: STRUCT ++ [$( $var:ident: $typ:ty ),*] ++ { from($fvar:ident: $ftyp:ty) -> {$( $tvar:ident: $texpr:expr ),*} $( $tail:tt )*} ++ ) => { ++ impl From<$ftyp> for $name { ++ fn from($fvar: $ftyp) -> $name { ++ $name::$item { ++ $( $tvar: $texpr ),* ++ } ++ } ++ } ++ impl_error_chain_kind!(FIND_FROM_IMPL ++ $name $item: STRUCT [$( $var:$typ ),*] ++ { $($tail)* }); ++ }; ++ (FIND_FROM_IMPL $name:ident $item:ident: $imode:tt ++ [$( $var:ident: $typ:ty ),*] ++ { $t:tt $( $tail:tt )*} ++ ) => { ++ impl_error_chain_kind!(FIND_FROM_IMPL ++ $name $item: $imode [$( $var:$typ ),*] ++ {$( $tail )*} ++ ); ++ }; ++ (FIND_FROM_IMPL $name:ident $item:ident: $imode:tt ++ [$( $var:ident: $typ:ty ),*] ++ { } ++ ) => { ++ }; ++ (ITEM_BODY $(#[$imeta:meta])* $item:ident: UNIT ++ ) => { }; ++ (ITEM_BODY $(#[$imeta:meta])* $item:ident: TUPLE ++ [$( $typ:ty ),*] ++ ) => { ++ ($( $typ ),*) ++ }; ++ (ITEM_BODY $(#[$imeta:meta])* $item:ident: STRUCT ++ [$( $var:ident: $typ:ty ),*] ++ ) => { ++ {$( $var:$typ ),*} ++ }; ++ (ITEM_PATTERN $name:ident $item:ident: UNIT [] ++ ) => { ++ $name::$item ++ }; ++ (ITEM_PATTERN $name:ident $item:ident: TUPLE ++ [$( ref $var:ident ),*] ++ ) => { ++ $name::$item ($( ref $var ),*) ++ }; ++ (ITEM_PATTERN $name:ident $item:ident: STRUCT ++ [$( ref $var:ident ),*] ++ ) => { ++ $name::$item {$( ref $var ),*} ++ }; ++ // This one should match all allowed sequences in "funcs" but not match ++ // anything else. ++ // This is to contrast FIND_* clauses which just find stuff they need and ++ // skip everything else completely ++ (ERROR_CHECK $imode:tt display($self_:tt) -> ($( $exprs:tt )*) $( $tail:tt )*) ++ => { impl_error_chain_kind!(ERROR_CHECK_COMMA $imode $($tail)*); }; ++ (ERROR_CHECK $imode:tt display($pattern: expr) $( $tail:tt )*) ++ => { impl_error_chain_kind!(ERROR_CHECK_COMMA $imode $($tail)*); }; ++ (ERROR_CHECK $imode:tt display($pattern: expr, $( $exprs:tt )*) $( $tail:tt )*) ++ => { impl_error_chain_kind!(ERROR_CHECK_COMMA $imode $($tail)*); }; ++ (ERROR_CHECK $imode:tt description($expr:expr) $( $tail:tt )*) ++ => { impl_error_chain_kind!(ERROR_CHECK_COMMA $imode $($tail)*); }; ++ (ERROR_CHECK $imode:tt cause($expr:expr) $($tail:tt)*) ++ => { impl_error_chain_kind!(ERROR_CHECK_COMMA $imode $($tail)*); }; ++ (ERROR_CHECK $imode:tt from() $($tail:tt)*) ++ => { impl_error_chain_kind!(ERROR_CHECK_COMMA $imode $($tail)*); }; ++ (ERROR_CHECK $imode:tt from($ftyp:ty) $($tail:tt)*) ++ => { impl_error_chain_kind!(ERROR_CHECK_COMMA $imode $($tail)*); }; ++ (ERROR_CHECK TUPLE from($fvar:ident: $ftyp:ty) -> ($( $e:expr ),*) $( $tail:tt )*) ++ => { impl_error_chain_kind!(ERROR_CHECK_COMMA TUPLE $($tail)*); }; ++ (ERROR_CHECK STRUCT from($fvar:ident: $ftyp:ty) -> {$( $v:ident: $e:expr ),*} $( $tail:tt )*) ++ => { impl_error_chain_kind!(ERROR_CHECK_COMMA STRUCT $($tail)*); }; ++ (ERROR_CHECK $imode:tt ) => {}; ++ (ERROR_CHECK_COMMA $imode:tt , $( $tail:tt )*) ++ => { impl_error_chain_kind!(ERROR_CHECK $imode $($tail)*); }; ++ (ERROR_CHECK_COMMA $imode:tt $( $tail:tt )*) ++ => { impl_error_chain_kind!(ERROR_CHECK $imode $($tail)*); }; ++ // Utility functions ++ (IDENT $ident:ident) => { $ident } ++} diff --cc vendor/error-chain-0.11.0/src/lib.rs index 000000000,000000000..d0881fcef new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/src/lib.rs @@@ -1,0 -1,0 +1,865 @@@ ++#![deny(missing_docs)] ++#![allow(unknown_lints)] // to be removed when unused_doc_comments lints is merged ++#![doc(html_root_url = "https://docs.rs/error-chain/0.11.0")] ++ ++//! A library for consistent and reliable error handling ++//! ++//! error-chain makes it easy to take full advantage of Rust's ++//! powerful error handling features without the overhead of ++//! maintaining boilerplate error types and conversions. It implements ++//! an opinionated strategy for defining your own error types, as well ++//! as conversions from others' error types. ++//! ++//! ## Quick start ++//! ++//! If you just want to set up your new project with error-chain, ++//! follow the [quickstart.rs] template, and read this [intro] ++//! to error-chain. ++//! ++//! [quickstart.rs]: https://github.com/rust-lang-nursery/error-chain/blob/master/examples/quickstart.rs ++//! [intro]: http://brson.github.io/2016/11/30/starting-with-error-chain ++//! ++//! ## Why error chain? ++//! ++//! * error-chain is easy to configure. Handle errors robustly with minimal ++//! effort. ++//! * Basic error handling requires no maintenance of custom error types ++//! nor the [`From`] conversions that make `?` work. ++//! * error-chain scales from simple error handling strategies to more ++//! rigorous. Return formatted strings for simple errors, only ++//! introducing error variants and their strong typing as needed for ++//! advanced error recovery. ++//! * error-chain makes it trivial to correctly manage the [cause] of ++//! the errors generated by your own code. This is the "chaining" ++//! in "error-chain". ++//! ++//! [cause]: https://doc.rust-lang.org/std/error/trait.Error.html#method.cause ++//! ++//! ## Principles of error-chain ++//! ++//! error-chain is based on the following principles: ++//! ++//! * No error should ever be discarded. This library primarily ++//! makes it easy to "chain" errors with the [`chain_err`] method. ++//! * Introducing new errors is trivial. Simple errors can be introduced ++//! at the error site with just a string. ++//! * Handling errors is possible with pattern matching. ++//! * Conversions between error types are done in an automatic and ++//! consistent way - [`From`] conversion behavior is never specified ++//! explicitly. ++//! * Errors implement [`Send`]. ++//! * Errors can carry backtraces. ++//! ++//! Similar to other libraries like [error-type] and [quick-error], ++//! this library introduces the error chaining mechanism originally ++//! employed by Cargo. The [`error_chain!`] macro declares the types ++//! and implementation boilerplate necessary for fulfilling a ++//! particular error-handling strategy. Most importantly it defines a ++//! custom error type (called [`Error`] by convention) and the [`From`] ++//! conversions that let the `?` operator work. ++//! ++//! This library differs in a few ways from previous error libs: ++//! ++//! * Instead of defining the custom [`Error`] type as an enum, it is a ++//! struct containing an [`ErrorKind`][] (which defines the ++//! [`description`] and [`display_chain`] methods for the error), an opaque, ++//! optional, boxed [`std::error::Error`]` + `[`Send`]` + 'static` object ++//! (which defines the [`cause`], and establishes the links in the ++//! error chain), and a [`Backtrace`]. ++//! * The macro also defines a [`ResultExt`] trait that defines a ++//! [`chain_err`] method. This method on all [`std::error::Error`]` + `[`Send`]` + 'static` ++//! types extends the error chain by boxing the current ++//! error into an opaque object and putting it inside a new concrete ++//! error. ++//! * It provides automatic [`From`] conversions between other error types ++//! defined by the [`error_chain!`] that preserve type information, ++//! and facilitate seamless error composition and matching of composed ++//! errors. ++//! * It provides automatic [`From`] conversions between any other error ++//! type that hides the type of the other error in the [`cause`] box. ++//! * If `RUST_BACKTRACE` is enabled, it collects a single backtrace at ++//! the earliest opportunity and propagates it down the stack through ++//! [`From`] and [`ResultExt`] conversions. ++//! ++//! To accomplish its goals it makes some tradeoffs: ++//! ++//! * The split between the [`Error`] and [`ErrorKind`] types can make it ++//! slightly more cumbersome to instantiate new (unchained) errors, ++//! requiring an [`Into`] or [`From`] conversion; as well as slightly ++//! more cumbersome to match on errors with another layer of types ++//! to match. ++//! * Because the error type contains [`std::error::Error`]` + `[`Send`]` + 'static` objects, ++//! it can't implement [`PartialEq`] for easy comparisons. ++//! ++//! ## Declaring error types ++//! ++//! Generally, you define one family of error types per crate, though ++//! it's also perfectly fine to define error types on a finer-grained ++//! basis, such as per module. ++//! ++//! Assuming you are using crate-level error types, typically you will ++//! define an `errors` module and inside it call [`error_chain!`]: ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! mod other_error { ++//! error_chain! {} ++//! } ++//! ++//! error_chain! { ++//! // The type defined for this error. These are the conventional ++//! // and recommended names, but they can be arbitrarily chosen. ++//! // ++//! // It is also possible to leave this section out entirely, or ++//! // leave it empty, and these names will be used automatically. ++//! types { ++//! Error, ErrorKind, ResultExt, Result; ++//! } ++//! ++//! // Without the `Result` wrapper: ++//! // ++//! // types { ++//! // Error, ErrorKind, ResultExt; ++//! // } ++//! ++//! // Automatic conversions between this error chain and other ++//! // error chains. In this case, it will e.g. generate an ++//! // `ErrorKind` variant called `Another` which in turn contains ++//! // the `other_error::ErrorKind`, with conversions from ++//! // `other_error::Error`. ++//! // ++//! // Optionally, some attributes can be added to a variant. ++//! // ++//! // This section can be empty. ++//! links { ++//! Another(other_error::Error, other_error::ErrorKind) #[cfg(unix)]; ++//! } ++//! ++//! // Automatic conversions between this error chain and other ++//! // error types not defined by the `error_chain!`. These will be ++//! // wrapped in a new error with, in the first case, the ++//! // `ErrorKind::Fmt` variant. The description and cause will ++//! // forward to the description and cause of the original error. ++//! // ++//! // Optionally, some attributes can be added to a variant. ++//! // ++//! // This section can be empty. ++//! foreign_links { ++//! Fmt(::std::fmt::Error); ++//! Io(::std::io::Error) #[cfg(unix)]; ++//! } ++//! ++//! // Define additional `ErrorKind` variants. Define custom responses with the ++//! // `description` and `display` calls. ++//! errors { ++//! InvalidToolchainName(t: String) { ++//! description("invalid toolchain name") ++//! display("invalid toolchain name: '{}'", t) ++//! } ++//! ++//! // You can also add commas after description/display. ++//! // This may work better with some editor auto-indentation modes: ++//! UnknownToolchainVersion(v: String) { ++//! description("unknown toolchain version"), // note the , ++//! display("unknown toolchain version: '{}'", v), // trailing comma is allowed ++//! } ++//! } ++//! } ++//! ++//! # fn main() {} ++//! ``` ++//! ++//! Each section, `types`, `links`, `foreign_links`, and `errors` may ++//! be omitted if it is empty. ++//! ++//! This populates the module with a number of definitions, ++//! the most important of which are the [`Error`] type ++//! and the [`ErrorKind`] type. An example of generated code can be found in the ++//! [example_generated](example_generated/index.html) module. ++//! ++//! ## Returning new errors ++//! ++//! Introducing new error chains, with a string message: ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! # fn main() {} ++//! # error_chain! {} ++//! fn foo() -> Result<()> { ++//! Err("foo error!".into()) ++//! } ++//! ``` ++//! ++//! Introducing new error chains, with an [`ErrorKind`]: ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! # fn main() {} ++//! error_chain! { ++//! errors { FooError } ++//! } ++//! ++//! fn foo() -> Result<()> { ++//! Err(ErrorKind::FooError.into()) ++//! } ++//! ``` ++//! ++//! Note that the return type is the typedef [`Result`], which is ++//! defined by the macro as `pub type Result = ++//! ::std::result::Result`. Note that in both cases ++//! [`.into()`] is called to convert a type into the [`Error`] type; both ++//! strings and [`ErrorKind`] have [`From`] conversions to turn them into ++//! [`Error`]. ++//! ++//! When the error is emitted behind the `?` operator, the explicit conversion ++//! isn't needed; `Err(ErrorKind)` will automatically be converted to `Err(Error)`. ++//! So the below is equivalent to the previous: ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! # fn main() {} ++//! # error_chain! { errors { FooError } } ++//! fn foo() -> Result<()> { ++//! Ok(Err(ErrorKind::FooError)?) ++//! } ++//! ++//! fn bar() -> Result<()> { ++//! Ok(Err("bogus!")?) ++//! } ++//! ``` ++//! ++//! ## The `bail!` macro ++//! ++//! The above method of introducing new errors works but is a little ++//! verbose. Instead, we can use the [`bail!`] macro, which performs an early return ++//! with conversions done automatically. ++//! ++//! With [`bail!`] the previous examples look like: ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! # fn main() {} ++//! # error_chain! { errors { FooError } } ++//! fn foo() -> Result<()> { ++//! if true { ++//! bail!(ErrorKind::FooError); ++//! } else { ++//! Ok(()) ++//! } ++//! } ++//! ++//! fn bar() -> Result<()> { ++//! if true { ++//! bail!("bogus!"); ++//! } else { ++//! Ok(()) ++//! } ++//! } ++//! ``` ++//! ++//! ## Chaining errors ++//! error-chain supports extending an error chain by appending new errors. ++//! This can be done on a Result or on an existing Error. ++//! ++//! To extend the error chain: ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! # fn main() {} ++//! # error_chain! {} ++//! # fn do_something() -> Result<()> { unimplemented!() } ++//! # fn test() -> Result<()> { ++//! let res: Result<()> = do_something().chain_err(|| "something went wrong"); ++//! # Ok(()) ++//! # } ++//! ``` ++//! ++//! [`chain_err`] can be called on any [`Result`] type where the contained ++//! error type implements [`std::error::Error`]` + `[`Send`]` + 'static`, as long as ++//! the [`Result`] type's corresponding [`ResultExt`] trait is in scope. If ++//! the [`Result`] is an `Err` then [`chain_err`] evaluates the closure, ++//! which returns *some type that can be converted to [`ErrorKind`]*, ++//! boxes the original error to store as the cause, then returns a new ++//! error containing the original error. ++//! ++//! Calling [`chain_err`][Error_chain_err] on an existing [`Error`] instance has ++//! the same signature and produces the same outcome as being called on a ++//! [`Result`] matching the properties described above. This is most useful when ++//! partially handling errors using the [`map_err`] function. ++//! ++//! To chain an error directly, use [`with_chain`]: ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! # fn main() {} ++//! # error_chain! {} ++//! # fn do_something() -> Result<()> { unimplemented!() } ++//! # fn test() -> Result<()> { ++//! let res: Result<()> = ++//! do_something().map_err(|e| Error::with_chain(e, "something went wrong")); ++//! # Ok(()) ++//! # } ++//! ``` ++//! ++//! ## Linking errors ++//! ++//! To convert an error from another error chain to this error chain: ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! # fn main() {} ++//! # mod other { error_chain! {} } ++//! error_chain! { ++//! links { ++//! OtherError(other::Error, other::ErrorKind); ++//! } ++//! } ++//! ++//! fn do_other_thing() -> other::Result<()> { unimplemented!() } ++//! ++//! # fn test() -> Result<()> { ++//! let res: Result<()> = do_other_thing().map_err(|e| e.into()); ++//! # Ok(()) ++//! # } ++//! ``` ++//! ++//! The [`Error`] and [`ErrorKind`] types implements [`From`] for the corresponding ++//! types of all linked error chains. Linked errors do not introduce a new ++//! cause to the error chain. ++//! ++//! ## Matching errors ++//! ++//! error-chain error variants are matched with simple patterns. ++//! [`Error`] is a tuple struct and its first field is the [`ErrorKind`], ++//! making dispatching on error kinds relatively compact: ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! # fn main() { ++//! error_chain! { ++//! errors { ++//! InvalidToolchainName(t: String) { ++//! description("invalid toolchain name") ++//! display("invalid toolchain name: '{}'", t) ++//! } ++//! } ++//! } ++//! ++//! match Error::from("error!") { ++//! Error(ErrorKind::InvalidToolchainName(_), _) => { } ++//! Error(ErrorKind::Msg(_), _) => { } ++//! _ => { } ++//! } ++//! # } ++//! ``` ++//! ++//! Chained errors are also matched with (relatively) compact syntax ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! mod utils { ++//! error_chain! { ++//! errors { ++//! BadStuff { ++//! description("bad stuff") ++//! } ++//! } ++//! } ++//! } ++//! ++//! mod app { ++//! error_chain! { ++//! links { ++//! Utils(::utils::Error, ::utils::ErrorKind); ++//! } ++//! } ++//! } ++//! ++//! ++//! # fn main() { ++//! match app::Error::from("error!") { ++//! app::Error(app::ErrorKind::Utils(utils::ErrorKind::BadStuff), _) => { } ++//! _ => { } ++//! } ++//! # } ++//! ``` ++//! ++//! ## Inspecting errors ++//! ++//! An error-chain error contains information about the error itself, a backtrace, and the chain ++//! of causing errors. For reporting purposes, this information can be accessed as follows. ++//! ++//! ``` ++//! # #[macro_use] extern crate error_chain; ++//! use error_chain::ChainedError; // for e.display_chain() ++//! ++//! error_chain! { ++//! errors { ++//! InvalidToolchainName(t: String) { ++//! description("invalid toolchain name") ++//! display("invalid toolchain name: '{}'", t) ++//! } ++//! } ++//! } ++//! ++//! # fn main() { ++//! // Generate an example error to inspect: ++//! let e = "xyzzy".parse::() ++//! .chain_err(|| ErrorKind::InvalidToolchainName("xyzzy".to_string())) ++//! .unwrap_err(); ++//! ++//! // Get the brief description of the error: ++//! assert_eq!(e.description(), "invalid toolchain name"); ++//! ++//! // Get the display version of the error: ++//! assert_eq!(e.to_string(), "invalid toolchain name: 'xyzzy'"); ++//! ++//! // Get the full cause and backtrace: ++//! println!("{}", e.display_chain().to_string()); ++//! // Error: invalid toolchain name: 'xyzzy' ++//! // Caused by: invalid digit found in string ++//! // stack backtrace: ++//! // 0: 0x7fa9f684fc94 - backtrace::backtrace::libunwind::trace ++//! // at src/backtrace/libunwind.rs:53 ++//! // - backtrace::backtrace::trace ++//! // at src/backtrace/mod.rs:42 ++//! // 1: 0x7fa9f6850b0e - backtrace::capture::{{impl}}::new ++//! // at out/capture.rs:79 ++//! // [..] ++//! # } ++//! ``` ++//! ++//! The [`Error`] and [`ErrorKind`] types also allow programmatic access to these elements. ++//! ++//! ## Foreign links ++//! ++//! Errors that do not conform to the same conventions as this library ++//! can still be included in the error chain. They are considered "foreign ++//! errors", and are declared using the `foreign_links` block of the ++//! [`error_chain!`] macro. [`Error`]s are automatically created from ++//! foreign errors by the `?` operator. ++//! ++//! Foreign links and regular links have one crucial difference: ++//! [`From`] conversions for regular links *do not introduce a new error ++//! into the error chain*, while conversions for foreign links *always ++//! introduce a new error into the error chain*. So for the example ++//! above all errors deriving from the [`std::fmt::Error`] type will be ++//! presented to the user as a new [`ErrorKind`] variant, and the ++//! cause will be the original [`std::fmt::Error`] error. In contrast, when ++//! `other_error::Error` is converted to `Error` the two `ErrorKind`s ++//! are converted between each other to create a new `Error` but the ++//! old error is discarded; there is no "cause" created from the ++//! original error. ++//! ++//! ## Backtraces ++//! ++//! If the `RUST_BACKTRACE` environment variable is set to anything ++//! but ``0``, the earliest non-foreign error to be generated creates ++//! a single backtrace, which is passed through all [`From`] conversions ++//! and [`chain_err`] invocations of compatible types. To read the ++//! backtrace just call the [`backtrace`] method. ++//! ++//! Backtrace generation can be disabled by turning off the `backtrace` feature. ++//! ++//! The Backtrace contains a Vec of [`BacktraceFrame`]s that can be operated ++//! on directly. For example, to only see the files and line numbers of code ++//! within your own project. ++//! ++//! ``` ++//! # #[macro_use] ++//! # extern crate error_chain; ++//! # mod errors { ++//! # error_chain! { ++//! # foreign_links { ++//! # Io(::std::io::Error); ++//! # } ++//! # } ++//! # } ++//! # use errors::*; ++//! # #[cfg(feature="backtrace")] ++//! # fn main() { ++//! if let Err(ref e) = open_file() { ++//! if let Some(backtrace) = e.backtrace() { ++//! let frames = backtrace.frames(); ++//! for frame in frames.iter() { ++//! for symbol in frame.symbols().iter() { ++//! if let (Some(file), Some(lineno)) = (symbol.filename(), symbol.lineno()) { ++//! if file.display().to_string()[0..3] == "src".to_string(){ ++//! println!("{}:{}", file.display().to_string(), lineno); ++//! } ++//! } ++//! } ++//! } ++//! } ++//! }; ++//! # } ++//! # #[cfg(not(feature="backtrace"))] ++//! # fn main() { } ++//! ++//! fn open_file() -> Result<()> { ++//! std::fs::File::open("does_not_exist")?; ++//! Ok(()) ++//! } ++//! ``` ++//! ++//! ## Iteration ++//! ++//! The [`iter`] method returns an iterator over the chain of error boxes. ++//! ++//! [error-type]: https://github.com/DanielKeep/rust-error-type ++//! [quick-error]: https://github.com/tailhook/quick-error ++ ++//! [`display_chain`]: trait.ChainedError.html#method.display_chain ++//! [`error_chain!`]: macro.error_chain.html ++//! [`bail!`]: macro.bail.html ++//! [`Backtrace`]: struct.Backtrace.html ++ ++//! [`Error`]: example_generated/struct.Error.html ++//! [`with_chain`]: example_generated/struct.Error.html#method.with_chain ++//! [Error_chain_err]: example_generated/struct.Error.html#method.chain_err ++//! [`cause`]: example_generated/struct.Error.html#method.cause ++//! [`backtrace`]: example_generated/struct.Error.html#method.backtrace ++//! [`iter`]: example_generated/struct.Error.html#method.iter ++//! [`ErrorKind`]: example_generated/enum.ErrorKind.html ++//! [`description`]: example_generated/enum.ErrorKind.html#method.description ++//! [`Result`]: example_generated/type.Result.html ++//! [`ResultExt`]: example_generated/trait.ResultExt.html ++//! [`chain_err`]: example_generated/trait.ResultExt.html#tymethod.chain_err ++ ++//! [`std::error::Error`]: https://doc.rust-lang.org/std/error/trait.Error.html ++//! [`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html ++//! [`Into`]: https://doc.rust-lang.org/std/convert/trait.Into.html ++//! [`From`]: https://doc.rust-lang.org/std/convert/trait.From.html ++//! [`PartialEq`]: https://doc.rust-lang.org/std/cmp/trait.PartialEq.html ++//! [`std::fmt::Error`]: https://doc.rust-lang.org/std/fmt/struct.Error.html ++//! [`.into()`]: https://doc.rust-lang.org/std/convert/trait.Into.html#tymethod.into ++//! [`map_err`]: https://doc.rust-lang.org/std/result/enum.Result.html#method.map_err ++//! [`BacktraceFrame`]: https://docs.rs/backtrace/0.3.2/backtrace/struct.BacktraceFrame.html ++ ++ ++#[cfg(feature = "backtrace")] ++extern crate backtrace; ++ ++use std::error; ++use std::iter::Iterator; ++#[cfg(feature = "backtrace")] ++use std::sync::Arc; ++use std::fmt; ++ ++#[cfg(feature = "backtrace")] ++pub use backtrace::Backtrace; ++#[cfg(not(feature = "backtrace"))] ++/// Dummy type used when the `backtrace` feature is disabled. ++pub type Backtrace = (); ++ ++#[macro_use] ++mod impl_error_chain_kind; ++#[macro_use] ++mod error_chain; ++#[macro_use] ++mod quick_main; ++pub use quick_main::ExitCode; ++#[cfg(feature = "example_generated")] ++pub mod example_generated; ++ ++#[derive(Debug)] ++/// Iterator over the error chain using the `Error::cause()` method. ++pub struct Iter<'a>(Option<&'a error::Error>); ++ ++impl<'a> Iter<'a> { ++ /// Returns a new iterator over the error chain using `Error::cause()`. ++ pub fn new(err: Option<&'a error::Error>) -> Iter<'a> { ++ Iter(err) ++ } ++} ++ ++impl<'a> Iterator for Iter<'a> { ++ type Item = &'a error::Error; ++ ++ fn next<'b>(&'b mut self) -> Option<&'a error::Error> { ++ match self.0.take() { ++ Some(e) => { ++ self.0 = e.cause(); ++ Some(e) ++ } ++ None => None, ++ } ++ } ++} ++ ++/// Returns a backtrace of the current call stack if `RUST_BACKTRACE` ++/// is set to anything but ``0``, and `None` otherwise. This is used ++/// in the generated error implementations. ++#[cfg(feature = "backtrace")] ++#[doc(hidden)] ++pub fn make_backtrace() -> Option> { ++ use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering}; ++ ++ // The lowest bit indicates whether the value was computed, ++ // while the second lowest bit is the actual "enabled" bit. ++ static BACKTRACE_ENABLED_CACHE: AtomicUsize = ATOMIC_USIZE_INIT; ++ ++ let enabled = match BACKTRACE_ENABLED_CACHE.load(Ordering::Relaxed) { ++ 0 => { ++ let enabled = match std::env::var_os("RUST_BACKTRACE") { ++ Some(ref val) if val != "0" => true, ++ _ => false ++ }; ++ let encoded = ((enabled as usize) << 1) | 1; ++ BACKTRACE_ENABLED_CACHE.store(encoded, Ordering::Relaxed); ++ enabled ++ } ++ encoded => (encoded >> 1) != 0 ++ }; ++ ++ if enabled { ++ Some(Arc::new(Backtrace::new())) ++ } else { ++ None ++ } ++} ++ ++/// This trait is implemented on all the errors generated by the `error_chain` ++/// macro. ++pub trait ChainedError: error::Error + Send + 'static { ++ /// Associated kind type. ++ type ErrorKind; ++ ++ /// Constructs an error from a kind, and generates a backtrace. ++ fn from_kind(kind: Self::ErrorKind) -> Self where Self: Sized; ++ ++ /// Constructs a chained error from another error and a kind, and generates a backtrace. ++ fn with_chain(error: E, kind: K) -> Self ++ where Self: Sized, ++ E: ::std::error::Error + Send + 'static, ++ K: Into; ++ ++ /// Returns the kind of the error. ++ fn kind(&self) -> &Self::ErrorKind; ++ ++ /// Iterates over the error chain. ++ fn iter(&self) -> Iter; ++ ++ /// Returns the backtrace associated with this error. ++ fn backtrace(&self) -> Option<&Backtrace>; ++ ++ /// Returns an object which implements `Display` for printing the full ++ /// context of this error. ++ /// ++ /// The full cause chain and backtrace, if present, will be printed. ++ fn display_chain<'a>(&'a self) -> DisplayChain<'a, Self> { ++ DisplayChain(self) ++ } ++ ++ /// Extends the error chain with a new entry. ++ fn chain_err(self, error: F) -> Self ++ where F: FnOnce() -> EK, ++ EK: Into; ++ ++ /// Creates an error from its parts. ++ #[doc(hidden)] ++ fn new(kind: Self::ErrorKind, state: State) -> Self where Self: Sized; ++ ++ /// Returns the first known backtrace, either from its State or from one ++ /// of the errors from `foreign_links`. ++ #[cfg(feature = "backtrace")] ++ #[doc(hidden)] ++ fn extract_backtrace(e: &(error::Error + Send + 'static)) -> Option> ++ where Self: Sized; ++} ++ ++/// A struct which formats an error for output. ++#[derive(Debug)] ++pub struct DisplayChain<'a, T: 'a + ?Sized>(&'a T); ++ ++impl<'a, T> fmt::Display for DisplayChain<'a, T> ++ where T: ChainedError ++{ ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ // Keep `try!` for 1.10 support ++ try!(writeln!(fmt, "Error: {}", self.0)); ++ ++ for e in self.0.iter().skip(1) { ++ try!(writeln!(fmt, "Caused by: {}", e)); ++ } ++ ++ if let Some(backtrace) = self.0.backtrace() { ++ try!(writeln!(fmt, "{:?}", backtrace)); ++ } ++ ++ Ok(()) ++ } ++} ++ ++/// Common state between errors. ++#[derive(Debug)] ++#[doc(hidden)] ++pub struct State { ++ /// Next error in the error chain. ++ pub next_error: Option>, ++ /// Backtrace for the current error. ++ #[cfg(feature = "backtrace")] ++ pub backtrace: Option>, ++} ++ ++impl Default for State { ++ #[cfg(feature = "backtrace")] ++ fn default() -> State { ++ State { ++ next_error: None, ++ backtrace: make_backtrace(), ++ } ++ } ++ ++ #[cfg(not(feature = "backtrace"))] ++ fn default() -> State { ++ State { next_error: None } ++ } ++} ++ ++impl State { ++ /// Creates a new State type ++ #[cfg(feature = "backtrace")] ++ pub fn new(e: Box) -> State { ++ let backtrace = CE::extract_backtrace(&*e).or_else(make_backtrace); ++ State { ++ next_error: Some(e), ++ backtrace: backtrace, ++ } ++ } ++ ++ /// Creates a new State type ++ #[cfg(not(feature = "backtrace"))] ++ pub fn new(e: Box) -> State { ++ State { next_error: Some(e) } ++ } ++ ++ /// Returns the inner backtrace if present. ++ #[cfg(feature = "backtrace")] ++ pub fn backtrace(&self) -> Option<&Backtrace> { ++ self.backtrace.as_ref().map(|v| &**v) ++ } ++ ++ /// Returns the inner backtrace if present. ++ #[cfg(not(feature = "backtrace"))] ++ pub fn backtrace(&self) -> Option<&Backtrace> { ++ None ++ } ++} ++ ++/// Exits a function early with an error ++/// ++/// The `bail!` macro provides an easy way to exit a function. ++/// `bail!(expr)` is equivalent to writing. ++/// ++/// ``` ++/// # #[macro_use] extern crate error_chain; ++/// # error_chain! { } ++/// # fn main() { } ++/// # fn foo() -> Result<()> { ++/// # let expr = ""; ++/// return Err(expr.into()); ++/// # } ++/// ``` ++/// ++/// And as shorthand it takes a formatting string a la `println!`: ++/// ++/// ``` ++/// # #[macro_use] extern crate error_chain; ++/// # error_chain! { } ++/// # fn main() { } ++/// # fn foo() -> Result<()> { ++/// # let n = 0; ++/// bail!("bad number: {}", n); ++/// # } ++/// ``` ++/// ++/// # Examples ++/// ++/// Bailing on a custom error: ++/// ++/// ``` ++/// # #[macro_use] extern crate error_chain; ++/// # fn main() {} ++/// error_chain! { ++/// errors { FooError } ++/// } ++/// ++/// fn foo() -> Result<()> { ++/// if bad_condition() { ++/// bail!(ErrorKind::FooError); ++/// } ++/// ++/// Ok(()) ++/// } ++/// ++/// # fn bad_condition() -> bool { true } ++/// ``` ++/// ++/// Bailing on a formatted string: ++/// ++/// ``` ++/// # #[macro_use] extern crate error_chain; ++/// # fn main() {} ++/// error_chain! { } ++/// ++/// fn foo() -> Result<()> { ++/// if let Some(bad_num) = bad_condition() { ++/// bail!("so bad: {}", bad_num); ++/// } ++/// ++/// Ok(()) ++/// } ++/// ++/// # fn bad_condition() -> Option { None } ++/// ``` ++#[macro_export] ++macro_rules! bail { ++ ($e:expr) => { ++ return Err($e.into()); ++ }; ++ ($fmt:expr, $($arg:tt)+) => { ++ return Err(format!($fmt, $($arg)+).into()); ++ }; ++} ++ ++/// Exits a function early with an error if the condition is not satisfied ++/// ++/// The `ensure!` macro is a convenience helper that provides a way to exit ++/// a function with an error if the given condition fails. ++/// ++/// As an example, `ensure!(condition, "error code: {}", errcode)` is equivalent to ++/// ++/// ``` ++/// # #[macro_use] extern crate error_chain; ++/// # error_chain! { } ++/// # fn main() { } ++/// # fn foo() -> Result<()> { ++/// # let errcode = 0u8; ++/// # let condition = true; ++/// if !condition { ++/// bail!("error code: {}", errcode); ++/// } ++/// # Ok(()) ++/// # } ++/// ``` ++/// ++/// See documentation for `bail!` macro for further details. ++#[macro_export] ++macro_rules! ensure { ++ ($cond:expr, $e:expr) => { ++ if !($cond) { ++ bail!($e); ++ } ++ }; ++ ($cond:expr, $fmt:expr, $($arg:tt)+) => { ++ if !($cond) { ++ bail!($fmt, $($arg)+); ++ } ++ }; ++} ++ ++#[doc(hidden)] ++pub mod mock { ++ error_chain!{} ++} diff --cc vendor/error-chain-0.11.0/src/quick_main.rs index 000000000,000000000..f81e7d704 new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/src/quick_main.rs @@@ -1,0 -1,0 +1,77 @@@ ++/// Convenient wrapper to be able to use `?` and such in the main. You can ++/// use it with a separated function: ++/// ++/// ``` ++/// # #[macro_use] extern crate error_chain; ++/// # error_chain! {} ++/// # fn main() { ++/// quick_main!(run); ++/// # } ++/// ++/// fn run() -> Result<()> { ++/// Err("error".into()) ++/// } ++/// ``` ++/// ++/// or with a closure: ++/// ++/// ``` ++/// # #[macro_use] extern crate error_chain; ++/// # error_chain! {} ++/// # fn main() { ++/// quick_main!(|| -> Result<()> { ++/// Err("error".into()) ++/// }); ++/// # } ++/// ``` ++/// ++/// You can also set the exit value of the process by returning a type that implements [`ExitCode`](trait.ExitCode.html): ++/// ++/// ``` ++/// # #[macro_use] extern crate error_chain; ++/// # error_chain! {} ++/// # fn main() { ++/// quick_main!(run); ++/// # } ++/// ++/// fn run() -> Result { ++/// Err("error".into()) ++/// } ++/// ``` ++#[macro_export] ++macro_rules! quick_main { ++ ($main:expr) => { ++ fn main() { ++ use ::std::io::Write; ++ ++ ::std::process::exit(match $main() { ++ Ok(ret) => $crate::ExitCode::code(ret), ++ Err(ref e) => { ++ write!(&mut ::std::io::stderr(), "{}", $crate::ChainedError::display_chain(e)) ++ .expect("Error writing to stderr"); ++ ++ 1 ++ } ++ }); ++ } ++ }; ++} ++ ++/// Represents a value that can be used as the exit status of the process. ++/// See [`quick_main!`](macro.quick_main.html). ++pub trait ExitCode { ++ /// Returns the value to use as the exit status. ++ fn code(self) -> i32; ++} ++ ++impl ExitCode for i32 { ++ fn code(self) -> i32 { ++ self ++ } ++} ++ ++impl ExitCode for () { ++ fn code(self) -> i32 { ++ 0 ++ } ++} diff --cc vendor/error-chain-0.11.0/tests/quick_main.rs index 000000000,000000000..4ada3b4e0 new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/tests/quick_main.rs @@@ -1,0 -1,0 +1,28 @@@ ++#![allow(dead_code)] ++#[macro_use] ++extern crate error_chain; ++ ++error_chain!(); ++ ++mod unit { ++ use super::*; ++ quick_main!(run); ++ ++ fn run() -> Result<()> { ++ Ok(()) ++ } ++} ++ ++mod i32 { ++ use super::*; ++ quick_main!(run); ++ ++ fn run() -> Result { ++ Ok(1) ++ } ++} ++ ++mod closure { ++ use super::*; ++ quick_main!(|| -> Result<()> { Ok(()) }); ++} diff --cc vendor/error-chain-0.11.0/tests/tests.rs index 000000000,000000000..e603e02af new file mode 100644 --- /dev/null +++ b/vendor/error-chain-0.11.0/tests/tests.rs @@@ -1,0 -1,0 +1,628 @@@ ++#![allow(dead_code)] ++ ++#[macro_use] ++extern crate error_chain; ++ ++#[test] ++fn smoke_test_1() { ++ error_chain! { ++ types { ++ Error, ErrorKind, ResultExt, Result; ++ } ++ ++ links { } ++ ++ foreign_links { } ++ ++ errors { } ++ }; ++} ++ ++#[test] ++fn smoke_test_2() { ++ error_chain! { ++ types { } ++ ++ links { } ++ ++ foreign_links { } ++ ++ errors { } ++ }; ++} ++ ++#[test] ++fn smoke_test_3() { ++ error_chain! { ++ links { } ++ ++ foreign_links { } ++ ++ errors { } ++ }; ++} ++ ++#[test] ++fn smoke_test_4() { ++ error_chain! { ++ links { } ++ ++ foreign_links { } ++ ++ errors { ++ HttpStatus(e: u32) { ++ description("http request returned an unsuccessful status code") ++ display("http request returned an unsuccessful status code: {}", e) ++ } ++ } ++ }; ++} ++ ++#[test] ++fn smoke_test_5() { ++ error_chain! { ++ types { } ++ ++ links { } ++ ++ foreign_links { } ++ ++ errors { ++ HttpStatus(e: u32) { ++ description("http request returned an unsuccessful status code") ++ display("http request returned an unsuccessful status code: {}", e) ++ } ++ } ++ }; ++} ++ ++#[test] ++fn smoke_test_6() { ++ error_chain! { ++ errors { ++ HttpStatus(e: u32) { ++ description("http request returned an unsuccessful status code") ++ display("http request returned an unsuccessful status code: {}", e) ++ } ++ } ++ }; ++} ++ ++#[test] ++fn smoke_test_7() { ++ error_chain! { ++ types { } ++ ++ foreign_links { } ++ ++ errors { ++ HttpStatus(e: u32) { ++ description("http request returned an unsuccessful status code") ++ display("http request returned an unsuccessful status code: {}", e) ++ } ++ } ++ }; ++} ++ ++#[test] ++fn smoke_test_8() { ++ error_chain! { ++ types { } ++ ++ links { } ++ links { } ++ ++ foreign_links { } ++ foreign_links { } ++ ++ errors { ++ FileNotFound ++ AccessDenied ++ } ++ }; ++} ++ ++#[test] ++fn order_test_1() { ++ error_chain! { types { } links { } foreign_links { } errors { } }; ++} ++ ++#[test] ++fn order_test_2() { ++ error_chain! { links { } types { } foreign_links { } errors { } }; ++} ++ ++#[test] ++fn order_test_3() { ++ error_chain! { foreign_links { } links { } errors { } types { } }; ++} ++ ++#[test] ++fn order_test_4() { ++ error_chain! { errors { } types { } foreign_links { } }; ++} ++ ++#[test] ++fn order_test_5() { ++ error_chain! { foreign_links { } types { } }; ++} ++ ++#[test] ++fn order_test_6() { ++ error_chain! { ++ links { } ++ ++ errors { ++ HttpStatus(e: u32) { ++ description("http request returned an unsuccessful status code") ++ display("http request returned an unsuccessful status code: {}", e) ++ } ++ } ++ ++ ++ foreign_links { } ++ }; ++} ++ ++#[test] ++fn order_test_7() { ++ error_chain! { ++ links { } ++ ++ foreign_links { } ++ ++ types { ++ Error, ErrorKind, ResultExt, Result; ++ } ++ }; ++} ++ ++ ++#[test] ++fn order_test_8() { ++ error_chain! { ++ links { } ++ ++ foreign_links { } ++ foreign_links { } ++ ++ types { ++ Error, ErrorKind, ResultExt, Result; ++ } ++ }; ++} ++ ++#[test] ++fn empty() { ++ error_chain!{}; ++} ++ ++#[test] ++#[cfg(feature = "backtrace")] ++fn has_backtrace_depending_on_env() { ++ use std::process::Command; ++ use std::path::Path; ++ ++ let cmd_path = if cfg!(windows) { ++ Path::new("./target/debug/has_backtrace.exe") ++ } else { ++ Path::new("./target/debug/has_backtrace") ++ }; ++ let mut cmd = Command::new(cmd_path); ++ ++ // missing RUST_BACKTRACE and RUST_BACKTRACE=0 ++ cmd.env_remove("RUST_BACKTRACE"); ++ assert_eq!(cmd.status().unwrap().code().unwrap(), 0); ++ ++ cmd.env("RUST_BACKTRACE", "0"); ++ assert_eq!(cmd.status().unwrap().code().unwrap(), 0); ++ ++ // RUST_BACKTRACE set to anything but 0 ++ cmd.env("RUST_BACKTRACE", "yes"); ++ assert_eq!(cmd.status().unwrap().code().unwrap(), 1); ++ ++ cmd.env("RUST_BACKTRACE", "1"); ++ assert_eq!(cmd.status().unwrap().code().unwrap(), 1); ++} ++ ++#[test] ++fn chain_err() { ++ use std::fmt; ++ ++ error_chain! { ++ foreign_links { ++ Fmt(fmt::Error); ++ } ++ errors { ++ Test ++ } ++ } ++ ++ let _: Result<()> = Err(fmt::Error).chain_err(|| ""); ++ let _: Result<()> = Err(Error::from_kind(ErrorKind::Test)).chain_err(|| ""); ++} ++ ++/// Verify that an error chain is extended one by `Error::chain_err`, with ++/// the new error added to the end. ++#[test] ++fn error_chain_err() { ++ error_chain! { ++ errors { ++ Test ++ } ++ } ++ ++ let base = Error::from(ErrorKind::Test); ++ let ext = base.chain_err(|| "Test passes"); ++ ++ if let Error(ErrorKind::Msg(_), _) = ext { ++ // pass ++ } else { ++ panic!("The error should be wrapped. {:?}", ext); ++ } ++} ++ ++#[test] ++fn links() { ++ mod test { ++ error_chain!{} ++ } ++ ++ error_chain! { ++ links { ++ Test(test::Error, test::ErrorKind); ++ } ++ } ++} ++ ++#[cfg(test)] ++mod foreign_link_test { ++ ++ use std::fmt; ++ ++ // Note: foreign errors must be `pub` because they appear in the ++ // signature of the public foreign_link_error_path ++ #[derive(Debug)] ++ pub struct ForeignError { ++ cause: ForeignErrorCause, ++ } ++ ++ impl ::std::error::Error for ForeignError { ++ fn description(&self) -> &'static str { ++ "Foreign error description" ++ } ++ ++ fn cause(&self) -> Option<&::std::error::Error> { ++ Some(&self.cause) ++ } ++ } ++ ++ impl fmt::Display for ForeignError { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ write!(formatter, "Foreign error display") ++ } ++ } ++ ++ #[derive(Debug)] ++ pub struct ForeignErrorCause {} ++ ++ impl ::std::error::Error for ForeignErrorCause { ++ fn description(&self) -> &'static str { ++ "Foreign error cause description" ++ } ++ ++ fn cause(&self) -> Option<&::std::error::Error> { ++ None ++ } ++ } ++ ++ impl fmt::Display for ForeignErrorCause { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ write!(formatter, "Foreign error cause display") ++ } ++ } ++ ++ error_chain! { ++ types{ ++ Error, ErrorKind, ResultExt, Result; ++ } ++ links {} ++ foreign_links { ++ Foreign(ForeignError); ++ Io(::std::io::Error); ++ } ++ errors {} ++ } ++ ++ #[test] ++ fn display_underlying_error() { ++ let chained_error = try_foreign_error().err().unwrap(); ++ assert_eq!(format!("{}", ForeignError { cause: ForeignErrorCause {} }), ++ format!("{}", chained_error)); ++ } ++ ++ #[test] ++ fn finds_cause() { ++ let chained_error = try_foreign_error().err().unwrap(); ++ assert_eq!(format!("{}", ForeignErrorCause {}), ++ format!("{}", ::std::error::Error::cause(&chained_error).unwrap())); ++ } ++ ++ #[test] ++ fn iterates() { ++ let chained_error = try_foreign_error().err().unwrap(); ++ let mut error_iter = chained_error.iter(); ++ assert!(!format!("{:?}", error_iter).is_empty()); ++ assert_eq!(format!("{}", ForeignError { cause: ForeignErrorCause {} }), ++ format!("{}", error_iter.next().unwrap())); ++ assert_eq!(format!("{}", ForeignErrorCause {}), ++ format!("{}", error_iter.next().unwrap())); ++ assert_eq!(format!("{:?}", None as Option<&::std::error::Error>), ++ format!("{:?}", error_iter.next())); ++ } ++ ++ fn try_foreign_error() -> Result<()> { ++ Err(ForeignError { cause: ForeignErrorCause {} })?; ++ Ok(()) ++ } ++} ++ ++#[cfg(test)] ++mod attributes_test { ++ #[allow(unused_imports)] ++ use std::io; ++ ++ #[cfg(not(test))] ++ mod inner { ++ error_chain!{} ++ } ++ ++ error_chain! { ++ types { ++ Error, ErrorKind, ResultExt, Result; ++ } ++ ++ links { ++ Inner(inner::Error, inner::ErrorKind) #[cfg(not(test))]; ++ } ++ ++ foreign_links { ++ Io(io::Error) #[cfg(not(test))]; ++ } ++ ++ errors { ++ #[cfg(not(test))] ++ AnError { ++ ++ } ++ } ++ } ++} ++ ++#[test] ++fn with_result() { ++ error_chain! { ++ types { ++ Error, ErrorKind, ResultExt, Result; ++ } ++ } ++ let _: Result<()> = Ok(()); ++} ++ ++#[test] ++fn without_result() { ++ error_chain! { ++ types { ++ Error, ErrorKind, ResultExt; ++ } ++ } ++ let _: Result<(), ()> = Ok(()); ++} ++ ++#[test] ++fn documentation() { ++ mod inner { ++ error_chain!{} ++ } ++ ++ error_chain! { ++ links { ++ Inner(inner::Error, inner::ErrorKind) #[doc = "Doc"]; ++ } ++ foreign_links { ++ Io(::std::io::Error) #[doc = "Doc"]; ++ } ++ errors { ++ /// Doc ++ Variant ++ } ++ } ++} ++ ++#[cfg(test)] ++mod multiple_error_same_mod { ++ error_chain! { ++ types { ++ MyError, MyErrorKind, MyResultExt, MyResult; ++ } ++ } ++ error_chain!{} ++} ++ ++#[doc(test)] ++#[deny(dead_code)] ++mod allow_dead_code { ++ error_chain!{} ++} ++ ++// Make sure links actually work! ++#[test] ++fn rustup_regression() { ++ error_chain! { ++ links { ++ Download(error_chain::mock::Error, error_chain::mock::ErrorKind); ++ } ++ ++ foreign_links { } ++ ++ errors { ++ LocatingWorkingDir { ++ description("could not locate working directory") ++ } ++ } ++ } ++} ++ ++#[test] ++fn error_patterns() { ++ error_chain! { ++ links { } ++ ++ foreign_links { } ++ ++ errors { } ++ } ++ ++ // Tuples look nice when matching errors ++ match Error::from("Test") { ++ Error(ErrorKind::Msg(_), _) => {}, ++ _ => {}, ++ } ++} ++ ++#[test] ++fn error_first() { ++ error_chain! { ++ errors { ++ LocatingWorkingDir { ++ description("could not locate working directory") ++ } ++ } ++ ++ links { ++ Download(error_chain::mock::Error, error_chain::mock::ErrorKind); ++ } ++ ++ foreign_links { } ++ } ++} ++ ++#[test] ++fn bail() { ++ error_chain! { ++ errors { Foo } ++ } ++ ++ fn foo() -> Result<()> { ++ bail!(ErrorKind::Foo) ++ } ++ ++ fn bar() -> Result<()> { ++ bail!("bar") ++ } ++ ++ fn baz() -> Result<()> { ++ bail!("{}", "baz") ++ } ++} ++ ++#[test] ++fn ensure() { ++ error_chain! { ++ errors { Bar } ++ } ++ ++ fn foo(x: u8) -> Result<()> { ++ ensure!(x == 42, ErrorKind::Bar); ++ Ok(()) ++ } ++ ++ assert!(foo(42).is_ok()); ++ assert!(foo(0).is_err()); ++} ++ ++/// Since the `types` declaration is a list of symbols, check if we ++/// don't change their meaning or order. ++#[test] ++fn types_declarations() { ++ error_chain! { ++ types { ++ MyError, MyErrorKind, MyResultExt, MyResult; ++ } ++ } ++ ++ MyError::from_kind(MyErrorKind::Msg("".into())); ++ ++ let err: Result<(), ::std::io::Error> = Ok(()); ++ MyResultExt::chain_err(err, || "").unwrap(); ++ ++ let _: MyResult<()> = Ok(()); ++} ++ ++#[test] ++/// Calling chain_err over a `Result` containing an error to get a chained error ++/// and constructing a MyError directly, passing it an error should be equivalent. ++fn rewrapping() { ++ ++ use std::env::VarError::{self, NotPresent, NotUnicode}; ++ ++ error_chain! { ++ foreign_links { ++ VarErr(VarError); ++ } ++ ++ types { ++ MyError, MyErrorKind, MyResultExt, MyResult; ++ } ++ } ++ ++ let result_a_from_func: Result = Err(VarError::NotPresent); ++ let result_b_from_func: Result = Err(VarError::NotPresent); ++ ++ let our_error_a = result_a_from_func.map_err(|e| match e { ++ NotPresent => MyError::with_chain(e, "env var wasn't provided"), ++ NotUnicode(_) => MyError::with_chain(e, "env var was bork文字化ã"), ++ }); ++ ++ let our_error_b = result_b_from_func.or_else(|e| match e { ++ NotPresent => Err(e).chain_err(|| "env var wasn't provided"), ++ NotUnicode(_) => Err(e).chain_err(|| "env var was bork文字化ã"), ++ }); ++ ++ assert_eq!(format!("{}", our_error_a.unwrap_err()), ++ format!("{}", our_error_b.unwrap_err())); ++ ++} ++ ++#[test] ++fn comma_in_errors_impl() { ++ error_chain! { ++ links { } ++ ++ foreign_links { } ++ ++ errors { ++ HttpStatus(e: u32) { ++ description("http request returned an unsuccessful status code"), ++ display("http request returned an unsuccessful status code: {}", e) ++ } ++ } ++ }; ++} ++ ++ ++#[test] ++fn trailing_comma_in_errors_impl() { ++ error_chain! { ++ links { } ++ ++ foreign_links { } ++ ++ errors { ++ HttpStatus(e: u32) { ++ description("http request returned an unsuccessful status code"), ++ display("http request returned an unsuccessful status code: {}", e), ++ } ++ } ++ }; ++} diff --cc vendor/filetime-0.1.12/.cargo-checksum.json index 000000000,000000000..913182090 new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"6ab199bf38537c6f38792669e081e0bb278b9b7405bba2642e4e5d15bf732c0e"} diff --cc vendor/filetime-0.1.12/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/.cargo-ok diff --cc vendor/filetime-0.1.12/.travis.yml index 000000000,000000000..ba7721842 new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/.travis.yml @@@ -1,0 -1,0 +1,26 @@@ ++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 test --verbose ++ - cargo doc --no-deps ++after_success: ++ - travis-cargo --only nightly doc-upload ++env: ++ global: ++ secure: "MIaQyJIgy7VUoYHY7KbYtxpN/t+a2eWk8PihYctz+F+1PANgD6KbgbF9JW4ip5MYaehk7UWs++kPkHiAvJFKWo2BnQswc4digTUa9Vc2n8/C0d0Ec2zn1EUXH4fkeaMvIffn8QQUPwuNdE6khifSfG8Y42siqJF4zkuPKwaLrUo=" ++ ++ ++ ++notifications: ++ email: ++ on_success: never ++os: ++ - linux ++ - osx diff --cc vendor/filetime-0.1.12/Cargo.toml index 000000000,000000000..2cb3dd0cc new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/Cargo.toml @@@ -1,0 -1,0 +1,29 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "filetime" ++version = "0.1.12" ++authors = ["Alex Crichton "] ++description = "Platform-agnostic accessors of timestamps in File metadata\n" ++homepage = "https://github.com/alexcrichton/filetime" ++documentation = "http://alexcrichton.com/filetime" ++readme = "README.md" ++keywords = ["timestamp", "mtime"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/filetime" ++[dev-dependencies.tempdir] ++version = "0.3" ++[target."cfg(target_os = \"redox\")".dependencies.redox_syscall] ++version = "0.1" ++[target."cfg(unix)".dependencies.libc] ++version = "0.2" diff --cc vendor/filetime-0.1.12/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/filetime-0.1.12/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/filetime-0.1.12/README.md index 000000000,000000000..0422084e7 new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/README.md @@@ -1,0 -1,0 +1,25 @@@ ++# filetime ++ ++[![Build Status](https://travis-ci.org/alexcrichton/filetime.svg?branch=master)](https://travis-ci.org/alexcrichton/filetime) ++[![Build status](https://ci.appveyor.com/api/projects/status/9tatexq47i3ee13k?svg=true)](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 --cc vendor/filetime-0.1.12/appveyor.yml index 000000000,000000000..4a6104291 new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/appveyor.yml @@@ -1,0 -1,0 +1,17 @@@ ++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 --target %TARGET% diff --cc vendor/filetime-0.1.12/src/lib.rs index 000000000,000000000..dff3a2de9 new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/src/lib.rs @@@ -1,0 -1,0 +1,282 @@@ ++//! 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 your `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()); ++//! ``` ++ ++use std::fmt; ++use std::fs; ++use std::io; ++use std::path::Path; ++ ++#[cfg(all(unix, not(target_os = "redox")))] ++#[path = "unix.rs"] ++mod imp; ++ ++#[cfg(target_os = "redox")] ++#[path = "redox.rs"] ++mod imp; ++ ++#[cfg(target_os = "windows")] ++#[path = "windows.rs"] ++mod imp; ++ ++/// 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 { ++ imp::from_last_modification_time(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 { ++ imp::from_last_access_time(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 { ++ imp::from_creation_time(meta) ++ } ++ ++ /// 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, atime: FileTime, mtime: FileTime) ++ -> io::Result<()> ++ where P: AsRef ++{ ++ imp::set_file_times(p.as_ref(), atime, mtime) ++} ++ ++/// Set the last access and modification times for a file on the filesystem. ++/// This function does not follow symlink. ++/// ++/// This function will set the `atime` and `mtime` metadata fields for a file ++/// on the local filesystem, returning any error encountered. ++pub fn set_symlink_file_times

(p: P, atime: FileTime, mtime: FileTime) ++ -> io::Result<()> ++ where P: AsRef ++{ ++ imp::set_symlink_file_times(p.as_ref(), atime, mtime) ++} ++ ++#[cfg(test)] ++mod tests { ++ extern crate tempdir; ++ ++ use std::io; ++ use std::path::Path; ++ use std::fs::{self, File}; ++ use self::tempdir::TempDir; ++ use super::{FileTime, set_file_times, set_symlink_file_times}; ++ ++ #[cfg(unix)] ++ fn make_symlink(src: P, dst: Q) -> io::Result<()> ++ where P: AsRef, ++ Q: AsRef, ++ { ++ use std::os::unix::fs::symlink; ++ symlink(src, dst) ++ } ++ ++ #[cfg(windows)] ++ fn make_symlink(src: P, dst: Q) -> io::Result<()> ++ where P: AsRef, ++ Q: AsRef, ++ { ++ use std::os::windows::fs::symlink_file; ++ symlink_file(src, dst) ++ } ++ ++ #[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); ++ ++ let spath = td.path().join("bar.txt"); ++ make_symlink(&path, &spath).unwrap(); ++ let metadata = fs::symlink_metadata(&spath).unwrap(); ++ let smtime = FileTime::from_last_modification_time(&metadata); ++ ++ set_file_times(&spath, atime, mtime).unwrap(); ++ ++ let metadata = fs::metadata(&path).unwrap(); ++ let cur_mtime = FileTime::from_last_modification_time(&metadata); ++ assert_eq!(mtime, cur_mtime); ++ ++ let metadata = fs::symlink_metadata(&spath).unwrap(); ++ let cur_mtime = FileTime::from_last_modification_time(&metadata); ++ assert_eq!(smtime, cur_mtime); ++ ++ set_file_times(&spath, atime, new_mtime).unwrap(); ++ ++ let metadata = fs::metadata(&path).unwrap(); ++ let mtime = FileTime::from_last_modification_time(&metadata); ++ assert_eq!(mtime, new_mtime); ++ ++ let metadata = fs::symlink_metadata(&spath).unwrap(); ++ let mtime = FileTime::from_last_modification_time(&metadata); ++ assert_eq!(mtime, smtime); ++ } ++ ++ #[test] ++ fn set_symlink_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_symlink_file_times(&path, atime, mtime).unwrap(); ++ ++ let new_mtime = FileTime::from_seconds_since_1970(10_000, 0); ++ set_symlink_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); ++ ++ let spath = td.path().join("bar.txt"); ++ make_symlink(&path, &spath).unwrap(); ++ ++ let metadata = fs::symlink_metadata(&spath).unwrap(); ++ let smtime = FileTime::from_last_modification_time(&metadata); ++ let satime = FileTime::from_last_access_time(&metadata); ++ set_symlink_file_times(&spath, smtime, satime).unwrap(); ++ ++ let metadata = fs::metadata(&path).unwrap(); ++ let mtime = FileTime::from_last_modification_time(&metadata); ++ assert_eq!(mtime, new_mtime); ++ ++ let new_smtime = FileTime::from_seconds_since_1970(20_000, 0); ++ set_symlink_file_times(&spath, atime, new_smtime).unwrap(); ++ ++ let metadata = fs::metadata(&spath).unwrap(); ++ let mtime = FileTime::from_last_modification_time(&metadata); ++ assert_eq!(mtime, new_mtime); ++ ++ let metadata = fs::symlink_metadata(&spath).unwrap(); ++ let mtime = FileTime::from_last_modification_time(&metadata); ++ assert_eq!(mtime, new_smtime); ++ } ++} diff --cc vendor/filetime-0.1.12/src/redox.rs index 000000000,000000000..d4d16d51e new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/src/redox.rs @@@ -1,0 -1,0 +1,57 @@@ ++extern crate syscall; ++ ++use std::fs; ++use std::io; ++use std::os::unix::prelude::*; ++use std::path::Path; ++ ++use FileTime; ++ ++pub fn set_file_times(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { ++ let fd = syscall::open(p.as_os_str().as_bytes(), 0) ++ .map_err(|err| io::Error::from_raw_os_error(err.errno))?; ++ set_file_times_redox(fd, atime, mtime) ++} ++ ++pub fn set_symlink_file_times(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { ++ let fd = syscall::open(p.as_os_str().as_bytes(), syscall::O_NOFOLLOW) ++ .map_err(|err| io::Error::from_raw_os_error(err.errno))?; ++ set_file_times_redox(fd, atime, mtime) ++} ++ ++fn set_file_times_redox(fd: usize, atime: FileTime, mtime: FileTime) -> io::Result<()> { ++ use self::syscall::TimeSpec; ++ ++ fn to_timespec(ft: &FileTime) -> TimeSpec { ++ TimeSpec { ++ tv_sec: ft.seconds() as i64, ++ tv_nsec: ft.nanoseconds() as i32 ++ } ++ } ++ ++ let times = [to_timespec(&atime), to_timespec(&mtime)]; ++ let res = syscall::futimens(fd, ×); ++ let _ = syscall::close(fd); ++ match res { ++ Ok(_) => Ok(()), ++ Err(err) => Err(io::Error::from_raw_os_error(err.errno)) ++ } ++} ++ ++pub fn from_last_modification_time(meta: &fs::Metadata) -> FileTime { ++ FileTime { ++ seconds: meta.mtime() as u64, ++ nanos: meta.mtime_nsec() as u32, ++ } ++} ++ ++pub fn from_last_access_time(meta: &fs::Metadata) -> FileTime { ++ FileTime { ++ seconds: meta.atime() as u64, ++ nanos: meta.atime_nsec() as u32, ++ } ++} ++ ++pub fn from_creation_time(_meta: &fs::Metadata) -> Option { ++ None ++} diff --cc vendor/filetime-0.1.12/src/unix.rs index 000000000,000000000..41e9ccac1 new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/src/unix.rs @@@ -1,0 -1,0 +1,94 @@@ ++extern crate libc; ++ ++use std::ffi::CString; ++use std::fs; ++use std::io; ++use std::os::unix::prelude::*; ++use std::path::Path; ++ ++use self::libc::{c_int, c_char, timeval, time_t, suseconds_t}; ++ ++use FileTime; ++ ++pub fn set_file_times(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { ++ set_file_times_u(p, atime, mtime, libc::utimes) ++} ++ ++#[cfg(target_os = "android")] ++pub fn set_symlink_file_times(_p: &Path, _atime: FileTime, _mtime: FileTime) -> io::Result<()> { ++ Err(io::Error::new(io::ErrorKind::Other, "not supported on Android")) ++} ++ ++#[cfg(not(target_os = "android"))] ++pub fn set_symlink_file_times(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { ++ set_file_times_u(p, atime, mtime, libc::lutimes) ++} ++ ++fn set_file_times_u(p: &Path, ++ atime: FileTime, ++ mtime: FileTime, ++ utimes: unsafe extern fn(*const c_char, *const timeval) -> c_int) ++ -> io::Result<()> ++{ ++ let times = [to_timeval(&atime), to_timeval(&mtime)]; ++ let p = try!(CString::new(p.as_os_str().as_bytes())); ++ return if unsafe { 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, ++ } ++ } ++} ++ ++pub fn from_last_modification_time(meta: &fs::Metadata) -> FileTime { ++ FileTime { ++ seconds: meta.mtime() as u64, ++ nanos: meta.mtime_nsec() as u32, ++ } ++} ++ ++pub fn from_last_access_time(meta: &fs::Metadata) -> FileTime { ++ FileTime { ++ seconds: meta.atime() as u64, ++ nanos: meta.atime_nsec() as u32, ++ } ++} ++ ++pub fn from_creation_time(meta: &fs::Metadata) -> Option { ++ macro_rules! birthtim { ++ ($(($e:expr, $i:ident)),*) => { ++ #[cfg(any($(target_os = $e),*))] ++ fn imp(meta: &fs::Metadata) -> Option { ++ $( ++ #[cfg(target_os = $e)] ++ use std::os::$i::fs::MetadataExt; ++ )* ++ Some(FileTime { ++ seconds: meta.st_birthtime() as u64, ++ nanos: meta.st_birthtime_nsec() as u32, ++ }) ++ } ++ ++ #[cfg(all($(not(target_os = $e)),*))] ++ fn imp(_meta: &fs::Metadata) -> Option { ++ None ++ } ++ } ++ } ++ ++ birthtim! { ++ ("bitrig", bitrig), ++ ("freebsd", freebsd), ++ ("ios", ios), ++ ("macos", macos), ++ ("openbsd", openbsd) ++ } ++ ++ imp(meta) ++} diff --cc vendor/filetime-0.1.12/src/windows.rs index 000000000,000000000..f3eb2bf44 new file mode 100644 --- /dev/null +++ b/vendor/filetime-0.1.12/src/windows.rs @@@ -1,0 -1,0 +1,87 @@@ ++#![allow(bad_style)] ++ ++use std::fs::{self, OpenOptions}; ++use std::io; ++use std::os::windows::prelude::*; ++use std::path::Path; ++ ++use FileTime; ++ ++pub fn set_file_times(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { ++ set_file_times_w(p, atime, mtime, OpenOptions::new()) ++} ++ ++pub fn set_symlink_file_times(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { ++ use std::os::windows::fs::OpenOptionsExt; ++ const FILE_FLAG_OPEN_REPARSE_POINT: u32 = 0x00200000; ++ ++ let mut options = OpenOptions::new(); ++ options.custom_flags(FILE_FLAG_OPEN_REPARSE_POINT); ++ set_file_times_w(p, atime, mtime, options) ++} ++ ++pub fn set_file_times_w(p: &Path, ++ atime: FileTime, ++ mtime: FileTime, ++ mut options: OpenOptions) -> io::Result<()> { ++ 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!(options.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, ++ } ++ } ++} ++ ++pub fn from_last_modification_time(meta: &fs::Metadata) -> FileTime { ++ from_intervals(meta.last_write_time()) ++} ++ ++pub fn from_last_access_time(meta: &fs::Metadata) -> FileTime { ++ from_intervals(meta.last_access_time()) ++} ++ ++pub fn from_creation_time(meta: &fs::Metadata) -> Option { ++ Some(from_intervals(meta.creation_time())) ++} ++ ++fn from_intervals(ticks: u64) -> FileTime { ++ // Windows write times are in 100ns intervals, so do a little math to ++ // get it into the right representation. ++ FileTime { ++ seconds: ticks / (1_000_000_000 / 100), ++ nanos: ((ticks % (1_000_000_000 / 100)) * 100) as u32, ++ } ++} diff --cc vendor/flate2-0.2.20/.cargo-checksum.json index 000000000,000000000..c1b7327bd new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"e6234dd4468ae5d1e2dbb06fe2b058696fdc50a339c68a393aefbf00bc81e423"} diff --cc vendor/flate2-0.2.20/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/.cargo-ok diff --cc vendor/flate2-0.2.20/.travis.yml index 000000000,000000000..eb722100d new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/.travis.yml @@@ -1,0 -1,0 +1,32 @@@ ++language: rust ++rust: ++ - stable ++ - beta ++ - nightly ++sudo: false ++before_script: ++ - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH ++script: ++ - export CARGO_TARGET_DIR=`pwd`/target ++ - cargo build --verbose ++ - rustdoc --test README.md -L target/debug/deps --extern flate2=target/debug/libflate2.rlib ++ - cargo test --verbose ++ - cargo test --verbose --features zlib ++ - cargo test --verbose --features tokio ++ - cargo test --verbose --features 'tokio zlib' ++ - cargo test --verbose --features zlib --no-default-features ++ - cargo clean && cargo build ++ - cargo doc --no-deps ++ - cargo doc --no-deps --manifest-path=miniz-sys/Cargo.toml ++after_success: ++ - travis-cargo --only nightly doc-upload ++env: ++ global: ++ secure: "PHVT7IaeP5nQQVwGHKwqCYBDp0QyetSlER7se2j2Xgfx+lw3Bu6VWH6VF04B636Gb0tHPN/sUCXSgGRcvDuy6XFOev4LfynoYxNKgHJYg2E34EP2QLwsFfnvE4iujaG3GJk3o935Y7OYGv2OP1HeG4Mv6JhQK0GLnNDBZQ65kWI=" ++ ++notifications: ++ email: ++ on_success: never ++os: ++ - linux ++ - osx diff --cc vendor/flate2-0.2.20/Cargo.toml index 000000000,000000000..d1d100bb6 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/Cargo.toml @@@ -1,0 -1,0 +1,61 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "flate2" ++version = "0.2.20" ++authors = ["Alex Crichton "] ++description = "Bindings to miniz.c for DEFLATE compression and decompression exposed as\nReader/Writer streams. Contains bindings for zlib, deflate, and gzip-based\nstreams.\n" ++homepage = "https://github.com/alexcrichton/flate2-rs" ++documentation = "https://docs.rs/flate2" ++readme = "README.md" ++keywords = ["gzip", "flate", "zlib", "encoding"] ++categories = ["compression", "api-bindings"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/flate2-rs" ++[dependencies.libc] ++version = "0.2" ++ ++[dependencies.libz-sys] ++version = "1.0" ++optional = true ++ ++[dependencies.miniz-sys] ++version = "0.1.7" ++optional = true ++ ++[dependencies.futures] ++version = "0.1" ++optional = true ++ ++[dependencies.tokio-io] ++version = "0.1" ++optional = true ++[dev-dependencies.rand] ++version = "0.3" ++ ++[dev-dependencies.quickcheck] ++version = "0.4" ++default-features = false ++ ++[dev-dependencies.tokio-core] ++version = "0.1" ++ ++[features] ++default = ["miniz-sys"] ++zlib = ["libz-sys"] ++tokio = ["tokio-io", "futures"] ++[badges.travis-ci] ++repository = "alexcrichton/flate2-rs" ++ ++[badges.appveyor] ++repository = "alexcrichton/flate2-rs" diff --cc vendor/flate2-0.2.20/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/flate2-0.2.20/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/flate2-0.2.20/README.md index 000000000,000000000..c8937912f new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/README.md @@@ -1,0 -1,0 +1,70 @@@ ++# flate2 ++ ++[![Build Status](https://travis-ci.org/alexcrichton/flate2-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/flate2-rs) ++[![Build status](https://ci.appveyor.com/api/projects/status/9tatexq47i3ee13k?svg=true)](https://ci.appveyor.com/project/alexcrichton/flate2-rs) ++[![Crates.io](https://img.shields.io/crates/v/flate2.svg?maxAge=2592000)](https://crates.io/crates/flate2) ++[![Documentation](https://docs.rs/flate2/badge.svg)](https://docs.rs/flate2) ++ ++A streaming compression/decompression library for Rust. The underlying ++implementation by default uses [`miniz`](https://code.google.com/p/miniz/) but ++can optionally be configured to use the system zlib, if available. ++ ++Supported formats: ++ ++* deflate ++* zlib ++* gzip ++ ++```toml ++# Cargo.toml ++[dependencies] ++flate2 = "0.2" ++``` ++ ++Using zlib instead of miniz: ++ ++```toml ++[dependencies] ++flate2 = { version = "0.2", features = ["zlib"], default-features = false } ++``` ++ ++## Compression ++ ++```rust ++extern crate flate2; ++ ++use std::io::prelude::*; ++use flate2::Compression; ++use flate2::write::ZlibEncoder; ++ ++fn main() { ++ let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"foo"); ++ e.write(b"bar"); ++ let compressed_bytes = e.finish(); ++} ++``` ++ ++## Decompression ++ ++```rust,no_run ++extern crate flate2; ++ ++use std::io::prelude::*; ++use flate2::read::GzDecoder; ++ ++fn main() { ++ let mut d = GzDecoder::new("...".as_bytes()).unwrap(); ++ let mut s = String::new(); ++ d.read_to_string(&mut s).unwrap(); ++ println!("{}", s); ++} ++``` ++ ++# License ++ ++`flate2-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 --cc vendor/flate2-0.2.20/appveyor.yml index 000000000,000000000..0a140f7bc new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/appveyor.yml @@@ -1,0 -1,0 +1,24 @@@ ++environment: ++ matrix: ++ - TARGET: x86_64-pc-windows-msvc ++ - TARGET: x86_64-pc-windows-gnu ++ - TARGET: i686-pc-windows-msvc ++ - TARGET: i686-pc-windows-gnu ++install: ++ - ps: >- ++ If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') { ++ $Env:PATH += ';C:\msys64\mingw64\bin' ++ } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') { ++ $Env:PATH += ';C:\MinGW\bin' ++ } ++ - 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 ++ - rustc -V ++ - cargo -V ++ ++build: false ++ ++test_script: ++ - cargo test --verbose --target %TARGET% ++ - cargo test --verbose --target %TARGET% --features tokio diff --cc vendor/flate2-0.2.20/examples/deflatedecoder-bufread.rs index 000000000,000000000..117297feb new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/deflatedecoder-bufread.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::write::DeflateEncoder; ++use flate2::bufread::DeflateDecoder; ++ ++// Compress a sample string and print it after transformation. ++fn main() { ++ let mut e = DeflateEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ let bytes = e.finish().unwrap(); ++ println!("{}", decode_reader(bytes).unwrap()); ++} ++ ++// Uncompresses a Deflate Encoded vector of bytes and returns a string or error ++// Here &[u8] implements Read ++fn decode_reader(bytes: Vec) -> io::Result { ++ let mut deflater = DeflateDecoder::new(&bytes[..]); ++ let mut s = String::new(); ++ deflater.read_to_string(&mut s)?; ++ Ok(s) ++} diff --cc vendor/flate2-0.2.20/examples/deflatedecoder-read.rs index 000000000,000000000..2d2685780 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/deflatedecoder-read.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::write::DeflateEncoder; ++use flate2::read::DeflateDecoder; ++ ++// Compress a sample string and print it after transformation. ++fn main() { ++ let mut e = DeflateEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ let bytes = e.finish().unwrap(); ++ println!("{}", decode_reader(bytes).unwrap()); ++} ++ ++// Uncompresses a Deflate Encoded vector of bytes and returns a string or error ++// Here &[u8] implements Read ++fn decode_reader(bytes: Vec) -> io::Result { ++ let mut deflater = DeflateDecoder::new(&bytes[..]); ++ let mut s = String::new(); ++ deflater.read_to_string(&mut s)?; ++ Ok(s) ++} diff --cc vendor/flate2-0.2.20/examples/deflatedecoder-write.rs index 000000000,000000000..46791e623 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/deflatedecoder-write.rs @@@ -1,0 -1,0 +1,26 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::write::DeflateEncoder; ++use flate2::write::DeflateDecoder; ++ ++// Compress a sample string and print it after transformation. ++fn main() { ++ let mut e = DeflateEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ let bytes = e.finish().unwrap(); ++ println!("{}", decode_reader(bytes).unwrap()); ++} ++ ++// Uncompresses a Deflate Encoded vector of bytes and returns a string or error ++// Here Vec implements Write ++fn decode_reader(bytes: Vec) -> io::Result { ++ let mut writer = Vec::new(); ++ let mut deflater = DeflateDecoder::new(writer); ++ deflater.write(&bytes[..])?; ++ writer = deflater.finish()?; ++ let return_string = String::from_utf8(writer).expect("String parsing error"); ++ Ok(return_string) ++} diff --cc vendor/flate2-0.2.20/examples/deflateencoder-bufread.rs index 000000000,000000000..4ec2ed1c7 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/deflateencoder-bufread.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::bufread::DeflateEncoder; ++use std::fs::File; ++use std::io::BufReader; ++ ++// Open file and debug print the contents compressed with Deflate ++fn main() { ++ println!("{:?}", open_hello_world().unwrap()); ++} ++ ++// Opens sample file, compresses the contents and returns a Vector or error ++// File wrapped in a BufReader implements Bufread ++fn open_hello_world() -> io::Result> { ++ let f = File::open("examples/hello_world.txt")?; ++ let b = BufReader::new(f); ++ let mut deflater = DeflateEncoder::new(b, Compression::Fast); ++ let mut buffer = Vec::new(); ++ deflater.read_to_end(&mut buffer)?; ++ Ok(buffer) ++} diff --cc vendor/flate2-0.2.20/examples/deflateencoder-read.rs index 000000000,000000000..bf1bcc6a6 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/deflateencoder-read.rs @@@ -1,0 -1,0 +1,20 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::read::DeflateEncoder; ++ ++// Print the Deflate compressed representation of hello world ++fn main() { ++ println!("{:?}", deflateencoder_read_hello_world().unwrap()); ++} ++ ++// Return a vector containing the Defalte compressed version of hello world ++fn deflateencoder_read_hello_world() -> io::Result> { ++ let mut ret_vec = [0;100]; ++ let c = b"hello world"; ++ let mut deflater = DeflateEncoder::new(&c[..], Compression::Fast); ++ let count = deflater.read(&mut ret_vec)?; ++ Ok(ret_vec[0..count].to_vec()) ++} diff --cc vendor/flate2-0.2.20/examples/deflateencoder-write.rs index 000000000,000000000..f511aec4b new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/deflateencoder-write.rs @@@ -1,0 -1,0 +1,12 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use flate2::Compression; ++use flate2::write::DeflateEncoder; ++ ++// Vec implements Write to print the compressed bytes of sample string ++fn main() { ++ let mut e = DeflateEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ println!("{:?}", e.finish().unwrap()); ++} diff --cc vendor/flate2-0.2.20/examples/flatereadext.rs index 000000000,000000000..a3a9b0444 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/flatereadext.rs @@@ -1,0 -1,0 +1,22 @@@ ++extern crate flate2; ++ ++use flate2::{FlateReadExt, Compression}; ++use std::io::prelude::*; ++use std::io; ++use std::fs::File; ++ ++fn main() { ++ println!("{}", run().unwrap()); ++} ++ ++fn run() -> io::Result { ++ let f = File::open("examples/hello_world.txt")?; ++ ++ //gz_encode method comes from FlateReadExt and applies to a std::fs::File ++ let data = f.gz_encode(Compression::Default); ++ let mut buffer = String::new(); ++ ++ //gz_decode method comes from FlateReadExt and applies to a &[u8] ++ &data.gz_decode()?.read_to_string(&mut buffer)?; ++ Ok(buffer) ++} diff --cc vendor/flate2-0.2.20/examples/gzbuilder.rs index 000000000,000000000..a61a03f4f new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/gzbuilder.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use std::fs::File; ++use flate2::GzBuilder; ++use flate2::Compression; ++ ++// Open file and debug print the contents compressed with gzip ++fn main() { ++ sample_builder().unwrap(); ++} ++ ++// GzBuilder opens a file and writes a sample string using Builder pattern ++fn sample_builder() -> Result<(), io::Error> { ++ let f = File::create("examples/hello_world.gz")?; ++ let mut gz = GzBuilder::new() ++ .filename("hello_world.txt") ++ .comment("test file, please delete") ++ .write(f, Compression::Default); ++ gz.write(b"hello world")?; ++ gz.finish()?; ++ Ok(()) ++} diff --cc vendor/flate2-0.2.20/examples/gzdecoder-bufread.rs index 000000000,000000000..77f325194 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/gzdecoder-bufread.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::write::GzEncoder; ++use flate2::bufread::GzDecoder; ++ ++// Compress a sample string and print it after transformation. ++fn main() { ++ let mut e = GzEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ let bytes = e.finish().unwrap(); ++ println!("{}", decode_reader(bytes).unwrap()); ++} ++ ++// Uncompresses a Gz Encoded vector of bytes and returns a string or error ++// Here &[u8] implements BufRead ++fn decode_reader(bytes: Vec) -> io::Result { ++ let mut gz = GzDecoder::new(&bytes[..])?; ++ let mut s = String::new(); ++ gz.read_to_string(&mut s)?; ++ Ok(s) ++} diff --cc vendor/flate2-0.2.20/examples/gzdecoder-read.rs index 000000000,000000000..843d7bd6a new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/gzdecoder-read.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::write::GzEncoder; ++use flate2::read::GzDecoder; ++ ++// Compress a sample string and print it after transformation. ++fn main() { ++ let mut e = GzEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ let bytes = e.finish().unwrap(); ++ println!("{}", decode_reader(bytes).unwrap()); ++} ++ ++// Uncompresses a Gz Encoded vector of bytes and returns a string or error ++// Here &[u8] implements Read ++fn decode_reader(bytes: Vec) -> io::Result { ++ let mut gz = GzDecoder::new(&bytes[..])?; ++ let mut s = String::new(); ++ gz.read_to_string(&mut s)?; ++ Ok(s) ++} diff --cc vendor/flate2-0.2.20/examples/gzencoder-bufread.rs index 000000000,000000000..8b320d813 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/gzencoder-bufread.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::bufread::GzEncoder; ++use std::fs::File; ++use std::io::BufReader; ++ ++// Open file and debug print the contents compressed with gzip ++fn main() { ++ println!("{:?}", open_hello_world().unwrap()); ++} ++ ++// Opens sample file, compresses the contents and returns a Vector or error ++// File wrapped in a BufReader implements Bufread ++fn open_hello_world() -> io::Result> { ++ let f = File::open("examples/hello_world.txt")?; ++ let b = BufReader::new(f); ++ let mut gz = GzEncoder::new(b, Compression::Fast); ++ let mut buffer = Vec::new(); ++ gz.read_to_end(&mut buffer)?; ++ Ok(buffer) ++} diff --cc vendor/flate2-0.2.20/examples/gzencoder-read.rs index 000000000,000000000..65dd26bc4 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/gzencoder-read.rs @@@ -1,0 -1,0 +1,20 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::read::GzEncoder; ++ ++// Print the GZ compressed representation of hello world ++fn main() { ++ println!("{:?}", gzencoder_read_hello_world().unwrap()); ++} ++ ++// Return a vector containing the GZ compressed version of hello world ++fn gzencoder_read_hello_world() -> io::Result> { ++ let mut ret_vec = [0;100]; ++ let c = b"hello world"; ++ let mut z = GzEncoder::new(&c[..], Compression::Fast); ++ let count = z.read(&mut ret_vec)?; ++ Ok(ret_vec[0..count].to_vec()) ++} diff --cc vendor/flate2-0.2.20/examples/gzencoder-write.rs index 000000000,000000000..b423b5241 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/gzencoder-write.rs @@@ -1,0 -1,0 +1,12 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use flate2::Compression; ++use flate2::write::GzEncoder; ++ ++// Vec implements Write to print the compressed bytes of sample string ++fn main() { ++ let mut e = GzEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ println!("{:?}", e.finish().unwrap()); ++} diff --cc vendor/flate2-0.2.20/examples/gzmultidecoder-bufread.rs index 000000000,000000000..d5db3673e new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/gzmultidecoder-bufread.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::write::GzEncoder; ++use flate2::bufread::MultiGzDecoder; ++ ++// Compress a sample string and print it after transformation. ++fn main() { ++ let mut e = GzEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ let bytes = e.finish().unwrap(); ++ println!("{}", decode_reader(bytes).unwrap()); ++} ++ ++// Uncompresses a Gz Encoded vector of bytes and returns a string or error ++// Here &[u8] implements BufRead ++fn decode_reader(bytes: Vec) -> io::Result { ++ let mut gz = MultiGzDecoder::new(&bytes[..])?; ++ let mut s = String::new(); ++ gz.read_to_string(&mut s)?; ++ Ok(s) ++} diff --cc vendor/flate2-0.2.20/examples/gzmultidecoder-read.rs index 000000000,000000000..9263292c9 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/gzmultidecoder-read.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::write::GzEncoder; ++use flate2::read::MultiGzDecoder; ++ ++// Compress a sample string and print it after transformation. ++fn main() { ++ let mut e = GzEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ let bytes = e.finish().unwrap(); ++ println!("{}", decode_reader(bytes).unwrap()); ++} ++ ++// Uncompresses a Gz Encoded vector of bytes and returns a string or error ++// Here &[u8] implements Read ++fn decode_reader(bytes: Vec) -> io::Result { ++ let mut gz = MultiGzDecoder::new(&bytes[..])?; ++ let mut s = String::new(); ++ gz.read_to_string(&mut s)?; ++ Ok(s) ++} diff --cc vendor/flate2-0.2.20/examples/hello_world.txt index 000000000,000000000..557db03de new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/hello_world.txt @@@ -1,0 -1,0 +1,1 @@@ ++Hello World diff --cc vendor/flate2-0.2.20/examples/zlibdecoder-bufread.rs index 000000000,000000000..7216f801e new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/zlibdecoder-bufread.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::write::ZlibEncoder; ++use flate2::bufread::ZlibDecoder; ++ ++// Compress a sample string and print it after transformation. ++fn main() { ++ let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ let bytes = e.finish().unwrap(); ++ println!("{}", decode_bufreader(bytes).unwrap()); ++} ++ ++// Uncompresses a Zlib Encoded vector of bytes and returns a string or error ++// Here &[u8] implements BufRead ++fn decode_bufreader(bytes: Vec) -> io::Result { ++ let mut z = ZlibDecoder::new(&bytes[..]); ++ let mut s = String::new(); ++ z.read_to_string(&mut s)?; ++ Ok(s) ++} diff --cc vendor/flate2-0.2.20/examples/zlibdecoder-read.rs index 000000000,000000000..ab82413fb new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/zlibdecoder-read.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::write::ZlibEncoder; ++use flate2::read::ZlibDecoder; ++ ++// Compress a sample string and print it after transformation. ++fn main() { ++ let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ let bytes = e.finish().unwrap(); ++ println!("{}", decode_reader(bytes).unwrap()); ++} ++ ++// Uncompresses a Zlib Encoded vector of bytes and returns a string or error ++// Here &[u8] implements Read ++fn decode_reader(bytes: Vec) -> io::Result { ++ let mut z = ZlibDecoder::new(&bytes[..]); ++ let mut s = String::new(); ++ z.read_to_string(&mut s)?; ++ Ok(s) ++} diff --cc vendor/flate2-0.2.20/examples/zlibdecoder-write.rs index 000000000,000000000..c70ded3c1 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/zlibdecoder-write.rs @@@ -1,0 -1,0 +1,26 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::write::ZlibEncoder; ++use flate2::write::ZlibDecoder; ++ ++// Compress a sample string and print it after transformation. ++fn main() { ++ let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ let bytes = e.finish().unwrap(); ++ println!("{}", decode_reader(bytes).unwrap()); ++} ++ ++// Uncompresses a Zlib Encoded vector of bytes and returns a string or error ++// Here Vec implements Write ++fn decode_reader(bytes: Vec) -> io::Result { ++ let mut writer = Vec::new(); ++ let mut z = ZlibDecoder::new(writer); ++ z.write(&bytes[..])?; ++ writer = z.finish()?; ++ let return_string = String::from_utf8(writer).expect("String parsing error"); ++ Ok(return_string) ++} diff --cc vendor/flate2-0.2.20/examples/zlibencoder-bufread.rs index 000000000,000000000..39d93611a new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/zlibencoder-bufread.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use std::io; ++use flate2::Compression; ++use flate2::bufread::ZlibEncoder; ++use std::fs::File; ++use std::io::BufReader; ++ ++// Open file and debug print the contents compressed with zlib ++fn main() { ++ println!("{:?}", open_hello_world().unwrap()); ++} ++ ++// Opens sample file, compresses the contents and returns a Vector or error ++// File wrapped in a BufReader implements Bufread ++fn open_hello_world() -> io::Result> { ++ let f = File::open("examples/hello_world.txt")?; ++ let b = BufReader::new(f); ++ let mut z = ZlibEncoder::new(b, Compression::Fast); ++ let mut buffer = Vec::new(); ++ z.read_to_end(&mut buffer)?; ++ Ok(buffer) ++} diff --cc vendor/flate2-0.2.20/examples/zlibencoder-read.rs index 000000000,000000000..3aef92ca4 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/zlibencoder-read.rs @@@ -1,0 -1,0 +1,21 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use flate2::Compression; ++use flate2::read::ZlibEncoder; ++use std::fs::File; ++ ++// Open file and debug print the compressed contents ++fn main() { ++ println!("{:?}", open_hello_world().unwrap()); ++} ++ ++// Opens sample file, compresses the contents and returns a Vector or error ++// File implements Read ++fn open_hello_world() -> std::io::Result> { ++ let f = File::open("examples/hello_world.txt")?; ++ let mut z = ZlibEncoder::new(f, Compression::Fast); ++ let mut buffer = [0;50]; ++ let byte_count = z.read(&mut buffer)?; ++ Ok(buffer[0..byte_count].to_vec()) ++} diff --cc vendor/flate2-0.2.20/examples/zlibencoder-write.rs index 000000000,000000000..9152b30ea new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/examples/zlibencoder-write.rs @@@ -1,0 -1,0 +1,12 @@@ ++extern crate flate2; ++ ++use std::io::prelude::*; ++use flate2::Compression; ++use flate2::write::ZlibEncoder; ++ ++// Vec implements Write to print the compressed bytes of sample string ++fn main() { ++ let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); ++ e.write(b"Hello World").unwrap(); ++ println!("{:?}", e.finish().unwrap()); ++} diff --cc vendor/flate2-0.2.20/src/bufreader.rs index 000000000,000000000..a4bd8c796 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/bufreader.rs @@@ -1,0 -1,0 +1,98 @@@ ++// Copyright 2013 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::cmp; ++use std::io; ++use std::io::prelude::*; ++use std::mem; ++ ++pub struct BufReader { ++ inner: R, ++ buf: Box<[u8]>, ++ pos: usize, ++ cap: usize, ++} ++ ++impl ::std::fmt::Debug for BufReader where R: ::std::fmt::Debug { ++ fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error>{ ++ fmt.debug_struct("BufReader") ++ .field("reader", &self.inner) ++ .field("buffer", &format_args!("{}/{}", self.cap - self.pos, self.buf.len())) ++ .finish() ++ } ++} ++ ++impl BufReader { ++ pub fn new(inner: R) -> BufReader { ++ BufReader::with_buf(vec![0; 32 * 1024], inner) ++ } ++ ++ pub fn with_buf(buf: Vec, inner: R) -> BufReader { ++ BufReader { ++ inner: inner, ++ buf: buf.into_boxed_slice(), ++ pos: 0, ++ cap: 0, ++ } ++ } ++} ++ ++impl BufReader { ++ pub fn get_ref(&self) -> &R { ++ &self.inner ++ } ++ ++ pub fn get_mut(&mut self) -> &mut R { ++ &mut self.inner ++ } ++ ++ pub fn into_inner(self) -> R { ++ self.inner ++ } ++ ++ pub fn reset(&mut self, inner: R) -> R { ++ self.pos = 0; ++ self.cap = 0; ++ mem::replace(&mut self.inner, inner) ++ } ++} ++ ++impl Read for BufReader { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ // If we don't have any buffered data and we're doing a massive read ++ // (larger than our internal buffer), bypass our internal buffer ++ // entirely. ++ if self.pos == self.cap && buf.len() >= self.buf.len() { ++ return self.inner.read(buf); ++ } ++ let nread = { ++ let mut rem = try!(self.fill_buf()); ++ try!(rem.read(buf)) ++ }; ++ self.consume(nread); ++ Ok(nread) ++ } ++} ++ ++impl BufRead for BufReader { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { ++ // If we've reached the end of our internal buffer then we need to fetch ++ // some more data from the underlying reader. ++ if self.pos == self.cap { ++ self.cap = try!(self.inner.read(&mut self.buf)); ++ self.pos = 0; ++ } ++ Ok(&self.buf[self.pos..self.cap]) ++ } ++ ++ fn consume(&mut self, amt: usize) { ++ self.pos = cmp::min(self.pos + amt, self.cap); ++ } ++} diff --cc vendor/flate2-0.2.20/src/crc.rs index 000000000,000000000..c6e93ac1f new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/crc.rs @@@ -1,0 -1,0 +1,124 @@@ ++//! Simple CRC bindings backed by miniz.c ++ ++use std::io::prelude::*; ++use std::io; ++use libc; ++ ++use ffi; ++ ++/// The CRC calculated by a [`CrcReader`]. ++/// ++/// [`CrcReader`]: struct.CrcReader.html ++#[derive(Debug)] ++pub struct Crc { ++ crc: libc::c_ulong, ++ amt: u32, ++} ++ ++/// A wrapper around a [`Read`] that calculates the CRC. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++#[derive(Debug)] ++pub struct CrcReader { ++ inner: R, ++ crc: Crc, ++} ++ ++impl Crc { ++ /// Create a new CRC. ++ pub fn new() -> Crc { ++ Crc { crc: 0, amt: 0 } ++ } ++ ++ /// bla ++ pub fn sum(&self) -> u32 { ++ self.crc as u32 ++ } ++ ++ /// The number of bytes that have been used to calculate the CRC. ++ /// This value is only accurate if the amount is lower than 2^32. ++ pub fn amount(&self) -> u32 { ++ self.amt ++ } ++ ++ /// Update the CRC with the bytes in `data`. ++ pub fn update(&mut self, data: &[u8]) { ++ self.amt = self.amt.wrapping_add(data.len() as u32); ++ self.crc = unsafe { ++ ffi::mz_crc32(self.crc, data.as_ptr(), data.len() as libc::size_t) ++ }; ++ } ++ ++ /// Reset the CRC. ++ pub fn reset(&mut self) { ++ self.crc = 0; ++ self.amt = 0; ++ } ++ ++ /// Combine the CRC with the CRC for the subsequent block of bytes. ++ pub fn combine(&mut self, additional_crc: &Crc) { ++ self.crc = unsafe { ++ ffi::mz_crc32_combine(self.crc as ::libc::c_ulong, ++ additional_crc.crc as ::libc::c_ulong, ++ additional_crc.amt as ::libc::off_t) ++ }; ++ self.amt += additional_crc.amt; ++ } ++} ++ ++impl CrcReader { ++ /// Create a new CrcReader. ++ pub fn new(r: R) -> CrcReader { ++ CrcReader { ++ inner: r, ++ crc: Crc::new(), ++ } ++ } ++} ++ ++impl CrcReader { ++ /// Get the Crc for this CrcReader. ++ pub fn crc(&self) -> &Crc { ++ &self.crc ++ } ++ ++ /// Get the reader that is wrapped by this CrcReader. ++ pub fn into_inner(self) -> R { ++ self.inner ++ } ++ ++ /// Get the reader that is wrapped by this CrcReader by reference. ++ pub fn get_ref(&self) -> &R { ++ &self.inner ++ } ++ ++ /// Get a mutable reference to the reader that is wrapped by this CrcReader. ++ pub fn get_mut(&mut self) -> &mut R { ++ &mut self.inner ++ } ++ ++ /// Reset the Crc in this CrcReader. ++ pub fn reset(&mut self) { ++ self.crc.reset(); ++ } ++} ++ ++impl Read for CrcReader { ++ fn read(&mut self, into: &mut [u8]) -> io::Result { ++ let amt = try!(self.inner.read(into)); ++ self.crc.update(&into[..amt]); ++ Ok(amt) ++ } ++} ++ ++impl BufRead for CrcReader { ++ fn fill_buf(&mut self) -> io::Result<&[u8]> { ++ self.inner.fill_buf() ++ } ++ fn consume(&mut self, amt: usize) { ++ if let Ok(data) = self.inner.fill_buf() { ++ self.crc.update(&data[..amt]); ++ } ++ self.inner.consume(amt); ++ } ++} diff --cc vendor/flate2-0.2.20/src/deflate/bufread.rs index 000000000,000000000..9a9a47ec6 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/deflate/bufread.rs @@@ -1,0 -1,0 +1,269 @@@ ++use std::io::prelude::*; ++use std::io; ++use std::mem; ++ ++#[cfg(feature = "tokio")] ++use futures::Poll; ++#[cfg(feature = "tokio")] ++use tokio_io::{AsyncRead, AsyncWrite}; ++ ++use zio; ++use {Compress, Decompress}; ++ ++/// A DEFLATE encoder, or compressor. ++/// ++/// This structure implements a [`BufRead`] interface and will read uncompressed ++/// data from an underlying stream and emit a stream of compressed data. ++/// ++/// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// use flate2::Compression; ++/// use flate2::bufread::DeflateEncoder; ++/// use std::fs::File; ++/// use std::io::BufReader; ++/// ++/// # fn main() { ++/// # println!("{:?}", open_hello_world().unwrap()); ++/// # } ++/// # ++/// // Opens sample file, compresses the contents and returns a Vector ++/// fn open_hello_world() -> io::Result> { ++/// let f = File::open("examples/hello_world.txt")?; ++/// let b = BufReader::new(f); ++/// let mut deflater = DeflateEncoder::new(b, Compression::Fast); ++/// let mut buffer = Vec::new(); ++/// deflater.read_to_end(&mut buffer)?; ++/// Ok(buffer) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct DeflateEncoder { ++ obj: R, ++ data: Compress, ++} ++ ++ ++impl DeflateEncoder { ++ /// Creates a new encoder which will read uncompressed data from the given ++ /// stream and emit the compressed stream. ++ pub fn new(r: R, level: ::Compression) -> DeflateEncoder { ++ DeflateEncoder { ++ obj: r, ++ data: Compress::new(level, false), ++ } ++ } ++} ++ ++pub fn reset_encoder_data(zlib: &mut DeflateEncoder) { ++ zlib.data.reset(); ++} ++ ++impl DeflateEncoder { ++ /// Resets the state of this encoder entirely, swapping out the input ++ /// stream for another. ++ /// ++ /// This function will reset the internal state of this encoder and replace ++ /// the input stream with the one provided, returning the previous input ++ /// stream. Future data read from this encoder will be the compressed ++ /// version of `r`'s data. ++ pub fn reset(&mut self, r: R) -> R { ++ reset_encoder_data(self); ++ mem::replace(&mut self.obj, r) ++ } ++ ++ /// Acquires a reference to the underlying reader ++ pub fn get_ref(&self) -> &R { ++ &self.obj ++ } ++ ++ /// Acquires a mutable reference to the underlying stream ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ &mut self.obj ++ } ++ ++ /// Consumes this encoder, returning the underlying reader. ++ pub fn into_inner(self) -> R { ++ self.obj ++ } ++ ++ /// Returns the number of bytes that have been read into this compressor. ++ /// ++ /// Note that not all bytes read from the underlying object may be accounted ++ /// for, there may still be some active buffering. ++ pub fn total_in(&self) -> u64 { ++ self.data.total_in() ++ } ++ ++ /// Returns the number of bytes that the compressor has produced. ++ /// ++ /// Note that not all bytes may have been read yet, some may still be ++ /// buffered. ++ pub fn total_out(&self) -> u64 { ++ self.data.total_out() ++ } ++} ++ ++impl Read for DeflateEncoder { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ zio::read(&mut self.obj, &mut self.data, buf) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for DeflateEncoder {} ++ ++impl Write for DeflateEncoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for DeflateEncoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ self.get_mut().shutdown() ++ } ++} ++ ++/// A DEFLATE decoder, or decompressor. ++/// ++/// This structure implements a [`BufRead`] interface and takes a stream of ++/// compressed data as input, providing the decompressed data when read from. ++/// ++/// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// # use flate2::Compression; ++/// # use flate2::write::DeflateEncoder; ++/// use flate2::bufread::DeflateDecoder; ++/// ++/// # fn main() { ++/// # let mut e = DeflateEncoder::new(Vec::new(), Compression::Default); ++/// # e.write(b"Hello World").unwrap(); ++/// # let bytes = e.finish().unwrap(); ++/// # println!("{}", decode_reader(bytes).unwrap()); ++/// # } ++/// // Uncompresses a Deflate Encoded vector of bytes and returns a string or error ++/// // Here &[u8] implements Read ++/// fn decode_reader(bytes: Vec) -> io::Result { ++/// let mut deflater = DeflateDecoder::new(&bytes[..]); ++/// let mut s = String::new(); ++/// deflater.read_to_string(&mut s)?; ++/// Ok(s) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct DeflateDecoder { ++ obj: R, ++ data: Decompress, ++} ++ ++pub fn reset_decoder_data(zlib: &mut DeflateDecoder) { ++ zlib.data = Decompress::new(false); ++} ++ ++impl DeflateDecoder { ++ /// Creates a new decoder which will decompress data read from the given ++ /// stream. ++ pub fn new(r: R) -> DeflateDecoder { ++ DeflateDecoder { ++ obj: r, ++ data: Decompress::new(false), ++ } ++ } ++} ++ ++impl DeflateDecoder { ++ /// Resets the state of this decoder entirely, swapping out the input ++ /// stream for another. ++ /// ++ /// This will reset the internal state of this decoder and replace the ++ /// input stream with the one provided, returning the previous input ++ /// stream. Future data read from this decoder will be the decompressed ++ /// version of `r`'s data. ++ pub fn reset(&mut self, r: R) -> R { ++ reset_decoder_data(self); ++ mem::replace(&mut self.obj, r) ++ } ++ ++ /// Resets the state of this decoder's data ++ /// ++ /// This will reset the internal state of this decoder. It will continue ++ /// reading from the same stream. ++ pub fn reset_data(&mut self) { ++ reset_decoder_data(self); ++ } ++ ++ /// Acquires a reference to the underlying stream ++ pub fn get_ref(&self) -> &R { ++ &self.obj ++ } ++ ++ /// Acquires a mutable reference to the underlying stream ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ &mut self.obj ++ } ++ ++ /// Consumes this decoder, returning the underlying reader. ++ pub fn into_inner(self) -> R { ++ self.obj ++ } ++ ++ /// Returns the number of bytes that the decompressor has consumed. ++ /// ++ /// Note that this will likely be smaller than what the decompressor ++ /// actually read from the underlying stream due to buffering. ++ pub fn total_in(&self) -> u64 { ++ self.data.total_in() ++ } ++ ++ /// Returns the number of bytes that the decompressor has produced. ++ pub fn total_out(&self) -> u64 { ++ self.data.total_out() ++ } ++} ++ ++impl Read for DeflateDecoder { ++ fn read(&mut self, into: &mut [u8]) -> io::Result { ++ zio::read(&mut self.obj, &mut self.data, into) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for DeflateDecoder {} ++ ++impl Write for DeflateDecoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for DeflateDecoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ self.get_mut().shutdown() ++ } ++} diff --cc vendor/flate2-0.2.20/src/deflate/mod.rs index 000000000,000000000..7bacfa7c8 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/deflate/mod.rs @@@ -1,0 -1,0 +1,198 @@@ ++pub mod bufread; ++pub mod read; ++pub mod write; ++ ++#[cfg(test)] ++mod tests { ++ use std::io::prelude::*; ++ ++ use rand::{thread_rng, Rng}; ++ ++ use super::{read, write}; ++ use Compression::Default; ++ ++ #[test] ++ fn roundtrip() { ++ let mut real = Vec::new(); ++ let mut w = write::DeflateEncoder::new(Vec::new(), Default); ++ let v = thread_rng().gen_iter::().take(1024).collect::>(); ++ for _ in 0..200 { ++ let to_write = &v[..thread_rng().gen_range(0, v.len())]; ++ real.extend(to_write.iter().map(|x| *x)); ++ w.write_all(to_write).unwrap(); ++ } ++ let result = w.finish().unwrap(); ++ let mut r = read::DeflateDecoder::new(&result[..]); ++ let mut ret = Vec::new(); ++ r.read_to_end(&mut ret).unwrap(); ++ assert!(ret == real); ++ } ++ ++ #[test] ++ fn drop_writes() { ++ let mut data = Vec::new(); ++ write::DeflateEncoder::new(&mut data, Default) ++ .write_all(b"foo") ++ .unwrap(); ++ let mut r = read::DeflateDecoder::new(&data[..]); ++ let mut ret = Vec::new(); ++ r.read_to_end(&mut ret).unwrap(); ++ assert!(ret == b"foo"); ++ } ++ ++ #[test] ++ fn total_in() { ++ let mut real = Vec::new(); ++ let mut w = write::DeflateEncoder::new(Vec::new(), Default); ++ let v = thread_rng().gen_iter::().take(1024).collect::>(); ++ for _ in 0..200 { ++ let to_write = &v[..thread_rng().gen_range(0, v.len())]; ++ real.extend(to_write.iter().map(|x| *x)); ++ w.write_all(to_write).unwrap(); ++ } ++ let mut result = w.finish().unwrap(); ++ ++ let result_len = result.len(); ++ ++ for _ in 0..200 { ++ result.extend(v.iter().map(|x| *x)); ++ } ++ ++ let mut r = read::DeflateDecoder::new(&result[..]); ++ let mut ret = Vec::new(); ++ r.read_to_end(&mut ret).unwrap(); ++ assert!(ret == real); ++ assert_eq!(r.total_in(), result_len as u64); ++ } ++ ++ #[test] ++ fn roundtrip2() { ++ let v = thread_rng() ++ .gen_iter::() ++ .take(1024 * 1024) ++ .collect::>(); ++ let mut r = read::DeflateDecoder::new(read::DeflateEncoder::new(&v[..], Default)); ++ let mut ret = Vec::new(); ++ r.read_to_end(&mut ret).unwrap(); ++ assert_eq!(ret, v); ++ } ++ ++ #[test] ++ fn roundtrip3() { ++ let v = thread_rng() ++ .gen_iter::() ++ .take(1024 * 1024) ++ .collect::>(); ++ let mut w = write::DeflateEncoder::new(write::DeflateDecoder::new(Vec::new()), Default); ++ w.write_all(&v).unwrap(); ++ let w = w.finish().unwrap().finish().unwrap(); ++ assert!(w == v); ++ } ++ ++ #[test] ++ fn reset_writer() { ++ let v = thread_rng() ++ .gen_iter::() ++ .take(1024 * 1024) ++ .collect::>(); ++ let mut w = write::DeflateEncoder::new(Vec::new(), Default); ++ w.write_all(&v).unwrap(); ++ let a = w.reset(Vec::new()).unwrap(); ++ w.write_all(&v).unwrap(); ++ let b = w.finish().unwrap(); ++ ++ let mut w = write::DeflateEncoder::new(Vec::new(), Default); ++ w.write_all(&v).unwrap(); ++ let c = w.finish().unwrap(); ++ assert!(a == b && b == c); ++ } ++ ++ #[test] ++ fn reset_reader() { ++ let v = thread_rng() ++ .gen_iter::() ++ .take(1024 * 1024) ++ .collect::>(); ++ let (mut a, mut b, mut c) = (Vec::new(), Vec::new(), Vec::new()); ++ let mut r = read::DeflateEncoder::new(&v[..], Default); ++ r.read_to_end(&mut a).unwrap(); ++ r.reset(&v[..]); ++ r.read_to_end(&mut b).unwrap(); ++ ++ let mut r = read::DeflateEncoder::new(&v[..], Default); ++ r.read_to_end(&mut c).unwrap(); ++ assert!(a == b && b == c); ++ } ++ ++ #[test] ++ fn reset_decoder() { ++ let v = thread_rng() ++ .gen_iter::() ++ .take(1024 * 1024) ++ .collect::>(); ++ let mut w = write::DeflateEncoder::new(Vec::new(), Default); ++ w.write_all(&v).unwrap(); ++ let data = w.finish().unwrap(); ++ ++ { ++ let (mut a, mut b, mut c) = (Vec::new(), Vec::new(), Vec::new()); ++ let mut r = read::DeflateDecoder::new(&data[..]); ++ r.read_to_end(&mut a).unwrap(); ++ r.reset(&data); ++ r.read_to_end(&mut b).unwrap(); ++ ++ let mut r = read::DeflateDecoder::new(&data[..]); ++ r.read_to_end(&mut c).unwrap(); ++ assert!(a == b && b == c && c == v); ++ } ++ ++ { ++ let mut w = write::DeflateDecoder::new(Vec::new()); ++ w.write_all(&data).unwrap(); ++ let a = w.reset(Vec::new()).unwrap(); ++ w.write_all(&data).unwrap(); ++ let b = w.finish().unwrap(); ++ ++ let mut w = write::DeflateDecoder::new(Vec::new()); ++ w.write_all(&data).unwrap(); ++ let c = w.finish().unwrap(); ++ assert!(a == b && b == c && c == v); ++ } ++ } ++ ++ #[test] ++ fn zero_length_read_with_data() { ++ let m = vec![3u8; 128 * 1024 + 1]; ++ let mut c = read::DeflateEncoder::new(&m[..], ::Compression::Default); ++ ++ let mut result = Vec::new(); ++ c.read_to_end(&mut result).unwrap(); ++ ++ let mut d = read::DeflateDecoder::new(&result[..]); ++ let mut data = Vec::new(); ++ assert!(d.read(&mut data).unwrap() == 0); ++ } ++ ++ #[test] ++ fn qc_reader() { ++ ::quickcheck::quickcheck(test as fn(_) -> _); ++ ++ fn test(v: Vec) -> bool { ++ let mut r = read::DeflateDecoder::new(read::DeflateEncoder::new(&v[..], Default)); ++ let mut v2 = Vec::new(); ++ r.read_to_end(&mut v2).unwrap(); ++ v == v2 ++ } ++ } ++ ++ #[test] ++ fn qc_writer() { ++ ::quickcheck::quickcheck(test as fn(_) -> _); ++ ++ fn test(v: Vec) -> bool { ++ let mut w = write::DeflateEncoder::new(write::DeflateDecoder::new(Vec::new()), Default); ++ w.write_all(&v).unwrap(); ++ v == w.finish().unwrap().finish().unwrap() ++ } ++ } ++} diff --cc vendor/flate2-0.2.20/src/deflate/read.rs index 000000000,000000000..e2363c9cc new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/deflate/read.rs @@@ -1,0 -1,0 +1,268 @@@ ++use std::io::prelude::*; ++use std::io; ++ ++#[cfg(feature = "tokio")] ++use futures::Poll; ++#[cfg(feature = "tokio")] ++use tokio_io::{AsyncRead, AsyncWrite}; ++ ++use bufreader::BufReader; ++use super::bufread; ++ ++/// A DEFLATE encoder, or compressor. ++/// ++/// This structure implements a [`Read`] interface and will read uncompressed ++/// data from an underlying stream and emit a stream of compressed data. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// use flate2::Compression; ++/// use flate2::read::DeflateEncoder; ++/// ++/// # fn main() { ++/// # println!("{:?}", deflateencoder_read_hello_world().unwrap()); ++/// # } ++/// # ++/// // Return a vector containing the Deflate compressed version of hello world ++/// fn deflateencoder_read_hello_world() -> io::Result> { ++/// let mut ret_vec = [0;100]; ++/// let c = b"hello world"; ++/// let mut deflater = DeflateEncoder::new(&c[..], Compression::Fast); ++/// let count = deflater.read(&mut ret_vec)?; ++/// Ok(ret_vec[0..count].to_vec()) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct DeflateEncoder { ++ inner: bufread::DeflateEncoder>, ++} ++ ++impl DeflateEncoder { ++ /// Creates a new encoder which will read uncompressed data from the given ++ /// stream and emit the compressed stream. ++ pub fn new(r: R, level: ::Compression) -> DeflateEncoder { ++ DeflateEncoder { ++ inner: bufread::DeflateEncoder::new(BufReader::new(r), level), ++ } ++ } ++} ++ ++impl DeflateEncoder { ++ /// Resets the state of this encoder entirely, swapping out the input ++ /// stream for another. ++ /// ++ /// This function will reset the internal state of this encoder and replace ++ /// the input stream with the one provided, returning the previous input ++ /// stream. Future data read from this encoder will be the compressed ++ /// version of `r`'s data. ++ /// ++ /// Note that there may be currently buffered data when this function is ++ /// called, and in that case the buffered data is discarded. ++ pub fn reset(&mut self, r: R) -> R { ++ super::bufread::reset_encoder_data(&mut self.inner); ++ self.inner.get_mut().reset(r) ++ } ++ ++ /// Acquires a reference to the underlying reader ++ pub fn get_ref(&self) -> &R { ++ self.inner.get_ref().get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying stream ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ self.inner.get_mut().get_mut() ++ } ++ ++ /// Consumes this encoder, returning the underlying reader. ++ /// ++ /// Note that there may be buffered bytes which are not re-acquired as part ++ /// of this transition. It's recommended to only call this function after ++ /// EOF has been reached. ++ pub fn into_inner(self) -> R { ++ self.inner.into_inner().into_inner() ++ } ++ ++ /// Returns the number of bytes that have been read into this compressor. ++ /// ++ /// Note that not all bytes read from the underlying object may be accounted ++ /// for, there may still be some active buffering. ++ pub fn total_in(&self) -> u64 { ++ self.inner.total_in() ++ } ++ ++ /// Returns the number of bytes that the compressor has produced. ++ /// ++ /// Note that not all bytes may have been read yet, some may still be ++ /// buffered. ++ pub fn total_out(&self) -> u64 { ++ self.inner.total_out() ++ } ++} ++ ++impl Read for DeflateEncoder { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.inner.read(buf) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for DeflateEncoder {} ++ ++impl Write for DeflateEncoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for DeflateEncoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ self.get_mut().shutdown() ++ } ++} ++ ++/// A DEFLATE decoder, or decompressor. ++/// ++/// This structure implements a [`Read`] interface and takes a stream of ++/// compressed data as input, providing the decompressed data when read from. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// # use flate2::Compression; ++/// # use flate2::write::DeflateEncoder; ++/// use flate2::read::DeflateDecoder; ++/// ++/// # fn main() { ++/// # let mut e = DeflateEncoder::new(Vec::new(), Compression::Default); ++/// # e.write(b"Hello World").unwrap(); ++/// # let bytes = e.finish().unwrap(); ++/// # println!("{}", decode_reader(bytes).unwrap()); ++/// # } ++/// // Uncompresses a Deflate Encoded vector of bytes and returns a string or error ++/// // Here &[u8] implements Read ++/// fn decode_reader(bytes: Vec) -> io::Result { ++/// let mut deflater = DeflateDecoder::new(&bytes[..]); ++/// let mut s = String::new(); ++/// deflater.read_to_string(&mut s)?; ++/// Ok(s) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct DeflateDecoder { ++ inner: bufread::DeflateDecoder>, ++} ++ ++ ++ ++impl DeflateDecoder { ++ /// Creates a new decoder which will decompress data read from the given ++ /// stream. ++ pub fn new(r: R) -> DeflateDecoder { ++ DeflateDecoder::new_with_buf(r, vec![0; 32 * 1024]) ++ } ++ ++ /// Same as `new`, but the intermediate buffer for data is specified. ++ /// ++ /// Note that the capacity of the intermediate buffer is never increased, ++ /// and it is recommended for it to be large. ++ pub fn new_with_buf(r: R, buf: Vec) -> DeflateDecoder { ++ DeflateDecoder { ++ inner: bufread::DeflateDecoder::new(BufReader::with_buf(buf, r)), ++ } ++ } ++} ++ ++impl DeflateDecoder { ++ /// Resets the state of this decoder entirely, swapping out the input ++ /// stream for another. ++ /// ++ /// This will reset the internal state of this decoder and replace the ++ /// input stream with the one provided, returning the previous input ++ /// stream. Future data read from this decoder will be the decompressed ++ /// version of `r`'s data. ++ /// ++ /// Note that there may be currently buffered data when this function is ++ /// called, and in that case the buffered data is discarded. ++ pub fn reset(&mut self, r: R) -> R { ++ super::bufread::reset_decoder_data(&mut self.inner); ++ self.inner.get_mut().reset(r) ++ } ++ ++ /// Acquires a reference to the underlying stream ++ pub fn get_ref(&self) -> &R { ++ self.inner.get_ref().get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying stream ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ self.inner.get_mut().get_mut() ++ } ++ ++ /// Consumes this decoder, returning the underlying reader. ++ /// ++ /// Note that there may be buffered bytes which are not re-acquired as part ++ /// of this transition. It's recommended to only call this function after ++ /// EOF has been reached. ++ pub fn into_inner(self) -> R { ++ self.inner.into_inner().into_inner() ++ } ++ ++ /// Returns the number of bytes that the decompressor has consumed. ++ /// ++ /// Note that this will likely be smaller than what the decompressor ++ /// actually read from the underlying stream due to buffering. ++ pub fn total_in(&self) -> u64 { ++ self.inner.total_in() ++ } ++ ++ /// Returns the number of bytes that the decompressor has produced. ++ pub fn total_out(&self) -> u64 { ++ self.inner.total_out() ++ } ++} ++ ++impl Read for DeflateDecoder { ++ fn read(&mut self, into: &mut [u8]) -> io::Result { ++ self.inner.read(into) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for DeflateDecoder {} ++ ++impl Write for DeflateDecoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for DeflateDecoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ self.get_mut().shutdown() ++ } ++} diff --cc vendor/flate2-0.2.20/src/deflate/write.rs index 000000000,000000000..596450348 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/deflate/write.rs @@@ -1,0 -1,0 +1,350 @@@ ++use std::io::prelude::*; ++use std::io; ++ ++#[cfg(feature = "tokio")] ++use futures::Poll; ++#[cfg(feature = "tokio")] ++use tokio_io::{AsyncRead, AsyncWrite}; ++ ++use zio; ++use {Compress, Decompress}; ++ ++/// A DEFLATE encoder, or compressor. ++/// ++/// This structure implements a [`Write`] interface and takes a stream of ++/// uncompressed data, writing the compressed data to the wrapped writer. ++/// ++/// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use flate2::Compression; ++/// use flate2::write::DeflateEncoder; ++/// ++/// // Vec implements Write to print the compressed bytes of sample string ++/// # fn main() { ++/// ++/// let mut e = DeflateEncoder::new(Vec::new(), Compression::Default); ++/// e.write(b"Hello World").unwrap(); ++/// println!("{:?}", e.finish().unwrap()); ++/// # } ++/// ``` ++#[derive(Debug)] ++pub struct DeflateEncoder { ++ inner: zio::Writer, ++} ++ ++impl DeflateEncoder { ++ /// Creates a new encoder which will write compressed data to the stream ++ /// given at the given compression level. ++ /// ++ /// When this encoder is dropped or unwrapped the final pieces of data will ++ /// be flushed. ++ pub fn new(w: W, level: ::Compression) -> DeflateEncoder { ++ DeflateEncoder { ++ inner: zio::Writer::new(w, Compress::new(level, false)), ++ } ++ } ++ ++ /// Acquires a reference to the underlying writer. ++ pub fn get_ref(&self) -> &W { ++ self.inner.get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying writer. ++ /// ++ /// Note that mutating the output/input state of the stream may corrupt this ++ /// object, so care must be taken when using this method. ++ pub fn get_mut(&mut self) -> &mut W { ++ self.inner.get_mut() ++ } ++ ++ /// Resets the state of this encoder entirely, swapping out the output ++ /// stream for another. ++ /// ++ /// This function will finish encoding the current stream into the current ++ /// output stream before swapping out the two output streams. If the stream ++ /// cannot be finished an error is returned. ++ /// ++ /// After the current stream has been finished, this will reset the internal ++ /// state of this encoder and replace the output stream with the one ++ /// provided, returning the previous output stream. Future data written to ++ /// this encoder will be the compressed into the stream `w` provided. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn reset(&mut self, w: W) -> io::Result { ++ try!(self.inner.finish()); ++ self.inner.data.reset(); ++ Ok(self.inner.replace(w)) ++ } ++ ++ /// Attempt to finish this output stream, writing out final chunks of data. ++ /// ++ /// Note that this function can only be used once data has finished being ++ /// written to the output stream. After this function is called then further ++ /// calls to `write` may result in a panic. ++ /// ++ /// # Panics ++ /// ++ /// Attempts to write data to this stream may result in a panic after this ++ /// function is called. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn try_finish(&mut self) -> io::Result<()> { ++ self.inner.finish() ++ } ++ ++ /// Consumes this encoder, flushing the output stream. ++ /// ++ /// This will flush the underlying data stream, close off the compressed ++ /// stream and, if successful, return the contained writer. ++ /// ++ /// Note that this function may not be suitable to call in a situation where ++ /// the underlying stream is an asynchronous I/O stream. To finish a stream ++ /// the `try_finish` (or `shutdown`) method should be used instead. To ++ /// re-acquire ownership of a stream it is safe to call this method after ++ /// `try_finish` or `shutdown` has returned `Ok`. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn finish(mut self) -> io::Result { ++ try!(self.inner.finish()); ++ Ok(self.inner.take_inner()) ++ } ++ ++ /// Consumes this encoder, flushing the output stream. ++ /// ++ /// This will flush the underlying data stream and then return the contained ++ /// writer if the flush succeeded. ++ /// The compressed stream will not closed but only flushed. This ++ /// means that obtained byte array can by extended by another deflated ++ /// stream. To close the stream add the two bytes 0x3 and 0x0. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn flush_finish(mut self) -> io::Result { ++ try!(self.inner.flush()); ++ Ok(self.inner.take_inner()) ++ } ++ ++ /// Returns the number of bytes that have been written to this compresor. ++ /// ++ /// Note that not all bytes written to this object may be accounted for, ++ /// there may still be some active buffering. ++ pub fn total_in(&self) -> u64 { ++ self.inner.data.total_in() ++ } ++ ++ /// Returns the number of bytes that the compressor has produced. ++ /// ++ /// Note that not all bytes may have been written yet, some may still be ++ /// buffered. ++ pub fn total_out(&self) -> u64 { ++ self.inner.data.total_out() ++ } ++} ++ ++impl Write for DeflateEncoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.inner.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.inner.flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for DeflateEncoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ try_nb!(self.inner.finish()); ++ self.inner.get_mut().shutdown() ++ } ++} ++ ++impl Read for DeflateEncoder { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.inner.get_mut().read(buf) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for DeflateEncoder {} ++ ++/// A DEFLATE decoder, or decompressor. ++/// ++/// This structure implements a [`Write`] and will emit a stream of decompressed ++/// data when fed a stream of compressed data. ++/// ++/// [`Write`]: https://doc.rust-lang.org/std/io/trait.Read.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// # use flate2::Compression; ++/// # use flate2::write::DeflateEncoder; ++/// use flate2::write::DeflateDecoder; ++/// ++/// # fn main() { ++/// # let mut e = DeflateEncoder::new(Vec::new(), Compression::Default); ++/// # e.write(b"Hello World").unwrap(); ++/// # let bytes = e.finish().unwrap(); ++/// # println!("{}", decode_writer(bytes).unwrap()); ++/// # } ++/// // Uncompresses a Deflate Encoded vector of bytes and returns a string or error ++/// // Here Vec implements Write ++/// fn decode_writer(bytes: Vec) -> io::Result { ++/// let mut writer = Vec::new(); ++/// let mut deflater = DeflateDecoder::new(writer); ++/// deflater.write(&bytes[..])?; ++/// writer = deflater.finish()?; ++/// let return_string = String::from_utf8(writer).expect("String parsing error"); ++/// Ok(return_string) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct DeflateDecoder { ++ inner: zio::Writer, ++} ++ ++ ++impl DeflateDecoder { ++ /// Creates a new decoder which will write uncompressed data to the stream. ++ /// ++ /// When this encoder is dropped or unwrapped the final pieces of data will ++ /// be flushed. ++ pub fn new(w: W) -> DeflateDecoder { ++ DeflateDecoder { ++ inner: zio::Writer::new(w, Decompress::new(false)), ++ } ++ } ++ ++ /// Acquires a reference to the underlying writer. ++ pub fn get_ref(&self) -> &W { ++ self.inner.get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying writer. ++ /// ++ /// Note that mutating the output/input state of the stream may corrupt this ++ /// object, so care must be taken when using this method. ++ pub fn get_mut(&mut self) -> &mut W { ++ self.inner.get_mut() ++ } ++ ++ /// Resets the state of this decoder entirely, swapping out the output ++ /// stream for another. ++ /// ++ /// This function will finish encoding the current stream into the current ++ /// output stream before swapping out the two output streams. ++ /// ++ /// This will then reset the internal state of this decoder and replace the ++ /// output stream with the one provided, returning the previous output ++ /// stream. Future data written to this decoder will be decompressed into ++ /// the output stream `w`. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to finish the stream, and if that I/O ++ /// returns an error then that will be returned from this function. ++ pub fn reset(&mut self, w: W) -> io::Result { ++ try!(self.inner.finish()); ++ self.inner.data = Decompress::new(false); ++ Ok(self.inner.replace(w)) ++ } ++ ++ /// Attempt to finish this output stream, writing out final chunks of data. ++ /// ++ /// Note that this function can only be used once data has finished being ++ /// written to the output stream. After this function is called then further ++ /// calls to `write` may result in a panic. ++ /// ++ /// # Panics ++ /// ++ /// Attempts to write data to this stream may result in a panic after this ++ /// function is called. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to finish the stream, returning any ++ /// errors which happen. ++ pub fn try_finish(&mut self) -> io::Result<()> { ++ self.inner.finish() ++ } ++ ++ /// Consumes this encoder, flushing the output stream. ++ /// ++ /// This will flush the underlying data stream and then return the contained ++ /// writer if the flush succeeded. ++ /// ++ /// Note that this function may not be suitable to call in a situation where ++ /// the underlying stream is an asynchronous I/O stream. To finish a stream ++ /// the `try_finish` (or `shutdown`) method should be used instead. To ++ /// re-acquire ownership of a stream it is safe to call this method after ++ /// `try_finish` or `shutdown` has returned `Ok`. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn finish(mut self) -> io::Result { ++ try!(self.inner.finish()); ++ Ok(self.inner.take_inner()) ++ } ++ ++ /// Returns the number of bytes that the decompressor has consumed for ++ /// decompression. ++ /// ++ /// Note that this will likely be smaller than the number of bytes ++ /// successfully written to this stream due to internal buffering. ++ pub fn total_in(&self) -> u64 { ++ self.inner.data.total_in() ++ } ++ ++ /// Returns the number of bytes that the decompressor has written to its ++ /// output stream. ++ pub fn total_out(&self) -> u64 { ++ self.inner.data.total_out() ++ } ++} ++ ++impl Write for DeflateDecoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.inner.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.inner.flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for DeflateDecoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ try_nb!(self.inner.finish()); ++ self.inner.get_mut().shutdown() ++ } ++} ++ ++impl Read for DeflateDecoder { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.inner.get_mut().read(buf) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for DeflateDecoder {} diff --cc vendor/flate2-0.2.20/src/ffi.rs index 000000000,000000000..92a30a6a7 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/ffi.rs @@@ -1,0 -1,0 +1,235 @@@ ++pub use self::imp::*; ++ ++#[cfg(feature = "zlib")] ++#[allow(bad_style)] ++mod imp { ++ extern crate libz_sys as z; ++ use std::mem; ++ use std::ops::{Deref, DerefMut}; ++ use libc::{c_int, size_t, c_ulong, c_uint, c_char}; ++ ++ pub use self::z::*; ++ pub use self::z::deflateEnd as mz_deflateEnd; ++ pub use self::z::inflateEnd as mz_inflateEnd; ++ pub use self::z::deflateReset as mz_deflateReset; ++ pub use self::z::deflate as mz_deflate; ++ pub use self::z::inflate as mz_inflate; ++ pub use self::z::z_stream as mz_stream; ++ ++ pub use self::z::Z_BLOCK as MZ_BLOCK; ++ pub use self::z::Z_BUF_ERROR as MZ_BUF_ERROR; ++ pub use self::z::Z_DATA_ERROR as MZ_DATA_ERROR; ++ pub use self::z::Z_DEFAULT_STRATEGY as MZ_DEFAULT_STRATEGY; ++ pub use self::z::Z_DEFLATED as MZ_DEFLATED; ++ pub use self::z::Z_FINISH as MZ_FINISH; ++ pub use self::z::Z_FULL_FLUSH as MZ_FULL_FLUSH; ++ pub use self::z::Z_NO_FLUSH as MZ_NO_FLUSH; ++ pub use self::z::Z_OK as MZ_OK; ++ pub use self::z::Z_PARTIAL_FLUSH as MZ_PARTIAL_FLUSH; ++ pub use self::z::Z_STREAM_END as MZ_STREAM_END; ++ pub use self::z::Z_SYNC_FLUSH as MZ_SYNC_FLUSH; ++ pub use self::z::Z_STREAM_ERROR as MZ_STREAM_ERROR; ++ ++ pub const MZ_DEFAULT_WINDOW_BITS: c_int = 15; ++ ++ pub unsafe extern fn mz_crc32(crc: c_ulong, ++ ptr: *const u8, ++ len: size_t) -> c_ulong { ++ z::crc32(crc, ptr, len as c_uint) ++ } ++ ++ pub unsafe extern fn mz_crc32_combine(crc1: c_ulong, ++ crc2: c_ulong, ++ len2: z_off_t) -> c_ulong { ++ z::crc32_combine(crc1, crc2, len2) ++ } ++ ++ const ZLIB_VERSION: &'static str = "1.2.8\0"; ++ ++ pub unsafe extern fn mz_deflateInit2(stream: *mut mz_stream, ++ level: c_int, ++ method: c_int, ++ window_bits: c_int, ++ mem_level: c_int, ++ strategy: c_int) -> c_int { ++ z::deflateInit2_(stream, level, method, window_bits, mem_level, ++ strategy, ++ ZLIB_VERSION.as_ptr() as *const c_char, ++ mem::size_of::() as c_int) ++ } ++ pub unsafe extern fn mz_inflateInit2(stream: *mut mz_stream, ++ window_bits: c_int) ++ -> c_int { ++ z::inflateInit2_(stream, window_bits, ++ ZLIB_VERSION.as_ptr() as *const c_char, ++ mem::size_of::() as c_int) ++ } ++ ++ pub struct StreamWrapper{ ++ inner: Box, ++ } ++ ++ impl ::std::fmt::Debug for StreamWrapper{ ++ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error>{ ++ write!(f, "StreamWrapper") ++ } ++ } ++ ++ impl Default for StreamWrapper { ++ fn default() -> StreamWrapper { ++ StreamWrapper { ++ inner: Box::new(unsafe{ mem::zeroed() }) ++ } ++ } ++ } ++ ++ impl Deref for StreamWrapper { ++ type Target = mz_stream; ++ ++ fn deref(&self) -> &Self::Target { ++ & *self.inner ++ } ++ } ++ ++ impl DerefMut for StreamWrapper { ++ fn deref_mut(&mut self) -> &mut Self::Target { ++ &mut *self.inner ++ } ++ } ++} ++ ++#[cfg(not(feature = "zlib"))] ++mod imp { ++ extern crate miniz_sys; ++ use std::mem; ++ use std::ops::{Deref, DerefMut}; ++ ++ use libc::{c_ulong, off_t}; ++ pub use self::miniz_sys::*; ++ ++ pub struct StreamWrapper { ++ inner: mz_stream, ++ } ++ ++ impl ::std::fmt::Debug for StreamWrapper{ ++ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error>{ ++ write!(f, "StreamWrapper") ++ } ++ } ++ ++ impl Default for StreamWrapper { ++ fn default() -> StreamWrapper { ++ StreamWrapper { ++ inner : unsafe{ mem::zeroed() } ++ } ++ } ++ } ++ ++ impl Deref for StreamWrapper { ++ type Target = mz_stream; ++ ++ fn deref(&self) -> &Self::Target { ++ &self.inner ++ } ++ } ++ ++ impl DerefMut for StreamWrapper { ++ fn deref_mut(&mut self) -> &mut Self::Target { ++ &mut self.inner ++ } ++ } ++ ++ pub unsafe extern fn mz_crc32_combine(crc1: c_ulong, ++ crc2: c_ulong, ++ len2: off_t) -> c_ulong { ++ crc32_combine_(crc1, crc2, len2) ++ } ++ ++ // gf2_matrix_times, gf2_matrix_square and crc32_combine_ are ported from ++ // zlib. ++ ++ fn gf2_matrix_times(mat: &[c_ulong; 32], mut vec: c_ulong) -> c_ulong { ++ let mut sum = 0; ++ let mut mat_pos = 0; ++ while vec != 0 { ++ if vec & 1 == 1 { ++ sum ^= mat[mat_pos]; ++ } ++ vec >>= 1; ++ mat_pos += 1; ++ } ++ sum ++ } ++ ++ fn gf2_matrix_square(square: &mut [c_ulong; 32], mat: &[c_ulong; 32]) { ++ for n in 0..32 { ++ square[n] = gf2_matrix_times(mat, mat[n]); ++ } ++ } ++ ++ fn crc32_combine_(mut crc1: c_ulong, crc2: c_ulong, mut len2: off_t) -> c_ulong { ++ let mut row; ++ ++ let mut even = [0; 32]; /* even-power-of-two zeros operator */ ++ let mut odd = [0; 32]; /* odd-power-of-two zeros operator */ ++ ++ /* degenerate case (also disallow negative lengths) */ ++ if len2 <= 0 { ++ return crc1; ++ } ++ ++ /* put operator for one zero bit in odd */ ++ odd[0] = 0xedb88320; /* CRC-32 polynomial */ ++ row = 1; ++ for n in 1..32 { ++ odd[n] = row; ++ row <<= 1; ++ } ++ ++ /* put operator for two zero bits in even */ ++ gf2_matrix_square(&mut even, &odd); ++ ++ /* put operator for four zero bits in odd */ ++ gf2_matrix_square(&mut odd, &even); ++ ++ /* apply len2 zeros to crc1 (first square will put the operator for one ++ zero byte, eight zero bits, in even) */ ++ loop { ++ /* apply zeros operator for this bit of len2 */ ++ gf2_matrix_square(&mut even, &odd); ++ if len2 & 1 == 1 { ++ crc1 = gf2_matrix_times(&even, crc1); ++ } ++ len2 >>= 1; ++ ++ /* if no more bits set, then done */ ++ if len2 == 0 { ++ break; ++ } ++ ++ /* another iteration of the loop with odd and even swapped */ ++ gf2_matrix_square(&mut odd, &even); ++ if len2 & 1 == 1 { ++ crc1 = gf2_matrix_times(&odd, crc1); ++ } ++ len2 >>= 1; ++ ++ /* if no more bits set, then done */ ++ if len2 == 0 { ++ break; ++ } ++ } ++ ++ /* return combined crc */ ++ crc1 ^= crc2; ++ crc1 ++ } ++} ++ ++#[test] ++fn crc32_combine() { ++ let crc32 = unsafe { ++ imp::mz_crc32_combine(1, 2, 3) ++ }; ++ assert_eq!(crc32, 29518389); ++} diff --cc vendor/flate2-0.2.20/src/gz/bufread.rs index 000000000,000000000..22be33ae3 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/gz/bufread.rs @@@ -1,0 -1,0 +1,547 @@@ ++use std::cmp; ++use std::io::prelude::*; ++use std::io; ++use std::mem; ++ ++use super::{Builder, Header}; ++use super::{FCOMMENT, FEXTRA, FHCRC, FNAME}; ++use Compression; ++use crc::CrcReader; ++use deflate; ++ ++fn copy(into: &mut [u8], from: &[u8], pos: &mut usize) -> usize { ++ let min = cmp::min(into.len(), from.len() - *pos); ++ for (slot, val) in into.iter_mut().zip(from[*pos..*pos + min].iter()) { ++ *slot = *val; ++ } ++ *pos += min; ++ return min; ++} ++fn corrupt() -> io::Error { ++ io::Error::new( ++ io::ErrorKind::InvalidInput, ++ "corrupt gzip stream does not have a matching checksum", ++ ) ++} ++ ++fn bad_header() -> io::Error { ++ io::Error::new(io::ErrorKind::InvalidInput, "invalid gzip header") ++} ++ ++fn read_le_u16(r: &mut R) -> io::Result { ++ let mut b = [0; 2]; ++ try!(r.read_exact(&mut b)); ++ Ok((b[0] as u16) | ((b[1] as u16) << 8)) ++} ++ ++fn read_gz_header(r: &mut R) -> io::Result

{ ++ let mut crc_reader = CrcReader::new(r); ++ let mut header = [0; 10]; ++ try!(crc_reader.read_exact(&mut header)); ++ ++ let id1 = header[0]; ++ let id2 = header[1]; ++ if id1 != 0x1f || id2 != 0x8b { ++ return Err(bad_header()); ++ } ++ let cm = header[2]; ++ if cm != 8 { ++ return Err(bad_header()); ++ } ++ ++ let flg = header[3]; ++ let mtime = ((header[4] as u32) << 0) | ((header[5] as u32) << 8) | ((header[6] as u32) << 16) | ++ ((header[7] as u32) << 24); ++ let _xfl = header[8]; ++ let _os = header[9]; ++ ++ let extra = if flg & FEXTRA != 0 { ++ let xlen = try!(read_le_u16(&mut crc_reader)); ++ let mut extra = vec![0; xlen as usize]; ++ try!(crc_reader.read_exact(&mut extra)); ++ Some(extra) ++ } else { ++ None ++ }; ++ let filename = if flg & FNAME != 0 { ++ // wow this is slow ++ let mut b = Vec::new(); ++ for byte in crc_reader.by_ref().bytes() { ++ let byte = try!(byte); ++ if byte == 0 { ++ break; ++ } ++ b.push(byte); ++ } ++ Some(b) ++ } else { ++ None ++ }; ++ let comment = if flg & FCOMMENT != 0 { ++ // wow this is slow ++ let mut b = Vec::new(); ++ for byte in crc_reader.by_ref().bytes() { ++ let byte = try!(byte); ++ if byte == 0 { ++ break; ++ } ++ b.push(byte); ++ } ++ Some(b) ++ } else { ++ None ++ }; ++ ++ if flg & FHCRC != 0 { ++ let calced_crc = crc_reader.crc().sum() as u16; ++ let stored_crc = try!(read_le_u16(&mut crc_reader)); ++ if calced_crc != stored_crc { ++ return Err(corrupt()); ++ } ++ } ++ ++ Ok(Header { ++ extra: extra, ++ filename: filename, ++ comment: comment, ++ mtime: mtime, ++ }) ++} ++ ++ ++/// A gzip streaming encoder ++/// ++/// This structure exposes a [`BufRead`] interface that will read uncompressed data ++/// from the underlying reader and expose the compressed version as a [`BufRead`] ++/// interface. ++/// ++/// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// use flate2::Compression; ++/// use flate2::bufread::GzEncoder; ++/// use std::fs::File; ++/// use std::io::BufReader; ++/// ++/// // Opens sample file, compresses the contents and returns a Vector or error ++/// // File wrapped in a BufReader implements BufRead ++/// ++/// fn open_hello_world() -> io::Result> { ++/// let f = File::open("examples/hello_world.txt")?; ++/// let b = BufReader::new(f); ++/// let mut gz = GzEncoder::new(b, Compression::Fast); ++/// let mut buffer = Vec::new(); ++/// gz.read_to_end(&mut buffer)?; ++/// Ok(buffer) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct GzEncoder { ++ inner: deflate::bufread::DeflateEncoder>, ++ header: Vec, ++ pos: usize, ++ eof: bool, ++} ++ ++pub fn gz_encoder(header: Vec, r: R, lvl: Compression) ++ -> GzEncoder ++{ ++ let crc = CrcReader::new(r); ++ GzEncoder { ++ inner: deflate::bufread::DeflateEncoder::new(crc, lvl), ++ header: header, ++ pos: 0, ++ eof: false, ++ } ++} ++ ++impl GzEncoder { ++ /// Creates a new encoder which will use the given compression level. ++ /// ++ /// The encoder is not configured specially for the emitted header. For ++ /// header configuration, see the `Builder` type. ++ /// ++ /// The data read from the stream `r` will be compressed and available ++ /// through the returned reader. ++ pub fn new(r: R, level: Compression) -> GzEncoder { ++ Builder::new().buf_read(r, level) ++ } ++ ++ fn read_footer(&mut self, into: &mut [u8]) -> io::Result { ++ if self.pos == 8 { ++ return Ok(0); ++ } ++ let crc = self.inner.get_ref().crc(); ++ let ref arr = [ ++ (crc.sum() >> 0) as u8, ++ (crc.sum() >> 8) as u8, ++ (crc.sum() >> 16) as u8, ++ (crc.sum() >> 24) as u8, ++ (crc.amount() >> 0) as u8, ++ (crc.amount() >> 8) as u8, ++ (crc.amount() >> 16) as u8, ++ (crc.amount() >> 24) as u8, ++ ]; ++ Ok(copy(into, arr, &mut self.pos)) ++ } ++} ++ ++impl GzEncoder { ++ /// Acquires a reference to the underlying reader. ++ pub fn get_ref(&self) -> &R { ++ self.inner.get_ref().get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying reader. ++ /// ++ /// Note that mutation of the reader may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ self.inner.get_mut().get_mut() ++ } ++ ++ /// Returns the underlying stream, consuming this encoder ++ pub fn into_inner(self) -> R { ++ self.inner.into_inner().into_inner() ++ } ++} ++ ++impl Read for GzEncoder { ++ fn read(&mut self, mut into: &mut [u8]) -> io::Result { ++ let mut amt = 0; ++ if self.eof { ++ return self.read_footer(into); ++ } else if self.pos < self.header.len() { ++ amt += copy(into, &self.header, &mut self.pos); ++ if amt == into.len() { ++ return Ok(amt); ++ } ++ let tmp = into; ++ into = &mut tmp[amt..]; ++ } ++ match try!(self.inner.read(into)) { ++ 0 => { ++ self.eof = true; ++ self.pos = 0; ++ self.read_footer(into) ++ } ++ n => Ok(amt + n), ++ } ++ } ++} ++ ++impl Write for GzEncoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++ ++/// A gzip streaming decoder ++/// ++/// This structure exposes a [`ReadBuf`] interface that will consume compressed ++/// data from the underlying reader and emit uncompressed data. ++/// ++/// [`ReadBuf`]: https://doc.rust-lang.org/std/io/trait.BufRead.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// # use flate2::Compression; ++/// # use flate2::write::GzEncoder; ++/// use flate2::bufread::GzDecoder; ++/// ++/// # fn main() { ++/// # let mut e = GzEncoder::new(Vec::new(), Compression::Default); ++/// # e.write(b"Hello World").unwrap(); ++/// # let bytes = e.finish().unwrap(); ++/// # println!("{}", decode_reader(bytes).unwrap()); ++/// # } ++/// # ++/// // Uncompresses a Gz Encoded vector of bytes and returns a string or error ++/// // Here &[u8] implements BufRead ++/// ++/// fn decode_reader(bytes: Vec) -> io::Result { ++/// let mut gz = GzDecoder::new(&bytes[..])?; ++/// let mut s = String::new(); ++/// gz.read_to_string(&mut s)?; ++/// Ok(s) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct GzDecoder { ++ inner: CrcReader>, ++ header: Header, ++ finished: bool, ++} ++ ++ ++impl GzDecoder { ++ /// Creates a new decoder from the given reader, immediately parsing the ++ /// gzip header. ++ /// ++ /// # Errors ++ /// ++ /// If an error is encountered when parsing the gzip header, an error is ++ /// returned. ++ pub fn new(mut r: R) -> io::Result> { ++ let header = try!(read_gz_header(&mut r)); ++ ++ let flate = deflate::bufread::DeflateDecoder::new(r); ++ return Ok(GzDecoder { ++ inner: CrcReader::new(flate), ++ header: header, ++ finished: false, ++ }); ++ } ++ ++ fn finish(&mut self) -> io::Result<()> { ++ if self.finished { ++ return Ok(()); ++ } ++ let ref mut buf = [0u8; 8]; ++ { ++ let mut len = 0; ++ ++ while len < buf.len() { ++ match try!(self.inner.get_mut().get_mut().read(&mut buf[len..])) { ++ 0 => return Err(corrupt()), ++ n => len += n, ++ } ++ } ++ } ++ ++ let crc = ((buf[0] as u32) << 0) | ((buf[1] as u32) << 8) | ((buf[2] as u32) << 16) | ++ ((buf[3] as u32) << 24); ++ let amt = ((buf[4] as u32) << 0) | ((buf[5] as u32) << 8) | ((buf[6] as u32) << 16) | ++ ((buf[7] as u32) << 24); ++ if crc != self.inner.crc().sum() as u32 { ++ return Err(corrupt()); ++ } ++ if amt != self.inner.crc().amount() { ++ return Err(corrupt()); ++ } ++ self.finished = true; ++ Ok(()) ++ } ++} ++ ++impl GzDecoder { ++ /// Returns the header associated with this stream. ++ pub fn header(&self) -> &Header { ++ &self.header ++ } ++ ++ /// Acquires a reference to the underlying reader. ++ pub fn get_ref(&self) -> &R { ++ self.inner.get_ref().get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying stream. ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ self.inner.get_mut().get_mut() ++ } ++ ++ /// Consumes this decoder, returning the underlying reader. ++ pub fn into_inner(self) -> R { ++ self.inner.into_inner().into_inner() ++ } ++} ++ ++impl Read for GzDecoder { ++ fn read(&mut self, into: &mut [u8]) -> io::Result { ++ match try!(self.inner.read(into)) { ++ 0 => { ++ try!(self.finish()); ++ Ok(0) ++ } ++ n => Ok(n), ++ } ++ } ++} ++ ++impl Write for GzDecoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++ ++ ++/// A gzip streaming decoder that decodes all members of a multistream ++/// ++/// A gzip member consists of a header, compressed data and a trailer. The [gzip ++/// specification](https://tools.ietf.org/html/rfc1952), however, allows multiple ++/// gzip members to be joined in a single stream. `MultiGzDecoder` will ++/// decode all consecutive members while `GzDecoder` will only decompress ++/// the first gzip member. The multistream format is commonly used in ++/// bioinformatics, for example when using the BGZF compressed data. ++/// ++/// This structure exposes a [`BufRead`] interface that will consume all gzip members ++/// from the underlying reader and emit uncompressed data. ++/// ++/// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// # use flate2::Compression; ++/// # use flate2::write::GzEncoder; ++/// use flate2::bufread::MultiGzDecoder; ++/// ++/// # fn main() { ++/// # let mut e = GzEncoder::new(Vec::new(), Compression::Default); ++/// # e.write(b"Hello World").unwrap(); ++/// # let bytes = e.finish().unwrap(); ++/// # println!("{}", decode_reader(bytes).unwrap()); ++/// # } ++/// # ++/// // Uncompresses a Gz Encoded vector of bytes and returns a string or error ++/// // Here &[u8] implements BufRead ++/// ++/// fn decode_reader(bytes: Vec) -> io::Result { ++/// let mut gz = MultiGzDecoder::new(&bytes[..])?; ++/// let mut s = String::new(); ++/// gz.read_to_string(&mut s)?; ++/// Ok(s) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct MultiGzDecoder { ++ inner: CrcReader>, ++ header: Header, ++ finished: bool, ++} ++ ++ ++impl MultiGzDecoder { ++ /// Creates a new decoder from the given reader, immediately parsing the ++ /// (first) gzip header. If the gzip stream contains multiple members all will ++ /// be decoded. ++ /// ++ /// # Errors ++ /// ++ /// If an error is encountered when parsing the gzip header, an error is ++ /// returned. ++ pub fn new(mut r: R) -> io::Result> { ++ let header = try!(read_gz_header(&mut r)); ++ ++ let flate = deflate::bufread::DeflateDecoder::new(r); ++ return Ok(MultiGzDecoder { ++ inner: CrcReader::new(flate), ++ header: header, ++ finished: false, ++ }); ++ } ++ ++ fn finish_member(&mut self) -> io::Result { ++ if self.finished { ++ return Ok(0); ++ } ++ let ref mut buf = [0u8; 8]; ++ { ++ let mut len = 0; ++ ++ while len < buf.len() { ++ match try!(self.inner.get_mut().get_mut().read(&mut buf[len..])) { ++ 0 => return Err(corrupt()), ++ n => len += n, ++ } ++ } ++ } ++ ++ let crc = ((buf[0] as u32) << 0) | ((buf[1] as u32) << 8) | ((buf[2] as u32) << 16) | ++ ((buf[3] as u32) << 24); ++ let amt = ((buf[4] as u32) << 0) | ((buf[5] as u32) << 8) | ((buf[6] as u32) << 16) | ++ ((buf[7] as u32) << 24); ++ if crc != self.inner.crc().sum() as u32 { ++ return Err(corrupt()); ++ } ++ if amt != self.inner.crc().amount() { ++ return Err(corrupt()); ++ } ++ let remaining = match self.inner.get_mut().get_mut().fill_buf() { ++ Ok(b) => if b.is_empty() { ++ self.finished = true; ++ return Ok(0); ++ } else { ++ b.len() ++ }, ++ Err(e) => return Err(e), ++ }; ++ ++ let next_header = try!(read_gz_header(self.inner.get_mut().get_mut())); ++ mem::replace(&mut self.header, next_header); ++ self.inner.reset(); ++ self.inner.get_mut().reset_data(); ++ ++ Ok(remaining) ++ } ++} ++ ++impl MultiGzDecoder { ++ /// Returns the current header associated with this stream. ++ pub fn header(&self) -> &Header { ++ &self.header ++ } ++ ++ /// Acquires a reference to the underlying reader. ++ pub fn get_ref(&self) -> &R { ++ self.inner.get_ref().get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying stream. ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ self.inner.get_mut().get_mut() ++ } ++ ++ /// Consumes this decoder, returning the underlying reader. ++ pub fn into_inner(self) -> R { ++ self.inner.into_inner().into_inner() ++ } ++} ++ ++impl Read for MultiGzDecoder { ++ fn read(&mut self, into: &mut [u8]) -> io::Result { ++ match try!(self.inner.read(into)) { ++ 0 => match self.finish_member() { ++ Ok(0) => Ok(0), ++ Ok(_) => self.read(into), ++ Err(e) => Err(e), ++ }, ++ n => Ok(n), ++ } ++ } ++} ++ ++impl Write for MultiGzDecoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} diff --cc vendor/flate2-0.2.20/src/gz/mod.rs index 000000000,000000000..04ff5fcf0 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/gz/mod.rs @@@ -1,0 -1,0 +1,344 @@@ ++use std::env; ++use std::ffi::CString; ++use std::io::prelude::*; ++use std::time; ++ ++use Compression; ++use bufreader::BufReader; ++ ++pub static FHCRC: u8 = 1 << 1; ++pub static FEXTRA: u8 = 1 << 2; ++pub static FNAME: u8 = 1 << 3; ++pub static FCOMMENT: u8 = 1 << 4; ++ ++pub mod bufread; ++pub mod read; ++pub mod write; ++ ++ ++/// A structure representing the header of a gzip stream. ++/// ++/// The header can contain metadata about the file that was compressed, if ++/// present. ++#[derive(PartialEq, Debug)] ++pub struct Header { ++ extra: Option>, ++ filename: Option>, ++ comment: Option>, ++ mtime: u32, ++} ++ ++impl Header { ++ /// Returns the `filename` field of this gzip stream's header, if present. ++ pub fn filename(&self) -> Option<&[u8]> { ++ self.filename.as_ref().map(|s| &s[..]) ++ } ++ ++ /// Returns the `extra` field of this gzip stream's header, if present. ++ pub fn extra(&self) -> Option<&[u8]> { ++ self.extra.as_ref().map(|s| &s[..]) ++ } ++ ++ /// Returns the `comment` field of this gzip stream's header, if present. ++ pub fn comment(&self) -> Option<&[u8]> { ++ self.comment.as_ref().map(|s| &s[..]) ++ } ++ ++ /// This gives the most recent modification time of the original file being compressed. ++ /// ++ /// The time is in Unix format, i.e., seconds since 00:00:00 GMT, Jan. 1, 1970. ++ /// (Note that this may cause problems for MS-DOS and other systems that use local ++ /// rather than Universal time.) If the compressed data did not come from a file, ++ /// `mtime` is set to the time at which compression started. ++ /// `mtime` = 0 means no time stamp is available. ++ /// ++ /// The usage of `mtime` is discouraged because of Year 2038 problem. ++ pub fn mtime(&self) -> u32 { ++ self.mtime ++ } ++ ++ /// Returns the most recent modification time represented by a date-time type. ++ /// Returns `None` if the value of the underlying counter is 0, ++ /// indicating no time stamp is available. ++ /// ++ /// ++ /// The time is measured as seconds since 00:00:00 GMT, Jan. 1 1970. ++ /// See [`mtime`](#method.mtime) for more detail. ++ pub fn mtime_as_datetime(&self) -> Option { ++ if self.mtime == 0 { ++ None ++ } else { ++ let duration = time::Duration::new(u64::from(self.mtime), 0); ++ let datetime = time::UNIX_EPOCH + duration; ++ Some(datetime) ++ } ++ } ++} ++ ++/// A builder structure to create a new gzip Encoder. ++/// ++/// This structure controls header configuration options such as the filename. ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// # use std::io; ++/// use std::fs::File; ++/// use flate2::GzBuilder; ++/// use flate2::Compression; ++/// ++/// // GzBuilder opens a file and writes a sample string using Builder pattern ++/// ++/// # fn sample_builder() -> Result<(), io::Error> { ++/// let f = File::create("examples/hello_world.gz")?; ++/// let mut gz = GzBuilder::new() ++/// .filename("hello_world.txt") ++/// .comment("test file, please delete") ++/// .write(f, Compression::Default); ++/// gz.write(b"hello world")?; ++/// gz.finish()?; ++/// # Ok(()) ++/// # } ++/// ``` ++#[derive(Debug)] ++pub struct Builder { ++ extra: Option>, ++ filename: Option, ++ comment: Option, ++ mtime: u32, ++} ++ ++impl Builder { ++ /// Create a new blank builder with no header by default. ++ pub fn new() -> Builder { ++ Builder { ++ extra: None, ++ filename: None, ++ comment: None, ++ mtime: 0, ++ } ++ } ++ ++ /// Configure the `mtime` field in the gzip header. ++ pub fn mtime(mut self, mtime: u32) -> Builder { ++ self.mtime = mtime; ++ self ++ } ++ ++ /// Configure the `extra` field in the gzip header. ++ pub fn extra>>(mut self, extra: T) -> Builder { ++ self.extra = Some(extra.into()); ++ self ++ } ++ ++ /// Configure the `filename` field in the gzip header. ++ /// ++ /// # Panics ++ /// ++ /// Panics if the `filename` slice contains a zero. ++ pub fn filename>>(mut self, filename: T) -> Builder { ++ self.filename = Some(CString::new(filename.into()).unwrap()); ++ self ++ } ++ ++ /// Configure the `comment` field in the gzip header. ++ /// ++ /// # Panics ++ /// ++ /// Panics if the `comment` slice contains a zero. ++ pub fn comment>>(mut self, comment: T) -> Builder { ++ self.comment = Some(CString::new(comment.into()).unwrap()); ++ self ++ } ++ ++ /// Consume this builder, creating a writer encoder in the process. ++ /// ++ /// The data written to the returned encoder will be compressed and then ++ /// written out to the supplied parameter `w`. ++ pub fn write(self, w: W, lvl: Compression) -> write::GzEncoder { ++ write::gz_encoder(self.into_header(lvl), w, lvl) ++ } ++ ++ /// Consume this builder, creating a reader encoder in the process. ++ /// ++ /// Data read from the returned encoder will be the compressed version of ++ /// the data read from the given reader. ++ pub fn read(self, r: R, lvl: Compression) -> read::GzEncoder { ++ read::gz_encoder(self.buf_read(BufReader::new(r), lvl)) ++ } ++ ++ /// Consume this builder, creating a reader encoder in the process. ++ /// ++ /// Data read from the returned encoder will be the compressed version of ++ /// the data read from the given reader. ++ pub fn buf_read(self, r: R, lvl: Compression) -> bufread::GzEncoder ++ where ++ R: BufRead, ++ { ++ bufread::gz_encoder(self.into_header(lvl), r, lvl) ++ } ++ ++ fn into_header(self, lvl: Compression) -> Vec { ++ let Builder { ++ extra, ++ filename, ++ comment, ++ mtime, ++ } = self; ++ let mut flg = 0; ++ let mut header = vec![0u8; 10]; ++ match extra { ++ Some(v) => { ++ flg |= FEXTRA; ++ header.push((v.len() >> 0) as u8); ++ header.push((v.len() >> 8) as u8); ++ header.extend(v); ++ } ++ None => {} ++ } ++ match filename { ++ Some(filename) => { ++ flg |= FNAME; ++ header.extend(filename.as_bytes_with_nul().iter().map(|x| *x)); ++ } ++ None => {} ++ } ++ match comment { ++ Some(comment) => { ++ flg |= FCOMMENT; ++ header.extend(comment.as_bytes_with_nul().iter().map(|x| *x)); ++ } ++ None => {} ++ } ++ header[0] = 0x1f; ++ header[1] = 0x8b; ++ header[2] = 8; ++ header[3] = flg; ++ header[4] = (mtime >> 0) as u8; ++ header[5] = (mtime >> 8) as u8; ++ header[6] = (mtime >> 16) as u8; ++ header[7] = (mtime >> 24) as u8; ++ header[8] = match lvl { ++ Compression::Best => 2, ++ Compression::Fast => 4, ++ _ => 0, ++ }; ++ ++ // Typically this byte indicates what OS the gz stream was created on, ++ // but in an effort to have cross-platform reproducible streams just ++ // always set this to 255. I'm not sure that if we "correctly" set this ++ // it'd do anything anyway... ++ header[9] = 255; ++ return header; ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::io::prelude::*; ++ ++ use super::{read, write, Builder}; ++ use Compression::Default; ++ use rand::{thread_rng, Rng}; ++ ++ #[test] ++ fn roundtrip() { ++ let mut e = write::GzEncoder::new(Vec::new(), Default); ++ e.write_all(b"foo bar baz").unwrap(); ++ let inner = e.finish().unwrap(); ++ let mut d = read::GzDecoder::new(&inner[..]).unwrap(); ++ let mut s = String::new(); ++ d.read_to_string(&mut s).unwrap(); ++ assert_eq!(s, "foo bar baz"); ++ } ++ ++ #[test] ++ fn roundtrip_zero() { ++ let e = write::GzEncoder::new(Vec::new(), Default); ++ let inner = e.finish().unwrap(); ++ let mut d = read::GzDecoder::new(&inner[..]).unwrap(); ++ let mut s = String::new(); ++ d.read_to_string(&mut s).unwrap(); ++ assert_eq!(s, ""); ++ } ++ ++ #[test] ++ fn roundtrip_big() { ++ let mut real = Vec::new(); ++ let mut w = write::GzEncoder::new(Vec::new(), Default); ++ let v = thread_rng().gen_iter::().take(1024).collect::>(); ++ for _ in 0..200 { ++ let to_write = &v[..thread_rng().gen_range(0, v.len())]; ++ real.extend(to_write.iter().map(|x| *x)); ++ w.write_all(to_write).unwrap(); ++ } ++ let result = w.finish().unwrap(); ++ let mut r = read::GzDecoder::new(&result[..]).unwrap(); ++ let mut v = Vec::new(); ++ r.read_to_end(&mut v).unwrap(); ++ assert!(v == real); ++ } ++ ++ #[test] ++ fn roundtrip_big2() { ++ let v = thread_rng() ++ .gen_iter::() ++ .take(1024 * 1024) ++ .collect::>(); ++ let mut r = read::GzDecoder::new(read::GzEncoder::new(&v[..], Default)).unwrap(); ++ let mut res = Vec::new(); ++ r.read_to_end(&mut res).unwrap(); ++ assert!(res == v); ++ } ++ ++ #[test] ++ fn fields() { ++ let r = vec![0, 2, 4, 6]; ++ let e = Builder::new() ++ .filename("foo.rs") ++ .comment("bar") ++ .extra(vec![0, 1, 2, 3]) ++ .read(&r[..], Default); ++ let mut d = read::GzDecoder::new(e).unwrap(); ++ assert_eq!(d.header().filename(), Some(&b"foo.rs"[..])); ++ assert_eq!(d.header().comment(), Some(&b"bar"[..])); ++ assert_eq!(d.header().extra(), Some(&b"\x00\x01\x02\x03"[..])); ++ let mut res = Vec::new(); ++ d.read_to_end(&mut res).unwrap(); ++ assert_eq!(res, vec![0, 2, 4, 6]); ++ } ++ ++ #[test] ++ fn keep_reading_after_end() { ++ let mut e = write::GzEncoder::new(Vec::new(), Default); ++ e.write_all(b"foo bar baz").unwrap(); ++ let inner = e.finish().unwrap(); ++ let mut d = read::GzDecoder::new(&inner[..]).unwrap(); ++ let mut s = String::new(); ++ d.read_to_string(&mut s).unwrap(); ++ assert_eq!(s, "foo bar baz"); ++ d.read_to_string(&mut s).unwrap(); ++ assert_eq!(s, "foo bar baz"); ++ } ++ ++ #[test] ++ fn qc_reader() { ++ ::quickcheck::quickcheck(test as fn(_) -> _); ++ ++ fn test(v: Vec) -> bool { ++ let r = read::GzEncoder::new(&v[..], Default); ++ let mut r = read::GzDecoder::new(r).unwrap(); ++ let mut v2 = Vec::new(); ++ r.read_to_end(&mut v2).unwrap(); ++ v == v2 ++ } ++ } ++ ++ #[test] ++ fn flush_after_write() { ++ let mut f = write::GzEncoder::new(Vec::new(), Default); ++ write!(f, "Hello world").unwrap(); ++ f.flush().unwrap(); ++ } ++} diff --cc vendor/flate2-0.2.20/src/gz/read.rs index 000000000,000000000..c95e388a5 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/gz/read.rs @@@ -1,0 -1,0 +1,286 @@@ ++use std::io::prelude::*; ++use std::io; ++ ++use super::{Builder, Header}; ++use Compression; ++use bufreader::BufReader; ++use super::bufread; ++ ++/// A gzip streaming encoder ++/// ++/// This structure exposes a [`Read`] interface that will read uncompressed data ++/// from the underlying reader and expose the compressed version as a [`Read`] ++/// interface. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// use flate2::Compression; ++/// use flate2::read::GzEncoder; ++/// ++/// // Return a vector containing the GZ compressed version of hello world ++/// ++/// fn gzencode_hello_world() -> io::Result> { ++/// let mut ret_vec = [0;100]; ++/// let bytestring = b"hello world"; ++/// let mut gz = GzEncoder::new(&bytestring[..], Compression::Fast); ++/// let count = gz.read(&mut ret_vec)?; ++/// Ok(ret_vec[0..count].to_vec()) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct GzEncoder { ++ inner: bufread::GzEncoder>, ++} ++ ++pub fn gz_encoder(inner: bufread::GzEncoder>) ++ -> GzEncoder ++{ ++ GzEncoder { inner: inner } ++} ++ ++impl GzEncoder { ++ /// Creates a new encoder which will use the given compression level. ++ /// ++ /// The encoder is not configured specially for the emitted header. For ++ /// header configuration, see the `Builder` type. ++ /// ++ /// The data read from the stream `r` will be compressed and available ++ /// through the returned reader. ++ pub fn new(r: R, level: Compression) -> GzEncoder { ++ Builder::new().read(r, level) ++ } ++} ++ ++impl GzEncoder { ++ /// Acquires a reference to the underlying reader. ++ pub fn get_ref(&self) -> &R { ++ self.inner.get_ref().get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying reader. ++ /// ++ /// Note that mutation of the reader may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ self.inner.get_mut().get_mut() ++ } ++ ++ /// Returns the underlying stream, consuming this encoder ++ pub fn into_inner(self) -> R { ++ self.inner.into_inner().into_inner() ++ } ++} ++ ++impl Read for GzEncoder { ++ fn read(&mut self, into: &mut [u8]) -> io::Result { ++ self.inner.read(into) ++ } ++} ++ ++impl Write for GzEncoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++/// A gzip streaming decoder ++/// ++/// This structure exposes a [`Read`] interface that will consume compressed ++/// data from the underlying reader and emit uncompressed data. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++/// ++/// # Examples ++/// ++/// ``` ++/// ++/// use std::io::prelude::*; ++/// use std::io; ++/// # use flate2::Compression; ++/// # use flate2::write::GzEncoder; ++/// use flate2::read::GzDecoder; ++/// ++/// # fn main() { ++/// # let mut e = GzEncoder::new(Vec::new(), Compression::Default); ++/// # e.write(b"Hello World").unwrap(); ++/// # let bytes = e.finish().unwrap(); ++/// # println!("{}", decode_reader(bytes).unwrap()); ++/// # } ++/// # ++/// // Uncompresses a Gz Encoded vector of bytes and returns a string or error ++/// // Here &[u8] implements Read ++/// ++/// fn decode_reader(bytes: Vec) -> io::Result { ++/// let mut gz = GzDecoder::new(&bytes[..])?; ++/// let mut s = String::new(); ++/// gz.read_to_string(&mut s)?; ++/// Ok(s) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct GzDecoder { ++ inner: bufread::GzDecoder>, ++} ++ ++impl GzDecoder { ++ /// Creates a new decoder from the given reader, immediately parsing the ++ /// gzip header. ++ /// ++ /// # Errors ++ /// ++ /// If an error is encountered when parsing the gzip header, an error is ++ /// returned. ++ pub fn new(r: R) -> io::Result> { ++ bufread::GzDecoder::new(BufReader::new(r)).map(|r| GzDecoder { inner: r }) ++ } ++} ++ ++impl GzDecoder { ++ /// Returns the header associated with this stream. ++ pub fn header(&self) -> &Header { ++ self.inner.header() ++ } ++ ++ /// Acquires a reference to the underlying reader. ++ pub fn get_ref(&self) -> &R { ++ self.inner.get_ref().get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying stream. ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ self.inner.get_mut().get_mut() ++ } ++ ++ /// Consumes this decoder, returning the underlying reader. ++ pub fn into_inner(self) -> R { ++ self.inner.into_inner().into_inner() ++ } ++} ++ ++impl Read for GzDecoder { ++ fn read(&mut self, into: &mut [u8]) -> io::Result { ++ self.inner.read(into) ++ } ++} ++ ++impl Write for GzDecoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++/// A gzip streaming decoder that decodes all members of a multistream ++/// ++/// A gzip member consists of a header, compressed data and a trailer. The [gzip ++/// specification](https://tools.ietf.org/html/rfc1952), however, allows multiple ++/// gzip members to be joined in a single stream. `MultiGzDecoder` will ++/// decode all consecutive members while `GzDecoder` will only decompress the ++/// first gzip member. The multistream format is commonly used in bioinformatics, ++/// for example when using the BGZF compressed data. ++/// ++/// This structure exposes a [`Read`] interface that will consume all gzip members ++/// from the underlying reader and emit uncompressed data. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// # use flate2::Compression; ++/// # use flate2::write::GzEncoder; ++/// use flate2::read::MultiGzDecoder; ++/// ++/// # fn main() { ++/// # let mut e = GzEncoder::new(Vec::new(), Compression::Default); ++/// # e.write(b"Hello World").unwrap(); ++/// # let bytes = e.finish().unwrap(); ++/// # println!("{}", decode_reader(bytes).unwrap()); ++/// # } ++/// # ++/// // Uncompresses a Gz Encoded vector of bytes and returns a string or error ++/// // Here &[u8] implements Read ++/// ++/// fn decode_reader(bytes: Vec) -> io::Result { ++/// let mut gz = MultiGzDecoder::new(&bytes[..])?; ++/// let mut s = String::new(); ++/// gz.read_to_string(&mut s)?; ++/// Ok(s) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct MultiGzDecoder { ++ inner: bufread::MultiGzDecoder>, ++} ++ ++impl MultiGzDecoder { ++ /// Creates a new decoder from the given reader, immediately parsing the ++ /// (first) gzip header. If the gzip stream contains multiple members all will ++ /// be decoded. ++ /// ++ /// # Errors ++ /// ++ /// If an error is encountered when parsing the gzip header, an error is ++ /// returned. ++ pub fn new(r: R) -> io::Result> { ++ bufread::MultiGzDecoder::new(BufReader::new(r)).map(|r| MultiGzDecoder { inner: r }) ++ } ++} ++ ++impl MultiGzDecoder { ++ /// Returns the current header associated with this stream. ++ pub fn header(&self) -> &Header { ++ self.inner.header() ++ } ++ ++ /// Acquires a reference to the underlying reader. ++ pub fn get_ref(&self) -> &R { ++ self.inner.get_ref().get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying stream. ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ self.inner.get_mut().get_mut() ++ } ++ ++ /// Consumes this decoder, returning the underlying reader. ++ pub fn into_inner(self) -> R { ++ self.inner.into_inner().into_inner() ++ } ++} ++ ++impl Read for MultiGzDecoder { ++ fn read(&mut self, into: &mut [u8]) -> io::Result { ++ self.inner.read(into) ++ } ++} ++ ++impl Write for MultiGzDecoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} diff --cc vendor/flate2-0.2.20/src/gz/write.rs index 000000000,000000000..a9a10569a new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/gz/write.rs @@@ -1,0 -1,0 +1,182 @@@ ++use std::io::prelude::*; ++use std::io; ++ ++#[cfg(feature = "tokio")] ++use futures::Poll; ++#[cfg(feature = "tokio")] ++use tokio_io::{AsyncRead, AsyncWrite}; ++ ++use super::Builder; ++use {Compress, Compression}; ++use crc::Crc; ++use zio; ++ ++/// A gzip streaming encoder ++/// ++/// This structure exposes a [`Write`] interface that will emit compressed data ++/// to the underlying writer `W`. ++/// ++/// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use flate2::Compression; ++/// use flate2::write::GzEncoder; ++/// ++/// // Vec implements Write to print the compressed bytes of sample string ++/// # fn main() { ++/// ++/// let mut e = GzEncoder::new(Vec::new(), Compression::Default); ++/// e.write(b"Hello World").unwrap(); ++/// println!("{:?}", e.finish().unwrap()); ++/// # } ++/// ``` ++#[derive(Debug)] ++pub struct GzEncoder { ++ inner: zio::Writer, ++ crc: Crc, ++ crc_bytes_written: usize, ++ header: Vec, ++} ++ ++pub fn gz_encoder(header: Vec, w: W, lvl: Compression) -> GzEncoder { ++ GzEncoder { ++ inner: zio::Writer::new(w, Compress::new(lvl, false)), ++ crc: Crc::new(), ++ header: header, ++ crc_bytes_written: 0, ++ } ++} ++ ++impl GzEncoder { ++ /// Creates a new encoder which will use the given compression level. ++ /// ++ /// The encoder is not configured specially for the emitted header. For ++ /// header configuration, see the `Builder` type. ++ /// ++ /// The data written to the returned encoder will be compressed and then ++ /// written to the stream `w`. ++ pub fn new(w: W, level: Compression) -> GzEncoder { ++ Builder::new().write(w, level) ++ } ++ ++ /// Acquires a reference to the underlying writer. ++ pub fn get_ref(&self) -> &W { ++ self.inner.get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying writer. ++ /// ++ /// Note that mutation of the writer may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut W { ++ self.inner.get_mut() ++ } ++ ++ /// Attempt to finish this output stream, writing out final chunks of data. ++ /// ++ /// Note that this function can only be used once data has finished being ++ /// written to the output stream. After this function is called then further ++ /// calls to `write` may result in a panic. ++ /// ++ /// # Panics ++ /// ++ /// Attempts to write data to this stream may result in a panic after this ++ /// function is called. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn try_finish(&mut self) -> io::Result<()> { ++ try!(self.write_header()); ++ try!(self.inner.finish()); ++ ++ while self.crc_bytes_written < 8 { ++ let (sum, amt) = (self.crc.sum() as u32, self.crc.amount()); ++ let buf = [ ++ (sum >> 0) as u8, ++ (sum >> 8) as u8, ++ (sum >> 16) as u8, ++ (sum >> 24) as u8, ++ (amt >> 0) as u8, ++ (amt >> 8) as u8, ++ (amt >> 16) as u8, ++ (amt >> 24) as u8, ++ ]; ++ let inner = self.inner.get_mut(); ++ let n = try!(inner.write(&buf[self.crc_bytes_written..])); ++ self.crc_bytes_written += n; ++ } ++ Ok(()) ++ } ++ ++ /// Finish encoding this stream, returning the underlying writer once the ++ /// encoding is done. ++ /// ++ /// Note that this function may not be suitable to call in a situation where ++ /// the underlying stream is an asynchronous I/O stream. To finish a stream ++ /// the `try_finish` (or `shutdown`) method should be used instead. To ++ /// re-acquire ownership of a stream it is safe to call this method after ++ /// `try_finish` or `shutdown` has returned `Ok`. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn finish(mut self) -> io::Result { ++ try!(self.try_finish()); ++ Ok(self.inner.take_inner()) ++ } ++ ++ fn write_header(&mut self) -> io::Result<()> { ++ while self.header.len() > 0 { ++ let n = try!(self.inner.get_mut().write(&self.header)); ++ self.header.drain(..n); ++ } ++ Ok(()) ++ } ++} ++ ++impl Write for GzEncoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ assert_eq!(self.crc_bytes_written, 0); ++ try!(self.write_header()); ++ let n = try!(self.inner.write(buf)); ++ self.crc.update(&buf[..n]); ++ Ok(n) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ assert_eq!(self.crc_bytes_written, 0); ++ try!(self.write_header()); ++ self.inner.flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for GzEncoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ try_nb!(self.try_finish()); ++ self.get_mut().shutdown() ++ } ++} ++ ++impl Read for GzEncoder { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.get_mut().read(buf) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for GzEncoder {} ++ ++impl Drop for GzEncoder { ++ fn drop(&mut self) { ++ if self.inner.is_present() { ++ let _ = self.try_finish(); ++ } ++ } ++} diff --cc vendor/flate2-0.2.20/src/lib.rs index 000000000,000000000..3846913b9 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/lib.rs @@@ -1,0 -1,0 +1,308 @@@ ++//! A DEFLATE-based stream compression/decompression library ++//! ++//! This library is meant to supplement/replace the standard distributon's ++//! libflate library by providing a streaming encoder/decoder rather than purely ++//! an in-memory encoder/decoder. ++//! ++//! Like with [`libflate`], flate2 is based on [`miniz.c`][1] ++//! ++//! [1]: https://code.google.com/p/miniz/ ++//! [`libflate`]: https://docs.rs/crate/libflate/ ++//! ++//! # Organization ++//! ++//! This crate consists mainly of two modules, [`read`] and [`write`]. Each ++//! module contains a number of types used to encode and decode various streams ++//! of data. All types in the [`write`] module work on instances of [`Write`], ++//! whereas all types in the [`read`] module work on instances of [`Read`]. ++//! ++//! ``` ++//! use flate2::write::GzEncoder; ++//! use flate2::Compression; ++//! use std::io; ++//! use std::io::prelude::*; ++//! ++//! # fn main() { let _ = run(); } ++//! # fn run() -> io::Result<()> { ++//! let mut encoder = GzEncoder::new(Vec::new(), Compression::Default); ++//! encoder.write(b"Example")?; ++//! # Ok(()) ++//! # } ++//! ``` ++//! ++//! ++//! Other various types are provided at the top-level of the crate for ++//! management and dealing with encoders/decoders. ++//! ++//! [`read`]: read/index.html ++//! [`write`]: write/index.html ++//! [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++//! [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html ++//! ++//! # Helper traits ++//! ++//! There are two helper traits provided: [`FlateReadExt`] and [`FlateWriteExt`]. ++//! These provide convenience methods for creating a decoder/encoder out of an ++//! already existing stream to chain construction. ++//! ++//! [`FlateReadExt`]: trait.FlateReadExt.html ++//! [`FlateWriteExt`]: trait.FlateWriteExt.html ++//! ++//! ``` ++//! use flate2::{FlateReadExt, Compression}; ++//! use std::io::prelude::*; ++//! use std::io; ++//! use std::fs::File; ++//! ++//! # fn main() { ++//! # println!("{}", run().unwrap()); ++//! # } ++//! # ++//! // Read contents of file with a compression stream, then decompress with GZ ++//! ++//! # fn run() -> io::Result { ++//! let f = File::open("examples/hello_world.txt")?; ++//! ++//! //gz_encode method comes from FlateReadExt and applies to a std::fs::File ++//! let data = f.gz_encode(Compression::Default); ++//! let mut buffer = String::new(); ++//! ++//! //gz_decode method comes from FlateReadExt and applies to a &[u8] ++//! &data.gz_decode()?.read_to_string(&mut buffer)?; ++//! # Ok(buffer) ++//! # } ++//! ``` ++//! ++//! # Async I/O ++//! ++//! This crate optionally can support async I/O streams with the [Tokio stack] via ++//! the `tokio` feature of this crate: ++//! ++//! [Tokio stack]: https://tokio.rs/ ++//! ++//! ```toml ++//! flate2 = { version = "0.2", features = ["tokio"] } ++//! ``` ++//! ++//! All methods are internally capable of working with streams that may return ++//! [`ErrorKind::WouldBlock`] when they're not ready to perform the particular ++//! operation. ++//! ++//! [`ErrorKind::WouldBlock`]: https://doc.rust-lang.org/std/io/enum.ErrorKind.html ++//! ++//! Note that care needs to be taken when using these objects, however. The ++//! Tokio runtime, in particular, requires that data is fully flushed before ++//! dropping streams. For compatibility with blocking streams all streams are ++//! flushed/written when they are dropped, and this is not always a suitable ++//! time to perform I/O. If I/O streams are flushed before drop, however, then ++//! these operations will be a noop. ++#![doc(html_root_url = "https://docs.rs/flate2/0.2")] ++#![deny(missing_docs)] ++#![deny(missing_debug_implementations)] ++#![allow(trivial_numeric_casts)] ++#![cfg_attr(test, deny(warnings))] ++ ++#[cfg(feature = "tokio")] ++extern crate futures; ++extern crate libc; ++#[cfg(test)] ++extern crate quickcheck; ++#[cfg(test)] ++extern crate rand; ++#[cfg(feature = "tokio")] ++#[macro_use] ++extern crate tokio_io; ++ ++use std::io::prelude::*; ++use std::io; ++ ++pub use gz::Builder as GzBuilder; ++pub use gz::Header as GzHeader; ++pub use mem::{Compress, DataError, Decompress, Flush, Status}; ++pub use crc::{Crc, CrcReader}; ++ ++mod bufreader; ++mod crc; ++mod deflate; ++mod ffi; ++mod gz; ++mod zio; ++mod mem; ++mod zlib; ++ ++/// Types which operate over [`Read`] streams, both encoders and decoders for ++/// various formats. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++pub mod read { ++ pub use deflate::read::DeflateEncoder; ++ pub use deflate::read::DeflateDecoder; ++ pub use zlib::read::ZlibEncoder; ++ pub use zlib::read::ZlibDecoder; ++ pub use gz::read::GzEncoder; ++ pub use gz::read::GzDecoder; ++ pub use gz::read::MultiGzDecoder; ++} ++ ++/// Types which operate over [`Write`] streams, both encoders and decoders for ++/// various formats. ++/// ++/// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html ++pub mod write { ++ pub use deflate::write::DeflateEncoder; ++ pub use deflate::write::DeflateDecoder; ++ pub use zlib::write::ZlibEncoder; ++ pub use zlib::write::ZlibDecoder; ++ pub use gz::write::GzEncoder; ++} ++ ++/// Types which operate over [`BufRead`] streams, both encoders and decoders for ++/// various formats. ++/// ++/// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html ++pub mod bufread { ++ pub use deflate::bufread::DeflateEncoder; ++ pub use deflate::bufread::DeflateDecoder; ++ pub use zlib::bufread::ZlibEncoder; ++ pub use zlib::bufread::ZlibDecoder; ++ pub use gz::bufread::GzEncoder; ++ pub use gz::bufread::GzDecoder; ++ pub use gz::bufread::MultiGzDecoder; ++} ++ ++fn _assert_send_sync() { ++ fn _assert_send_sync() {} ++ ++ _assert_send_sync::>(); ++ _assert_send_sync::>(); ++ _assert_send_sync::>(); ++ _assert_send_sync::>(); ++ _assert_send_sync::>(); ++ _assert_send_sync::>(); ++ _assert_send_sync::>(); ++ _assert_send_sync::>>(); ++ _assert_send_sync::>>(); ++ _assert_send_sync::>>(); ++ _assert_send_sync::>>(); ++ _assert_send_sync::>>(); ++} ++ ++/// When compressing data, the compression level can be specified by a value in ++/// this enum. ++#[derive(Copy, Clone, PartialEq, Eq, Debug)] ++pub enum Compression { ++ /// No compression is to be performed, this may actually inflate data ++ /// slightly when encoding. ++ None = 0, ++ /// Optimize for the best speed of encoding. ++ Fast = 1, ++ /// Optimize for the size of data being encoded. ++ Best = 9, ++ /// Choose the default compression, a balance between speed and size. ++ Default = 6, ++} ++ ++/// Default to Compression::Default. ++impl Default for Compression { ++ fn default() -> Compression { ++ Compression::Default ++ } ++} ++ ++/// A helper trait to create encoder/decoders with method syntax. ++pub trait FlateReadExt: Read + Sized { ++ /// Consume this reader to create a compression stream at the specified ++ /// compression level. ++ fn gz_encode(self, lvl: Compression) -> read::GzEncoder { ++ read::GzEncoder::new(self, lvl) ++ } ++ ++ /// Consume this reader to create a decompression stream of this stream. ++ fn gz_decode(self) -> io::Result> { ++ read::GzDecoder::new(self) ++ } ++ ++ /// Consume this reader to create a compression stream at the specified ++ /// compression level. ++ fn zlib_encode(self, lvl: Compression) -> read::ZlibEncoder { ++ read::ZlibEncoder::new(self, lvl) ++ } ++ ++ /// Consume this reader to create a decompression stream of this stream. ++ fn zlib_decode(self) -> read::ZlibDecoder { ++ read::ZlibDecoder::new(self) ++ } ++ ++ /// Consume this reader to create a compression stream at the specified ++ /// compression level. ++ fn deflate_encode(self, lvl: Compression) -> read::DeflateEncoder { ++ read::DeflateEncoder::new(self, lvl) ++ } ++ ++ /// Consume this reader to create a decompression stream of this stream. ++ fn deflate_decode(self) -> read::DeflateDecoder { ++ read::DeflateDecoder::new(self) ++ } ++} ++ ++/// A helper trait to create encoder/decoders with method syntax. ++pub trait FlateWriteExt: Write + Sized { ++ /// Consume this writer to create a compression stream at the specified ++ /// compression level. ++ fn gz_encode(self, lvl: Compression) -> write::GzEncoder { ++ write::GzEncoder::new(self, lvl) ++ } ++ ++ // TODO: coming soon to a theater near you! ++ // /// Consume this writer to create a decompression stream of this stream. ++ // fn gz_decode(self) -> IoResult> { ++ // write::GzDecoder::new(self) ++ // } ++ ++ /// Consume this writer to create a compression stream at the specified ++ /// compression level. ++ fn zlib_encode(self, lvl: Compression) -> write::ZlibEncoder { ++ write::ZlibEncoder::new(self, lvl) ++ } ++ ++ /// Consume this writer to create a decompression stream of this stream. ++ fn zlib_decode(self) -> write::ZlibDecoder { ++ write::ZlibDecoder::new(self) ++ } ++ ++ /// Consume this writer to create a compression stream at the specified ++ /// compression level. ++ fn deflate_encode(self, lvl: Compression) -> write::DeflateEncoder { ++ write::DeflateEncoder::new(self, lvl) ++ } ++ ++ /// Consume this writer to create a decompression stream of this stream. ++ fn deflate_decode(self) -> write::DeflateDecoder { ++ write::DeflateDecoder::new(self) ++ } ++} ++ ++impl FlateReadExt for T {} ++impl FlateWriteExt for T {} ++ ++#[cfg(test)] ++mod test { ++ use std::io::prelude::*; ++ use {Compression, FlateReadExt}; ++ ++ #[test] ++ fn crazy() { ++ let rdr = &mut b"foobar"; ++ let mut res = Vec::new(); ++ rdr.gz_encode(Compression::Default) ++ .deflate_encode(Compression::Default) ++ .zlib_encode(Compression::Default) ++ .zlib_decode() ++ .deflate_decode() ++ .gz_decode() ++ .unwrap() ++ .read_to_end(&mut res) ++ .unwrap(); ++ assert_eq!(res, b"foobar"); ++ } ++} diff --cc vendor/flate2-0.2.20/src/mem.rs index 000000000,000000000..3eaf36abe new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/mem.rs @@@ -1,0 -1,0 +1,516 @@@ ++use std::error::Error; ++use std::fmt; ++use std::io; ++use std::marker; ++use std::slice; ++ ++use libc::{c_int, c_uint}; ++ ++use Compression; ++use ffi; ++ ++/// Raw in-memory compression stream for blocks of data. ++/// ++/// This type is the building block for the I/O streams in the rest of this ++/// crate. It requires more management than the [`Read`]/[`Write`] API but is ++/// maximally flexible in terms of accepting input from any source and being ++/// able to produce output to any memory location. ++/// ++/// It is recommended to use the I/O stream adaptors over this type as they're ++/// easier to use. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++/// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html ++#[derive(Debug)] ++pub struct Compress { ++ inner: Stream, ++} ++ ++/// Raw in-memory decompression stream for blocks of data. ++/// ++/// This type is the building block for the I/O streams in the rest of this ++/// crate. It requires more management than the [`Read`]/[`Write`] API but is ++/// maximally flexible in terms of accepting input from any source and being ++/// able to produce output to any memory location. ++/// ++/// It is recommended to use the I/O stream adaptors over this type as they're ++/// easier to use. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++/// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html ++#[derive(Debug)] ++pub struct Decompress { ++ inner: Stream, ++} ++ ++#[derive(Debug)] ++struct Stream { ++ stream_wrapper: ffi::StreamWrapper, ++ total_in: u64, ++ total_out: u64, ++ _marker: marker::PhantomData, ++} ++ ++unsafe impl Send for Stream {} ++unsafe impl Sync for Stream {} ++ ++trait Direction { ++ unsafe fn destroy(stream: *mut ffi::mz_stream) -> c_int; ++} ++ ++#[derive(Debug)] ++enum DirCompress {} ++#[derive(Debug)] ++enum DirDecompress {} ++ ++/// Values which indicate the form of flushing to be used when compressing or ++/// decompressing in-memory data. ++#[derive(Copy, Clone, PartialEq, Eq, Debug)] ++pub enum Flush { ++ /// A typical parameter for passing to compression/decompression functions, ++ /// this indicates that the underlying stream to decide how much data to ++ /// accumulate before producing output in order to maximize compression. ++ None = ffi::MZ_NO_FLUSH as isize, ++ ++ /// All pending output is flushed to the output buffer and the output is ++ /// aligned on a byte boundary so that the decompressor can get all input ++ /// data available so far. ++ /// ++ /// Flushing may degrade compression for some compression algorithms and so ++ /// it should only be used when necessary. This will complete the current ++ /// deflate block and follow it with an empty stored block. ++ Sync = ffi::MZ_SYNC_FLUSH as isize, ++ ++ /// All pending output is flushed to the output buffer, but the output is ++ /// not aligned to a byte boundary. ++ /// ++ /// All of the input data so far will be available to the decompressor (as ++ /// with `Flush::Sync`. This completes the current deflate block and follows ++ /// it with an empty fixed codes block that is 10 bites long, and it assures ++ /// that enough bytes are output in order for the decompessor to finish the ++ /// block before the empty fixed code block. ++ Partial = ffi::MZ_PARTIAL_FLUSH as isize, ++ ++ /// A deflate block is completed and emitted, as for `Flush::Sync`, but the ++ /// output is not aligned on a byte boundary and up to seven vits of the ++ /// current block are held to be written as the next byte after the next ++ /// deflate block is completed. ++ /// ++ /// In this case the decompressor may not be provided enough bits at this ++ /// point in order to complete decompression of the data provided so far to ++ /// the compressor, it may need to wait for the next block to be emitted. ++ /// This is for advanced applications that need to control the emission of ++ /// deflate blocks. ++ Block = ffi::MZ_BLOCK as isize, ++ ++ /// All output is flushed as with `Flush::Sync` and the compression state is ++ /// reset so decompression can restart from this point if previous ++ /// compressed data has been damaged or if random access is desired. ++ /// ++ /// Using this option too often can seriously degrade compression. ++ Full = ffi::MZ_FULL_FLUSH as isize, ++ ++ /// Pending input is processed and pending output is flushed. ++ /// ++ /// The return value may indicate that the stream is not yet done and more ++ /// data has yet to be processed. ++ Finish = ffi::MZ_FINISH as isize, ++} ++ ++/// Error returned when a decompression object finds that the input stream of ++/// bytes was not a valid input stream of bytes. ++#[derive(Debug)] ++pub struct DataError(()); ++ ++/// Possible status results of compressing some data or successfully ++/// decompressing a block of data. ++#[derive(Copy, Clone, PartialEq, Eq, Debug)] ++pub enum Status { ++ /// Indicates success. ++ /// ++ /// Means that more input may be needed but isn't available ++ /// and/or there' smore output to be written but the output buffer is full. ++ Ok, ++ ++ /// Indicates that forward progress is not possible due to input or output ++ /// buffers being empty. ++ /// ++ /// For compression it means the input buffer needs some more data or the ++ /// output buffer needs to be freed up before trying again. ++ /// ++ /// For decompression this means that more input is needed to continue or ++ /// the output buffer isn't large enough to contain the result. The function ++ /// can be called again after fixing both. ++ BufError, ++ ++ /// Indicates that all input has been consumed and all output bytes have ++ /// been written. Decompression/compression should not be called again. ++ /// ++ /// For decompression with zlib streams the adler-32 of the decompressed ++ /// data has also been verified. ++ StreamEnd, ++} ++ ++impl Compress { ++ /// Creates a new object ready for compressing data that it's given. ++ /// ++ /// The `level` argument here indicates what level of compression is going ++ /// to be performed, and the `zlib_header` argument indicates whether the ++ /// output data should have a zlib header or not. ++ pub fn new(level: Compression, zlib_header: bool) -> Compress { ++ unsafe { ++ let mut state = ffi::StreamWrapper::default(); ++ let ret = ffi::mz_deflateInit2(&mut *state, ++ level as c_int, ++ ffi::MZ_DEFLATED, ++ if zlib_header { ++ ffi::MZ_DEFAULT_WINDOW_BITS ++ } else { ++ -ffi::MZ_DEFAULT_WINDOW_BITS ++ }, ++ 9, ++ ffi::MZ_DEFAULT_STRATEGY); ++ debug_assert_eq!(ret, 0); ++ Compress { ++ inner: Stream { ++ stream_wrapper: state, ++ total_in: 0, ++ total_out: 0, ++ _marker: marker::PhantomData, ++ }, ++ } ++ } ++ } ++ ++ /// Returns the total number of input bytes which have been processed by ++ /// this compression object. ++ pub fn total_in(&self) -> u64 { ++ self.inner.total_in ++ } ++ ++ /// Returns the total number of output bytes which have been produced by ++ /// this compression object. ++ pub fn total_out(&self) -> u64 { ++ self.inner.total_out ++ } ++ ++ /// Quickly resets this compressor without having to reallocate anything. ++ /// ++ /// This is equivalent to dropping this object and then creating a new one. ++ pub fn reset(&mut self) { ++ let rc = unsafe { ffi::mz_deflateReset(&mut *self.inner.stream_wrapper) }; ++ assert_eq!(rc, ffi::MZ_OK); ++ ++ self.inner.total_in = 0; ++ self.inner.total_out = 0; ++ } ++ ++ /// Compresses the input data into the output, consuming only as much ++ /// input as needed and writing as much output as possible. ++ /// ++ /// The flush option can be any of the available flushing parameters. ++ /// ++ /// To learn how much data was consumed or how much output was produced, use ++ /// the `total_in` and `total_out` functions before/after this is called. ++ pub fn compress(&mut self, ++ input: &[u8], ++ output: &mut [u8], ++ flush: Flush) ++ -> Status { ++ let raw = &mut *self.inner.stream_wrapper; ++ raw.next_in = input.as_ptr() as *mut _; ++ raw.avail_in = input.len() as c_uint; ++ raw.next_out = output.as_mut_ptr(); ++ raw.avail_out = output.len() as c_uint; ++ ++ let rc = unsafe { ffi::mz_deflate(raw, flush as c_int) }; ++ ++ // Unfortunately the total counters provided by zlib might be only ++ // 32 bits wide and overflow while processing large amounts of data. ++ self.inner.total_in += (raw.next_in as usize - ++ input.as_ptr() as usize) as u64; ++ self.inner.total_out += (raw.next_out as usize - ++ output.as_ptr() as usize) as u64; ++ ++ match rc { ++ ffi::MZ_OK => Status::Ok, ++ ffi::MZ_BUF_ERROR => Status::BufError, ++ ffi::MZ_STREAM_END => Status::StreamEnd, ++ c => panic!("unknown return code: {}", c), ++ } ++ } ++ ++ /// Compresses the input data into the extra space of the output, consuming ++ /// only as much input as needed and writing as much output as possible. ++ /// ++ /// This function has the same semantics as `compress`, except that the ++ /// length of `vec` is managed by this function. This will not reallocate ++ /// the vector provided or attempt to grow it, so space for the output must ++ /// be reserved in the output vector by the caller before calling this ++ /// function. ++ pub fn compress_vec(&mut self, ++ input: &[u8], ++ output: &mut Vec, ++ flush: Flush) ++ -> Status { ++ let cap = output.capacity(); ++ let len = output.len(); ++ ++ unsafe { ++ let before = self.total_out(); ++ let ret = { ++ let ptr = output.as_mut_ptr().offset(len as isize); ++ let out = slice::from_raw_parts_mut(ptr, cap - len); ++ self.compress(input, out, flush) ++ }; ++ output.set_len((self.total_out() - before) as usize + len); ++ return ret ++ } ++ } ++} ++ ++impl Decompress { ++ /// Creates a new object ready for decompressing data that it's given. ++ /// ++ /// The `zlib_header` argument indicates whether the input data is expected ++ /// to have a zlib header or not. ++ pub fn new(zlib_header: bool) -> Decompress { ++ unsafe { ++ let mut state = ffi::StreamWrapper::default(); ++ let ret = ffi::mz_inflateInit2(&mut *state, ++ if zlib_header { ++ ffi::MZ_DEFAULT_WINDOW_BITS ++ } else { ++ -ffi::MZ_DEFAULT_WINDOW_BITS ++ }); ++ debug_assert_eq!(ret, 0); ++ Decompress { ++ inner: Stream { ++ stream_wrapper: state, ++ total_in: 0, ++ total_out: 0, ++ _marker: marker::PhantomData, ++ }, ++ } ++ } ++ } ++ ++ /// Returns the total number of input bytes which have been processed by ++ /// this decompression object. ++ pub fn total_in(&self) -> u64 { ++ self.inner.total_in ++ } ++ ++ /// Returns the total number of output bytes which have been produced by ++ /// this decompression object. ++ pub fn total_out(&self) -> u64 { ++ self.inner.total_out ++ } ++ ++ /// Decompresses the input data into the output, consuming only as much ++ /// input as needed and writing as much output as possible. ++ /// ++ /// The flush option provided can either be `Flush::None`, `Flush::Sync`, ++ /// or `Flush::Finish`. If the first call passes `Flush::Finish` it is ++ /// assumed that the input and output buffers are both sized large enough to ++ /// decompress the entire stream in a single call. ++ /// ++ /// A flush value of `Flush::Finish` indicates that there are no more source ++ /// bytes available beside what's already in the input buffer, and the ++ /// output buffer is large enough to hold the rest of the decompressed data. ++ /// ++ /// To learn how much data was consumed or how much output was produced, use ++ /// the `total_in` and `total_out` functions before/after this is called. ++ /// ++ /// # Errors ++ /// ++ /// If the input data to this instance of `Decompress` is not a valid ++ /// zlib/deflate stream then this function may return an instance of ++ /// `DataError` to indicate that the stream of input bytes is corrupted. ++ pub fn decompress(&mut self, ++ input: &[u8], ++ output: &mut [u8], ++ flush: Flush) ++ -> Result { ++ let raw = &mut *self.inner.stream_wrapper; ++ raw.next_in = input.as_ptr() as *mut u8; ++ raw.avail_in = input.len() as c_uint; ++ raw.next_out = output.as_mut_ptr(); ++ raw.avail_out = output.len() as c_uint; ++ ++ let rc = unsafe { ffi::mz_inflate(raw, flush as c_int) }; ++ ++ // Unfortunately the total counters provided by zlib might be only ++ // 32 bits wide and overflow while processing large amounts of data. ++ self.inner.total_in += (raw.next_in as usize - ++ input.as_ptr() as usize) as u64; ++ self.inner.total_out += (raw.next_out as usize - ++ output.as_ptr() as usize) as u64; ++ ++ match rc { ++ ffi::MZ_DATA_ERROR | ++ ffi::MZ_STREAM_ERROR => Err(DataError(())), ++ ffi::MZ_OK => Ok(Status::Ok), ++ ffi::MZ_BUF_ERROR => Ok(Status::BufError), ++ ffi::MZ_STREAM_END => Ok(Status::StreamEnd), ++ c => panic!("unknown return code: {}", c), ++ } ++ } ++ ++ /// Decompresses the input data into the extra space in the output vector ++ /// specified by `output`. ++ /// ++ /// This function has the same semantics as `decompress`, except that the ++ /// length of `vec` is managed by this function. This will not reallocate ++ /// the vector provided or attempt to grow it, so space for the output must ++ /// be reserved in the output vector by the caller before calling this ++ /// function. ++ /// ++ /// # Errors ++ /// ++ /// If the input data to this instance of `Decompress` is not a valid ++ /// zlib/deflate stream then this function may return an instance of ++ /// `DataError` to indicate that the stream of input bytes is corrupted. ++ pub fn decompress_vec(&mut self, ++ input: &[u8], ++ output: &mut Vec, ++ flush: Flush) ++ -> Result { ++ let cap = output.capacity(); ++ let len = output.len(); ++ ++ unsafe { ++ let before = self.total_out(); ++ let ret = { ++ let ptr = output.as_mut_ptr().offset(len as isize); ++ let out = slice::from_raw_parts_mut(ptr, cap - len); ++ self.decompress(input, out, flush) ++ }; ++ output.set_len((self.total_out() - before) as usize + len); ++ return ret ++ } ++ } ++ ++ /// Performs the equivalent of replacing this decompression state with a ++ /// freshly allocated copy. ++ /// ++ /// This function may not allocate memory, though, and attempts to reuse any ++ /// previously existing resources. ++ /// ++ /// The argument provided here indicates whether the reset state will ++ /// attempt to decode a zlib header first or not. ++ pub fn reset(&mut self, zlib_header: bool) { ++ self._reset(zlib_header); ++ } ++ ++ #[cfg(feature = "zlib")] ++ fn _reset(&mut self, zlib_header: bool) { ++ let bits = if zlib_header { ++ ffi::MZ_DEFAULT_WINDOW_BITS ++ } else { ++ -ffi::MZ_DEFAULT_WINDOW_BITS ++ }; ++ unsafe { ++ ffi::inflateReset2(&mut *self.inner.stream_wrapper, bits); ++ } ++ self.inner.total_out = 0; ++ self.inner.total_in = 0; ++ } ++ ++ #[cfg(not(feature = "zlib"))] ++ fn _reset(&mut self, zlib_header: bool) { ++ *self = Decompress::new(zlib_header); ++ } ++} ++ ++impl Error for DataError { ++ fn description(&self) -> &str { "deflate data error" } ++} ++ ++impl From for io::Error { ++ fn from(data: DataError) -> io::Error { ++ io::Error::new(io::ErrorKind::Other, data) ++ } ++} ++ ++impl fmt::Display for DataError { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ self.description().fmt(f) ++ } ++} ++ ++impl Direction for DirCompress { ++ unsafe fn destroy(stream: *mut ffi::mz_stream) -> c_int { ++ ffi::mz_deflateEnd(stream) ++ } ++} ++impl Direction for DirDecompress { ++ unsafe fn destroy(stream: *mut ffi::mz_stream) -> c_int { ++ ffi::mz_inflateEnd(stream) ++ } ++} ++ ++impl Drop for Stream { ++ fn drop(&mut self) { ++ unsafe { ++ let _ = D::destroy(&mut *self.stream_wrapper); ++ } ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::io::Write; ++ ++ use write; ++ use {Compression, Decompress, Flush}; ++ ++ #[test] ++ fn issue51() { ++ let data = vec![ ++ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xb3, 0xc9, ++ 0x28, 0xc9, 0xcd, 0xb1, 0xe3, 0xe5, 0xb2, 0xc9, 0x48, 0x4d, 0x4c, 0xb1, ++ 0xb3, 0x29, 0xc9, 0x2c, 0xc9, 0x49, 0xb5, 0x33, 0x31, 0x30, 0x51, 0xf0, ++ 0xcb, 0x2f, 0x51, 0x70, 0xcb, 0x2f, 0xcd, 0x4b, 0xb1, 0xd1, 0x87, 0x08, ++ 0xda, 0xe8, 0x83, 0x95, 0x00, 0x95, 0x26, 0xe5, 0xa7, 0x54, 0x2a, 0x24, ++ 0xa5, 0x27, 0xe7, 0xe7, 0xe4, 0x17, 0xd9, 0x2a, 0x95, 0x67, 0x64, 0x96, ++ 0xa4, 0x2a, 0x81, 0x8c, 0x48, 0x4e, 0xcd, 0x2b, 0x49, 0x2d, 0xb2, 0xb3, ++ 0xc9, 0x30, 0x44, 0x37, 0x01, 0x28, 0x62, 0xa3, 0x0f, 0x95, 0x06, 0xd9, ++ 0x05, 0x54, 0x04, 0xe5, 0xe5, 0xa5, 0x67, 0xe6, 0x55, 0xe8, 0x1b, 0xea, ++ 0x99, 0xe9, 0x19, 0x21, 0xab, 0xd0, 0x07, 0xd9, 0x01, 0x32, 0x53, 0x1f, ++ 0xea, 0x3e, 0x00, 0x94, 0x85, 0xeb, 0xe4, 0xa8, 0x00, 0x00, 0x00 ++ ]; ++ ++ let mut decoded = Vec::with_capacity(data.len()*2); ++ ++ let mut d = Decompress::new(false); ++ // decompressed whole deflate stream ++ assert!(d.decompress_vec(&data[10..], &mut decoded, Flush::Finish).is_ok()); ++ ++ // decompress data that has nothing to do with the deflate stream (this ++ // used to panic) ++ drop(d.decompress_vec(&[0], &mut decoded, Flush::None)); ++ } ++ ++ #[test] ++ fn reset() { ++ let string = "hello world".as_bytes(); ++ let mut zlib = Vec::new(); ++ let mut deflate = Vec::new(); ++ ++ let comp = Compression::Default; ++ write::ZlibEncoder::new(&mut zlib, comp).write_all(string).unwrap(); ++ write::DeflateEncoder::new(&mut deflate, comp).write_all(string).unwrap(); ++ ++ let mut dst = [0; 1024]; ++ let mut decoder = Decompress::new(true); ++ decoder.decompress(&zlib, &mut dst, Flush::Finish).unwrap(); ++ assert_eq!(decoder.total_out(), string.len() as u64); ++ assert!(dst.starts_with(string)); ++ ++ decoder.reset(false); ++ decoder.decompress(&deflate, &mut dst, Flush::Finish).unwrap(); ++ assert_eq!(decoder.total_out(), string.len() as u64); ++ assert!(dst.starts_with(string)); ++ } ++} diff --cc vendor/flate2-0.2.20/src/zio.rs index 000000000,000000000..358ffb326 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/zio.rs @@@ -1,0 -1,0 +1,201 @@@ ++use std::io::prelude::*; ++use std::io; ++use std::mem; ++ ++use {Decompress, Compress, Status, Flush, DataError}; ++ ++#[derive(Debug)] ++pub struct Writer { ++ obj: Option, ++ pub data: D, ++ buf: Vec, ++} ++ ++pub trait Ops { ++ fn total_in(&self) -> u64; ++ fn total_out(&self) -> u64; ++ fn run(&mut self, input: &[u8], output: &mut [u8], flush: Flush) ++ -> Result; ++ fn run_vec(&mut self, input: &[u8], output: &mut Vec, flush: Flush) ++ -> Result; ++} ++ ++impl Ops for Compress { ++ fn total_in(&self) -> u64 { self.total_in() } ++ fn total_out(&self) -> u64 { self.total_out() } ++ fn run(&mut self, input: &[u8], output: &mut [u8], flush: Flush) ++ -> Result { ++ Ok(self.compress(input, output, flush)) ++ } ++ fn run_vec(&mut self, input: &[u8], output: &mut Vec, flush: Flush) ++ -> Result { ++ Ok(self.compress_vec(input, output, flush)) ++ } ++} ++ ++impl Ops for Decompress { ++ fn total_in(&self) -> u64 { self.total_in() } ++ fn total_out(&self) -> u64 { self.total_out() } ++ fn run(&mut self, input: &[u8], output: &mut [u8], flush: Flush) ++ -> Result { ++ self.decompress(input, output, flush) ++ } ++ fn run_vec(&mut self, input: &[u8], output: &mut Vec, flush: Flush) ++ -> Result { ++ self.decompress_vec(input, output, flush) ++ } ++} ++ ++pub fn read(obj: &mut R, data: &mut D, dst: &mut [u8]) -> io::Result ++ where R: BufRead, D: Ops ++{ ++ loop { ++ let (read, consumed, ret, eof); ++ { ++ let input = try!(obj.fill_buf()); ++ eof = input.is_empty(); ++ let before_out = data.total_out(); ++ let before_in = data.total_in(); ++ let flush = if eof {Flush::Finish} else {Flush::None}; ++ ret = data.run(input, dst, flush); ++ read = (data.total_out() - before_out) as usize; ++ consumed = (data.total_in() - before_in) as usize; ++ } ++ obj.consume(consumed); ++ ++ match ret { ++ // If we haven't ready any data and we haven't hit EOF yet, ++ // then we need to keep asking for more data because if we ++ // return that 0 bytes of data have been read then it will ++ // be interpreted as EOF. ++ Ok(Status::Ok) | ++ Ok(Status::BufError) if read == 0 && !eof && dst.len() > 0 => { ++ continue ++ } ++ Ok(Status::Ok) | ++ Ok(Status::BufError) | ++ Ok(Status::StreamEnd) => return Ok(read), ++ ++ Err(..) => return Err(io::Error::new(io::ErrorKind::InvalidInput, ++ "corrupt deflate stream")) ++ } ++ } ++} ++ ++impl Writer { ++ pub fn new(w: W, d: D) -> Writer { ++ Writer { ++ obj: Some(w), ++ data: d, ++ buf: Vec::with_capacity(32 * 1024), ++ } ++ } ++ ++ pub fn finish(&mut self) -> io::Result<()> { ++ loop { ++ try!(self.dump()); ++ ++ let before = self.data.total_out(); ++ try!(self.data.run_vec(&[], &mut self.buf, Flush::Finish)); ++ if before == self.data.total_out() { ++ return Ok(()) ++ } ++ } ++ } ++ ++ pub fn replace(&mut self, w: W) -> W { ++ self.buf.truncate(0); ++ mem::replace(self.get_mut(), w) ++ } ++ ++ pub fn get_ref(&self) -> &W { ++ self.obj.as_ref().unwrap() ++ } ++ ++ pub fn get_mut(&mut self) -> &mut W { ++ self.obj.as_mut().unwrap() ++ } ++ ++ // Note that this should only be called if the outer object is just about ++ // to be consumed! ++ // ++ // (e.g. an implementation of `into_inner`) ++ pub fn take_inner(&mut self) -> W { ++ self.obj.take().unwrap() ++ } ++ ++ pub fn is_present(&self) -> bool { ++ self.obj.is_some() ++ } ++ ++ fn dump(&mut self) -> io::Result<()> { ++ // TODO: should manage this buffer not with `drain` but probably more of ++ // a deque-like strategy. ++ while self.buf.len() > 0 { ++ let n = try!(self.obj.as_mut().unwrap().write(&self.buf)); ++ if n == 0 { ++ return Err(io::ErrorKind::WriteZero.into()) ++ } ++ self.buf.drain(..n); ++ } ++ Ok(()) ++ } ++} ++ ++impl Write for Writer { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ // miniz isn't guaranteed to actually write any of the buffer provided, ++ // it may be in a flushing mode where it's just giving us data before ++ // we're actually giving it any data. We don't want to spuriously return ++ // `Ok(0)` when possible as it will cause calls to write_all() to fail. ++ // As a result we execute this in a loop to ensure that we try our ++ // darndest to write the data. ++ loop { ++ try!(self.dump()); ++ ++ let before_in = self.data.total_in(); ++ let ret = self.data.run_vec(buf, &mut self.buf, Flush::None); ++ let written = (self.data.total_in() - before_in) as usize; ++ ++ if buf.len() > 0 && written == 0 && ret.is_ok() { ++ continue ++ } ++ return match ret { ++ Ok(Status::Ok) | ++ Ok(Status::BufError) | ++ Ok(Status::StreamEnd) => Ok(written), ++ ++ Err(..) => Err(io::Error::new(io::ErrorKind::InvalidInput, ++ "corrupt deflate stream")) ++ } ++ } ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.data.run_vec(&[], &mut self.buf, Flush::Sync).unwrap(); ++ ++ // Unfortunately miniz doesn't actually tell us when we're done with ++ // pulling out all the data from the internal stream. To remedy this we ++ // have to continually ask the stream for more memory until it doesn't ++ // give us a chunk of memory the same size as our own internal buffer, ++ // at which point we assume it's reached the end. ++ loop { ++ try!(self.dump()); ++ let before = self.data.total_out(); ++ self.data.run_vec(&[], &mut self.buf, Flush::None).unwrap(); ++ if before == self.data.total_out() { ++ break ++ } ++ } ++ ++ self.obj.as_mut().unwrap().flush() ++ } ++} ++ ++impl Drop for Writer { ++ fn drop(&mut self) { ++ if self.obj.is_some() { ++ let _ = self.finish(); ++ } ++ } ++} diff --cc vendor/flate2-0.2.20/src/zlib/bufread.rs index 000000000,000000000..a21a905f6 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/zlib/bufread.rs @@@ -1,0 -1,0 +1,259 @@@ ++use std::io::prelude::*; ++use std::io; ++use std::mem; ++ ++#[cfg(feature = "tokio")] ++use futures::Poll; ++#[cfg(feature = "tokio")] ++use tokio_io::{AsyncRead, AsyncWrite}; ++ ++use zio; ++use {Compress, Decompress}; ++ ++/// A ZLIB encoder, or compressor. ++/// ++/// This structure implements a [`BufRead`] interface and will read uncompressed ++/// data from an underlying stream and emit a stream of compressed data. ++/// ++/// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use flate2::Compression; ++/// use flate2::bufread::ZlibEncoder; ++/// use std::fs::File; ++/// use std::io::BufReader; ++/// ++/// // Use a buffered file to compress contents into a Vec ++/// ++/// # fn open_hello_world() -> std::io::Result> { ++/// let f = File::open("examples/hello_world.txt")?; ++/// let b = BufReader::new(f); ++/// let mut z = ZlibEncoder::new(b, Compression::Fast); ++/// let mut buffer = Vec::new(); ++/// z.read_to_end(&mut buffer)?; ++/// # Ok(buffer) ++/// # } ++/// ``` ++#[derive(Debug)] ++pub struct ZlibEncoder { ++ obj: R, ++ data: Compress, ++} ++ ++ ++impl ZlibEncoder { ++ /// Creates a new encoder which will read uncompressed data from the given ++ /// stream and emit the compressed stream. ++ pub fn new(r: R, level: ::Compression) -> ZlibEncoder { ++ ZlibEncoder { ++ obj: r, ++ data: Compress::new(level, true), ++ } ++ } ++} ++ ++pub fn reset_encoder_data(zlib: &mut ZlibEncoder) { ++ zlib.data.reset() ++} ++ ++impl ZlibEncoder { ++ /// Resets the state of this encoder entirely, swapping out the input ++ /// stream for another. ++ /// ++ /// This function will reset the internal state of this encoder and replace ++ /// the input stream with the one provided, returning the previous input ++ /// stream. Future data read from this encoder will be the compressed ++ /// version of `r`'s data. ++ pub fn reset(&mut self, r: R) -> R { ++ reset_encoder_data(self); ++ mem::replace(&mut self.obj, r) ++ } ++ ++ /// Acquires a reference to the underlying reader ++ pub fn get_ref(&self) -> &R { ++ &self.obj ++ } ++ ++ /// Acquires a mutable reference to the underlying stream ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ &mut self.obj ++ } ++ ++ /// Consumes this encoder, returning the underlying reader. ++ pub fn into_inner(self) -> R { ++ self.obj ++ } ++ ++ /// Returns the number of bytes that have been read into this compressor. ++ /// ++ /// Note that not all bytes read from the underlying object may be accounted ++ /// for, there may still be some active buffering. ++ pub fn total_in(&self) -> u64 { ++ self.data.total_in() ++ } ++ ++ /// Returns the number of bytes that the compressor has produced. ++ /// ++ /// Note that not all bytes may have been read yet, some may still be ++ /// buffered. ++ pub fn total_out(&self) -> u64 { ++ self.data.total_out() ++ } ++} ++ ++impl Read for ZlibEncoder { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ zio::read(&mut self.obj, &mut self.data, buf) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for ZlibEncoder {} ++ ++impl Write for ZlibEncoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for ZlibEncoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ self.get_mut().shutdown() ++ } ++} ++ ++/// A ZLIB decoder, or decompressor. ++/// ++/// This structure implements a [`BufRead`] interface and takes a stream of ++/// compressed data as input, providing the decompressed data when read from. ++/// ++/// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// # use flate2::Compression; ++/// # use flate2::write::ZlibEncoder; ++/// use flate2::bufread::ZlibDecoder; ++/// ++/// # fn main() { ++/// # let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); ++/// # e.write(b"Hello World").unwrap(); ++/// # let bytes = e.finish().unwrap(); ++/// # println!("{}", decode_bufreader(bytes).unwrap()); ++/// # } ++/// # ++/// // Uncompresses a Zlib Encoded vector of bytes and returns a string or error ++/// // Here &[u8] implements BufRead ++/// ++/// fn decode_bufreader(bytes: Vec) -> io::Result { ++/// let mut z = ZlibDecoder::new(&bytes[..]); ++/// let mut s = String::new(); ++/// z.read_to_string(&mut s)?; ++/// Ok(s) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct ZlibDecoder { ++ obj: R, ++ data: Decompress, ++} ++ ++impl ZlibDecoder { ++ /// Creates a new decoder which will decompress data read from the given ++ /// stream. ++ pub fn new(r: R) -> ZlibDecoder { ++ ZlibDecoder { ++ obj: r, ++ data: Decompress::new(true), ++ } ++ } ++} ++ ++pub fn reset_decoder_data(zlib: &mut ZlibDecoder) { ++ zlib.data = Decompress::new(true); ++} ++ ++impl ZlibDecoder { ++ /// Resets the state of this decoder entirely, swapping out the input ++ /// stream for another. ++ /// ++ /// This will reset the internal state of this decoder and replace the ++ /// input stream with the one provided, returning the previous input ++ /// stream. Future data read from this decoder will be the decompressed ++ /// version of `r`'s data. ++ pub fn reset(&mut self, r: R) -> R { ++ reset_decoder_data(self); ++ mem::replace(&mut self.obj, r) ++ } ++ ++ /// Acquires a reference to the underlying stream ++ pub fn get_ref(&self) -> &R { ++ &self.obj ++ } ++ ++ /// Acquires a mutable reference to the underlying stream ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ &mut self.obj ++ } ++ ++ /// Consumes this decoder, returning the underlying reader. ++ pub fn into_inner(self) -> R { ++ self.obj ++ } ++ ++ /// Returns the number of bytes that the decompressor has consumed. ++ /// ++ /// Note that this will likely be smaller than what the decompressor ++ /// actually read from the underlying stream due to buffering. ++ pub fn total_in(&self) -> u64 { ++ self.data.total_in() ++ } ++ ++ /// Returns the number of bytes that the decompressor has produced. ++ pub fn total_out(&self) -> u64 { ++ self.data.total_out() ++ } ++} ++ ++impl Read for ZlibDecoder { ++ fn read(&mut self, into: &mut [u8]) -> io::Result { ++ zio::read(&mut self.obj, &mut self.data, into) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for ZlibDecoder {} ++ ++impl Write for ZlibDecoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for ZlibDecoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ self.get_mut().shutdown() ++ } ++} diff --cc vendor/flate2-0.2.20/src/zlib/mod.rs index 000000000,000000000..b04e40b82 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/zlib/mod.rs @@@ -1,0 -1,0 +1,164 @@@ ++pub mod bufread; ++pub mod read; ++pub mod write; ++ ++ ++#[cfg(test)] ++mod tests { ++ use std::io::prelude::*; ++ use std::io; ++ ++ use rand::{thread_rng, Rng}; ++ ++ use zlib::{read, write}; ++ use Compression::Default; ++ ++ #[test] ++ fn roundtrip() { ++ let mut real = Vec::new(); ++ let mut w = write::ZlibEncoder::new(Vec::new(), Default); ++ let v = thread_rng().gen_iter::().take(1024).collect::>(); ++ for _ in 0..200 { ++ let to_write = &v[..thread_rng().gen_range(0, v.len())]; ++ real.extend(to_write.iter().map(|x| *x)); ++ w.write_all(to_write).unwrap(); ++ } ++ let result = w.finish().unwrap(); ++ let mut r = read::ZlibDecoder::new(&result[..]); ++ let mut ret = Vec::new(); ++ r.read_to_end(&mut ret).unwrap(); ++ assert!(ret == real); ++ } ++ ++ #[test] ++ fn drop_writes() { ++ let mut data = Vec::new(); ++ write::ZlibEncoder::new(&mut data, Default) ++ .write_all(b"foo") ++ .unwrap(); ++ let mut r = read::ZlibDecoder::new(&data[..]); ++ let mut ret = Vec::new(); ++ r.read_to_end(&mut ret).unwrap(); ++ assert!(ret == b"foo"); ++ } ++ ++ #[test] ++ fn total_in() { ++ let mut real = Vec::new(); ++ let mut w = write::ZlibEncoder::new(Vec::new(), Default); ++ let v = thread_rng().gen_iter::().take(1024).collect::>(); ++ for _ in 0..200 { ++ let to_write = &v[..thread_rng().gen_range(0, v.len())]; ++ real.extend(to_write.iter().map(|x| *x)); ++ w.write_all(to_write).unwrap(); ++ } ++ let mut result = w.finish().unwrap(); ++ ++ let result_len = result.len(); ++ ++ for _ in 0..200 { ++ result.extend(v.iter().map(|x| *x)); ++ } ++ ++ let mut r = read::ZlibDecoder::new(&result[..]); ++ let mut ret = Vec::new(); ++ r.read_to_end(&mut ret).unwrap(); ++ assert!(ret == real); ++ assert_eq!(r.total_in(), result_len as u64); ++ } ++ ++ #[test] ++ fn roundtrip2() { ++ let v = thread_rng() ++ .gen_iter::() ++ .take(1024 * 1024) ++ .collect::>(); ++ let mut r = read::ZlibDecoder::new(read::ZlibEncoder::new(&v[..], Default)); ++ let mut ret = Vec::new(); ++ r.read_to_end(&mut ret).unwrap(); ++ assert_eq!(ret, v); ++ } ++ ++ #[test] ++ fn roundtrip3() { ++ let v = thread_rng() ++ .gen_iter::() ++ .take(1024 * 1024) ++ .collect::>(); ++ let mut w = write::ZlibEncoder::new(write::ZlibDecoder::new(Vec::new()), Default); ++ w.write_all(&v).unwrap(); ++ let w = w.finish().unwrap().finish().unwrap(); ++ assert!(w == v); ++ } ++ ++ #[test] ++ fn reset_decoder() { ++ let v = thread_rng() ++ .gen_iter::() ++ .take(1024 * 1024) ++ .collect::>(); ++ let mut w = write::ZlibEncoder::new(Vec::new(), Default); ++ w.write_all(&v).unwrap(); ++ let data = w.finish().unwrap(); ++ ++ { ++ let (mut a, mut b, mut c) = (Vec::new(), Vec::new(), Vec::new()); ++ let mut r = read::ZlibDecoder::new(&data[..]); ++ r.read_to_end(&mut a).unwrap(); ++ r.reset(&data); ++ r.read_to_end(&mut b).unwrap(); ++ ++ let mut r = read::ZlibDecoder::new(&data[..]); ++ r.read_to_end(&mut c).unwrap(); ++ assert!(a == b && b == c && c == v); ++ } ++ ++ { ++ let mut w = write::ZlibDecoder::new(Vec::new()); ++ w.write_all(&data).unwrap(); ++ let a = w.reset(Vec::new()).unwrap(); ++ w.write_all(&data).unwrap(); ++ let b = w.finish().unwrap(); ++ ++ let mut w = write::ZlibDecoder::new(Vec::new()); ++ w.write_all(&data).unwrap(); ++ let c = w.finish().unwrap(); ++ assert!(a == b && b == c && c == v); ++ } ++ } ++ ++ #[test] ++ fn bad_input() { ++ // regress tests: previously caused a panic on drop ++ let mut out: Vec = Vec::new(); ++ let data: Vec = (0..255).cycle().take(1024).collect(); ++ let mut w = write::ZlibDecoder::new(&mut out); ++ match w.write_all(&data[..]) { ++ Ok(_) => panic!("Expected an error to be returned!"), ++ Err(e) => assert_eq!(e.kind(), io::ErrorKind::InvalidInput), ++ } ++ } ++ ++ #[test] ++ fn qc_reader() { ++ ::quickcheck::quickcheck(test as fn(_) -> _); ++ ++ fn test(v: Vec) -> bool { ++ let mut r = read::ZlibDecoder::new(read::ZlibEncoder::new(&v[..], Default)); ++ let mut v2 = Vec::new(); ++ r.read_to_end(&mut v2).unwrap(); ++ v == v2 ++ } ++ } ++ ++ #[test] ++ fn qc_writer() { ++ ::quickcheck::quickcheck(test as fn(_) -> _); ++ ++ fn test(v: Vec) -> bool { ++ let mut w = write::ZlibEncoder::new(write::ZlibDecoder::new(Vec::new()), Default); ++ w.write_all(&v).unwrap(); ++ v == w.finish().unwrap().finish().unwrap() ++ } ++ } ++} diff --cc vendor/flate2-0.2.20/src/zlib/read.rs index 000000000,000000000..a2eece78d new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/zlib/read.rs @@@ -1,0 -1,0 +1,266 @@@ ++use std::io::prelude::*; ++use std::io; ++ ++#[cfg(feature = "tokio")] ++use futures::Poll; ++#[cfg(feature = "tokio")] ++use tokio_io::{AsyncRead, AsyncWrite}; ++ ++use bufreader::BufReader; ++use super::bufread; ++ ++/// A ZLIB encoder, or compressor. ++/// ++/// This structure implements a [`Read`] interface and will read uncompressed ++/// data from an underlying stream and emit a stream of compressed data. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use flate2::Compression; ++/// use flate2::read::ZlibEncoder; ++/// use std::fs::File; ++/// ++/// // Open example file and compress the contents using Read interface ++/// ++/// # fn open_hello_world() -> std::io::Result> { ++/// let f = File::open("examples/hello_world.txt")?; ++/// let mut z = ZlibEncoder::new(f, Compression::Fast); ++/// let mut buffer = [0;50]; ++/// let byte_count = z.read(&mut buffer)?; ++/// # Ok(buffer[0..byte_count].to_vec()) ++/// # } ++/// ``` ++#[derive(Debug)] ++pub struct ZlibEncoder { ++ inner: bufread::ZlibEncoder>, ++} ++ ++impl ZlibEncoder { ++ /// Creates a new encoder which will read uncompressed data from the given ++ /// stream and emit the compressed stream. ++ pub fn new(r: R, level: ::Compression) -> ZlibEncoder { ++ ZlibEncoder { ++ inner: bufread::ZlibEncoder::new(BufReader::new(r), level), ++ } ++ } ++} ++ ++impl ZlibEncoder { ++ /// Resets the state of this encoder entirely, swapping out the input ++ /// stream for another. ++ /// ++ /// This function will reset the internal state of this encoder and replace ++ /// the input stream with the one provided, returning the previous input ++ /// stream. Future data read from this encoder will be the compressed ++ /// version of `r`'s data. ++ /// ++ /// Note that there may be currently buffered data when this function is ++ /// called, and in that case the buffered data is discarded. ++ pub fn reset(&mut self, r: R) -> R { ++ super::bufread::reset_encoder_data(&mut self.inner); ++ self.inner.get_mut().reset(r) ++ } ++ ++ /// Acquires a reference to the underlying stream ++ pub fn get_ref(&self) -> &R { ++ self.inner.get_ref().get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying stream ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ self.inner.get_mut().get_mut() ++ } ++ ++ /// Consumes this encoder, returning the underlying reader. ++ /// ++ /// Note that there may be buffered bytes which are not re-acquired as part ++ /// of this transition. It's recommended to only call this function after ++ /// EOF has been reached. ++ pub fn into_inner(self) -> R { ++ self.inner.into_inner().into_inner() ++ } ++ ++ /// Returns the number of bytes that have been read into this compressor. ++ /// ++ /// Note that not all bytes read from the underlying object may be accounted ++ /// for, there may still be some active buffering. ++ pub fn total_in(&self) -> u64 { ++ self.inner.total_in() ++ } ++ ++ /// Returns the number of bytes that the compressor has produced. ++ /// ++ /// Note that not all bytes may have been read yet, some may still be ++ /// buffered. ++ pub fn total_out(&self) -> u64 { ++ self.inner.total_out() ++ } ++} ++ ++impl Read for ZlibEncoder { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.inner.read(buf) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for ZlibEncoder {} ++ ++impl Write for ZlibEncoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for ZlibEncoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ self.get_mut().shutdown() ++ } ++} ++ ++/// A ZLIB decoder, or decompressor. ++/// ++/// This structure implements a [`Read`] interface and takes a stream of ++/// compressed data as input, providing the decompressed data when read from. ++/// ++/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// # use flate2::Compression; ++/// # use flate2::write::ZlibEncoder; ++/// use flate2::read::ZlibDecoder; ++/// ++/// # fn main() { ++/// # let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); ++/// # e.write(b"Hello World").unwrap(); ++/// # let bytes = e.finish().unwrap(); ++/// # println!("{}", decode_reader(bytes).unwrap()); ++/// # } ++/// # ++/// // Uncompresses a Zlib Encoded vector of bytes and returns a string or error ++/// // Here &[u8] implements Read ++/// ++/// fn decode_reader(bytes: Vec) -> io::Result { ++/// let mut z = ZlibDecoder::new(&bytes[..]); ++/// let mut s = String::new(); ++/// z.read_to_string(&mut s)?; ++/// Ok(s) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct ZlibDecoder { ++ inner: bufread::ZlibDecoder>, ++} ++ ++ ++impl ZlibDecoder { ++ /// Creates a new decoder which will decompress data read from the given ++ /// stream. ++ pub fn new(r: R) -> ZlibDecoder { ++ ZlibDecoder::new_with_buf(r, vec![0; 32 * 1024]) ++ } ++ ++ /// Same as `new`, but the intermediate buffer for data is specified. ++ /// ++ /// Note that the specified buffer will only be used up to its current ++ /// length. The buffer's capacity will also not grow over time. ++ pub fn new_with_buf(r: R, buf: Vec) -> ZlibDecoder { ++ ZlibDecoder { ++ inner: bufread::ZlibDecoder::new(BufReader::with_buf(buf, r)), ++ } ++ } ++} ++ ++impl ZlibDecoder { ++ /// Resets the state of this decoder entirely, swapping out the input ++ /// stream for another. ++ /// ++ /// This will reset the internal state of this decoder and replace the ++ /// input stream with the one provided, returning the previous input ++ /// stream. Future data read from this decoder will be the decompressed ++ /// version of `r`'s data. ++ /// ++ /// Note that there may be currently buffered data when this function is ++ /// called, and in that case the buffered data is discarded. ++ pub fn reset(&mut self, r: R) -> R { ++ super::bufread::reset_decoder_data(&mut self.inner); ++ self.inner.get_mut().reset(r) ++ } ++ ++ /// Acquires a reference to the underlying stream ++ pub fn get_ref(&self) -> &R { ++ self.inner.get_ref().get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying stream ++ /// ++ /// Note that mutation of the stream may result in surprising results if ++ /// this encoder is continued to be used. ++ pub fn get_mut(&mut self) -> &mut R { ++ self.inner.get_mut().get_mut() ++ } ++ ++ /// Consumes this decoder, returning the underlying reader. ++ /// ++ /// Note that there may be buffered bytes which are not re-acquired as part ++ /// of this transition. It's recommended to only call this function after ++ /// EOF has been reached. ++ pub fn into_inner(self) -> R { ++ self.inner.into_inner().into_inner() ++ } ++ ++ /// Returns the number of bytes that the decompressor has consumed. ++ /// ++ /// Note that this will likely be smaller than what the decompressor ++ /// actually read from the underlying stream due to buffering. ++ pub fn total_in(&self) -> u64 { ++ self.inner.total_in() ++ } ++ ++ /// Returns the number of bytes that the decompressor has produced. ++ pub fn total_out(&self) -> u64 { ++ self.inner.total_out() ++ } ++} ++ ++impl Read for ZlibDecoder { ++ fn read(&mut self, into: &mut [u8]) -> io::Result { ++ self.inner.read(into) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for ZlibDecoder {} ++ ++impl Write for ZlibDecoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.get_mut().write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for ZlibDecoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ self.get_mut().shutdown() ++ } ++} diff --cc vendor/flate2-0.2.20/src/zlib/write.rs index 000000000,000000000..52e4fc28e new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/src/zlib/write.rs @@@ -1,0 -1,0 +1,351 @@@ ++use std::io::prelude::*; ++use std::io; ++ ++#[cfg(feature = "tokio")] ++use futures::Poll; ++#[cfg(feature = "tokio")] ++use tokio_io::{AsyncRead, AsyncWrite}; ++ ++use zio; ++use {Compress, Decompress}; ++ ++/// A ZLIB encoder, or compressor. ++/// ++/// This structure implements a [`Write`] interface and takes a stream of ++/// uncompressed data, writing the compressed data to the wrapped writer. ++/// ++/// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use flate2::Compression; ++/// use flate2::write::ZlibEncoder; ++/// ++/// // Vec implements Write, assigning the compressed bytes of sample string ++/// ++/// # fn zlib_encoding() -> std::io::Result<()> { ++/// let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); ++/// e.write(b"Hello World")?; ++/// let compressed = e.finish()?; ++/// # Ok(()) ++/// # } ++/// ``` ++#[derive(Debug)] ++pub struct ZlibEncoder { ++ inner: zio::Writer, ++} ++ ++ ++impl ZlibEncoder { ++ /// Creates a new encoder which will write compressed data to the stream ++ /// given at the given compression level. ++ /// ++ /// When this encoder is dropped or unwrapped the final pieces of data will ++ /// be flushed. ++ pub fn new(w: W, level: ::Compression) -> ZlibEncoder { ++ ZlibEncoder { ++ inner: zio::Writer::new(w, Compress::new(level, true)), ++ } ++ } ++ ++ /// Acquires a reference to the underlying writer. ++ pub fn get_ref(&self) -> &W { ++ self.inner.get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying writer. ++ /// ++ /// Note that mutating the output/input state of the stream may corrupt this ++ /// object, so care must be taken when using this method. ++ pub fn get_mut(&mut self) -> &mut W { ++ self.inner.get_mut() ++ } ++ ++ /// Resets the state of this encoder entirely, swapping out the output ++ /// stream for another. ++ /// ++ /// This function will finish encoding the current stream into the current ++ /// output stream before swapping out the two output streams. ++ /// ++ /// After the current stream has been finished, this will reset the internal ++ /// state of this encoder and replace the output stream with the one ++ /// provided, returning the previous output stream. Future data written to ++ /// this encoder will be the compressed into the stream `w` provided. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn reset(&mut self, w: W) -> io::Result { ++ try!(self.inner.finish()); ++ self.inner.data.reset(); ++ Ok(self.inner.replace(w)) ++ } ++ ++ /// Attempt to finish this output stream, writing out final chunks of data. ++ /// ++ /// Note that this function can only be used once data has finished being ++ /// written to the output stream. After this function is called then further ++ /// calls to `write` may result in a panic. ++ /// ++ /// # Panics ++ /// ++ /// Attempts to write data to this stream may result in a panic after this ++ /// function is called. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn try_finish(&mut self) -> io::Result<()> { ++ self.inner.finish() ++ } ++ ++ /// Consumes this encoder, flushing the output stream. ++ /// ++ /// This will flush the underlying data stream, close off the compressed ++ /// stream and, if successful, return the contained writer. ++ /// ++ /// Note that this function may not be suitable to call in a situation where ++ /// the underlying stream is an asynchronous I/O stream. To finish a stream ++ /// the `try_finish` (or `shutdown`) method should be used instead. To ++ /// re-acquire ownership of a stream it is safe to call this method after ++ /// `try_finish` or `shutdown` has returned `Ok`. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn finish(mut self) -> io::Result { ++ try!(self.inner.finish()); ++ Ok(self.inner.take_inner()) ++ } ++ ++ /// Consumes this encoder, flushing the output stream. ++ /// ++ /// This will flush the underlying data stream and then return the contained ++ /// writer if the flush succeeded. ++ /// The compressed stream will not closed but only flushed. This ++ /// means that obtained byte array can by extended by another deflated ++ /// stream. To close the stream add the two bytes 0x3 and 0x0. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn flush_finish(mut self) -> io::Result { ++ try!(self.inner.flush()); ++ Ok(self.inner.take_inner()) ++ } ++ ++ /// Returns the number of bytes that have been written to this compresor. ++ /// ++ /// Note that not all bytes written to this object may be accounted for, ++ /// there may still be some active buffering. ++ pub fn total_in(&self) -> u64 { ++ self.inner.data.total_in() ++ } ++ ++ /// Returns the number of bytes that the compressor has produced. ++ /// ++ /// Note that not all bytes may have been written yet, some may still be ++ /// buffered. ++ pub fn total_out(&self) -> u64 { ++ self.inner.data.total_out() ++ } ++} ++ ++impl Write for ZlibEncoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.inner.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.inner.flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for ZlibEncoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ try_nb!(self.try_finish()); ++ self.get_mut().shutdown() ++ } ++} ++ ++impl Read for ZlibEncoder { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.get_mut().read(buf) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for ZlibEncoder {} ++ ++ ++/// A ZLIB decoder, or decompressor. ++/// ++/// This structure implements a [`Write`] and will emit a stream of decompressed ++/// data when fed a stream of compressed data. ++/// ++/// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html ++/// ++/// # Examples ++/// ++/// ``` ++/// use std::io::prelude::*; ++/// use std::io; ++/// # use flate2::Compression; ++/// # use flate2::write::ZlibEncoder; ++/// use flate2::write::ZlibDecoder; ++/// ++/// # fn main() { ++/// # let mut e = ZlibEncoder::new(Vec::new(), Compression::Default); ++/// # e.write(b"Hello World").unwrap(); ++/// # let bytes = e.finish().unwrap(); ++/// # println!("{}", decode_reader(bytes).unwrap()); ++/// # } ++/// # ++/// // Uncompresses a Zlib Encoded vector of bytes and returns a string or error ++/// // Here Vec implements Write ++/// ++/// fn decode_reader(bytes: Vec) -> io::Result { ++/// let mut writer = Vec::new(); ++/// let mut z = ZlibDecoder::new(writer); ++/// z.write(&bytes[..])?; ++/// writer = z.finish()?; ++/// let return_string = String::from_utf8(writer).expect("String parsing error"); ++/// Ok(return_string) ++/// } ++/// ``` ++#[derive(Debug)] ++pub struct ZlibDecoder { ++ inner: zio::Writer, ++} ++ ++ ++impl ZlibDecoder { ++ /// Creates a new decoder which will write uncompressed data to the stream. ++ /// ++ /// When this decoder is dropped or unwrapped the final pieces of data will ++ /// be flushed. ++ pub fn new(w: W) -> ZlibDecoder { ++ ZlibDecoder { ++ inner: zio::Writer::new(w, Decompress::new(true)), ++ } ++ } ++ ++ /// Acquires a reference to the underlying writer. ++ pub fn get_ref(&self) -> &W { ++ self.inner.get_ref() ++ } ++ ++ /// Acquires a mutable reference to the underlying writer. ++ /// ++ /// Note that mutating the output/input state of the stream may corrupt this ++ /// object, so care must be taken when using this method. ++ pub fn get_mut(&mut self) -> &mut W { ++ self.inner.get_mut() ++ } ++ ++ /// Resets the state of this decoder entirely, swapping out the output ++ /// stream for another. ++ /// ++ /// This will reset the internal state of this decoder and replace the ++ /// output stream with the one provided, returning the previous output ++ /// stream. Future data written to this decoder will be decompressed into ++ /// the output stream `w`. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn reset(&mut self, w: W) -> io::Result { ++ try!(self.inner.finish()); ++ self.inner.data = Decompress::new(true); ++ Ok(self.inner.replace(w)) ++ } ++ ++ /// Attempt to finish this output stream, writing out final chunks of data. ++ /// ++ /// Note that this function can only be used once data has finished being ++ /// written to the output stream. After this function is called then further ++ /// calls to `write` may result in a panic. ++ /// ++ /// # Panics ++ /// ++ /// Attempts to write data to this stream may result in a panic after this ++ /// function is called. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn try_finish(&mut self) -> io::Result<()> { ++ self.inner.finish() ++ } ++ ++ /// Consumes this encoder, flushing the output stream. ++ /// ++ /// This will flush the underlying data stream and then return the contained ++ /// writer if the flush succeeded. ++ /// ++ /// Note that this function may not be suitable to call in a situation where ++ /// the underlying stream is an asynchronous I/O stream. To finish a stream ++ /// the `try_finish` (or `shutdown`) method should be used instead. To ++ /// re-acquire ownership of a stream it is safe to call this method after ++ /// `try_finish` or `shutdown` has returned `Ok`. ++ /// ++ /// # Errors ++ /// ++ /// This function will perform I/O to complete this stream, and any I/O ++ /// errors which occur will be returned from this function. ++ pub fn finish(mut self) -> io::Result { ++ try!(self.inner.finish()); ++ Ok(self.inner.take_inner()) ++ } ++ ++ /// Returns the number of bytes that the decompressor has consumed for ++ /// decompression. ++ /// ++ /// Note that this will likely be smaller than the number of bytes ++ /// successfully written to this stream due to internal buffering. ++ pub fn total_in(&self) -> u64 { ++ self.inner.data.total_in() ++ } ++ ++ /// Returns the number of bytes that the decompressor has written to its ++ /// output stream. ++ pub fn total_out(&self) -> u64 { ++ self.inner.data.total_out() ++ } ++} ++ ++impl Write for ZlibDecoder { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.inner.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.inner.flush() ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncWrite for ZlibDecoder { ++ fn shutdown(&mut self) -> Poll<(), io::Error> { ++ try_nb!(self.inner.finish()); ++ self.inner.get_mut().shutdown() ++ } ++} ++ ++impl Read for ZlibDecoder { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.inner.get_mut().read(buf) ++ } ++} ++ ++#[cfg(feature = "tokio")] ++impl AsyncRead for ZlibDecoder {} diff --cc vendor/flate2-0.2.20/tests/corrupt-file.gz index 000000000,000000000..159333b03 new file mode 100644 Binary files differ diff --cc vendor/flate2-0.2.20/tests/early-flush.rs index 000000000,000000000..70c10673f new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/tests/early-flush.rs @@@ -1,0 -1,0 +1,20 @@@ ++extern crate flate2; ++ ++use std::io::{Read, Write}; ++ ++use flate2::write::GzEncoder; ++use flate2::read::GzDecoder; ++ ++#[test] ++fn smoke() { ++ let mut w = GzEncoder::new(Vec::new(), flate2::Compression::Default); ++ w.flush().unwrap(); ++ w.write(b"hello").unwrap(); ++ ++ let bytes = w.finish().unwrap(); ++ ++ let mut r = GzDecoder::new(&bytes[..]).unwrap(); ++ let mut s = String::new(); ++ r.read_to_string(&mut s).unwrap(); ++ assert_eq!(s, "hello"); ++} diff --cc vendor/flate2-0.2.20/tests/good-file.gz index 000000000,000000000..f968689cc new file mode 100644 Binary files differ diff --cc vendor/flate2-0.2.20/tests/good-file.txt index 000000000,000000000..ee39ac53d new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/tests/good-file.txt @@@ -1,0 -1,0 +1,733 @@@ ++## ## ++timestep simulated EIR patent hosts ++0 0.136402 16855 ++1 0.146872 18564 ++2 0.150157 20334 ++3 0.146358 22159 ++4 0.136315 23655 ++5 0.122354 24848 ++6 0.104753 25887 ++7 0.084439 26770 ++8 0.06417 27238 ++9 0.0450397 27349 ++10 0.0295473 27274 ++11 0.0184662 26909 ++12 0.0110032 26324 ++13 0.00634348 25513 ++14 0.0036144 24469 ++15 0.00208133 23383 ++16 0.00122468 22345 ++17 0.000752514 21342 ++18 0.000545333 20416 ++19 0.000546139 19657 ++20 0.00054572 18806 ++21 0.000545757 18015 ++22 0.000545898 17349 ++23 0.000546719 16594 ++24 0.000547353 15955 ++25 0.000547944 15374 ++26 0.000547606 14765 ++27 0.000594773 14212 ++28 0.000969163 13677 ++29 0.00168295 13180 ++30 0.003059 12760 ++31 0.00571599 12313 ++32 0.0107918 11896 ++33 0.0201943 11512 ++34 0.0368013 11340 ++35 0.0640629 11323 ++36 0.104447 11769 ++37 0.157207 12728 ++38 0.216682 14261 ++39 0.271159 16491 ++40 0.303552 19274 ++41 0.303678 22157 ++42 0.271945 24875 ++43 0.215445 27027 ++44 0.154503 28690 ++45 0.100717 30046 ++46 0.0600343 30602 ++47 0.0328576 30709 ++48 0.016964 30315 ++49 0.00841526 29310 ++50 0.0040958 28058 ++51 0.0019953 26662 ++52 0.000986531 25259 ++53 0.000545786 24049 ++54 0.000546405 22966 ++55 0.000546036 21933 ++56 0.00054427 20953 ++57 0.000542769 20057 ++58 0.000541566 19304 ++59 0.000541822 18477 ++60 0.000541643 17695 ++61 0.000541989 17002 ++62 0.000769298 16391 ++63 0.00150811 15805 ++64 0.00295097 15172 ++65 0.00566197 14690 ++66 0.0105243 14206 ++67 0.0186965 13791 ++68 0.0313363 13470 ++69 0.0490605 13377 ++70 0.0711679 13631 ++71 0.0953625 14209 ++72 0.118026 15277 ++73 0.134612 16760 ++74 0.144311 18339 ++75 0.146328 20124 ++76 0.142936 21803 ++77 0.134029 23435 ++78 0.120562 24854 ++79 0.103157 25880 ++80 0.0834054 26597 ++81 0.0632474 27226 ++82 0.0447785 27294 ++83 0.0295654 27169 ++84 0.0184081 26803 ++85 0.0109489 26265 ++86 0.00631234 25375 ++87 0.00359978 24306 ++88 0.00206967 23260 ++89 0.00122197 22225 ++90 0.000751031 21277 ++91 0.000544507 20295 ++92 0.000543897 19417 ++93 0.000543483 18623 ++94 0.000542926 17837 ++95 0.000542685 17070 ++96 0.000542387 16424 ++97 0.000541194 15838 ++98 0.000540427 15177 ++99 0.000540774 14608 ++100 0.000588312 14066 ++101 0.000959183 13499 ++102 0.00166774 12979 ++103 0.00303278 12545 ++104 0.00567457 12067 ++105 0.0107272 11712 ++106 0.0200606 11368 ++107 0.0364637 11207 ++108 0.063339 11238 ++109 0.103717 11660 ++110 0.156884 12621 ++111 0.217072 14151 ++112 0.272311 16358 ++113 0.305046 19005 ++114 0.304927 21926 ++115 0.272427 24662 ++116 0.216478 27080 ++117 0.155168 29064 ++118 0.10079 30370 ++119 0.0599659 30992 ++120 0.0331287 30975 ++121 0.017235 30317 ++122 0.00860221 29455 ++123 0.00419286 28172 ++124 0.00203361 26809 ++125 0.000998847 25476 ++126 0.000551418 24230 ++127 0.000551119 23106 ++128 0.000552786 22147 ++129 0.000553814 21183 ++130 0.000553743 20280 ++131 0.000554428 19423 ++132 0.000555022 18598 ++133 0.000555921 17864 ++134 0.000556687 17187 ++135 0.000789996 16527 ++136 0.00154597 15870 ++137 0.00302776 15226 ++138 0.00581484 14685 ++139 0.010812 14234 ++140 0.0191832 13818 ++141 0.0321572 13571 ++142 0.050328 13538 ++143 0.072817 13812 ++144 0.0974321 14368 ++145 0.120225 15436 ++146 0.137418 16988 ++147 0.147086 18775 ++148 0.149165 20563 ++149 0.144943 22223 ++150 0.136631 23741 ++151 0.123355 24920 ++152 0.105401 25779 ++153 0.0851918 26781 ++154 0.0641702 27265 ++155 0.0450746 27505 ++156 0.0294136 27416 ++157 0.0183811 27028 ++158 0.0109285 26260 ++159 0.00634296 25451 ++160 0.00364513 24472 ++161 0.0021051 23427 ++162 0.00123693 22403 ++163 0.000759531 21393 ++164 0.000551727 20485 ++165 0.000552256 19660 ++166 0.000552303 18862 ++167 0.000550927 18094 ++168 0.000551098 17378 ++169 0.000551093 16691 ++170 0.000551885 16050 ++171 0.000552282 15420 ++172 0.000552591 14878 ++173 0.00060109 14357 ++174 0.000980446 13768 ++175 0.00170301 13241 ++176 0.003096 12745 ++177 0.00579971 12294 ++178 0.010976 11879 ++179 0.0205422 11636 ++180 0.0374515 11431 ++181 0.0649916 11517 ++182 0.106008 11966 ++183 0.159983 12918 ++184 0.221127 14484 ++185 0.276503 16696 ++186 0.310316 19518 ++187 0.311205 22301 ++188 0.276769 25047 ++189 0.220506 27360 ++190 0.159123 29133 ++191 0.103761 30440 ++192 0.0613797 31087 ++193 0.033583 31037 ++194 0.0173275 30555 ++195 0.00861968 29617 ++196 0.00419503 28292 ++197 0.00203304 26944 ++198 0.00100126 25569 ++199 0.000553511 24349 ++200 0.000554687 23257 ++201 0.00055586 22204 ++202 0.000555419 21176 ++203 0.000556032 20316 ++204 0.000555974 19509 ++205 0.000556859 18746 ++206 0.000556996 17978 ++207 0.000557102 17288 ++208 0.000790187 16672 ++209 0.00154711 16057 ++210 0.00303521 15449 ++211 0.00584201 14915 ++212 0.0108854 14397 ++213 0.0193386 14010 ++214 0.0324346 13730 ++215 0.0507192 13674 ++216 0.0736661 13874 ++217 0.0987887 14515 ++218 0.122411 15693 ++219 0.139964 17265 ++220 0.149125 18894 ++221 0.151434 20662 ++222 0.148067 22442 ++223 0.138894 24116 ++224 0.125436 25367 ++225 0.107664 26360 ++226 0.0865709 27044 ++227 0.0655588 27428 ++228 0.0459664 27714 ++229 0.0301384 27687 ++230 0.0186481 27262 ++231 0.01103 26677 ++232 0.00636957 25722 ++233 0.00366188 24662 ++234 0.00212213 23575 ++235 0.00125358 22520 ++236 0.000768665 21480 ++237 0.000556393 20563 ++238 0.000555892 19706 ++239 0.00055534 18914 ++240 0.000555027 18165 ++241 0.000555062 17432 ++242 0.000553766 16733 ++243 0.000552984 16070 ++244 0.000553634 15396 ++245 0.000554286 14867 ++246 0.000603759 14362 ++247 0.000982974 13867 ++248 0.00170532 13379 ++249 0.00310471 12907 ++250 0.00582577 12446 ++251 0.0110122 12018 ++252 0.0206284 11730 ++253 0.0375835 11546 ++254 0.0652192 11605 ++255 0.10646 11981 ++256 0.160858 12949 ++257 0.223122 14478 ++258 0.279678 16810 ++259 0.312171 19452 ++260 0.311778 22391 ++261 0.276966 25204 ++262 0.22251 27379 ++263 0.159246 29248 ++264 0.104109 30532 ++265 0.0617903 30995 ++266 0.0338421 31042 ++267 0.0174647 30620 ++268 0.00867821 29589 ++269 0.00419968 28293 ++270 0.00203244 26916 ++271 0.00100204 25464 ++272 0.000555586 24219 ++273 0.000555599 23207 ++274 0.00055582 22187 ++275 0.00055516 21136 ++276 0.000555436 20243 ++277 0.000555618 19426 ++278 0.000556778 18635 ++279 0.000556976 17870 ++280 0.000557162 17190 ++281 0.0007904 16506 ++282 0.00154557 15837 ++283 0.00302973 15234 ++284 0.00584543 14717 ++285 0.0108796 14225 ++286 0.0192919 13810 ++287 0.032329 13605 ++288 0.0505293 13536 ++289 0.0733417 13760 ++290 0.0982413 14378 ++291 0.121477 15400 ++292 0.138636 17017 ++293 0.14875 18764 ++294 0.150515 20516 ++295 0.146372 22389 ++296 0.137332 23975 ++297 0.124076 25120 ++298 0.106469 26137 ++299 0.0862987 26973 ++300 0.0650552 27584 ++301 0.0456456 27741 ++302 0.0300744 27565 ++303 0.0187879 27212 ++304 0.0112085 26432 ++305 0.00648306 25501 ++306 0.00370346 24466 ++307 0.00213399 23472 ++308 0.00125463 22415 ++309 0.000765794 21427 ++310 0.000552587 20533 ++311 0.000553175 19632 ++312 0.000553525 18831 ++313 0.000554941 18119 ++314 0.000556327 17336 ++315 0.000556008 16721 ++316 0.00055593 16086 ++317 0.000556421 15516 ++318 0.000557308 14918 ++319 0.00060681 14402 ++320 0.000990746 13849 ++321 0.00172359 13355 ++322 0.00313688 12902 ++323 0.0058708 12425 ++324 0.0110637 12087 ++325 0.0206777 11743 ++326 0.0376394 11531 ++327 0.0656182 11582 ++328 0.107414 12034 ++329 0.162101 12955 ++330 0.223525 14571 ++331 0.279935 16842 ++332 0.314601 19566 ++333 0.313556 22575 ++334 0.279571 25279 ++335 0.221638 27642 ++336 0.158038 29275 ++337 0.102505 30638 ++338 0.0608328 31209 ++339 0.0335531 31260 ++340 0.0173332 30520 ++341 0.00861545 29604 ++342 0.00419454 28370 ++343 0.00202587 26940 ++344 0.000994029 25614 ++345 0.000549339 24445 ++346 0.000551477 23239 ++347 0.000552891 22300 ++348 0.000551775 21280 ++349 0.000552425 20424 ++350 0.000552135 19571 ++351 0.000552542 18753 ++352 0.000552863 18058 ++353 0.000554438 17348 ++354 0.000786735 16671 ++355 0.00153958 16047 ++356 0.00301482 15500 ++357 0.00580589 14883 ++358 0.0108227 14347 ++359 0.0192357 13947 ++360 0.0321613 13672 ++361 0.050229 13606 ++362 0.0729462 13815 ++363 0.0978564 14566 ++364 0.120879 15674 ++365 0.137663 17049 ++366 0.147092 18813 ++367 0.150184 20578 ++368 0.146971 22245 ++369 0.136769 23723 ++370 0.12367 24905 ++371 0.106187 25871 ++372 0.0860921 26687 ++373 0.0645899 27375 ++374 0.0453473 27635 ++375 0.0298122 27551 ++376 0.0185448 27134 ++377 0.0110517 26468 ++378 0.00640294 25661 ++379 0.00367011 24653 ++380 0.00211832 23556 ++381 0.00125246 22513 ++382 0.00076891 21568 ++383 0.000557384 20672 ++384 0.000557295 19811 ++385 0.000556837 18982 ++386 0.000557433 18179 ++387 0.000557376 17457 ++388 0.000557751 16720 ++389 0.000556844 16112 ++390 0.000555603 15479 ++391 0.000554871 14809 ++392 0.00060335 14275 ++393 0.000982808 13757 ++394 0.00170757 13221 ++395 0.00310351 12758 ++396 0.0058181 12286 ++397 0.010991 11906 ++398 0.0205342 11557 ++399 0.0373486 11393 ++400 0.0647659 11487 ++401 0.105589 11887 ++402 0.15967 12798 ++403 0.220945 14260 ++404 0.277122 16477 ++405 0.310108 19295 ++406 0.308854 22110 ++407 0.274911 24915 ++408 0.218618 27273 ++409 0.156618 29189 ++410 0.101775 30572 ++411 0.0607503 31174 ++412 0.0334708 31316 ++413 0.0173443 30731 ++414 0.00865633 29636 ++415 0.00421141 28342 ++416 0.00204387 26991 ++417 0.00100602 25595 ++418 0.000555131 24336 ++419 0.000555037 23251 ++420 0.000555559 22267 ++421 0.000554916 21212 ++422 0.000554432 20306 ++423 0.000554751 19488 ++424 0.00055638 18727 ++425 0.000556727 17927 ++426 0.000556368 17198 ++427 0.000788004 16578 ++428 0.00154404 15944 ++429 0.00302383 15315 ++430 0.00582586 14786 ++431 0.0108457 14290 ++432 0.0192962 13815 ++433 0.0323072 13561 ++434 0.0505101 13456 ++435 0.0732162 13811 ++436 0.0978737 14403 ++437 0.121405 15460 ++438 0.138202 16993 ++439 0.1482 18710 ++440 0.149707 20578 ++441 0.146945 22256 ++442 0.137785 23713 ++443 0.123767 25058 ++444 0.105989 26087 ++445 0.085483 26759 ++446 0.0646144 27375 ++447 0.0454389 27680 ++448 0.0299337 27531 ++449 0.018663 27041 ++450 0.0111347 26416 ++451 0.00644197 25614 ++452 0.00369229 24666 ++453 0.00211986 23647 ++454 0.00124761 22650 ++455 0.000769104 21642 ++456 0.000558796 20693 ++457 0.000559908 19746 ++458 0.000559562 18952 ++459 0.00056042 18100 ++460 0.000559447 17401 ++461 0.000557893 16756 ++462 0.000557137 16148 ++463 0.000557269 15504 ++464 0.000557596 14974 ++465 0.000606298 14408 ++466 0.000987712 13909 ++467 0.00171257 13402 ++468 0.00311667 12891 ++469 0.00584794 12433 ++470 0.0110774 11980 ++471 0.0207006 11713 ++472 0.037673 11583 ++473 0.0654988 11677 ++474 0.106982 12072 ++475 0.161926 12898 ++476 0.224327 14548 ++477 0.281709 16796 ++478 0.314567 19512 ++479 0.313419 22428 ++480 0.278962 25186 ++481 0.221864 27755 ++482 0.158559 29556 ++483 0.103532 30572 ++484 0.0611592 31162 ++485 0.0337539 31197 ++486 0.0175096 30619 ++487 0.00865906 29606 ++488 0.00420125 28271 ++489 0.00203207 26856 ++490 0.00100238 25542 ++491 0.000554405 24306 ++492 0.00055373 23160 ++493 0.0005552 22152 ++494 0.000553776 21192 ++495 0.000553636 20302 ++496 0.000553165 19505 ++497 0.000554014 18719 ++498 0.00055519 17993 ++499 0.000556582 17233 ++500 0.000788165 16569 ++501 0.00154132 15953 ++502 0.00302099 15350 ++503 0.00581186 14752 ++504 0.0108291 14267 ++505 0.0192368 13946 ++506 0.0322191 13677 ++507 0.0503789 13594 ++508 0.0730706 13768 ++509 0.0980646 14416 ++510 0.121601 15634 ++511 0.139046 17110 ++512 0.147779 18876 ++513 0.149612 20734 ++514 0.145796 22414 ++515 0.136936 23884 ++516 0.123807 25078 ++517 0.106212 26066 ++518 0.0855482 26779 ++519 0.0643386 27340 ++520 0.0452926 27530 ++521 0.0298659 27573 ++522 0.0185447 27169 ++523 0.0110178 26489 ++524 0.00635235 25588 ++525 0.00362881 24549 ++526 0.00209238 23528 ++527 0.00123133 22541 ++528 0.000755917 21498 ++529 0.000546368 20607 ++530 0.000547382 19712 ++531 0.000547084 18975 ++532 0.000546453 18178 ++533 0.000546062 17452 ++534 0.000546085 16749 ++535 0.000546151 16135 ++536 0.000545628 15567 ++537 0.000545969 14968 ++538 0.000594606 14392 ++539 0.000968849 13854 ++540 0.00168489 13360 ++541 0.00306337 12899 ++542 0.00573505 12407 ++543 0.0108348 12017 ++544 0.02025 11713 ++545 0.0368201 11517 ++546 0.0639795 11556 ++547 0.104882 11941 ++548 0.158923 12854 ++549 0.219796 14396 ++550 0.275801 16733 ++551 0.307622 19367 ++552 0.30785 22230 ++553 0.272898 24873 ++554 0.217351 27152 ++555 0.156138 29108 ++556 0.101477 30379 ++557 0.0601091 30971 ++558 0.0331551 31126 ++559 0.017167 30418 ++560 0.00853886 29430 ++561 0.00415201 28190 ++562 0.00201849 26849 ++563 0.000991957 25528 ++564 0.000546751 24180 ++565 0.00054534 23090 ++566 0.000544403 22096 ++567 0.00054368 21140 ++568 0.000543407 20213 ++569 0.000544421 19405 ++570 0.000545241 18625 ++571 0.000546995 17868 ++572 0.000547101 17102 ++573 0.00077428 16423 ++574 0.00151348 15783 ++575 0.00296212 15220 ++576 0.00569555 14602 ++577 0.0106307 14154 ++578 0.0188783 13743 ++579 0.0316572 13538 ++580 0.0495211 13467 ++581 0.0718936 13665 ++582 0.0961304 14240 ++583 0.119127 15341 ++584 0.136233 16912 ++585 0.145327 18567 ++586 0.146983 20301 ++587 0.143022 21953 ++588 0.134931 23439 ++589 0.121892 24750 ++590 0.103955 25688 ++591 0.0833804 26253 ++592 0.0625106 26918 ++593 0.0440419 27279 ++594 0.0290823 27159 ++595 0.0180758 26786 ++596 0.0107654 26049 ++597 0.00622673 25202 ++598 0.00356716 24168 ++599 0.00205866 23122 ++600 0.00121254 22076 ++601 0.000745744 21100 ++602 0.000537789 20207 ++603 0.000537982 19340 ++604 0.000537795 18527 ++605 0.000537955 17768 ++606 0.000539259 17117 ++607 0.00053942 16425 ++608 0.000540477 15701 ++609 0.000540424 15134 ++610 0.000540084 14558 ++611 0.00058571 14069 ++612 0.00095364 13498 ++613 0.00165505 13054 ++614 0.00300205 12616 ++615 0.00561724 12142 ++616 0.0106079 11720 ++617 0.0198178 11410 ++618 0.0360368 11231 ++619 0.0623418 11314 ++620 0.101856 11688 ++621 0.15376 12623 ++622 0.213046 14078 ++623 0.267285 16225 ++624 0.299225 18856 ++625 0.299517 21756 ++626 0.26697 24652 ++627 0.2119 27051 ++628 0.151393 28925 ++629 0.098869 30065 ++630 0.0593653 30570 ++631 0.0327177 30483 ++632 0.0170081 29735 ++633 0.0084493 28844 ++634 0.00409333 27665 ++635 0.00197466 26356 ++636 0.000967996 25009 ++637 0.000533137 23839 ++638 0.000532992 22721 ++639 0.000534258 21676 ++640 0.000534251 20709 ++641 0.000534556 19798 ++642 0.000535287 19008 ++643 0.000536214 18278 ++644 0.000536647 17547 ++645 0.000536556 16901 ++646 0.000761043 16256 ++647 0.00149108 15621 ++648 0.00292808 15032 ++649 0.0056527 14504 ++650 0.0105421 14010 ++651 0.0186823 13646 ++652 0.0312164 13356 ++653 0.0485643 13404 ++654 0.0704061 13612 ++655 0.0945219 14230 ++656 0.117178 15374 ++657 0.134568 16843 ++658 0.144475 18492 ++659 0.146915 20238 ++660 0.14393 21958 ++661 0.134621 23537 ++662 0.121737 24773 ++663 0.104744 25772 ++664 0.0846226 26427 ++665 0.0639754 27040 ++666 0.0448457 27279 ++667 0.029482 27106 ++668 0.0183036 26853 ++669 0.0108721 26178 ++670 0.00627116 25425 ++671 0.0035776 24326 ++672 0.00206466 23279 ++673 0.00122064 22191 ++674 0.000751578 21231 ++675 0.000542574 20323 ++676 0.000540396 19496 ++677 0.000538805 18651 ++678 0.00053881 17920 ++679 0.000537801 17217 ++680 0.000537866 16520 ++681 0.000538522 15876 ++682 0.000538795 15229 ++683 0.000539519 14656 ++684 0.000587348 14121 ++685 0.000955855 13626 ++686 0.00165656 13086 ++687 0.00301095 12666 ++688 0.00564993 12250 ++689 0.0106767 11869 ++690 0.0199729 11524 ++691 0.03641 11331 ++692 0.0632378 11402 ++693 0.103483 11788 ++694 0.156399 12682 ++695 0.215591 14337 ++696 0.269462 16547 ++697 0.303615 19239 ++698 0.304506 22023 ++699 0.273068 24769 ++700 0.21682 27223 ++701 0.154934 29029 ++702 0.100495 30241 ++703 0.0597382 30801 ++704 0.0329221 30881 ++705 0.0170591 30288 ++706 0.00845353 29329 ++707 0.00408176 28108 ++708 0.00198037 26715 ++709 0.000977102 25340 ++710 0.000541566 24039 ++711 0.000542333 22965 ++712 0.000542417 21858 ++713 0.000541182 20952 ++714 0.00054038 20049 ++715 0.000539725 19192 ++716 0.000539603 18409 ++717 0.000539754 17700 ++718 0.000539679 16960 ++719 0.000763508 16287 ++720 0.00149327 15637 ++721 0.00292609 15057 ++722 0.00563308 14524 ++723 0.0104893 14003 ++724 0.0185874 13625 ++725 0.0310985 13319 ++726 0.0487417 13278 ++727 0.0707124 13502 ++728 0.0947795 14147 ++729 0.117155 15183 ++730 0.133995 16622 diff --cc vendor/flate2-0.2.20/tests/gunzip.rs index 000000000,000000000..37dcefe35 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/tests/gunzip.rs @@@ -1,0 -1,0 +1,59 @@@ ++extern crate flate2; ++ ++use std::fs::File; ++use std::io::prelude::*; ++use std::io::{self, BufReader}; ++use std::path::Path; ++use flate2::read::GzDecoder; ++use flate2::read::MultiGzDecoder; ++ ++// test extraction of a gzipped file ++#[test] ++fn test_extract_success() { ++ let content = extract_file(Path::new("tests/good-file.gz")).unwrap(); ++ let mut expected = Vec::new(); ++ File::open("tests/good-file.txt").unwrap().read_to_end(&mut expected).unwrap(); ++ assert!(content == expected); ++} ++// ++// test partial extraction of a multistream gzipped file ++#[test] ++fn test_extract_success_partial_multi() { ++ let content = extract_file(Path::new("tests/multi.gz")).unwrap(); ++ let mut expected = String::new(); ++ BufReader::new(File::open("tests/multi.txt").unwrap()).read_line(&mut expected).unwrap(); ++ assert_eq!(content, expected.as_bytes()); ++} ++ ++// test extraction fails on a corrupt file ++#[test] ++fn test_extract_failure() { ++ let result = extract_file(Path::new("tests/corrupt-file.gz")); ++ assert_eq!(result.err().unwrap().kind(), io::ErrorKind::InvalidInput); ++} ++ ++//test complete extraction of a multistream gzipped file ++#[test] ++fn test_extract_success_multi() { ++ let content = extract_file_multi(Path::new("tests/multi.gz")).unwrap(); ++ let mut expected = Vec::new(); ++ File::open("tests/multi.txt").unwrap().read_to_end(&mut expected).unwrap(); ++ assert_eq!(content, expected); ++} ++ ++// Tries to extract path into memory (assuming a .gz file). ++fn extract_file(path_compressed: &Path) -> io::Result>{ ++ let mut v = Vec::new(); ++ let f = try!(File::open(path_compressed)); ++ try!(try!(GzDecoder::new(f)).read_to_end(&mut v)); ++ Ok(v) ++} ++ ++// Tries to extract path into memory (decompressing all members in case ++// of a multi member .gz file). ++fn extract_file_multi(path_compressed: &Path) -> io::Result>{ ++ let mut v = Vec::new(); ++ let f = try!(File::open(path_compressed)); ++ try!(try!(MultiGzDecoder::new(f)).read_to_end(&mut v)); ++ Ok(v) ++} diff --cc vendor/flate2-0.2.20/tests/multi.gz index 000000000,000000000..cabc89630 new file mode 100644 Binary files differ diff --cc vendor/flate2-0.2.20/tests/multi.txt index 000000000,000000000..66a52ee7a new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/tests/multi.txt @@@ -1,0 -1,0 +1,2 @@@ ++first ++second diff --cc vendor/flate2-0.2.20/tests/tokio.rs index 000000000,000000000..47fb55c12 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/tests/tokio.rs @@@ -1,0 -1,0 +1,125 @@@ ++#![cfg(feature = "tokio")] ++ ++extern crate tokio_core; ++extern crate flate2; ++extern crate tokio_io; ++extern crate futures; ++extern crate rand; ++ ++use std::thread; ++use std::net::{Shutdown, TcpListener}; ++use std::io::{Read, Write}; ++ ++use flate2::Compression; ++use flate2::read; ++use flate2::write; ++use futures::Future; ++use rand::{Rng, thread_rng}; ++use tokio_core::net::TcpStream; ++use tokio_core::reactor::Core; ++use tokio_io::AsyncRead; ++use tokio_io::io::{copy, shutdown}; ++ ++#[test] ++fn tcp_stream_echo_pattern() { ++ const N: u8 = 16; ++ const M: usize = 16 * 1024; ++ ++ let mut core = Core::new().unwrap(); ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let addr = listener.local_addr().unwrap(); ++ let t = thread::spawn(move || { ++ let a = listener.accept().unwrap().0; ++ let b = a.try_clone().unwrap(); ++ ++ let t = thread::spawn(move || { ++ let mut b = read::DeflateDecoder::new(b); ++ let mut buf = [0; M]; ++ for i in 0..N { ++ b.read_exact(&mut buf).unwrap(); ++ for byte in buf.iter() { ++ assert_eq!(*byte, i); ++ } ++ } ++ ++ assert_eq!(b.read(&mut buf).unwrap(), 0); ++ }); ++ ++ let mut a = write::ZlibEncoder::new(a, Compression::Default); ++ for i in 0..N { ++ let buf = [i; M]; ++ a.write_all(&buf).unwrap(); ++ } ++ a.finish().unwrap() ++ .shutdown(Shutdown::Write).unwrap(); ++ ++ t.join().unwrap(); ++ }); ++ ++ let handle = core.handle(); ++ let stream = TcpStream::connect(&addr, &handle); ++ let copy = stream.and_then(|s| { ++ let (a, b) = s.split(); ++ let a = read::ZlibDecoder::new(a); ++ let b = write::DeflateEncoder::new(b, Compression::Default); ++ copy(a, b) ++ }).then(|result| { ++ let (amt, _a, b) = result.unwrap(); ++ assert_eq!(amt, (N as u64) * (M as u64)); ++ shutdown(b).map(|_| ()) ++ }); ++ ++ core.run(copy).unwrap(); ++ t.join().unwrap(); ++} ++ ++#[test] ++fn echo_random() { ++ let v = thread_rng().gen_iter::().take(1024 * 1024).collect::>(); ++ let mut core = Core::new().unwrap(); ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let addr = listener.local_addr().unwrap(); ++ let v2 = v.clone(); ++ let t = thread::spawn(move || { ++ let a = listener.accept().unwrap().0; ++ let b = a.try_clone().unwrap(); ++ ++ let mut v3 = v2.clone(); ++ let t = thread::spawn(move || { ++ let mut b = read::DeflateDecoder::new(b); ++ let mut buf = [0; 1024]; ++ while v3.len() > 0 { ++ let n = b.read(&mut buf).unwrap(); ++ for (actual, expected) in buf[..n].iter().zip(&v3) { ++ assert_eq!(*actual, *expected); ++ } ++ v3.drain(..n); ++ } ++ ++ assert_eq!(b.read(&mut buf).unwrap(), 0); ++ }); ++ ++ let mut a = write::ZlibEncoder::new(a, Compression::Default); ++ a.write_all(&v2).unwrap(); ++ a.finish().unwrap() ++ .shutdown(Shutdown::Write).unwrap(); ++ ++ t.join().unwrap(); ++ }); ++ ++ let handle = core.handle(); ++ let stream = TcpStream::connect(&addr, &handle); ++ let copy = stream.and_then(|s| { ++ let (a, b) = s.split(); ++ let a = read::ZlibDecoder::new(a); ++ let b = write::DeflateEncoder::new(b, Compression::Default); ++ copy(a, b) ++ }).then(|result| { ++ let (amt, _a, b) = result.unwrap(); ++ assert_eq!(amt, v.len() as u64); ++ shutdown(b).map(|_| ()) ++ }); ++ ++ core.run(copy).unwrap(); ++ t.join().unwrap(); ++} diff --cc vendor/flate2-0.2.20/tests/zero-write.rs index 000000000,000000000..8174e0c39 new file mode 100644 --- /dev/null +++ b/vendor/flate2-0.2.20/tests/zero-write.rs @@@ -1,0 -1,0 +1,8 @@@ ++extern crate flate2; ++ ++#[test] ++fn zero_write_is_error() { ++ let mut buf = [0u8]; ++ let writer = flate2::write::DeflateEncoder::new(&mut buf[..], flate2::Compression::Default); ++ assert!(writer.finish().is_err()); ++} diff --cc vendor/git2-0.6.8/.cargo-checksum.json index 000000000,000000000..e50849050 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"0c1c0203d653f4140241da0c1375a404f0a397249ec818cd2076c6280c50f6fa"} diff --cc vendor/git2-0.6.8/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/.cargo-ok diff --cc vendor/git2-0.6.8/.gitmodules index 000000000,000000000..95c45cce4 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/.gitmodules @@@ -1,0 -1,0 +1,3 @@@ ++[submodule "libgit2-sys/libgit2"] ++ path = libgit2-sys/libgit2 ++ url = https://github.com/libgit2/libgit2 diff --cc vendor/git2-0.6.8/.travis.yml index 000000000,000000000..c62fb4d7f new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/.travis.yml @@@ -1,0 -1,0 +1,47 @@@ ++language: rust ++rust: ++ - stable ++ - beta ++ - nightly ++sudo: false ++git: ++ submodules: false ++before_script: ++ - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH ++script: ++ - git submodule update --init ++ - cargo test --no-default-features ++ - cargo test ++ - cargo run --manifest-path systest/Cargo.toml --release ++ - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then ++ cargo test --features unstable; ++ cargo test --manifest-path git2-curl/Cargo.toml; ++ fi ++ - cargo doc --no-deps ++ - cargo doc --manifest-path=git2-curl/Cargo.toml --no-deps ++ - cargo doc --manifest-path=libgit2-sys/Cargo.toml --no-deps ++after_success: ++ - travis-cargo --only nightly doc-upload ++ - travis-cargo coveralls --no-sudo ++notifications: ++ email: ++ on_success: never ++matrix: ++ include: ++ - os: osx ++ rust: stable ++ before_install: ++ - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include ++ - export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib ++addons: ++ apt: ++ sources: ++ - kalakris-cmake ++ packages: ++ - cmake ++ - libcurl4-openssl-dev ++ - libelf-dev ++ - libdw-dev ++env: ++ global: ++ secure: "SVk5cv4VnBQAoaBXt9pIHk+FQ7Z58zT5EaPo7Ac81LltKztwHovhN/R1otKzgrAJqFsZ/nKR4cGyQGbYtfVJcsqweQVM75LI6Oh6lYyEdfX211ZI3SWQ50JO93CmwLtanC5UpECdXvJLCgXrHGJXuL1oi7hySGy47/yQlKH6eaM=" diff --cc vendor/git2-0.6.8/Cargo.toml index 000000000,000000000..6afbc8c41 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/Cargo.toml @@@ -1,0 -1,0 +1,68 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "git2" ++version = "0.6.8" ++authors = ["Alex Crichton "] ++description = "Bindings to libgit2 for interoperating with git repositories. This library is\nboth threadsafe and memory safe and allows both reading and writing git\nrepositories.\n" ++homepage = "https://github.com/alexcrichton/git2-rs" ++documentation = "https://docs.rs/git2" ++readme = "README.md" ++keywords = ["git"] ++categories = ["api-bindings"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/git2-rs" ++[dependencies.url] ++version = "1.0" ++ ++[dependencies.libc] ++version = "0.2" ++ ++[dependencies.bitflags] ++version = "0.9" ++ ++[dependencies.libgit2-sys] ++version = "0.6.14" ++[dev-dependencies.tempdir] ++version = "0.3" ++ ++[dev-dependencies.serde] ++version = "1.0" ++ ++[dev-dependencies.docopt] ++version = "0.8" ++ ++[dev-dependencies.serde_derive] ++version = "1.0" ++ ++[dev-dependencies.time] ++version = "0.1" ++ ++[features] ++default = ["ssh", "https", "curl"] ++curl = ["libgit2-sys/curl"] ++https = ["libgit2-sys/https", "openssl-sys", "openssl-probe"] ++unstable = [] ++ssh = ["libgit2-sys/ssh"] ++[target."cfg(all(unix, not(target_os = \"macos\")))".dependencies.openssl-probe] ++version = "0.1" ++optional = true ++ ++[target."cfg(all(unix, not(target_os = \"macos\")))".dependencies.openssl-sys] ++version = "0.9.0" ++optional = true ++[badges.appveyor] ++repository = "alexcrichton/git2-rs" ++ ++[badges.travis-ci] ++repository = "alexcrichton/git2-rs" diff --cc vendor/git2-0.6.8/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/git2-0.6.8/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/git2-0.6.8/README.md index 000000000,000000000..1d32bf8f5 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/README.md @@@ -1,0 -1,0 +1,47 @@@ ++# git2-rs ++ ++[![Build Status](https://travis-ci.org/alexcrichton/git2-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/git2-rs) ++[![Build Status](https://ci.appveyor.com/api/projects/status/6vem3xgno2kuxnfm?svg=true)](https://ci.appveyor.com/project/alexcrichton/git2-rs) ++ ++[Documentation](https://docs.rs/git2) ++ ++libgit2 bindings for Rust ++ ++```toml ++[dependencies] ++git2 = "0.6" ++``` ++ ++## Version of libgit2 ++ ++Currently this library requires libgit2 0.25.1. The source for libgit2 is ++included in the libgit2-sys crate so there's no need to pre-install the libgit2 ++library, the libgit2-sys crate will figure that and/or build that for you. ++ ++## Building git2-rs ++ ++First, you'll need to install _CMake_. Afterwards, just run: ++ ++```sh ++$ git clone https://github.com/alexcrichton/git2-rs ++$ cd git2-rs ++$ cargo build ++``` ++ ++## Building on OSX 10.10+ ++ ++Currently libssh2 requires linking against OpenSSL, and to compile libssh2 it ++also needs to find the OpenSSL headers. On OSX 10.10+ the OpenSSL headers have ++been removed, but if you're using Homebrew you can install them via: ++ ++```sh ++brew install openssl ++``` ++ ++# License ++ ++`git2-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 --cc vendor/git2-0.6.8/appveyor.yml index 000000000,000000000..31aaccb0e new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/appveyor.yml @@@ -1,0 -1,0 +1,23 @@@ ++environment: ++ matrix: ++ - TARGET: x86_64-pc-windows-gnu ++ MSYS_BITS: 64 ++ - TARGET: i686-pc-windows-gnu ++ MSYS_BITS: 32 ++ - TARGET: x86_64-pc-windows-msvc ++ - TARGET: i686-pc-windows-msvc ++install: ++ - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" ++ - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" ++ - set PATH=%PATH%;C:\Program Files (x86)\Rust\bin ++ - if defined MSYS_BITS set PATH=C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin;%PATH% ++ - set CARGO_TARGET_DIR=%APPVEYOR_BUILD_FOLDER%\target ++ - rustc -V ++ - cargo -V ++ ++build: false ++ ++test_script: ++ - cargo test --target %TARGET% ++ - cargo test --no-default-features --target %TARGET% ++ - cargo run --manifest-path systest/Cargo.toml --target %TARGET% diff --cc vendor/git2-0.6.8/examples/add.rs index 000000000,000000000..71082d09b new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/add.rs @@@ -1,0 -1,0 +1,85 @@@ ++/* ++ * libgit2 "add" example - shows how to modify the index ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++#![allow(trivial_casts)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use std::path::Path; ++use docopt::Docopt; ++use git2::Repository; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_spec: Vec, ++ flag_dry_run: bool, ++ flag_verbose: bool, ++ flag_update: bool, ++} ++ ++fn run(args: &Args) -> Result<(), git2::Error> { ++ let repo = try!(Repository::open(&Path::new("."))); ++ let mut index = try!(repo.index()); ++ ++ let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { ++ let status = repo.status_file(path).unwrap(); ++ ++ let ret = if status.contains(git2::STATUS_WT_MODIFIED) || ++ status.contains(git2::STATUS_WT_NEW) { ++ println!("add '{}'", path.display()); ++ 0 ++ } else { ++ 1 ++ }; ++ ++ if args.flag_dry_run {1} else {ret} ++ }; ++ let cb = if args.flag_verbose || args.flag_update { ++ Some(cb as &mut git2::IndexMatchedPath) ++ } else { ++ None ++ }; ++ ++ if args.flag_update { ++ try!(index.update_all(args.arg_spec.iter(), cb)); ++ } else { ++ try!(index.add_all(args.arg_spec.iter(), git2::ADD_DEFAULT, cb)); ++ } ++ ++ try!(index.write()); ++ Ok(()) ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: add [options] [--] [..] ++ ++Options: ++ -n, --dry-run dry run ++ -v, --verbose be verbose ++ -u, --update update tracked files ++ -h, --help show this message ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/examples/blame.rs index 000000000,000000000..fcd890ad9 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/blame.rs @@@ -1,0 -1,0 +1,106 @@@ ++/* ++ * libgit2 "blame" example - shows how to use the blame API ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use docopt::Docopt; ++use git2::{Repository, BlameOptions}; ++use std::path::Path; ++use std::io::{BufReader, BufRead}; ++ ++#[derive(Deserialize)] #[allow(non_snake_case)] ++struct Args { ++ arg_path: String, ++ arg_spec: Option, ++ flag_M: bool, ++ flag_C: bool, ++ flag_F: bool, ++} ++ ++fn run(args: &Args) -> Result<(), git2::Error> { ++ let repo = try!(Repository::open(".")); ++ let path = Path::new(&args.arg_path[..]); ++ ++ // Prepare our blame options ++ let mut opts = BlameOptions::new(); ++ opts.track_copies_same_commit_moves(args.flag_M) ++ .track_copies_same_commit_copies(args.flag_C) ++ .first_parent(args.flag_F); ++ ++ let mut commit_id = "HEAD".to_string(); ++ ++ // Parse spec ++ if let Some(spec) = args.arg_spec.as_ref() { ++ ++ let revspec = try!(repo.revparse(spec)); ++ ++ let (oldest, newest) = if revspec.mode().contains(git2::REVPARSE_SINGLE) { ++ (None, revspec.from()) ++ } else if revspec.mode().contains(git2::REVPARSE_RANGE) { ++ (revspec.from(), revspec.to()) ++ } else { ++ (None, None) ++ }; ++ ++ if let Some(commit) = oldest { ++ opts.oldest_commit(commit.id()); ++ } ++ ++ if let Some(commit) = newest { ++ opts.newest_commit(commit.id()); ++ if !commit.id().is_zero() { ++ commit_id = format!("{}", commit.id()) ++ } ++ } ++ ++ } ++ ++ let spec = format!("{}:{}", commit_id, path.display()); ++ let blame = try!(repo.blame_file(path, Some(&mut opts))); ++ let object = try!(repo.revparse_single(&spec[..])); ++ let blob = try!(repo.find_blob(object.id())); ++ let reader = BufReader::new(blob.content()); ++ ++ for (i, line) in reader.lines().enumerate() { ++ if let (Ok(line), Some(hunk)) = (line, blame.get_line(i+1)) { ++ let sig = hunk.final_signature(); ++ println!("{} {} <{}> {}", hunk.final_commit_id(), ++ String::from_utf8_lossy(sig.name_bytes()), ++ String::from_utf8_lossy(sig.email_bytes()), line); ++ } ++ } ++ ++ Ok(()) ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: blame [options] [] ++ ++Options: ++ -M find line moves within and across files ++ -C find line copies within and across files ++ -F follow only the first parent commits ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/examples/cat-file.rs index 000000000,000000000..68117bd88 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/cat-file.rs @@@ -1,0 -1,0 +1,142 @@@ ++/* ++ * libgit2 "cat-file" example - shows how to print data from the ODB ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use std::io::{self, Write}; ++ ++use docopt::Docopt; ++use git2::{Repository, ObjectType, Blob, Commit, Signature, Tag, Tree}; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_object: String, ++ flag_t: bool, ++ flag_s: bool, ++ flag_e: bool, ++ flag_p: bool, ++ flag_q: bool, ++ flag_v: bool, ++ flag_git_dir: Option, ++} ++ ++fn run(args: &Args) -> Result<(), git2::Error> { ++ let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); ++ let repo = try!(Repository::open(path)); ++ ++ let obj = try!(repo.revparse_single(&args.arg_object)); ++ if args.flag_v && !args.flag_q { ++ println!("{} {}\n--", obj.kind().unwrap().str(), obj.id()); ++ } ++ ++ if args.flag_t { ++ println!("{}", obj.kind().unwrap().str()); ++ } else if args.flag_s || args.flag_e { ++ /* ... */ ++ } else if args.flag_p { ++ match obj.kind() { ++ Some(ObjectType::Blob) => { ++ show_blob(obj.as_blob().unwrap()); ++ } ++ Some(ObjectType::Commit) => { ++ show_commit(obj.as_commit().unwrap()); ++ } ++ Some(ObjectType::Tag) => { ++ show_tag(obj.as_tag().unwrap()); ++ } ++ Some(ObjectType::Tree) => { ++ show_tree(obj.as_tree().unwrap()); ++ } ++ Some(ObjectType::Any) | None => { ++ println!("unknown {}", obj.id()) ++ } ++ } ++ } ++ Ok(()) ++} ++ ++fn show_blob(blob: &Blob) { ++ io::stdout().write_all(blob.content()).unwrap(); ++} ++ ++fn show_commit(commit: &Commit) { ++ println!("tree {}", commit.tree_id()); ++ for parent in commit.parent_ids() { ++ println!("parent {}", parent); ++ } ++ show_sig("author", Some(commit.author())); ++ show_sig("committer", Some(commit.committer())); ++ if let Some(msg) = commit.message() { ++ println!("\n{}", msg); ++ } ++} ++ ++fn show_tag(tag: &Tag) { ++ println!("object {}", tag.target_id()); ++ println!("type {}", tag.target_type().unwrap().str()); ++ println!("tag {}", tag.name().unwrap()); ++ show_sig("tagger", tag.tagger()); ++ ++ if let Some(msg) = tag.message() { ++ println!("\n{}", msg); ++ } ++} ++ ++fn show_tree(tree: &Tree) { ++ for entry in tree.iter() { ++ println!("{:06o} {} {}\t{}", ++ entry.filemode(), ++ entry.kind().unwrap().str(), ++ entry.id(), ++ entry.name().unwrap()); ++ } ++} ++ ++fn show_sig(header: &str, sig: Option) { ++ let sig = match sig { Some(s) => s, None => return }; ++ let offset = sig.when().offset_minutes(); ++ let (sign, offset) = if offset < 0 {('-', -offset)} else {('+', offset)}; ++ let (hours, minutes) = (offset / 60, offset % 60); ++ println!("{} {} {} {}{:02}{:02}", ++ header, sig, sig.when().seconds(), sign, hours, minutes); ++ ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: cat-file (-t | -s | -e | -p) [options] ++ ++Options: ++ -t show the object type ++ -s show the object size ++ -e suppress all output ++ -p pretty print the contents of the object ++ -q suppress output ++ -v use verbose output ++ --git-dir use the specified directory as the base directory ++ -h, --help show this message ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/examples/clone.rs index 000000000,000000000..3bd72bc2e new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/clone.rs @@@ -1,0 -1,0 +1,124 @@@ ++/* ++ * libgit2 "clone" example ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use docopt::Docopt; ++use git2::build::{RepoBuilder, CheckoutBuilder}; ++use git2::{RemoteCallbacks, Progress, FetchOptions}; ++use std::cell::RefCell; ++use std::io::{self, Write}; ++use std::path::{Path, PathBuf}; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_url: String, ++ arg_path: String, ++} ++ ++struct State { ++ progress: Option>, ++ total: usize, ++ current: usize, ++ path: Option, ++ newline: bool, ++} ++ ++fn print(state: &mut State) { ++ let stats = state.progress.as_ref().unwrap(); ++ let network_pct = (100 * stats.received_objects()) / stats.total_objects(); ++ let index_pct = (100 * stats.indexed_objects()) / stats.total_objects(); ++ let co_pct = if state.total > 0 { ++ (100 * state.current) / state.total ++ } else { ++ 0 ++ }; ++ let kbytes = stats.received_bytes() / 1024; ++ if stats.received_objects() == stats.total_objects() { ++ if !state.newline { ++ println!(""); ++ state.newline = true; ++ } ++ print!("Resolving deltas {}/{}\r", stats.indexed_deltas(), ++ stats.total_deltas()); ++ } else { ++ print!("net {:3}% ({:4} kb, {:5}/{:5}) / idx {:3}% ({:5}/{:5}) \ ++ / chk {:3}% ({:4}/{:4}) {}\r", ++ network_pct, kbytes, stats.received_objects(), ++ stats.total_objects(), ++ index_pct, stats.indexed_objects(), stats.total_objects(), ++ co_pct, state.current, state.total, ++ state.path ++ .as_ref() ++ .map(|s| s.to_string_lossy().into_owned()) ++ .unwrap_or_default()) ++ } ++ io::stdout().flush().unwrap(); ++} ++ ++fn run(args: &Args) -> Result<(), git2::Error> { ++ let state = RefCell::new(State { ++ progress: None, ++ total: 0, ++ current: 0, ++ path: None, ++ newline: false, ++ }); ++ let mut cb = RemoteCallbacks::new(); ++ cb.transfer_progress(|stats| { ++ let mut state = state.borrow_mut(); ++ state.progress = Some(stats.to_owned()); ++ print(&mut *state); ++ true ++ }); ++ ++ let mut co = CheckoutBuilder::new(); ++ co.progress(|path, cur, total| { ++ let mut state = state.borrow_mut(); ++ state.path = path.map(|p| p.to_path_buf()); ++ state.current = cur; ++ state.total = total; ++ print(&mut *state); ++ }); ++ ++ let mut fo = FetchOptions::new(); ++ fo.remote_callbacks(cb); ++ try!(RepoBuilder::new().fetch_options(fo).with_checkout(co) ++ .clone(&args.arg_url, Path::new(&args.arg_path))); ++ println!(""); ++ ++ Ok(()) ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: add [options] ++ ++Options: ++ -h, --help show this message ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} ++ diff --cc vendor/git2-0.6.8/examples/diff.rs index 000000000,000000000..a74307692 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/diff.rs @@@ -1,0 -1,0 +1,284 @@@ ++/* ++ * libgit2 "diff" example - shows how to use the diff API ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use std::str; ++ ++use docopt::Docopt; ++use git2::{Repository, Error, Object, ObjectType, DiffOptions, Diff}; ++use git2::{DiffFindOptions, DiffFormat}; ++ ++#[derive(Deserialize)] #[allow(non_snake_case)] ++struct Args { ++ arg_from_oid: Option, ++ arg_to_oid: Option, ++ flag_patch: bool, ++ flag_cached: bool, ++ flag_nocached: bool, ++ flag_name_only: bool, ++ flag_name_status: bool, ++ flag_raw: bool, ++ flag_format: Option, ++ flag_color: bool, ++ flag_no_color: bool, ++ flag_R: bool, ++ flag_text: bool, ++ flag_ignore_space_at_eol: bool, ++ flag_ignore_space_change: bool, ++ flag_ignore_all_space: bool, ++ flag_ignored: bool, ++ flag_untracked: bool, ++ flag_patience: bool, ++ flag_minimal: bool, ++ flag_stat: bool, ++ flag_numstat: bool, ++ flag_shortstat: bool, ++ flag_summary: bool, ++ flag_find_renames: Option, ++ flag_find_copies: Option, ++ flag_find_copies_harder: bool, ++ flag_break_rewrites: bool, ++ flag_unified: Option, ++ flag_inter_hunk_context: Option, ++ flag_abbrev: Option, ++ flag_src_prefix: Option, ++ flag_dst_prefix: Option, ++ flag_git_dir: Option, ++} ++ ++const RESET: &'static str = "\u{1b}[m"; ++const BOLD: &'static str = "\u{1b}[1m"; ++const RED: &'static str = "\u{1b}[31m"; ++const GREEN: &'static str = "\u{1b}[32m"; ++const CYAN: &'static str = "\u{1b}[36m"; ++ ++#[derive(PartialEq, Eq, Copy, Clone)] ++enum Cache { Normal, Only, None } ++ ++fn run(args: &Args) -> Result<(), Error> { ++ let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); ++ let repo = try!(Repository::open(path)); ++ ++ // Prepare our diff options based on the arguments given ++ let mut opts = DiffOptions::new(); ++ opts.reverse(args.flag_R) ++ .force_text(args.flag_text) ++ .ignore_whitespace_eol(args.flag_ignore_space_at_eol) ++ .ignore_whitespace_change(args.flag_ignore_space_change) ++ .ignore_whitespace(args.flag_ignore_all_space) ++ .include_ignored(args.flag_ignored) ++ .include_untracked(args.flag_untracked) ++ .patience(args.flag_patience) ++ .minimal(args.flag_minimal); ++ if let Some(amt) = args.flag_unified { opts.context_lines(amt); } ++ if let Some(amt) = args.flag_inter_hunk_context { opts.interhunk_lines(amt); } ++ if let Some(amt) = args.flag_abbrev { opts.id_abbrev(amt); } ++ if let Some(ref s) = args.flag_src_prefix { opts.old_prefix(&s); } ++ if let Some(ref s) = args.flag_dst_prefix { opts.new_prefix(&s); } ++ if let Some("diff-index") = args.flag_format.as_ref().map(|s| &s[..]) { ++ opts.id_abbrev(40); ++ } ++ ++ // Prepare the diff to inspect ++ let t1 = try!(tree_to_treeish(&repo, args.arg_from_oid.as_ref())); ++ let t2 = try!(tree_to_treeish(&repo, args.arg_to_oid.as_ref())); ++ let head = try!(tree_to_treeish(&repo, Some(&"HEAD".to_string()))).unwrap(); ++ let mut diff = match (t1, t2, args.cache()) { ++ (Some(t1), Some(t2), _) => { ++ try!(repo.diff_tree_to_tree(t1.as_tree(), t2.as_tree(), ++ Some(&mut opts))) ++ } ++ (t1, None, Cache::None) => { ++ let t1 = t1.unwrap_or(head); ++ try!(repo.diff_tree_to_workdir(t1.as_tree(), Some(&mut opts))) ++ } ++ (t1, None, Cache::Only) => { ++ let t1 = t1.unwrap_or(head); ++ try!(repo.diff_tree_to_index(t1.as_tree(), None, Some(&mut opts))) ++ } ++ (Some(t1), None, _) => { ++ try!(repo.diff_tree_to_workdir_with_index(t1.as_tree(), ++ Some(&mut opts))) ++ } ++ (None, None, _) => { ++ try!(repo.diff_index_to_workdir(None, Some(&mut opts))) ++ } ++ (None, Some(_), _) => unreachable!(), ++ }; ++ ++ // Apply rename and copy detection if requested ++ if args.flag_break_rewrites || args.flag_find_copies_harder || ++ args.flag_find_renames.is_some() || args.flag_find_copies.is_some() ++ { ++ let mut opts = DiffFindOptions::new(); ++ if let Some(t) = args.flag_find_renames { ++ opts.rename_threshold(t); ++ opts.renames(true); ++ } ++ if let Some(t) = args.flag_find_copies { ++ opts.copy_threshold(t); ++ opts.copies(true); ++ } ++ opts.copies_from_unmodified(args.flag_find_copies_harder) ++ .rewrites(args.flag_break_rewrites); ++ try!(diff.find_similar(Some(&mut opts))); ++ } ++ ++ // Generate simple output ++ let stats = args.flag_stat | args.flag_numstat | args.flag_shortstat | ++ args.flag_summary; ++ if stats { ++ try!(print_stats(&diff, args)); ++ } ++ if args.flag_patch || !stats { ++ if args.color() { print!("{}", RESET); } ++ let mut last_color = None; ++ try!(diff.print(args.diff_format(), |_delta, _hunk, line| { ++ if args.color() { ++ let next = match line.origin() { ++ '+' => Some(GREEN), ++ '-' => Some(RED), ++ '>' => Some(GREEN), ++ '<' => Some(RED), ++ 'F' => Some(BOLD), ++ 'H' => Some(CYAN), ++ _ => None ++ }; ++ if args.color() && next != last_color { ++ if last_color == Some(BOLD) || next == Some(BOLD) { ++ print!("{}", RESET); ++ } ++ print!("{}", next.unwrap_or(RESET)); ++ last_color = next; ++ } ++ } ++ ++ match line.origin() { ++ '+' | '-' | ' ' => print!("{}", line.origin()), ++ _ => {} ++ } ++ print!("{}", str::from_utf8(line.content()).unwrap()); ++ true ++ })); ++ if args.color() { print!("{}", RESET); } ++ } ++ ++ Ok(()) ++} ++ ++fn print_stats(diff: &Diff, args: &Args) -> Result<(), Error> { ++ let stats = try!(diff.stats()); ++ let mut format = git2::DIFF_STATS_NONE; ++ if args.flag_stat { ++ format |= git2::DIFF_STATS_FULL; ++ } ++ if args.flag_shortstat { ++ format |= git2::DIFF_STATS_SHORT; ++ } ++ if args.flag_numstat { ++ format |= git2::DIFF_STATS_NUMBER; ++ } ++ if args.flag_summary { ++ format |= git2::DIFF_STATS_INCLUDE_SUMMARY; ++ } ++ let buf = try!(stats.to_buf(format, 80)); ++ print!("{}", str::from_utf8(&*buf).unwrap()); ++ Ok(()) ++} ++ ++fn tree_to_treeish<'a>(repo: &'a Repository, arg: Option<&String>) ++ -> Result>, Error> { ++ let arg = match arg { Some(s) => s, None => return Ok(None) }; ++ let obj = try!(repo.revparse_single(arg)); ++ let tree = try!(obj.peel(ObjectType::Tree)); ++ Ok(Some(tree)) ++} ++ ++impl Args { ++ fn cache(&self) -> Cache { ++ if self.flag_cached {Cache::Only} ++ else if self.flag_nocached {Cache::None} ++ else {Cache::Normal} ++ } ++ fn color(&self) -> bool { self.flag_color && !self.flag_no_color } ++ fn diff_format(&self) -> DiffFormat { ++ if self.flag_patch {DiffFormat::Patch} ++ else if self.flag_name_only {DiffFormat::NameOnly} ++ else if self.flag_name_status {DiffFormat::NameStatus} ++ else if self.flag_raw {DiffFormat::Raw} ++ else { ++ match self.flag_format.as_ref().map(|s| &s[..]) { ++ Some("name") => DiffFormat::NameOnly, ++ Some("name-status") => DiffFormat::NameStatus, ++ Some("raw") => DiffFormat::Raw, ++ Some("diff-index") => DiffFormat::Raw, ++ _ => DiffFormat::Patch, ++ } ++ } ++ } ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: diff [options] [ []] ++ ++Options: ++ -p, --patch show output in patch format ++ --cached use staged changes as diff ++ --nocached do not use staged changes ++ --name-only show only names of changed files ++ --name-status show only names and status changes ++ --raw generate the raw format ++ --format= specify format for stat summary ++ --color use color output ++ --no-color never use color output ++ -R swap two inputs ++ -a, --text treat all files as text ++ --ignore-space-at-eol ignore changes in whitespace at EOL ++ -b, --ignore-space-change ignore changes in amount of whitespace ++ -w, --ignore-all-space ignore whitespace when comparing lines ++ --ignored show ignored files as well ++ --untracked show untracked files ++ --patience generate diff using the patience algorithm ++ --minimal spend extra time to find smallest diff ++ --stat generate a diffstat ++ --numstat similar to --stat, but more machine friendly ++ --shortstat only output last line of --stat ++ --summary output condensed summary of header info ++ -M, --find-renames set threshold for findind renames (default 50) ++ -C, --find-copies set threshold for finding copies (default 50) ++ --find-copies-harder inspect unmodified files for sources of copies ++ -B, --break-rewrites break complete rewrite changes into pairs ++ -U, --unified lints of context to show ++ --inter-hunk-context maximum lines of change between hunks ++ --abbrev length to abbreviate commits to ++ --src-prefix show given source prefix instead of 'a/' ++ --dst-prefix show given destinction prefix instead of 'b/' ++ --git-dir path to git repository to use ++ -h, --help show this message ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/examples/fetch.rs index 000000000,000000000..c667d7b63 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/fetch.rs @@@ -1,0 -1,0 +1,128 @@@ ++/* ++ * libgit2 "fetch" example - shows how to fetch remote data ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use docopt::Docopt; ++use git2::{Repository, RemoteCallbacks, AutotagOption, FetchOptions}; ++use std::io::{self, Write}; ++use std::str; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_remote: Option, ++} ++ ++fn run(args: &Args) -> Result<(), git2::Error> { ++ let repo = try!(Repository::open(".")); ++ let remote = args.arg_remote.as_ref().map(|s| &s[..]).unwrap_or("origin"); ++ ++ // Figure out whether it's a named remote or a URL ++ println!("Fetching {} for repo", remote); ++ let mut cb = RemoteCallbacks::new(); ++ let mut remote = try!(repo.find_remote(remote).or_else(|_| { ++ repo.remote_anonymous(remote) ++ })); ++ cb.sideband_progress(|data| { ++ print!("remote: {}", str::from_utf8(data).unwrap()); ++ io::stdout().flush().unwrap(); ++ true ++ }); ++ ++ // This callback gets called for each remote-tracking branch that gets ++ // updated. The message we output depends on whether it's a new one or an ++ // update. ++ cb.update_tips(|refname, a, b| { ++ if a.is_zero() { ++ println!("[new] {:20} {}", b, refname); ++ } else { ++ println!("[updated] {:10}..{:10} {}", a, b, refname); ++ } ++ true ++ }); ++ ++ // Here we show processed and total objects in the pack and the amount of ++ // received data. Most frontends will probably want to show a percentage and ++ // the download rate. ++ cb.transfer_progress(|stats| { ++ if stats.received_objects() == stats.total_objects() { ++ print!("Resolving deltas {}/{}\r", stats.indexed_deltas(), ++ stats.total_deltas()); ++ } else if stats.total_objects() > 0 { ++ print!("Received {}/{} objects ({}) in {} bytes\r", ++ stats.received_objects(), ++ stats.total_objects(), ++ stats.indexed_objects(), ++ stats.received_bytes()); ++ } ++ io::stdout().flush().unwrap(); ++ true ++ }); ++ ++ // Download the packfile and index it. This function updates the amount of ++ // received data and the indexer stats which lets you inform the user about ++ // progress. ++ let mut fo = FetchOptions::new(); ++ fo.remote_callbacks(cb); ++ try!(remote.download(&[], Some(&mut fo))); ++ ++ { ++ // If there are local objects (we got a thin pack), then tell the user ++ // how many objects we saved from having to cross the network. ++ let stats = remote.stats(); ++ if stats.local_objects() > 0 { ++ println!("\rReceived {}/{} objects in {} bytes (used {} local \ ++ objects)", stats.indexed_objects(), ++ stats.total_objects(), stats.received_bytes(), ++ stats.local_objects()); ++ } else { ++ println!("\rReceived {}/{} objects in {} bytes", ++ stats.indexed_objects(), stats.total_objects(), ++ stats.received_bytes()); ++ } ++ } ++ ++ // Disconnect the underlying connection to prevent from idling. ++ remote.disconnect(); ++ ++ // Update the references in the remote's namespace to point to the right ++ // commits. This may be needed even if there was no packfile to download, ++ // which can happen e.g. when the branches have been changed but all the ++ // needed objects are available locally. ++ try!(remote.update_tips(None, true, ++ AutotagOption::Unspecified, None)); ++ ++ Ok(()) ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: fetch [options] [] ++ ++Options: ++ -h, --help show this message ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/examples/init.rs index 000000000,000000000..ccdef76cc new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/init.rs @@@ -1,0 -1,0 +1,152 @@@ ++/* ++ * libgit2 "init" example - shows how to initialize a new repo ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use docopt::Docopt; ++use git2::{Repository, RepositoryInitOptions, RepositoryInitMode, Error}; ++use std::path::{PathBuf, Path}; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_directory: String, ++ flag_quiet: bool, ++ flag_bare: bool, ++ flag_template: Option, ++ flag_separate_git_dir: Option, ++ flag_initial_commit: bool, ++ flag_shared: Option, ++} ++ ++fn run(args: &Args) -> Result<(), Error> { ++ let mut path = PathBuf::from(&args.arg_directory); ++ let repo = if !args.flag_bare && args.flag_template.is_none() && ++ args.flag_shared.is_none() && ++ args.flag_separate_git_dir.is_none() { ++ try!(Repository::init(&path)) ++ } else { ++ let mut opts = RepositoryInitOptions::new(); ++ opts.bare(args.flag_bare); ++ if let Some(ref s) = args.flag_template { ++ opts.template_path(Path::new(s)); ++ } ++ ++ // If you specified a separate git directory, then initialize ++ // the repository at that path and use the second path as the ++ // working directory of the repository (with a git-link file) ++ if let Some(ref s) = args.flag_separate_git_dir { ++ opts.workdir_path(&path); ++ path = PathBuf::from(s); ++ } ++ ++ if let Some(ref s) = args.flag_shared { ++ opts.mode(try!(parse_shared(s))); ++ } ++ try!(Repository::init_opts(&path, &opts)) ++ }; ++ ++ // Print a message to stdout like "git init" does ++ if !args.flag_quiet { ++ if args.flag_bare || args.flag_separate_git_dir.is_some() { ++ path = repo.path().to_path_buf(); ++ } else { ++ path = repo.workdir().unwrap().to_path_buf(); ++ } ++ println!("Initialized empty Git repository in {}", path.display()); ++ } ++ ++ if args.flag_initial_commit { ++ try!(create_initial_commit(&repo)); ++ println!("Created empty initial commit"); ++ } ++ ++ Ok(()) ++} ++ ++/// Unlike regular "git init", this example shows how to create an initial empty ++/// commit in the repository. This is the helper function that does that. ++fn create_initial_commit(repo: &Repository) -> Result<(), Error> { ++ // First use the config to initialize a commit signature for the user. ++ let sig = try!(repo.signature()); ++ ++ // Now let's create an empty tree for this commit ++ let tree_id = { ++ let mut index = try!(repo.index()); ++ ++ // Outside of this example, you could call index.add_path() ++ // here to put actual files into the index. For our purposes, we'll ++ // leave it empty for now. ++ ++ try!(index.write_tree()) ++ }; ++ ++ let tree = try!(repo.find_tree(tree_id)); ++ ++ // Ready to create the initial commit. ++ // ++ // Normally creating a commit would involve looking up the current HEAD ++ // commit and making that be the parent of the initial commit, but here this ++ // is the first commit so there will be no parent. ++ try!(repo.commit(Some("HEAD"), &sig, &sig, "Initial commit", &tree, &[])); ++ ++ Ok(()) ++} ++ ++fn parse_shared(shared: &str) -> Result { ++ match shared { ++ "false" | "umask" => Ok(git2::REPOSITORY_INIT_SHARED_UMASK), ++ "true" | "group" => Ok(git2::REPOSITORY_INIT_SHARED_GROUP), ++ "all" | "world" => Ok(git2::REPOSITORY_INIT_SHARED_ALL), ++ _ => { ++ if shared.starts_with('0') { ++ match u32::from_str_radix(&shared[1..], 8).ok() { ++ Some(n) => { ++ Ok(RepositoryInitMode::from_bits_truncate(n)) ++ } ++ None => { ++ Err(Error::from_str("invalid octal value for --shared")) ++ } ++ } ++ } else { ++ Err(Error::from_str("unknown value for --shared")) ++ } ++ } ++ } ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: init [options] ++ ++Options: ++ -q, --quiet don't print information to stdout ++ --bare initialize a new bare repository ++ --template use as an initialization template ++ --separate-git-dir use as the .git directory ++ --initial-commit create an initial empty commit ++ --shared permissions to create the repository with ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/examples/log.rs index 000000000,000000000..835136a55 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/log.rs @@@ -1,0 -1,0 +1,263 @@@ ++/* ++ * libgit2 "log" example - shows how to walk history and get commit info ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++#[macro_use] ++extern crate serde_derive; ++extern crate docopt; ++extern crate git2; ++extern crate time; ++ ++use std::str; ++use docopt::Docopt; ++use git2::{Repository, Signature, Commit, ObjectType, Time, DiffOptions}; ++use git2::{Pathspec, Error, DiffFormat}; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_commit: Vec, ++ arg_spec: Vec, ++ flag_topo_order: bool, ++ flag_date_order: bool, ++ flag_reverse: bool, ++ flag_author: Option, ++ flag_committer: Option, ++ flag_grep: Option, ++ flag_git_dir: Option, ++ flag_skip: Option, ++ flag_max_count: Option, ++ flag_merges: bool, ++ flag_no_merges: bool, ++ flag_no_min_parents: bool, ++ flag_no_max_parents: bool, ++ flag_max_parents: Option, ++ flag_min_parents: Option, ++ flag_patch: bool, ++} ++ ++fn run(args: &Args) -> Result<(), Error> { ++ let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); ++ let repo = try!(Repository::open(path)); ++ let mut revwalk = try!(repo.revwalk()); ++ ++ // Prepare the revwalk based on CLI parameters ++ let base = if args.flag_reverse {git2::SORT_REVERSE} else {git2::SORT_NONE}; ++ revwalk.set_sorting(base | if args.flag_topo_order { ++ git2::SORT_TOPOLOGICAL ++ } else if args.flag_date_order { ++ git2::SORT_TIME ++ } else { ++ git2::SORT_NONE ++ }); ++ for commit in &args.arg_commit { ++ if commit.starts_with('^') { ++ let obj = try!(repo.revparse_single(&commit[1..])); ++ try!(revwalk.hide(obj.id())); ++ continue ++ } ++ let revspec = try!(repo.revparse(commit)); ++ if revspec.mode().contains(git2::REVPARSE_SINGLE) { ++ try!(revwalk.push(revspec.from().unwrap().id())); ++ } else { ++ let from = revspec.from().unwrap().id(); ++ let to = revspec.to().unwrap().id(); ++ try!(revwalk.push(to)); ++ if revspec.mode().contains(git2::REVPARSE_MERGE_BASE) { ++ let base = try!(repo.merge_base(from, to)); ++ let o = try!(repo.find_object(base, Some(ObjectType::Commit))); ++ try!(revwalk.push(o.id())); ++ } ++ try!(revwalk.hide(from)); ++ } ++ } ++ if args.arg_commit.is_empty() { ++ try!(revwalk.push_head()); ++ } ++ ++ // Prepare our diff options and pathspec matcher ++ let (mut diffopts, mut diffopts2) = (DiffOptions::new(), DiffOptions::new()); ++ for spec in &args.arg_spec { ++ diffopts.pathspec(spec); ++ diffopts2.pathspec(spec); ++ } ++ let ps = try!(Pathspec::new(args.arg_spec.iter())); ++ ++ // Filter our revwalk based on the CLI parameters ++ macro_rules! filter_try { ++ ($e:expr) => (match $e { Ok(t) => t, Err(e) => return Some(Err(e)) }) ++ } ++ let revwalk = revwalk.filter_map(|id| { ++ let id = filter_try!(id); ++ let commit = filter_try!(repo.find_commit(id)); ++ let parents = commit.parents().len(); ++ if parents < args.min_parents() { return None } ++ if let Some(n) = args.max_parents() { ++ if parents >= n { return None } ++ } ++ if !args.arg_spec.is_empty() { ++ match commit.parents().len() { ++ 0 => { ++ let tree = filter_try!(commit.tree()); ++ let flags = git2::PATHSPEC_NO_MATCH_ERROR; ++ if ps.match_tree(&tree, flags).is_err() { return None } ++ } ++ _ => { ++ let m = commit.parents().all(|parent| { ++ match_with_parent(&repo, &commit, &parent, &mut diffopts) ++ .unwrap_or(false) ++ }); ++ if !m { return None } ++ } ++ } ++ } ++ if !sig_matches(&commit.author(), &args.flag_author) { return None } ++ if !sig_matches(&commit.committer(), &args.flag_committer) { return None } ++ if !log_message_matches(commit.message(), &args.flag_grep) { return None } ++ Some(Ok(commit)) ++ }).skip(args.flag_skip.unwrap_or(0)).take(args.flag_max_count.unwrap_or(!0)); ++ ++ // print! ++ for commit in revwalk { ++ let commit = try!(commit); ++ print_commit(&commit); ++ if !args.flag_patch || commit.parents().len() > 1 { continue } ++ let a = if commit.parents().len() == 1 { ++ let parent = try!(commit.parent(0)); ++ Some(try!(parent.tree())) ++ } else { ++ None ++ }; ++ let b = try!(commit.tree()); ++ let diff = try!(repo.diff_tree_to_tree(a.as_ref(), Some(&b), ++ Some(&mut diffopts2))); ++ try!(diff.print(DiffFormat::Patch, |_delta, _hunk, line| { ++ match line.origin() { ++ ' ' | '+' | '-' => print!("{}", line.origin()), ++ _ => {} ++ } ++ print!("{}", str::from_utf8(line.content()).unwrap()); ++ true ++ })); ++ } ++ ++ Ok(()) ++} ++ ++fn sig_matches(sig: &Signature, arg: &Option) -> bool { ++ match *arg { ++ Some(ref s) => { ++ sig.name().map(|n| n.contains(s)).unwrap_or(false) || ++ sig.email().map(|n| n.contains(s)).unwrap_or(false) ++ } ++ None => true ++ } ++} ++ ++fn log_message_matches(msg: Option<&str>, grep: &Option) -> bool { ++ match (grep, msg) { ++ (&None, _) => true, ++ (&Some(_), None) => false, ++ (&Some(ref s), Some(msg)) => msg.contains(s), ++ } ++} ++ ++fn print_commit(commit: &Commit) { ++ println!("commit {}", commit.id()); ++ ++ if commit.parents().len() > 1 { ++ print!("Merge:"); ++ for id in commit.parent_ids() { ++ print!(" {:.8}", id); ++ } ++ println!(""); ++ } ++ ++ let author = commit.author(); ++ println!("Author: {}", author); ++ print_time(&author.when(), "Date: "); ++ println!(""); ++ ++ for line in String::from_utf8_lossy(commit.message_bytes()).lines() { ++ println!(" {}", line); ++ } ++ println!(""); ++} ++ ++fn print_time(time: &Time, prefix: &str) { ++ let (offset, sign) = match time.offset_minutes() { ++ n if n < 0 => (-n, '-'), ++ n => (n, '+'), ++ }; ++ let (hours, minutes) = (offset / 60, offset % 60); ++ let ts = time::Timespec::new(time.seconds() + ++ (time.offset_minutes() as i64) * 60, 0); ++ let time = time::at(ts); ++ ++ println!("{}{} {}{:02}{:02}", prefix, ++ time.strftime("%a %b %e %T %Y").unwrap(), sign, hours, minutes); ++ ++} ++ ++fn match_with_parent(repo: &Repository, commit: &Commit, parent: &Commit, ++ opts: &mut DiffOptions) -> Result { ++ let a = try!(parent.tree()); ++ let b = try!(commit.tree()); ++ let diff = try!(repo.diff_tree_to_tree(Some(&a), Some(&b), Some(opts))); ++ Ok(diff.deltas().len() > 0) ++} ++ ++impl Args { ++ fn min_parents(&self) -> usize { ++ if self.flag_no_min_parents { return 0 } ++ self.flag_min_parents.unwrap_or(if self.flag_merges {2} else {0}) ++ } ++ ++ fn max_parents(&self) -> Option { ++ if self.flag_no_max_parents { return None } ++ self.flag_max_parents.or(if self.flag_no_merges {Some(1)} else {None}) ++ } ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: log [options] [..] [--] [..] ++ ++Options: ++ --topo-order sort commits in topological order ++ --date-order sort commits in date order ++ --reverse sort commits in reverse ++ --author author to sort by ++ --committer committer to sort by ++ --grep pattern to filter commit messages by ++ --git-dir alternative git directory to use ++ --skip number of commits to skip ++ -n, --max-count maximum number of commits to show ++ --merges only show merge commits ++ --no-merges don't show merge commits ++ --no-min-parents don't require a minimum number of parents ++ --no-max-parents don't require a maximum number of parents ++ --max-parents specify a maximum number of parents for a commit ++ --min-parents specify a minimum number of parents for a commit ++ -p, --patch show commit diff ++ -h, --help show this message ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/examples/ls-remote.rs index 000000000,000000000..5da9575f7 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/ls-remote.rs @@@ -1,0 -1,0 +1,63 @@@ ++/* ++ * libgit2 "ls-remote" example ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use docopt::Docopt; ++use git2::{Repository, Direction}; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_remote: String, ++} ++ ++fn run(args: &Args) -> Result<(), git2::Error> { ++ let repo = try!(Repository::open(".")); ++ let remote = &args.arg_remote; ++ let mut remote = try!(repo.find_remote(remote).or_else(|_| { ++ repo.remote_anonymous(remote) ++ })); ++ ++ // Connect to the remote and call the printing function for each of the ++ // remote references. ++ let connection = try!(remote.connect_auth(Direction::Fetch, None, None)); ++ ++ // Get the list of references on the remote and print out their name next to ++ // what they point to. ++ for head in try!(connection.list()).iter() { ++ println!("{}\t{}", head.oid(), head.name()); ++ } ++ Ok(()) ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: ls-remote [option] ++ ++Options: ++ -h, --help show this message ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/examples/rev-list.rs index 000000000,000000000..d2a618197 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/rev-list.rs @@@ -1,0 -1,0 +1,97 @@@ ++/* ++ * libgit2 "rev-list" example - shows how to transform a rev-spec into a list ++ * of commit ids ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use docopt::Docopt; ++use git2::{Repository, Error, Revwalk, Oid}; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_spec: Vec, ++ flag_topo_order: bool, ++ flag_date_order: bool, ++ flag_reverse: bool, ++ flag_not: Vec, ++} ++ ++fn run(args: &Args) -> Result<(), git2::Error> { ++ let repo = try!(Repository::open(".")); ++ let mut revwalk = try!(repo.revwalk()); ++ ++ let base = if args.flag_reverse {git2::SORT_REVERSE} else {git2::SORT_NONE}; ++ revwalk.set_sorting(base | if args.flag_topo_order { ++ git2::SORT_TOPOLOGICAL ++ } else if args.flag_date_order { ++ git2::SORT_TIME ++ } else { ++ git2::SORT_NONE ++ }); ++ ++ let specs = args.flag_not.iter().map(|s| (s, true)) ++ .chain(args.arg_spec.iter().map(|s| (s, false))) ++ .map(|(spec, hide)| { ++ if spec.starts_with('^') {(&spec[1..], !hide)} else {(&spec[..], hide)} ++ }); ++ for (spec, hide) in specs { ++ let id = if spec.contains("..") { ++ let revspec = try!(repo.revparse(spec)); ++ if revspec.mode().contains(git2::REVPARSE_MERGE_BASE) { ++ return Err(Error::from_str("merge bases not implemented")) ++ } ++ try!(push(&mut revwalk, revspec.from().unwrap().id(), !hide)); ++ revspec.to().unwrap().id() ++ } else { ++ try!(repo.revparse_single(spec)).id() ++ }; ++ try!(push(&mut revwalk, id, hide)); ++ } ++ ++ for id in revwalk { ++ let id = try!(id); ++ println!("{}", id); ++ } ++ Ok(()) ++} ++ ++fn push(revwalk: &mut Revwalk, id: Oid, hide: bool) -> Result<(), Error> { ++ if hide {revwalk.hide(id)} else {revwalk.push(id)} ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: rev-list [options] [--] ... ++ ++Options: ++ --topo-order sort commits in topological order ++ --date-order sort commits in date order ++ --reverse sort commits in reverse ++ --not don't show ++ -h, --help show this message ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} ++ diff --cc vendor/git2-0.6.8/examples/rev-parse.rs index 000000000,000000000..f1caf00f0 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/rev-parse.rs @@@ -1,0 -1,0 +1,70 @@@ ++/* ++ * libgit2 "rev-parse" example - shows how to parse revspecs ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use docopt::Docopt; ++use git2::Repository; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_spec: String, ++ flag_git_dir: Option, ++} ++ ++fn run(args: &Args) -> Result<(), git2::Error> { ++ let path = args.flag_git_dir.as_ref().map(|s| &s[..]).unwrap_or("."); ++ let repo = try!(Repository::open(path)); ++ ++ let revspec = try!(repo.revparse(&args.arg_spec)); ++ ++ if revspec.mode().contains(git2::REVPARSE_SINGLE) { ++ println!("{}", revspec.from().unwrap().id()); ++ } else if revspec.mode().contains(git2::REVPARSE_RANGE) { ++ let to = revspec.to().unwrap(); ++ let from = revspec.from().unwrap(); ++ println!("{}", to.id()); ++ ++ if revspec.mode().contains(git2::REVPARSE_MERGE_BASE) { ++ let base = try!(repo.merge_base(from.id(), to.id())); ++ println!("{}", base); ++ } ++ ++ println!("^{}", from.id()); ++ } else { ++ return Err(git2::Error::from_str("invalid results from revparse")) ++ } ++ Ok(()) ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: rev-parse [options] ++ ++Options: ++ --git-dir directory for the git repository to check ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/examples/status.rs index 000000000,000000000..86cbfcb6c new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/status.rs @@@ -1,0 -1,0 +1,369 @@@ ++/* ++ * libgit2 "status" example - shows how to use the status APIs ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use std::str; ++use std::time::Duration; ++use docopt::Docopt; ++use git2::{Repository, Error, StatusOptions, ErrorCode, SubmoduleIgnore}; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_spec: Vec, ++ flag_short: bool, ++ flag_porcelain: bool, ++ flag_branch: bool, ++ flag_z: bool, ++ flag_ignored: bool, ++ flag_untracked_files: Option, ++ flag_ignore_submodules: Option, ++ flag_git_dir: Option, ++ flag_repeat: bool, ++ flag_list_submodules: bool, ++} ++ ++#[derive(Eq, PartialEq)] ++enum Format { Long, Short, Porcelain } ++ ++fn run(args: &Args) -> Result<(), Error> { ++ let path = args.flag_git_dir.clone().unwrap_or_else(|| ".".to_string()); ++ let repo = try!(Repository::open(&path)); ++ if repo.is_bare() { ++ return Err(Error::from_str("cannot report status on bare repository")) ++ } ++ ++ let mut opts = StatusOptions::new(); ++ opts.include_ignored(args.flag_ignored); ++ match args.flag_untracked_files.as_ref().map(|s| &s[..]) { ++ Some("no") => { opts.include_untracked(false); } ++ Some("normal") => { opts.include_untracked(true); } ++ Some("all") => { ++ opts.include_untracked(true).recurse_untracked_dirs(true); ++ } ++ Some(_) => return Err(Error::from_str("invalid untracked-files value")), ++ None => {} ++ } ++ match args.flag_ignore_submodules.as_ref().map(|s| &s[..]) { ++ Some("all") => { opts.exclude_submodules(true); } ++ Some(_) => return Err(Error::from_str("invalid ignore-submodules value")), ++ None => {} ++ } ++ opts.include_untracked(!args.flag_ignored); ++ for spec in &args.arg_spec { ++ opts.pathspec(spec); ++ } ++ ++ loop { ++ if args.flag_repeat { ++ println!("\u{1b}[H\u{1b}[2J"); ++ } ++ ++ let statuses = try!(repo.statuses(Some(&mut opts))); ++ ++ if args.flag_branch { ++ try!(show_branch(&repo, &args.format())); ++ } ++ if args.flag_list_submodules { ++ try!(print_submodules(&repo)); ++ } ++ ++ if args.format() == Format::Long { ++ print_long(&statuses); ++ } else { ++ print_short(&repo, &statuses); ++ } ++ ++ if args.flag_repeat { ++ std::thread::sleep(Duration::new(10, 0)); ++ } else { ++ return Ok(()) ++ } ++ } ++} ++ ++fn show_branch(repo: &Repository, format: &Format) -> Result<(), Error> { ++ let head = match repo.head() { ++ Ok(head) => Some(head), ++ Err(ref e) if e.code() == ErrorCode::UnbornBranch || ++ e.code() == ErrorCode::NotFound => None, ++ Err(e) => return Err(e), ++ }; ++ let head = head.as_ref().and_then(|h| h.shorthand()); ++ ++ if format == &Format::Long { ++ println!("# On branch {}", ++ head.unwrap_or("Not currently on any branch")); ++ } else { ++ println!("## {}", head.unwrap_or("HEAD (no branch)")); ++ } ++ Ok(()) ++} ++ ++fn print_submodules(repo: &Repository) -> Result<(), Error> { ++ let modules = try!(repo.submodules()); ++ println!("# Submodules"); ++ for sm in &modules { ++ println!("# - submodule '{}' at {}", sm.name().unwrap(), ++ sm.path().display()); ++ } ++ Ok(()) ++} ++ ++// This function print out an output similar to git's status command in long ++// form, including the command-line hints. ++fn print_long(statuses: &git2::Statuses) { ++ let mut header = false; ++ let mut rm_in_workdir = false; ++ let mut changes_in_index = false; ++ let mut changed_in_workdir = false; ++ ++ // Print index changes ++ for entry in statuses.iter().filter(|e| e.status() != git2::STATUS_CURRENT) { ++ if entry.status().contains(git2::STATUS_WT_DELETED) { ++ rm_in_workdir = true; ++ } ++ let istatus = match entry.status() { ++ s if s.contains(git2::STATUS_INDEX_NEW) => "new file: ", ++ s if s.contains(git2::STATUS_INDEX_MODIFIED) => "modified: ", ++ s if s.contains(git2::STATUS_INDEX_DELETED) => "deleted: ", ++ s if s.contains(git2::STATUS_INDEX_RENAMED) => "renamed: ", ++ s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => "typechange:", ++ _ => continue, ++ }; ++ if !header { ++ println!("\ ++# Changes to be committed: ++# (use \"git reset HEAD ...\" to unstage) ++#"); ++ header = true; ++ } ++ ++ let old_path = entry.head_to_index().unwrap().old_file().path(); ++ let new_path = entry.head_to_index().unwrap().new_file().path(); ++ match (old_path, new_path) { ++ (Some(old), Some(new)) if old != new => { ++ println!("#\t{} {} -> {}", istatus, old.display(), ++ new.display()); ++ } ++ (old, new) => { ++ println!("#\t{} {}", istatus, old.or(new).unwrap().display()); ++ } ++ } ++ } ++ ++ if header { ++ changes_in_index = true; ++ println!("#"); ++ } ++ header = false; ++ ++ // Print workdir changes to tracked files ++ for entry in statuses.iter() { ++ // With `STATUS_OPT_INCLUDE_UNMODIFIED` (not used in this example) ++ // `index_to_workdir` may not be `None` even if there are no differences, ++ // in which case it will be a `Delta::Unmodified`. ++ if entry.status() == git2::STATUS_CURRENT || ++ entry.index_to_workdir().is_none() { ++ continue ++ } ++ ++ let istatus = match entry.status() { ++ s if s.contains(git2::STATUS_WT_MODIFIED) => "modified: ", ++ s if s.contains(git2::STATUS_WT_DELETED) => "deleted: ", ++ s if s.contains(git2::STATUS_WT_RENAMED) => "renamed: ", ++ s if s.contains(git2::STATUS_WT_TYPECHANGE) => "typechange:", ++ _ => continue, ++ }; ++ ++ if !header { ++ println!("\ ++# Changes not staged for commit: ++# (use \"git add{} ...\" to update what will be committed) ++# (use \"git checkout -- ...\" to discard changes in working directory) ++#\ ++ ", if rm_in_workdir {"/rm"} else {""}); ++ header = true; ++ } ++ ++ let old_path = entry.index_to_workdir().unwrap().old_file().path(); ++ let new_path = entry.index_to_workdir().unwrap().new_file().path(); ++ match (old_path, new_path) { ++ (Some(old), Some(new)) if old != new => { ++ println!("#\t{} {} -> {}", istatus, old.display(), ++ new.display()); ++ } ++ (old, new) => { ++ println!("#\t{} {}", istatus, old.or(new).unwrap().display()); ++ } ++ } ++ } ++ ++ if header { ++ changed_in_workdir = true; ++ println!("#"); ++ } ++ header = false; ++ ++ // Print untracked files ++ for entry in statuses.iter().filter(|e| e.status() == git2::STATUS_WT_NEW) { ++ if !header { ++ println!("\ ++# Untracked files ++# (use \"git add ...\" to include in what will be committed) ++#"); ++ header = true; ++ } ++ let file = entry.index_to_workdir().unwrap().old_file().path().unwrap(); ++ println!("#\t{}", file.display()); ++ } ++ header = false; ++ ++ // Print ignored files ++ for entry in statuses.iter().filter(|e| e.status() == git2::STATUS_IGNORED) { ++ if !header { ++ println!("\ ++# Ignored files ++# (use \"git add -f ...\" to include in what will be committed) ++#"); ++ header = true; ++ } ++ let file = entry.index_to_workdir().unwrap().old_file().path().unwrap(); ++ println!("#\t{}", file.display()); ++ } ++ ++ if !changes_in_index && changed_in_workdir { ++ println!("no changes added to commit (use \"git add\" and/or \ ++ \"git commit -a\")"); ++ } ++} ++ ++// This version of the output prefixes each path with two status columns and ++// shows submodule status information. ++fn print_short(repo: &Repository, statuses: &git2::Statuses) { ++ for entry in statuses.iter().filter(|e| e.status() != git2::STATUS_CURRENT) { ++ let mut istatus = match entry.status() { ++ s if s.contains(git2::STATUS_INDEX_NEW) => 'A', ++ s if s.contains(git2::STATUS_INDEX_MODIFIED) => 'M', ++ s if s.contains(git2::STATUS_INDEX_DELETED) => 'D', ++ s if s.contains(git2::STATUS_INDEX_RENAMED) => 'R', ++ s if s.contains(git2::STATUS_INDEX_TYPECHANGE) => 'T', ++ _ => ' ', ++ }; ++ let mut wstatus = match entry.status() { ++ s if s.contains(git2::STATUS_WT_NEW) => { ++ if istatus == ' ' { istatus = '?'; } '?' ++ } ++ s if s.contains(git2::STATUS_WT_MODIFIED) => 'M', ++ s if s.contains(git2::STATUS_WT_DELETED) => 'D', ++ s if s.contains(git2::STATUS_WT_RENAMED) => 'R', ++ s if s.contains(git2::STATUS_WT_TYPECHANGE) => 'T', ++ _ => ' ', ++ }; ++ ++ if entry.status().contains(git2::STATUS_IGNORED) { ++ istatus = '!'; ++ wstatus = '!'; ++ } ++ if istatus == '?' && wstatus == '?' { continue } ++ let mut extra = ""; ++ ++ // A commit in a tree is how submodules are stored, so let's go take a ++ // look at its status. ++ // ++ // TODO: check for GIT_FILEMODE_COMMIT ++ let status = entry.index_to_workdir().and_then(|diff| { ++ let ignore = SubmoduleIgnore::Unspecified; ++ diff.new_file().path_bytes() ++ .and_then(|s| str::from_utf8(s).ok()) ++ .and_then(|name| repo.submodule_status(name, ignore).ok()) ++ }); ++ if let Some(status) = status { ++ if status.contains(git2::SUBMODULE_STATUS_WD_MODIFIED) { ++ extra = " (new commits)"; ++ } else if status.contains(git2::SUBMODULE_STATUS_WD_INDEX_MODIFIED) || status.contains(git2::SUBMODULE_STATUS_WD_WD_MODIFIED) { ++ extra = " (modified content)"; ++ } else if status.contains(git2::SUBMODULE_STATUS_WD_UNTRACKED) { ++ extra = " (untracked content)"; ++ } ++ } ++ ++ let (mut a, mut b, mut c) = (None, None, None); ++ if let Some(diff) = entry.head_to_index() { ++ a = diff.old_file().path(); ++ b = diff.new_file().path(); ++ } ++ if let Some(diff) = entry.index_to_workdir() { ++ a = a.or_else(|| diff.old_file().path()); ++ b = b.or_else(|| diff.old_file().path()); ++ c = diff.new_file().path(); ++ } ++ ++ match (istatus, wstatus) { ++ ('R', 'R') => println!("RR {} {} {}{}", a.unwrap().display(), ++ b.unwrap().display(), c.unwrap().display(), ++ extra), ++ ('R', w) => println!("R{} {} {}{}", w, a.unwrap().display(), ++ b.unwrap().display(), extra), ++ (i, 'R') => println!("{}R {} {}{}", i, a.unwrap().display(), ++ c.unwrap().display(), extra), ++ (i, w) => println!("{}{} {}{}", i, w, a.unwrap().display(), extra), ++ } ++ } ++ ++ for entry in statuses.iter().filter(|e| e.status() == git2::STATUS_WT_NEW) { ++ println!("?? {}", entry.index_to_workdir().unwrap().old_file() ++ .path().unwrap().display()); ++ } ++} ++ ++impl Args { ++ fn format(&self) -> Format { ++ if self.flag_short { Format::Short } ++ else if self.flag_porcelain || self.flag_z { Format::Porcelain } ++ else { Format::Long } ++ } ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: status [options] [--] [..] ++ ++Options: ++ -s, --short show short statuses ++ --long show longer statuses (default) ++ --porcelain ?? ++ -b, --branch show branch information ++ -z ?? ++ --ignored show ignored files as well ++ --untracked-files setting for showing untracked files [no|normal|all] ++ --ignore-submodules setting for ignoring submodules [all] ++ --git-dir git directory to analyze ++ --repeat repeatedly show status, sleeping inbetween ++ --list-submodules show submodules ++ -h, --help show this message ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/examples/tag.rs index 000000000,000000000..f0ff3a219 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/examples/tag.rs @@@ -1,0 -1,0 +1,134 @@@ ++/* ++ * libgit2 "tag" example - shows how to list, create and delete tags ++ * ++ * Written by the libgit2 contributors ++ * ++ * To the extent possible under law, the author(s) have dedicated all copyright ++ * and related and neighboring rights to this software to the public domain ++ * worldwide. This software is distributed without any warranty. ++ * ++ * You should have received a copy of the CC0 Public Domain Dedication along ++ * with this software. If not, see ++ * . ++ */ ++ ++#![deny(warnings)] ++ ++extern crate git2; ++extern crate docopt; ++#[macro_use] ++extern crate serde_derive; ++ ++use std::str; ++use docopt::Docopt; ++use git2::{Repository, Error, Tag, Commit}; ++ ++#[derive(Deserialize)] ++struct Args { ++ arg_tagname: Option, ++ arg_object: Option, ++ arg_pattern: Option, ++ flag_n: Option, ++ flag_force: bool, ++ flag_list: bool, ++ flag_delete: Option, ++ flag_message: Option, ++} ++ ++fn run(args: &Args) -> Result<(), Error> { ++ let repo = try!(Repository::open(".")); ++ ++ if let Some(ref name) = args.arg_tagname { ++ let target = args.arg_object.as_ref().map(|s| &s[..]).unwrap_or("HEAD"); ++ let obj = try!(repo.revparse_single(target)); ++ ++ if let Some(ref message) = args.flag_message { ++ let sig = try!(repo.signature()); ++ try!(repo.tag(name, &obj, &sig, message, args.flag_force)); ++ } else { ++ try!(repo.tag_lightweight(name, &obj, args.flag_force)); ++ } ++ ++ } else if let Some(ref name) = args.flag_delete { ++ let obj = try!(repo.revparse_single(name)); ++ let id = try!(obj.short_id()); ++ try!(repo.tag_delete(name)); ++ println!("Deleted tag '{}' (was {})", name, ++ str::from_utf8(&*id).unwrap()); ++ ++ } else if args.flag_list { ++ let pattern = args.arg_pattern.as_ref().map(|s| &s[..]).unwrap_or("*"); ++ for name in try!(repo.tag_names(Some(pattern))).iter() { ++ let name = name.unwrap(); ++ let obj = try!(repo.revparse_single(name)); ++ ++ if let Some(tag) = obj.as_tag() { ++ print_tag(tag, args); ++ } else if let Some(commit) = obj.as_commit() { ++ print_commit(commit, name, args); ++ } else { ++ print_name(name); ++ } ++ } ++ } ++ Ok(()) ++} ++ ++fn print_tag(tag: &Tag, args: &Args) { ++ print!("{:<16}", tag.name().unwrap()); ++ if args.flag_n.is_some() { ++ print_list_lines(tag.message(), args); ++ } else { ++ println!(""); ++ } ++} ++ ++fn print_commit(commit: &Commit, name: &str, args: &Args) { ++ print!("{:<16}", name); ++ if args.flag_n.is_some() { ++ print_list_lines(commit.message(), args); ++ } else { ++ println!(""); ++ } ++} ++ ++fn print_name(name: &str) { ++ println!("{}", name); ++} ++ ++fn print_list_lines(message: Option<&str>, args: &Args) { ++ let message = match message { Some(s) => s, None => return }; ++ let mut lines = message.lines().filter(|l| !l.trim().is_empty()); ++ if let Some(first) = lines.next() { ++ print!("{}", first); ++ } ++ println!(""); ++ ++ for line in lines.take(args.flag_n.unwrap_or(0) as usize) { ++ print!(" {}", line); ++ } ++} ++ ++fn main() { ++ const USAGE: &'static str = " ++usage: ++ tag [-a] [-f] [-m ] [] ++ tag -d ++ tag [-n ] -l [] ++ ++Options: ++ -n specify number of lines from teh annotation to print ++ -f, --force replace an existing tag with the given name ++ -l, --list list tags with names matching the pattern given ++ -d, --delete delete the tag specified ++ -m, --message message for a new tag ++ -h, --help show this message ++"; ++ ++ let args = Docopt::new(USAGE).and_then(|d| d.deserialize()) ++ .unwrap_or_else(|e| e.exit()); ++ match run(&args) { ++ Ok(()) => {} ++ Err(e) => println!("error: {}", e), ++ } ++} diff --cc vendor/git2-0.6.8/src/blame.rs index 000000000,000000000..9f6b15571 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/blame.rs @@@ -1,0 -1,0 +1,315 @@@ ++use std::marker; ++use {raw, Repository, Oid, signature, Signature}; ++use util::{self, Binding}; ++use std::path::Path; ++use std::ops::Range; ++use std::mem; ++ ++/// Opaque structure to hold blame results. ++pub struct Blame<'repo> { ++ raw: *mut raw::git_blame, ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++/// Structure that represents a blame hunk. ++pub struct BlameHunk<'blame> { ++ raw: *mut raw::git_blame_hunk, ++ _marker: marker::PhantomData<&'blame raw::git_blame>, ++} ++ ++/// Blame options ++pub struct BlameOptions { ++ raw: raw::git_blame_options, ++} ++ ++/// An iterator over the hunks in a blame. ++pub struct BlameIter<'blame> { ++ range: Range, ++ blame: &'blame Blame<'blame>, ++} ++ ++impl<'repo> Blame<'repo> { ++ ++ /// Gets the number of hunks that exist in the blame structure. ++ pub fn len(&self) -> usize { ++ unsafe { raw::git_blame_get_hunk_count(self.raw) as usize } ++ } ++ ++ /// Return `true` is there is no hunk in the blame structure. ++ pub fn is_empty(&self) -> bool { ++ self.len() == 0 ++ } ++ ++ /// Gets the blame hunk at the given index. ++ pub fn get_index(&self, index: usize) -> Option { ++ unsafe { ++ let ptr = raw::git_blame_get_hunk_byindex(self.raw(), index as u32); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(BlameHunk::from_raw_const(ptr)) ++ } ++ } ++ } ++ ++ /// Gets the hunk that relates to the given line number in the newest ++ /// commit. ++ pub fn get_line(&self, lineno: usize) -> Option { ++ unsafe { ++ let ptr = raw::git_blame_get_hunk_byline(self.raw(), lineno); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(BlameHunk::from_raw_const(ptr)) ++ } ++ } ++ } ++ ++ /// Returns an iterator over the hunks in this blame. ++ pub fn iter(&self) -> BlameIter { ++ BlameIter { range: 0..self.len(), blame: self } ++ } ++ ++} ++ ++impl<'blame> BlameHunk<'blame> { ++ ++ unsafe fn from_raw_const(raw: *const raw::git_blame_hunk) ++ -> BlameHunk<'blame> { ++ BlameHunk { ++ raw: raw as *mut raw::git_blame_hunk, ++ _marker: marker::PhantomData, ++ } ++ } ++ ++ /// Returns OID of the commit where this line was last changed ++ pub fn final_commit_id(&self) -> Oid { ++ unsafe { Oid::from_raw(&(*self.raw).final_commit_id) } ++ } ++ ++ /// Returns signature of the commit. ++ pub fn final_signature(&self) -> Signature { ++ unsafe { signature::from_raw_const(self, (*self.raw).final_signature) } ++ } ++ ++ /// Returns line number where this hunk begins. ++ /// ++ /// Note that the start line is counting from 1. ++ pub fn final_start_line(&self) -> usize { ++ unsafe { (*self.raw).final_start_line_number } ++ } ++ ++ /// Returns the OID of the commit where this hunk was found. ++ /// ++ /// This will usually be the same as `final_commit_id`, ++ /// except when `BlameOptions::track_copies_any_commit_copies` has been ++ /// turned on ++ pub fn orig_commit_id(&self) -> Oid { ++ unsafe { Oid::from_raw(&(*self.raw).orig_commit_id) } ++ } ++ ++ /// Returns signature of the commit. ++ pub fn orig_signature(&self) -> Signature { ++ unsafe { signature::from_raw_const(self, (*self.raw).orig_signature) } ++ } ++ ++ /// Returns line number where this hunk begins. ++ /// ++ /// Note that the start line is counting from 1. ++ pub fn orig_start_line(&self) -> usize { ++ unsafe { (*self.raw).orig_start_line_number} ++ } ++ ++ /// Returns path to the file where this hunk originated. ++ /// ++ /// Note: `None` could be returned for non-unicode paths on Widnows. ++ pub fn path(&self) -> Option<&Path> { ++ unsafe { ++ if let Some(bytes) = ::opt_bytes(self, (*self.raw).orig_path) { ++ Some(util::bytes2path(bytes)) ++ } else { ++ None ++ } ++ } ++ } ++ ++ /// Tests whether this hunk has been tracked to a boundary commit ++ /// (the root, or the commit specified in git_blame_options.oldest_commit). ++ pub fn is_boundary(&self) -> bool { ++ unsafe { (*self.raw).boundary == 1 } ++ } ++ ++ /// Returns number of lines in this hunk. ++ pub fn lines_in_hunk(&self) -> usize { ++ unsafe { (*self.raw).lines_in_hunk as usize } ++ } ++} ++ ++ ++impl Default for BlameOptions { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl BlameOptions { ++ ++ /// Initialize options ++ pub fn new() -> BlameOptions { ++ unsafe { ++ let mut raw: raw::git_blame_options = mem::zeroed(); ++ assert_eq!( ++ raw::git_blame_init_options(&mut raw, ++ raw::GIT_BLAME_OPTIONS_VERSION) ++ , 0); ++ ++ Binding::from_raw(&raw as *const _ as *mut _) ++ } ++ } ++ ++ fn flag(&mut self, opt: u32, val: bool) -> &mut BlameOptions { ++ if val { ++ self.raw.flags |= opt; ++ } else { ++ self.raw.flags &= !opt; ++ } ++ self ++ } ++ ++ /// Track lines that have moved within a file. ++ pub fn track_copies_same_file(&mut self, opt: bool) -> &mut BlameOptions { ++ self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_FILE, opt) ++ } ++ ++ /// Track lines that have moved across files in the same commit. ++ pub fn track_copies_same_commit_moves(&mut self, opt: bool) -> &mut BlameOptions { ++ self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES, opt) ++ } ++ ++ /// Track lines that have been copied from another file that exists ++ /// in the same commit. ++ pub fn track_copies_same_commit_copies(&mut self, opt: bool) -> &mut BlameOptions { ++ self.flag(raw::GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES, opt) ++ } ++ ++ /// Track lines that have been copied from another file that exists ++ /// in any commit. ++ pub fn track_copies_any_commit_copies(&mut self, opt: bool) -> &mut BlameOptions { ++ self.flag(raw::GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES, opt) ++ } ++ ++ /// Restrict the search of commits to those reachable following only ++ /// the first parents. ++ pub fn first_parent(&mut self, opt: bool) -> &mut BlameOptions { ++ self.flag(raw::GIT_BLAME_FIRST_PARENT, opt) ++ } ++ ++ /// Setter for the id of the newest commit to consider. ++ pub fn newest_commit(&mut self, id: Oid) -> &mut BlameOptions { ++ unsafe { self.raw.newest_commit = *id.raw(); } ++ self ++ } ++ ++ /// Setter for the id of the oldest commit to consider. ++ pub fn oldest_commit(&mut self, id: Oid) -> &mut BlameOptions { ++ unsafe { self.raw.oldest_commit = *id.raw(); } ++ self ++ } ++ ++} ++ ++impl<'repo> Binding for Blame<'repo> { ++ type Raw = *mut raw::git_blame; ++ ++ unsafe fn from_raw(raw: *mut raw::git_blame) -> Blame<'repo> { ++ Blame { raw: raw, _marker: marker::PhantomData } ++ } ++ ++ fn raw(&self) -> *mut raw::git_blame { self.raw } ++} ++ ++impl<'repo> Drop for Blame<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_blame_free(self.raw) } ++ } ++} ++ ++impl<'blame> Binding for BlameHunk<'blame> { ++ type Raw = *mut raw::git_blame_hunk; ++ ++ unsafe fn from_raw(raw: *mut raw::git_blame_hunk) -> BlameHunk<'blame> { ++ BlameHunk { raw: raw, _marker: marker::PhantomData } ++ } ++ ++ fn raw(&self) -> *mut raw::git_blame_hunk { self.raw } ++} ++ ++impl Binding for BlameOptions { ++ type Raw = *mut raw::git_blame_options; ++ ++ unsafe fn from_raw(opts: *mut raw::git_blame_options) -> BlameOptions { ++ BlameOptions { raw: *opts } ++ } ++ ++ fn raw(&self) -> *mut raw::git_blame_options { ++ &self.raw as *const _ as *mut _ ++ } ++} ++ ++impl<'blame> Iterator for BlameIter<'blame> { ++ type Item = BlameHunk<'blame>; ++ fn next(&mut self) -> Option> { ++ self.range.next().and_then(|i| self.blame.get_index(i)) ++ } ++ ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++ ++impl<'blame> DoubleEndedIterator for BlameIter<'blame> { ++ fn next_back(&mut self) -> Option> { ++ self.range.next_back().and_then(|i| self.blame.get_index(i)) ++ } ++} ++ ++impl<'blame> ExactSizeIterator for BlameIter<'blame> {} ++ ++#[cfg(test)] ++mod tests { ++ use std::fs::{self, File}; ++ use std::path::Path; ++ ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut index = repo.index().unwrap(); ++ ++ let root = repo.path().parent().unwrap(); ++ fs::create_dir(&root.join("foo")).unwrap(); ++ File::create(&root.join("foo/bar")).unwrap(); ++ index.add_path(Path::new("foo/bar")).unwrap(); ++ ++ let id = index.write_tree().unwrap(); ++ let tree = repo.find_tree(id).unwrap(); ++ let sig = repo.signature().unwrap(); ++ let id = repo.refname_to_id("HEAD").unwrap(); ++ let parent = repo.find_commit(id).unwrap(); ++ let commit = repo.commit(Some("HEAD"), &sig, &sig, "commit", ++ &tree, &[&parent]).unwrap(); ++ ++ let blame = repo.blame_file(Path::new("foo/bar"), None).unwrap(); ++ ++ assert_eq!(blame.len(), 1); ++ assert_eq!(blame.iter().count(), 1); ++ ++ let hunk = blame.get_index(0).unwrap(); ++ assert_eq!(hunk.final_commit_id(), commit); ++ assert_eq!(hunk.final_signature().name(), sig.name()); ++ assert_eq!(hunk.final_signature().email(), sig.email()); ++ assert_eq!(hunk.final_start_line(), 1); ++ assert_eq!(hunk.path(), Some(Path::new("foo/bar"))); ++ assert_eq!(hunk.lines_in_hunk(), 0); ++ assert!(!hunk.is_boundary()) ++ } ++ ++} ++ diff --cc vendor/git2-0.6.8/src/blob.rs index 000000000,000000000..d6a388e16 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/blob.rs @@@ -1,0 -1,0 +1,175 @@@ ++use std::marker; ++use std::mem; ++use std::slice; ++use std::io; ++ ++use {raw, Oid, Object, Error}; ++use util::Binding; ++ ++/// A structure to represent a git [blob][1] ++/// ++/// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects ++pub struct Blob<'repo> { ++ raw: *mut raw::git_blob, ++ _marker: marker::PhantomData>, ++} ++ ++impl<'repo> Blob<'repo> { ++ /// Get the id (SHA1) of a repository blob ++ pub fn id(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_blob_id(&*self.raw)) } ++ } ++ ++ /// Determine if the blob content is most certainly binary or not. ++ pub fn is_binary(&self) -> bool { ++ unsafe { raw::git_blob_is_binary(&*self.raw) == 1 } ++ } ++ ++ /// Get the content of this blob. ++ pub fn content(&self) -> &[u8] { ++ unsafe { ++ let data = raw::git_blob_rawcontent(&*self.raw) as *const u8; ++ let len = raw::git_blob_rawsize(&*self.raw) as usize; ++ slice::from_raw_parts(data, len) ++ } ++ } ++ ++ /// Casts this Blob to be usable as an `Object` ++ pub fn as_object(&self) -> &Object<'repo> { ++ unsafe { ++ &*(self as *const _ as *const Object<'repo>) ++ } ++ } ++ ++ /// Consumes Blob to be returned as an `Object` ++ pub fn into_object(self) -> Object<'repo> { ++ assert_eq!(mem::size_of_val(&self), mem::size_of::()); ++ unsafe { ++ mem::transmute(self) ++ } ++ } ++} ++ ++impl<'repo> Binding for Blob<'repo> { ++ type Raw = *mut raw::git_blob; ++ ++ unsafe fn from_raw(raw: *mut raw::git_blob) -> Blob<'repo> { ++ Blob { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_blob { self.raw } ++} ++ ++ ++impl<'repo> Drop for Blob<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_blob_free(self.raw) } ++ } ++} ++ ++/// A structure to represent a git writestream for blobs ++pub struct BlobWriter<'repo> { ++ raw: *mut raw::git_writestream, ++ need_cleanup: bool, ++ _marker: marker::PhantomData>, ++} ++ ++impl<'repo> BlobWriter<'repo> { ++ /// Finalize blob writing stream and write the blob to the object db ++ pub fn commit(mut self) -> Result { ++ // After commit we already doesn't need cleanup on drop ++ self.need_cleanup = false; ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_blob_create_fromstream_commit(&mut raw, self.raw)); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++} ++ ++impl<'repo> Binding for BlobWriter<'repo> { ++ type Raw = *mut raw::git_writestream; ++ ++ unsafe fn from_raw(raw: *mut raw::git_writestream) -> BlobWriter<'repo> { ++ BlobWriter { ++ raw: raw, ++ need_cleanup: true, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_writestream { self.raw } ++} ++ ++impl<'repo> Drop for BlobWriter<'repo> { ++ fn drop(&mut self) { ++ // We need cleanup in case the stream has not been committed ++ if self.need_cleanup { ++ unsafe { ((*self.raw).free)(self.raw) } ++ } ++ } ++} ++ ++impl<'repo> io::Write for BlobWriter<'repo> { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ unsafe { ++ let res = ((*self.raw).write)(self.raw, buf.as_ptr() as *const _, buf.len()); ++ if res < 0 { ++ Err(io::Error::new(io::ErrorKind::Other, "Write error")) ++ } else { ++ Ok(buf.len()) ++ } ++ } ++ } ++ fn flush(&mut self) -> io::Result<()> { Ok(()) } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::io::prelude::*; ++ use std::fs::File; ++ use std::path::Path; ++ use tempdir::TempDir; ++ use Repository; ++ ++ #[test] ++ fn buffer() { ++ let td = TempDir::new("test").unwrap(); ++ let repo = Repository::init(td.path()).unwrap(); ++ let id = repo.blob(&[5, 4, 6]).unwrap(); ++ let blob = repo.find_blob(id).unwrap(); ++ ++ assert_eq!(blob.id(), id); ++ assert_eq!(blob.content(), [5, 4, 6]); ++ assert!(blob.is_binary()); ++ ++ repo.find_object(id, None).unwrap().as_blob().unwrap(); ++ repo.find_object(id, None).unwrap().into_blob().ok().unwrap(); ++ } ++ ++ #[test] ++ fn path() { ++ let td = TempDir::new("test").unwrap(); ++ let path = td.path().join("foo"); ++ File::create(&path).unwrap().write_all(&[7, 8, 9]).unwrap(); ++ let repo = Repository::init(td.path()).unwrap(); ++ let id = repo.blob_path(&path).unwrap(); ++ let blob = repo.find_blob(id).unwrap(); ++ assert_eq!(blob.content(), [7, 8, 9]); ++ blob.into_object(); ++ } ++ ++ #[test] ++ fn stream() { ++ let td = TempDir::new("test").unwrap(); ++ let repo = Repository::init(td.path()).unwrap(); ++ let mut ws = repo.blob_writer(Some(Path::new("foo"))).unwrap(); ++ let wl = ws.write(&[10, 11, 12]).unwrap(); ++ assert_eq!(wl, 3); ++ let id = ws.commit().unwrap(); ++ let blob = repo.find_blob(id).unwrap(); ++ assert_eq!(blob.content(), [10, 11, 12]); ++ blob.into_object(); ++ } ++} diff --cc vendor/git2-0.6.8/src/branch.rs index 000000000,000000000..75edd2b30 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/branch.rs @@@ -1,0 -1,0 +1,162 @@@ ++use std::ffi::CString; ++use std::marker; ++use std::ptr; ++use std::str; ++ ++use {raw, Error, Reference, BranchType, References}; ++use util::Binding; ++ ++/// A structure to represent a git [branch][1] ++/// ++/// A branch is currently just a wrapper to an underlying `Reference`. The ++/// reference can be accessed through the `get` and `unwrap` methods. ++/// ++/// [1]: http://git-scm.com/book/en/Git-Branching-What-a-Branch-Is ++pub struct Branch<'repo> { ++ inner: Reference<'repo>, ++} ++ ++/// An iterator over the branches inside of a repository. ++pub struct Branches<'repo> { ++ raw: *mut raw::git_branch_iterator, ++ _marker: marker::PhantomData>, ++} ++ ++impl<'repo> Branch<'repo> { ++ /// Creates a new branch from a reference ++ pub fn wrap(reference: Reference) -> Branch { Branch { inner: reference } } ++ ++ /// Gain access to the reference that is this branch ++ pub fn get(&self) -> &Reference<'repo> { &self.inner } ++ ++ /// Take ownership of the underlying reference. ++ pub fn into_reference(self) -> Reference<'repo> { self.inner } ++ ++ /// Delete an existing branch reference. ++ pub fn delete(&mut self) -> Result<(), Error> { ++ unsafe { try_call!(raw::git_branch_delete(self.get().raw())); } ++ Ok(()) ++ } ++ ++ /// Determine if the current local branch is pointed at by HEAD. ++ pub fn is_head(&self) -> bool { ++ unsafe { raw::git_branch_is_head(&*self.get().raw()) == 1 } ++ } ++ ++ /// Move/rename an existing local branch reference. ++ pub fn rename(&mut self, new_branch_name: &str, force: bool) ++ -> Result, Error> { ++ let mut ret = ptr::null_mut(); ++ let new_branch_name = try!(CString::new(new_branch_name)); ++ unsafe { ++ try_call!(raw::git_branch_move(&mut ret, self.get().raw(), ++ new_branch_name, force)); ++ Ok(Branch::wrap(Binding::from_raw(ret))) ++ } ++ } ++ ++ /// Return the name of the given local or remote branch. ++ /// ++ /// May return `Ok(None)` if the name is not valid utf-8. ++ pub fn name(&self) -> Result, Error> { ++ self.name_bytes().map(|s| str::from_utf8(s).ok()) ++ } ++ ++ /// Return the name of the given local or remote branch. ++ pub fn name_bytes(&self) -> Result<&[u8], Error> { ++ let mut ret = ptr::null(); ++ unsafe { ++ try_call!(raw::git_branch_name(&mut ret, &*self.get().raw())); ++ Ok(::opt_bytes(self, ret).unwrap()) ++ } ++ } ++ ++ /// Return the reference supporting the remote tracking branch, given a ++ /// local branch reference. ++ pub fn upstream<'a>(&'a self) -> Result, Error> { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_branch_upstream(&mut ret, &*self.get().raw())); ++ Ok(Branch::wrap(Binding::from_raw(ret))) ++ } ++ } ++ ++ /// Set the upstream configuration for a given local branch. ++ /// ++ /// If `None` is specified, then the upstream branch is unset. The name ++ /// provided is the name of the branch to set as upstream. ++ pub fn set_upstream(&mut self, ++ upstream_name: Option<&str>) -> Result<(), Error> { ++ let upstream_name = try!(::opt_cstr(upstream_name)); ++ unsafe { ++ try_call!(raw::git_branch_set_upstream(self.get().raw(), ++ upstream_name)); ++ Ok(()) ++ } ++ } ++} ++ ++impl<'repo> Branches<'repo> { ++ /// Creates a new iterator from the raw pointer given. ++ /// ++ /// This function is unsafe as it is not guaranteed that `raw` is a valid ++ /// pointer. ++ pub unsafe fn from_raw(raw: *mut raw::git_branch_iterator) ++ -> Branches<'repo> { ++ Branches { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++} ++ ++impl<'repo> Iterator for Branches<'repo> { ++ type Item = Result<(Branch<'repo>, BranchType), Error>; ++ fn next(&mut self) -> Option, BranchType), Error>> { ++ let mut ret = ptr::null_mut(); ++ let mut typ = raw::GIT_BRANCH_LOCAL; ++ unsafe { ++ try_call_iter!(raw::git_branch_next(&mut ret, &mut typ, self.raw)); ++ let typ = match typ { ++ raw::GIT_BRANCH_LOCAL => BranchType::Local, ++ raw::GIT_BRANCH_REMOTE => BranchType::Remote, ++ n => panic!("unexected branch type: {}", n), ++ }; ++ Some(Ok((Branch::wrap(Binding::from_raw(ret)), typ))) ++ } ++ } ++} ++ ++impl<'repo> Drop for Branches<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_branch_iterator_free(self.raw) } ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use BranchType; ++ ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ let head = repo.head().unwrap(); ++ let target = head.target().unwrap(); ++ let commit = repo.find_commit(target).unwrap(); ++ ++ let mut b1 = repo.branch("foo", &commit, false).unwrap(); ++ assert!(!b1.is_head()); ++ repo.branch("foo2", &commit, false).unwrap(); ++ ++ assert_eq!(repo.branches(None).unwrap().count(), 3); ++ repo.find_branch("foo", BranchType::Local).unwrap(); ++ let mut b1 = b1.rename("bar", false).unwrap(); ++ assert_eq!(b1.name().unwrap(), Some("bar")); ++ assert!(b1.upstream().is_err()); ++ b1.set_upstream(Some("master")).unwrap(); ++ b1.upstream().unwrap(); ++ b1.set_upstream(None).unwrap(); ++ ++ b1.delete().unwrap(); ++ } ++} diff --cc vendor/git2-0.6.8/src/buf.rs index 000000000,000000000..78e958e2e new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/buf.rs @@@ -1,0 -1,0 +1,73 @@@ ++use std::slice; ++use std::str; ++use std::ptr; ++use std::ops::{Deref, DerefMut}; ++ ++use raw; ++use util::Binding; ++ ++/// A structure to wrap an intermediate buffer used by libgit2. ++/// ++/// A buffer can be thought of a `Vec`, but the `Vec` type is not used to ++/// avoid copying data back and forth. ++pub struct Buf { ++ raw: raw::git_buf, ++} ++ ++impl Default for Buf { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl Buf { ++ /// Creates a new empty buffer. ++ pub fn new() -> Buf { ++ ::init(); ++ unsafe { ++ Binding::from_raw(&mut raw::git_buf { ++ ptr: ptr::null_mut(), ++ size: 0, ++ asize: 0, ++ } as *mut _) ++ } ++ } ++ ++ /// Attempt to view this buffer as a string slice. ++ /// ++ /// Returns `None` if the buffer is not valid utf-8. ++ pub fn as_str(&self) -> Option<&str> { str::from_utf8(&**self).ok() } ++} ++ ++impl Deref for Buf { ++ type Target = [u8]; ++ fn deref(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts(self.raw.ptr as *const u8, ++ self.raw.size as usize) ++ } ++ } ++} ++ ++impl DerefMut for Buf { ++ fn deref_mut(&mut self) -> &mut [u8] { ++ unsafe { ++ slice::from_raw_parts_mut(self.raw.ptr as *mut u8, ++ self.raw.size as usize) ++ } ++ } ++} ++ ++impl Binding for Buf { ++ type Raw = *mut raw::git_buf; ++ unsafe fn from_raw(raw: *mut raw::git_buf) -> Buf { ++ Buf { raw: *raw } ++ } ++ fn raw(&self) -> *mut raw::git_buf { &self.raw as *const _ as *mut _ } ++} ++ ++impl Drop for Buf { ++ fn drop(&mut self) { ++ unsafe { raw::git_buf_free(&mut self.raw) } ++ } ++} diff --cc vendor/git2-0.6.8/src/build.rs index 000000000,000000000..155b0c5dd new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/build.rs @@@ -1,0 -1,0 +1,556 @@@ ++//! Builder-pattern objects for configuration various git operations. ++ ++use std::ffi::{CStr, CString}; ++use std::mem; ++use std::path::Path; ++use std::ptr; ++use libc::{c_char, size_t, c_void, c_uint, c_int}; ++ ++use {raw, panic, Error, Repository, FetchOptions, IntoCString}; ++use {CheckoutNotificationType, DiffFile}; ++use util::{self, Binding}; ++ ++/// A builder struct which is used to build configuration for cloning a new git ++/// repository. ++pub struct RepoBuilder<'cb> { ++ bare: bool, ++ branch: Option, ++ local: bool, ++ hardlinks: bool, ++ checkout: Option>, ++ fetch_opts: Option>, ++} ++ ++/// A builder struct for configuring checkouts of a repository. ++pub struct CheckoutBuilder<'cb> { ++ their_label: Option, ++ our_label: Option, ++ ancestor_label: Option, ++ target_dir: Option, ++ paths: Vec, ++ path_ptrs: Vec<*const c_char>, ++ file_perm: Option, ++ dir_perm: Option, ++ disable_filters: bool, ++ checkout_opts: u32, ++ progress: Option>>, ++ notify: Option>>, ++ notify_flags: CheckoutNotificationType, ++} ++ ++/// Checkout progress notification callback. ++/// ++/// The first argument is the path for the notification, the next is the numver ++/// of completed steps so far, and the final is the total number of steps. ++pub type Progress<'a> = FnMut(Option<&Path>, usize, usize) + 'a; ++ ++/// Checkout notifications callback. ++/// ++/// The first argument is the notification type, the next is the path for the ++/// the notification, followed by the baseline diff, target diff, and workdir diff. ++/// ++/// The callback must return a bool specifying whether the checkout should ++/// continue. ++pub type Notify<'a> = FnMut(CheckoutNotificationType, Option<&Path>, DiffFile, ++ DiffFile, DiffFile) -> bool + 'a; ++ ++ ++impl<'cb> Default for RepoBuilder<'cb> { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl<'cb> RepoBuilder<'cb> { ++ /// Creates a new repository builder with all of the default configuration. ++ /// ++ /// When ready, the `clone()` method can be used to clone a new repository ++ /// using this configuration. ++ pub fn new() -> RepoBuilder<'cb> { ++ ::init(); ++ RepoBuilder { ++ bare: false, ++ branch: None, ++ local: true, ++ hardlinks: true, ++ checkout: None, ++ fetch_opts: None, ++ } ++ } ++ ++ /// Indicate whether the repository will be cloned as a bare repository or ++ /// not. ++ pub fn bare(&mut self, bare: bool) -> &mut RepoBuilder<'cb> { ++ self.bare = bare; ++ self ++ } ++ ++ /// Specify the name of the branch to check out after the clone. ++ /// ++ /// If not specified, the remote's default branch will be used. ++ pub fn branch(&mut self, branch: &str) -> &mut RepoBuilder<'cb> { ++ self.branch = Some(CString::new(branch).unwrap()); ++ self ++ } ++ ++ /// Set the flag for bypassing the git aware transport mechanism for local ++ /// paths. ++ /// ++ /// If `true`, the git-aware transport will be bypassed for local paths. If ++ /// `false`, the git-aware transport will not be bypassed. ++ pub fn local(&mut self, local: bool) -> &mut RepoBuilder<'cb> { ++ self.local = local; ++ self ++ } ++ ++ /// Set the flag for whether hardlinks are used when using a local git-aware ++ /// transport mechanism. ++ pub fn hardlinks(&mut self, links: bool) -> &mut RepoBuilder<'cb> { ++ self.hardlinks = links; ++ self ++ } ++ ++ /// Configure the checkout which will be performed by consuming a checkout ++ /// builder. ++ pub fn with_checkout(&mut self, checkout: CheckoutBuilder<'cb>) ++ -> &mut RepoBuilder<'cb> { ++ self.checkout = Some(checkout); ++ self ++ } ++ ++ /// Options which control the fetch, including callbacks. ++ /// ++ /// The callbacks are used for reporting fetch progress, and for acquiring ++ /// credentials in the event they are needed. ++ pub fn fetch_options(&mut self, fetch_opts: FetchOptions<'cb>) ++ -> &mut RepoBuilder<'cb> { ++ self.fetch_opts = Some(fetch_opts); ++ self ++ } ++ ++ /// Clone a remote repository. ++ /// ++ /// This will use the options configured so far to clone the specified url ++ /// into the specified local path. ++ pub fn clone(&mut self, url: &str, into: &Path) -> Result { ++ let mut opts: raw::git_clone_options = unsafe { mem::zeroed() }; ++ unsafe { ++ try_call!(raw::git_clone_init_options(&mut opts, ++ raw::GIT_CLONE_OPTIONS_VERSION)); ++ } ++ opts.bare = self.bare as c_int; ++ opts.checkout_branch = self.branch.as_ref().map(|s| { ++ s.as_ptr() ++ }).unwrap_or(ptr::null()); ++ ++ opts.local = match (self.local, self.hardlinks) { ++ (true, false) => raw::GIT_CLONE_LOCAL_NO_LINKS, ++ (false, _) => raw::GIT_CLONE_NO_LOCAL, ++ (true, _) => raw::GIT_CLONE_LOCAL_AUTO, ++ }; ++ opts.checkout_opts.checkout_strategy = ++ raw::GIT_CHECKOUT_SAFE as c_uint; ++ ++ if let Some(ref mut cbs) = self.fetch_opts { ++ opts.fetch_opts = cbs.raw(); ++ } ++ ++ if let Some(ref mut c) = self.checkout { ++ unsafe { ++ c.configure(&mut opts.checkout_opts); ++ } ++ } ++ ++ let url = try!(CString::new(url)); ++ let into = try!(into.into_c_string()); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_clone(&mut raw, url, into, &opts)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++} ++ ++impl<'cb> Default for CheckoutBuilder<'cb> { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl<'cb> CheckoutBuilder<'cb> { ++ /// Creates a new builder for checkouts with all of its default ++ /// configuration. ++ pub fn new() -> CheckoutBuilder<'cb> { ++ ::init(); ++ CheckoutBuilder { ++ disable_filters: false, ++ dir_perm: None, ++ file_perm: None, ++ path_ptrs: Vec::new(), ++ paths: Vec::new(), ++ target_dir: None, ++ ancestor_label: None, ++ our_label: None, ++ their_label: None, ++ checkout_opts: raw::GIT_CHECKOUT_SAFE as u32, ++ progress: None, ++ notify: None, ++ notify_flags: CheckoutNotificationType::empty(), ++ } ++ } ++ ++ /// Indicate that this checkout should perform a dry run by checking for ++ /// conflicts but not make any actual changes. ++ pub fn dry_run(&mut self) -> &mut CheckoutBuilder<'cb> { ++ self.checkout_opts &= !((1 << 4) - 1); ++ self.checkout_opts |= raw::GIT_CHECKOUT_NONE as u32; ++ self ++ } ++ ++ /// Take any action necessary to get the working directory to match the ++ /// target including potentially discarding modified files. ++ pub fn force(&mut self) -> &mut CheckoutBuilder<'cb> { ++ self.checkout_opts &= !((1 << 4) - 1); ++ self.checkout_opts |= raw::GIT_CHECKOUT_FORCE as u32; ++ self ++ } ++ ++ /// Indicate that the checkout should be performed safely, allowing new ++ /// files to be created but not overwriting extisting files or changes. ++ /// ++ /// This is the default. ++ pub fn safe(&mut self) -> &mut CheckoutBuilder<'cb> { ++ self.checkout_opts &= !((1 << 4) - 1); ++ self.checkout_opts |= raw::GIT_CHECKOUT_SAFE as u32; ++ self ++ } ++ ++ fn flag(&mut self, bit: raw::git_checkout_strategy_t, ++ on: bool) -> &mut CheckoutBuilder<'cb> { ++ if on { ++ self.checkout_opts |= bit as u32; ++ } else { ++ self.checkout_opts &= !(bit as u32); ++ } ++ self ++ } ++ ++ /// In safe mode, create files that don't exist. ++ /// ++ /// Defaults to false. ++ pub fn recreate_missing(&mut self, allow: bool) -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_RECREATE_MISSING, allow) ++ } ++ ++ /// In safe mode, apply safe file updates even when there are conflicts ++ /// instead of canceling the checkout. ++ /// ++ /// Defaults to false. ++ pub fn allow_conflicts(&mut self, allow: bool) -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_ALLOW_CONFLICTS, allow) ++ } ++ ++ /// Remove untracked files from the working dir. ++ /// ++ /// Defaults to false. ++ pub fn remove_untracked(&mut self, remove: bool) ++ -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_REMOVE_UNTRACKED, remove) ++ } ++ ++ /// Remove ignored files from the working dir. ++ /// ++ /// Defaults to false. ++ pub fn remove_ignored(&mut self, remove: bool) -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_REMOVE_IGNORED, remove) ++ } ++ ++ /// Only update the contents of files that already exist. ++ /// ++ /// If set, files will not be created or deleted. ++ /// ++ /// Defaults to false. ++ pub fn update_only(&mut self, update: bool) -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_UPDATE_ONLY, update) ++ } ++ ++ /// Prevents checkout from writing the updated files' information to the ++ /// index. ++ /// ++ /// Defaults to true. ++ pub fn update_index(&mut self, update: bool) -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_DONT_UPDATE_INDEX, !update) ++ } ++ ++ /// Indicate whether the index and git attributes should be refreshed from ++ /// disk before any operations. ++ /// ++ /// Defaults to true, ++ pub fn refresh(&mut self, refresh: bool) -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_NO_REFRESH, !refresh) ++ } ++ ++ /// Skip files with unmerged index entries. ++ /// ++ /// Defaults to false. ++ pub fn skip_unmerged(&mut self, skip: bool) -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_SKIP_UNMERGED, skip) ++ } ++ ++ /// Indicate whether the checkout should proceed on conflicts by using the ++ /// stage 2 version of the file ("ours"). ++ /// ++ /// Defaults to false. ++ pub fn use_ours(&mut self, ours: bool) -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_USE_OURS, ours) ++ } ++ ++ /// Indicate whether the checkout should proceed on conflicts by using the ++ /// stage 3 version of the file ("theirs"). ++ /// ++ /// Defaults to false. ++ pub fn use_theirs(&mut self, theirs: bool) -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_USE_THEIRS, theirs) ++ } ++ ++ /// Indicate whether ignored files should be overwritten during the checkout. ++ /// ++ /// Defaults to true. ++ pub fn overwrite_ignored(&mut self, overwrite: bool) ++ -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_DONT_OVERWRITE_IGNORED, !overwrite) ++ } ++ ++ /// Indicate whether a normal merge file should be written for conflicts. ++ /// ++ /// Defaults to false. ++ pub fn conflict_style_merge(&mut self, on: bool) ++ -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_CONFLICT_STYLE_MERGE, on) ++ } ++ ++ /// Specify for which notification types to invoke the notification ++ /// callback. ++ /// ++ /// Defaults to none. ++ pub fn notify_on(&mut self, notification_types: CheckoutNotificationType) ++ -> &mut CheckoutBuilder<'cb> { ++ self.notify_flags = notification_types; ++ self ++ } ++ ++ /// Indicates whether to include common ancestor data in diff3 format files ++ /// for conflicts. ++ /// ++ /// Defaults to false. ++ pub fn conflict_style_diff3(&mut self, on: bool) ++ -> &mut CheckoutBuilder<'cb> { ++ self.flag(raw::GIT_CHECKOUT_CONFLICT_STYLE_DIFF3, on) ++ } ++ ++ /// Indicate whether to apply filters like CRLF conversion. ++ pub fn disable_filters(&mut self, disable: bool) ++ -> &mut CheckoutBuilder<'cb> { ++ self.disable_filters = disable; ++ self ++ } ++ ++ /// Set the mode with which new directories are created. ++ /// ++ /// Default is 0755 ++ pub fn dir_perm(&mut self, perm: i32) -> &mut CheckoutBuilder<'cb> { ++ self.dir_perm = Some(perm); ++ self ++ } ++ ++ /// Set the mode with which new files are created. ++ /// ++ /// The default is 0644 or 0755 as dictated by the blob. ++ pub fn file_perm(&mut self, perm: i32) -> &mut CheckoutBuilder<'cb> { ++ self.file_perm = Some(perm); ++ self ++ } ++ ++ /// Add a path to be checked out. ++ /// ++ /// If no paths are specified, then all files are checked out. Otherwise ++ /// only these specified paths are checked out. ++ pub fn path(&mut self, path: T) ++ -> &mut CheckoutBuilder<'cb> { ++ let path = path.into_c_string().unwrap(); ++ self.path_ptrs.push(path.as_ptr()); ++ self.paths.push(path); ++ self ++ } ++ ++ /// Set the directory to check out to ++ pub fn target_dir(&mut self, dst: &Path) -> &mut CheckoutBuilder<'cb> { ++ self.target_dir = Some(dst.into_c_string().unwrap()); ++ self ++ } ++ ++ /// The name of the common ancestor side of conflicts ++ pub fn ancestor_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> { ++ self.ancestor_label = Some(CString::new(label).unwrap()); ++ self ++ } ++ ++ /// The name of the common our side of conflicts ++ pub fn our_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> { ++ self.our_label = Some(CString::new(label).unwrap()); ++ self ++ } ++ ++ /// The name of the common their side of conflicts ++ pub fn their_label(&mut self, label: &str) -> &mut CheckoutBuilder<'cb> { ++ self.their_label = Some(CString::new(label).unwrap()); ++ self ++ } ++ ++ /// Set a callback to receive notifications of checkout progress. ++ pub fn progress(&mut self, cb: F) -> &mut CheckoutBuilder<'cb> ++ where F: FnMut(Option<&Path>, usize, usize) + 'cb { ++ self.progress = Some(Box::new(cb) as Box>); ++ self ++ } ++ ++ /// Set a callback to receive checkout notifications. ++ /// ++ /// Callbacks are invoked prior to modifying any files on disk. ++ /// Returning `false` from the callback will cancel the checkout. ++ pub fn notify(&mut self, cb: F) -> &mut CheckoutBuilder<'cb> ++ where F: FnMut(CheckoutNotificationType, Option<&Path>, DiffFile, ++ DiffFile, DiffFile) -> bool + 'cb ++ { ++ self.notify = Some(Box::new(cb) as Box>); ++ self ++ } ++ ++ /// Configure a raw checkout options based on this configuration. ++ /// ++ /// This method is unsafe as there is no guarantee that this structure will ++ /// outlive the provided checkout options. ++ pub unsafe fn configure(&mut self, opts: &mut raw::git_checkout_options) { ++ opts.version = raw::GIT_CHECKOUT_OPTIONS_VERSION; ++ opts.disable_filters = self.disable_filters as c_int; ++ opts.dir_mode = self.dir_perm.unwrap_or(0) as c_uint; ++ opts.file_mode = self.file_perm.unwrap_or(0) as c_uint; ++ ++ if !self.path_ptrs.is_empty() { ++ opts.paths.strings = self.path_ptrs.as_ptr() as *mut _; ++ opts.paths.count = self.path_ptrs.len() as size_t; ++ } ++ ++ if let Some(ref c) = self.target_dir { ++ opts.target_directory = c.as_ptr(); ++ } ++ if let Some(ref c) = self.ancestor_label { ++ opts.ancestor_label = c.as_ptr(); ++ } ++ if let Some(ref c) = self.our_label { ++ opts.our_label = c.as_ptr(); ++ } ++ if let Some(ref c) = self.their_label { ++ opts.their_label = c.as_ptr(); ++ } ++ if self.progress.is_some() { ++ let f: raw::git_checkout_progress_cb = progress_cb; ++ opts.progress_cb = Some(f); ++ opts.progress_payload = self as *mut _ as *mut _; ++ } ++ if self.notify.is_some() { ++ let f: raw::git_checkout_notify_cb = notify_cb; ++ opts.notify_cb = Some(f); ++ opts.notify_payload = self as *mut _ as *mut _; ++ opts.notify_flags = self.notify_flags.bits() as c_uint; ++ } ++ opts.checkout_strategy = self.checkout_opts as c_uint; ++ } ++} ++ ++extern fn progress_cb(path: *const c_char, ++ completed: size_t, ++ total: size_t, ++ data: *mut c_void) { ++ panic::wrap(|| unsafe { ++ let payload = &mut *(data as *mut CheckoutBuilder); ++ let callback = match payload.progress { ++ Some(ref mut c) => c, ++ None => return, ++ }; ++ let path = if path.is_null() { ++ None ++ } else { ++ Some(util::bytes2path(CStr::from_ptr(path).to_bytes())) ++ }; ++ callback(path, completed as usize, total as usize) ++ }); ++} ++ ++extern fn notify_cb(why: raw::git_checkout_notify_t, ++ path: *const c_char, ++ baseline: *const raw::git_diff_file, ++ target: *const raw::git_diff_file, ++ workdir: *const raw::git_diff_file, ++ data: *mut c_void) -> c_int { ++ // pack callback etc ++ panic::wrap(|| unsafe { ++ let payload = &mut *(data as *mut CheckoutBuilder); ++ let callback = match payload.notify { ++ Some(ref mut c) => c, ++ None => return 0, ++ }; ++ let path = if path.is_null() { ++ None ++ } else { ++ Some(util::bytes2path(CStr::from_ptr(path).to_bytes())) ++ }; ++ ++ let why = CheckoutNotificationType::from_bits_truncate(why as u32); ++ let keep_going = callback(why, ++ path, ++ DiffFile::from_raw(baseline), ++ DiffFile::from_raw(target), ++ DiffFile::from_raw(workdir)); ++ if keep_going {0} else {1} ++ }).unwrap_or(2) ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::fs; ++ use std::path::Path; ++ use tempdir::TempDir; ++ use super::RepoBuilder; ++ use Repository; ++ ++ #[test] ++ fn smoke() { ++ let r = RepoBuilder::new().clone("/path/to/nowhere", Path::new("foo")); ++ assert!(r.is_err()); ++ } ++ ++ #[test] ++ fn smoke2() { ++ let td = TempDir::new("test").unwrap(); ++ Repository::init_bare(&td.path().join("bare")).unwrap(); ++ let url = if cfg!(unix) { ++ format!("file://{}/bare", td.path().display()) ++ } else { ++ format!("file:///{}/bare", td.path().display().to_string() ++ .replace("\\", "/")) ++ }; ++ ++ let dst = td.path().join("foo"); ++ RepoBuilder::new().clone(&url, &dst).unwrap(); ++ fs::remove_dir_all(&dst).unwrap(); ++ RepoBuilder::new().local(false).clone(&url, &dst).unwrap(); ++ fs::remove_dir_all(&dst).unwrap(); ++ RepoBuilder::new().local(false).hardlinks(false).bare(true) ++ .clone(&url, &dst).unwrap(); ++ fs::remove_dir_all(&dst).unwrap(); ++ assert!(RepoBuilder::new().branch("foo") ++ .clone(&url, &dst).is_err()); ++ } ++ ++} diff --cc vendor/git2-0.6.8/src/call.rs index 000000000,000000000..ba5a1d565 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/call.rs @@@ -1,0 -1,0 +1,219 @@@ ++#![macro_use] ++use libc; ++ ++use Error; ++ ++macro_rules! call { ++ (raw::$p:ident ($($e:expr),*)) => ( ++ raw::$p($(::call::convert(&$e)),*) ++ ) ++} ++ ++macro_rules! try_call { ++ (raw::$p:ident ($($e:expr),*)) => ({ ++ match ::call::try(raw::$p($(::call::convert(&$e)),*)) { ++ Ok(o) => o, ++ Err(e) => { ::panic::check(); return Err(e) } ++ } ++ }) ++} ++ ++macro_rules! try_call_iter { ++ ($($f:tt)*) => { ++ match call!($($f)*) { ++ 0 => {} ++ raw::GIT_ITEROVER => return None, ++ e => return Some(Err(::call::last_error(e))) ++ } ++ } ++} ++ ++#[doc(hidden)] ++pub trait Convert { ++ fn convert(&self) -> T; ++} ++ ++pub fn convert>(u: &U) -> T { u.convert() } ++ ++pub fn try(ret: libc::c_int) -> Result { ++ match ret { ++ n if n < 0 => Err(last_error(n)), ++ n => Ok(n), ++ } ++} ++ ++pub fn last_error(code: libc::c_int) -> Error { ++ // Apparently libgit2 isn't necessarily guaranteed to set the last error ++ // whenever a function returns a negative value! ++ Error::last_error(code).unwrap_or_else(|| { ++ Error::from_str("an unknown error occurred") ++ }) ++} ++ ++mod impls { ++ use std::ffi::CString; ++ use std::ptr; ++ ++ use libc; ++ ++ use {raw, ConfigLevel, ResetType, ObjectType, BranchType, Direction}; ++ use {DiffFormat, FileFavor, SubmoduleIgnore, AutotagOption, FetchPrune}; ++ use call::Convert; ++ ++ impl Convert for T { ++ fn convert(&self) -> T { *self } ++ } ++ ++ impl Convert for bool { ++ fn convert(&self) -> libc::c_int { *self as libc::c_int } ++ } ++ impl<'a, T> Convert<*const T> for &'a T { ++ fn convert(&self) -> *const T { *self as *const T } ++ } ++ impl<'a, T> Convert<*mut T> for &'a mut T { ++ fn convert(&self) -> *mut T { &**self as *const T as *mut T } ++ } ++ impl Convert<*const T> for *mut T { ++ fn convert(&self) -> *const T { *self as *const T } ++ } ++ ++ impl Convert<*const libc::c_char> for CString { ++ fn convert(&self) -> *const libc::c_char { self.as_ptr() } ++ } ++ ++ impl> Convert<*const T> for Option { ++ fn convert(&self) -> *const T { ++ self.as_ref().map(|s| s.convert()).unwrap_or(ptr::null()) ++ } ++ } ++ ++ impl> Convert<*mut T> for Option { ++ fn convert(&self) -> *mut T { ++ self.as_ref().map(|s| s.convert()).unwrap_or(ptr::null_mut()) ++ } ++ } ++ ++ impl Convert for ResetType { ++ fn convert(&self) -> raw::git_reset_t { ++ match *self { ++ ResetType::Soft => raw::GIT_RESET_SOFT, ++ ResetType::Hard => raw::GIT_RESET_HARD, ++ ResetType::Mixed => raw::GIT_RESET_MIXED, ++ } ++ } ++ } ++ ++ impl Convert for Direction { ++ fn convert(&self) -> raw::git_direction { ++ match *self { ++ Direction::Push => raw::GIT_DIRECTION_PUSH, ++ Direction::Fetch => raw::GIT_DIRECTION_FETCH, ++ } ++ } ++ } ++ ++ impl Convert for ObjectType { ++ fn convert(&self) -> raw::git_otype { ++ match *self { ++ ObjectType::Any => raw::GIT_OBJ_ANY, ++ ObjectType::Commit => raw::GIT_OBJ_COMMIT, ++ ObjectType::Tree => raw::GIT_OBJ_TREE, ++ ObjectType::Blob => raw::GIT_OBJ_BLOB, ++ ObjectType::Tag => raw::GIT_OBJ_TAG, ++ } ++ } ++ } ++ ++ impl Convert for Option { ++ fn convert(&self) -> raw::git_otype { ++ self.unwrap_or(ObjectType::Any).convert() ++ } ++ } ++ ++ impl Convert for BranchType { ++ fn convert(&self) -> raw::git_branch_t { ++ match *self { ++ BranchType::Remote => raw::GIT_BRANCH_REMOTE, ++ BranchType::Local => raw::GIT_BRANCH_LOCAL, ++ } ++ } ++ } ++ ++ impl Convert for Option { ++ fn convert(&self) -> raw::git_branch_t { ++ self.map(|s| s.convert()).unwrap_or(raw::GIT_BRANCH_ALL) ++ } ++ } ++ ++ impl Convert for ConfigLevel { ++ fn convert(&self) -> raw::git_config_level_t { ++ match *self { ++ ConfigLevel::ProgramData => raw::GIT_CONFIG_LEVEL_PROGRAMDATA, ++ ConfigLevel::System => raw::GIT_CONFIG_LEVEL_SYSTEM, ++ ConfigLevel::XDG => raw::GIT_CONFIG_LEVEL_XDG, ++ ConfigLevel::Global => raw::GIT_CONFIG_LEVEL_GLOBAL, ++ ConfigLevel::Local => raw::GIT_CONFIG_LEVEL_LOCAL, ++ ConfigLevel::App => raw::GIT_CONFIG_LEVEL_APP, ++ ConfigLevel::Highest => raw::GIT_CONFIG_HIGHEST_LEVEL, ++ } ++ } ++ } ++ ++ impl Convert for DiffFormat { ++ fn convert(&self) -> raw::git_diff_format_t { ++ match *self { ++ DiffFormat::Patch => raw::GIT_DIFF_FORMAT_PATCH, ++ DiffFormat::PatchHeader => raw::GIT_DIFF_FORMAT_PATCH_HEADER, ++ DiffFormat::Raw => raw::GIT_DIFF_FORMAT_RAW, ++ DiffFormat::NameOnly => raw::GIT_DIFF_FORMAT_NAME_ONLY, ++ DiffFormat::NameStatus => raw::GIT_DIFF_FORMAT_NAME_STATUS, ++ } ++ } ++ } ++ ++ impl Convert for FileFavor { ++ fn convert(&self) -> raw::git_merge_file_favor_t { ++ match *self { ++ FileFavor::Normal => raw::GIT_MERGE_FILE_FAVOR_NORMAL, ++ FileFavor::Ours => raw::GIT_MERGE_FILE_FAVOR_OURS, ++ FileFavor::Theirs => raw::GIT_MERGE_FILE_FAVOR_THEIRS, ++ FileFavor::Union => raw::GIT_MERGE_FILE_FAVOR_UNION, ++ } ++ } ++ } ++ ++ impl Convert for SubmoduleIgnore { ++ fn convert(&self) -> raw::git_submodule_ignore_t { ++ match *self { ++ SubmoduleIgnore::Unspecified => ++ raw::GIT_SUBMODULE_IGNORE_UNSPECIFIED, ++ SubmoduleIgnore::None => raw::GIT_SUBMODULE_IGNORE_NONE, ++ SubmoduleIgnore::Untracked => raw::GIT_SUBMODULE_IGNORE_UNTRACKED, ++ SubmoduleIgnore::Dirty => raw::GIT_SUBMODULE_IGNORE_DIRTY, ++ SubmoduleIgnore::All => raw::GIT_SUBMODULE_IGNORE_ALL, ++ } ++ } ++ } ++ ++ impl Convert for AutotagOption { ++ fn convert(&self) -> raw::git_remote_autotag_option_t { ++ match *self { ++ AutotagOption::Unspecified => ++ raw::GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, ++ AutotagOption::None => raw::GIT_REMOTE_DOWNLOAD_TAGS_NONE, ++ AutotagOption::Auto => raw::GIT_REMOTE_DOWNLOAD_TAGS_AUTO, ++ AutotagOption::All => raw::GIT_REMOTE_DOWNLOAD_TAGS_ALL, ++ } ++ } ++ } ++ ++ impl Convert for FetchPrune { ++ fn convert(&self) -> raw::git_fetch_prune_t { ++ match *self { ++ FetchPrune::Unspecified => raw::GIT_FETCH_PRUNE_UNSPECIFIED, ++ FetchPrune::On => raw::GIT_FETCH_PRUNE, ++ FetchPrune::Off => raw::GIT_FETCH_NO_PRUNE, ++ } ++ } ++ } ++} diff --cc vendor/git2-0.6.8/src/cert.rs index 000000000,000000000..70ab9498f new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/cert.rs @@@ -1,0 -1,0 +1,97 @@@ ++//! Certificate types which are passed to `CertificateCheck` in ++//! `RemoteCallbacks`. ++ ++use std::marker; ++use std::mem; ++use std::slice; ++ ++use raw; ++use util::Binding; ++ ++/// A certificate for a remote connection, viewable as one of `CertHostkey` or ++/// `CertX509` currently. ++pub struct Cert<'a> { ++ raw: *mut raw::git_cert, ++ _marker: marker::PhantomData<&'a raw::git_cert>, ++} ++ ++/// Hostkey information taken from libssh2 ++pub struct CertHostkey<'a> { ++ raw: *mut raw::git_cert_hostkey, ++ _marker: marker::PhantomData<&'a raw::git_cert>, ++} ++ ++/// X.509 certificate information ++pub struct CertX509<'a> { ++ raw: *mut raw::git_cert_x509, ++ _marker: marker::PhantomData<&'a raw::git_cert>, ++} ++ ++impl<'a> Cert<'a> { ++ /// Attempt to view this certificate as an SSH hostkey. ++ /// ++ /// Returns `None` if this is not actually an SSH hostkey. ++ pub fn as_hostkey(&self) -> Option<&CertHostkey<'a>> { ++ self.cast(raw::GIT_CERT_HOSTKEY_LIBSSH2) ++ } ++ ++ /// Attempt to view this certificate as an X.509 certificate. ++ /// ++ /// Returns `None` if this is not actually an X.509 certificate. ++ pub fn as_x509(&self) -> Option<&CertX509<'a>> { ++ self.cast(raw::GIT_CERT_X509) ++ } ++ ++ fn cast(&self, kind: raw::git_cert_t) -> Option<&T> { ++ assert_eq!(mem::size_of::>(), mem::size_of::()); ++ unsafe { ++ if kind == (*self.raw).cert_type { ++ Some(&*(self as *const Cert<'a> as *const T)) ++ } else { ++ None ++ } ++ } ++ } ++} ++ ++impl<'a> CertHostkey<'a> { ++ /// Returns the md5 hash of the hostkey, if available. ++ pub fn hash_md5(&self) -> Option<&[u8; 16]> { ++ unsafe { ++ if (*self.raw).kind as u32 & raw::GIT_CERT_SSH_MD5 as u32 == 0 { ++ None ++ } else { ++ Some(&(*self.raw).hash_md5) ++ } ++ } ++ } ++ ++ /// Returns the SHA-1 hash of the hostkey, if available. ++ pub fn hash_sha1(&self) -> Option<&[u8; 20]> { ++ unsafe { ++ if (*self.raw).kind as u32 & raw::GIT_CERT_SSH_SHA1 as u32 == 0 { ++ None ++ } else { ++ Some(&(*self.raw).hash_sha1) ++ } ++ } ++ } ++} ++ ++impl<'a> CertX509<'a> { ++ /// Return the X.509 certificate data as a byte slice ++ pub fn data(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts((*self.raw).data as *const u8, ++ (*self.raw).len as usize) ++ } ++ } ++} ++ ++impl<'a> Binding for Cert<'a> { ++ type Raw = *mut raw::git_cert; ++ unsafe fn from_raw(raw: *mut raw::git_cert) -> Cert<'a> { ++ Cert { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *mut raw::git_cert { self.raw } ++} diff --cc vendor/git2-0.6.8/src/commit.rs index 000000000,000000000..891c1b0f2 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/commit.rs @@@ -1,0 -1,0 +1,343 @@@ ++use std::marker; ++use std::mem; ++use std::ops::Range; ++use std::ptr; ++use std::str; ++use libc; ++ ++use {raw, signature, Oid, Error, Signature, Tree, Time, Object}; ++use util::Binding; ++ ++/// A structure to represent a git [commit][1] ++/// ++/// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects ++pub struct Commit<'repo> { ++ raw: *mut raw::git_commit, ++ _marker: marker::PhantomData>, ++} ++ ++/// An iterator over the parent commits of a commit. ++pub struct Parents<'commit, 'repo: 'commit> { ++ range: Range, ++ commit: &'commit Commit<'repo>, ++} ++ ++/// An iterator over the parent commits' ids of a commit. ++pub struct ParentIds<'commit> { ++ range: Range, ++ commit: &'commit Commit<'commit>, ++} ++ ++impl<'repo> Commit<'repo> { ++ /// Get the id (SHA1) of a repository commit ++ pub fn id(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_commit_id(&*self.raw)) } ++ } ++ ++ /// Get the id of the tree pointed to by this commit. ++ /// ++ /// No attempts are made to fetch an object from the ODB. ++ pub fn tree_id(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_commit_tree_id(&*self.raw)) } ++ } ++ ++ /// Get the tree pointed to by a commit. ++ pub fn tree(&self) -> Result, Error> { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_commit_tree(&mut ret, &*self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Get access to the underlying raw pointer. ++ pub fn raw(&self) -> *mut raw::git_commit { self.raw } ++ ++ /// Get the full message of a commit. ++ /// ++ /// The returned message will be slightly prettified by removing any ++ /// potential leading newlines. ++ /// ++ /// `None` will be returned if the message is not valid utf-8 ++ pub fn message(&self) -> Option<&str> { ++ str::from_utf8(self.message_bytes()).ok() ++ } ++ ++ /// Get the full message of a commit as a byte slice. ++ /// ++ /// The returned message will be slightly prettified by removing any ++ /// potential leading newlines. ++ pub fn message_bytes(&self) -> &[u8] { ++ unsafe { ++ ::opt_bytes(self, raw::git_commit_message(&*self.raw)).unwrap() ++ } ++ } ++ ++ /// Get the encoding for the message of a commit, as a string representing a ++ /// standard encoding name. ++ /// ++ /// `None` will be returned if the encoding is not known ++ pub fn message_encoding(&self) -> Option<&str> { ++ let bytes = unsafe { ++ ::opt_bytes(self, raw::git_commit_message(&*self.raw)) ++ }; ++ bytes.map(|b| str::from_utf8(b).unwrap()) ++ } ++ ++ /// Get the full raw message of a commit. ++ /// ++ /// `None` will be returned if the message is not valid utf-8 ++ pub fn message_raw(&self) -> Option<&str> { ++ str::from_utf8(self.message_raw_bytes()).ok() ++ } ++ ++ /// Get the full raw message of a commit. ++ pub fn message_raw_bytes(&self) -> &[u8] { ++ unsafe { ++ ::opt_bytes(self, raw::git_commit_message_raw(&*self.raw)).unwrap() ++ } ++ } ++ ++ /// Get the full raw text of the commit header. ++ /// ++ /// `None` will be returned if the message is not valid utf-8 ++ pub fn raw_header(&self) -> Option<&str> { ++ str::from_utf8(self.raw_header_bytes()).ok() ++ } ++ ++ /// Get the full raw text of the commit header. ++ pub fn raw_header_bytes(&self) -> &[u8] { ++ unsafe { ++ ::opt_bytes(self, raw::git_commit_raw_header(&*self.raw)).unwrap() ++ } ++ } ++ ++ /// Get the short "summary" of the git commit message. ++ /// ++ /// The returned message is the summary of the commit, comprising the first ++ /// paragraph of the message with whitespace trimmed and squashed. ++ /// ++ /// `None` may be returned if an error occurs or if the summary is not valid ++ /// utf-8. ++ pub fn summary(&mut self) -> Option<&str> { ++ self.summary_bytes().and_then(|s| str::from_utf8(s).ok()) ++ } ++ ++ /// Get the short "summary" of the git commit message. ++ /// ++ /// The returned message is the summary of the commit, comprising the first ++ /// paragraph of the message with whitespace trimmed and squashed. ++ /// ++ /// `None` may be returned if an error occurs ++ pub fn summary_bytes(&mut self) -> Option<&[u8]> { ++ unsafe { ::opt_bytes(self, raw::git_commit_summary(self.raw)) } ++ } ++ ++ /// Get the commit time (i.e. committer time) of a commit. ++ /// ++ /// The first element of the tuple is the time, in seconds, since the epoch. ++ /// The second element is the offset, in minutes, of the time zone of the ++ /// committer's preferred time zone. ++ pub fn time(&self) -> Time { ++ unsafe { ++ Time::new(raw::git_commit_time(&*self.raw) as i64, ++ raw::git_commit_time_offset(&*self.raw) as i32) ++ } ++ } ++ ++ /// Creates a new iterator over the parents of this commit. ++ pub fn parents<'a>(&'a self) -> Parents<'a, 'repo> { ++ let max = unsafe { raw::git_commit_parentcount(&*self.raw) as usize }; ++ Parents { range: 0..max, commit: self } ++ } ++ ++ /// Creates a new iterator over the parents of this commit. ++ pub fn parent_ids(&self) -> ParentIds { ++ let max = unsafe { raw::git_commit_parentcount(&*self.raw) as usize }; ++ ParentIds { range: 0..max, commit: self } ++ } ++ ++ /// Get the author of this commit. ++ pub fn author(&self) -> Signature { ++ unsafe { ++ let ptr = raw::git_commit_author(&*self.raw); ++ signature::from_raw_const(self, ptr) ++ } ++ } ++ ++ /// Get the committer of this commit. ++ pub fn committer(&self) -> Signature { ++ unsafe { ++ let ptr = raw::git_commit_committer(&*self.raw); ++ signature::from_raw_const(self, ptr) ++ } ++ } ++ ++ /// Amend this existing commit with all non-`None` values ++ /// ++ /// This creates a new commit that is exactly the same as the old commit, ++ /// except that any non-`None` values will be updated. The new commit has ++ /// the same parents as the old commit. ++ /// ++ /// For information about `update_ref`, see [`Repository::commit`]. ++ /// ++ /// [`Repository::commit`]: struct.Repository.html#method.commit ++ pub fn amend(&self, ++ update_ref: Option<&str>, ++ author: Option<&Signature>, ++ committer: Option<&Signature>, ++ message_encoding: Option<&str>, ++ message: Option<&str>, ++ tree: Option<&Tree<'repo>>) -> Result { ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ let update_ref = try!(::opt_cstr(update_ref)); ++ let encoding = try!(::opt_cstr(message_encoding)); ++ let message = try!(::opt_cstr(message)); ++ unsafe { ++ try_call!(raw::git_commit_amend(&mut raw, ++ self.raw(), ++ update_ref, ++ author.map(|s| s.raw()), ++ committer.map(|s| s.raw()), ++ encoding, ++ message, ++ tree.map(|t| t.raw()))); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++ ++ /// Get the specified parent of the commit. ++ /// ++ /// Use the `parents` iterator to return an iterator over all parents. ++ pub fn parent(&self, i: usize) -> Result, Error> { ++ unsafe { ++ let mut raw = ptr::null_mut(); ++ try_call!(raw::git_commit_parent(&mut raw, &*self.raw, ++ i as libc::c_uint)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Get the specified parent id of the commit. ++ /// ++ /// This is different from `parent`, which will attemptstempt to load the ++ /// parent commit from the ODB. ++ /// ++ /// Use the `parent_ids` iterator to return an iterator over all parents. ++ pub fn parent_id(&self, i: usize) -> Result { ++ unsafe { ++ let id = raw::git_commit_parent_id(self.raw, i as libc::c_uint); ++ if id.is_null() { ++ Err(Error::from_str("parent index out of bounds")) ++ } else { ++ Ok(Binding::from_raw(id)) ++ } ++ } ++ } ++ ++ /// Casts this Commit to be usable as an `Object` ++ pub fn as_object(&self) -> &Object<'repo> { ++ unsafe { ++ &*(self as *const _ as *const Object<'repo>) ++ } ++ } ++ ++ /// Consumes Commit to be returned as an `Object` ++ pub fn into_object(self) -> Object<'repo> { ++ assert_eq!(mem::size_of_val(&self), mem::size_of::()); ++ unsafe { ++ mem::transmute(self) ++ } ++ } ++} ++ ++impl<'repo> Binding for Commit<'repo> { ++ type Raw = *mut raw::git_commit; ++ unsafe fn from_raw(raw: *mut raw::git_commit) -> Commit<'repo> { ++ Commit { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_commit { self.raw } ++} ++ ++ ++impl<'repo, 'commit> Iterator for Parents<'commit, 'repo> { ++ type Item = Commit<'repo>; ++ fn next(&mut self) -> Option> { ++ self.range.next().map(|i| self.commit.parent(i).unwrap()) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++ ++impl<'repo, 'commit> DoubleEndedIterator for Parents<'commit, 'repo> { ++ fn next_back(&mut self) -> Option> { ++ self.range.next_back().map(|i| self.commit.parent(i).unwrap()) ++ } ++} ++ ++impl<'repo, 'commit> ExactSizeIterator for Parents<'commit, 'repo> {} ++ ++impl<'commit> Iterator for ParentIds<'commit> { ++ type Item = Oid; ++ fn next(&mut self) -> Option { ++ self.range.next().map(|i| self.commit.parent_id(i).unwrap()) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++ ++impl<'commit> DoubleEndedIterator for ParentIds<'commit> { ++ fn next_back(&mut self) -> Option { ++ self.range.next_back().map(|i| self.commit.parent_id(i).unwrap()) ++ } ++} ++ ++impl<'commit> ExactSizeIterator for ParentIds<'commit> {} ++ ++impl<'repo> Drop for Commit<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_commit_free(self.raw) } ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ let head = repo.head().unwrap(); ++ let target = head.target().unwrap(); ++ let mut commit = repo.find_commit(target).unwrap(); ++ assert_eq!(commit.message(), Some("initial")); ++ assert_eq!(commit.id(), target); ++ commit.message_raw().unwrap(); ++ commit.raw_header().unwrap(); ++ commit.message_encoding(); ++ commit.summary().unwrap(); ++ commit.tree_id(); ++ commit.tree().unwrap(); ++ assert_eq!(commit.parents().count(), 0); ++ ++ assert_eq!(commit.author().name(), Some("name")); ++ assert_eq!(commit.author().email(), Some("email")); ++ assert_eq!(commit.committer().name(), Some("name")); ++ assert_eq!(commit.committer().email(), Some("email")); ++ ++ let sig = repo.signature().unwrap(); ++ let tree = repo.find_tree(commit.tree_id()).unwrap(); ++ let id = repo.commit(Some("HEAD"), &sig, &sig, "bar", &tree, ++ &[&commit]).unwrap(); ++ let head = repo.find_commit(id).unwrap(); ++ ++ let new_head = head.amend(Some("HEAD"), None, None, None, ++ Some("new message"), None).unwrap(); ++ let new_head = repo.find_commit(new_head).unwrap(); ++ assert_eq!(new_head.message(), Some("new message")); ++ new_head.into_object(); ++ ++ repo.find_object(target, None).unwrap().as_commit().unwrap(); ++ repo.find_object(target, None).unwrap().into_commit().ok().unwrap(); ++ } ++} ++ diff --cc vendor/git2-0.6.8/src/config.rs index 000000000,000000000..32c148cd6 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/config.rs @@@ -1,0 -1,0 +1,608 @@@ ++use std::ffi::CString; ++use std::marker; ++use std::path::{Path, PathBuf}; ++use std::ptr; ++use std::str; ++use libc; ++ ++use {raw, Error, ConfigLevel, Buf, IntoCString}; ++use util::{self, Binding}; ++ ++/// A structure representing a git configuration key/value store ++pub struct Config { ++ raw: *mut raw::git_config, ++} ++ ++/// A struct representing a certain entry owned by a `Config` instance. ++/// ++/// An entry has a name, a value, and a level it applies to. ++pub struct ConfigEntry<'cfg> { ++ raw: *mut raw::git_config_entry, ++ _marker: marker::PhantomData<&'cfg Config>, ++ owned: bool, ++} ++ ++/// An iterator over the `ConfigEntry` values of a `Config` structure. ++pub struct ConfigEntries<'cfg> { ++ raw: *mut raw::git_config_iterator, ++ _marker: marker::PhantomData<&'cfg Config>, ++} ++ ++impl Config { ++ /// Allocate a new configuration object ++ /// ++ /// This object is empty, so you have to add a file to it before you can do ++ /// anything with it. ++ pub fn new() -> Result { ++ ::init(); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_config_new(&mut raw)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Create a new config instance containing a single on-disk file ++ pub fn open(path: &Path) -> Result { ++ ::init(); ++ let mut raw = ptr::null_mut(); ++ let path = try!(path.into_c_string()); ++ unsafe { ++ try_call!(raw::git_config_open_ondisk(&mut raw, path)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Open the global, XDG and system configuration files ++ /// ++ /// Utility wrapper that finds the global, XDG and system configuration ++ /// files and opens them into a single prioritized config object that can ++ /// be used when accessing default config data outside a repository. ++ pub fn open_default() -> Result { ++ ::init(); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_config_open_default(&mut raw)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Locate the path to the global configuration file ++ /// ++ /// The user or global configuration file is usually located in ++ /// `$HOME/.gitconfig`. ++ /// ++ /// This method will try to guess the full path to that file, if the file ++ /// exists. The returned path may be used on any method call to load ++ /// the global configuration file. ++ /// ++ /// This method will not guess the path to the xdg compatible config file ++ /// (`.config/git/config`). ++ pub fn find_global() -> Result { ++ ::init(); ++ let buf = Buf::new(); ++ unsafe { try_call!(raw::git_config_find_global(buf.raw())); } ++ Ok(util::bytes2path(&buf).to_path_buf()) ++ } ++ ++ /// Locate the path to the system configuration file ++ /// ++ /// If /etc/gitconfig doesn't exist, it will look for %PROGRAMFILES% ++ pub fn find_system() -> Result { ++ ::init(); ++ let buf = Buf::new(); ++ unsafe { try_call!(raw::git_config_find_system(buf.raw())); } ++ Ok(util::bytes2path(&buf).to_path_buf()) ++ } ++ ++ /// Locate the path to the global xdg compatible configuration file ++ /// ++ /// The xdg compatible configuration file is usually located in ++ /// `$HOME/.config/git/config`. ++ pub fn find_xdg() -> Result { ++ ::init(); ++ let buf = Buf::new(); ++ unsafe { try_call!(raw::git_config_find_xdg(buf.raw())); } ++ Ok(util::bytes2path(&buf).to_path_buf()) ++ } ++ ++ /// Add an on-disk config file instance to an existing config ++ /// ++ /// The on-disk file pointed at by path will be opened and parsed; it's ++ /// expected to be a native Git config file following the default Git config ++ /// syntax (see man git-config). ++ /// ++ /// Further queries on this config object will access each of the config ++ /// file instances in order (instances with a higher priority level will be ++ /// accessed first). ++ pub fn add_file(&mut self, path: &Path, level: ConfigLevel, ++ force: bool) -> Result<(), Error> { ++ let path = try!(path.into_c_string()); ++ unsafe { ++ try_call!(raw::git_config_add_file_ondisk(self.raw, path, level, ++ force)); ++ Ok(()) ++ } ++ } ++ ++ /// Delete a config variable from the config file with the highest level ++ /// (usually the local one). ++ pub fn remove(&mut self, name: &str) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_delete_entry(self.raw, name)); ++ Ok(()) ++ } ++ } ++ ++ /// Get the value of a boolean config variable. ++ /// ++ /// All config files will be looked into, in the order of their defined ++ /// level. A higher level means a higher priority. The first occurrence of ++ /// the variable will be returned here. ++ pub fn get_bool(&self, name: &str) -> Result { ++ let mut out = 0 as libc::c_int; ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_get_bool(&mut out, &*self.raw, name)); ++ ++ } ++ Ok(!(out == 0)) ++ } ++ ++ /// Get the value of an integer config variable. ++ /// ++ /// All config files will be looked into, in the order of their defined ++ /// level. A higher level means a higher priority. The first occurrence of ++ /// the variable will be returned here. ++ pub fn get_i32(&self, name: &str) -> Result { ++ let mut out = 0i32; ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_get_int32(&mut out, &*self.raw, name)); ++ ++ } ++ Ok(out) ++ } ++ ++ /// Get the value of an integer config variable. ++ /// ++ /// All config files will be looked into, in the order of their defined ++ /// level. A higher level means a higher priority. The first occurrence of ++ /// the variable will be returned here. ++ pub fn get_i64(&self, name: &str) -> Result { ++ let mut out = 0i64; ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_get_int64(&mut out, &*self.raw, name)); ++ } ++ Ok(out) ++ } ++ ++ /// Get the value of a string config variable. ++ /// ++ /// This is the same as `get_bytes` except that it may return `Err` if ++ /// the bytes are not valid utf-8. ++ pub fn get_str(&self, name: &str) -> Result<&str, Error> { ++ str::from_utf8(try!(self.get_bytes(name))).map_err(|_| { ++ Error::from_str("configuration value is not valid utf8") ++ }) ++ } ++ ++ /// Get the value of a string config variable as a byte slice. ++ /// ++ /// This method will return an error if this `Config` is not a snapshot. ++ pub fn get_bytes(&self, name: &str) -> Result<&[u8], Error> { ++ let mut ret = ptr::null(); ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_get_string(&mut ret, &*self.raw, name)); ++ Ok(::opt_bytes(self, ret).unwrap()) ++ } ++ } ++ ++ /// Get the value of a string config variable as an owned string. ++ /// ++ /// An error will be returned if the config value is not valid utf-8. ++ pub fn get_string(&self, name: &str) -> Result { ++ let ret = Buf::new(); ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_get_string_buf(ret.raw(), self.raw, name)); ++ } ++ str::from_utf8(&ret).map(|s| s.to_string()).map_err(|_| { ++ Error::from_str("configuration value is not valid utf8") ++ }) ++ } ++ ++ /// Get the value of a path config variable as an owned . ++ pub fn get_path(&self, name: &str) -> Result { ++ let ret = Buf::new(); ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_get_path(ret.raw(), self.raw, name)); ++ } ++ Ok(::util::bytes2path(&ret).to_path_buf()) ++ } ++ ++ /// Get the ConfigEntry for a config variable. ++ pub fn get_entry(&self, name: &str) -> Result { ++ let mut ret = ptr::null_mut(); ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_get_entry(&mut ret, self.raw, name)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Iterate over all the config variables ++ /// ++ /// If `glob` is `Some`, then the iterator will only iterate over all ++ /// variables whose name matches the pattern. ++ /// ++ /// # Example ++ /// ++ /// ``` ++ /// # #![allow(unstable)] ++ /// use git2::Config; ++ /// ++ /// let cfg = Config::new().unwrap(); ++ /// ++ /// for entry in &cfg.entries(None).unwrap() { ++ /// let entry = entry.unwrap(); ++ /// println!("{} => {}", entry.name().unwrap(), entry.value().unwrap()); ++ /// } ++ /// ``` ++ pub fn entries(&self, glob: Option<&str>) -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ match glob { ++ Some(s) => { ++ let s = try!(CString::new(s)); ++ try_call!(raw::git_config_iterator_glob_new(&mut ret, ++ &*self.raw, ++ s)); ++ } ++ None => { ++ try_call!(raw::git_config_iterator_new(&mut ret, &*self.raw)); ++ } ++ } ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Open the global/XDG configuration file according to git's rules ++ /// ++ /// Git allows you to store your global configuration at `$HOME/.config` or ++ /// `$XDG_CONFIG_HOME/git/config`. For backwards compatability, the XDG file ++ /// shouldn't be used unless the use has created it explicitly. With this ++ /// function you'll open the correct one to write to. ++ pub fn open_global(&mut self) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_config_open_global(&mut raw, self.raw)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Build a single-level focused config object from a multi-level one. ++ /// ++ /// The returned config object can be used to perform get/set/delete ++ /// operations on a single specific level. ++ pub fn open_level(&self, level: ConfigLevel) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_config_open_level(&mut raw, &*self.raw, level)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Set the value of a boolean config variable in the config file with the ++ /// highest level (usually the local one). ++ pub fn set_bool(&mut self, name: &str, value: bool) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_set_bool(self.raw, name, value)); ++ } ++ Ok(()) ++ } ++ ++ /// Set the value of an integer config variable in the config file with the ++ /// highest level (usually the local one). ++ pub fn set_i32(&mut self, name: &str, value: i32) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_set_int32(self.raw, name, value)); ++ } ++ Ok(()) ++ } ++ ++ /// Set the value of an integer config variable in the config file with the ++ /// highest level (usually the local one). ++ pub fn set_i64(&mut self, name: &str, value: i64) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_config_set_int64(self.raw, name, value)); ++ } ++ Ok(()) ++ } ++ ++ /// Set the value of an multivar config variable in the config file with the ++ /// highest level (usually the local one). ++ pub fn set_multivar(&mut self, name: &str, regexp: &str, value: &str) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ let regexp = try!(CString::new(regexp)); ++ let value = try!(CString::new(value)); ++ unsafe { ++ try_call!(raw::git_config_set_multivar(self.raw, name, regexp, value)); ++ } ++ Ok(()) ++ } ++ ++ /// Set the value of a string config variable in the config file with the ++ /// highest level (usually the local one). ++ pub fn set_str(&mut self, name: &str, value: &str) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ let value = try!(CString::new(value)); ++ unsafe { ++ try_call!(raw::git_config_set_string(self.raw, name, value)); ++ } ++ Ok(()) ++ } ++ ++ /// Create a snapshot of the configuration ++ /// ++ /// Create a snapshot of the current state of a configuration, which allows ++ /// you to look into a consistent view of the configuration for looking up ++ /// complex values (e.g. a remote, submodule). ++ pub fn snapshot(&mut self) -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_config_snapshot(&mut ret, self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Parse a string as a bool. ++ /// Interprets "true", "yes", "on", 1, or any non-zero number as true. ++ /// Interprets "false", "no", "off", 0, or an empty string as false. ++ pub fn parse_bool(s: S) -> Result { ++ let s = try!(s.into_c_string()); ++ let mut out = 0; ++ ::init(); ++ unsafe { ++ try_call!(raw::git_config_parse_bool(&mut out, s)); ++ } ++ Ok(out != 0) ++ } ++ ++ /// Parse a string as an i32; handles suffixes like k, M, or G, and ++ /// multiplies by the appropriate power of 1024. ++ pub fn parse_i32(s: S) -> Result { ++ let s = try!(s.into_c_string()); ++ let mut out = 0; ++ ::init(); ++ unsafe { ++ try_call!(raw::git_config_parse_int32(&mut out, s)); ++ } ++ Ok(out) ++ } ++ ++ /// Parse a string as an i64; handles suffixes like k, M, or G, and ++ /// multiplies by the appropriate power of 1024. ++ pub fn parse_i64(s: S) -> Result { ++ let s = try!(s.into_c_string()); ++ let mut out = 0; ++ ::init(); ++ unsafe { ++ try_call!(raw::git_config_parse_int64(&mut out, s)); ++ } ++ Ok(out) ++ } ++} ++ ++impl Binding for Config { ++ type Raw = *mut raw::git_config; ++ unsafe fn from_raw(raw: *mut raw::git_config) -> Config { ++ Config { raw: raw } ++ } ++ fn raw(&self) -> *mut raw::git_config { self.raw } ++} ++ ++impl Drop for Config { ++ fn drop(&mut self) { ++ unsafe { raw::git_config_free(self.raw) } ++ } ++} ++ ++impl<'cfg> ConfigEntry<'cfg> { ++ /// Gets the name of this entry. ++ /// ++ /// May return `None` if the name is not valid utf-8 ++ pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } ++ ++ /// Gets the name of this entry as a byte slice. ++ pub fn name_bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, (*self.raw).name).unwrap() } ++ } ++ ++ /// Gets the value of this entry. ++ /// ++ /// May return `None` if the value is not valid utf-8 ++ pub fn value(&self) -> Option<&str> { str::from_utf8(self.value_bytes()).ok() } ++ ++ /// Gets the value of this entry as a byte slice. ++ pub fn value_bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, (*self.raw).value).unwrap() } ++ } ++ ++ /// Gets the configuration level of this entry. ++ pub fn level(&self) -> ConfigLevel { ++ unsafe { ConfigLevel::from_raw((*self.raw).level) } ++ } ++} ++ ++impl<'cfg> Binding for ConfigEntry<'cfg> { ++ type Raw = *mut raw::git_config_entry; ++ ++ unsafe fn from_raw(raw: *mut raw::git_config_entry) ++ -> ConfigEntry<'cfg> { ++ ConfigEntry { ++ raw: raw, ++ _marker: marker::PhantomData, ++ owned: true, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_config_entry { self.raw } ++} ++ ++impl<'cfg> Binding for ConfigEntries<'cfg> { ++ type Raw = *mut raw::git_config_iterator; ++ ++ unsafe fn from_raw(raw: *mut raw::git_config_iterator) ++ -> ConfigEntries<'cfg> { ++ ConfigEntries { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_config_iterator { self.raw } ++} ++ ++// entries are only valid until the iterator is freed, so this impl is for ++// `&'b T` instead of `T` to have a lifetime to tie them to. ++// ++// It's also not implemented for `&'b mut T` so we can have multiple entries ++// (ok). ++impl<'cfg, 'b> Iterator for &'b ConfigEntries<'cfg> { ++ type Item = Result, Error>; ++ fn next(&mut self) -> Option, Error>> { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call_iter!(raw::git_config_next(&mut raw, self.raw)); ++ Some(Ok(ConfigEntry { ++ owned: false, ++ raw: raw, ++ _marker: marker::PhantomData, ++ })) ++ } ++ } ++} ++ ++impl<'cfg> Drop for ConfigEntries<'cfg> { ++ fn drop(&mut self) { ++ unsafe { raw::git_config_iterator_free(self.raw) } ++ } ++} ++ ++impl<'cfg> Drop for ConfigEntry<'cfg> { ++ fn drop(&mut self) { ++ if self.owned { ++ unsafe { raw::git_config_entry_free(self.raw) } ++ } ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::fs::File; ++ use tempdir::TempDir; ++ ++ use Config; ++ ++ #[test] ++ fn smoke() { ++ let _cfg = Config::new().unwrap(); ++ let _ = Config::find_global(); ++ let _ = Config::find_system(); ++ let _ = Config::find_xdg(); ++ } ++ ++ #[test] ++ fn persisted() { ++ let td = TempDir::new("test").unwrap(); ++ let path = td.path().join("foo"); ++ File::create(&path).unwrap(); ++ ++ let mut cfg = Config::open(&path).unwrap(); ++ assert!(cfg.get_bool("foo.bar").is_err()); ++ cfg.set_bool("foo.k1", true).unwrap(); ++ cfg.set_i32("foo.k2", 1).unwrap(); ++ cfg.set_i64("foo.k3", 2).unwrap(); ++ cfg.set_str("foo.k4", "bar").unwrap(); ++ cfg.snapshot().unwrap(); ++ drop(cfg); ++ ++ let cfg = Config::open(&path).unwrap().snapshot().unwrap(); ++ assert_eq!(cfg.get_bool("foo.k1").unwrap(), true); ++ assert_eq!(cfg.get_i32("foo.k2").unwrap(), 1); ++ assert_eq!(cfg.get_i64("foo.k3").unwrap(), 2); ++ assert_eq!(cfg.get_str("foo.k4").unwrap(), "bar"); ++ ++ for entry in &cfg.entries(None).unwrap() { ++ let entry = entry.unwrap(); ++ entry.name(); ++ entry.value(); ++ entry.level(); ++ } ++ } ++ ++ #[test] ++ fn multivar() { ++ let td = TempDir::new("test").unwrap(); ++ let path = td.path().join("foo"); ++ File::create(&path).unwrap(); ++ ++ let mut cfg = Config::open(&path).unwrap(); ++ cfg.set_multivar("foo.bar", "^$", "baz").unwrap(); ++ cfg.set_multivar("foo.bar", "^$", "qux").unwrap(); ++ ++ let mut values: Vec = cfg.entries(None) ++ .unwrap() ++ .into_iter() ++ .map(|entry| entry.unwrap().value().unwrap().into()) ++ .collect(); ++ values.sort(); ++ assert_eq!(values, ["baz", "qux"]); ++ } ++ ++ #[test] ++ fn parse() { ++ assert_eq!(Config::parse_bool("").unwrap(), false); ++ assert_eq!(Config::parse_bool("false").unwrap(), false); ++ assert_eq!(Config::parse_bool("no").unwrap(), false); ++ assert_eq!(Config::parse_bool("off").unwrap(), false); ++ assert_eq!(Config::parse_bool("0").unwrap(), false); ++ ++ assert_eq!(Config::parse_bool("true").unwrap(), true); ++ assert_eq!(Config::parse_bool("yes").unwrap(), true); ++ assert_eq!(Config::parse_bool("on").unwrap(), true); ++ assert_eq!(Config::parse_bool("1").unwrap(), true); ++ assert_eq!(Config::parse_bool("42").unwrap(), true); ++ ++ assert!(Config::parse_bool(" ").is_err()); ++ assert!(Config::parse_bool("some-string").is_err()); ++ assert!(Config::parse_bool("-").is_err()); ++ ++ assert_eq!(Config::parse_i32("0").unwrap(), 0); ++ assert_eq!(Config::parse_i32("1").unwrap(), 1); ++ assert_eq!(Config::parse_i32("100").unwrap(), 100); ++ assert_eq!(Config::parse_i32("-1").unwrap(), -1); ++ assert_eq!(Config::parse_i32("-100").unwrap(), -100); ++ assert_eq!(Config::parse_i32("1k").unwrap(), 1024); ++ assert_eq!(Config::parse_i32("4k").unwrap(), 4096); ++ assert_eq!(Config::parse_i32("1M").unwrap(), 1048576); ++ assert_eq!(Config::parse_i32("1G").unwrap(), 1024*1024*1024); ++ ++ assert_eq!(Config::parse_i64("0").unwrap(), 0); ++ assert_eq!(Config::parse_i64("1").unwrap(), 1); ++ assert_eq!(Config::parse_i64("100").unwrap(), 100); ++ assert_eq!(Config::parse_i64("-1").unwrap(), -1); ++ assert_eq!(Config::parse_i64("-100").unwrap(), -100); ++ assert_eq!(Config::parse_i64("1k").unwrap(), 1024); ++ assert_eq!(Config::parse_i64("4k").unwrap(), 4096); ++ assert_eq!(Config::parse_i64("1M").unwrap(), 1048576); ++ assert_eq!(Config::parse_i64("1G").unwrap(), 1024*1024*1024); ++ assert_eq!(Config::parse_i64("100G").unwrap(), 100*1024*1024*1024); ++ } ++} diff --cc vendor/git2-0.6.8/src/cred.rs index 000000000,000000000..61591daae new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/cred.rs @@@ -1,0 -1,0 +1,465 @@@ ++use std::ffi::CString; ++use std::io::Write; ++use std::mem; ++use std::path::Path; ++use std::process::{Command, Stdio}; ++use std::ptr; ++use url; ++ ++use {raw, Error, Config, IntoCString}; ++use util::Binding; ++ ++/// A structure to represent git credentials in libgit2. ++pub struct Cred { ++ raw: *mut raw::git_cred, ++} ++ ++/// Management of the gitcredentials(7) interface. ++pub struct CredentialHelper { ++ /// A public field representing the currently discovered username from ++ /// configuration. ++ pub username: Option, ++ protocol: Option, ++ host: Option, ++ url: String, ++ commands: Vec, ++} ++ ++impl Cred { ++ /// Create a "default" credential usable for Negotiate mechanisms like NTLM ++ /// or Kerberos authentication. ++ pub fn default() -> Result { ++ ::init(); ++ let mut out = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_cred_default_new(&mut out)); ++ Ok(Binding::from_raw(out)) ++ } ++ } ++ ++ /// Create a new ssh key credential object used for querying an ssh-agent. ++ /// ++ /// The username specified is the username to authenticate. ++ pub fn ssh_key_from_agent(username: &str) -> Result { ++ ::init(); ++ let mut out = ptr::null_mut(); ++ let username = try!(CString::new(username)); ++ unsafe { ++ try_call!(raw::git_cred_ssh_key_from_agent(&mut out, username)); ++ Ok(Binding::from_raw(out)) ++ } ++ } ++ ++ /// Create a new passphrase-protected ssh key credential object. ++ pub fn ssh_key(username: &str, ++ publickey: Option<&Path>, ++ privatekey: &Path, ++ passphrase: Option<&str>) -> Result { ++ ::init(); ++ let username = try!(CString::new(username)); ++ let publickey = try!(::opt_cstr(publickey)); ++ let privatekey = try!(privatekey.into_c_string()); ++ let passphrase = try!(::opt_cstr(passphrase)); ++ let mut out = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_cred_ssh_key_new(&mut out, username, publickey, ++ privatekey, passphrase)); ++ Ok(Binding::from_raw(out)) ++ } ++ } ++ ++ /// Create a new plain-text username and password credential object. ++ pub fn userpass_plaintext(username: &str, ++ password: &str) -> Result { ++ ::init(); ++ let username = try!(CString::new(username)); ++ let password = try!(CString::new(password)); ++ let mut out = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_cred_userpass_plaintext_new(&mut out, username, ++ password)); ++ Ok(Binding::from_raw(out)) ++ } ++ } ++ ++ /// Attempt to read `credential.helper` according to gitcredentials(7) [1] ++ /// ++ /// This function will attempt to parse the user's `credential.helper` ++ /// configuration, invoke the necessary processes, and read off what the ++ /// username/password should be for a particular url. ++ /// ++ /// The returned credential type will be a username/password credential if ++ /// successful. ++ /// ++ /// [1]: https://www.kernel.org/pub/software/scm/git/docs/gitcredentials.html ++ pub fn credential_helper(config: &Config, ++ url: &str, ++ username: Option<&str>) ++ -> Result { ++ match CredentialHelper::new(url).config(config).username(username) ++ .execute() { ++ Some((username, password)) => { ++ Cred::userpass_plaintext(&username, &password) ++ } ++ None => Err(Error::from_str("failed to acquire username/password \ ++ from local configuration")) ++ } ++ } ++ ++ /// Create a credential to specify a username. ++ /// ++ /// THis is used with ssh authentication to query for the username if non is ++ /// specified in the url. ++ pub fn username(username: &str) -> Result { ++ ::init(); ++ let username = try!(CString::new(username)); ++ let mut out = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_cred_username_new(&mut out, username)); ++ Ok(Binding::from_raw(out)) ++ } ++ } ++ ++ /// Check whether a credential object contains username information. ++ pub fn has_username(&self) -> bool { ++ unsafe { raw::git_cred_has_username(self.raw) == 1 } ++ } ++ ++ /// Return the type of credentials that this object represents. ++ pub fn credtype(&self) -> raw::git_credtype_t { ++ unsafe { (*self.raw).credtype } ++ } ++ ++ /// Unwrap access to the underlying raw pointer, canceling the destructor ++ pub unsafe fn unwrap(mut self) -> *mut raw::git_cred { ++ mem::replace(&mut self.raw, ptr::null_mut()) ++ } ++} ++ ++impl Binding for Cred { ++ type Raw = *mut raw::git_cred; ++ ++ unsafe fn from_raw(raw: *mut raw::git_cred) -> Cred { ++ Cred { raw: raw } ++ } ++ fn raw(&self) -> *mut raw::git_cred { self.raw } ++} ++ ++impl Drop for Cred { ++ fn drop(&mut self) { ++ if !self.raw.is_null() { ++ unsafe { ((*self.raw).free)(self.raw) } ++ } ++ } ++} ++ ++impl CredentialHelper { ++ /// Create a new credential helper object which will be used to probe git's ++ /// local credential configuration. ++ /// ++ /// The url specified is the namespace on which this will query credentials. ++ /// Invalid urls are currently ignored. ++ pub fn new(url: &str) -> CredentialHelper { ++ let mut ret = CredentialHelper { ++ protocol: None, ++ host: None, ++ username: None, ++ url: url.to_string(), ++ commands: Vec::new(), ++ }; ++ ++ // Parse out the (protocol, host) if one is available ++ if let Ok(url) = url::Url::parse(url) { ++ if let Some(url::Host::Domain(s)) = url.host() { ++ ret.host = Some(s.to_string()); ++ } ++ ret.protocol = Some(url.scheme().to_string()) ++ } ++ ret ++ } ++ ++ /// Set the username that this credential helper will query with. ++ /// ++ /// By default the username is `None`. ++ pub fn username(&mut self, username: Option<&str>) -> &mut CredentialHelper { ++ self.username = username.map(|s| s.to_string()); ++ self ++ } ++ ++ /// Query the specified configuration object to discover commands to ++ /// execute, usernames to query, etc. ++ pub fn config(&mut self, config: &Config) -> &mut CredentialHelper { ++ // Figure out the configured username/helper program. ++ // ++ // see http://git-scm.com/docs/gitcredentials.html#_configuration_options ++ // ++ // TODO: implement useHttpPath ++ if self.username.is_none() { ++ self.config_username(config); ++ } ++ self.config_helper(config); ++ self ++ } ++ ++ // Configure the queried username from `config` ++ fn config_username(&mut self, config: &Config) { ++ let key = self.exact_key("username"); ++ self.username = config.get_string(&key).ok().or_else(|| { ++ self.url_key("username").and_then(|s| { ++ config.get_string(&s).ok() ++ }) ++ }).or_else(|| { ++ config.get_string("credential.username").ok() ++ }) ++ } ++ ++ // Discover all `helper` directives from `config` ++ fn config_helper(&mut self, config: &Config) { ++ let exact = config.get_string(&self.exact_key("helper")); ++ self.add_command(exact.as_ref().ok().map(|s| &s[..])); ++ if let Some(key) = self.url_key("helper") { ++ let url = config.get_string(&key); ++ self.add_command(url.as_ref().ok().map(|s| &s[..])); ++ } ++ let global = config.get_string("credential.helper"); ++ self.add_command(global.as_ref().ok().map(|s| &s[..])); ++ } ++ ++ // Add a `helper` configured command to the list of commands to execute. ++ // ++ // see https://www.kernel.org/pub/software/scm/git/docs/technical ++ // /api-credentials.html#_credential_helpers ++ fn add_command(&mut self, cmd: Option<&str>) { ++ let cmd = match cmd { ++ Some("") | None => return, ++ Some(s) => s, ++ }; ++ ++ if cmd.starts_with('!') { ++ self.commands.push(cmd[1..].to_string()); ++ } else if cmd.starts_with('/') || cmd.starts_with('\\') || ++ cmd[1..].starts_with(":\\") { ++ self.commands.push(format!("\"{}\"", cmd)); ++ } else { ++ self.commands.push(format!("git credential-{}", cmd)); ++ } ++ } ++ ++ fn exact_key(&self, name: &str) -> String { ++ format!("credential.{}.{}", self.url, name) ++ } ++ ++ fn url_key(&self, name: &str) -> Option { ++ match (&self.host, &self.protocol) { ++ (&Some(ref host), &Some(ref protocol)) => { ++ Some(format!("credential.{}://{}.{}", protocol, host, name)) ++ } ++ _ => None ++ } ++ } ++ ++ /// Execute this helper, attempting to discover a username/password pair. ++ /// ++ /// All I/O errors are ignored, (to match git behavior), and this function ++ /// only succeeds if both a username and a password were found ++ pub fn execute(&self) -> Option<(String, String)> { ++ let mut username = self.username.clone(); ++ let mut password = None; ++ for cmd in &self.commands { ++ let (u, p) = self.execute_cmd(cmd, &username); ++ if u.is_some() && username.is_none() { ++ username = u; ++ } ++ if p.is_some() && password.is_none() { ++ password = p; ++ } ++ if username.is_some() && password.is_some() { break } ++ } ++ ++ match (username, password) { ++ (Some(u), Some(p)) => Some((u, p)), ++ _ => None, ++ } ++ } ++ ++ // Execute the given `cmd`, providing the appropriate variables on stdin and ++ // then afterwards parsing the output into the username/password on stdout. ++ fn execute_cmd(&self, cmd: &str, username: &Option) ++ -> (Option, Option) { ++ macro_rules! my_try( ($e:expr) => ( ++ match $e { Ok(e) => e, Err(..) => return (None, None) } ++ ) ); ++ ++ let mut p = my_try!(Command::new("sh").arg("-c") ++ .arg(&format!("{} get", cmd)) ++ .stdin(Stdio::piped()) ++ .stdout(Stdio::piped()) ++ .stderr(Stdio::piped()) ++ .spawn()); ++ // Ignore write errors as the command may not actually be listening for ++ // stdin ++ { ++ let stdin = p.stdin.as_mut().unwrap(); ++ if let Some(ref p) = self.protocol { ++ let _ = writeln!(stdin, "protocol={}", p); ++ } ++ if let Some(ref p) = self.host { ++ let _ = writeln!(stdin, "host={}", p); ++ } ++ if let Some(ref p) = *username { ++ let _ = writeln!(stdin, "username={}", p); ++ } ++ } ++ let output = my_try!(p.wait_with_output()); ++ if !output.status.success() { return (None, None) } ++ self.parse_output(output.stdout) ++ } ++ ++ // Parse the output of a command into the username/password found ++ fn parse_output(&self, output: Vec) -> (Option, Option) { ++ // Parse the output of the command, looking for username/password ++ let mut username = None; ++ let mut password = None; ++ for line in output.split(|t| *t == b'\n') { ++ let mut parts = line.splitn(2, |t| *t == b'='); ++ let key = parts.next().unwrap(); ++ let value = match parts.next() { Some(s) => s, None => continue }; ++ let value = match String::from_utf8(value.to_vec()) { ++ Ok(s) => s, ++ Err(..) => continue, ++ }; ++ match key { ++ b"username" => username = Some(value), ++ b"password" => password = Some(value), ++ _ => {} ++ } ++ } ++ (username, password) ++ } ++} ++ ++#[cfg(all(test, feature = "unstable"))] ++mod test { ++ use std::env; ++ use std::fs::File; ++ use std::io::prelude::*; ++ use std::path::Path; ++ use tempdir::TempDir; ++ ++ use {Cred, Config, CredentialHelper, ConfigLevel}; ++ ++ macro_rules! cfg( ($($k:expr => $v:expr),*) => ({ ++ let td = TempDir::new("git2-rs").unwrap(); ++ let mut cfg = Config::new().unwrap(); ++ cfg.add_file(&td.path().join("cfg"), ConfigLevel::Highest, false).unwrap(); ++ $(cfg.set_str($k, $v).unwrap();)* ++ cfg ++ }) ); ++ ++ #[test] ++ fn smoke() { ++ Cred::default().unwrap(); ++ } ++ ++ #[test] ++ fn credential_helper1() { ++ let cfg = cfg! { ++ "credential.helper" => "!f() { echo username=a; echo password=b; }; f" ++ }; ++ let (u, p) = CredentialHelper::new("https://example.com/foo/bar") ++ .config(&cfg) ++ .execute().unwrap(); ++ assert_eq!(u, "a"); ++ assert_eq!(p, "b"); ++ } ++ ++ #[test] ++ fn credential_helper2() { ++ let cfg = cfg! {}; ++ assert!(CredentialHelper::new("https://example.com/foo/bar") ++ .config(&cfg) ++ .execute().is_none()); ++ } ++ ++ #[test] ++ fn credential_helper3() { ++ let cfg = cfg! { ++ "credential.https://example.com.helper" => ++ "!f() { echo username=c; }; f", ++ "credential.helper" => "!f() { echo username=a; echo password=b; }; f" ++ }; ++ let (u, p) = CredentialHelper::new("https://example.com/foo/bar") ++ .config(&cfg) ++ .execute().unwrap(); ++ assert_eq!(u, "c"); ++ assert_eq!(p, "b"); ++ } ++ ++ #[test] ++ fn credential_helper4() { ++ let td = TempDir::new("git2-rs").unwrap(); ++ let path = td.path().join("script"); ++ File::create(&path).unwrap().write(br"\ ++#!/bin/sh ++echo username=c ++").unwrap(); ++ chmod(&path); ++ let cfg = cfg! { ++ "credential.https://example.com.helper" => ++ &path.display().to_string()[..], ++ "credential.helper" => "!f() { echo username=a; echo password=b; }; f" ++ }; ++ let (u, p) = CredentialHelper::new("https://example.com/foo/bar") ++ .config(&cfg) ++ .execute().unwrap(); ++ assert_eq!(u, "c"); ++ assert_eq!(p, "b"); ++ } ++ ++ #[test] ++ fn credential_helper5() { ++ let td = TempDir::new("git2-rs").unwrap(); ++ let path = td.path().join("git-credential-script"); ++ File::create(&path).unwrap().write(br"\ ++#!/bin/sh ++echo username=c ++").unwrap(); ++ chmod(&path); ++ ++ let paths = env::var("PATH").unwrap(); ++ let paths = env::split_paths(&paths) ++ .chain(path.parent().map(|p| p.to_path_buf()).into_iter()); ++ env::set_var("PATH", &env::join_paths(paths).unwrap()); ++ ++ let cfg = cfg! { ++ "credential.https://example.com.helper" => "script", ++ "credential.helper" => "!f() { echo username=a; echo password=b; }; f" ++ }; ++ let (u, p) = CredentialHelper::new("https://example.com/foo/bar") ++ .config(&cfg) ++ .execute().unwrap(); ++ assert_eq!(u, "c"); ++ assert_eq!(p, "b"); ++ } ++ ++ #[test] ++ fn credential_helper6() { ++ let cfg = cfg! { ++ "credential.helper" => "" ++ }; ++ assert!(CredentialHelper::new("https://example.com/foo/bar") ++ .config(&cfg) ++ .execute().is_none()); ++ } ++ ++ #[cfg(unix)] ++ fn chmod(path: &Path) { ++ use std::os::unix::prelude::*; ++ use std::fs; ++ let mut perms = fs::metadata(path).unwrap().permissions(); ++ perms.set_mode(0o755); ++ fs::set_permissions(path, perms).unwrap(); ++ } ++ #[cfg(windows)] ++ fn chmod(_path: &Path) {} ++} diff --cc vendor/git2-0.6.8/src/describe.rs index 000000000,000000000..c06208871 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/describe.rs @@@ -1,0 -1,0 +1,199 @@@ ++use std::marker; ++use std::mem; ++use std::ffi::CString; ++use std::ptr; ++ ++use libc::{c_uint, c_int}; ++ ++use {raw, Repository, Error, Buf}; ++use util::Binding; ++ ++/// The result of a `describe` operation on either an `Describe` or a ++/// `Repository`. ++pub struct Describe<'repo> { ++ raw: *mut raw::git_describe_result, ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++/// Options which indicate how a `Describe` is created. ++pub struct DescribeOptions { ++ raw: raw::git_describe_options, ++ pattern: CString, ++} ++ ++/// Options which can be used to customize how a description is formatted. ++pub struct DescribeFormatOptions { ++ raw: raw::git_describe_format_options, ++ dirty_suffix: CString, ++} ++ ++impl<'repo> Describe<'repo> { ++ /// Prints this describe result, returning the result as a string. ++ pub fn format(&self, opts: Option<&DescribeFormatOptions>) ++ -> Result { ++ let buf = Buf::new(); ++ let opts = opts.map(|o| &o.raw as *const _).unwrap_or(ptr::null()); ++ unsafe { ++ try_call!(raw::git_describe_format(buf.raw(), self.raw, opts)); ++ } ++ Ok(String::from_utf8(buf.to_vec()).unwrap()) ++ } ++} ++ ++impl<'repo> Binding for Describe<'repo> { ++ type Raw = *mut raw::git_describe_result; ++ ++ unsafe fn from_raw(raw: *mut raw::git_describe_result) -> Describe<'repo> { ++ Describe { raw: raw, _marker: marker::PhantomData, } ++ } ++ fn raw(&self) -> *mut raw::git_describe_result { self.raw } ++} ++ ++impl<'repo> Drop for Describe<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_describe_result_free(self.raw) } ++ } ++} ++ ++impl Default for DescribeFormatOptions { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl DescribeFormatOptions { ++ /// Creates a new blank set of formatting options for a description. ++ pub fn new() -> DescribeFormatOptions { ++ let mut opts = DescribeFormatOptions { ++ raw: unsafe { mem::zeroed() }, ++ dirty_suffix: CString::new(Vec::new()).unwrap(), ++ }; ++ opts.raw.version = 1; ++ opts.raw.abbreviated_size = 7; ++ opts ++ } ++ ++ /// Sets the size of the abbreviated commit id to use. ++ /// ++ /// The value is the lower bound for the length of the abbreviated string, ++ /// and the default is 7. ++ pub fn abbreviated_size(&mut self, size: u32) -> &mut Self { ++ self.raw.abbreviated_size = size as c_uint; ++ self ++ } ++ ++ /// Sets whether or not the long format is used even when a shorter name ++ /// could be used. ++ pub fn always_use_long_format(&mut self, long: bool) -> &mut Self { ++ self.raw.always_use_long_format = long as c_int; ++ self ++ } ++ ++ /// If the workdir is dirty and this is set, this string will be appended to ++ /// the description string. ++ pub fn dirty_suffix(&mut self, suffix: &str) -> &mut Self { ++ self.dirty_suffix = CString::new(suffix).unwrap(); ++ self.raw.dirty_suffix = self.dirty_suffix.as_ptr(); ++ self ++ } ++} ++ ++impl Default for DescribeOptions { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl DescribeOptions { ++ /// Creates a new blank set of formatting options for a description. ++ pub fn new() -> DescribeOptions { ++ let mut opts = DescribeOptions { ++ raw: unsafe { mem::zeroed() }, ++ pattern: CString::new(Vec::new()).unwrap(), ++ }; ++ opts.raw.version = 1; ++ opts.raw.max_candidates_tags = 10; ++ opts ++ } ++ ++ #[allow(missing_docs)] ++ pub fn max_candidates_tags(&mut self, max: u32) -> &mut Self { ++ self.raw.max_candidates_tags = max as c_uint; ++ self ++ } ++ ++ /// Sets the reference lookup strategy ++ /// ++ /// This behaves like the `--tags` option to git-decribe. ++ pub fn describe_tags(&mut self) -> &mut Self { ++ self.raw.describe_strategy = raw::GIT_DESCRIBE_TAGS as c_uint; ++ self ++ } ++ ++ /// Sets the reference lookup strategy ++ /// ++ /// This behaves like the `--all` option to git-decribe. ++ pub fn describe_all(&mut self) -> &mut Self { ++ self.raw.describe_strategy = raw::GIT_DESCRIBE_ALL as c_uint; ++ self ++ } ++ ++ /// Indicates when calculating the distance from the matching tag or ++ /// reference whether to only walk down the first-parent ancestry. ++ pub fn only_follow_first_parent(&mut self, follow: bool) -> &mut Self { ++ self.raw.only_follow_first_parent = follow as c_int; ++ self ++ } ++ ++ /// If no matching tag or reference is found whether a describe option would ++ /// normally fail. This option indicates, however, that it will instead fall ++ /// back to showing the full id of the commit. ++ pub fn show_commit_oid_as_fallback(&mut self, show: bool) -> &mut Self { ++ self.raw.show_commit_oid_as_fallback = show as c_int; ++ self ++ } ++ ++ #[allow(missing_docs)] ++ pub fn pattern(&mut self, pattern: &str) -> &mut Self { ++ self.pattern = CString::new(pattern).unwrap(); ++ self.raw.pattern = self.pattern.as_ptr(); ++ self ++ } ++} ++ ++impl Binding for DescribeOptions { ++ type Raw = *mut raw::git_describe_options; ++ ++ unsafe fn from_raw(_raw: *mut raw::git_describe_options) ++ -> DescribeOptions { ++ panic!("unimplemened") ++ } ++ fn raw(&self) -> *mut raw::git_describe_options { ++ &self.raw as *const _ as *mut _ ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use DescribeOptions; ++ ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ let head = t!(repo.head()).target().unwrap(); ++ ++ let d = t!(repo.describe(DescribeOptions::new() ++ .show_commit_oid_as_fallback(true))); ++ let id = head.to_string(); ++ assert_eq!(t!(d.format(None)), &id[..7]); ++ ++ let obj = t!(repo.find_object(head, None)); ++ let sig = t!(repo.signature()); ++ t!(repo.tag("foo", &obj, &sig, "message", true)); ++ let d = t!(repo.describe(&DescribeOptions::new())); ++ assert_eq!(t!(d.format(None)), "foo"); ++ ++ let d = t!(obj.describe(&DescribeOptions::new())); ++ assert_eq!(t!(d.format(None)), "foo"); ++ } ++} diff --cc vendor/git2-0.6.8/src/diff.rs index 000000000,000000000..5f5c62d3d new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/diff.rs @@@ -1,0 -1,0 +1,1250 @@@ ++use std::ffi::CString; ++use std::marker; ++use std::mem; ++use std::ops::Range; ++use std::path::Path; ++use std::ptr; ++use std::slice; ++use libc::{c_char, size_t, c_void, c_int}; ++ ++use {raw, panic, Buf, Delta, Oid, Repository, Error, DiffFormat}; ++use {DiffStatsFormat, IntoCString}; ++use util::{self, Binding}; ++ ++/// The diff object that contains all individual file deltas. ++/// ++/// This is an opaque structure which will be allocated by one of the diff ++/// generator functions on the `Repository` structure (e.g. `diff_tree_to_tree` ++/// or other `diff_*` functions). ++pub struct Diff<'repo> { ++ raw: *mut raw::git_diff, ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++unsafe impl<'repo> Send for Diff<'repo> {} ++ ++/// Description of changes to one entry. ++pub struct DiffDelta<'a> { ++ raw: *mut raw::git_diff_delta, ++ _marker: marker::PhantomData<&'a raw::git_diff_delta>, ++} ++ ++/// Description of one side of a delta. ++/// ++/// Although this is called a "file" it could represent a file, a symbolic ++/// link, a submodule commit id, or even a tree (although that only happens if ++/// you are tracking type changes or ignored/untracked directories). ++pub struct DiffFile<'a> { ++ raw: *const raw::git_diff_file, ++ _marker: marker::PhantomData<&'a raw::git_diff_file>, ++} ++ ++/// Structure describing options about how the diff should be executed. ++pub struct DiffOptions { ++ pathspec: Vec, ++ pathspec_ptrs: Vec<*const c_char>, ++ old_prefix: Option, ++ new_prefix: Option, ++ raw: raw::git_diff_options, ++} ++ ++/// Control behavior of rename and copy detection ++pub struct DiffFindOptions { ++ raw: raw::git_diff_find_options, ++} ++ ++/// An iterator over the diffs in a delta ++pub struct Deltas<'diff> { ++ range: Range, ++ diff: &'diff Diff<'diff>, ++} ++ ++/// Structure describing a line (or data span) of a diff. ++pub struct DiffLine<'a> { ++ raw: *const raw::git_diff_line, ++ _marker: marker::PhantomData<&'a raw::git_diff_line>, ++} ++ ++/// Structure describing a hunk of a diff. ++pub struct DiffHunk<'a> { ++ raw: *const raw::git_diff_hunk, ++ _marker: marker::PhantomData<&'a raw::git_diff_hunk>, ++} ++ ++/// Structure describing a hunk of a diff. ++pub struct DiffStats { ++ raw: *mut raw::git_diff_stats, ++} ++ ++/// Structure describing the binary contents of a diff. ++pub struct DiffBinary<'a> { ++ raw: *const raw::git_diff_binary, ++ _marker: marker::PhantomData<&'a raw::git_diff_binary>, ++} ++ ++/// The contents of one of the files in a binary diff. ++pub struct DiffBinaryFile<'a> { ++ raw: *const raw::git_diff_binary_file, ++ _marker: marker::PhantomData<&'a raw::git_diff_binary_file>, ++} ++ ++/// When producing a binary diff, the binary data returned will be ++/// either the deflated full ("literal") contents of the file, or ++/// the deflated binary delta between the two sides (whichever is ++/// smaller). ++#[derive(Copy, Clone, Debug)] ++pub enum DiffBinaryKind { ++ /// There is no binary delta ++ None, ++ /// The binary data is the literal contents of the file ++ Literal, ++ /// The binary data is the delta from one side to the other ++ Delta, ++} ++ ++type PrintCb<'a> = FnMut(DiffDelta, Option, DiffLine) -> bool + 'a; ++ ++pub type FileCb<'a> = FnMut(DiffDelta, f32) -> bool + 'a; ++pub type BinaryCb<'a> = FnMut(DiffDelta, DiffBinary) -> bool + 'a; ++pub type HunkCb<'a> = FnMut(DiffDelta, DiffHunk) -> bool + 'a; ++pub type LineCb<'a> = FnMut(DiffDelta, Option, DiffLine) -> bool + 'a; ++ ++struct ForeachCallbacks<'a, 'b: 'a, 'c, 'd: 'c, 'e, 'f: 'e, 'g, 'h: 'g> { ++ file: &'a mut FileCb<'b>, ++ binary: Option<&'c mut BinaryCb<'d>>, ++ hunk: Option<&'e mut HunkCb<'f>>, ++ line: Option<&'g mut LineCb<'h>>, ++} ++ ++impl<'repo> Diff<'repo> { ++ /// Merge one diff into another. ++ /// ++ /// This merges items from the "from" list into the "self" list. The ++ /// resulting diff will have all items that appear in either list. ++ /// If an item appears in both lists, then it will be "merged" to appear ++ /// as if the old version was from the "onto" list and the new version ++ /// is from the "from" list (with the exception that if the item has a ++ /// pending DELETE in the middle, then it will show as deleted). ++ pub fn merge(&mut self, from: &Diff<'repo>) -> Result<(), Error> { ++ unsafe { try_call!(raw::git_diff_merge(self.raw, &*from.raw)); } ++ Ok(()) ++ } ++ ++ /// Returns an iterator over the deltas in this diff. ++ pub fn deltas(&self) -> Deltas { ++ let num_deltas = unsafe { raw::git_diff_num_deltas(&*self.raw) }; ++ Deltas { range: 0..(num_deltas as usize), diff: self } ++ } ++ ++ /// Return the diff delta for an entry in the diff list. ++ pub fn get_delta(&self, i: usize) -> Option { ++ unsafe { ++ let ptr = raw::git_diff_get_delta(&*self.raw, i as size_t); ++ Binding::from_raw_opt(ptr as *mut _) ++ } ++ } ++ ++ /// Check if deltas are sorted case sensitively or insensitively. ++ pub fn is_sorted_icase(&self) -> bool { ++ unsafe { raw::git_diff_is_sorted_icase(&*self.raw) == 1 } ++ } ++ ++ /// Iterate over a diff generating formatted text output. ++ /// ++ /// Returning `false` from the callback will terminate the iteration and ++ /// return an error from this function. ++ pub fn print(&self, format: DiffFormat, mut cb: F) -> Result<(), Error> ++ where F: FnMut(DiffDelta, ++ Option, ++ DiffLine) -> bool { ++ let mut cb: &mut PrintCb = &mut cb; ++ let ptr = &mut cb as *mut _; ++ unsafe { ++ try_call!(raw::git_diff_print(self.raw, format, print_cb, ++ ptr as *mut _)); ++ Ok(()) ++ } ++ } ++ ++ /// Loop over all deltas in a diff issuing callbacks. ++ /// ++ /// Returning `false` from any callback will terminate the iteration and ++ /// return an error from this function. ++ pub fn foreach(&self, ++ file_cb: &mut FileCb, ++ binary_cb: Option<&mut BinaryCb>, ++ hunk_cb: Option<&mut HunkCb>, ++ line_cb: Option<&mut LineCb>) -> Result<(), Error> { ++ let mut cbs = ForeachCallbacks { ++ file: file_cb, ++ binary: binary_cb, ++ hunk: hunk_cb, ++ line: line_cb, ++ }; ++ let ptr = &mut cbs as *mut _; ++ unsafe { ++ let binary_cb_c = if cbs.binary.is_some() { ++ Some(binary_cb_c as raw::git_diff_binary_cb) ++ } else { ++ None ++ }; ++ let hunk_cb_c = if cbs.hunk.is_some() { ++ Some(hunk_cb_c as raw::git_diff_hunk_cb) ++ } else { ++ None ++ }; ++ let line_cb_c = if cbs.line.is_some() { ++ Some(line_cb_c as raw::git_diff_line_cb) ++ } else { ++ None ++ }; ++ try_call!(raw::git_diff_foreach(self.raw, file_cb_c, binary_cb_c, ++ hunk_cb_c, line_cb_c, ++ ptr as *mut _)); ++ Ok(()) ++ } ++ } ++ ++ /// Accumulate diff statistics for all patches. ++ pub fn stats(&self) -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_diff_get_stats(&mut ret, self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Transform a diff marking file renames, copies, etc. ++ /// ++ /// This modifies a diff in place, replacing old entries that look like ++ /// renames or copies with new entries reflecting those changes. This also ++ /// will, if requested, break modified files into add/remove pairs if the ++ /// amount of change is above a threshold. ++ pub fn find_similar(&mut self, opts: Option<&mut DiffFindOptions>) ++ -> Result<(), Error> { ++ let opts = opts.map(|opts| &opts.raw); ++ unsafe { try_call!(raw::git_diff_find_similar(self.raw, opts)); } ++ Ok(()) ++ } ++ ++ // TODO: num_deltas_of_type, format_email, find_similar ++} ++ ++pub extern fn print_cb(delta: *const raw::git_diff_delta, ++ hunk: *const raw::git_diff_hunk, ++ line: *const raw::git_diff_line, ++ data: *mut c_void) -> c_int { ++ unsafe { ++ let delta = Binding::from_raw(delta as *mut _); ++ let hunk = Binding::from_raw_opt(hunk); ++ let line = Binding::from_raw(line); ++ ++ let r = panic::wrap(|| { ++ let data = data as *mut &mut PrintCb; ++ (*data)(delta, hunk, line) ++ }); ++ if r == Some(true) {0} else {-1} ++ } ++} ++ ++extern fn file_cb_c(delta: *const raw::git_diff_delta, ++ progress: f32, ++ data: *mut c_void) -> c_int { ++ unsafe { ++ let delta = Binding::from_raw(delta as *mut _); ++ ++ let r = panic::wrap(|| { ++ let cbs = data as *mut ForeachCallbacks; ++ ((*cbs).file)(delta, progress) ++ }); ++ if r == Some(true) {0} else {-1} ++ } ++} ++ ++extern fn binary_cb_c(delta: *const raw::git_diff_delta, ++ binary: *const raw::git_diff_binary, ++ data: *mut c_void) -> c_int { ++ unsafe { ++ let delta = Binding::from_raw(delta as *mut _); ++ let binary = Binding::from_raw(binary); ++ ++ let r = panic::wrap(|| { ++ let cbs = data as *mut ForeachCallbacks; ++ match (*cbs).binary { ++ Some(ref mut cb) => cb(delta, binary), ++ None => false, ++ } ++ }); ++ if r == Some(true) {0} else {-1} ++ } ++} ++ ++extern fn hunk_cb_c(delta: *const raw::git_diff_delta, ++ hunk: *const raw::git_diff_hunk, ++ data: *mut c_void) -> c_int { ++ unsafe { ++ let delta = Binding::from_raw(delta as *mut _); ++ let hunk = Binding::from_raw(hunk); ++ ++ let r = panic::wrap(|| { ++ let cbs = data as *mut ForeachCallbacks; ++ match (*cbs).hunk { ++ Some(ref mut cb) => cb(delta, hunk), ++ None => false, ++ } ++ }); ++ if r == Some(true) {0} else {-1} ++ } ++} ++ ++extern fn line_cb_c(delta: *const raw::git_diff_delta, ++ hunk: *const raw::git_diff_hunk, ++ line: *const raw::git_diff_line, ++ data: *mut c_void) -> c_int { ++ unsafe { ++ let delta = Binding::from_raw(delta as *mut _); ++ let hunk = Binding::from_raw_opt(hunk); ++ let line = Binding::from_raw(line); ++ ++ let r = panic::wrap(|| { ++ let cbs = data as *mut ForeachCallbacks; ++ match (*cbs).line { ++ Some(ref mut cb) => cb(delta, hunk, line), ++ None => false, ++ } ++ }); ++ if r == Some(true) {0} else {-1} ++ } ++} ++ ++ ++impl<'repo> Binding for Diff<'repo> { ++ type Raw = *mut raw::git_diff; ++ unsafe fn from_raw(raw: *mut raw::git_diff) -> Diff<'repo> { ++ Diff { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_diff { self.raw } ++} ++ ++impl<'repo> Drop for Diff<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_diff_free(self.raw) } ++ } ++} ++ ++impl<'a> DiffDelta<'a> { ++ // TODO: expose when diffs are more exposed ++ // pub fn similarity(&self) -> u16 { ++ // unsafe { (*self.raw).similarity } ++ // } ++ ++ /// Returns the number of files in this delta. ++ pub fn nfiles(&self) -> u16 { ++ unsafe { (*self.raw).nfiles } ++ } ++ ++ /// Returns the status of this entry ++ /// ++ /// For more information, see `Delta`'s documentation ++ pub fn status(&self) -> Delta { ++ match unsafe { (*self.raw).status } { ++ raw::GIT_DELTA_UNMODIFIED => Delta::Unmodified, ++ raw::GIT_DELTA_ADDED => Delta::Added, ++ raw::GIT_DELTA_DELETED => Delta::Deleted, ++ raw::GIT_DELTA_MODIFIED => Delta::Modified, ++ raw::GIT_DELTA_RENAMED => Delta::Renamed, ++ raw::GIT_DELTA_COPIED => Delta::Copied, ++ raw::GIT_DELTA_IGNORED => Delta::Ignored, ++ raw::GIT_DELTA_UNTRACKED => Delta::Untracked, ++ raw::GIT_DELTA_TYPECHANGE => Delta::Typechange, ++ raw::GIT_DELTA_UNREADABLE => Delta::Unreadable, ++ raw::GIT_DELTA_CONFLICTED => Delta::Conflicted, ++ n => panic!("unknown diff status: {}", n), ++ } ++ } ++ ++ /// Return the file which represents the "from" side of the diff. ++ /// ++ /// What side this means depends on the function that was used to generate ++ /// the diff and will be documented on the function itself. ++ pub fn old_file(&self) -> DiffFile<'a> { ++ unsafe { Binding::from_raw(&(*self.raw).old_file as *const _) } ++ } ++ ++ /// Return the file which represents the "to" side of the diff. ++ /// ++ /// What side this means depends on the function that was used to generate ++ /// the diff and will be documented on the function itself. ++ pub fn new_file(&self) -> DiffFile<'a> { ++ unsafe { Binding::from_raw(&(*self.raw).new_file as *const _) } ++ } ++} ++ ++impl<'a> Binding for DiffDelta<'a> { ++ type Raw = *mut raw::git_diff_delta; ++ unsafe fn from_raw(raw: *mut raw::git_diff_delta) -> DiffDelta<'a> { ++ DiffDelta { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_diff_delta { self.raw } ++} ++ ++impl<'a> DiffFile<'a> { ++ /// Returns the Oid of this item. ++ /// ++ /// If this entry represents an absent side of a diff (e.g. the `old_file` ++ /// of a `Added` delta), then the oid returned will be zeroes. ++ pub fn id(&self) -> Oid { ++ unsafe { Binding::from_raw(&(*self.raw).id as *const _) } ++ } ++ ++ /// Returns the path, in bytes, of the entry relative to the working ++ /// directory of the repository. ++ pub fn path_bytes(&self) -> Option<&'a [u8]> { ++ static FOO: () = (); ++ unsafe { ::opt_bytes(&FOO, (*self.raw).path) } ++ } ++ ++ /// Returns the path of the entry relative to the working directory of the ++ /// repository. ++ pub fn path(&self) -> Option<&'a Path> { ++ self.path_bytes().map(util::bytes2path) ++ } ++ ++ /// Returns the size of this entry, in bytes ++ pub fn size(&self) -> u64 { unsafe { (*self.raw).size as u64 } } ++ ++ // TODO: expose flags/mode ++} ++ ++impl<'a> Binding for DiffFile<'a> { ++ type Raw = *const raw::git_diff_file; ++ unsafe fn from_raw(raw: *const raw::git_diff_file) -> DiffFile<'a> { ++ DiffFile { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *const raw::git_diff_file { self.raw } ++} ++ ++impl Default for DiffOptions { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl DiffOptions { ++ /// Creates a new set of empty diff options. ++ /// ++ /// All flags and other options are defaulted to false or their otherwise ++ /// zero equivalents. ++ pub fn new() -> DiffOptions { ++ let mut opts = DiffOptions { ++ pathspec: Vec::new(), ++ pathspec_ptrs: Vec::new(), ++ raw: unsafe { mem::zeroed() }, ++ old_prefix: None, ++ new_prefix: None, ++ }; ++ assert_eq!(unsafe { ++ raw::git_diff_init_options(&mut opts.raw, 1) ++ }, 0); ++ opts ++ } ++ ++ fn flag(&mut self, opt: u32, val: bool) -> &mut DiffOptions { ++ if val { ++ self.raw.flags |= opt; ++ } else { ++ self.raw.flags &= !opt; ++ } ++ self ++ } ++ ++ /// Flag indicating whether the sides of the diff will be reversed. ++ pub fn reverse(&mut self, reverse: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_REVERSE, reverse) ++ } ++ ++ /// Flag indicating whether ignored files are included. ++ pub fn include_ignored(&mut self, include: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_INCLUDE_IGNORED, include) ++ } ++ ++ /// Flag indicating whether ignored directories are traversed deeply or not. ++ pub fn recurse_ignored_dirs(&mut self, recurse: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_RECURSE_IGNORED_DIRS, recurse) ++ } ++ ++ /// Flag indicating whether untracked files are in the diff ++ pub fn include_untracked(&mut self, include: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_INCLUDE_UNTRACKED, include) ++ } ++ ++ /// Flag indicating whether untracked directories are deeply traversed or ++ /// not. ++ pub fn recurse_untracked_dirs(&mut self, recurse: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_RECURSE_UNTRACKED_DIRS, recurse) ++ } ++ ++ /// Flag indicating whether unmodified files are in the diff. ++ pub fn include_unmodified(&mut self, include: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_INCLUDE_UNMODIFIED, include) ++ } ++ ++ /// If entrabled, then Typechange delta records are generated. ++ pub fn include_typechange(&mut self, include: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_INCLUDE_TYPECHANGE, include) ++ } ++ ++ /// Event with `include_typechange`, the tree treturned generally shows a ++ /// deleted blow. This flag correctly labels the tree transitions as a ++ /// typechange record with the `new_file`'s mode set to tree. ++ /// ++ /// Note that the tree SHA will not be available. ++ pub fn include_typechange_trees(&mut self, include: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_INCLUDE_TYPECHANGE_TREES, include) ++ } ++ ++ /// Flag indicating whether file mode changes are ignored. ++ pub fn ignore_filemode(&mut self, ignore: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_IGNORE_FILEMODE, ignore) ++ } ++ ++ /// Flag indicating whether all submodules should be treated as unmodified. ++ pub fn ignore_submodules(&mut self, ignore: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_IGNORE_SUBMODULES, ignore) ++ } ++ ++ /// Flag indicating whether case insensitive filenames should be used. ++ pub fn ignore_case(&mut self, ignore: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_IGNORE_CASE, ignore) ++ } ++ ++ /// If pathspecs are specified, this flag means that they should be applied ++ /// as an exact match instead of a fnmatch pattern. ++ pub fn disable_pathspec_match(&mut self, disable: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_DISABLE_PATHSPEC_MATCH, disable) ++ } ++ ++ /// Disable updating the `binary` flag in delta records. This is useful when ++ /// iterating over a diff if you don't need hunk and data callbacks and want ++ /// to avoid having to load a file completely. ++ pub fn skip_binary_check(&mut self, skip: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_SKIP_BINARY_CHECK, skip) ++ } ++ ++ /// When diff finds an untracked directory, to match the behavior of core ++ /// Git, it scans the contents for ignored and untracked files. If all ++ /// contents are ignored, then the directory is ignored; if any contents are ++ /// not ignored, then the directory is untracked. This is extra work that ++ /// may not matter in many cases. ++ /// ++ /// This flag turns off that scan and immediately labels an untracked ++ /// directory as untracked (changing the behavior to not match core git). ++ pub fn enable_fast_untracked_dirs(&mut self, enable: bool) ++ -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS, enable) ++ } ++ ++ /// When diff finds a file in the working directory with stat information ++ /// different from the index, but the OID ends up being the same, write the ++ /// correct stat information into the index. Note: without this flag, diff ++ /// will always leave the index untouched. ++ pub fn update_index(&mut self, update: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_UPDATE_INDEX, update) ++ } ++ ++ /// Include unreadable files in the diff ++ pub fn include_unreadable(&mut self, include: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_INCLUDE_UNREADABLE, include) ++ } ++ ++ /// Include unreadable files in the diff ++ pub fn include_unreadable_as_untracked(&mut self, include: bool) ++ -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED, include) ++ } ++ ++ /// Treat all files as text, disabling binary attributes and detection. ++ pub fn force_text(&mut self, force: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_FORCE_TEXT, force) ++ } ++ ++ /// Treat all files as binary, disabling text diffs ++ pub fn force_binary(&mut self, force: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_FORCE_TEXT, force) ++ } ++ ++ /// Ignore all whitespace ++ pub fn ignore_whitespace(&mut self, ignore: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE, ignore) ++ } ++ ++ /// Ignore changes in the amount of whitespace ++ pub fn ignore_whitespace_change(&mut self, ignore: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE_CHANGE, ignore) ++ } ++ ++ /// Ignore whitespace at tend of line ++ pub fn ignore_whitespace_eol(&mut self, ignore: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_IGNORE_WHITESPACE_EOL, ignore) ++ } ++ ++ /// When generating patch text, include the content of untracked files. ++ /// ++ /// This automatically turns on `include_untracked` but it does not turn on ++ /// `recurse_untracked_dirs`. Add that flag if you want the content of every ++ /// single untracked file. ++ pub fn show_untracked_content(&mut self, show: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_SHOW_UNTRACKED_CONTENT, show) ++ } ++ ++ /// When generating output, include the names of unmodified files if they ++ /// are included in the `Diff`. Normally these are skipped in the formats ++ /// that list files (e.g. name-only, name-status, raw). Even with this these ++ /// will not be included in the patch format. ++ pub fn show_unmodified(&mut self, show: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_SHOW_UNMODIFIED, show) ++ } ++ ++ /// Use the "patience diff" algorithm ++ pub fn patience(&mut self, patience: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_PATIENCE, patience) ++ } ++ ++ /// Take extra time to find the minimal diff ++ pub fn minimal(&mut self, minimal: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_MINIMAL, minimal) ++ } ++ ++ /// Include the necessary deflate/delta information so that `git-apply` can ++ /// apply given diff information to binary files. ++ pub fn show_binary(&mut self, show: bool) -> &mut DiffOptions { ++ self.flag(raw::GIT_DIFF_SHOW_BINARY, show) ++ } ++ ++ /// Set the number of unchanged lines that define the boundary of a hunk ++ /// (and to display before and after). ++ /// ++ /// The default value for this is 3. ++ pub fn context_lines(&mut self, lines: u32) -> &mut DiffOptions { ++ self.raw.context_lines = lines; ++ self ++ } ++ ++ /// Set the maximum number of unchanged lines between hunk boundaries before ++ /// the hunks will be merged into one. ++ /// ++ /// The default value for this is 0. ++ pub fn interhunk_lines(&mut self, lines: u32) -> &mut DiffOptions { ++ self.raw.interhunk_lines = lines; ++ self ++ } ++ ++ /// The default value for this is `core.abbrev` or 7 if unset. ++ pub fn id_abbrev(&mut self, abbrev: u16) -> &mut DiffOptions { ++ self.raw.id_abbrev = abbrev; ++ self ++ } ++ ++ /// Maximum size (in bytes) above which a blob will be marked as binary ++ /// automatically. ++ /// ++ /// A negative value will disable this entirely. ++ /// ++ /// The default value for this is 512MB. ++ pub fn max_size(&mut self, size: i64) -> &mut DiffOptions { ++ self.raw.max_size = size as raw::git_off_t; ++ self ++ } ++ ++ /// The virtual "directory" to prefix old file names with in hunk headers. ++ /// ++ /// The default value for this is "a". ++ pub fn old_prefix(&mut self, t: T) -> &mut DiffOptions { ++ self.old_prefix = Some(t.into_c_string().unwrap()); ++ self ++ } ++ ++ /// The virtual "directory" to prefix new file names with in hunk headers. ++ /// ++ /// The default value for this is "b". ++ pub fn new_prefix(&mut self, t: T) -> &mut DiffOptions { ++ self.new_prefix = Some(t.into_c_string().unwrap()); ++ self ++ } ++ ++ /// Add to the array of paths/fnmatch patterns to constrain the diff. ++ pub fn pathspec(&mut self, pathspec: T) ++ -> &mut DiffOptions { ++ let s = pathspec.into_c_string().unwrap(); ++ self.pathspec_ptrs.push(s.as_ptr()); ++ self.pathspec.push(s); ++ self ++ } ++ ++ /// Acquire a pointer to the underlying raw options. ++ /// ++ /// This function is unsafe as the pointer is only valid so long as this ++ /// structure is not moved, modified, or used elsewhere. ++ pub unsafe fn raw(&mut self) -> *const raw::git_diff_options { ++ self.raw.old_prefix = self.old_prefix.as_ref().map(|s| s.as_ptr()) ++ .unwrap_or(ptr::null()); ++ self.raw.new_prefix = self.new_prefix.as_ref().map(|s| s.as_ptr()) ++ .unwrap_or(ptr::null()); ++ self.raw.pathspec.count = self.pathspec_ptrs.len() as size_t; ++ self.raw.pathspec.strings = self.pathspec_ptrs.as_ptr() as *mut _; ++ &self.raw as *const _ ++ } ++ ++ // TODO: expose ignore_submodules, notify_cb/notify_payload ++} ++ ++impl<'diff> Iterator for Deltas<'diff> { ++ type Item = DiffDelta<'diff>; ++ fn next(&mut self) -> Option> { ++ self.range.next().and_then(|i| self.diff.get_delta(i)) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++impl<'diff> DoubleEndedIterator for Deltas<'diff> { ++ fn next_back(&mut self) -> Option> { ++ self.range.next_back().and_then(|i| self.diff.get_delta(i)) ++ } ++} ++impl<'diff> ExactSizeIterator for Deltas<'diff> {} ++ ++impl<'a> DiffLine<'a> { ++ /// Line number in old file or `None` for added line ++ pub fn old_lineno(&self) -> Option { ++ match unsafe { (*self.raw).old_lineno } { ++ n if n < 0 => None, ++ n => Some(n as u32), ++ } ++ } ++ ++ /// Line number in new file or `None` for deleted line ++ pub fn new_lineno(&self) -> Option { ++ match unsafe { (*self.raw).new_lineno } { ++ n if n < 0 => None, ++ n => Some(n as u32), ++ } ++ } ++ ++ /// Number of newline characters in content ++ pub fn num_lines(&self) -> u32 { ++ unsafe { (*self.raw).num_lines as u32 } ++ } ++ ++ /// Offset in the original file to the content ++ pub fn content_offset(&self) -> i64 { ++ unsafe { (*self.raw).content_offset as i64 } ++ } ++ ++ /// Content of this line as bytes. ++ pub fn content(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts((*self.raw).content as *const u8, ++ (*self.raw).content_len as usize) ++ } ++ } ++ ++ /// Sigil showing the origin of this `DiffLine`. ++ /// ++ /// * ` ` - Line context ++ /// * `+` - Line addition ++ /// * `-` - Line deletion ++ /// * `=` - Context (End of file) ++ /// * `>` - Add (End of file) ++ /// * `<` - Remove (End of file) ++ /// * `F` - File header ++ /// * `H` - Hunk header ++ /// * `B` - Line binary ++ pub fn origin(&self) -> char { ++ match unsafe { (*self.raw).origin as raw::git_diff_line_t } { ++ raw::GIT_DIFF_LINE_CONTEXT => ' ', ++ raw::GIT_DIFF_LINE_ADDITION => '+', ++ raw::GIT_DIFF_LINE_DELETION => '-', ++ raw::GIT_DIFF_LINE_CONTEXT_EOFNL => '=', ++ raw::GIT_DIFF_LINE_ADD_EOFNL => '>', ++ raw::GIT_DIFF_LINE_DEL_EOFNL => '<', ++ raw::GIT_DIFF_LINE_FILE_HDR => 'F', ++ raw::GIT_DIFF_LINE_HUNK_HDR => 'H', ++ raw::GIT_DIFF_LINE_BINARY => 'B', ++ _ => ' ', ++ } ++ } ++} ++ ++impl<'a> Binding for DiffLine<'a> { ++ type Raw = *const raw::git_diff_line; ++ unsafe fn from_raw(raw: *const raw::git_diff_line) -> DiffLine<'a> { ++ DiffLine { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *const raw::git_diff_line { self.raw } ++} ++ ++impl<'a> DiffHunk<'a> { ++ /// Starting line number in old_file ++ pub fn old_start(&self) -> u32 { ++ unsafe { (*self.raw).old_start as u32 } ++ } ++ ++ /// Number of lines in old_file ++ pub fn old_lines(&self) -> u32 { ++ unsafe { (*self.raw).old_lines as u32 } ++ } ++ ++ /// Starting line number in new_file ++ pub fn new_start(&self) -> u32 { ++ unsafe { (*self.raw).new_start as u32 } ++ } ++ ++ /// Number of lines in new_file ++ pub fn new_lines(&self) -> u32 { ++ unsafe { (*self.raw).new_lines as u32 } ++ } ++ ++ /// Header text ++ pub fn header(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts((*self.raw).header.as_ptr() as *const u8, ++ (*self.raw).header_len as usize) ++ } ++ } ++} ++ ++impl<'a> Binding for DiffHunk<'a> { ++ type Raw = *const raw::git_diff_hunk; ++ unsafe fn from_raw(raw: *const raw::git_diff_hunk) -> DiffHunk<'a> { ++ DiffHunk { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *const raw::git_diff_hunk { self.raw } ++} ++ ++impl DiffStats { ++ /// Get the total number of files chaned in a diff. ++ pub fn files_changed(&self) -> usize { ++ unsafe { raw::git_diff_stats_files_changed(&*self.raw) as usize } ++ } ++ ++ /// Get the total number of insertions in a diff ++ pub fn insertions(&self) -> usize { ++ unsafe { raw::git_diff_stats_insertions(&*self.raw) as usize } ++ } ++ ++ /// Get the total number of deletions in a diff ++ pub fn deletions(&self) -> usize { ++ unsafe { raw::git_diff_stats_deletions(&*self.raw) as usize } ++ } ++ ++ /// Print diff statistics to a Buf ++ pub fn to_buf(&self, format: DiffStatsFormat, width: usize) ++ -> Result { ++ let buf = Buf::new(); ++ unsafe { ++ try_call!(raw::git_diff_stats_to_buf(buf.raw(), self.raw, ++ format.bits(), ++ width as size_t)); ++ } ++ Ok(buf) ++ } ++} ++ ++impl Binding for DiffStats { ++ type Raw = *mut raw::git_diff_stats; ++ ++ unsafe fn from_raw(raw: *mut raw::git_diff_stats) -> DiffStats { ++ DiffStats { raw: raw } ++ } ++ fn raw(&self) -> *mut raw::git_diff_stats { self.raw } ++} ++ ++impl Drop for DiffStats { ++ fn drop(&mut self) { ++ unsafe { raw::git_diff_stats_free(self.raw) } ++ } ++} ++ ++impl<'a> DiffBinary<'a> { ++ /// Returns whether there is data in this binary structure or not. ++ /// ++ /// If this is `true`, then this was produced and included binary content. ++ /// If this is `false` then this was generated knowing only that a binary ++ /// file changed but without providing the data, probably from a patch that ++ /// said `Binary files a/file.txt and b/file.txt differ`. ++ pub fn contains_data(&self) -> bool { ++ unsafe { (*self.raw).contains_data == 1 } ++ } ++ ++ /// The contents of the old file. ++ pub fn old_file(&self) -> DiffBinaryFile<'a> { ++ unsafe { Binding::from_raw(&(*self.raw).old_file as *const _) } ++ } ++ ++ /// The contents of the new file. ++ pub fn new_file(&self) -> DiffBinaryFile<'a> { ++ unsafe { Binding::from_raw(&(*self.raw).new_file as *const _) } ++ } ++} ++ ++impl<'a> Binding for DiffBinary<'a> { ++ type Raw = *const raw::git_diff_binary; ++ unsafe fn from_raw(raw: *const raw::git_diff_binary) -> DiffBinary<'a> { ++ DiffBinary { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *const raw::git_diff_binary { self.raw } ++} ++ ++impl<'a> DiffBinaryFile<'a> { ++ /// The type of binary data for this file ++ pub fn kind(&self) -> DiffBinaryKind { ++ unsafe { Binding::from_raw((*self.raw).kind) } ++ } ++ ++ /// The binary data, deflated ++ pub fn data(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts((*self.raw).data as *const u8, ++ (*self.raw).datalen as usize) ++ } ++ } ++ ++ /// The length of the binary data after inflation ++ pub fn inflated_len(&self) -> usize { ++ unsafe { (*self.raw).inflatedlen as usize } ++ } ++ ++} ++ ++impl<'a> Binding for DiffBinaryFile<'a> { ++ type Raw = *const raw::git_diff_binary_file; ++ unsafe fn from_raw(raw: *const raw::git_diff_binary_file) -> DiffBinaryFile<'a> { ++ DiffBinaryFile { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *const raw::git_diff_binary_file { self.raw } ++} ++ ++impl Binding for DiffBinaryKind { ++ type Raw = raw::git_diff_binary_t; ++ unsafe fn from_raw(raw: raw::git_diff_binary_t) -> DiffBinaryKind { ++ match raw { ++ raw::GIT_DIFF_BINARY_NONE => DiffBinaryKind::None, ++ raw::GIT_DIFF_BINARY_LITERAL => DiffBinaryKind::Literal, ++ raw::GIT_DIFF_BINARY_DELTA => DiffBinaryKind::Delta, ++ _ => panic!("Unknown git diff binary kind"), ++ } ++ } ++ fn raw(&self) -> raw::git_diff_binary_t { ++ match *self { ++ DiffBinaryKind::None => raw::GIT_DIFF_BINARY_NONE, ++ DiffBinaryKind::Literal => raw::GIT_DIFF_BINARY_LITERAL, ++ DiffBinaryKind::Delta => raw::GIT_DIFF_BINARY_DELTA, ++ } ++ } ++} ++ ++impl Default for DiffFindOptions { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl DiffFindOptions { ++ /// Creates a new set of empty diff find options. ++ /// ++ /// All flags and other options are defaulted to false or their otherwise ++ /// zero equivalents. ++ pub fn new() -> DiffFindOptions { ++ let mut opts = DiffFindOptions { ++ raw: unsafe { mem::zeroed() }, ++ }; ++ assert_eq!(unsafe { ++ raw::git_diff_find_init_options(&mut opts.raw, 1) ++ }, 0); ++ opts ++ } ++ ++ fn flag(&mut self, opt: u32, val: bool) -> &mut DiffFindOptions { ++ if val { ++ self.raw.flags |= opt; ++ } else { ++ self.raw.flags &= !opt; ++ } ++ self ++ } ++ ++ /// Reset all flags back to their unset state, indicating that ++ /// `diff.renames` should be used instead. This is overridden once any flag ++ /// is set. ++ pub fn by_config(&mut self) -> &mut DiffFindOptions { ++ self.flag(0xffffffff, false) ++ } ++ ++ /// Look for renames? ++ pub fn renames(&mut self, find: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_RENAMES, find) ++ } ++ ++ /// Consider old side of modified for renames? ++ pub fn renames_from_rewrites(&mut self, find: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_RENAMES_FROM_REWRITES, find) ++ } ++ ++ /// Look for copies? ++ pub fn copies(&mut self, find: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_COPIES, find) ++ } ++ ++ /// Consider unmodified as copy sources? ++ /// ++ /// For this to work correctly, use `include_unmodified` when the initial ++ /// diff is being generated. ++ pub fn copies_from_unmodified(&mut self, find: bool) ++ -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED, find) ++ } ++ ++ /// Mark significant rewrites for split. ++ pub fn rewrites(&mut self, find: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_REWRITES, find) ++ } ++ ++ /// Actually split large rewrites into delete/add pairs ++ pub fn break_rewrites(&mut self, find: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_BREAK_REWRITES, find) ++ } ++ ++ #[doc(hidden)] ++ pub fn break_rewries(&mut self, find: bool) -> &mut DiffFindOptions { ++ self.break_rewrites(find) ++ } ++ ++ /// Find renames/copies for untracked items in working directory. ++ /// ++ /// For this to work correctly use the `include_untracked` option when the ++ /// initial diff is being generated. ++ pub fn for_untracked(&mut self, find: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_FOR_UNTRACKED, find) ++ } ++ ++ /// Turn on all finding features. ++ pub fn all(&mut self, find: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_ALL, find) ++ } ++ ++ /// Measure similarity ignoring leading whitespace (default) ++ pub fn ignore_leading_whitespace(&mut self, ignore: bool) ++ -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_IGNORE_LEADING_WHITESPACE, ignore) ++ } ++ ++ /// Measure similarity ignoring all whitespace ++ pub fn ignore_whitespace(&mut self, ignore: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_IGNORE_WHITESPACE, ignore) ++ } ++ ++ /// Measure similarity including all data ++ pub fn dont_ignore_whitespace(&mut self, dont: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE, dont) ++ } ++ ++ /// Measure similarity only by comparing SHAs (fast and cheap) ++ pub fn exact_match_only(&mut self, exact: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_EXACT_MATCH_ONLY, exact) ++ } ++ ++ /// Do not break rewrites unless they contribute to a rename. ++ /// ++ /// Normally, `break_rewrites` and `rewrites` will measure the ++ /// self-similarity of modified files and split the ones that have changed a ++ /// lot into a delete/add pair. Then the sides of that pair will be ++ /// considered candidates for rename and copy detection ++ /// ++ /// If you add this flag in and the split pair is not used for an actual ++ /// rename or copy, then the modified record will be restored to a regular ++ /// modified record instead of being split. ++ pub fn break_rewrites_for_renames_only(&mut self, b: bool) ++ -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY, b) ++ } ++ ++ /// Remove any unmodified deltas after find_similar is done. ++ /// ++ /// Using `copies_from_unmodified` to emulate the `--find-copies-harder` ++ /// behavior requires building a diff with the `include_unmodified` flag. If ++ /// you do not want unmodified records in the final result, pas this flag to ++ /// have them removed. ++ pub fn remove_unmodified(&mut self, remove: bool) -> &mut DiffFindOptions { ++ self.flag(raw::GIT_DIFF_FIND_REMOVE_UNMODIFIED, remove) ++ } ++ ++ /// Similarity to consider a file renamed (default 50) ++ pub fn rename_threshold(&mut self, thresh: u16) -> &mut DiffFindOptions { ++ self.raw.rename_threshold = thresh; ++ self ++ } ++ ++ /// Similarity of modified to be glegible rename source (default 50) ++ pub fn rename_from_rewrite_threshold(&mut self, thresh: u16) ++ -> &mut DiffFindOptions { ++ self.raw.rename_from_rewrite_threshold = thresh; ++ self ++ } ++ ++ /// Similarity to consider a file copy (default 50) ++ pub fn copy_threshold(&mut self, thresh: u16) -> &mut DiffFindOptions { ++ self.raw.copy_threshold = thresh; ++ self ++ } ++ ++ /// Similarity to split modify into delete/add pair (default 60) ++ pub fn break_rewrite_threshold(&mut self, thresh: u16) ++ -> &mut DiffFindOptions { ++ self.raw.break_rewrite_threshold = thresh; ++ self ++ } ++ ++ /// Maximum similarity sources to examine for a file (somewhat like ++ /// git-diff's `-l` option or `diff.renameLimit` config) ++ /// ++ /// Defaults to 200 ++ pub fn rename_limit(&mut self, limit: usize) -> &mut DiffFindOptions { ++ self.raw.rename_limit = limit as size_t; ++ self ++ } ++ ++ // TODO: expose git_diff_similarity_metric ++} ++ ++#[cfg(test)] ++mod tests { ++ use DiffOptions; ++ use std::fs::File; ++ use std::path::Path; ++ use std::borrow::Borrow; ++ use std::io::Write; ++ ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ let diff = repo.diff_tree_to_workdir(None, None).unwrap(); ++ assert_eq!(diff.deltas().len(), 0); ++ let stats = diff.stats().unwrap(); ++ assert_eq!(stats.insertions(), 0); ++ assert_eq!(stats.deletions(), 0); ++ assert_eq!(stats.files_changed(), 0); ++ } ++ ++ #[test] ++ fn foreach_smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ let diff = t!(repo.diff_tree_to_workdir(None, None)); ++ let mut count = 0; ++ t!(diff.foreach(&mut |_file, _progress| { count = count + 1; true }, ++ None, None, None)); ++ assert_eq!(count, 0); ++ } ++ ++ #[test] ++ fn foreach_file_only() { ++ let path = Path::new("foo"); ++ let (td, repo) = ::test::repo_init(); ++ t!(t!(File::create(&td.path().join(path))).write_all(b"bar")); ++ let mut opts = DiffOptions::new(); ++ opts.include_untracked(true); ++ let diff = t!(repo.diff_tree_to_workdir(None, Some(&mut opts))); ++ let mut count = 0; ++ let mut result = None; ++ t!(diff.foreach(&mut |file, _progress| { ++ count = count + 1; ++ result = file.new_file().path().map(ToOwned::to_owned); ++ true ++ }, None, None, None)); ++ assert_eq!(result.as_ref().map(Borrow::borrow), Some(path)); ++ assert_eq!(count, 1); ++ } ++ ++ #[test] ++ fn foreach_file_and_hunk() { ++ let path = Path::new("foo"); ++ let (td, repo) = ::test::repo_init(); ++ t!(t!(File::create(&td.path().join(path))).write_all(b"bar")); ++ let mut index = t!(repo.index()); ++ t!(index.add_path(path)); ++ let mut opts = DiffOptions::new(); ++ opts.include_untracked(true); ++ let diff = t!(repo.diff_tree_to_index(None, Some(&index), ++ Some(&mut opts))); ++ let mut new_lines = 0; ++ t!(diff.foreach( ++ &mut |_file, _progress| { true }, ++ None, ++ Some(&mut |_file, hunk| { ++ new_lines = hunk.new_lines(); ++ true ++ }), ++ None)); ++ assert_eq!(new_lines, 1); ++ } ++ ++ #[test] ++ fn foreach_all_callbacks() { ++ let fib = vec![0, 1, 1, 2, 3, 5, 8]; ++ // Verified with a node implementation of deflate, might be worth ++ // adding a deflate lib to do this inline here. ++ let deflated_fib = vec![120, 156, 99, 96, 100, 100, 98, 102, 229, 0, 0, ++ 0, 53, 0, 21]; ++ let foo_path = Path::new("foo"); ++ let bin_path = Path::new("bin"); ++ let (td, repo) = ::test::repo_init(); ++ t!(t!(File::create(&td.path().join(foo_path))).write_all(b"bar\n")); ++ t!(t!(File::create(&td.path().join(bin_path))).write_all(&fib)); ++ let mut index = t!(repo.index()); ++ t!(index.add_path(foo_path)); ++ t!(index.add_path(bin_path)); ++ let mut opts = DiffOptions::new(); ++ opts.include_untracked(true).show_binary(true); ++ let diff = t!(repo.diff_tree_to_index(None, Some(&index), ++ Some(&mut opts))); ++ let mut bin_content = None; ++ let mut new_lines = 0; ++ let mut line_content = None; ++ t!(diff.foreach( ++ &mut |_file, _progress| { true }, ++ Some(&mut |_file, binary| { ++ bin_content = Some(binary.new_file().data().to_owned()); ++ true ++ }), ++ Some(&mut |_file, hunk| { ++ new_lines = hunk.new_lines(); ++ true ++ }), ++ Some(&mut |_file, _hunk, line| { ++ line_content = String::from_utf8(line.content().into()).ok(); ++ true ++ }))); ++ assert_eq!(bin_content, Some(deflated_fib)); ++ assert_eq!(new_lines, 1); ++ assert_eq!(line_content, Some("bar\n".to_string())); ++ } ++} diff --cc vendor/git2-0.6.8/src/error.rs index 000000000,000000000..7d8f42c84 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/error.rs @@@ -1,0 -1,0 +1,237 @@@ ++use std::env::JoinPathsError; ++use std::ffi::{CStr, NulError}; ++use std::error; ++use std::fmt; ++use std::str; ++use libc::c_int; ++ ++use {raw, ErrorClass, ErrorCode}; ++ ++/// A structure to represent errors coming out of libgit2. ++#[derive(Debug,PartialEq)] ++pub struct Error { ++ code: c_int, ++ klass: c_int, ++ message: String, ++} ++ ++impl Error { ++ /// Returns the last error, or `None` if one is not available. ++ pub fn last_error(code: c_int) -> Option { ++ ::init(); ++ unsafe { ++ let ptr = raw::giterr_last(); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(Error::from_raw(code, ptr)) ++ } ++ } ++ } ++ ++ unsafe fn from_raw(code: c_int, ptr: *const raw::git_error) -> Error { ++ let msg = CStr::from_ptr((*ptr).message as *const _).to_bytes(); ++ let msg = str::from_utf8(msg).unwrap(); ++ Error { code: code, klass: (*ptr).klass, message: msg.to_string() } ++ } ++ ++ /// Creates a new error from the given string as the error. ++ pub fn from_str(s: &str) -> Error { ++ Error { ++ code: raw::GIT_ERROR as c_int, ++ klass: raw::GITERR_NONE as c_int, ++ message: s.to_string(), ++ } ++ } ++ ++ /// Return the error code associated with this error. ++ pub fn code(&self) -> ErrorCode { ++ match self.raw_code() { ++ raw::GIT_OK => super::ErrorCode::GenericError, ++ raw::GIT_ERROR => super::ErrorCode::GenericError, ++ raw::GIT_ENOTFOUND => super::ErrorCode::NotFound, ++ raw::GIT_EEXISTS => super::ErrorCode::Exists, ++ raw::GIT_EAMBIGUOUS => super::ErrorCode::Ambiguous, ++ raw::GIT_EBUFS => super::ErrorCode::BufSize, ++ raw::GIT_EUSER => super::ErrorCode::User, ++ raw::GIT_EBAREREPO => super::ErrorCode::BareRepo, ++ raw::GIT_EUNBORNBRANCH => super::ErrorCode::UnbornBranch, ++ raw::GIT_EUNMERGED => super::ErrorCode::Unmerged, ++ raw::GIT_ENONFASTFORWARD => super::ErrorCode::NotFastForward, ++ raw::GIT_EINVALIDSPEC => super::ErrorCode::InvalidSpec, ++ raw::GIT_ECONFLICT => super::ErrorCode::Conflict, ++ raw::GIT_ELOCKED => super::ErrorCode::Locked, ++ raw::GIT_EMODIFIED => super::ErrorCode::Modified, ++ raw::GIT_PASSTHROUGH => super::ErrorCode::GenericError, ++ raw::GIT_ITEROVER => super::ErrorCode::GenericError, ++ raw::GIT_EAUTH => super::ErrorCode::Auth, ++ raw::GIT_ECERTIFICATE => super::ErrorCode::Certificate, ++ raw::GIT_EAPPLIED => super::ErrorCode::Applied, ++ raw::GIT_EPEEL => super::ErrorCode::Peel, ++ raw::GIT_EEOF => super::ErrorCode::Eof, ++ raw::GIT_EINVALID => super::ErrorCode::Invalid, ++ raw::GIT_EUNCOMMITTED => super::ErrorCode::Uncommitted, ++ raw::GIT_EDIRECTORY => super::ErrorCode::Directory, ++ _ => super::ErrorCode::GenericError, ++ } ++ } ++ ++ /// Return the error class associated with this error. ++ pub fn class(&self) -> ErrorClass { ++ match self.raw_class() { ++ raw::GITERR_NONE => super::ErrorClass::None, ++ raw::GITERR_NOMEMORY => super::ErrorClass::NoMemory, ++ raw::GITERR_OS => super::ErrorClass::Os, ++ raw::GITERR_INVALID => super::ErrorClass::Invalid, ++ raw::GITERR_REFERENCE => super::ErrorClass::Reference, ++ raw::GITERR_ZLIB => super::ErrorClass::Zlib, ++ raw::GITERR_REPOSITORY => super::ErrorClass::Repository, ++ raw::GITERR_CONFIG => super::ErrorClass::Config, ++ raw::GITERR_REGEX => super::ErrorClass::Regex, ++ raw::GITERR_ODB => super::ErrorClass::Odb, ++ raw::GITERR_INDEX => super::ErrorClass::Index, ++ raw::GITERR_OBJECT => super::ErrorClass::Object, ++ raw::GITERR_NET => super::ErrorClass::Net, ++ raw::GITERR_TAG => super::ErrorClass::Tag, ++ raw::GITERR_TREE => super::ErrorClass::Tree, ++ raw::GITERR_INDEXER => super::ErrorClass::Indexer, ++ raw::GITERR_SSL => super::ErrorClass::Ssl, ++ raw::GITERR_SUBMODULE => super::ErrorClass::Submodule, ++ raw::GITERR_THREAD => super::ErrorClass::Thread, ++ raw::GITERR_STASH => super::ErrorClass::Stash, ++ raw::GITERR_CHECKOUT => super::ErrorClass::Checkout, ++ raw::GITERR_FETCHHEAD => super::ErrorClass::FetchHead, ++ raw::GITERR_MERGE => super::ErrorClass::Merge, ++ raw::GITERR_SSH => super::ErrorClass::Ssh, ++ raw::GITERR_FILTER => super::ErrorClass::Filter, ++ raw::GITERR_REVERT => super::ErrorClass::Revert, ++ raw::GITERR_CALLBACK => super::ErrorClass::Callback, ++ raw::GITERR_CHERRYPICK => super::ErrorClass::CherryPick, ++ raw::GITERR_DESCRIBE => super::ErrorClass::Describe, ++ raw::GITERR_REBASE => super::ErrorClass::Rebase, ++ raw::GITERR_FILESYSTEM => super::ErrorClass::Filesystem, ++ _ => super::ErrorClass::None, ++ } ++ } ++ ++ /// Return the raw error code associated with this error. ++ pub fn raw_code(&self) -> raw::git_error_code { ++ macro_rules! check( ($($e:ident,)*) => ( ++ $(if self.code == raw::$e as c_int { raw::$e }) else * ++ else { ++ raw::GIT_ERROR ++ } ++ ) ); ++ check!( ++ GIT_OK, ++ GIT_ERROR, ++ GIT_ENOTFOUND, ++ GIT_EEXISTS, ++ GIT_EAMBIGUOUS, ++ GIT_EBUFS, ++ GIT_EUSER, ++ GIT_EBAREREPO, ++ GIT_EUNBORNBRANCH, ++ GIT_EUNMERGED, ++ GIT_ENONFASTFORWARD, ++ GIT_EINVALIDSPEC, ++ GIT_ECONFLICT, ++ GIT_ELOCKED, ++ GIT_EMODIFIED, ++ GIT_EAUTH, ++ GIT_ECERTIFICATE, ++ GIT_EAPPLIED, ++ GIT_EPEEL, ++ GIT_EEOF, ++ GIT_EINVALID, ++ GIT_EUNCOMMITTED, ++ GIT_PASSTHROUGH, ++ GIT_ITEROVER, ++ ) ++ } ++ ++ /// Return the raw error class associated with this error. ++ pub fn raw_class(&self) -> raw::git_error_t { ++ macro_rules! check( ($($e:ident,)*) => ( ++ $(if self.klass == raw::$e as c_int { raw::$e }) else * ++ else { ++ raw::GITERR_NONE ++ } ++ ) ); ++ check!( ++ GITERR_NONE, ++ GITERR_NOMEMORY, ++ GITERR_OS, ++ GITERR_INVALID, ++ GITERR_REFERENCE, ++ GITERR_ZLIB, ++ GITERR_REPOSITORY, ++ GITERR_CONFIG, ++ GITERR_REGEX, ++ GITERR_ODB, ++ GITERR_INDEX, ++ GITERR_OBJECT, ++ GITERR_NET, ++ GITERR_TAG, ++ GITERR_TREE, ++ GITERR_INDEXER, ++ GITERR_SSL, ++ GITERR_SUBMODULE, ++ GITERR_THREAD, ++ GITERR_STASH, ++ GITERR_CHECKOUT, ++ GITERR_FETCHHEAD, ++ GITERR_MERGE, ++ GITERR_SSH, ++ GITERR_FILTER, ++ GITERR_REVERT, ++ GITERR_CALLBACK, ++ GITERR_CHERRYPICK, ++ GITERR_DESCRIBE, ++ GITERR_REBASE, ++ GITERR_FILESYSTEM, ++ ) ++ } ++ ++ /// Return the message associated with this error ++ pub fn message(&self) -> &str { &self.message } ++} ++ ++impl error::Error for Error { ++ fn description(&self) -> &str { &self.message } ++} ++ ++impl fmt::Display for Error { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ try!(write!(f, "[{}/{}] ", self.klass, self.code)); ++ f.write_str(&self.message) ++ } ++} ++ ++impl From for Error { ++ fn from(_: NulError) -> Error { ++ Error::from_str("data contained a nul byte that could not be \ ++ represented as a string") ++ } ++} ++ ++impl From for Error { ++ fn from(e: JoinPathsError) -> Error { ++ Error::from_str(error::Error::description(&e)) ++ } ++} ++ ++ ++#[cfg(test)] ++mod tests { ++ use {ErrorClass, ErrorCode}; ++ ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ ++ let err = repo.find_submodule("does_not_exist").err().unwrap(); ++ assert_eq!(err.code(), ErrorCode::NotFound); ++ assert_eq!(err.class(), ErrorClass::Submodule); ++ } ++} diff --cc vendor/git2-0.6.8/src/index.rs index 000000000,000000000..8d5172e61 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/index.rs @@@ -1,0 -1,0 +1,634 @@@ ++use std::ffi::{CStr, OsString, CString}; ++use std::ops::Range; ++use std::path::Path; ++use std::ptr; ++use std::slice; ++ ++use libc::{c_int, c_uint, size_t, c_void, c_char}; ++ ++use {raw, panic, Repository, Error, Tree, Oid, IndexAddOption, IndexTime}; ++use IntoCString; ++use util::{self, Binding}; ++ ++/// A structure to represent a git [index][1] ++/// ++/// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects ++pub struct Index { ++ raw: *mut raw::git_index, ++} ++ ++/// An iterator over the entries in an index ++pub struct IndexEntries<'index> { ++ range: Range, ++ index: &'index Index, ++} ++ ++/// A callback function to filter index matches. ++/// ++/// Used by `Index::{add_all,remove_all,update_all}`. The first argument is the ++/// path, and the second is the patchspec that matched it. Return 0 to confirm ++/// the operation on the item, > 0 to skip the item, and < 0 to abort the scan. ++pub type IndexMatchedPath<'a> = FnMut(&Path, &[u8]) -> i32 + 'a; ++ ++/// A structure to represent an entry or a file inside of an index. ++/// ++/// All fields of an entry are public for modification and inspection. This is ++/// also how a new index entry is created. ++#[allow(missing_docs)] ++pub struct IndexEntry { ++ pub ctime: IndexTime, ++ pub mtime: IndexTime, ++ pub dev: u32, ++ pub ino: u32, ++ pub mode: u32, ++ pub uid: u32, ++ pub gid: u32, ++ pub file_size: u32, ++ pub id: Oid, ++ pub flags: u16, ++ pub flags_extended: u16, ++ pub path: Vec, ++} ++ ++impl Index { ++ /// Creates a new in-memory index. ++ /// ++ /// This index object cannot be read/written to the filesystem, but may be ++ /// used to perform in-memory index operations. ++ pub fn new() -> Result { ++ ::init(); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_index_new(&mut raw)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Create a new bare Git index object as a memory representation of the Git ++ /// index file in 'index_path', without a repository to back it. ++ /// ++ /// Since there is no ODB or working directory behind this index, any Index ++ /// methods which rely on these (e.g. add_path) will fail. ++ /// ++ /// If you need an index attached to a repository, use the `index()` method ++ /// on `Repository`. ++ pub fn open(index_path: &Path) -> Result { ++ ::init(); ++ let mut raw = ptr::null_mut(); ++ let index_path = try!(index_path.into_c_string()); ++ unsafe { ++ try_call!(raw::git_index_open(&mut raw, index_path)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Add or update an index entry from an in-memory struct ++ /// ++ /// If a previous index entry exists that has the same path and stage as the ++ /// given 'source_entry', it will be replaced. Otherwise, the 'source_entry' ++ /// will be added. ++ pub fn add(&mut self, entry: &IndexEntry) -> Result<(), Error> { ++ let path = try!(CString::new(&entry.path[..])); ++ ++ // libgit2 encodes the length of the path in the lower bits of the ++ // `flags` entry, so mask those out and recalculate here to ensure we ++ // don't corrupt anything. ++ let mut flags = entry.flags & !raw::GIT_IDXENTRY_NAMEMASK; ++ ++ if entry.path.len() < raw::GIT_IDXENTRY_NAMEMASK as usize { ++ flags |= entry.path.len() as u16; ++ } else { ++ flags |= raw::GIT_IDXENTRY_NAMEMASK; ++ } ++ ++ unsafe { ++ let raw = raw::git_index_entry { ++ dev: entry.dev, ++ ino: entry.ino, ++ mode: entry.mode, ++ uid: entry.uid, ++ gid: entry.gid, ++ file_size: entry.file_size, ++ id: *entry.id.raw(), ++ flags: flags, ++ flags_extended: entry.flags_extended, ++ path: path.as_ptr(), ++ mtime: raw::git_index_time { ++ seconds: entry.mtime.seconds(), ++ nanoseconds: entry.mtime.nanoseconds(), ++ }, ++ ctime: raw::git_index_time { ++ seconds: entry.ctime.seconds(), ++ nanoseconds: entry.ctime.nanoseconds(), ++ }, ++ }; ++ try_call!(raw::git_index_add(self.raw, &raw)); ++ Ok(()) ++ } ++ } ++ ++ /// Add or update an index entry from a file on disk ++ /// ++ /// The file path must be relative to the repository's working folder and ++ /// must be readable. ++ /// ++ /// This method will fail in bare index instances. ++ /// ++ /// This forces the file to be added to the index, not looking at gitignore ++ /// rules. ++ /// ++ /// If this file currently is the result of a merge conflict, this file will ++ /// no longer be marked as conflicting. The data about the conflict will be ++ /// moved to the "resolve undo" (REUC) section. ++ pub fn add_path(&mut self, path: &Path) -> Result<(), Error> { ++ // Git apparently expects '/' to be separators for paths ++ let mut posix_path = OsString::new(); ++ for (i, comp) in path.components().enumerate() { ++ if i != 0 { posix_path.push("/"); } ++ posix_path.push(comp.as_os_str()); ++ } ++ let posix_path = try!(posix_path.into_c_string()); ++ unsafe { ++ try_call!(raw::git_index_add_bypath(self.raw, posix_path)); ++ Ok(()) ++ } ++ } ++ ++ /// Add or update index entries matching files in the working directory. ++ /// ++ /// This method will fail in bare index instances. ++ /// ++ /// The `pathspecs` are a list of file names or shell glob patterns that ++ /// will matched against files in the repository's working directory. Each ++ /// file that matches will be added to the index (either updating an ++ /// existing entry or adding a new entry). You can disable glob expansion ++ /// and force exact matching with the `AddDisablePathspecMatch` flag. ++ /// ++ /// Files that are ignored will be skipped (unlike `add_path`). If a file is ++ /// already tracked in the index, then it will be updated even if it is ++ /// ignored. Pass the `AddForce` flag to skip the checking of ignore rules. ++ /// ++ /// To emulate `git add -A` and generate an error if the pathspec contains ++ /// the exact path of an ignored file (when not using `AddForce`), add the ++ /// `AddCheckPathspec` flag. This checks that each entry in `pathspecs` ++ /// that is an exact match to a filename on disk is either not ignored or ++ /// already in the index. If this check fails, the function will return ++ /// an error. ++ /// ++ /// To emulate `git add -A` with the "dry-run" option, just use a callback ++ /// function that always returns a positive value. See below for details. ++ /// ++ /// If any files are currently the result of a merge conflict, those files ++ /// will no longer be marked as conflicting. The data about the conflicts ++ /// will be moved to the "resolve undo" (REUC) section. ++ /// ++ /// If you provide a callback function, it will be invoked on each matching ++ /// item in the working directory immediately before it is added to / ++ /// updated in the index. Returning zero will add the item to the index, ++ /// greater than zero will skip the item, and less than zero will abort the ++ /// scan an return an error to the caller. ++ pub fn add_all(&mut self, ++ pathspecs: I, ++ flag: IndexAddOption, ++ mut cb: Option<&mut IndexMatchedPath>) ++ -> Result<(), Error> ++ where T: IntoCString, I: IntoIterator, ++ { ++ let (_a, _b, raw_strarray) = try!(::util::iter2cstrs(pathspecs)); ++ let ptr = cb.as_mut(); ++ let callback = ptr.as_ref().map(|_| { ++ index_matched_path_cb as raw::git_index_matched_path_cb ++ }); ++ unsafe { ++ try_call!(raw::git_index_add_all(self.raw, ++ &raw_strarray, ++ flag.bits() as c_uint, ++ callback, ++ ptr.map(|p| p as *mut _) ++ .unwrap_or(ptr::null_mut()) ++ as *mut c_void)); ++ } ++ Ok(()) ++ } ++ ++ /// Clear the contents (all the entries) of an index object. ++ /// ++ /// This clears the index object in memory; changes must be explicitly ++ /// written to disk for them to take effect persistently via `write_*`. ++ pub fn clear(&mut self) -> Result<(), Error> { ++ unsafe { try_call!(raw::git_index_clear(self.raw)); } ++ Ok(()) ++ } ++ ++ /// Get the count of entries currently in the index ++ pub fn len(&self) -> usize { ++ unsafe { raw::git_index_entrycount(&*self.raw) as usize } ++ } ++ ++ /// Return `true` is there is no entry in the index ++ pub fn is_empty(&self) -> bool { ++ self.len() == 0 ++ } ++ ++ /// Get one of the entries in the index by its position. ++ pub fn get(&self, n: usize) -> Option { ++ unsafe { ++ let ptr = raw::git_index_get_byindex(self.raw, n as size_t); ++ if ptr.is_null() {None} else {Some(Binding::from_raw(*ptr))} ++ } ++ } ++ ++ /// Get an iterator over the entries in this index. ++ pub fn iter(&self) -> IndexEntries { ++ IndexEntries { range: 0..self.len(), index: self } ++ } ++ ++ /// Get one of the entries in the index by its path. ++ pub fn get_path(&self, path: &Path, stage: i32) -> Option { ++ let path = path.into_c_string().unwrap(); ++ unsafe { ++ let ptr = call!(raw::git_index_get_bypath(self.raw, path, ++ stage as c_int)); ++ if ptr.is_null() {None} else {Some(Binding::from_raw(*ptr))} ++ } ++ } ++ ++ /// Does this index have conflicts? ++ /// ++ /// Returns `true` if the index contains conflicts, `false` if it does not. ++ pub fn has_conflicts(&self) -> bool { ++ unsafe { ++ raw::git_index_has_conflicts(self.raw) == 1 ++ } ++ } ++ ++ /// Get the full path to the index file on disk. ++ /// ++ /// Returns `None` if this is an in-memory index. ++ pub fn path(&self) -> Option<&Path> { ++ unsafe { ++ ::opt_bytes(self, raw::git_index_path(&*self.raw)).map(util::bytes2path) ++ } ++ } ++ ++ /// Update the contents of an existing index object in memory by reading ++ /// from the hard disk. ++ /// ++ /// If force is true, this performs a "hard" read that discards in-memory ++ /// changes and always reloads the on-disk index data. If there is no ++ /// on-disk version, the index will be cleared. ++ /// ++ /// If force is false, this does a "soft" read that reloads the index data ++ /// from disk only if it has changed since the last time it was loaded. ++ /// Purely in-memory index data will be untouched. Be aware: if there are ++ /// changes on disk, unwritten in-memory changes are discarded. ++ pub fn read(&mut self, force: bool) -> Result<(), Error> { ++ unsafe { try_call!(raw::git_index_read(self.raw, force)); } ++ Ok(()) ++ } ++ ++ /// Read a tree into the index file with stats ++ /// ++ /// The current index contents will be replaced by the specified tree. ++ pub fn read_tree(&mut self, tree: &Tree) -> Result<(), Error> { ++ unsafe { try_call!(raw::git_index_read_tree(self.raw, &*tree.raw())); } ++ Ok(()) ++ } ++ ++ /// Remove an entry from the index ++ pub fn remove(&mut self, path: &Path, stage: i32) -> Result<(), Error> { ++ let path = try!(path.into_c_string()); ++ unsafe { ++ try_call!(raw::git_index_remove(self.raw, path, stage as c_int)); ++ } ++ Ok(()) ++ } ++ ++ /// Remove an index entry corresponding to a file on disk. ++ /// ++ /// The file path must be relative to the repository's working folder. It ++ /// may exist. ++ /// ++ /// If this file currently is the result of a merge conflict, this file will ++ /// no longer be marked as conflicting. The data about the conflict will be ++ /// moved to the "resolve undo" (REUC) section. ++ pub fn remove_path(&mut self, path: &Path) -> Result<(), Error> { ++ let path = try!(path.into_c_string()); ++ unsafe { ++ try_call!(raw::git_index_remove_bypath(self.raw, path)); ++ } ++ Ok(()) ++ } ++ ++ /// Remove all entries from the index under a given directory. ++ pub fn remove_dir(&mut self, path: &Path, stage: i32) -> Result<(), Error> { ++ let path = try!(path.into_c_string()); ++ unsafe { ++ try_call!(raw::git_index_remove_directory(self.raw, path, ++ stage as c_int)); ++ } ++ Ok(()) ++ } ++ ++ /// Remove all matching index entries. ++ /// ++ /// If you provide a callback function, it will be invoked on each matching ++ /// item in the index immediately before it is removed. Return 0 to remove ++ /// the item, > 0 to skip the item, and < 0 to abort the scan. ++ pub fn remove_all(&mut self, ++ pathspecs: I, ++ mut cb: Option<&mut IndexMatchedPath>) ++ -> Result<(), Error> ++ where T: IntoCString, I: IntoIterator, ++ { ++ let (_a, _b, raw_strarray) = try!(::util::iter2cstrs(pathspecs)); ++ let ptr = cb.as_mut(); ++ let callback = ptr.as_ref().map(|_| { ++ index_matched_path_cb as raw::git_index_matched_path_cb ++ }); ++ unsafe { ++ try_call!(raw::git_index_remove_all(self.raw, ++ &raw_strarray, ++ callback, ++ ptr.map(|p| p as *mut _) ++ .unwrap_or(ptr::null_mut()) ++ as *mut c_void)); ++ } ++ Ok(()) ++ } ++ ++ /// Update all index entries to match the working directory ++ /// ++ /// This method will fail in bare index instances. ++ /// ++ /// This scans the existing index entries and synchronizes them with the ++ /// working directory, deleting them if the corresponding working directory ++ /// file no longer exists otherwise updating the information (including ++ /// adding the latest version of file to the ODB if needed). ++ /// ++ /// If you provide a callback function, it will be invoked on each matching ++ /// item in the index immediately before it is updated (either refreshed or ++ /// removed depending on working directory state). Return 0 to proceed with ++ /// updating the item, > 0 to skip the item, and < 0 to abort the scan. ++ pub fn update_all(&mut self, ++ pathspecs: I, ++ mut cb: Option<&mut IndexMatchedPath>) ++ -> Result<(), Error> ++ where T: IntoCString, I: IntoIterator, ++ { ++ let (_a, _b, raw_strarray) = try!(::util::iter2cstrs(pathspecs)); ++ let ptr = cb.as_mut(); ++ let callback = ptr.as_ref().map(|_| { ++ index_matched_path_cb as raw::git_index_matched_path_cb ++ }); ++ unsafe { ++ try_call!(raw::git_index_update_all(self.raw, ++ &raw_strarray, ++ callback, ++ ptr.map(|p| p as *mut _) ++ .unwrap_or(ptr::null_mut()) ++ as *mut c_void)); ++ } ++ Ok(()) ++ } ++ ++ /// Write an existing index object from memory back to disk using an atomic ++ /// file lock. ++ pub fn write(&mut self) -> Result<(), Error> { ++ unsafe { try_call!(raw::git_index_write(self.raw)); } ++ Ok(()) ++ } ++ ++ /// Write the index as a tree. ++ /// ++ /// This method will scan the index and write a representation of its ++ /// current state back to disk; it recursively creates tree objects for each ++ /// of the subtrees stored in the index, but only returns the OID of the ++ /// root tree. This is the OID that can be used e.g. to create a commit. ++ /// ++ /// The index instance cannot be bare, and needs to be associated to an ++ /// existing repository. ++ /// ++ /// The index must not contain any file in conflict. ++ pub fn write_tree(&mut self) -> Result { ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_index_write_tree(&mut raw, self.raw)); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++ ++ /// Write the index as a tree to the given repository ++ /// ++ /// This is the same as `write_tree` except that the destination repository ++ /// can be chosen. ++ pub fn write_tree_to(&mut self, repo: &Repository) -> Result { ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_index_write_tree_to(&mut raw, self.raw, ++ repo.raw())); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++} ++ ++impl Binding for Index { ++ type Raw = *mut raw::git_index; ++ unsafe fn from_raw(raw: *mut raw::git_index) -> Index { ++ Index { raw: raw } ++ } ++ fn raw(&self) -> *mut raw::git_index { self.raw } ++} ++ ++extern fn index_matched_path_cb(path: *const c_char, ++ matched_pathspec: *const c_char, ++ payload: *mut c_void) -> c_int { ++ unsafe { ++ let path = CStr::from_ptr(path).to_bytes(); ++ let matched_pathspec = CStr::from_ptr(matched_pathspec).to_bytes(); ++ ++ panic::wrap(|| { ++ let payload = payload as *mut &mut IndexMatchedPath; ++ (*payload)(util::bytes2path(path), matched_pathspec) as c_int ++ }).unwrap_or(-1) ++ } ++} ++ ++impl Drop for Index { ++ fn drop(&mut self) { ++ unsafe { raw::git_index_free(self.raw) } ++ } ++} ++ ++impl<'index> Iterator for IndexEntries<'index> { ++ type Item = IndexEntry; ++ fn next(&mut self) -> Option { ++ self.range.next().map(|i| self.index.get(i).unwrap()) ++ } ++} ++ ++impl Binding for IndexEntry { ++ type Raw = raw::git_index_entry; ++ ++ unsafe fn from_raw(raw: raw::git_index_entry) -> IndexEntry { ++ let raw::git_index_entry { ++ ctime, mtime, dev, ino, mode, uid, gid, file_size, id, flags, ++ flags_extended, path ++ } = raw; ++ ++ // libgit2 encodes the length of the path in the lower bits of `flags`, ++ // but if the length exceeds the number of bits then the path is ++ // nul-terminated. ++ let mut pathlen = (flags & raw::GIT_IDXENTRY_NAMEMASK) as usize; ++ if pathlen == raw::GIT_IDXENTRY_NAMEMASK as usize { ++ pathlen = CStr::from_ptr(path).to_bytes().len(); ++ } ++ ++ let path = slice::from_raw_parts(path as *const u8, pathlen); ++ ++ IndexEntry { ++ dev: dev, ++ ino: ino, ++ mode: mode, ++ uid: uid, ++ gid: gid, ++ file_size: file_size, ++ id: Binding::from_raw(&id as *const _), ++ flags: flags, ++ flags_extended: flags_extended, ++ path: path.to_vec(), ++ mtime: Binding::from_raw(mtime), ++ ctime: Binding::from_raw(ctime), ++ } ++ } ++ ++ fn raw(&self) -> raw::git_index_entry { ++ // not implemented, may require a CString in storage ++ panic!() ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::fs::{self, File}; ++ use std::path::Path; ++ use tempdir::TempDir; ++ ++ use {Index, IndexEntry, Repository, ResetType, Oid, IndexTime}; ++ ++ #[test] ++ fn smoke() { ++ let mut index = Index::new().unwrap(); ++ assert!(index.add_path(&Path::new(".")).is_err()); ++ index.clear().unwrap(); ++ assert_eq!(index.len(), 0); ++ assert!(index.get(0).is_none()); ++ assert!(index.path().is_none()); ++ assert!(index.read(true).is_err()); ++ } ++ ++ #[test] ++ fn smoke_from_repo() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut index = repo.index().unwrap(); ++ assert_eq!(index.path().map(|s| s.to_path_buf()), ++ Some(repo.path().join("index"))); ++ Index::open(&repo.path().join("index")).unwrap(); ++ ++ index.clear().unwrap(); ++ index.read(true).unwrap(); ++ index.write().unwrap(); ++ index.write_tree().unwrap(); ++ index.write_tree_to(&repo).unwrap(); ++ } ++ ++ #[test] ++ fn add_all() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut index = repo.index().unwrap(); ++ ++ let root = repo.path().parent().unwrap(); ++ fs::create_dir(&root.join("foo")).unwrap(); ++ File::create(&root.join("foo/bar")).unwrap(); ++ let mut called = false; ++ index.add_all(["foo"].iter(), ::ADD_DEFAULT, ++ Some(&mut |a: &Path, b: &[u8]| { ++ assert!(!called); ++ called = true; ++ assert_eq!(b, b"foo"); ++ assert_eq!(a, Path::new("foo/bar")); ++ 0 ++ })).unwrap(); ++ assert!(called); ++ ++ called = false; ++ index.remove_all(["."].iter(), Some(&mut |a: &Path, b: &[u8]| { ++ assert!(!called); ++ called = true; ++ assert_eq!(b, b"."); ++ assert_eq!(a, Path::new("foo/bar")); ++ 0 ++ })).unwrap(); ++ assert!(called); ++ } ++ ++ #[test] ++ fn smoke_add() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut index = repo.index().unwrap(); ++ ++ let root = repo.path().parent().unwrap(); ++ fs::create_dir(&root.join("foo")).unwrap(); ++ File::create(&root.join("foo/bar")).unwrap(); ++ index.add_path(Path::new("foo/bar")).unwrap(); ++ index.write().unwrap(); ++ assert_eq!(index.iter().count(), 1); ++ ++ // Make sure we can use this repo somewhere else now. ++ let id = index.write_tree().unwrap(); ++ let tree = repo.find_tree(id).unwrap(); ++ let sig = repo.signature().unwrap(); ++ let id = repo.refname_to_id("HEAD").unwrap(); ++ let parent = repo.find_commit(id).unwrap(); ++ let commit = repo.commit(Some("HEAD"), &sig, &sig, "commit", ++ &tree, &[&parent]).unwrap(); ++ let obj = repo.find_object(commit, None).unwrap(); ++ repo.reset(&obj, ResetType::Hard, None).unwrap(); ++ ++ let td2 = TempDir::new("git").unwrap(); ++ let url = ::test::path2url(&root); ++ let repo = Repository::clone(&url, td2.path()).unwrap(); ++ let obj = repo.find_object(commit, None).unwrap(); ++ repo.reset(&obj, ResetType::Hard, None).unwrap(); ++ } ++ ++ #[test] ++ fn add_then_read() { ++ let mut index = Index::new().unwrap(); ++ assert!(index.add(&entry()).is_err()); ++ ++ let mut index = Index::new().unwrap(); ++ let mut e = entry(); ++ e.path = b"foobar".to_vec(); ++ index.add(&e).unwrap(); ++ let e = index.get(0).unwrap(); ++ assert_eq!(e.path.len(), 6); ++ } ++ ++ fn entry() -> IndexEntry { ++ IndexEntry { ++ ctime: IndexTime::new(0, 0), ++ mtime: IndexTime::new(0, 0), ++ dev: 0, ++ ino: 0, ++ mode: 0o100644, ++ uid: 0, ++ gid: 0, ++ file_size: 0, ++ id: Oid::from_bytes(&[0; 20]).unwrap(), ++ flags: 0, ++ flags_extended: 0, ++ path: Vec::new(), ++ } ++ } ++} diff --cc vendor/git2-0.6.8/src/lib.rs index 000000000,000000000..e2f460af6 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/lib.rs @@@ -1,0 -1,0 +1,1128 @@@ ++//! # libgit2 bindings for Rust ++//! ++//! This library contains bindings to the [libgit2][1] C library which is used ++//! to manage git repositories. The library itself is a work in progress and is ++//! likely lacking some bindings here and there, so be warned. ++//! ++//! [1]: https://libgit2.github.com/ ++//! ++//! The git2-rs library strives to be as close to libgit2 as possible, but also ++//! strives to make using libgit2 as safe as possible. All resource management ++//! is automatic as well as adding strong types to all interfaces (including ++//! `Result`) ++//! ++//! ## Creating a `Repository` ++//! ++//! The `Repository` is the source from which almost all other objects in git-rs ++//! are spawned. A repository can be created through opening, initializing, or ++//! cloning. ++//! ++//! ### Initializing a new repository ++//! ++//! The `init` method will create a new repository, assuming one does not ++//! already exist. ++//! ++//! ```no_run ++//! # #![allow(unstable)] ++//! use git2::Repository; ++//! ++//! let repo = match Repository::init("/path/to/a/repo") { ++//! Ok(repo) => repo, ++//! Err(e) => panic!("failed to init: {}", e), ++//! }; ++//! ``` ++//! ++//! ### Opening an existing repository ++//! ++//! ```no_run ++//! # #![allow(unstable)] ++//! use git2::Repository; ++//! ++//! let repo = match Repository::open("/path/to/a/repo") { ++//! Ok(repo) => repo, ++//! Err(e) => panic!("failed to open: {}", e), ++//! }; ++//! ``` ++//! ++//! ### Cloning an existing repository ++//! ++//! ```no_run ++//! # #![allow(unstable)] ++//! use git2::Repository; ++//! ++//! let url = "https://github.com/alexcrichton/git2-rs"; ++//! let repo = match Repository::clone(url, "/path/to/a/repo") { ++//! Ok(repo) => repo, ++//! Err(e) => panic!("failed to clone: {}", e), ++//! }; ++//! ``` ++//! ++//! ## Working with a `Repository` ++//! ++//! All deriviative objects, references, etc are attached to the lifetime of the ++//! source `Repository`, to ensure that they do not outlive the repository ++//! itself. ++ ++#![doc(html_root_url = "https://docs.rs/git2/0.6")] ++#![allow(trivial_numeric_casts, trivial_casts)] ++#![deny(missing_docs)] ++#![cfg_attr(test, deny(warnings))] ++ ++extern crate libc; ++extern crate url; ++extern crate libgit2_sys as raw; ++#[macro_use] extern crate bitflags; ++#[cfg(test)] extern crate tempdir; ++ ++use std::ffi::{CStr, CString}; ++use std::fmt; ++use std::str; ++use std::sync::{Once, ONCE_INIT}; ++ ++pub use blame::{Blame, BlameHunk, BlameIter, BlameOptions}; ++pub use blob::{Blob, BlobWriter}; ++pub use branch::{Branch, Branches}; ++pub use buf::Buf; ++pub use commit::{Commit, Parents}; ++pub use config::{Config, ConfigEntry, ConfigEntries}; ++pub use cred::{Cred, CredentialHelper}; ++pub use describe::{Describe, DescribeFormatOptions, DescribeOptions}; ++pub use diff::{Diff, DiffDelta, DiffFile, DiffOptions, Deltas}; ++pub use diff::{DiffBinary, DiffBinaryFile, DiffBinaryKind}; ++pub use diff::{DiffLine, DiffHunk, DiffStats, DiffFindOptions}; ++pub use error::Error; ++pub use index::{Index, IndexEntry, IndexEntries, IndexMatchedPath}; ++pub use merge::{AnnotatedCommit, MergeOptions}; ++pub use message::{message_prettify, DEFAULT_COMMENT_CHAR}; ++pub use note::{Note, Notes}; ++pub use object::Object; ++pub use oid::Oid; ++pub use packbuilder::{PackBuilder, PackBuilderStage}; ++pub use pathspec::{Pathspec, PathspecMatchList, PathspecFailedEntries}; ++pub use pathspec::{PathspecDiffEntries, PathspecEntries}; ++pub use patch::Patch; ++pub use proxy_options::ProxyOptions; ++pub use reference::{Reference, References, ReferenceNames}; ++pub use reflog::{Reflog, ReflogEntry, ReflogIter}; ++pub use refspec::Refspec; ++pub use remote::{Remote, RemoteConnection, Refspecs, RemoteHead, FetchOptions, PushOptions}; ++pub use remote_callbacks::{RemoteCallbacks, Credentials, TransferProgress}; ++pub use remote_callbacks::{TransportMessage, Progress, UpdateTips}; ++pub use repo::{Repository, RepositoryInitOptions}; ++pub use revspec::Revspec; ++pub use revwalk::Revwalk; ++pub use signature::Signature; ++pub use status::{StatusOptions, Statuses, StatusIter, StatusEntry, StatusShow}; ++pub use stash::{StashApplyOptions, StashCb, StashApplyProgressCb}; ++pub use submodule::Submodule; ++pub use tag::Tag; ++pub use time::{Time, IndexTime}; ++pub use tree::{Tree, TreeEntry, TreeIter}; ++pub use treebuilder::TreeBuilder; ++pub use util::IntoCString; ++ ++/// An enumeration of possible errors that can happen when working with a git ++/// repository. ++#[derive(PartialEq, Eq, Clone, Debug, Copy)] ++pub enum ErrorCode { ++ /// Generic error ++ GenericError, ++ /// Requested object could not be found ++ NotFound, ++ /// Object exists preventing operation ++ Exists, ++ /// More than one object matches ++ Ambiguous, ++ /// Output buffer too short to hold data ++ BufSize, ++ /// User-generated error ++ User, ++ /// Operation not allowed on bare repository ++ BareRepo, ++ /// HEAD refers to branch with no commits ++ UnbornBranch, ++ /// Merge in progress prevented operation ++ Unmerged, ++ /// Reference was not fast-forwardable ++ NotFastForward, ++ /// Name/ref spec was not in a valid format ++ InvalidSpec, ++ /// Checkout conflicts prevented operation ++ Conflict, ++ /// Lock file prevented operation ++ Locked, ++ /// Reference value does not match expected ++ Modified, ++ /// Authentication error ++ Auth, ++ /// Server certificate is invalid ++ Certificate, ++ /// Patch/merge has already been applied ++ Applied, ++ /// The requested peel operation is not possible ++ Peel, ++ /// Unexpected EOF ++ Eof, ++ /// Invalid operation or input ++ Invalid, ++ /// Uncommitted changes in index prevented operation ++ Uncommitted, ++ /// Operation was not valid for a directory, ++ Directory, ++} ++ ++/// An enumeration of possible categories of things that can have ++/// errors when working with a git repository. ++#[derive(PartialEq, Eq, Clone, Debug, Copy)] ++pub enum ErrorClass { ++ /// Uncategorized ++ None, ++ /// Out of memory or insufficient allocated space ++ NoMemory, ++ /// Syscall or standard system library error ++ Os, ++ /// Invalid input ++ Invalid, ++ /// Error resolving or manipulating a reference ++ Reference, ++ /// ZLib failure ++ Zlib, ++ /// Bad repository state ++ Repository, ++ /// Bad configuration ++ Config, ++ /// Regex failure ++ Regex, ++ /// Bad object ++ Odb, ++ /// Invalid index data ++ Index, ++ /// Error creating or obtaining an object ++ Object, ++ /// Network error ++ Net, ++ /// Error manpulating a tag ++ Tag, ++ /// Invalid value in tree ++ Tree, ++ /// Hashing or packing error ++ Indexer, ++ /// Error from SSL ++ Ssl, ++ /// Error involing submodules ++ Submodule, ++ /// Threading error ++ Thread, ++ /// Error manipulating a stash ++ Stash, ++ /// Checkout failure ++ Checkout, ++ /// Invalid FETCH_HEAD ++ FetchHead, ++ /// Merge failure ++ Merge, ++ /// SSH failure ++ Ssh, ++ /// Error manipulating filters ++ Filter, ++ /// Error reverting commit ++ Revert, ++ /// Error from a user callback ++ Callback, ++ /// Error cherry-picking commit ++ CherryPick, ++ /// Can't describe object ++ Describe, ++ /// Error during rebase ++ Rebase, ++ /// Filesystem-related error ++ Filesystem, ++} ++ ++/// A listing of the possible states that a repository can be in. ++#[derive(PartialEq, Eq, Clone, Debug, Copy)] ++#[allow(missing_docs)] ++pub enum RepositoryState { ++ Clean, ++ Merge, ++ Revert, ++ RevertSequence, ++ CherryPick, ++ CherryPickSequence, ++ Bisect, ++ Rebase, ++ RebaseInteractive, ++ RebaseMerge, ++ ApplyMailbox, ++ ApplyMailboxOrRebase, ++} ++ ++/// An enumeration of the possible directions for a remote. ++#[derive(Copy, Clone)] ++pub enum Direction { ++ /// Data will be fetched (read) from this remote. ++ Fetch, ++ /// Data will be pushed (written) to this remote. ++ Push, ++} ++ ++/// An enumeration of the operations that can be performed for the `reset` ++/// method on a `Repository`. ++#[derive(Copy, Clone)] ++pub enum ResetType { ++ /// Move the head to the given commit. ++ Soft, ++ /// Soft plus reset the index to the commit. ++ Mixed, ++ /// Mixed plus changes in the working tree are discarded. ++ Hard, ++} ++ ++/// An enumeration all possible kinds objects may have. ++#[derive(PartialEq, Eq, Copy, Clone, Debug)] ++pub enum ObjectType { ++ /// Any kind of git object ++ Any, ++ /// An object which corresponds to a git commit ++ Commit, ++ /// An object which corresponds to a git tree ++ Tree, ++ /// An object which corresponds to a git blob ++ Blob, ++ /// An object which corresponds to a git tag ++ Tag, ++} ++ ++/// An enumeration for the possible types of branches ++#[derive(PartialEq, Eq, Debug, Copy, Clone)] ++pub enum BranchType { ++ /// A local branch not on a remote. ++ Local, ++ /// A branch for a remote. ++ Remote, ++} ++ ++/// An enumeration of the possible priority levels of a config file. ++/// ++/// The levels corresponding to the escalation logic (higher to lower) when ++/// searching for config entries. ++#[derive(PartialEq, Eq, Debug, Copy, Clone)] ++pub enum ConfigLevel { ++ /// System-wide on Windows, for compatibility with portable git ++ ProgramData, ++ /// System-wide configuration file, e.g. /etc/gitconfig ++ System, ++ /// XDG-compatible configuration file, e.g. ~/.config/git/config ++ XDG, ++ /// User-specific configuration, e.g. ~/.gitconfig ++ Global, ++ /// Repository specific config, e.g. $PWD/.git/config ++ Local, ++ /// Application specific configuration file ++ App, ++ /// Highest level available ++ Highest, ++} ++ ++/// Merge file favor options for `MergeOptions` instruct the file-level ++/// merging functionality how to deal with conflicting regions of the files. ++#[derive(PartialEq, Eq, Debug, Copy, Clone)] ++pub enum FileFavor { ++ /// When a region of a file is changed in both branches, a conflict will be ++ /// recorded in the index so that git_checkout can produce a merge file with ++ /// conflict markers in the working directory. This is the default. ++ Normal, ++ /// When a region of a file is changed in both branches, the file created ++ /// in the index will contain the "ours" side of any conflicting region. ++ /// The index will not record a conflict. ++ Ours, ++ /// When a region of a file is changed in both branches, the file created ++ /// in the index will contain the "theirs" side of any conflicting region. ++ /// The index will not record a conflict. ++ Theirs, ++ /// When a region of a file is changed in both branches, the file created ++ /// in the index will contain each unique line from each side, which has ++ /// the result of combining both files. The index will not record a conflict. ++ Union, ++} ++ ++bitflags! { ++ /// Orderings that may be specified for Revwalk iteration. ++ pub struct Sort: u32 { ++ /// Sort the repository contents in no particular ordering. ++ /// ++ /// This sorting is arbitrary, implementation-specific, and subject to ++ /// change at any time. This is the default sorting for new walkers. ++ const SORT_NONE = raw::GIT_SORT_NONE as u32; ++ ++ /// Sort the repository contents in topological order (parents before ++ /// children). ++ /// ++ /// This sorting mode can be combined with time sorting. ++ const SORT_TOPOLOGICAL = raw::GIT_SORT_TOPOLOGICAL as u32; ++ ++ /// Sort the repository contents by commit time. ++ /// ++ /// This sorting mode can be combined with topological sorting. ++ const SORT_TIME = raw::GIT_SORT_TIME as u32; ++ ++ /// Iterate through the repository contents in reverse order. ++ /// ++ /// This sorting mode can be combined with any others. ++ const SORT_REVERSE = raw::GIT_SORT_REVERSE as u32; ++ } ++} ++ ++bitflags! { ++ /// Types of credentials that can be requested by a credential callback. ++ pub struct CredentialType: u32 { ++ #[allow(missing_docs)] ++ const USER_PASS_PLAINTEXT = raw::GIT_CREDTYPE_USERPASS_PLAINTEXT as u32; ++ #[allow(missing_docs)] ++ const SSH_KEY = raw::GIT_CREDTYPE_SSH_KEY as u32; ++ #[allow(missing_docs)] ++ const SSH_MEMORY = raw::GIT_CREDTYPE_SSH_MEMORY as u32; ++ #[allow(missing_docs)] ++ const SSH_CUSTOM = raw::GIT_CREDTYPE_SSH_CUSTOM as u32; ++ #[allow(missing_docs)] ++ const DEFAULT = raw::GIT_CREDTYPE_DEFAULT as u32; ++ #[allow(missing_docs)] ++ const SSH_INTERACTIVE = raw::GIT_CREDTYPE_SSH_INTERACTIVE as u32; ++ #[allow(missing_docs)] ++ const USERNAME = raw::GIT_CREDTYPE_USERNAME as u32; ++ } ++} ++ ++bitflags! { ++ /// Flags for the `flags` field of an IndexEntry. ++ pub struct IndexEntryFlag: u16 { ++ /// Set when the `extended_flags` field is valid. ++ const IDXENTRY_EXTENDED = raw::GIT_IDXENTRY_EXTENDED as u16; ++ /// "Assume valid" flag ++ const IDXENTRY_VALID = raw::GIT_IDXENTRY_VALID as u16; ++ } ++} ++ ++bitflags! { ++ /// Flags for the `extended_flags` field of an IndexEntry. ++ pub struct IndexEntryExtendedFlag: u16 { ++ /// An "intent to add" entry from "git add -N" ++ const IDXENTRY_INTENT_TO_ADD = raw::GIT_IDXENTRY_INTENT_TO_ADD as u16; ++ /// Skip the associated worktree file, for sparse checkouts ++ const IDXENTRY_SKIP_WORKTREE = raw::GIT_IDXENTRY_SKIP_WORKTREE as u16; ++ /// Reserved for a future on-disk extended flag ++ const IDXENTRY_EXTENDED2 = raw::GIT_IDXENTRY_EXTENDED2 as u16; ++ ++ #[allow(missing_docs)] ++ const IDXENTRY_UPDATE = raw::GIT_IDXENTRY_UPDATE as u16; ++ #[allow(missing_docs)] ++ const IDXENTRY_REMOVE = raw::GIT_IDXENTRY_REMOVE as u16; ++ #[allow(missing_docs)] ++ const IDXENTRY_UPTODATE = raw::GIT_IDXENTRY_UPTODATE as u16; ++ #[allow(missing_docs)] ++ const IDXENTRY_ADDED = raw::GIT_IDXENTRY_ADDED as u16; ++ ++ #[allow(missing_docs)] ++ const IDXENTRY_HASHED = raw::GIT_IDXENTRY_HASHED as u16; ++ #[allow(missing_docs)] ++ const IDXENTRY_UNHASHED = raw::GIT_IDXENTRY_UNHASHED as u16; ++ #[allow(missing_docs)] ++ const IDXENTRY_WT_REMOVE = raw::GIT_IDXENTRY_WT_REMOVE as u16; ++ #[allow(missing_docs)] ++ const IDXENTRY_CONFLICTED = raw::GIT_IDXENTRY_CONFLICTED as u16; ++ ++ #[allow(missing_docs)] ++ const IDXENTRY_UNPACKED = raw::GIT_IDXENTRY_UNPACKED as u16; ++ #[allow(missing_docs)] ++ const IDXENTRY_NEW_SKIP_WORKTREE = raw::GIT_IDXENTRY_NEW_SKIP_WORKTREE as u16; ++ } ++} ++ ++bitflags! { ++ /// Flags for APIs that add files matching pathspec ++ pub struct IndexAddOption: u32 { ++ #[allow(missing_docs)] ++ const ADD_DEFAULT = raw::GIT_INDEX_ADD_DEFAULT as u32; ++ #[allow(missing_docs)] ++ const ADD_FORCE = raw::GIT_INDEX_ADD_FORCE as u32; ++ #[allow(missing_docs)] ++ const ADD_DISABLE_PATHSPEC_MATCH = ++ raw::GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH as u32; ++ #[allow(missing_docs)] ++ const ADD_CHECK_PATHSPEC = raw::GIT_INDEX_ADD_CHECK_PATHSPEC as u32; ++ } ++} ++ ++bitflags! { ++ /// Flags for `Repository::open_ext` ++ pub struct RepositoryOpenFlags: u32 { ++ /// Only open the specified path; don't walk upward searching. ++ const REPOSITORY_OPEN_NO_SEARCH = raw::GIT_REPOSITORY_OPEN_NO_SEARCH as u32; ++ /// Search across filesystem boundaries. ++ const REPOSITORY_OPEN_CROSS_FS = raw::GIT_REPOSITORY_OPEN_CROSS_FS as u32; ++ /// Force opening as bare repository, and defer loading its config. ++ const REPOSITORY_OPEN_BARE = raw::GIT_REPOSITORY_OPEN_BARE as u32; ++ /// Don't try appending `/.git` to the specified repository path. ++ const REPOSITORY_OPEN_NO_DOTGIT = raw::GIT_REPOSITORY_OPEN_NO_DOTGIT as u32; ++ /// Respect environment variables like `$GIT_DIR`. ++ const REPOSITORY_OPEN_FROM_ENV = raw::GIT_REPOSITORY_OPEN_FROM_ENV as u32; ++ } ++} ++ ++bitflags! { ++ /// Flags for the return value of `Repository::revparse` ++ pub struct RevparseMode: u32 { ++ /// The spec targeted a single object ++ const REVPARSE_SINGLE = raw::GIT_REVPARSE_SINGLE as u32; ++ /// The spec targeted a range of commits ++ const REVPARSE_RANGE = raw::GIT_REVPARSE_RANGE as u32; ++ /// The spec used the `...` operator, which invokes special semantics. ++ const REVPARSE_MERGE_BASE = raw::GIT_REVPARSE_MERGE_BASE as u32; ++ } ++} ++ ++bitflags! { ++ /// The results of `merge_analysis` indicating the merge opportunities. ++ pub struct MergeAnalysis: u32 { ++ /// No merge is possible. ++ const MERGE_ANALYSIS_NONE = raw::GIT_MERGE_ANALYSIS_NONE as u32; ++ /// A "normal" merge; both HEAD and the given merge input have diverged ++ /// from their common ancestor. The divergent commits must be merged. ++ const MERGE_ANALYSIS_NORMAL = raw::GIT_MERGE_ANALYSIS_NORMAL as u32; ++ /// All given merge inputs are reachable from HEAD, meaning the ++ /// repository is up-to-date and no merge needs to be performed. ++ const MERGE_ANALYSIS_UP_TO_DATE = raw::GIT_MERGE_ANALYSIS_UP_TO_DATE as u32; ++ /// The given merge input is a fast-forward from HEAD and no merge ++ /// needs to be performed. Instead, the client can check out the ++ /// given merge input. ++ const MERGE_ANALYSIS_FASTFORWARD = raw::GIT_MERGE_ANALYSIS_FASTFORWARD as u32; ++ /// The HEAD of the current repository is "unborn" and does not point to ++ /// a valid commit. No merge can be performed, but the caller may wish ++ /// to simply set HEAD to the target commit(s). ++ const MERGE_ANALYSIS_UNBORN = raw::GIT_MERGE_ANALYSIS_UNBORN as u32; ++ } ++} ++ ++bitflags! { ++ /// The user's stated preference for merges. ++ pub struct MergePreference: u32 { ++ /// No configuration was found that suggests a preferred behavior for ++ /// merge. ++ const MERGE_PREFERENCE_NONE = raw::GIT_MERGE_PREFERENCE_NONE as u32; ++ /// There is a `merge.ff=false` configuration setting, suggesting that ++ /// the user does not want to allow a fast-forward merge. ++ const MERGE_PREFERENCE_NO_FAST_FORWARD = raw::GIT_MERGE_PREFERENCE_NO_FASTFORWARD as u32; ++ /// There is a `merge.ff=only` configuration setting, suggesting that ++ /// the user only wants fast-forward merges. ++ const MERGE_PREFERENCE_FASTFORWARD_ONLY = raw::GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY as u32; ++ } ++} ++ ++#[cfg(test)] #[macro_use] mod test; ++#[macro_use] mod panic; ++mod call; ++mod util; ++ ++pub mod build; ++pub mod cert; ++pub mod string_array; ++pub mod oid_array; ++pub mod transport; ++ ++mod blame; ++mod blob; ++mod branch; ++mod buf; ++mod commit; ++mod config; ++mod cred; ++mod describe; ++mod diff; ++mod error; ++mod index; ++mod merge; ++mod message; ++mod note; ++mod object; ++mod oid; ++mod packbuilder; ++mod pathspec; ++mod patch; ++mod proxy_options; ++mod reference; ++mod reflog; ++mod refspec; ++mod remote; ++mod remote_callbacks; ++mod repo; ++mod revspec; ++mod revwalk; ++mod signature; ++mod status; ++mod submodule; ++mod stash; ++mod tag; ++mod time; ++mod tree; ++mod treebuilder; ++ ++fn init() { ++ static INIT: Once = ONCE_INIT; ++ ++ INIT.call_once(|| { ++ openssl_env_init(); ++ }); ++ ++ raw::init(); ++} ++ ++#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), feature = "https"))] ++fn openssl_env_init() { ++ extern crate openssl_probe; ++ ++ // Currently, libgit2 leverages OpenSSL for SSL support when cloning ++ // repositories over HTTPS. This means that we're picking up an OpenSSL ++ // dependency on non-Windows platforms (where it has its own HTTPS ++ // subsystem). As a result, we need to link to OpenSSL. ++ // ++ // Now actually *linking* to OpenSSL isn't so hard. We just need to make ++ // sure to use pkg-config to discover any relevant system dependencies for ++ // differences between distributions like CentOS and Ubuntu. The actual ++ // trickiness comes about when we start *distributing* the resulting ++ // binaries. Currently Cargo is distributed in binary form as nightlies, ++ // which means we're distributing a binary with OpenSSL linked in. ++ // ++ // For historical reasons, the Linux nightly builder is running a CentOS ++ // distribution in order to have as much ABI compatibility with other ++ // distributions as possible. Sadly, however, this compatibility does not ++ // extend to OpenSSL. Currently OpenSSL has two major versions, 0.9 and 1.0, ++ // which are incompatible (many ABI differences). The CentOS builder we ++ // build on has version 1.0, as do most distributions today. Some still have ++ // 0.9, however. This means that if we are to distribute the binaries built ++ // by the CentOS machine, we would only be compatible with OpenSSL 1.0 and ++ // we would fail to run (a dynamic linker error at runtime) on systems with ++ // only 9.8 installed (hopefully). ++ // ++ // But wait, the plot thickens! Apparently CentOS has dubbed their OpenSSL ++ // library as `libssl.so.10`, notably the `10` is included at the end. On ++ // the other hand Ubuntu, for example, only distributes `libssl.so`. This ++ // means that the binaries created at CentOS are hard-wired to probe for a ++ // file called `libssl.so.10` at runtime (using the LD_LIBRARY_PATH), which ++ // will not be found on ubuntu. The conclusion of this is that binaries ++ // built on CentOS cannot be distributed to Ubuntu and run successfully. ++ // ++ // There are a number of sneaky things we could do, including, but not ++ // limited to: ++ // ++ // 1. Create a shim program which runs "just before" cargo runs. The ++ // responsibility of this shim program would be to locate `libssl.so`, ++ // whatever it's called, on the current system, make sure there's a ++ // symlink *somewhere* called `libssl.so.10`, and then set up ++ // LD_LIBRARY_PATH and run the actual cargo. ++ // ++ // This approach definitely seems unconventional, and is borderline ++ // overkill for this problem. It's also dubious if we can find a ++ // libssl.so reliably on the target system. ++ // ++ // 2. Somehow re-work the CentOS installation so that the linked-against ++ // library is called libssl.so instead of libssl.so.10 ++ // ++ // The problem with this approach is that systems with 0.9 installed will ++ // start to silently fail, due to also having libraries called libssl.so ++ // (probably symlinked under a more appropriate version). ++ // ++ // 3. Compile Cargo against both OpenSSL 1.0 *and* OpenSSL 0.9, and ++ // distribute both. Also make sure that the linked-against name of the ++ // library is `libssl.so`. At runtime we determine which version is ++ // installed, and we then the appropriate binary. ++ // ++ // This approach clearly has drawbacks in terms of infrastructure and ++ // feasibility. ++ // ++ // 4. Build a nightly of Cargo for each distribution we'd like to support. ++ // You would then pick the appropriate Cargo nightly to install locally. ++ // ++ // So, with all this in mind, the decision was made to *statically* link ++ // OpenSSL. This solves any problem of relying on a downstream OpenSSL ++ // version being available. This does, however, open a can of worms related ++ // to security issues. It's generally a good idea to dynamically link ++ // OpenSSL as you'll get security updates over time without having to do ++ // anything (the system administrator will update the local openssl ++ // package). By statically linking, we're forfeiting this feature. ++ // ++ // The conclusion was made it is likely appropriate for the Cargo nightlies ++ // to statically link OpenSSL, but highly encourage distributions and ++ // packagers of Cargo to dynamically link OpenSSL. Packagers are targeting ++ // one system and are distributing to only that system, so none of the ++ // problems mentioned above would arise. ++ // ++ // In order to support this, a new package was made: openssl-static-sys. ++ // This package currently performs a fairly simple task: ++ // ++ // 1. Run pkg-config to discover where openssl is installed. ++ // 2. If openssl is installed in a nonstandard location, *and* static copies ++ // of the libraries are available, copy them to $OUT_DIR. ++ // ++ // This library will bring in libssl.a and libcrypto.a into the local build, ++ // allowing them to be picked up by this crate. This allows us to configure ++ // our own buildbots to have pkg-config point to these local pre-built ++ // copies of a static OpenSSL (with very few dependencies) while allowing ++ // most other builds of Cargo to naturally dynamically link OpenSSL. ++ // ++ // So in summary, if you're with me so far, we've statically linked OpenSSL ++ // to the Cargo binary (or any binary, for that matter) and we're ready to ++ // distribute it to *all* linux distributions. Remember that our original ++ // intent for openssl was for HTTPS support, which implies that we need some ++ // for of CA certificate store to validate certificates. This is normally ++ // installed in a standard system location. ++ // ++ // Unfortunately, as one might imagine, OpenSSL is configured for where this ++ // standard location is at *build time*, but it often varies widely ++ // per-system. Consequently, it was discovered that OpenSSL will respect the ++ // SSL_CERT_FILE and SSL_CERT_DIR environment variables in order to assist ++ // in discovering the location of this file (hurray!). ++ // ++ // So, finally getting to the point, this function solely exists to support ++ // our static builds of OpenSSL by probing for the "standard system ++ // location" of certificates and setting relevant environment variable to ++ // point to them. ++ // ++ // Ah, and as a final note, this is only a problem on Linux, not on OS X. On ++ // OS X the OpenSSL binaries are stable enough that we can just rely on ++ // dynamic linkage (plus they have some weird modifications to OpenSSL which ++ // means we wouldn't want to link statically). ++ openssl_probe::init_ssl_cert_env_vars(); ++} ++ ++#[cfg(any(windows, target_os = "macos", target_os = "ios", not(feature = "https")))] ++fn openssl_env_init() {} ++ ++unsafe fn opt_bytes<'a, T>(_anchor: &'a T, ++ c: *const libc::c_char) -> Option<&'a [u8]> { ++ if c.is_null() { ++ None ++ } else { ++ Some(CStr::from_ptr(c).to_bytes()) ++ } ++} ++ ++fn opt_cstr(o: Option) -> Result, Error> { ++ match o { ++ Some(s) => s.into_c_string().map(Some), ++ None => Ok(None) ++ } ++} ++ ++impl ObjectType { ++ /// Convert an object type to its string representation. ++ pub fn str(&self) -> &'static str { ++ unsafe { ++ let ptr = call!(raw::git_object_type2string(*self)) as *const _; ++ let data = CStr::from_ptr(ptr).to_bytes(); ++ str::from_utf8(data).unwrap() ++ } ++ } ++ ++ /// Determine if the given git_otype is a valid loose object type. ++ pub fn is_loose(&self) -> bool { ++ unsafe { (call!(raw::git_object_typeisloose(*self)) == 1) } ++ } ++ ++ /// Convert a raw git_otype to an ObjectType ++ pub fn from_raw(raw: raw::git_otype) -> Option { ++ match raw { ++ raw::GIT_OBJ_ANY => Some(ObjectType::Any), ++ raw::GIT_OBJ_COMMIT => Some(ObjectType::Commit), ++ raw::GIT_OBJ_TREE => Some(ObjectType::Tree), ++ raw::GIT_OBJ_BLOB => Some(ObjectType::Blob), ++ raw::GIT_OBJ_TAG => Some(ObjectType::Tag), ++ _ => None, ++ } ++ } ++ ++ /// Convert this kind into its raw representation ++ pub fn raw(&self) -> raw::git_otype { ++ call::convert(self) ++ } ++ ++ /// Convert a string object type representation to its object type. ++ pub fn from_str(s: &str) -> Option { ++ let raw = unsafe { call!(raw::git_object_string2type(CString::new(s).unwrap())) }; ++ ObjectType::from_raw(raw) ++ } ++} ++ ++impl fmt::Display for ObjectType { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ self.str().fmt(f) ++ } ++} ++ ++impl ConfigLevel { ++ /// Converts a raw configuration level to a ConfigLevel ++ pub fn from_raw(raw: raw::git_config_level_t) -> ConfigLevel { ++ match raw { ++ raw::GIT_CONFIG_LEVEL_PROGRAMDATA => ConfigLevel::ProgramData, ++ raw::GIT_CONFIG_LEVEL_SYSTEM => ConfigLevel::System, ++ raw::GIT_CONFIG_LEVEL_XDG => ConfigLevel::XDG, ++ raw::GIT_CONFIG_LEVEL_GLOBAL => ConfigLevel::Global, ++ raw::GIT_CONFIG_LEVEL_LOCAL => ConfigLevel::Local, ++ raw::GIT_CONFIG_LEVEL_APP => ConfigLevel::App, ++ raw::GIT_CONFIG_HIGHEST_LEVEL => ConfigLevel::Highest, ++ n => panic!("unknown config level: {}", n), ++ } ++ } ++} ++ ++bitflags! { ++ /// Status flags for a single file ++ /// ++ /// A combination of these values will be returned to indicate the status of ++ /// a file. Status compares the working directory, the index, and the ++ /// current HEAD of the repository. The `STATUS_INDEX_*` set of flags ++ /// represents the status of file in the index relative to the HEAD, and the ++ /// `STATUS_WT_*` set of flags represent the status of the file in the ++ /// working directory relative to the index. ++ pub struct Status: u32 { ++ #[allow(missing_docs)] ++ const STATUS_CURRENT = raw::GIT_STATUS_CURRENT as u32; ++ ++ #[allow(missing_docs)] ++ const STATUS_INDEX_NEW = raw::GIT_STATUS_INDEX_NEW as u32; ++ #[allow(missing_docs)] ++ const STATUS_INDEX_MODIFIED = raw::GIT_STATUS_INDEX_MODIFIED as u32; ++ #[allow(missing_docs)] ++ const STATUS_INDEX_DELETED = raw::GIT_STATUS_INDEX_DELETED as u32; ++ #[allow(missing_docs)] ++ const STATUS_INDEX_RENAMED = raw::GIT_STATUS_INDEX_RENAMED as u32; ++ #[allow(missing_docs)] ++ const STATUS_INDEX_TYPECHANGE = raw::GIT_STATUS_INDEX_TYPECHANGE as u32; ++ ++ #[allow(missing_docs)] ++ const STATUS_WT_NEW = raw::GIT_STATUS_WT_NEW as u32; ++ #[allow(missing_docs)] ++ const STATUS_WT_MODIFIED = raw::GIT_STATUS_WT_MODIFIED as u32; ++ #[allow(missing_docs)] ++ const STATUS_WT_DELETED = raw::GIT_STATUS_WT_DELETED as u32; ++ #[allow(missing_docs)] ++ const STATUS_WT_TYPECHANGE = raw::GIT_STATUS_WT_TYPECHANGE as u32; ++ #[allow(missing_docs)] ++ const STATUS_WT_RENAMED = raw::GIT_STATUS_WT_RENAMED as u32; ++ ++ #[allow(missing_docs)] ++ const STATUS_IGNORED = raw::GIT_STATUS_IGNORED as u32; ++ #[allow(missing_docs)] ++ const STATUS_CONFLICTED = raw::GIT_STATUS_CONFLICTED as u32; ++ } ++} ++ ++bitflags! { ++ /// Mode options for RepositoryInitOptions ++ pub struct RepositoryInitMode: u32 { ++ /// Use permissions configured by umask - the default ++ const REPOSITORY_INIT_SHARED_UMASK = ++ raw::GIT_REPOSITORY_INIT_SHARED_UMASK as u32; ++ /// Use `--shared=group` behavior, chmod'ing the new repo to be ++ /// group writable and \"g+sx\" for sticky group assignment ++ const REPOSITORY_INIT_SHARED_GROUP = ++ raw::GIT_REPOSITORY_INIT_SHARED_GROUP as u32; ++ /// Use `--shared=all` behavior, adding world readability. ++ const REPOSITORY_INIT_SHARED_ALL = ++ raw::GIT_REPOSITORY_INIT_SHARED_ALL as u32; ++ } ++} ++ ++/// What type of change is described by a `DiffDelta`? ++#[derive(Copy, Clone, Debug, PartialEq, Eq)] ++pub enum Delta { ++ /// No changes ++ Unmodified, ++ /// Entry does not exist in old version ++ Added, ++ /// Entry does not exist in new version ++ Deleted, ++ /// Entry content changed between old and new ++ Modified, ++ /// Entry was renamed wbetween old and new ++ Renamed, ++ /// Entry was copied from another old entry ++ Copied, ++ /// Entry is ignored item in workdir ++ Ignored, ++ /// Entry is untracked item in workdir ++ Untracked, ++ /// Type of entry changed between old and new ++ Typechange, ++ /// Entry is unreadable ++ Unreadable, ++ /// Entry in the index is conflicted ++ Conflicted, ++} ++ ++bitflags! { ++ /// Return codes for submodule status. ++ /// ++ /// A combination of these flags will be returned to describe the status of a ++ /// submodule. Depending on the "ignore" property of the submodule, some of ++ /// the flags may never be returned because they indicate changes that are ++ /// supposed to be ignored. ++ /// ++ /// Submodule info is contained in 4 places: the HEAD tree, the index, config ++ /// files (both .git/config and .gitmodules), and the working directory. Any ++ /// or all of those places might be missing information about the submodule ++ /// depending on what state the repo is in. We consider all four places to ++ /// build the combination of status flags. ++ /// ++ /// There are four values that are not really status, but give basic info ++ /// about what sources of submodule data are available. These will be ++ /// returned even if ignore is set to "ALL". ++ /// ++ /// * IN_HEAD - superproject head contains submodule ++ /// * IN_INDEX - superproject index contains submodule ++ /// * IN_CONFIG - superproject gitmodules has submodule ++ /// * IN_WD - superproject workdir has submodule ++ /// ++ /// The following values will be returned so long as ignore is not "ALL". ++ /// ++ /// * INDEX_ADDED - in index, not in head ++ /// * INDEX_DELETED - in head, not in index ++ /// * INDEX_MODIFIED - index and head don't match ++ /// * WD_UNINITIALIZED - workdir contains empty directory ++ /// * WD_ADDED - in workdir, not index ++ /// * WD_DELETED - in index, not workdir ++ /// * WD_MODIFIED - index and workdir head don't match ++ /// ++ /// The following can only be returned if ignore is "NONE" or "UNTRACKED". ++ /// ++ /// * WD_INDEX_MODIFIED - submodule workdir index is dirty ++ /// * WD_WD_MODIFIED - submodule workdir has modified files ++ /// ++ /// Lastly, the following will only be returned for ignore "NONE". ++ /// ++ /// * WD_UNTRACKED - wd contains untracked files ++ pub struct SubmoduleStatus: u32 { ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_IN_HEAD = ++ raw::GIT_SUBMODULE_STATUS_IN_HEAD as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_IN_INDEX = ++ raw::GIT_SUBMODULE_STATUS_IN_INDEX as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_IN_CONFIG = ++ raw::GIT_SUBMODULE_STATUS_IN_CONFIG as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_IN_WD = ++ raw::GIT_SUBMODULE_STATUS_IN_WD as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_INDEX_ADDED = ++ raw::GIT_SUBMODULE_STATUS_INDEX_ADDED as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_INDEX_DELETED = ++ raw::GIT_SUBMODULE_STATUS_INDEX_DELETED as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_INDEX_MODIFIED = ++ raw::GIT_SUBMODULE_STATUS_INDEX_MODIFIED as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_WD_UNINITIALIZED = ++ raw::GIT_SUBMODULE_STATUS_WD_UNINITIALIZED as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_WD_ADDED = ++ raw::GIT_SUBMODULE_STATUS_WD_ADDED as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_WD_DELETED = ++ raw::GIT_SUBMODULE_STATUS_WD_DELETED as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_WD_MODIFIED = ++ raw::GIT_SUBMODULE_STATUS_WD_MODIFIED as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_WD_INDEX_MODIFIED = ++ raw::GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_WD_WD_MODIFIED = ++ raw::GIT_SUBMODULE_STATUS_WD_WD_MODIFIED as u32; ++ #[allow(missing_docs)] ++ const SUBMODULE_STATUS_WD_UNTRACKED = ++ raw::GIT_SUBMODULE_STATUS_WD_UNTRACKED as u32; ++ } ++ ++} ++ ++/// Submodule ignore values ++/// ++/// These values represent settings for the `submodule.$name.ignore` ++/// configuration value which says how deeply to look at the working ++/// directory when getting the submodule status. ++pub enum SubmoduleIgnore { ++ /// Use the submodule's configuration ++ Unspecified, ++ /// Any change or untracked file is considered dirty ++ None, ++ /// Only dirty if tracked files have changed ++ Untracked, ++ /// Only dirty if HEAD has moved ++ Dirty, ++ /// Never dirty ++ All, ++} ++ ++bitflags! { ++ /// ... ++ pub struct PathspecFlags: u32 { ++ /// Use the default pathspec matching configuration. ++ const PATHSPEC_DEFAULT = raw::GIT_PATHSPEC_DEFAULT as u32; ++ /// Force matching to ignore case, otherwise matching will use native ++ /// case sensitivity fo the platform filesystem. ++ const PATHSPEC_IGNORE_CASE = raw::GIT_PATHSPEC_IGNORE_CASE as u32; ++ /// Force case sensitive matches, otherwise match will use the native ++ /// case sensitivity of the platform filesystem. ++ const PATHSPEC_USE_CASE = raw::GIT_PATHSPEC_USE_CASE as u32; ++ /// Disable glob patterns and just use simple string comparison for ++ /// matching. ++ const PATHSPEC_NO_GLOB = raw::GIT_PATHSPEC_NO_GLOB as u32; ++ /// Means that match functions return the error code `NotFound` if no ++ /// matches are found. By default no matches is a success. ++ const PATHSPEC_NO_MATCH_ERROR = raw::GIT_PATHSPEC_NO_MATCH_ERROR as u32; ++ /// Means that the list returned should track which patterns matched ++ /// which files so that at the end of the match we can identify patterns ++ /// that did not match any files. ++ const PATHSPEC_FIND_FAILURES = raw::GIT_PATHSPEC_FIND_FAILURES as u32; ++ /// Means that the list returned does not need to keep the actual ++ /// matching filenames. Use this to just test if there were any matches ++ /// at all or in combination with `PATHSPEC_FAILURES` to validate a ++ /// pathspec. ++ const PATHSPEC_FAILURES_ONLY = raw::GIT_PATHSPEC_FAILURES_ONLY as u32; ++ } ++} ++ ++bitflags! { ++ /// Types of notifications emitted from checkouts. ++ pub struct CheckoutNotificationType: u32 { ++ /// Notification about a conflict. ++ const CHECKOUT_NOTIFICATION_CONFLICT = raw::GIT_CHECKOUT_NOTIFY_CONFLICT as u32; ++ /// Notification about a dirty file. ++ const CHECKOUT_NOTIFICATION_DIRTY = raw::GIT_CHECKOUT_NOTIFY_DIRTY as u32; ++ /// Notification about an updated file. ++ const CHECKOUT_NOTIFICATION_UPDATED = raw::GIT_CHECKOUT_NOTIFY_UPDATED as u32; ++ /// Notification about an untracked file. ++ const CHECKOUT_NOTIFICATION_UNTRACKED = raw::GIT_CHECKOUT_NOTIFY_UNTRACKED as u32; ++ /// Notification about an ignored file. ++ const CHECKOUT_NOTIFICATION_IGNORED = raw::GIT_CHECKOUT_NOTIFY_IGNORED as u32; ++ } ++} ++ ++/// Possible output formats for diff data ++#[derive(Copy, Clone)] ++pub enum DiffFormat { ++ /// full git diff ++ Patch, ++ /// just the headers of the patch ++ PatchHeader, ++ /// like git diff --raw ++ Raw, ++ /// like git diff --name-only ++ NameOnly, ++ /// like git diff --name-status ++ NameStatus, ++} ++ ++bitflags! { ++ /// Formatting options for diff stats ++ pub struct DiffStatsFormat: raw::git_diff_stats_format_t { ++ /// Don't generate any stats ++ const DIFF_STATS_NONE = raw::GIT_DIFF_STATS_NONE; ++ /// Equivalent of `--stat` in git ++ const DIFF_STATS_FULL = raw::GIT_DIFF_STATS_FULL; ++ /// Equivalent of `--shortstat` in git ++ const DIFF_STATS_SHORT = raw::GIT_DIFF_STATS_SHORT; ++ /// Equivalent of `--numstat` in git ++ const DIFF_STATS_NUMBER = raw::GIT_DIFF_STATS_NUMBER; ++ /// Extended header information such as creations, renames and mode ++ /// changes, equivalent of `--summary` in git ++ const DIFF_STATS_INCLUDE_SUMMARY = ++ raw::GIT_DIFF_STATS_INCLUDE_SUMMARY; ++ } ++} ++ ++/// Automatic tag following options. ++pub enum AutotagOption { ++ /// Use the setting from the remote's configuration ++ Unspecified, ++ /// Ask the server for tags pointing to objects we're already downloading ++ Auto, ++ /// Don't ask for any tags beyond the refspecs ++ None, ++ /// Ask for all the tags ++ All, ++} ++ ++/// Configuration for how pruning is done on a fetch ++pub enum FetchPrune { ++ /// Use the setting from the configuration ++ Unspecified, ++ /// Force pruning on ++ On, ++ /// Force pruning off ++ Off, ++} ++ ++#[allow(missing_docs)] ++#[derive(Debug)] ++pub enum StashApplyProgress { ++ /// None ++ None, ++ /// Loading the stashed data from the object database ++ LoadingStash, ++ /// The stored index is being analyzed ++ AnalyzeIndex, ++ /// The modified files are being analyzed ++ AnalyzeModified, ++ /// The untracked and ignored files are being analyzed ++ AnalyzeUntracked, ++ /// The untracked files are being written to disk ++ CheckoutUntracked, ++ /// The modified files are being written to disk ++ CheckoutModified, ++ /// The stash was applied successfully ++ Done, ++} ++ ++bitflags! { ++ #[allow(missing_docs)] ++ pub struct StashApplyFlags: u32 { ++ #[allow(missing_docs)] ++ const STASH_APPLY_DEFAULT = raw::GIT_STASH_APPLY_DEFAULT as u32; ++ /// Try to reinstate not only the working tree's changes, ++ /// but also the index's changes. ++ const STASH_APPLY_REINSTATE_INDEX = raw::GIT_STASH_APPLY_REINSTATE_INDEX as u32; ++ } ++} ++ ++bitflags! { ++ #[allow(missing_docs)] ++ pub struct StashFlags: u32 { ++ #[allow(missing_docs)] ++ const STASH_DEFAULT = raw::GIT_STASH_DEFAULT as u32; ++ /// All changes already added to the index are left intact in ++ /// the working directory ++ const STASH_KEEP_INDEX = raw::GIT_STASH_KEEP_INDEX as u32; ++ /// All untracked files are also stashed and then cleaned up ++ /// from the working directory ++ const STASH_INCLUDE_UNTRACKED = raw::GIT_STASH_INCLUDE_UNTRACKED as u32; ++ /// All ignored files are also stashed and then cleaned up from ++ /// the working directory ++ const STASH_INCLUDE_IGNORED = raw::GIT_STASH_INCLUDE_IGNORED as u32; ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use super::ObjectType; ++ ++ #[test] ++ fn convert() { ++ assert_eq!(ObjectType::Blob.str(), "blob"); ++ assert_eq!(ObjectType::from_str("blob"), Some(ObjectType::Blob)); ++ assert!(ObjectType::Blob.is_loose()); ++ } ++ ++} diff --cc vendor/git2-0.6.8/src/merge.rs index 000000000,000000000..15089403e new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/merge.rs @@@ -1,0 -1,0 +1,160 @@@ ++use std::marker; ++use std::mem; ++use libc::c_uint; ++ ++use {raw, Oid, Commit, FileFavor}; ++use util::Binding; ++use call::Convert; ++ ++/// A structure to represent an annotated commit, the input to merge and rebase. ++/// ++/// An annotated commit contains information about how it was looked up, which ++/// may be useful for functions like merge or rebase to provide context to the ++/// operation. ++pub struct AnnotatedCommit<'repo> { ++ raw: *mut raw::git_annotated_commit, ++ _marker: marker::PhantomData>, ++} ++ ++/// Options to specify when merging. ++pub struct MergeOptions { ++ raw: raw::git_merge_options, ++} ++ ++impl<'repo> AnnotatedCommit<'repo> { ++ /// Gets the commit ID that the given git_annotated_commit refers to ++ pub fn id(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_annotated_commit_id(self.raw)) } ++ } ++} ++ ++impl Default for MergeOptions { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl MergeOptions { ++ /// Creates a default set of merge options. ++ pub fn new() -> MergeOptions { ++ let mut opts = MergeOptions { ++ raw: unsafe { mem::zeroed() }, ++ }; ++ assert_eq!(unsafe { ++ raw::git_merge_init_options(&mut opts.raw, 1) ++ }, 0); ++ opts ++ } ++ ++ /// Detect file renames ++ pub fn find_renames(&mut self, find: bool) -> &mut MergeOptions { ++ if find { ++ self.raw.flags |= raw::GIT_MERGE_FIND_RENAMES; ++ } else { ++ self.raw.flags &= !raw::GIT_MERGE_FIND_RENAMES; ++ } ++ self ++ } ++ ++ /// Similarity to consider a file renamed (default 50) ++ pub fn rename_threshold(&mut self, thresh: u32) -> &mut MergeOptions { ++ self.raw.rename_threshold = thresh; ++ self ++ } ++ ++ /// Maximum similarity sources to examine for renames (default 200). ++ /// If the number of rename candidates (add / delete pairs) is greater ++ /// than this value, inexact rename detection is aborted. This setting ++ /// overrides the `merge.renameLimit` configuration value. ++ pub fn target_limit(&mut self, limit: u32) -> &mut MergeOptions { ++ self.raw.target_limit = limit as c_uint; ++ self ++ } ++ ++ /// Maximum number of times to merge common ancestors to build a ++ /// virtual merge base when faced with criss-cross merges. When ++ /// this limit is reached, the next ancestor will simply be used ++ /// instead of attempting to merge it. The default is unlimited. ++ pub fn recursion_limit(&mut self, limit: u32) -> &mut MergeOptions { ++ self.raw.recursion_limit = limit as c_uint; ++ self ++ } ++ ++ /// Specify a side to favor for resolving conflicts ++ pub fn file_favor(&mut self, favor: FileFavor) -> &mut MergeOptions { ++ self.raw.file_favor = favor.convert(); ++ self ++ } ++ ++ fn flag(&mut self, opt: raw::git_merge_file_flag_t, val: bool) -> &mut MergeOptions { ++ if val { ++ self.raw.file_flags |= opt; ++ } else { ++ self.raw.file_flags &= !opt; ++ } ++ self ++ } ++ ++ /// Create standard conflicted merge files ++ pub fn standard_style(&mut self, standard: bool) -> &mut MergeOptions { ++ self.flag(raw::GIT_MERGE_FILE_STYLE_MERGE, standard) ++ } ++ ++ /// Create diff3-style file ++ pub fn diff3_style(&mut self, diff3: bool) -> &mut MergeOptions { ++ self.flag(raw::GIT_MERGE_FILE_STYLE_DIFF3, diff3) ++ } ++ ++ /// Condense non-alphanumeric regions for simplified diff file ++ pub fn simplify_alnum(&mut self, simplify: bool) -> &mut MergeOptions { ++ self.flag(raw::GIT_MERGE_FILE_SIMPLIFY_ALNUM, simplify) ++ } ++ ++ /// Ignore all whitespace ++ pub fn ignore_whitespace(&mut self, ignore: bool) -> &mut MergeOptions { ++ self.flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE, ignore) ++ } ++ ++ /// Ignore changes in amount of whitespace ++ pub fn ignore_whitespace_change(&mut self, ignore: bool) -> &mut MergeOptions { ++ self.flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE, ignore) ++ } ++ ++ /// Ignore whitespace at end of line ++ pub fn ignore_whitespace_eol(&mut self, ignore: bool) -> &mut MergeOptions { ++ self.flag(raw::GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL, ignore) ++ } ++ ++ /// Use the "patience diff" algorithm ++ pub fn patience(&mut self, patience: bool) -> &mut MergeOptions { ++ self.flag(raw::GIT_MERGE_FILE_DIFF_PATIENCE, patience) ++ } ++ ++ /// Take extra time to find minimal diff ++ pub fn minimal(&mut self, minimal: bool) -> &mut MergeOptions { ++ self.flag(raw::GIT_MERGE_FILE_DIFF_MINIMAL, minimal) ++ } ++ ++ /// Acquire a pointer to the underlying raw options. ++ pub unsafe fn raw(&self) -> *const raw::git_merge_options { ++ &self.raw as *const _ ++ } ++} ++ ++impl<'repo> Binding for AnnotatedCommit<'repo> { ++ type Raw = *mut raw::git_annotated_commit; ++ unsafe fn from_raw(raw: *mut raw::git_annotated_commit) ++ -> AnnotatedCommit<'repo> { ++ AnnotatedCommit { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_annotated_commit { self.raw } ++} ++ ++impl<'repo> Drop for AnnotatedCommit<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_annotated_commit_free(self.raw) } ++ } ++} diff --cc vendor/git2-0.6.8/src/message.rs index 000000000,000000000..96cdd589c new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/message.rs @@@ -1,0 -1,0 +1,52 @@@ ++use std::ffi::CString; ++ ++use libc::{c_char, c_int}; ++ ++use {raw, Buf, Error, IntoCString}; ++use util::Binding; ++ ++/// Clean up a message, removing extraneous whitespace, and ensure that the ++/// message ends with a newline. If `comment_char` is `Some`, also remove comment ++/// lines starting with that character. ++pub fn message_prettify(message: T, comment_char: Option) ++ -> Result { ++ _message_prettify(try!(message.into_c_string()), comment_char) ++} ++ ++fn _message_prettify(message: CString, comment_char: Option) ++ -> Result { ++ let ret = Buf::new(); ++ unsafe { ++ try_call!(raw::git_message_prettify(ret.raw(), message, ++ comment_char.is_some() as c_int, ++ comment_char.unwrap_or(0) as c_char)); ++ } ++ Ok(ret.as_str().unwrap().to_string()) ++} ++ ++/// The default comment character for `message_prettify` ('#') ++pub const DEFAULT_COMMENT_CHAR: Option = Some(b'#'); ++ ++#[cfg(test)] ++mod tests { ++ use {message_prettify, DEFAULT_COMMENT_CHAR}; ++ ++ #[test] ++ fn prettify() { ++ // This does not attempt to duplicate the extensive tests for ++ // git_message_prettify in libgit2, just a few representative values to ++ // make sure the interface works as expected. ++ assert_eq!(message_prettify("1\n\n\n2", None).unwrap(), ++ "1\n\n2\n"); ++ assert_eq!(message_prettify("1\n\n\n2\n\n\n3", None).unwrap(), ++ "1\n\n2\n\n3\n"); ++ assert_eq!(message_prettify("1\n# comment\n# more", None).unwrap(), ++ "1\n# comment\n# more\n"); ++ assert_eq!(message_prettify("1\n# comment\n# more", ++ DEFAULT_COMMENT_CHAR).unwrap(), ++ "1\n"); ++ assert_eq!(message_prettify("1\n; comment\n; more", ++ Some(';' as u8)).unwrap(), ++ "1\n"); ++ } ++} diff --cc vendor/git2-0.6.8/src/note.rs index 000000000,000000000..bbd94a517 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/note.rs @@@ -1,0 -1,0 +1,125 @@@ ++use std::marker; ++use std::str; ++ ++use {raw, signature, Signature, Oid, Repository, Error}; ++use util::Binding; ++ ++/// A structure representing a [note][note] in git. ++/// ++/// [note]: http://git-scm.com/blog/2010/08/25/notes.html ++pub struct Note<'repo> { ++ raw: *mut raw::git_note, ++ ++ // Hmm, the current libgit2 version does not have this inside of it, but ++ // perhaps it's a good idea to keep it around? Can always remove it later I ++ // suppose... ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++/// An iterator over all of the notes within a repository. ++pub struct Notes<'repo> { ++ raw: *mut raw::git_note_iterator, ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++impl<'repo> Note<'repo> { ++ /// Get the note author ++ pub fn author(&self) -> Signature { ++ unsafe { ++ signature::from_raw_const(self, raw::git_note_author(&*self.raw)) ++ } ++ } ++ ++ /// Get the note committer ++ pub fn committer(&self) -> Signature { ++ unsafe { ++ signature::from_raw_const(self, raw::git_note_committer(&*self.raw)) ++ } ++ } ++ ++ /// Get the note message, in bytes. ++ pub fn message_bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, raw::git_note_message(&*self.raw)).unwrap() } ++ } ++ ++ /// Get the note message as a string, returning `None` if it is not UTF-8. ++ pub fn message(&self) -> Option<&str> { ++ str::from_utf8(self.message_bytes()).ok() ++ } ++ ++ /// Get the note object's id ++ pub fn id(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_note_id(&*self.raw)) } ++ } ++} ++ ++impl<'repo> Binding for Note<'repo> { ++ type Raw = *mut raw::git_note; ++ unsafe fn from_raw(raw: *mut raw::git_note) -> Note<'repo> { ++ Note { raw: raw, _marker: marker::PhantomData, } ++ } ++ fn raw(&self) -> *mut raw::git_note { self.raw } ++} ++ ++ ++impl<'repo> Drop for Note<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_note_free(self.raw); } ++ } ++} ++ ++impl<'repo> Binding for Notes<'repo> { ++ type Raw = *mut raw::git_note_iterator; ++ unsafe fn from_raw(raw: *mut raw::git_note_iterator) -> Notes<'repo> { ++ Notes { raw: raw, _marker: marker::PhantomData, } ++ } ++ fn raw(&self) -> *mut raw::git_note_iterator { self.raw } ++} ++ ++impl<'repo> Iterator for Notes<'repo> { ++ type Item = Result<(Oid, Oid), Error>; ++ fn next(&mut self) -> Option> { ++ let mut note_id = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ let mut annotated_id = note_id; ++ unsafe { ++ try_call_iter!(raw::git_note_next(&mut note_id, &mut annotated_id, ++ self.raw)); ++ Some(Ok((Binding::from_raw(¬e_id as *const _), ++ Binding::from_raw(&annotated_id as *const _)))) ++ } ++ } ++} ++ ++impl<'repo> Drop for Notes<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_note_iterator_free(self.raw); } ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ assert!(repo.notes(None).is_err()); ++ ++ let sig = repo.signature().unwrap(); ++ let head = repo.head().unwrap().target().unwrap(); ++ let note = repo.note(&sig, &sig, None, head, "foo", false).unwrap(); ++ assert_eq!(repo.notes(None).unwrap().count(), 1); ++ ++ let note_obj = repo.find_note(None, head).unwrap(); ++ assert_eq!(note_obj.id(), note); ++ assert_eq!(note_obj.message(), Some("foo")); ++ ++ let (a, b) = repo.notes(None).unwrap().next().unwrap().unwrap(); ++ assert_eq!(a, note); ++ assert_eq!(b, head); ++ ++ assert_eq!(repo.note_default_ref().unwrap(), "refs/notes/commits"); ++ ++ assert_eq!(sig.name(), note_obj.author().name()); ++ assert_eq!(sig.name(), note_obj.committer().name()); ++ assert!(sig.when() == note_obj.committer().when()); ++ } ++} diff --cc vendor/git2-0.6.8/src/object.rs index 000000000,000000000..4af5ee71c new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/object.rs @@@ -1,0 -1,0 +1,174 @@@ ++use std::marker; ++use std::mem; ++use std::ptr; ++ ++use {raw, Oid, ObjectType, Error, Buf, Commit, Tag, Blob, Tree, Repository}; ++use {Describe, DescribeOptions}; ++use util::Binding; ++ ++/// A structure to represent a git [object][1] ++/// ++/// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects ++pub struct Object<'repo> { ++ raw: *mut raw::git_object, ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++impl<'repo> Object<'repo> { ++ /// Get the id (SHA1) of a repository object ++ pub fn id(&self) -> Oid { ++ unsafe { ++ Binding::from_raw(raw::git_object_id(&*self.raw)) ++ } ++ } ++ ++ /// Get the object type of an object. ++ /// ++ /// If the type is unknown, then `None` is returned. ++ pub fn kind(&self) -> Option { ++ ObjectType::from_raw(unsafe { raw::git_object_type(&*self.raw) }) ++ } ++ ++ /// Recursively peel an object until an object of the specified type is met. ++ /// ++ /// If you pass `Any` as the target type, then the object will be ++ /// peeled until the type changes (e.g. a tag will be chased until the ++ /// referenced object is no longer a tag). ++ pub fn peel(&self, kind: ObjectType) -> Result, Error> { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_object_peel(&mut raw, &*self.raw(), kind)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Get a short abbreviated OID string for the object ++ /// ++ /// This starts at the "core.abbrev" length (default 7 characters) and ++ /// iteratively extends to a longer string if that length is ambiguous. The ++ /// result will be unambiguous (at least until new objects are added to the ++ /// repository). ++ pub fn short_id(&self) -> Result { ++ unsafe { ++ let buf = Buf::new(); ++ try_call!(raw::git_object_short_id(buf.raw(), &*self.raw())); ++ Ok(buf) ++ } ++ } ++ ++ /// Attempt to view this object as a commit. ++ /// ++ /// Returns `None` if the object is not actually a commit. ++ pub fn as_commit(&self) -> Option<&Commit<'repo>> { ++ self.cast(ObjectType::Commit) ++ } ++ ++ /// Attempt to consume this object and return a commit. ++ /// ++ /// Returns `Err(self)` if this object is not actually a commit. ++ pub fn into_commit(self) -> Result, Object<'repo>> { ++ self.cast_into(ObjectType::Commit) ++ } ++ ++ /// Attempt to view this object as a tag. ++ /// ++ /// Returns `None` if the object is not actually a tag. ++ pub fn as_tag(&self) -> Option<&Tag<'repo>> { ++ self.cast(ObjectType::Tag) ++ } ++ ++ /// Attempt to consume this object and return a tag. ++ /// ++ /// Returns `Err(self)` if this object is not actually a tag. ++ pub fn into_tag(self) -> Result, Object<'repo>> { ++ self.cast_into(ObjectType::Tag) ++ } ++ ++ /// Attempt to view this object as a tree. ++ /// ++ /// Returns `None` if the object is not actually a tree. ++ pub fn as_tree(&self) -> Option<&Tree<'repo>> { ++ self.cast(ObjectType::Tree) ++ } ++ ++ /// Attempt to consume this object and return a tree. ++ /// ++ /// Returns `Err(self)` if this object is not actually a tree. ++ pub fn into_tree(self) -> Result, Object<'repo>> { ++ self.cast_into(ObjectType::Tree) ++ } ++ ++ /// Attempt to view this object as a blob. ++ /// ++ /// Returns `None` if the object is not actually a blob. ++ pub fn as_blob(&self) -> Option<&Blob<'repo>> { ++ self.cast(ObjectType::Blob) ++ } ++ ++ /// Attempt to consume this object and return a blob. ++ /// ++ /// Returns `Err(self)` if this object is not actually a blob. ++ pub fn into_blob(self) -> Result, Object<'repo>> { ++ self.cast_into(ObjectType::Blob) ++ } ++ ++ /// Describes a commit ++ /// ++ /// Performs a describe operation on this commitish object. ++ pub fn describe(&self, opts: &DescribeOptions) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_describe_commit(&mut ret, self.raw, opts.raw())); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ fn cast(&self, kind: ObjectType) -> Option<&T> { ++ assert_eq!(mem::size_of::(), mem::size_of::()); ++ if self.kind() == Some(kind) { ++ unsafe { Some(&*(self as *const _ as *const T)) } ++ } else { ++ None ++ } ++ } ++ ++ fn cast_into(self, kind: ObjectType) -> Result> { ++ assert_eq!(mem::size_of_val(&self), mem::size_of::()); ++ if self.kind() == Some(kind) { ++ Ok(unsafe { ++ let other = ptr::read(&self as *const _ as *const T); ++ mem::forget(self); ++ other ++ }) ++ } else { ++ Err(self) ++ } ++ } ++} ++ ++impl<'repo> Clone for Object<'repo> { ++ fn clone(&self) -> Object<'repo> { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ let rc = raw::git_object_dup(&mut raw, self.raw); ++ assert_eq!(rc, 0); ++ Binding::from_raw(raw) ++ } ++ } ++} ++ ++impl<'repo> Binding for Object<'repo> { ++ type Raw = *mut raw::git_object; ++ ++ unsafe fn from_raw(raw: *mut raw::git_object) -> Object<'repo> { ++ Object { raw: raw, _marker: marker::PhantomData, } ++ } ++ fn raw(&self) -> *mut raw::git_object { self.raw } ++} ++ ++impl<'repo> Drop for Object<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_object_free(self.raw) } ++ } ++} diff --cc vendor/git2-0.6.8/src/oid.rs index 000000000,000000000..26e0cc70c new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/oid.rs @@@ -1,0 -1,0 +1,140 @@@ ++use std::fmt; ++use std::cmp::Ordering; ++use std::hash::{Hasher, Hash}; ++use std::str; ++use libc; ++ ++use {raw, Error}; ++use util::Binding; ++ ++/// Unique identity of any object (commit, tree, blob, tag). ++#[derive(Copy, Clone)] ++pub struct Oid { ++ raw: raw::git_oid, ++} ++ ++impl Oid { ++ /// Parse a hex-formatted object id into an Oid structure. ++ /// ++ /// If the string is not a valid 40-character hex string, an error is ++ /// returned. ++ pub fn from_str(s: &str) -> Result { ++ ::init(); ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_oid_fromstrn(&mut raw, ++ s.as_bytes().as_ptr() ++ as *const libc::c_char, ++ s.len() as libc::size_t)); ++ } ++ Ok(Oid { raw: raw }) ++ } ++ ++ /// Parse a raw object id into an Oid structure. ++ /// ++ /// If the array given is not 20 bytes in length, an error is returned. ++ pub fn from_bytes(bytes: &[u8]) -> Result { ++ ::init(); ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ if bytes.len() != raw::GIT_OID_RAWSZ { ++ Err(Error::from_str("raw byte array must be 20 bytes")) ++ } else { ++ unsafe { raw::git_oid_fromraw(&mut raw, bytes.as_ptr()) } ++ Ok(Oid { raw: raw }) ++ } ++ } ++ ++ /// View this OID as a byte-slice 20 bytes in length. ++ pub fn as_bytes(&self) -> &[u8] { &self.raw.id } ++ ++ /// Test if this OID is all zeros. ++ pub fn is_zero(&self) -> bool { ++ unsafe { raw::git_oid_iszero(&self.raw) == 1 } ++ } ++} ++ ++impl Binding for Oid { ++ type Raw = *const raw::git_oid; ++ ++ unsafe fn from_raw(oid: *const raw::git_oid) -> Oid { ++ Oid { raw: *oid } ++ } ++ fn raw(&self) -> *const raw::git_oid { &self.raw as *const _ } ++} ++ ++impl fmt::Debug for Oid { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ fmt::Display::fmt(self, f) ++ } ++} ++ ++impl fmt::Display for Oid { ++ /// Hex-encode this Oid into a formatter. ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ let mut dst = [0u8; raw::GIT_OID_HEXSZ + 1]; ++ unsafe { ++ raw::git_oid_tostr(dst.as_mut_ptr() as *mut libc::c_char, ++ dst.len() as libc::size_t, &self.raw); ++ } ++ let s = &dst[..dst.iter().position(|&a| a == 0).unwrap()]; ++ str::from_utf8(s).unwrap().fmt(f) ++ } ++} ++ ++impl str::FromStr for Oid { ++ type Err = Error; ++ ++ /// Parse a hex-formatted object id into an Oid structure. ++ /// ++ /// If the string is not a valid 40-character hex string, an error is ++ /// returned. ++ fn from_str(s: &str) -> Result { ++ Oid::from_str(s) ++ } ++} ++ ++impl PartialEq for Oid { ++ fn eq(&self, other: &Oid) -> bool { ++ unsafe { raw::git_oid_equal(&self.raw, &other.raw) != 0 } ++ } ++} ++impl Eq for Oid {} ++ ++impl PartialOrd for Oid { ++ fn partial_cmp(&self, other: &Oid) -> Option { ++ Some(self.cmp(other)) ++ } ++} ++ ++impl Ord for Oid { ++ fn cmp(&self, other: &Oid) -> Ordering { ++ match unsafe { raw::git_oid_cmp(&self.raw, &other.raw) } { ++ 0 => Ordering::Equal, ++ n if n < 0 => Ordering::Less, ++ _ => Ordering::Greater, ++ } ++ } ++} ++ ++impl Hash for Oid { ++ fn hash(&self, into: &mut H) { ++ self.raw.id.hash(into) ++ } ++} ++ ++impl AsRef<[u8]> for Oid { ++ fn as_ref(&self) -> &[u8] { self.as_bytes() } ++} ++ ++#[cfg(test)] ++mod tests { ++ use super::Oid; ++ ++ #[test] ++ fn conversions() { ++ assert!(Oid::from_str("foo").is_err()); ++ assert!(Oid::from_str("decbf2be529ab6557d5429922251e5ee36519817").is_ok()); ++ assert!(Oid::from_bytes(b"foo").is_err()); ++ assert!(Oid::from_bytes(b"00000000000000000000").is_ok()); ++ } ++} diff --cc vendor/git2-0.6.8/src/oid_array.rs index 000000000,000000000..7533357dc new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/oid_array.rs @@@ -1,0 -1,0 +1,44 @@@ ++//! Bindings to libgit2's raw `git_strarray` type ++ ++use std::ops::Deref; ++ ++use oid::Oid; ++use raw; ++use util::Binding; ++use std::slice; ++use std::mem; ++ ++/// An oid array structure used by libgit2 ++/// ++/// Some apis return arrays of oids which originate from libgit2. This ++/// wrapper type behaves a little like `Vec<&Oid>` but does so without copying ++/// the underlying Oids until necessary. ++pub struct OidArray { ++ raw: raw::git_oidarray, ++} ++ ++impl Deref for OidArray { ++ type Target = [Oid]; ++ ++ fn deref(&self) -> &[Oid] { ++ unsafe { ++ debug_assert_eq!(mem::size_of::(), mem::size_of_val(&*self.raw.ids)); ++ ++ slice::from_raw_parts(self.raw.ids as *const Oid, self.raw.count as usize) ++ } ++ } ++} ++ ++impl Binding for OidArray { ++ type Raw = raw::git_oidarray; ++ unsafe fn from_raw(raw: raw::git_oidarray) -> OidArray { ++ OidArray { raw: raw } ++ } ++ fn raw(&self) -> raw::git_oidarray { self.raw } ++} ++ ++impl Drop for OidArray { ++ fn drop(&mut self) { ++ unsafe { raw::git_oidarray_free(&mut self.raw) } ++ } ++} diff --cc vendor/git2-0.6.8/src/packbuilder.rs index 000000000,000000000..e3ed5132b new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/packbuilder.rs @@@ -1,0 -1,0 +1,386 @@@ ++use std::marker; ++use std::ptr; ++use std::slice; ++use libc::{c_int, c_uint, c_void, size_t}; ++ ++use {raw, panic, Repository, Error, Oid, Revwalk, Buf}; ++use util::Binding; ++ ++/// Stages that are reported by the `PackBuilder` progress callback. ++pub enum PackBuilderStage { ++ /// Adding objects to the pack ++ AddingObjects, ++ /// Deltafication of the pack ++ Deltafication, ++} ++ ++pub type ProgressCb<'a> = FnMut(PackBuilderStage, u32, u32) -> bool + 'a; ++pub type ForEachCb<'a> = FnMut(&[u8]) -> bool + 'a; ++ ++/// A builder for creating a packfile ++pub struct PackBuilder<'repo> { ++ raw: *mut raw::git_packbuilder, ++ progress: Option>>>, ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++impl<'repo> PackBuilder<'repo> { ++ /// Insert a single object. For an optimal pack it's mandatory to insert ++ /// objects in recency order, commits followed by trees and blobs. ++ pub fn insert_object(&mut self, id: Oid, name: Option<&str>) ++ -> Result<(), Error> { ++ let name = try!(::opt_cstr(name)); ++ unsafe { ++ try_call!(raw::git_packbuilder_insert(self.raw, id.raw(), name)); ++ } ++ Ok(()) ++ } ++ ++ /// Insert a root tree object. This will add the tree as well as all ++ /// referenced trees and blobs. ++ pub fn insert_tree(&mut self, id: Oid) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_packbuilder_insert_tree(self.raw, id.raw())); ++ } ++ Ok(()) ++ } ++ ++ /// Insert a commit object. This will add a commit as well as the completed ++ /// referenced tree. ++ pub fn insert_commit(&mut self, id: Oid) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_packbuilder_insert_commit(self.raw, id.raw())); ++ } ++ Ok(()) ++ } ++ ++ /// Insert objects as given by the walk. Those commits and all objects they ++ /// reference will be inserted into the packbuilder. ++ pub fn insert_walk(&mut self, walk: &mut Revwalk) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_packbuilder_insert_walk(self.raw, walk.raw())); ++ } ++ Ok(()) ++ } ++ ++ /// Recursively insert an object and its referenced objects. Insert the ++ /// object as well as any object it references. ++ pub fn insert_recursive(&mut self, id: Oid, name: Option<&str>) ++ -> Result<(), Error> { ++ let name = try!(::opt_cstr(name)); ++ unsafe { ++ try_call!(raw::git_packbuilder_insert_recur(self.raw, ++ id.raw(), ++ name)); ++ } ++ Ok(()) ++ } ++ ++ /// Write the contents of the packfile to an in-memory buffer. The contents ++ /// of the buffer will become a valid packfile, even though there will be ++ /// no attached index. ++ pub fn write_buf(&mut self, buf: &mut Buf) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_packbuilder_write_buf(buf.raw(), self.raw)); ++ } ++ Ok(()) ++ } ++ ++ /// Create the new pack and pass each object to the callback. ++ pub fn foreach(&mut self, mut cb: F) -> Result<(), Error> ++ where F: FnMut(&[u8]) -> bool ++ { ++ let mut cb = &mut cb as &mut ForEachCb; ++ let ptr = &mut cb as *mut _; ++ unsafe { ++ try_call!(raw::git_packbuilder_foreach(self.raw, ++ foreach_c, ++ ptr as *mut _)); ++ } ++ Ok(()) ++ } ++ ++ /// `progress` will be called with progress information during pack ++ /// building. Be aware that this is called inline with pack building ++ /// operations, so performance may be affected. ++ /// ++ /// There can only be one progress callback attached, this will replace any ++ /// existing one. See `unset_progress_callback` to remove the current ++ /// progress callback without attaching a new one. ++ pub fn set_progress_callback(&mut self, progress: F) -> Result<(), Error> ++ where F: FnMut(PackBuilderStage, u32, u32) -> bool + 'repo ++ { ++ let mut progress = Box::new(Box::new(progress) as Box); ++ let ptr = &mut *progress as *mut _; ++ let progress_c = Some(progress_c as raw::git_packbuilder_progress); ++ unsafe { ++ try_call!(raw::git_packbuilder_set_callbacks(self.raw, ++ progress_c, ++ ptr as *mut _)); ++ } ++ self.progress = Some(progress); ++ Ok(()) ++ } ++ ++ /// Remove the current progress callback. See `set_progress_callback` to ++ /// set the progress callback. ++ pub fn unset_progress_callback(&mut self) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_packbuilder_set_callbacks(self.raw, ++ None, ++ ptr::null_mut())); ++ self.progress = None; ++ } ++ Ok(()) ++ } ++ ++ /// Get the total number of objects the packbuilder will write out. ++ pub fn object_count(&self) -> usize { ++ unsafe { raw::git_packbuilder_object_count(self.raw) } ++ } ++ ++ /// Get the number of objects the packbuilder has already written out. ++ pub fn written(&self) -> usize { ++ unsafe { raw::git_packbuilder_written(self.raw) } ++ } ++ ++ /// Get the packfile's hash. A packfile's name is derived from the sorted ++ /// hashing of all object names. This is only correct after the packfile ++ /// has been written. ++ pub fn hash(&self) -> Option { ++ if self.object_count() == 0 { ++ unsafe { ++ Some(Binding::from_raw(raw::git_packbuilder_hash(self.raw))) ++ } ++ } else { ++ None ++ } ++ } ++} ++ ++impl<'repo> Binding for PackBuilder<'repo> { ++ type Raw = *mut raw::git_packbuilder; ++ unsafe fn from_raw(ptr: *mut raw::git_packbuilder) -> PackBuilder<'repo> { ++ PackBuilder { ++ raw: ptr, ++ progress: None, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_packbuilder { ++ self.raw ++ } ++} ++ ++impl<'repo> Drop for PackBuilder<'repo> { ++ fn drop(&mut self) { ++ unsafe { ++ raw::git_packbuilder_set_callbacks(self.raw, None, ptr::null_mut()); ++ raw::git_packbuilder_free(self.raw); ++ } ++ } ++} ++ ++impl Binding for PackBuilderStage { ++ type Raw = raw::git_packbuilder_stage_t; ++ unsafe fn from_raw(raw: raw::git_packbuilder_stage_t) -> PackBuilderStage { ++ match raw { ++ raw::GIT_PACKBUILDER_ADDING_OBJECTS => PackBuilderStage::AddingObjects, ++ raw::GIT_PACKBUILDER_DELTAFICATION => PackBuilderStage::Deltafication, ++ _ => panic!("Unknown git diff binary kind"), ++ } ++ } ++ fn raw(&self) -> raw::git_packbuilder_stage_t { ++ match *self { ++ PackBuilderStage::AddingObjects => raw::GIT_PACKBUILDER_ADDING_OBJECTS, ++ PackBuilderStage::Deltafication => raw::GIT_PACKBUILDER_DELTAFICATION, ++ } ++ } ++} ++ ++extern fn foreach_c(buf: *const c_void, ++ size: size_t, ++ data: *mut c_void) ++ -> c_int { ++ unsafe { ++ let buf = slice::from_raw_parts(buf as *const u8, size as usize); ++ ++ let r = panic::wrap(|| { ++ let data = data as *mut &mut ForEachCb; ++ (*data)(buf) ++ }); ++ if r == Some(true) { ++ 0 ++ } else { ++ -1 ++ } ++ } ++} ++ ++extern fn progress_c(stage: raw::git_packbuilder_stage_t, ++ current: c_uint, ++ total: c_uint, ++ data: *mut c_void) ++ -> c_int { ++ unsafe { ++ let stage = Binding::from_raw(stage); ++ ++ let r = panic::wrap(|| { ++ let data = data as *mut Box; ++ (*data)(stage, current, total) ++ }); ++ if r == Some(true) { ++ 0 ++ } else { ++ -1 ++ } ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::fs::File; ++ use std::path::Path; ++ use {Buf, Repository, Oid}; ++ ++ fn commit(repo: &Repository) -> (Oid, Oid) { ++ let mut index = t!(repo.index()); ++ let root = repo.path().parent().unwrap(); ++ t!(File::create(&root.join("foo"))); ++ t!(index.add_path(Path::new("foo"))); ++ ++ let tree_id = t!(index.write_tree()); ++ let tree = t!(repo.find_tree(tree_id)); ++ let sig = t!(repo.signature()); ++ let head_id = t!(repo.refname_to_id("HEAD")); ++ let parent = t!(repo.find_commit(head_id)); ++ let commit = t!(repo.commit(Some("HEAD"), ++ &sig, ++ &sig, ++ "commit", ++ &tree, ++ &[&parent])); ++ (commit, tree_id) ++ } ++ ++ fn pack_header(len: u8) -> Vec { ++ [].into_iter() ++ .chain(b"PACK") // signature ++ .chain(&[0, 0, 0, 2]) // version number ++ .chain(&[0, 0, 0, len]) // number of objects ++ .cloned().collect::>() ++ } ++ ++ fn empty_pack_header() -> Vec { ++ pack_header(0).iter() ++ .chain(&[0x02, 0x9d, 0x08, 0x82, 0x3b, // ^ ++ 0xd8, 0xa8, 0xea, 0xb5, 0x10, // | SHA-1 of the zero ++ 0xad, 0x6a, 0xc7, 0x5c, 0x82, // | object pack header ++ 0x3c, 0xfd, 0x3e, 0xd3, 0x1e]) // v ++ .cloned().collect::>() ++ } ++ ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ let _builder = t!(repo.packbuilder()); ++ } ++ ++ #[test] ++ fn smoke_write_buf() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut builder = t!(repo.packbuilder()); ++ let mut buf = Buf::new(); ++ t!(builder.write_buf(&mut buf)); ++ assert!(builder.hash().unwrap().is_zero()); ++ assert_eq!(&*buf, &*empty_pack_header()); ++ } ++ ++ #[test] ++ fn smoke_foreach() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut builder = t!(repo.packbuilder()); ++ let mut buf = Vec::::new(); ++ t!(builder.foreach(|bytes| { ++ buf.extend(bytes); ++ true ++ })); ++ assert_eq!(&*buf, &*empty_pack_header()); ++ } ++ ++ #[test] ++ fn insert_write_buf() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut builder = t!(repo.packbuilder()); ++ let mut buf = Buf::new(); ++ let (commit, _tree) = commit(&repo); ++ t!(builder.insert_object(commit, None)); ++ assert_eq!(builder.object_count(), 1); ++ t!(builder.write_buf(&mut buf)); ++ // Just check that the correct number of objects are written ++ assert_eq!(&buf[0..12], &*pack_header(1)); ++ } ++ ++ #[test] ++ fn insert_tree_write_buf() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut builder = t!(repo.packbuilder()); ++ let mut buf = Buf::new(); ++ let (_commit, tree) = commit(&repo); ++ // will insert the tree itself and the blob, 2 objects ++ t!(builder.insert_tree(tree)); ++ assert_eq!(builder.object_count(), 2); ++ t!(builder.write_buf(&mut buf)); ++ // Just check that the correct number of objects are written ++ assert_eq!(&buf[0..12], &*pack_header(2)); ++ } ++ ++ #[test] ++ fn insert_commit_write_buf() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut builder = t!(repo.packbuilder()); ++ let mut buf = Buf::new(); ++ let (commit, _tree) = commit(&repo); ++ // will insert the commit, its tree and the blob, 3 objects ++ t!(builder.insert_commit(commit)); ++ assert_eq!(builder.object_count(), 3); ++ t!(builder.write_buf(&mut buf)); ++ // Just check that the correct number of objects are written ++ assert_eq!(&buf[0..12], &*pack_header(3)); ++ } ++ ++ #[test] ++ fn progress_callback() { ++ let mut progress_called = false; ++ { ++ let (_td, repo) = ::test::repo_init(); ++ let mut builder = t!(repo.packbuilder()); ++ let (commit, _tree) = commit(&repo); ++ t!(builder.set_progress_callback(|_, _, _| { ++ progress_called = true; ++ true ++ })); ++ t!(builder.insert_commit(commit)); ++ t!(builder.write_buf(&mut Buf::new())); ++ } ++ assert_eq!(progress_called, true); ++ } ++ ++ #[test] ++ fn clear_progress_callback() { ++ let mut progress_called = false; ++ { ++ let (_td, repo) = ::test::repo_init(); ++ let mut builder = t!(repo.packbuilder()); ++ let (commit, _tree) = commit(&repo); ++ t!(builder.set_progress_callback(|_, _, _| { ++ progress_called = true; ++ true ++ })); ++ t!(builder.unset_progress_callback()); ++ t!(builder.insert_commit(commit)); ++ t!(builder.write_buf(&mut Buf::new())); ++ } ++ assert_eq!(progress_called, false); ++ } ++} diff --cc vendor/git2-0.6.8/src/panic.rs index 000000000,000000000..35f2c0939 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/panic.rs @@@ -1,0 -1,0 +1,55 @@@ ++use std::any::Any; ++use std::cell::RefCell; ++ ++thread_local!(static LAST_ERROR: RefCell>> = { ++ RefCell::new(None) ++}); ++ ++#[cfg(feature = "unstable")] ++pub fn wrap T + ::std::panic::UnwindSafe>(f: F) -> Option { ++ use std::panic; ++ if LAST_ERROR.with(|slot| slot.borrow().is_some()) { ++ return None ++ } ++ match panic::catch_unwind(f) { ++ Ok(ret) => Some(ret), ++ Err(e) => { ++ LAST_ERROR.with(move |slot| { ++ *slot.borrow_mut() = Some(e); ++ }); ++ None ++ } ++ } ++} ++ ++#[cfg(not(feature = "unstable"))] ++pub fn wrap T>(f: F) -> Option { ++ struct Bomb { ++ enabled: bool, ++ } ++ impl Drop for Bomb { ++ fn drop(&mut self) { ++ if !self.enabled { ++ return ++ } ++ panic!("callback has panicked, and continuing to unwind into C \ ++ is not safe, so aborting the process"); ++ ++ } ++ } ++ let mut bomb = Bomb { enabled: true }; ++ let ret = Some(f()); ++ bomb.enabled = false; ++ ret ++} ++ ++pub fn check() { ++ let err = LAST_ERROR.with(|slot| slot.borrow_mut().take()); ++ if let Some(err) = err { ++ panic!(err) ++ } ++} ++ ++pub fn panicked() -> bool { ++ LAST_ERROR.with(|slot| slot.borrow().is_some()) ++} diff --cc vendor/git2-0.6.8/src/patch.rs index 000000000,000000000..19f774d77 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/patch.rs @@@ -1,0 -1,0 +1,202 @@@ ++use std::path::Path; ++use std::ptr; ++use libc::{c_char, c_int, c_void}; ++ ++use {raw, Blob, Buf, Diff, DiffDelta, DiffHunk, DiffLine, DiffOptions, Error}; ++use diff::{LineCb, print_cb}; ++use util::{Binding, into_opt_c_string}; ++ ++/// A structure representing the text changes in a single diff delta. ++/// ++/// This is an opaque structure. ++pub struct Patch { ++ raw: *mut raw::git_patch, ++} ++ ++unsafe impl Send for Patch {} ++ ++impl Binding for Patch { ++ type Raw = *mut raw::git_patch; ++ unsafe fn from_raw(raw: Self::Raw) -> Patch { ++ Patch { raw: raw } ++ } ++ fn raw(&self) -> Self::Raw { self.raw } ++} ++ ++impl Drop for Patch { ++ fn drop(&mut self) { ++ unsafe { raw::git_patch_free(self.raw) } ++ } ++} ++ ++impl Patch { ++ /// Return a Patch for one file in a Diff. ++ /// ++ /// Returns Ok(None) for an unchanged or binary file. ++ pub fn from_diff(diff: &Diff, idx: usize) -> Result, Error> { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_patch_from_diff(&mut ret, diff.raw(), idx)); ++ Ok(Binding::from_raw_opt(ret)) ++ } ++ } ++ ++ /// Generate a Patch by diffing two blobs. ++ pub fn from_blobs(old_blob: &Blob, ++ old_path: Option<&Path>, ++ new_blob: &Blob, ++ new_path: Option<&Path>, ++ opts: Option<&mut DiffOptions>) ++ -> Result ++ { ++ let mut ret = ptr::null_mut(); ++ let old_path = try!(into_opt_c_string(old_path)); ++ let new_path = try!(into_opt_c_string(new_path)); ++ unsafe { ++ try_call!(raw::git_patch_from_blobs(&mut ret, ++ old_blob.raw(), ++ old_path, ++ new_blob.raw(), ++ new_path, ++ opts.map(|s| s.raw()))); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Generate a Patch by diffing a blob and a buffer. ++ pub fn from_blob_and_buffer(old_blob: &Blob, ++ old_path: Option<&Path>, ++ new_buffer: &[u8], ++ new_path: Option<&Path>, ++ opts: Option<&mut DiffOptions>) ++ -> Result ++ { ++ let mut ret = ptr::null_mut(); ++ let old_path = try!(into_opt_c_string(old_path)); ++ let new_path = try!(into_opt_c_string(new_path)); ++ unsafe { ++ try_call!(raw::git_patch_from_blob_and_buffer(&mut ret, ++ old_blob.raw(), ++ old_path, ++ new_buffer.as_ptr() as *const c_char, ++ new_buffer.len(), ++ new_path, ++ opts.map(|s| s.raw()))); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Generate a Patch by diffing two buffers. ++ pub fn from_buffers(old_buffer: &[u8], ++ old_path: Option<&Path>, ++ new_buffer: &[u8], ++ new_path: Option<&Path>, ++ opts: Option<&mut DiffOptions>) ++ -> Result ++ { ++ let mut ret = ptr::null_mut(); ++ let old_path = try!(into_opt_c_string(old_path)); ++ let new_path = try!(into_opt_c_string(new_path)); ++ unsafe { ++ try_call!(raw::git_patch_from_buffers(&mut ret, ++ old_buffer.as_ptr() as *const c_void, ++ old_buffer.len(), ++ old_path, ++ new_buffer.as_ptr() as *const c_char, ++ new_buffer.len(), ++ new_path, ++ opts.map(|s| s.raw()))); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Get the DiffDelta associated with the Patch. ++ pub fn delta(&self) -> DiffDelta { ++ unsafe { ++ Binding::from_raw(raw::git_patch_get_delta(self.raw) as *mut _) ++ } ++ } ++ ++ /// Get the number of hunks in the Patch. ++ pub fn num_hunks(&self) -> usize { ++ unsafe { ++ raw::git_patch_num_hunks(self.raw) ++ } ++ } ++ ++ /// Get the number of lines of context, additions, and deletions in the Patch. ++ pub fn line_stats(&self) -> Result<(usize, usize, usize), Error> { ++ let mut context = 0; ++ let mut additions = 0; ++ let mut deletions = 0; ++ unsafe { ++ try_call!(raw::git_patch_line_stats(&mut context, ++ &mut additions, ++ &mut deletions, ++ self.raw)); ++ } ++ Ok((context, additions, deletions)) ++ } ++ ++ /// Get a DiffHunk and its total line count from the Patch. ++ pub fn hunk(&mut self, hunk_idx: usize) -> Result<(DiffHunk, usize), Error> { ++ let mut ret = ptr::null(); ++ let mut lines = 0; ++ unsafe { ++ try_call!(raw::git_patch_get_hunk(&mut ret, &mut lines, self.raw, hunk_idx)); ++ Ok((Binding::from_raw(ret), lines)) ++ } ++ } ++ ++ /// Get the number of lines in a hunk. ++ pub fn num_lines_in_hunk(&self, hunk_idx: usize) -> Result { ++ unsafe { ++ Ok(try_call!(raw::git_patch_num_lines_in_hunk(self.raw, hunk_idx)) as usize) ++ } ++ } ++ ++ /// Get a DiffLine from a hunk of the Patch. ++ pub fn line_in_hunk(&mut self, ++ hunk_idx: usize, ++ line_of_hunk: usize) -> Result { ++ let mut ret = ptr::null(); ++ unsafe { ++ try_call!(raw::git_patch_get_line_in_hunk(&mut ret, ++ self.raw, ++ hunk_idx, ++ line_of_hunk)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Get the size of a Patch's diff data in bytes. ++ pub fn size(&self, ++ include_context: bool, ++ include_hunk_headers: bool, ++ include_file_headers: bool) -> usize { ++ unsafe { ++ raw::git_patch_size(self.raw, ++ include_context as c_int, ++ include_hunk_headers as c_int, ++ include_file_headers as c_int) ++ } ++ } ++ ++ /// Print the Patch to text via a callback. ++ pub fn print(&mut self, mut line_cb: &mut LineCb) -> Result<(), Error> { ++ let ptr = &mut line_cb as *mut _ as *mut c_void; ++ unsafe { ++ try_call!(raw::git_patch_print(self.raw, print_cb, ptr)); ++ Ok(()) ++ } ++ } ++ ++ /// Get the Patch text as a Buf. ++ pub fn to_buf(&mut self) -> Result { ++ let buf = Buf::new(); ++ unsafe { ++ try_call!(raw::git_patch_to_buf(buf.raw(), self.raw)); ++ } ++ Ok(buf) ++ } ++} diff --cc vendor/git2-0.6.8/src/pathspec.rs index 000000000,000000000..e1ee3d225 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/pathspec.rs @@@ -1,0 -1,0 +1,301 @@@ ++use std::iter::IntoIterator; ++use std::marker; ++use std::ops::Range; ++use std::path::Path; ++use std::ptr; ++use libc::size_t; ++ ++use {raw, Error, Diff, Tree, PathspecFlags, Index, Repository, DiffDelta, IntoCString}; ++use util::Binding; ++ ++/// Structure representing a compiled pathspec used for matching against various ++/// structures. ++pub struct Pathspec { ++ raw: *mut raw::git_pathspec, ++} ++ ++/// List of filenames matching a pathspec. ++pub struct PathspecMatchList<'ps> { ++ raw: *mut raw::git_pathspec_match_list, ++ _marker: marker::PhantomData<&'ps Pathspec>, ++} ++ ++/// Iterator over the matched paths in a pathspec. ++pub struct PathspecEntries<'list> { ++ range: Range, ++ list: &'list PathspecMatchList<'list>, ++} ++ ++/// Iterator over the matching diff deltas. ++pub struct PathspecDiffEntries<'list> { ++ range: Range, ++ list: &'list PathspecMatchList<'list>, ++} ++ ++/// Iterator over the failed list of pathspec items that did not match. ++pub struct PathspecFailedEntries<'list> { ++ range: Range, ++ list: &'list PathspecMatchList<'list>, ++} ++ ++impl Pathspec { ++ /// Creates a new pathspec from a list of specs to match against. ++ pub fn new(specs: I) -> Result ++ where T: IntoCString, I: IntoIterator { ++ let (_a, _b, arr) = try!(::util::iter2cstrs(specs)); ++ unsafe { ++ let mut ret = ptr::null_mut(); ++ try_call!(raw::git_pathspec_new(&mut ret, &arr)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Match a pathspec against files in a diff. ++ /// ++ /// The list returned contains the list of all matched filenames (unless you ++ /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the ++ /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is ++ /// specified. ++ pub fn match_diff(&self, diff: &Diff, flags: PathspecFlags) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_pathspec_match_diff(&mut ret, diff.raw(), ++ flags.bits(), self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Match a pathspec against files in a tree. ++ /// ++ /// The list returned contains the list of all matched filenames (unless you ++ /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the ++ /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is ++ /// specified. ++ pub fn match_tree(&self, tree: &Tree, flags: PathspecFlags) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_pathspec_match_tree(&mut ret, tree.raw(), ++ flags.bits(), self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// This matches the pathspec against the files in the repository index. ++ /// ++ /// The list returned contains the list of all matched filenames (unless you ++ /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the ++ /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is ++ /// specified. ++ pub fn match_index(&self, index: &Index, flags: PathspecFlags) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_pathspec_match_index(&mut ret, index.raw(), ++ flags.bits(), self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Match a pathspec against the working directory of a repository. ++ /// ++ /// This matches the pathspec against the current files in the working ++ /// directory of the repository. It is an error to invoke this on a bare ++ /// repo. This handles git ignores (i.e. ignored files will not be ++ /// considered to match the pathspec unless the file is tracked in the ++ /// index). ++ /// ++ /// The list returned contains the list of all matched filenames (unless you ++ /// pass `PATHSPEC_FAILURES_ONLY` in the flags) and may also contain the ++ /// list of pathspecs with no match if the `PATHSPEC_FIND_FAILURES` flag is ++ /// specified. ++ pub fn match_workdir(&self, repo: &Repository, flags: PathspecFlags) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_pathspec_match_workdir(&mut ret, repo.raw(), ++ flags.bits(), self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Try to match a path against a pathspec ++ /// ++ /// Unlike most of the other pathspec matching functions, this will not fall ++ /// back on the native case-sensitivity for your platform. You must ++ /// explicitly pass flags to control case sensitivity or else this will fall ++ /// back on being case sensitive. ++ pub fn matches_path(&self, path: &Path, flags: PathspecFlags) -> bool { ++ let path = path.into_c_string().unwrap(); ++ unsafe { ++ raw::git_pathspec_matches_path(&*self.raw, flags.bits(), ++ path.as_ptr()) == 1 ++ } ++ } ++} ++ ++impl Binding for Pathspec { ++ type Raw = *mut raw::git_pathspec; ++ ++ unsafe fn from_raw(raw: *mut raw::git_pathspec) -> Pathspec { ++ Pathspec { raw: raw } ++ } ++ fn raw(&self) -> *mut raw::git_pathspec { self.raw } ++} ++ ++impl Drop for Pathspec { ++ fn drop(&mut self) { ++ unsafe { raw::git_pathspec_free(self.raw) } ++ } ++} ++ ++impl<'ps> PathspecMatchList<'ps> { ++ fn entrycount(&self) -> usize { ++ unsafe { raw::git_pathspec_match_list_entrycount(&*self.raw) as usize } ++ } ++ ++ fn failed_entrycount(&self) -> usize { ++ unsafe { raw::git_pathspec_match_list_failed_entrycount(&*self.raw) as usize } ++ } ++ ++ /// Returns an iterator over the matching filenames in this list. ++ pub fn entries(&self) -> PathspecEntries { ++ let n = self.entrycount(); ++ let n = if n > 0 && self.entry(0).is_none() {0} else {n}; ++ PathspecEntries { range: 0..n, list: self } ++ } ++ ++ /// Get a matching filename by position. ++ /// ++ /// If this list was generated from a diff, then the return value will ++ /// always be `None. ++ pub fn entry(&self, i: usize) -> Option<&[u8]> { ++ unsafe { ++ let ptr = raw::git_pathspec_match_list_entry(&*self.raw, i as size_t); ++ ::opt_bytes(self, ptr) ++ } ++ } ++ ++ /// Returns an iterator over the matching diff entries in this list. ++ pub fn diff_entries(&self) -> PathspecDiffEntries { ++ let n = self.entrycount(); ++ let n = if n > 0 && self.diff_entry(0).is_none() {0} else {n}; ++ PathspecDiffEntries { range: 0..n, list: self } ++ } ++ ++ /// Get a matching diff delta by position. ++ /// ++ /// If the list was not generated from a diff, then the return value will ++ /// always be `None`. ++ pub fn diff_entry(&self, i: usize) -> Option { ++ unsafe { ++ let ptr = raw::git_pathspec_match_list_diff_entry(&*self.raw, ++ i as size_t); ++ Binding::from_raw_opt(ptr as *mut _) ++ } ++ } ++ ++ /// Returns an iterator over the non-matching entries in this list. ++ pub fn failed_entries(&self) -> PathspecFailedEntries { ++ let n = self.failed_entrycount(); ++ let n = if n > 0 && self.failed_entry(0).is_none() {0} else {n}; ++ PathspecFailedEntries { range: 0..n, list: self } ++ } ++ ++ /// Get an original pathspec string that had no matches. ++ pub fn failed_entry(&self, i: usize) -> Option<&[u8]> { ++ unsafe { ++ let ptr = raw::git_pathspec_match_list_failed_entry(&*self.raw, ++ i as size_t); ++ ::opt_bytes(self, ptr) ++ } ++ } ++} ++ ++impl<'ps> Binding for PathspecMatchList<'ps> { ++ type Raw = *mut raw::git_pathspec_match_list; ++ ++ unsafe fn from_raw(raw: *mut raw::git_pathspec_match_list) ++ -> PathspecMatchList<'ps> { ++ PathspecMatchList { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *mut raw::git_pathspec_match_list { self.raw } ++} ++ ++impl<'ps> Drop for PathspecMatchList<'ps> { ++ fn drop(&mut self) { ++ unsafe { raw::git_pathspec_match_list_free(self.raw) } ++ } ++} ++ ++impl<'list> Iterator for PathspecEntries<'list> { ++ type Item = &'list [u8]; ++ fn next(&mut self) -> Option<&'list [u8]> { ++ self.range.next().and_then(|i| self.list.entry(i)) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++impl<'list> DoubleEndedIterator for PathspecEntries<'list> { ++ fn next_back(&mut self) -> Option<&'list [u8]> { ++ self.range.next_back().and_then(|i| self.list.entry(i)) ++ } ++} ++impl<'list> ExactSizeIterator for PathspecEntries<'list> {} ++ ++impl<'list> Iterator for PathspecDiffEntries<'list> { ++ type Item = DiffDelta<'list>; ++ fn next(&mut self) -> Option> { ++ self.range.next().and_then(|i| self.list.diff_entry(i)) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++impl<'list> DoubleEndedIterator for PathspecDiffEntries<'list> { ++ fn next_back(&mut self) -> Option> { ++ self.range.next_back().and_then(|i| self.list.diff_entry(i)) ++ } ++} ++impl<'list> ExactSizeIterator for PathspecDiffEntries<'list> {} ++ ++impl<'list> Iterator for PathspecFailedEntries<'list> { ++ type Item = &'list [u8]; ++ fn next(&mut self) -> Option<&'list [u8]> { ++ self.range.next().and_then(|i| self.list.failed_entry(i)) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++impl<'list> DoubleEndedIterator for PathspecFailedEntries<'list> { ++ fn next_back(&mut self) -> Option<&'list [u8]> { ++ self.range.next_back().and_then(|i| self.list.failed_entry(i)) ++ } ++} ++impl<'list> ExactSizeIterator for PathspecFailedEntries<'list> {} ++ ++#[cfg(test)] ++mod tests { ++ use PATHSPEC_DEFAULT; ++ use super::Pathspec; ++ use std::fs::File; ++ use std::path::Path; ++ ++ #[test] ++ fn smoke() { ++ let ps = Pathspec::new(["a"].iter()).unwrap(); ++ assert!(ps.matches_path(Path::new("a"), PATHSPEC_DEFAULT)); ++ assert!(ps.matches_path(Path::new("a/b"), PATHSPEC_DEFAULT)); ++ assert!(!ps.matches_path(Path::new("b"), PATHSPEC_DEFAULT)); ++ assert!(!ps.matches_path(Path::new("ab/c"), PATHSPEC_DEFAULT)); ++ ++ let (td, repo) = ::test::repo_init(); ++ let list = ps.match_workdir(&repo, PATHSPEC_DEFAULT).unwrap(); ++ assert_eq!(list.entries().len(), 0); ++ assert_eq!(list.diff_entries().len(), 0); ++ assert_eq!(list.failed_entries().len(), 0); ++ ++ File::create(&td.path().join("a")).unwrap(); ++ ++ let list = ps.match_workdir(&repo, ::PATHSPEC_FIND_FAILURES).unwrap(); ++ assert_eq!(list.entries().len(), 1); ++ assert_eq!(list.entries().next(), Some("a".as_bytes())); ++ } ++} diff --cc vendor/git2-0.6.8/src/proxy_options.rs index 000000000,000000000..e1601749b new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/proxy_options.rs @@@ -1,0 -1,0 +1,56 @@@ ++use std::ffi::CString; ++use std::marker; ++use std::ptr; ++ ++use raw; ++use util::Binding; ++ ++/// Options which can be specified to various fetch operations. ++#[derive(Default)] ++pub struct ProxyOptions<'a> { ++ url: Option, ++ proxy_kind: raw::git_proxy_t, ++ _marker: marker::PhantomData<&'a i32>, ++} ++ ++impl<'a> ProxyOptions<'a> { ++ /// Creates a new set of proxy options ready to be configured. ++ pub fn new() -> ProxyOptions<'a> { ++ Default::default() ++ } ++ ++ /// Try to auto-detect the proxy from the git configuration. ++ /// ++ /// Note that this will override `url` specified before. ++ pub fn auto(&mut self) -> &mut Self { ++ self.proxy_kind = raw::GIT_PROXY_AUTO; ++ self ++ } ++ ++ /// Specify the exact URL of the proxy to use. ++ /// ++ /// Note that this will override `auto` specified before. ++ pub fn url(&mut self, url: &str) -> &mut Self { ++ self.proxy_kind = raw::GIT_PROXY_SPECIFIED; ++ self.url = Some(CString::new(url).unwrap()); ++ self ++ } ++} ++ ++impl<'a> Binding for ProxyOptions<'a> { ++ type Raw = raw::git_proxy_options; ++ unsafe fn from_raw(_raw: raw::git_proxy_options) -> ProxyOptions<'a> { ++ panic!("can't create proxy from raw options") ++ } ++ ++ fn raw(&self) -> raw::git_proxy_options { ++ raw::git_proxy_options { ++ version: raw::GIT_PROXY_OPTIONS_VERSION, ++ kind: self.proxy_kind, ++ url: self.url.as_ref().map(|s| s.as_ptr()).unwrap_or(ptr::null()), ++ credentials: None, ++ certificate_check: None, ++ payload: ptr::null_mut(), ++ } ++ } ++} diff --cc vendor/git2-0.6.8/src/reference.rs index 000000000,000000000..faf829454 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/reference.rs @@@ -1,0 -1,0 +1,355 @@@ ++use std::cmp::Ordering; ++use std::ffi::CString; ++use std::marker; ++use std::mem; ++use std::ptr; ++use std::str; ++ ++use {raw, Error, Oid, Repository, Object, ObjectType}; ++use util::Binding; ++ ++struct Refdb<'repo>(&'repo Repository); ++ ++/// A structure to represent a git [reference][1]. ++/// ++/// [1]: http://git-scm.com/book/en/Git-Internals-Git-References ++pub struct Reference<'repo> { ++ raw: *mut raw::git_reference, ++ _marker: marker::PhantomData>, ++} ++ ++/// An iterator over the references in a repository. ++pub struct References<'repo> { ++ raw: *mut raw::git_reference_iterator, ++ _marker: marker::PhantomData>, ++} ++ ++/// An iterator over the names of references in a repository. ++pub struct ReferenceNames<'repo: 'references, 'references> { ++ inner: &'references mut References<'repo>, ++} ++ ++impl<'repo> Reference<'repo> { ++ /// Ensure the reference name is well-formed. ++ pub fn is_valid_name(refname: &str) -> bool { ++ ::init(); ++ let refname = CString::new(refname).unwrap(); ++ unsafe { raw::git_reference_is_valid_name(refname.as_ptr()) == 1 } ++ } ++ ++ /// Get access to the underlying raw pointer. ++ pub fn raw(&self) -> *mut raw::git_reference { self.raw } ++ ++ /// Delete an existing reference. ++ /// ++ /// This method works for both direct and symbolic references. The reference ++ /// will be immediately removed on disk. ++ /// ++ /// This function will return an error if the reference has changed from the ++ /// time it was looked up. ++ pub fn delete(&mut self) -> Result<(), Error> { ++ unsafe { try_call!(raw::git_reference_delete(self.raw)); } ++ Ok(()) ++ } ++ ++ /// Check if a reference is a local branch. ++ pub fn is_branch(&self) -> bool { ++ unsafe { raw::git_reference_is_branch(&*self.raw) == 1 } ++ } ++ ++ /// Check if a reference is a note. ++ pub fn is_note(&self) -> bool { ++ unsafe { raw::git_reference_is_note(&*self.raw) == 1 } ++ } ++ ++ /// Check if a reference is a remote tracking branch ++ pub fn is_remote(&self) -> bool { ++ unsafe { raw::git_reference_is_remote(&*self.raw) == 1 } ++ } ++ ++ /// Check if a reference is a tag ++ pub fn is_tag(&self) -> bool { ++ unsafe { raw::git_reference_is_tag(&*self.raw) == 1 } ++ } ++ ++ /// Get the full name of a reference. ++ /// ++ /// Returns `None` if the name is not valid utf-8. ++ pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } ++ ++ /// Get the full name of a reference. ++ pub fn name_bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, raw::git_reference_name(&*self.raw)).unwrap() } ++ } ++ ++ /// Get the full shorthand of a reference. ++ /// ++ /// This will transform the reference name into a name "human-readable" ++ /// version. If no shortname is appropriate, it will return the full name. ++ /// ++ /// Returns `None` if the shorthand is not valid utf-8. ++ pub fn shorthand(&self) -> Option<&str> { ++ str::from_utf8(self.shorthand_bytes()).ok() ++ } ++ ++ /// Get the full shorthand of a reference. ++ pub fn shorthand_bytes(&self) -> &[u8] { ++ unsafe { ++ ::opt_bytes(self, raw::git_reference_shorthand(&*self.raw)).unwrap() ++ } ++ } ++ ++ /// Get the OID pointed to by a direct reference. ++ /// ++ /// Only available if the reference is direct (i.e. an object id reference, ++ /// not a symbolic one). ++ pub fn target(&self) -> Option { ++ unsafe { ++ Binding::from_raw_opt(raw::git_reference_target(&*self.raw)) ++ } ++ } ++ ++ /// Return the peeled OID target of this reference. ++ /// ++ /// This peeled OID only applies to direct references that point to a hard ++ /// Tag object: it is the result of peeling such Tag. ++ pub fn target_peel(&self) -> Option { ++ unsafe { ++ Binding::from_raw_opt(raw::git_reference_target_peel(&*self.raw)) ++ } ++ } ++ ++ /// Get full name to the reference pointed to by a symbolic reference. ++ /// ++ /// May return `None` if the reference is either not symbolic or not a ++ /// valid utf-8 string. ++ pub fn symbolic_target(&self) -> Option<&str> { ++ self.symbolic_target_bytes().and_then(|s| str::from_utf8(s).ok()) ++ } ++ ++ /// Get full name to the reference pointed to by a symbolic reference. ++ /// ++ /// Only available if the reference is symbolic. ++ pub fn symbolic_target_bytes(&self) -> Option<&[u8]> { ++ unsafe { ::opt_bytes(self, raw::git_reference_symbolic_target(&*self.raw)) } ++ } ++ ++ /// Resolve a symbolic reference to a direct reference. ++ /// ++ /// This method iteratively peels a symbolic reference until it resolves to ++ /// a direct reference to an OID. ++ /// ++ /// If a direct reference is passed as an argument, a copy of that ++ /// reference is returned. ++ pub fn resolve(&self) -> Result, Error> { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_reference_resolve(&mut raw, &*self.raw)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Peel a reference to an object ++ /// ++ /// This method recursively peels the reference until it reaches ++ /// an object of the specified type. ++ pub fn peel(&self, kind: ObjectType) -> Result, Error> { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_reference_peel(&mut raw, self.raw, kind)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Rename an existing reference. ++ /// ++ /// This method works for both direct and symbolic references. ++ /// ++ /// If the force flag is not enabled, and there's already a reference with ++ /// the given name, the renaming will fail. ++ pub fn rename(&mut self, new_name: &str, force: bool, ++ msg: &str) -> Result, Error> { ++ let mut raw = ptr::null_mut(); ++ let new_name = try!(CString::new(new_name)); ++ let msg = try!(CString::new(msg)); ++ unsafe { ++ try_call!(raw::git_reference_rename(&mut raw, self.raw, new_name, ++ force, msg)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Conditionally create a new reference with the same name as the given ++ /// reference but a different OID target. The reference must be a direct ++ /// reference, otherwise this will fail. ++ /// ++ /// The new reference will be written to disk, overwriting the given ++ /// reference. ++ pub fn set_target(&mut self, id: Oid, reflog_msg: &str) ++ -> Result, Error> { ++ let mut raw = ptr::null_mut(); ++ let msg = try!(CString::new(reflog_msg)); ++ unsafe { ++ try_call!(raw::git_reference_set_target(&mut raw, self.raw, ++ id.raw(), msg)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++} ++ ++impl<'repo> PartialOrd for Reference<'repo> { ++ fn partial_cmp(&self, other: &Reference<'repo>) -> Option { ++ Some(self.cmp(other)) ++ } ++} ++ ++impl<'repo> Ord for Reference<'repo> { ++ fn cmp(&self, other: &Reference<'repo>) -> Ordering { ++ match unsafe { raw::git_reference_cmp(&*self.raw, &*other.raw) } { ++ 0 => Ordering::Equal, ++ n if n < 0 => Ordering::Less, ++ _ => Ordering::Greater, ++ } ++ } ++} ++ ++impl<'repo> PartialEq for Reference<'repo> { ++ fn eq(&self, other: &Reference<'repo>) -> bool { ++ self.cmp(other) == Ordering::Equal ++ } ++} ++ ++impl<'repo> Eq for Reference<'repo> {} ++ ++impl<'repo> Binding for Reference<'repo> { ++ type Raw = *mut raw::git_reference; ++ unsafe fn from_raw(raw: *mut raw::git_reference) -> Reference<'repo> { ++ Reference { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *mut raw::git_reference { self.raw } ++} ++ ++impl<'repo> Drop for Reference<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_reference_free(self.raw) } ++ } ++} ++ ++impl<'repo> References<'repo> { ++ /// Consumes a `References` iterator to create an iterator over just the ++ /// name of some references. ++ /// ++ /// This is more efficient if only the names are desired of references as ++ /// the references themselves don't have to be allocated and deallocated. ++ /// ++ /// The returned iterator will yield strings as opposed to a `Reference`. ++ pub fn names<'a>(&'a mut self) -> ReferenceNames<'repo, 'a> { ++ ReferenceNames { inner: self } ++ } ++} ++ ++impl<'repo> Binding for References<'repo> { ++ type Raw = *mut raw::git_reference_iterator; ++ unsafe fn from_raw(raw: *mut raw::git_reference_iterator) ++ -> References<'repo> { ++ References { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *mut raw::git_reference_iterator { self.raw } ++} ++ ++impl<'repo> Iterator for References<'repo> { ++ type Item = Result, Error>; ++ fn next(&mut self) -> Option, Error>> { ++ let mut out = ptr::null_mut(); ++ unsafe { ++ try_call_iter!(raw::git_reference_next(&mut out, self.raw)); ++ Some(Ok(Binding::from_raw(out))) ++ } ++ } ++} ++ ++impl<'repo> Drop for References<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_reference_iterator_free(self.raw) } ++ } ++} ++ ++impl<'repo, 'references> Iterator for ReferenceNames<'repo, 'references> { ++ type Item = Result<&'references str, Error>; ++ fn next(&mut self) -> Option> { ++ let mut out = ptr::null(); ++ unsafe { ++ try_call_iter!(raw::git_reference_next_name(&mut out, ++ self.inner.raw)); ++ let bytes = ::opt_bytes(self, out).unwrap(); ++ let s = str::from_utf8(bytes).unwrap(); ++ Some(Ok(mem::transmute::<&str, &'references str>(s))) ++ } ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use {Reference, ObjectType}; ++ ++ #[test] ++ fn smoke() { ++ assert!(Reference::is_valid_name("refs/foo")); ++ assert!(!Reference::is_valid_name("foo")); ++ } ++ ++ #[test] ++ fn smoke2() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut head = repo.head().unwrap(); ++ assert!(head.is_branch()); ++ assert!(!head.is_remote()); ++ assert!(!head.is_tag()); ++ assert!(!head.is_note()); ++ ++ assert!(head == repo.head().unwrap()); ++ assert_eq!(head.name(), Some("refs/heads/master")); ++ ++ assert!(head == repo.find_reference("refs/heads/master").unwrap()); ++ assert_eq!(repo.refname_to_id("refs/heads/master").unwrap(), ++ head.target().unwrap()); ++ ++ assert!(head.symbolic_target().is_none()); ++ assert!(head.target_peel().is_none()); ++ ++ assert_eq!(head.shorthand(), Some("master")); ++ assert!(head.resolve().unwrap() == head); ++ ++ let mut tag1 = repo.reference("refs/tags/tag1", ++ head.target().unwrap(), ++ false, "test").unwrap(); ++ assert!(tag1.is_tag()); ++ ++ let peeled_commit = tag1.peel(ObjectType::Commit).unwrap(); ++ assert_eq!(ObjectType::Commit, peeled_commit.kind().unwrap()); ++ assert_eq!(tag1.target().unwrap(), peeled_commit.id()); ++ ++ tag1.delete().unwrap(); ++ ++ let mut sym1 = repo.reference_symbolic("refs/tags/tag1", ++ "refs/heads/master", false, ++ "test").unwrap(); ++ sym1.delete().unwrap(); ++ ++ { ++ assert!(repo.references().unwrap().count() == 1); ++ assert!(repo.references().unwrap().next().unwrap().unwrap() == head); ++ let mut names = repo.references().unwrap(); ++ let mut names = names.names(); ++ assert_eq!(names.next().unwrap().unwrap(), "refs/heads/master"); ++ assert!(names.next().is_none()); ++ assert!(repo.references_glob("foo").unwrap().count() == 0); ++ assert!(repo.references_glob("refs/heads/*").unwrap().count() == 1); ++ } ++ ++ let mut head = head.rename("refs/foo", true, "test").unwrap(); ++ head.delete().unwrap(); ++ ++ } ++} diff --cc vendor/git2-0.6.8/src/reflog.rs index 000000000,000000000..6996a89da new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/reflog.rs @@@ -1,0 -1,0 +1,172 @@@ ++use std::ops::Range; ++use std::marker; ++use std::str; ++use libc::size_t; ++ ++use {raw, signature, Oid, Error, Signature}; ++use util::Binding; ++ ++/// A reference log of a git repository. ++pub struct Reflog { ++ raw: *mut raw::git_reflog, ++} ++ ++/// An entry inside the reflog of a repository ++pub struct ReflogEntry<'reflog> { ++ raw: *const raw::git_reflog_entry, ++ _marker: marker::PhantomData<&'reflog Reflog>, ++} ++ ++/// An iterator over the entries inside of a reflog. ++pub struct ReflogIter<'reflog> { ++ range: Range, ++ reflog: &'reflog Reflog, ++} ++ ++impl Reflog { ++ /// Add a new entry to the in-memory reflog. ++ pub fn append(&mut self, new_oid: Oid, committer: &Signature, ++ msg: Option<&str>) -> Result<(), Error> { ++ let msg = try!(::opt_cstr(msg)); ++ unsafe { ++ try_call!(raw::git_reflog_append(self.raw, new_oid.raw(), ++ committer.raw(), msg)); ++ } ++ Ok(()) ++ } ++ ++ /// Remove an entry from the reflog by its index ++ /// ++ /// To ensure there's no gap in the log history, set rewrite_previous_entry ++ /// param value to `true`. When deleting entry n, member old_oid of entry ++ /// n-1 (if any) will be updated with the value of member new_oid of entry ++ /// n+1. ++ pub fn remove(&mut self, i: usize, rewrite_previous_entry: bool) ++ -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_reflog_drop(self.raw, i as size_t, ++ rewrite_previous_entry)); ++ } ++ Ok(()) ++ } ++ ++ /// Lookup an entry by its index ++ /// ++ /// Requesting the reflog entry with an index of 0 (zero) will return the ++ /// most recently created entry. ++ pub fn get(&self, i: usize) -> Option { ++ unsafe { ++ let ptr = raw::git_reflog_entry_byindex(self.raw, i as size_t); ++ Binding::from_raw_opt(ptr) ++ } ++ } ++ ++ /// Get the number of log entries in a reflog ++ pub fn len(&self) -> usize { ++ unsafe { raw::git_reflog_entrycount(self.raw) as usize } ++ } ++ ++ /// Return `true ` is there is no log entry in a reflog ++ pub fn is_empty(&self) -> bool { ++ self.len() == 0 ++ } ++ ++ /// Get an iterator to all entries inside of this reflog ++ pub fn iter(&self) -> ReflogIter { ++ ReflogIter { range: 0..self.len(), reflog: self } ++ } ++ ++ /// Write an existing in-memory reflog object back to disk using an atomic ++ /// file lock. ++ pub fn write(&mut self) -> Result<(), Error> { ++ unsafe { try_call!(raw::git_reflog_write(self.raw)); } ++ Ok(()) ++ } ++} ++ ++impl Binding for Reflog { ++ type Raw = *mut raw::git_reflog; ++ ++ unsafe fn from_raw(raw: *mut raw::git_reflog) -> Reflog { ++ Reflog { raw: raw } ++ } ++ fn raw(&self) -> *mut raw::git_reflog { self.raw } ++} ++ ++impl Drop for Reflog { ++ fn drop(&mut self) { ++ unsafe { raw::git_reflog_free(self.raw) } ++ } ++} ++ ++impl<'reflog> ReflogEntry<'reflog> { ++ /// Get the committer of this entry ++ pub fn committer(&self) -> Signature { ++ unsafe { ++ let ptr = raw::git_reflog_entry_committer(self.raw); ++ signature::from_raw_const(self, ptr) ++ } ++ } ++ ++ /// Get the new oid ++ pub fn id_new(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_reflog_entry_id_new(self.raw)) } ++ } ++ ++ /// Get the old oid ++ pub fn id_old(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_reflog_entry_id_new(self.raw)) } ++ } ++ ++ /// Get the log message, returning `None` on invalid UTF-8. ++ pub fn message(&self) -> Option<&str> { ++ self.message_bytes().and_then(|s| str::from_utf8(s).ok()) ++ } ++ ++ /// Get the log message as a byte array. ++ pub fn message_bytes(&self) -> Option<&[u8]> { ++ unsafe { ++ ::opt_bytes(self, raw::git_reflog_entry_message(self.raw)) ++ } ++ } ++} ++ ++impl<'reflog> Binding for ReflogEntry<'reflog> { ++ type Raw = *const raw::git_reflog_entry; ++ ++ unsafe fn from_raw(raw: *const raw::git_reflog_entry) -> ReflogEntry<'reflog> { ++ ReflogEntry { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *const raw::git_reflog_entry { self.raw } ++} ++ ++impl<'reflog> Iterator for ReflogIter<'reflog> { ++ type Item = ReflogEntry<'reflog>; ++ fn next(&mut self) -> Option> { ++ self.range.next().and_then(|i| self.reflog.get(i)) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++impl<'reflog> DoubleEndedIterator for ReflogIter<'reflog> { ++ fn next_back(&mut self) -> Option> { ++ self.range.next_back().and_then(|i| self.reflog.get(i)) ++ } ++} ++impl<'reflog> ExactSizeIterator for ReflogIter<'reflog> {} ++ ++#[cfg(test)] ++mod tests { ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ let mut reflog = repo.reflog("HEAD").unwrap(); ++ assert_eq!(reflog.iter().len(), 1); ++ reflog.write().unwrap(); ++ ++ let entry = reflog.iter().next().unwrap(); ++ assert!(entry.message().is_some()); ++ ++ repo.reflog_rename("HEAD", "refs/heads/foo").unwrap(); ++ repo.reflog_delete("refs/heads/foo").unwrap(); ++ } ++} diff --cc vendor/git2-0.6.8/src/refspec.rs index 000000000,000000000..c814d23e5 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/refspec.rs @@@ -1,0 -1,0 +1,89 @@@ ++use std::ffi::CString; ++use std::marker; ++use std::str; ++ ++use {raw, Direction}; ++use util::Binding; ++ ++/// A structure to represent a git [refspec][1]. ++/// ++/// Refspecs are currently mainly accessed/created through a `Remote`. ++/// ++/// [1]: http://git-scm.com/book/en/Git-Internals-The-Refspec ++pub struct Refspec<'remote> { ++ raw: *const raw::git_refspec, ++ _marker: marker::PhantomData<&'remote raw::git_remote>, ++} ++ ++impl<'remote> Refspec<'remote> { ++ /// Get the refspec's direction. ++ pub fn direction(&self) -> Direction { ++ match unsafe { raw::git_refspec_direction(self.raw) } { ++ raw::GIT_DIRECTION_FETCH => Direction::Fetch, ++ raw::GIT_DIRECTION_PUSH => Direction::Push, ++ n => panic!("unknown refspec direction: {}", n), ++ } ++ } ++ ++ /// Get the destination specifier. ++ /// ++ /// If the destination is not utf-8, None is returned. ++ pub fn dst(&self) -> Option<&str> { ++ str::from_utf8(self.dst_bytes()).ok() ++ } ++ ++ /// Get the destination specifier, in bytes. ++ pub fn dst_bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, raw::git_refspec_dst(self.raw)).unwrap() } ++ } ++ ++ /// Check if a refspec's destination descriptor matches a reference ++ pub fn dst_matches(&self, refname: &str) -> bool { ++ let refname = CString::new(refname).unwrap(); ++ unsafe { raw::git_refspec_dst_matches(self.raw, refname.as_ptr()) == 1 } ++ } ++ ++ /// Get the source specifier. ++ /// ++ /// If the source is not utf-8, None is returned. ++ pub fn src(&self) -> Option<&str> { ++ str::from_utf8(self.src_bytes()).ok() ++ } ++ ++ /// Get the source specifier, in bytes. ++ pub fn src_bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, raw::git_refspec_src(self.raw)).unwrap() } ++ } ++ ++ /// Check if a refspec's source descriptor matches a reference ++ pub fn src_matches(&self, refname: &str) -> bool { ++ let refname = CString::new(refname).unwrap(); ++ unsafe { raw::git_refspec_src_matches(self.raw, refname.as_ptr()) == 1 } ++ } ++ ++ /// Get the force update setting. ++ pub fn is_force(&self) -> bool { ++ unsafe { raw::git_refspec_force(self.raw) == 1 } ++ } ++ ++ /// Get the refspec's string. ++ /// ++ /// Returns None if the string is not valid utf8. ++ pub fn str(&self) -> Option<&str> { ++ str::from_utf8(self.bytes()).ok() ++ } ++ ++ /// Get the refspec's string as a byte array ++ pub fn bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, raw::git_refspec_string(self.raw)).unwrap() } ++ } ++} ++ ++impl<'remote> Binding for Refspec<'remote> { ++ type Raw = *const raw::git_refspec; ++ ++ unsafe fn from_raw(raw: *const raw::git_refspec) -> Refspec<'remote> { ++ Refspec { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *const raw::git_refspec { self.raw } ++} diff --cc vendor/git2-0.6.8/src/remote.rs index 000000000,000000000..2324803f5 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/remote.rs @@@ -1,0 -1,0 +1,747 @@@ ++use std::ffi::CString; ++use std::ops::Range; ++use std::marker; ++use std::mem; ++use std::ptr; ++use std::slice; ++use std::str; ++use libc; ++ ++use {raw, Direction, Error, Refspec, Oid, FetchPrune, ProxyOptions}; ++use {RemoteCallbacks, Progress, Repository, AutotagOption}; ++use string_array::StringArray; ++use util::Binding; ++ ++/// A structure representing a [remote][1] of a git repository. ++/// ++/// [1]: http://git-scm.com/book/en/Git-Basics-Working-with-Remotes ++/// ++/// The lifetime is the lifetime of the repository that it is attached to. The ++/// remote is used to manage fetches and pushes as well as refspecs. ++pub struct Remote<'repo> { ++ raw: *mut raw::git_remote, ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++/// An iterator over the refspecs that a remote contains. ++pub struct Refspecs<'remote> { ++ range: Range, ++ remote: &'remote Remote<'remote>, ++} ++ ++/// Description of a reference advertised bya remote server, given out on calls ++/// to `list`. ++pub struct RemoteHead<'remote> { ++ raw: *const raw::git_remote_head, ++ _marker: marker::PhantomData<&'remote str>, ++} ++ ++/// Options which can be specified to various fetch operations. ++pub struct FetchOptions<'cb> { ++ callbacks: Option>, ++ proxy: Option>, ++ prune: FetchPrune, ++ update_fetchhead: bool, ++ download_tags: AutotagOption, ++} ++ ++/// Options to control the behavior of a git push. ++pub struct PushOptions<'cb> { ++ callbacks: Option>, ++ proxy: Option>, ++ pb_parallelism: u32, ++} ++ ++/// Holds callbacks for a connection to a `Remote`. Disconnects when dropped ++pub struct RemoteConnection<'repo, 'connection, 'cb> where 'repo: 'connection { ++ _callbacks: Box>, ++ _proxy: ProxyOptions<'cb>, ++ remote: &'connection mut Remote<'repo>, ++} ++ ++impl<'repo> Remote<'repo> { ++ /// Ensure the remote name is well-formed. ++ pub fn is_valid_name(remote_name: &str) -> bool { ++ ::init(); ++ let remote_name = CString::new(remote_name).unwrap(); ++ unsafe { raw::git_remote_is_valid_name(remote_name.as_ptr()) == 1 } ++ } ++ ++ /// Get the remote's name. ++ /// ++ /// Returns `None` if this remote has not yet been named or if the name is ++ /// not valid utf-8 ++ pub fn name(&self) -> Option<&str> { ++ self.name_bytes().and_then(|s| str::from_utf8(s).ok()) ++ } ++ ++ /// Get the remote's name, in bytes. ++ /// ++ /// Returns `None` if this remote has not yet been named ++ pub fn name_bytes(&self) -> Option<&[u8]> { ++ unsafe { ::opt_bytes(self, raw::git_remote_name(&*self.raw)) } ++ } ++ ++ /// Get the remote's url. ++ /// ++ /// Returns `None` if the url is not valid utf-8 ++ pub fn url(&self) -> Option<&str> { ++ str::from_utf8(self.url_bytes()).ok() ++ } ++ ++ /// Get the remote's url as a byte array. ++ pub fn url_bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, raw::git_remote_url(&*self.raw)).unwrap() } ++ } ++ ++ /// Get the remote's pushurl. ++ /// ++ /// Returns `None` if the pushurl is not valid utf-8 ++ pub fn pushurl(&self) -> Option<&str> { ++ self.pushurl_bytes().and_then(|s| str::from_utf8(s).ok()) ++ } ++ ++ /// Get the remote's pushurl as a byte array. ++ pub fn pushurl_bytes(&self) -> Option<&[u8]> { ++ unsafe { ::opt_bytes(self, raw::git_remote_pushurl(&*self.raw)) } ++ } ++ ++ /// Open a connection to a remote. ++ pub fn connect(&mut self, dir: Direction) -> Result<(), Error> { ++ // TODO: can callbacks be exposed safely? ++ unsafe { ++ try_call!(raw::git_remote_connect(self.raw, dir, ++ ptr::null(), ++ ptr::null(), ++ ptr::null())); ++ } ++ Ok(()) ++ } ++ ++ /// Open a connection to a remote with callbacks and proxy settings ++ /// ++ /// Returns a `RemoteConnection` that will disconnect once dropped ++ pub fn connect_auth<'connection, 'cb>(&'connection mut self, ++ dir: Direction, ++ cb: Option>, ++ proxy_options: Option>) ++ -> Result, Error> { ++ ++ let cb = Box::new(cb.unwrap_or_else(RemoteCallbacks::new)); ++ let proxy_options = proxy_options.unwrap_or_else(ProxyOptions::new); ++ unsafe { ++ try_call!(raw::git_remote_connect(self.raw, dir, ++ &cb.raw(), ++ &proxy_options.raw(), ++ ptr::null())); ++ } ++ ++ Ok(RemoteConnection { ++ _callbacks: cb, ++ _proxy: proxy_options, ++ remote: self, ++ }) ++ } ++ ++ /// Check whether the remote is connected ++ pub fn connected(&mut self) -> bool { ++ unsafe { raw::git_remote_connected(self.raw) == 1 } ++ } ++ ++ /// Disconnect from the remote ++ pub fn disconnect(&mut self) { ++ unsafe { raw::git_remote_disconnect(self.raw) } ++ } ++ ++ /// Download and index the packfile ++ /// ++ /// Connect to the remote if it hasn't been done yet, negotiate with the ++ /// remote git which objects are missing, download and index the packfile. ++ /// ++ /// The .idx file will be created and both it and the packfile with be ++ /// renamed to their final name. ++ /// ++ /// The `specs` argument is a list of refspecs to use for this negotiation ++ /// and download. Use an empty array to use the base refspecs. ++ pub fn download(&mut self, specs: &[&str], opts: Option<&mut FetchOptions>) ++ -> Result<(), Error> { ++ let (_a, _b, arr) = try!(::util::iter2cstrs(specs.iter())); ++ let raw = opts.map(|o| o.raw()); ++ unsafe { ++ try_call!(raw::git_remote_download(self.raw, &arr, raw.as_ref())); ++ } ++ Ok(()) ++ } ++ ++ /// Get the number of refspecs for a remote ++ pub fn refspecs<'a>(&'a self) -> Refspecs<'a> { ++ let cnt = unsafe { raw::git_remote_refspec_count(&*self.raw) as usize }; ++ Refspecs { range: 0..cnt, remote: self } ++ } ++ ++ /// Get the `nth` refspec from this remote. ++ /// ++ /// The `refspecs` iterator can be used to iterate over all refspecs. ++ pub fn get_refspec(&self, i: usize) -> Option> { ++ unsafe { ++ let ptr = raw::git_remote_get_refspec(&*self.raw, ++ i as libc::size_t); ++ Binding::from_raw_opt(ptr) ++ } ++ } ++ ++ /// Download new data and update tips ++ /// ++ /// Convenience function to connect to a remote, download the data, ++ /// disconnect and update the remote-tracking branches. ++ /// ++ /// # Examples ++ /// ++ /// Example of functionality similar to `git fetch origin/master`: ++ /// ++ /// ```no_run ++ /// fn fetch_origin_master(repo: git2::Repository) -> Result<(), git2::Error> { ++ /// repo.find_remote("origin")?.fetch(&["master"], None, None) ++ /// } ++ /// ++ /// let repo = git2::Repository::discover("rust").unwrap(); ++ /// fetch_origin_master(repo).unwrap(); ++ /// ``` ++ pub fn fetch(&mut self, ++ refspecs: &[&str], ++ opts: Option<&mut FetchOptions>, ++ reflog_msg: Option<&str>) -> Result<(), Error> { ++ let (_a, _b, arr) = try!(::util::iter2cstrs(refspecs.iter())); ++ let msg = try!(::opt_cstr(reflog_msg)); ++ let raw = opts.map(|o| o.raw()); ++ unsafe { ++ try_call!(raw::git_remote_fetch(self.raw, &arr, raw.as_ref(), msg)); ++ } ++ Ok(()) ++ } ++ ++ /// Update the tips to the new state ++ pub fn update_tips(&mut self, ++ callbacks: Option<&mut RemoteCallbacks>, ++ update_fetchhead: bool, ++ download_tags: AutotagOption, ++ msg: Option<&str>) -> Result<(), Error> { ++ let msg = try!(::opt_cstr(msg)); ++ let cbs = callbacks.map(|cb| cb.raw()); ++ unsafe { ++ try_call!(raw::git_remote_update_tips(self.raw, cbs.as_ref(), ++ update_fetchhead, ++ download_tags, msg)); ++ } ++ Ok(()) ++ } ++ ++ /// Perform a push ++ /// ++ /// Perform all the steps for a push. If no refspecs are passed then the ++ /// configured refspecs will be used. ++ /// ++ /// Note that you'll likely want to use `RemoteCallbacks` and set ++ /// `push_update_reference` to test whether all the references were pushed ++ /// successfully. ++ pub fn push(&mut self, ++ refspecs: &[&str], ++ opts: Option<&mut PushOptions>) -> Result<(), Error> { ++ let (_a, _b, arr) = try!(::util::iter2cstrs(refspecs.iter())); ++ let raw = opts.map(|o| o.raw()); ++ unsafe { ++ try_call!(raw::git_remote_push(self.raw, &arr, raw.as_ref())); ++ } ++ Ok(()) ++ } ++ ++ /// Get the statistics structure that is filled in by the fetch operation. ++ pub fn stats(&self) -> Progress { ++ unsafe { ++ Binding::from_raw(raw::git_remote_stats(self.raw)) ++ } ++ } ++ ++ /// Get the remote repository's reference advertisement list. ++ /// ++ /// Get the list of references with which the server responds to a new ++ /// connection. ++ /// ++ /// The remote (or more exactly its transport) must have connected to the ++ /// remote repository. This list is available as soon as the connection to ++ /// the remote is initiated and it remains available after disconnecting. ++ pub fn list(&self) -> Result<&[RemoteHead], Error> { ++ let mut size = 0; ++ let mut base = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_remote_ls(&mut base, &mut size, self.raw)); ++ assert_eq!(mem::size_of::(), ++ mem::size_of::<*const raw::git_remote_head>()); ++ let slice = slice::from_raw_parts(base as *const _, size as usize); ++ Ok(mem::transmute::<&[*const raw::git_remote_head], ++ &[RemoteHead]>(slice)) ++ } ++ } ++ ++ /// Get the remote's list of fetch refspecs ++ pub fn fetch_refspecs(&self) -> Result { ++ unsafe { ++ let mut raw: raw::git_strarray = mem::zeroed(); ++ try_call!(raw::git_remote_get_fetch_refspecs(&mut raw, self.raw)); ++ Ok(StringArray::from_raw(raw)) ++ } ++ } ++ ++ /// Get the remote's list of push refspecs ++ pub fn push_refspecs(&self) -> Result { ++ unsafe { ++ let mut raw: raw::git_strarray = mem::zeroed(); ++ try_call!(raw::git_remote_get_push_refspecs(&mut raw, self.raw)); ++ Ok(StringArray::from_raw(raw)) ++ } ++ } ++} ++ ++impl<'repo> Clone for Remote<'repo> { ++ fn clone(&self) -> Remote<'repo> { ++ let mut ret = ptr::null_mut(); ++ let rc = unsafe { call!(raw::git_remote_dup(&mut ret, self.raw)) }; ++ assert_eq!(rc, 0); ++ Remote { ++ raw: ret, ++ _marker: marker::PhantomData, ++ } ++ } ++} ++ ++impl<'repo> Binding for Remote<'repo> { ++ type Raw = *mut raw::git_remote; ++ ++ unsafe fn from_raw(raw: *mut raw::git_remote) -> Remote<'repo> { ++ Remote { ++ raw: raw, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_remote { self.raw } ++} ++ ++impl<'repo> Drop for Remote<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_remote_free(self.raw) } ++ } ++} ++ ++impl<'repo> Iterator for Refspecs<'repo> { ++ type Item = Refspec<'repo>; ++ fn next(&mut self) -> Option> { ++ self.range.next().and_then(|i| self.remote.get_refspec(i)) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++impl<'repo> DoubleEndedIterator for Refspecs<'repo> { ++ fn next_back(&mut self) -> Option> { ++ self.range.next_back().and_then(|i| self.remote.get_refspec(i)) ++ } ++} ++impl<'repo> ExactSizeIterator for Refspecs<'repo> {} ++ ++#[allow(missing_docs)] // not documented in libgit2 :( ++impl<'remote> RemoteHead<'remote> { ++ /// Flag if this is available locally. ++ pub fn is_local(&self) -> bool { ++ unsafe { (*self.raw).local != 0 } ++ } ++ ++ pub fn oid(&self) -> Oid { ++ unsafe { Binding::from_raw(&(*self.raw).oid as *const _) } ++ } ++ pub fn loid(&self) -> Oid { ++ unsafe { Binding::from_raw(&(*self.raw).loid as *const _) } ++ } ++ ++ pub fn name(&self) -> &str { ++ let b = unsafe { ::opt_bytes(self, (*self.raw).name).unwrap() }; ++ str::from_utf8(b).unwrap() ++ } ++ ++ pub fn symref_target(&self) -> Option<&str> { ++ let b = unsafe { ::opt_bytes(self, (*self.raw).symref_target) }; ++ b.map(|b| str::from_utf8(b).unwrap()) ++ } ++} ++ ++impl<'cb> Default for FetchOptions<'cb> { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl<'cb> FetchOptions<'cb> { ++ /// Creates a new blank set of fetch options ++ pub fn new() -> FetchOptions<'cb> { ++ FetchOptions { ++ callbacks: None, ++ proxy: None, ++ prune: FetchPrune::Unspecified, ++ update_fetchhead: true, ++ download_tags: AutotagOption::Unspecified, ++ } ++ } ++ ++ /// Set the callbacks to use for the fetch operation. ++ pub fn remote_callbacks(&mut self, cbs: RemoteCallbacks<'cb>) -> &mut Self { ++ self.callbacks = Some(cbs); ++ self ++ } ++ ++ /// Set the proxy options to use for the fetch operation. ++ pub fn proxy_options(&mut self, opts: ProxyOptions<'cb>) -> &mut Self { ++ self.proxy = Some(opts); ++ self ++ } ++ ++ /// Set whether to perform a prune after the fetch. ++ pub fn prune(&mut self, prune: FetchPrune) -> &mut Self { ++ self.prune = prune; ++ self ++ } ++ ++ /// Set whether to write the results to FETCH_HEAD. ++ /// ++ /// Defaults to `true`. ++ pub fn update_fetchhead(&mut self, update: bool) -> &mut Self { ++ self.update_fetchhead = update; ++ self ++ } ++ ++ /// Set how to behave regarding tags on the remote, such as auto-downloading ++ /// tags for objects we're downloading or downloading all of them. ++ /// ++ /// The default is to auto-follow tags. ++ pub fn download_tags(&mut self, opt: AutotagOption) -> &mut Self { ++ self.download_tags = opt; ++ self ++ } ++} ++ ++impl<'cb> Binding for FetchOptions<'cb> { ++ type Raw = raw::git_fetch_options; ++ ++ unsafe fn from_raw(_raw: raw::git_fetch_options) -> FetchOptions<'cb> { ++ panic!("unimplemented"); ++ } ++ fn raw(&self) -> raw::git_fetch_options { ++ raw::git_fetch_options { ++ version: 1, ++ callbacks: self.callbacks.as_ref().map(|m| m.raw()) ++ .unwrap_or_else(|| RemoteCallbacks::new().raw()), ++ proxy_opts: self.proxy.as_ref().map(|m| m.raw()) ++ .unwrap_or_else(|| ProxyOptions::new().raw()), ++ prune: ::call::convert(&self.prune), ++ update_fetchhead: ::call::convert(&self.update_fetchhead), ++ download_tags: ::call::convert(&self.download_tags), ++ // TODO: expose this as a builder option ++ custom_headers: raw::git_strarray { ++ count: 0, ++ strings: ptr::null_mut(), ++ }, ++ } ++ } ++} ++ ++ ++impl<'cb> Default for PushOptions<'cb> { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl<'cb> PushOptions<'cb> { ++ /// Creates a new blank set of push options ++ pub fn new() -> PushOptions<'cb> { ++ PushOptions { ++ callbacks: None, ++ proxy: None, ++ pb_parallelism: 1, ++ } ++ } ++ ++ /// Set the callbacks to use for the fetch operation. ++ pub fn remote_callbacks(&mut self, cbs: RemoteCallbacks<'cb>) -> &mut Self { ++ self.callbacks = Some(cbs); ++ self ++ } ++ ++ /// Set the proxy options to use for the fetch operation. ++ pub fn proxy_options(&mut self, opts: ProxyOptions<'cb>) -> &mut Self { ++ self.proxy = Some(opts); ++ self ++ } ++ ++ /// If the transport being used to push to the remote requires the creation ++ /// of a pack file, this controls the number of worker threads used by the ++ /// packbuilder when creating that pack file to be sent to the remote. ++ /// ++ /// if set to 0 the packbuilder will auto-detect the number of threads to ++ /// create, and the default value is 1. ++ pub fn packbuilder_parallelism(&mut self, parallel: u32) -> &mut Self { ++ self.pb_parallelism = parallel; ++ self ++ } ++} ++ ++impl<'cb> Binding for PushOptions<'cb> { ++ type Raw = raw::git_push_options; ++ ++ unsafe fn from_raw(_raw: raw::git_push_options) -> PushOptions<'cb> { ++ panic!("unimplemented"); ++ } ++ fn raw(&self) -> raw::git_push_options { ++ raw::git_push_options { ++ version: 1, ++ callbacks: self.callbacks.as_ref() ++ .map(|m| m.raw()) ++ .unwrap_or_else(|| RemoteCallbacks::new().raw()), ++ proxy_opts: self.proxy.as_ref().map(|m| m.raw()) ++ .unwrap_or_else(|| ProxyOptions::new().raw()), ++ pb_parallelism: self.pb_parallelism as libc::c_uint, ++ // TODO: expose this as a builder option ++ custom_headers: raw::git_strarray { ++ count: 0, ++ strings: ptr::null_mut(), ++ }, ++ } ++ } ++} ++ ++impl<'repo, 'connection, 'cb> RemoteConnection<'repo, 'connection, 'cb> { ++ /// Check whether the remote is (still) connected ++ pub fn connected(&mut self) -> bool { ++ self.remote.connected() ++ } ++ ++ /// Get the remote repository's reference advertisement list. ++ /// ++ /// This list is available as soon as the connection to ++ /// the remote is initiated and it remains available after disconnecting. ++ pub fn list(&self) -> Result<&[RemoteHead], Error> { ++ self.remote.list() ++ } ++} ++ ++impl<'repo, 'connection, 'cb> Drop for RemoteConnection<'repo, 'connection, 'cb> { ++ fn drop(&mut self) { ++ self.remote.disconnect() ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::cell::Cell; ++ use tempdir::TempDir; ++ use {Repository, Remote, RemoteCallbacks, Direction, FetchOptions}; ++ use {AutotagOption, PushOptions}; ++ ++ #[test] ++ fn smoke() { ++ let (td, repo) = ::test::repo_init(); ++ t!(repo.remote("origin", "/path/to/nowhere")); ++ drop(repo); ++ ++ let repo = t!(Repository::init(td.path())); ++ let origin = t!(repo.find_remote("origin")); ++ assert_eq!(origin.name(), Some("origin")); ++ assert_eq!(origin.url(), Some("/path/to/nowhere")); ++ assert_eq!(origin.pushurl(), None); ++ ++ t!(repo.remote_set_url("origin", "/path/to/elsewhere")); ++ t!(repo.remote_set_pushurl("origin", Some("/path/to/elsewhere"))); ++ ++ let stats = origin.stats(); ++ assert_eq!(stats.total_objects(), 0); ++ } ++ ++ #[test] ++ fn create_remote() { ++ let td = TempDir::new("test").unwrap(); ++ let remote = td.path().join("remote"); ++ Repository::init_bare(&remote).unwrap(); ++ ++ let (_td, repo) = ::test::repo_init(); ++ let url = if cfg!(unix) { ++ format!("file://{}", remote.display()) ++ } else { ++ format!("file:///{}", remote.display().to_string() ++ .replace("\\", "/")) ++ }; ++ ++ let mut origin = repo.remote("origin", &url).unwrap(); ++ assert_eq!(origin.name(), Some("origin")); ++ assert_eq!(origin.url(), Some(&url[..])); ++ assert_eq!(origin.pushurl(), None); ++ ++ { ++ let mut specs = origin.refspecs(); ++ let spec = specs.next().unwrap(); ++ assert!(specs.next().is_none()); ++ assert_eq!(spec.str(), Some("+refs/heads/*:refs/remotes/origin/*")); ++ assert_eq!(spec.dst(), Some("refs/remotes/origin/*")); ++ assert_eq!(spec.src(), Some("refs/heads/*")); ++ assert!(spec.is_force()); ++ } ++ assert!(origin.refspecs().next_back().is_some()); ++ { ++ let remotes = repo.remotes().unwrap(); ++ assert_eq!(remotes.len(), 1); ++ assert_eq!(remotes.get(0), Some("origin")); ++ assert_eq!(remotes.iter().count(), 1); ++ assert_eq!(remotes.iter().next().unwrap(), Some("origin")); ++ } ++ ++ origin.connect(Direction::Push).unwrap(); ++ assert!(origin.connected()); ++ origin.disconnect(); ++ ++ origin.connect(Direction::Fetch).unwrap(); ++ assert!(origin.connected()); ++ origin.download(&[], None).unwrap(); ++ origin.disconnect(); ++ ++ { ++ let mut connection = origin.connect_auth(Direction::Push, None, None).unwrap(); ++ assert!(connection.connected()); ++ } ++ assert!(!origin.connected()); ++ ++ { ++ let mut connection = origin.connect_auth(Direction::Fetch, None, None).unwrap(); ++ assert!(connection.connected()); ++ } ++ assert!(!origin.connected()); ++ ++ origin.fetch(&[], None, None).unwrap(); ++ origin.fetch(&[], None, Some("foo")).unwrap(); ++ origin.update_tips(None, true, AutotagOption::Unspecified, None).unwrap(); ++ origin.update_tips(None, true, AutotagOption::All, Some("foo")).unwrap(); ++ ++ t!(repo.remote_add_fetch("origin", "foo")); ++ t!(repo.remote_add_fetch("origin", "bar")); ++ } ++ ++ #[test] ++ fn rename_remote() { ++ let (_td, repo) = ::test::repo_init(); ++ repo.remote("origin", "foo").unwrap(); ++ repo.remote_rename("origin", "foo").unwrap(); ++ repo.remote_delete("foo").unwrap(); ++ } ++ ++ #[test] ++ fn create_remote_anonymous() { ++ let td = TempDir::new("test").unwrap(); ++ let repo = Repository::init(td.path()).unwrap(); ++ ++ let origin = repo.remote_anonymous("/path/to/nowhere").unwrap(); ++ assert_eq!(origin.name(), None); ++ drop(origin.clone()); ++ } ++ ++ #[test] ++ fn is_valid() { ++ assert!(Remote::is_valid_name("foobar")); ++ assert!(!Remote::is_valid_name("\x01")); ++ } ++ ++ #[test] ++ fn transfer_cb() { ++ let (td, _repo) = ::test::repo_init(); ++ let td2 = TempDir::new("git").unwrap(); ++ let url = ::test::path2url(&td.path()); ++ ++ let repo = Repository::init(td2.path()).unwrap(); ++ let progress_hit = Cell::new(false); ++ { ++ let mut callbacks = RemoteCallbacks::new(); ++ let mut origin = repo.remote("origin", &url).unwrap(); ++ ++ callbacks.transfer_progress(|_progress| { ++ progress_hit.set(true); ++ true ++ }); ++ origin.fetch(&[], ++ Some(FetchOptions::new().remote_callbacks(callbacks)), ++ None).unwrap(); ++ ++ let list = t!(origin.list()); ++ assert_eq!(list.len(), 2); ++ assert_eq!(list[0].name(), "HEAD"); ++ assert!(!list[0].is_local()); ++ assert_eq!(list[1].name(), "refs/heads/master"); ++ assert!(!list[1].is_local()); ++ } ++ assert!(progress_hit.get()); ++ } ++ ++ /// This test is meant to assure that the callbacks provided to connect will not cause ++ /// segfaults ++ #[test] ++ fn connect_list() { ++ let (td, _repo) = ::test::repo_init(); ++ let td2 = TempDir::new("git").unwrap(); ++ let url = ::test::path2url(&td.path()); ++ ++ let repo = Repository::init(td2.path()).unwrap(); ++ let mut callbacks = RemoteCallbacks::new(); ++ callbacks.sideband_progress(|_progress| { ++ // no-op ++ true ++ }); ++ ++ let mut origin = repo.remote("origin", &url).unwrap(); ++ ++ { ++ let mut connection = origin.connect_auth(Direction::Fetch, Some(callbacks), None).unwrap(); ++ assert!(connection.connected()); ++ ++ let list = t!(connection.list()); ++ assert_eq!(list.len(), 2); ++ assert_eq!(list[0].name(), "HEAD"); ++ assert!(!list[0].is_local()); ++ assert_eq!(list[1].name(), "refs/heads/master"); ++ assert!(!list[1].is_local()); ++ } ++ assert!(!origin.connected()); ++ } ++ ++ #[test] ++ fn push() { ++ let (_td, repo) = ::test::repo_init(); ++ let td2 = TempDir::new("git1").unwrap(); ++ let td3 = TempDir::new("git2").unwrap(); ++ let url = ::test::path2url(&td2.path()); ++ ++ Repository::init_bare(td2.path()).unwrap(); ++ // git push ++ let mut remote = repo.remote("origin", &url).unwrap(); ++ let mut updated = false; ++ { ++ let mut callbacks = RemoteCallbacks::new(); ++ callbacks.push_update_reference(|refname, status| { ++ updated = true; ++ assert_eq!(refname, "refs/heads/master"); ++ assert_eq!(status, None); ++ Ok(()) ++ }); ++ let mut options = PushOptions::new(); ++ options.remote_callbacks(callbacks); ++ remote.push(&["refs/heads/master"], Some(&mut options)).unwrap(); ++ } ++ assert!(updated); ++ ++ let repo = Repository::clone(&url, td3.path()).unwrap(); ++ let commit = repo.head().unwrap().target().unwrap(); ++ let commit = repo.find_commit(commit).unwrap(); ++ assert_eq!(commit.message(), Some("initial")); ++ } ++} diff --cc vendor/git2-0.6.8/src/remote_callbacks.rs index 000000000,000000000..a47260964 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/remote_callbacks.rs @@@ -1,0 -1,0 +1,389 @@@ ++use std::ffi::CStr; ++use std::marker; ++use std::mem; ++use std::slice; ++use std::ptr; ++use std::str; ++use libc::{c_void, c_int, c_char, c_uint}; ++ ++use {raw, panic, Error, Cred, CredentialType, Oid}; ++use cert::Cert; ++use util::Binding; ++ ++/// A structure to contain the callbacks which are invoked when a repository is ++/// being updated or downloaded. ++/// ++/// These callbacks are used to manage facilities such as authentication, ++/// transfer progress, etc. ++pub struct RemoteCallbacks<'a> { ++ progress: Option>>, ++ credentials: Option>>, ++ sideband_progress: Option>>, ++ update_tips: Option>>, ++ certificate_check: Option>>, ++ push_update_reference: Option>>, ++} ++ ++/// Struct representing the progress by an in-flight transfer. ++pub struct Progress<'a> { ++ raw: ProgressState, ++ _marker: marker::PhantomData<&'a raw::git_transfer_progress>, ++} ++ ++enum ProgressState { ++ Borrowed(*const raw::git_transfer_progress), ++ Owned(raw::git_transfer_progress), ++} ++ ++/// Callback used to acquire credentials for when a remote is fetched. ++/// ++/// * `url` - the resource for which the credentials are required. ++/// * `username_from_url` - the username that was embedded in the url, or `None` ++/// if it was not included. ++/// * `allowed_types` - a bitmask stating which cred types are ok to return. ++pub type Credentials<'a> = FnMut(&str, Option<&str>, CredentialType) ++ -> Result + 'a; ++ ++/// Callback to be invoked while a transfer is in progress. ++/// ++/// This callback will be periodically called with updates to the progress of ++/// the transfer so far. The return value indicates whether the transfer should ++/// continue. A return value of `false` will cancel the transfer. ++/// ++/// * `progress` - the progress being made so far. ++pub type TransferProgress<'a> = FnMut(Progress) -> bool + 'a; ++ ++/// Callback for receiving messages delivered by the transport. ++/// ++/// The return value indicates whether the network operation should continue. ++pub type TransportMessage<'a> = FnMut(&[u8]) -> bool + 'a; ++ ++/// Callback for whenever a reference is updated locally. ++pub type UpdateTips<'a> = FnMut(&str, Oid, Oid) -> bool + 'a; ++ ++/// Callback for a custom certificate check. ++/// ++/// The first argument is the certificate receved on the connection. ++/// Certificates are typically either an SSH or X509 certificate. ++/// ++/// The second argument is the hostname for the connection is passed as the last ++/// argument. ++pub type CertificateCheck<'a> = FnMut(&Cert, &str) -> bool + 'a; ++ ++/// Callback for each updated reference on push. ++/// ++/// The first argument here is the `refname` of the reference, and the second is ++/// the status message sent by a server. If the status is `Some` then the update ++/// was rejected by the remote server with a reason why. ++pub type PushUpdateReference<'a> = FnMut(&str, Option<&str>) -> Result<(), Error> + 'a; ++ ++impl<'a> Default for RemoteCallbacks<'a> { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl<'a> RemoteCallbacks<'a> { ++ /// Creates a new set of empty callbacks ++ pub fn new() -> RemoteCallbacks<'a> { ++ RemoteCallbacks { ++ credentials: None, ++ progress: None, ++ sideband_progress: None, ++ update_tips: None, ++ certificate_check: None, ++ push_update_reference: None, ++ } ++ } ++ ++ /// The callback through which to fetch credentials if required. ++ pub fn credentials(&mut self, cb: F) -> &mut RemoteCallbacks<'a> ++ where F: FnMut(&str, Option<&str>, CredentialType) ++ -> Result + 'a ++ { ++ self.credentials = Some(Box::new(cb) as Box>); ++ self ++ } ++ ++ /// The callback through which progress is monitored. ++ pub fn transfer_progress(&mut self, cb: F) -> &mut RemoteCallbacks<'a> ++ where F: FnMut(Progress) -> bool + 'a { ++ self.progress = Some(Box::new(cb) as Box>); ++ self ++ } ++ ++ /// Textual progress from the remote. ++ /// ++ /// Text sent over the progress side-band will be passed to this function ++ /// (this is the 'counting objects' output. ++ pub fn sideband_progress(&mut self, cb: F) -> &mut RemoteCallbacks<'a> ++ where F: FnMut(&[u8]) -> bool + 'a { ++ self.sideband_progress = Some(Box::new(cb) as Box>); ++ self ++ } ++ ++ /// Each time a reference is updated locally, the callback will be called ++ /// with information about it. ++ pub fn update_tips(&mut self, cb: F) -> &mut RemoteCallbacks<'a> ++ where F: FnMut(&str, Oid, Oid) -> bool + 'a { ++ self.update_tips = Some(Box::new(cb) as Box>); ++ self ++ } ++ ++ /// If certificate verification fails, then this callback will be invoked to ++ /// let the caller make the final decision of whether to allow the ++ /// connection to proceed. ++ pub fn certificate_check(&mut self, cb: F) -> &mut RemoteCallbacks<'a> ++ where F: FnMut(&Cert, &str) -> bool + 'a ++ { ++ self.certificate_check = Some(Box::new(cb) as Box>); ++ self ++ } ++ ++ /// Set a callback to get invoked for each updated reference on a push. ++ /// ++ /// The first argument to the callback is the name of the reference and the ++ /// second is a status message sent by the server. If the status is `Some` ++ /// then the push was rejected. ++ pub fn push_update_reference(&mut self, cb: F) -> &mut RemoteCallbacks<'a> ++ where F: FnMut(&str, Option<&str>) -> Result<(), Error> + 'a, ++ { ++ self.push_update_reference = Some(Box::new(cb) as Box>); ++ self ++ } ++} ++ ++impl<'a> Binding for RemoteCallbacks<'a> { ++ type Raw = raw::git_remote_callbacks; ++ unsafe fn from_raw(_raw: raw::git_remote_callbacks) -> RemoteCallbacks<'a> { ++ panic!("unimplemented"); ++ } ++ ++ fn raw(&self) -> raw::git_remote_callbacks { ++ unsafe { ++ let mut callbacks: raw::git_remote_callbacks = mem::zeroed(); ++ assert_eq!(raw::git_remote_init_callbacks(&mut callbacks, ++ raw::GIT_REMOTE_CALLBACKS_VERSION), 0); ++ if self.progress.is_some() { ++ let f: raw::git_transfer_progress_cb = transfer_progress_cb; ++ callbacks.transfer_progress = Some(f); ++ } ++ if self.credentials.is_some() { ++ let f: raw::git_cred_acquire_cb = credentials_cb; ++ callbacks.credentials = Some(f); ++ } ++ if self.sideband_progress.is_some() { ++ let f: raw::git_transport_message_cb = sideband_progress_cb; ++ callbacks.sideband_progress = Some(f); ++ } ++ if self.certificate_check.is_some() { ++ let f: raw::git_transport_certificate_check_cb = ++ certificate_check_cb; ++ callbacks.certificate_check = Some(f); ++ } ++ if self.push_update_reference.is_some() { ++ let f: extern fn(_, _, _) -> c_int = push_update_reference_cb; ++ callbacks.push_update_reference = Some(f); ++ } ++ if self.update_tips.is_some() { ++ let f: extern fn(*const c_char, *const raw::git_oid, ++ *const raw::git_oid, *mut c_void) -> c_int ++ = update_tips_cb; ++ callbacks.update_tips = Some(f); ++ } ++ callbacks.payload = self as *const _ as *mut _; ++ callbacks ++ } ++ } ++} ++ ++impl<'a> Progress<'a> { ++ /// Number of objects in the packfile being downloaded ++ pub fn total_objects(&self) -> usize { ++ unsafe { (*self.raw()).total_objects as usize } ++ } ++ /// Received objects that have been hashed ++ pub fn indexed_objects(&self) -> usize { ++ unsafe { (*self.raw()).indexed_objects as usize } ++ } ++ /// Objects which have been downloaded ++ pub fn received_objects(&self) -> usize { ++ unsafe { (*self.raw()).received_objects as usize } ++ } ++ /// Locally-available objects that have been injected in order to fix a thin ++ /// pack. ++ pub fn local_objects(&self) -> usize { ++ unsafe { (*self.raw()).local_objects as usize } ++ } ++ /// Number of deltas in the packfile being downloaded ++ pub fn total_deltas(&self) -> usize { ++ unsafe { (*self.raw()).total_deltas as usize } ++ } ++ /// Received deltas that have been hashed. ++ pub fn indexed_deltas(&self) -> usize { ++ unsafe { (*self.raw()).indexed_deltas as usize } ++ } ++ /// Size of the packfile received up to now ++ pub fn received_bytes(&self) -> usize { ++ unsafe { (*self.raw()).received_bytes as usize } ++ } ++ ++ /// Convert this to an owned version of `Progress`. ++ pub fn to_owned(&self) -> Progress<'static> { ++ Progress { ++ raw: ProgressState::Owned(unsafe { *self.raw() }), ++ _marker: marker::PhantomData, ++ } ++ } ++} ++ ++impl<'a> Binding for Progress<'a> { ++ type Raw = *const raw::git_transfer_progress; ++ unsafe fn from_raw(raw: *const raw::git_transfer_progress) ++ -> Progress<'a> { ++ Progress { ++ raw: ProgressState::Borrowed(raw), ++ _marker: marker::PhantomData, ++ } ++ } ++ ++ fn raw(&self) -> *const raw::git_transfer_progress { ++ match self.raw { ++ ProgressState::Borrowed(raw) => raw, ++ ProgressState::Owned(ref raw) => raw as *const _, ++ } ++ } ++} ++ ++extern fn credentials_cb(ret: *mut *mut raw::git_cred, ++ url: *const c_char, ++ username_from_url: *const c_char, ++ allowed_types: c_uint, ++ payload: *mut c_void) -> c_int { ++ unsafe { ++ let ok = panic::wrap(|| { ++ let payload = &mut *(payload as *mut RemoteCallbacks); ++ let callback = try!(payload.credentials.as_mut() ++ .ok_or(raw::GIT_PASSTHROUGH as c_int)); ++ *ret = ptr::null_mut(); ++ let url = try!(str::from_utf8(CStr::from_ptr(url).to_bytes()) ++ .map_err(|_| raw::GIT_PASSTHROUGH as c_int)); ++ let username_from_url = match ::opt_bytes(&url, username_from_url) { ++ Some(username) => { ++ Some(try!(str::from_utf8(username) ++ .map_err(|_| raw::GIT_PASSTHROUGH as c_int))) ++ } ++ None => None, ++ }; ++ ++ let cred_type = CredentialType::from_bits_truncate(allowed_types as u32); ++ ++ callback(url, username_from_url, cred_type).map_err(|e| { ++ e.raw_code() as c_int ++ }) ++ }); ++ match ok { ++ Some(Ok(cred)) => { ++ // Turns out it's a memory safety issue if we pass through any ++ // and all credentials into libgit2 ++ if allowed_types & (cred.credtype() as c_uint) != 0 { ++ *ret = cred.unwrap(); ++ 0 ++ } else { ++ raw::GIT_PASSTHROUGH as c_int ++ } ++ } ++ Some(Err(e)) => e, ++ None => -1, ++ } ++ } ++} ++ ++extern fn transfer_progress_cb(stats: *const raw::git_transfer_progress, ++ payload: *mut c_void) -> c_int { ++ let ok = panic::wrap(|| unsafe { ++ let payload = &mut *(payload as *mut RemoteCallbacks); ++ let callback = match payload.progress { ++ Some(ref mut c) => c, ++ None => return true, ++ }; ++ let progress = Binding::from_raw(stats); ++ callback(progress) ++ }); ++ if ok == Some(true) {0} else {-1} ++} ++ ++extern fn sideband_progress_cb(str: *const c_char, ++ len: c_int, ++ payload: *mut c_void) -> c_int { ++ let ok = panic::wrap(|| unsafe { ++ let payload = &mut *(payload as *mut RemoteCallbacks); ++ let callback = match payload.sideband_progress { ++ Some(ref mut c) => c, ++ None => return true, ++ }; ++ let buf = slice::from_raw_parts(str as *const u8, len as usize); ++ callback(buf) ++ }); ++ if ok == Some(true) {0} else {-1} ++} ++ ++extern fn update_tips_cb(refname: *const c_char, ++ a: *const raw::git_oid, ++ b: *const raw::git_oid, ++ data: *mut c_void) -> c_int { ++ let ok = panic::wrap(|| unsafe { ++ let payload = &mut *(data as *mut RemoteCallbacks); ++ let callback = match payload.update_tips { ++ Some(ref mut c) => c, ++ None => return true, ++ }; ++ let refname = str::from_utf8(CStr::from_ptr(refname).to_bytes()) ++ .unwrap(); ++ let a = Binding::from_raw(a); ++ let b = Binding::from_raw(b); ++ callback(refname, a, b) ++ }); ++ if ok == Some(true) {0} else {-1} ++} ++ ++extern fn certificate_check_cb(cert: *mut raw::git_cert, ++ _valid: c_int, ++ hostname: *const c_char, ++ data: *mut c_void) -> c_int { ++ let ok = panic::wrap(|| unsafe { ++ let payload = &mut *(data as *mut RemoteCallbacks); ++ let callback = match payload.certificate_check { ++ Some(ref mut c) => c, ++ None => return true, ++ }; ++ let cert = Binding::from_raw(cert); ++ let hostname = str::from_utf8(CStr::from_ptr(hostname).to_bytes()) ++ .unwrap(); ++ callback(&cert, hostname) ++ }); ++ if ok == Some(true) {0} else {-1} ++} ++ ++extern fn push_update_reference_cb(refname: *const c_char, ++ status: *const c_char, ++ data: *mut c_void) -> c_int { ++ panic::wrap(|| unsafe { ++ let payload = &mut *(data as *mut RemoteCallbacks); ++ let callback = match payload.push_update_reference { ++ Some(ref mut c) => c, ++ None => return 0, ++ }; ++ let refname = str::from_utf8(CStr::from_ptr(refname).to_bytes()) ++ .unwrap(); ++ let status = if status.is_null() { ++ None ++ } else { ++ Some(str::from_utf8(CStr::from_ptr(status).to_bytes()).unwrap()) ++ }; ++ match callback(refname, status) { ++ Ok(()) => 0, ++ Err(e) => e.raw_code(), ++ } ++ }).unwrap_or(-1) ++} diff --cc vendor/git2-0.6.8/src/repo.rs index 000000000,000000000..ad128beba new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/repo.rs @@@ -1,0 -1,0 +1,2346 @@@ ++use std::env; ++use std::ffi::{CStr, CString, OsStr}; ++use std::iter::IntoIterator; ++use std::mem; ++use std::path::Path; ++use std::ptr; ++use std::str; ++use libc::{c_int, c_char, size_t, c_void, c_uint}; ++ ++use {raw, Revspec, Error, init, Object, RepositoryOpenFlags, RepositoryState, Remote, Buf, StashFlags}; ++use {ResetType, Signature, Reference, References, Submodule, Blame, BlameOptions}; ++use {Branches, BranchType, Index, Config, Oid, Blob, BlobWriter, Branch, Commit, Tree}; ++use {AnnotatedCommit, MergeOptions, SubmoduleIgnore, SubmoduleStatus, MergeAnalysis, MergePreference}; ++use {ObjectType, Tag, Note, Notes, StatusOptions, Statuses, Status, Revwalk}; ++use {RevparseMode, RepositoryInitMode, Reflog, IntoCString, Describe}; ++use {DescribeOptions, TreeBuilder, Diff, DiffOptions, PackBuilder}; ++use build::{RepoBuilder, CheckoutBuilder}; ++use stash::{StashApplyOptions, StashCbData, stash_cb}; ++use string_array::StringArray; ++use oid_array::OidArray; ++use util::{self, Binding}; ++ ++/// An owned git repository, representing all state associated with the ++/// underlying filesystem. ++/// ++/// This structure corresponds to a `git_repository` in libgit2. Many other ++/// types in git2-rs are derivative from this structure and are attached to its ++/// lifetime. ++/// ++/// When a repository goes out of scope it is freed in memory but not deleted ++/// from the filesystem. ++pub struct Repository { ++ raw: *mut raw::git_repository, ++} ++ ++// It is the current belief that a `Repository` can be sent among threads, or ++// even shared among threads in a mutex. ++unsafe impl Send for Repository {} ++ ++/// Options which can be used to configure how a repository is initialized ++pub struct RepositoryInitOptions { ++ flags: u32, ++ mode: u32, ++ workdir_path: Option, ++ description: Option, ++ template_path: Option, ++ initial_head: Option, ++ origin_url: Option, ++} ++ ++impl Repository { ++ /// Attempt to open an already-existing repository at `path`. ++ /// ++ /// The path can point to either a normal or bare repository. ++ pub fn open>(path: P) -> Result { ++ init(); ++ let path = try!(path.as_ref().into_c_string()); ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_repository_open(&mut ret, path)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Find and open an existing repository, respecting git environment ++ /// variables. This acts like `open_ext` with the ++ /// `REPOSITORY_OPEN_FROM_ENV` flag, but additionally respects `$GIT_DIR`. ++ /// With `$GIT_DIR` unset, this will search for a repository starting in ++ /// the current directory. ++ pub fn open_from_env() -> Result { ++ init(); ++ let mut ret = ptr::null_mut(); ++ let flags = raw::GIT_REPOSITORY_OPEN_FROM_ENV; ++ unsafe { ++ try_call!(raw::git_repository_open_ext(&mut ret, ++ ptr::null(), ++ flags as c_uint, ++ ptr::null())); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Find and open an existing repository, with additional options. ++ /// ++ /// If flags contains REPOSITORY_OPEN_NO_SEARCH, the path must point ++ /// directly to a repository; otherwise, this may point to a subdirectory ++ /// of a repository, and `open_ext` will search up through parent ++ /// directories. ++ /// ++ /// If flags contains REPOSITORY_OPEN_CROSS_FS, the search through parent ++ /// directories will not cross a filesystem boundary (detected when the ++ /// stat st_dev field changes). ++ /// ++ /// If flags contains REPOSITORY_OPEN_BARE, force opening the repository as ++ /// bare even if it isn't, ignoring any working directory, and defer ++ /// loading the repository configuration for performance. ++ /// ++ /// If flags contains REPOSITORY_OPEN_NO_DOTGIT, don't try appending ++ /// `/.git` to `path`. ++ /// ++ /// If flags contains REPOSITORY_OPEN_FROM_ENV, `open_ext` will ignore ++ /// other flags and `ceiling_dirs`, and respect the same environment ++ /// variables git does. Note, however, that `path` overrides `$GIT_DIR`; to ++ /// respect `$GIT_DIR` as well, use `open_from_env`. ++ /// ++ /// ceiling_dirs specifies a list of paths that the search through parent ++ /// directories will stop before entering. Use the functions in std::env ++ /// to construct or manipulate such a path list. ++ pub fn open_ext(path: P, ++ flags: RepositoryOpenFlags, ++ ceiling_dirs: I) ++ -> Result ++ where P: AsRef, O: AsRef, I: IntoIterator ++ { ++ init(); ++ let path = try!(path.as_ref().into_c_string()); ++ let ceiling_dirs_os = try!(env::join_paths(ceiling_dirs)); ++ let ceiling_dirs = try!(ceiling_dirs_os.into_c_string()); ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_repository_open_ext(&mut ret, ++ path, ++ flags.bits() as c_uint, ++ ceiling_dirs)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Attempt to open an already-existing repository at or above `path` ++ /// ++ /// This starts at `path` and looks up the filesystem hierarchy ++ /// until it finds a repository. ++ pub fn discover>(path: P) -> Result { ++ // TODO: this diverges significantly from the libgit2 API ++ init(); ++ let buf = Buf::new(); ++ let path = try!(path.as_ref().into_c_string()); ++ unsafe { ++ try_call!(raw::git_repository_discover(buf.raw(), path, 1, ++ ptr::null())); ++ } ++ Repository::open(util::bytes2path(&*buf)) ++ } ++ ++ /// Creates a new repository in the specified folder. ++ /// ++ /// This by default will create any necessary directories to create the ++ /// repository, and it will read any user-specified templates when creating ++ /// the repository. This behavior can be configured through `init_opts`. ++ pub fn init>(path: P) -> Result { ++ Repository::init_opts(path, &RepositoryInitOptions::new()) ++ } ++ ++ /// Creates a new `--bare` repository in the specified folder. ++ /// ++ /// The folder must exist prior to invoking this function. ++ pub fn init_bare>(path: P) -> Result { ++ Repository::init_opts(path, RepositoryInitOptions::new().bare(true)) ++ } ++ ++ /// Creates a new `--bare` repository in the specified folder. ++ /// ++ /// The folder must exist prior to invoking this function. ++ pub fn init_opts>(path: P, opts: &RepositoryInitOptions) ++ -> Result { ++ init(); ++ let path = try!(path.as_ref().into_c_string()); ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ let mut opts = opts.raw(); ++ try_call!(raw::git_repository_init_ext(&mut ret, path, &mut opts)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Clone a remote repository. ++ /// ++ /// See the `RepoBuilder` struct for more information. This function will ++ /// delegate to a fresh `RepoBuilder` ++ pub fn clone>(url: &str, into: P) ++ -> Result { ++ ::init(); ++ RepoBuilder::new().clone(url, into.as_ref()) ++ } ++ ++ /// Clone a remote repository, initialize and update its submodules ++ /// recursively. ++ /// ++ /// This is similar to `git clone --recursive`. ++ pub fn clone_recurse>(url: &str, into: P) ++ -> Result { ++ let repo = Repository::clone(url, into)?; ++ repo.update_submodules()?; ++ Ok(repo) ++ } ++ ++ /// Update submodules recursively. ++ /// ++ /// Uninitialized submodules will be initialized. ++ fn update_submodules(&self) -> Result<(), Error> { ++ ++ fn add_subrepos(repo: &Repository, list: &mut Vec) ++ -> Result<(), Error> { ++ for mut subm in repo.submodules()? { ++ subm.update(true, None)?; ++ list.push(subm.open()?); ++ } ++ Ok(()) ++ } ++ ++ let mut repos = Vec::new(); ++ add_subrepos(self, &mut repos)?; ++ while let Some(repo) = repos.pop() { ++ add_subrepos(&repo, &mut repos)?; ++ } ++ Ok(()) ++ } ++ ++ /// Execute a rev-parse operation against the `spec` listed. ++ /// ++ /// The resulting revision specification is returned, or an error is ++ /// returned if one occurs. ++ pub fn revparse(&self, spec: &str) -> Result { ++ let mut raw = raw::git_revspec { ++ from: ptr::null_mut(), ++ to: ptr::null_mut(), ++ flags: 0, ++ }; ++ let spec = try!(CString::new(spec)); ++ unsafe { ++ try_call!(raw::git_revparse(&mut raw, self.raw, spec)); ++ let to = Binding::from_raw_opt(raw.to); ++ let from = Binding::from_raw_opt(raw.from); ++ let mode = RevparseMode::from_bits_truncate(raw.flags as u32); ++ Ok(Revspec::from_objects(from, to, mode)) ++ } ++ } ++ ++ /// Find a single object, as specified by a revision string. ++ pub fn revparse_single(&self, spec: &str) -> Result { ++ let spec = try!(CString::new(spec)); ++ let mut obj = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_revparse_single(&mut obj, self.raw, spec)); ++ assert!(!obj.is_null()); ++ Ok(Binding::from_raw(obj)) ++ } ++ } ++ ++ /// Find a single object and intermediate reference by a revision string. ++ /// ++ /// See `man gitrevisions`, or ++ /// http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for ++ /// information on the syntax accepted. ++ /// ++ /// In some cases (`@{<-n>}` or `@{upstream}`), the expression ++ /// may point to an intermediate reference. When such expressions are being ++ /// passed in, this intermediate reference is returned. ++ pub fn revparse_ext(&self, spec: &str) ++ -> Result<(Object, Option), Error> { ++ let spec = try!(CString::new(spec)); ++ let mut git_obj = ptr::null_mut(); ++ let mut git_ref = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_revparse_ext(&mut git_obj, &mut git_ref, ++ self.raw, spec)); ++ assert!(!git_obj.is_null()); ++ Ok((Binding::from_raw(git_obj), Binding::from_raw_opt(git_ref))) ++ } ++ } ++ ++ /// Tests whether this repository is a bare repository or not. ++ pub fn is_bare(&self) -> bool { ++ unsafe { raw::git_repository_is_bare(self.raw) == 1 } ++ } ++ ++ /// Tests whether this repository is a shallow clone. ++ pub fn is_shallow(&self) -> bool { ++ unsafe { raw::git_repository_is_shallow(self.raw) == 1 } ++ } ++ ++ /// Tests whether this repository is empty. ++ pub fn is_empty(&self) -> Result { ++ let empty = unsafe { ++ try_call!(raw::git_repository_is_empty(self.raw)) ++ }; ++ Ok(empty == 1) ++ } ++ ++ /// Returns the path to the `.git` folder for normal repositories or the ++ /// repository itself for bare repositories. ++ pub fn path(&self) -> &Path { ++ unsafe { ++ let ptr = raw::git_repository_path(self.raw); ++ util::bytes2path(::opt_bytes(self, ptr).unwrap()) ++ } ++ } ++ ++ /// Returns the current state of this repository ++ pub fn state(&self) -> RepositoryState { ++ let state = unsafe { raw::git_repository_state(self.raw) }; ++ macro_rules! check( ($($raw:ident => $real:ident),*) => ( ++ $(if state == raw::$raw as c_int { ++ super::RepositoryState::$real ++ }) else * ++ else { ++ panic!("unknown repository state: {}", state) ++ } ++ ) ); ++ ++ check!( ++ GIT_REPOSITORY_STATE_NONE => Clean, ++ GIT_REPOSITORY_STATE_MERGE => Merge, ++ GIT_REPOSITORY_STATE_REVERT => Revert, ++ GIT_REPOSITORY_STATE_REVERT_SEQUENCE => RevertSequence, ++ GIT_REPOSITORY_STATE_CHERRYPICK => CherryPick, ++ GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE => CherryPickSequence, ++ GIT_REPOSITORY_STATE_BISECT => Bisect, ++ GIT_REPOSITORY_STATE_REBASE => Rebase, ++ GIT_REPOSITORY_STATE_REBASE_INTERACTIVE => RebaseInteractive, ++ GIT_REPOSITORY_STATE_REBASE_MERGE => RebaseMerge, ++ GIT_REPOSITORY_STATE_APPLY_MAILBOX => ApplyMailbox, ++ GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE => ApplyMailboxOrRebase ++ ) ++ } ++ ++ /// Get the path of the working directory for this repository. ++ /// ++ /// If this repository is bare, then `None` is returned. ++ pub fn workdir(&self) -> Option<&Path> { ++ unsafe { ++ let ptr = raw::git_repository_workdir(self.raw); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(util::bytes2path(CStr::from_ptr(ptr).to_bytes())) ++ } ++ } ++ } ++ ++ /// Set the path to the working directory for this repository. ++ /// ++ /// If `update_link` is true, create/update the gitlink file in the workdir ++ /// and set config "core.worktree" (if workdir is not the parent of the .git ++ /// directory). ++ pub fn set_workdir(&self, path: &Path, update_gitlink: bool) ++ -> Result<(), Error> { ++ let path = try!(path.into_c_string()); ++ unsafe { ++ try_call!(raw::git_repository_set_workdir(self.raw(), path, ++ update_gitlink)); ++ } ++ Ok(()) ++ } ++ ++ /// Get the currently active namespace for this repository. ++ /// ++ /// If there is no namespace, or the namespace is not a valid utf8 string, ++ /// `None` is returned. ++ pub fn namespace(&self) -> Option<&str> { ++ self.namespace_bytes().and_then(|s| str::from_utf8(s).ok()) ++ } ++ ++ /// Get the currently active namespace for this repository as a byte array. ++ /// ++ /// If there is no namespace, `None` is returned. ++ pub fn namespace_bytes(&self) -> Option<&[u8]> { ++ unsafe { ::opt_bytes(self, raw::git_repository_get_namespace(self.raw)) } ++ } ++ ++ /// List all remotes for a given repository ++ pub fn remotes(&self) -> Result { ++ let mut arr = raw::git_strarray { ++ strings: 0 as *mut *mut c_char, ++ count: 0, ++ }; ++ unsafe { ++ try_call!(raw::git_remote_list(&mut arr, self.raw)); ++ Ok(Binding::from_raw(arr)) ++ } ++ } ++ ++ /// Get the information for a particular remote ++ pub fn find_remote(&self, name: &str) -> Result { ++ let mut ret = ptr::null_mut(); ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_remote_lookup(&mut ret, self.raw, name)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Add a remote with the default fetch refspec to the repository's ++ /// configuration. ++ pub fn remote(&self, name: &str, url: &str) -> Result { ++ let mut ret = ptr::null_mut(); ++ let name = try!(CString::new(name)); ++ let url = try!(CString::new(url)); ++ unsafe { ++ try_call!(raw::git_remote_create(&mut ret, self.raw, name, url)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Create an anonymous remote ++ /// ++ /// Create a remote with the given url and refspec in memory. You can use ++ /// this when you have a URL instead of a remote's name. Note that anonymous ++ /// remotes cannot be converted to persisted remotes. ++ pub fn remote_anonymous(&self, url: &str) -> Result { ++ let mut ret = ptr::null_mut(); ++ let url = try!(CString::new(url)); ++ unsafe { ++ try_call!(raw::git_remote_create_anonymous(&mut ret, self.raw, url)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Give a remote a new name ++ /// ++ /// All remote-tracking branches and configuration settings for the remote ++ /// are updated. ++ /// ++ /// A temporary in-memory remote cannot be given a name with this method. ++ /// ++ /// No loaded instances of the remote with the old name will change their ++ /// name or their list of refspecs. ++ /// ++ /// The returned array of strings is a list of the non-default refspecs ++ /// which cannot be renamed and are returned for further processing by the ++ /// caller. ++ pub fn remote_rename(&self, name: &str, ++ new_name: &str) -> Result { ++ let name = try!(CString::new(name)); ++ let new_name = try!(CString::new(new_name)); ++ let mut problems = raw::git_strarray { ++ count: 0, ++ strings: 0 as *mut *mut c_char, ++ }; ++ unsafe { ++ try_call!(raw::git_remote_rename(&mut problems, self.raw, name, ++ new_name)); ++ Ok(Binding::from_raw(problems)) ++ } ++ } ++ ++ /// Delete an existing persisted remote. ++ /// ++ /// All remote-tracking branches and configuration settings for the remote ++ /// will be removed. ++ pub fn remote_delete(&self, name: &str) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ unsafe { try_call!(raw::git_remote_delete(self.raw, name)); } ++ Ok(()) ++ } ++ ++ /// Add a fetch refspec to the remote's configuration ++ /// ++ /// Add the given refspec to the fetch list in the configuration. No loaded ++ /// remote instances will be affected. ++ pub fn remote_add_fetch(&self, name: &str, spec: &str) ++ -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ let spec = try!(CString::new(spec)); ++ unsafe { ++ try_call!(raw::git_remote_add_fetch(self.raw, name, spec)); ++ } ++ Ok(()) ++ } ++ ++ /// Add a push refspec to the remote's configuration. ++ /// ++ /// Add the given refspec to the push list in the configuration. No ++ /// loaded remote instances will be affected. ++ pub fn remote_add_push(&self, name: &str, spec: &str) ++ -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ let spec = try!(CString::new(spec)); ++ unsafe { ++ try_call!(raw::git_remote_add_push(self.raw, name, spec)); ++ } ++ Ok(()) ++ } ++ ++ /// Set the remote's url in the configuration ++ /// ++ /// Remote objects already in memory will not be affected. This assumes ++ /// the common case of a single-url remote and will otherwise return an ++ /// error. ++ pub fn remote_set_url(&self, name: &str, url: &str) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ let url = try!(CString::new(url)); ++ unsafe { try_call!(raw::git_remote_set_url(self.raw, name, url)); } ++ Ok(()) ++ } ++ ++ /// Set the remote's url for pushing in the configuration. ++ /// ++ /// Remote objects already in memory will not be affected. This assumes ++ /// the common case of a single-url remote and will otherwise return an ++ /// error. ++ /// ++ /// `None` indicates that it should be cleared. ++ pub fn remote_set_pushurl(&self, name: &str, pushurl: Option<&str>) ++ -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ let pushurl = try!(::opt_cstr(pushurl)); ++ unsafe { ++ try_call!(raw::git_remote_set_pushurl(self.raw, name, pushurl)); ++ } ++ Ok(()) ++ } ++ ++ /// Sets the current head to the specified object and optionally resets ++ /// the index and working tree to match. ++ /// ++ /// A soft reset means the head will be moved to the commit. ++ /// ++ /// A mixed reset will trigger a soft reset, plus the index will be ++ /// replaced with the content of the commit tree. ++ /// ++ /// A hard reset will trigger a mixed reset and the working directory will ++ /// be replaced with the content of the index. (Untracked and ignored files ++ /// will be left alone, however.) ++ /// ++ /// The `target` is a commit-ish to which the head should be moved to. The ++ /// object can either be a commit or a tag, but tags must be dereferenceable ++ /// to a commit. ++ /// ++ /// The `checkout` options will only be used for a hard reset. ++ pub fn reset(&self, ++ target: &Object, ++ kind: ResetType, ++ checkout: Option<&mut CheckoutBuilder>) ++ -> Result<(), Error> { ++ unsafe { ++ let mut opts: raw::git_checkout_options = mem::zeroed(); ++ try_call!(raw::git_checkout_init_options(&mut opts, ++ raw::GIT_CHECKOUT_OPTIONS_VERSION)); ++ let opts = checkout.map(|c| { ++ c.configure(&mut opts); &mut opts ++ }); ++ try_call!(raw::git_reset(self.raw, target.raw(), kind, opts)); ++ } ++ Ok(()) ++ } ++ ++ /// Updates some entries in the index from the target commit tree. ++ /// ++ /// The scope of the updated entries is determined by the paths being ++ /// in the iterator provided. ++ /// ++ /// Passing a `None` target will result in removing entries in the index ++ /// matching the provided pathspecs. ++ pub fn reset_default(&self, ++ target: Option<&Object>, ++ paths: I) -> Result<(), Error> ++ where T: IntoCString, I: IntoIterator, ++ { ++ let (_a, _b, mut arr) = try!(::util::iter2cstrs(paths)); ++ let target = target.map(|t| t.raw()); ++ unsafe { ++ try_call!(raw::git_reset_default(self.raw, target, &mut arr)); ++ } ++ Ok(()) ++ } ++ ++ /// Retrieve and resolve the reference pointed at by HEAD. ++ pub fn head(&self) -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_repository_head(&mut ret, self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Make the repository HEAD point to the specified reference. ++ /// ++ /// If the provided reference points to a tree or a blob, the HEAD is ++ /// unaltered and an error is returned. ++ /// ++ /// If the provided reference points to a branch, the HEAD will point to ++ /// that branch, staying attached, or become attached if it isn't yet. If ++ /// the branch doesn't exist yet, no error will be returned. The HEAD will ++ /// then be attached to an unborn branch. ++ /// ++ /// Otherwise, the HEAD will be detached and will directly point to the ++ /// commit. ++ pub fn set_head(&self, refname: &str) -> Result<(), Error> { ++ let refname = try!(CString::new(refname)); ++ unsafe { ++ try_call!(raw::git_repository_set_head(self.raw, refname)); ++ } ++ Ok(()) ++ } ++ ++ /// Make the repository HEAD directly point to the commit. ++ /// ++ /// If the provided committish cannot be found in the repository, the HEAD ++ /// is unaltered and an error is returned. ++ /// ++ /// If the provided commitish cannot be peeled into a commit, the HEAD is ++ /// unaltered and an error is returned. ++ /// ++ /// Otherwise, the HEAD will eventually be detached and will directly point ++ /// to the peeled commit. ++ pub fn set_head_detached(&self, commitish: Oid) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_repository_set_head_detached(self.raw, ++ commitish.raw())); ++ } ++ Ok(()) ++ } ++ ++ /// Create an iterator for the repo's references ++ pub fn references(&self) -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_reference_iterator_new(&mut ret, self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Create an iterator for the repo's references that match the specified ++ /// glob ++ pub fn references_glob(&self, glob: &str) -> Result { ++ let mut ret = ptr::null_mut(); ++ let glob = try!(CString::new(glob)); ++ unsafe { ++ try_call!(raw::git_reference_iterator_glob_new(&mut ret, self.raw, ++ glob)); ++ ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Load all submodules for this repository and return them. ++ pub fn submodules(&self) -> Result, Error> { ++ struct Data<'a, 'b:'a> { ++ repo: &'b Repository, ++ ret: &'a mut Vec>, ++ } ++ let mut ret = Vec::new(); ++ ++ unsafe { ++ let mut data = Data { ++ repo: self, ++ ret: &mut ret, ++ }; ++ try_call!(raw::git_submodule_foreach(self.raw, append, ++ &mut data as *mut _ ++ as *mut c_void)); ++ } ++ ++ return Ok(ret); ++ ++ extern fn append(_repo: *mut raw::git_submodule, ++ name: *const c_char, ++ data: *mut c_void) -> c_int { ++ unsafe { ++ let data = &mut *(data as *mut Data); ++ let mut raw = ptr::null_mut(); ++ let rc = raw::git_submodule_lookup(&mut raw, data.repo.raw(), ++ name); ++ assert_eq!(rc, 0); ++ data.ret.push(Binding::from_raw(raw)); ++ } ++ 0 ++ } ++ } ++ ++ /// Gather file status information and populate the returned structure. ++ /// ++ /// Note that if a pathspec is given in the options to filter the ++ /// status, then the results from rename detection (if you enable it) may ++ /// not be accurate. To do rename detection properly, this must be called ++ /// with no pathspec so that all files can be considered. ++ pub fn statuses(&self, options: Option<&mut StatusOptions>) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_status_list_new(&mut ret, self.raw, ++ options.map(|s| s.raw()) ++ .unwrap_or(ptr::null()))); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Test if the ignore rules apply to a given file. ++ /// ++ /// This function checks the ignore rules to see if they would apply to the ++ /// given file. This indicates if the file would be ignored regardless of ++ /// whether the file is already in the index or committed to the repository. ++ /// ++ /// One way to think of this is if you were to do "git add ." on the ++ /// directory containing the file, would it be added or not? ++ pub fn status_should_ignore(&self, path: &Path) -> Result { ++ let mut ret = 0 as c_int; ++ let path = try!(path.into_c_string()); ++ unsafe { ++ try_call!(raw::git_status_should_ignore(&mut ret, self.raw, ++ path)); ++ } ++ Ok(ret != 0) ++ } ++ ++ /// Get file status for a single file. ++ /// ++ /// This tries to get status for the filename that you give. If no files ++ /// match that name (in either the HEAD, index, or working directory), this ++ /// returns NotFound. ++ /// ++ /// If the name matches multiple files (for example, if the path names a ++ /// directory or if running on a case- insensitive filesystem and yet the ++ /// HEAD has two entries that both match the path), then this returns ++ /// Ambiguous because it cannot give correct results. ++ /// ++ /// This does not do any sort of rename detection. Renames require a set of ++ /// targets and because of the path filtering, there is not enough ++ /// information to check renames correctly. To check file status with rename ++ /// detection, there is no choice but to do a full `statuses` and scan ++ /// through looking for the path that you are interested in. ++ pub fn status_file(&self, path: &Path) -> Result { ++ let mut ret = 0 as c_uint; ++ let path = try!(path.into_c_string()); ++ unsafe { ++ try_call!(raw::git_status_file(&mut ret, self.raw, ++ path)); ++ } ++ Ok(Status::from_bits_truncate(ret as u32)) ++ } ++ ++ /// Create an iterator which loops over the requested branches. ++ pub fn branches(&self, filter: Option) ++ -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_branch_iterator_new(&mut raw, self.raw(), filter)); ++ Ok(Branches::from_raw(raw)) ++ } ++ } ++ ++ /// Get the Index file for this repository. ++ /// ++ /// If a custom index has not been set, the default index for the repository ++ /// will be returned (the one located in .git/index). ++ pub fn index(&self) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_repository_index(&mut raw, self.raw())); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Set the Index file for this repository. ++ pub fn set_index(&self, index: &mut Index) { ++ unsafe { ++ raw::git_repository_set_index(self.raw(), index.raw()); ++ } ++ } ++ ++ /// Get the configuration file for this repository. ++ /// ++ /// If a configuration file has not been set, the default config set for the ++ /// repository will be returned, including global and system configurations ++ /// (if they are available). ++ pub fn config(&self) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_repository_config(&mut raw, self.raw())); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Write an in-memory buffer to the ODB as a blob. ++ /// ++ /// The Oid returned can in turn be passed to `find_blob` to get a handle to ++ /// the blob. ++ pub fn blob(&self, data: &[u8]) -> Result { ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ let ptr = data.as_ptr() as *const c_void; ++ let len = data.len() as size_t; ++ try_call!(raw::git_blob_create_frombuffer(&mut raw, self.raw(), ++ ptr, len)); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++ ++ /// Read a file from the filesystem and write its content to the Object ++ /// Database as a loose blob ++ /// ++ /// The Oid returned can in turn be passed to `find_blob` to get a handle to ++ /// the blob. ++ pub fn blob_path(&self, path: &Path) -> Result { ++ let path = try!(path.into_c_string()); ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_blob_create_fromdisk(&mut raw, self.raw(), ++ path)); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++ ++ /// Create a stream to write blob ++ /// ++ /// This function may need to buffer the data on disk and will in general ++ /// not be the right choice if you know the size of the data to write. ++ /// ++ /// Use `BlobWriter::commit()` to commit the write to the object db ++ /// and get the object id. ++ /// ++ /// If the `hintpath` parameter is filled, it will be used to determine ++ /// what git filters should be applied to the object before it is written ++ /// to the object database. ++ pub fn blob_writer(&self, hintpath: Option<&Path>) -> Result { ++ let path_str = match hintpath { ++ Some(path) => Some(try!(path.into_c_string())), ++ None => None, ++ }; ++ let path = match path_str { ++ Some(ref path) => path.as_ptr(), ++ None => ptr::null(), ++ }; ++ let mut out = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_blob_create_fromstream(&mut out, self.raw(), path)); ++ Ok(BlobWriter::from_raw(out)) ++ } ++ } ++ ++ /// Lookup a reference to one of the objects in a repository. ++ pub fn find_blob(&self, oid: Oid) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_blob_lookup(&mut raw, self.raw(), oid.raw())); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Create a new branch pointing at a target commit ++ /// ++ /// A new direct reference will be created pointing to this target commit. ++ /// If `force` is true and a reference already exists with the given name, ++ /// it'll be replaced. ++ pub fn branch(&self, ++ branch_name: &str, ++ target: &Commit, ++ force: bool) -> Result { ++ let branch_name = try!(CString::new(branch_name)); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_branch_create(&mut raw, ++ self.raw(), ++ branch_name, ++ target.raw(), ++ force)); ++ Ok(Branch::wrap(Binding::from_raw(raw))) ++ } ++ } ++ ++ /// Lookup a branch by its name in a repository. ++ pub fn find_branch(&self, name: &str, branch_type: BranchType) ++ -> Result { ++ let name = try!(CString::new(name)); ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_branch_lookup(&mut ret, self.raw(), name, ++ branch_type)); ++ Ok(Branch::wrap(Binding::from_raw(ret))) ++ } ++ } ++ ++ /// Create new commit in the repository ++ /// ++ /// If the `update_ref` is not `None`, name of the reference that will be ++ /// updated to point to this commit. If the reference is not direct, it will ++ /// be resolved to a direct reference. Use "HEAD" to update the HEAD of the ++ /// current branch and make it point to this commit. If the reference ++ /// doesn't exist yet, it will be created. If it does exist, the first ++ /// parent must be the tip of this branch. ++ pub fn commit(&self, ++ update_ref: Option<&str>, ++ author: &Signature, ++ committer: &Signature, ++ message: &str, ++ tree: &Tree, ++ parents: &[&Commit]) -> Result { ++ let update_ref = try!(::opt_cstr(update_ref)); ++ let mut parent_ptrs = parents.iter().map(|p| { ++ p.raw() as *const raw::git_commit ++ }).collect::>(); ++ let message = try!(CString::new(message)); ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_commit_create(&mut raw, ++ self.raw(), ++ update_ref, ++ author.raw(), ++ committer.raw(), ++ ptr::null(), ++ message, ++ tree.raw(), ++ parents.len() as size_t, ++ parent_ptrs.as_mut_ptr())); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++ ++ ++ /// Lookup a reference to one of the commits in a repository. ++ pub fn find_commit(&self, oid: Oid) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_commit_lookup(&mut raw, self.raw(), oid.raw())); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Creates a `AnnotatedCommit` from the given commit id. ++ pub fn find_annotated_commit(&self, id: Oid) -> Result { ++ unsafe { ++ let mut raw = 0 as *mut raw::git_annotated_commit; ++ try_call!(raw::git_annotated_commit_lookup(&mut raw, self.raw(), id.raw())); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Lookup a reference to one of the objects in a repository. ++ pub fn find_object(&self, oid: Oid, ++ kind: Option) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_object_lookup(&mut raw, self.raw(), oid.raw(), ++ kind)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Create a new direct reference. ++ /// ++ /// This function will return an error if a reference already exists with ++ /// the given name unless force is true, in which case it will be ++ /// overwritten. ++ pub fn reference(&self, name: &str, id: Oid, force: bool, ++ log_message: &str) -> Result { ++ let name = try!(CString::new(name)); ++ let log_message = try!(CString::new(log_message)); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_reference_create(&mut raw, self.raw(), name, ++ id.raw(), force, ++ log_message)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Conditionally create new direct reference. ++ /// ++ /// A direct reference (also called an object id reference) refers directly ++ /// to a specific object id (a.k.a. OID or SHA) in the repository. The id ++ /// permanently refers to the object (although the reference itself can be ++ /// moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0" ++ /// refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977. ++ /// ++ /// The direct reference will be created in the repository and written to ++ /// the disk. ++ /// ++ /// Valid reference names must follow one of two patterns: ++ /// ++ /// 1. Top-level names must contain only capital letters and underscores, ++ /// and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). ++ /// 2. Names prefixed with "refs/" can be almost anything. You must avoid ++ /// the characters `~`, `^`, `:`, `\\`, `?`, `[`, and `*`, and the ++ /// sequences ".." and "@{" which have special meaning to revparse. ++ /// ++ /// This function will return an error if a reference already exists with ++ /// the given name unless `force` is true, in which case it will be ++ /// overwritten. ++ /// ++ /// The message for the reflog will be ignored if the reference does not ++ /// belong in the standard set (HEAD, branches and remote-tracking ++ /// branches) and it does not have a reflog. ++ /// ++ /// It will return GIT_EMODIFIED if the reference's value at the time of ++ /// updating does not match the one passed through `current_id` (i.e. if the ++ /// ref has changed since the user read it). ++ pub fn reference_matching(&self, ++ name: &str, ++ id: Oid, ++ force: bool, ++ current_id: Oid, ++ log_message: &str) -> Result { ++ let name = try!(CString::new(name)); ++ let log_message = try!(CString::new(log_message)); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_reference_create_matching(&mut raw, ++ self.raw(), ++ name, ++ id.raw(), ++ force, ++ current_id.raw(), ++ log_message)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Create a new symbolic reference. ++ /// ++ /// This function will return an error if a reference already exists with ++ /// the given name unless force is true, in which case it will be ++ /// overwritten. ++ pub fn reference_symbolic(&self, name: &str, target: &str, ++ force: bool, ++ log_message: &str) ++ -> Result { ++ let name = try!(CString::new(name)); ++ let target = try!(CString::new(target)); ++ let log_message = try!(CString::new(log_message)); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_reference_symbolic_create(&mut raw, self.raw(), ++ name, target, force, ++ log_message)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Create a new symbolic reference. ++ /// ++ /// This function will return an error if a reference already exists with ++ /// the given name unless force is true, in which case it will be ++ /// overwritten. ++ /// ++ /// It will return GIT_EMODIFIED if the reference's value at the time of ++ /// updating does not match the one passed through current_value (i.e. if ++ /// the ref has changed since the user read it). ++ pub fn reference_symbolic_matching(&self, ++ name: &str, ++ target: &str, ++ force: bool, ++ current_value: &str, ++ log_message: &str) ++ -> Result { ++ let name = try!(CString::new(name)); ++ let target = try!(CString::new(target)); ++ let current_value = try!(CString::new(current_value)); ++ let log_message = try!(CString::new(log_message)); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_reference_symbolic_create_matching(&mut raw, ++ self.raw(), ++ name, ++ target, ++ force, ++ current_value, ++ log_message)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Lookup a reference to one of the objects in a repository. ++ pub fn find_reference(&self, name: &str) -> Result { ++ let name = try!(CString::new(name)); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_reference_lookup(&mut raw, self.raw(), name)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Lookup a reference by name and resolve immediately to OID. ++ /// ++ /// This function provides a quick way to resolve a reference name straight ++ /// through to the object id that it refers to. This avoids having to ++ /// allocate or free any `Reference` objects for simple situations. ++ pub fn refname_to_id(&self, name: &str) -> Result { ++ let name = try!(CString::new(name)); ++ let mut ret = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_reference_name_to_id(&mut ret, self.raw(), name)); ++ Ok(Binding::from_raw(&ret as *const _)) ++ } ++ } ++ ++ /// Creates a git_annotated_commit from the given reference. ++ pub fn reference_to_annotated_commit(&self, reference: &Reference) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_annotated_commit_from_ref(&mut ret, ++ self.raw(), ++ reference.raw())); ++ Ok(AnnotatedCommit::from_raw(ret)) ++ } ++ } ++ ++ /// Create a new action signature with default user and now timestamp. ++ /// ++ /// This looks up the user.name and user.email from the configuration and ++ /// uses the current time as the timestamp, and creates a new signature ++ /// based on that information. It will return `NotFound` if either the ++ /// user.name or user.email are not set. ++ pub fn signature(&self) -> Result, Error> { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_signature_default(&mut ret, self.raw())); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Set up a new git submodule for checkout. ++ /// ++ /// This does "git submodule add" up to the fetch and checkout of the ++ /// submodule contents. It preps a new submodule, creates an entry in ++ /// `.gitmodules` and creates an empty initialized repository either at the ++ /// given path in the working directory or in `.git/modules` with a gitlink ++ /// from the working directory to the new repo. ++ /// ++ /// To fully emulate "git submodule add" call this function, then `open()` ++ /// the submodule repo and perform the clone step as needed. Lastly, call ++ /// `add_finalize()` to wrap up adding the new submodule and `.gitmodules` ++ /// to the index to be ready to commit. ++ pub fn submodule(&self, url: &str, path: &Path, ++ use_gitlink: bool) -> Result { ++ let url = try!(CString::new(url)); ++ let path = try!(path.into_c_string()); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_submodule_add_setup(&mut raw, self.raw(), ++ url, path, use_gitlink)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Lookup submodule information by name or path. ++ /// ++ /// Given either the submodule name or path (they are usually the same), ++ /// this returns a structure describing the submodule. ++ pub fn find_submodule(&self, name: &str) -> Result { ++ let name = try!(CString::new(name)); ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_submodule_lookup(&mut raw, self.raw(), name)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Get the status for a submodule. ++ /// ++ /// This looks at a submodule and tries to determine the status. It ++ /// will return a combination of the `SubmoduleStatus` values. ++ pub fn submodule_status(&self, name: &str, ignore: SubmoduleIgnore) ++ -> Result { ++ let mut ret = 0; ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_submodule_status(&mut ret, self.raw, name, ++ ignore)); ++ } ++ Ok(SubmoduleStatus::from_bits_truncate(ret as u32)) ++ } ++ ++ /// Lookup a reference to one of the objects in a repository. ++ pub fn find_tree(&self, oid: Oid) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_tree_lookup(&mut raw, self.raw(), oid.raw())); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Create a new TreeBuilder, optionally initialized with the ++ /// entries of the given Tree. ++ /// ++ /// The tree builder can be used to create or modify trees in memory and ++ /// write them as tree objects to the database. ++ pub fn treebuilder(&self, tree: Option<&Tree>) -> Result { ++ unsafe { ++ let mut ret = ptr::null_mut(); ++ let tree = match tree { ++ Some(tree) => tree.raw(), ++ None => ptr::null_mut(), ++ }; ++ try_call!(raw::git_treebuilder_new(&mut ret, self.raw, tree)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ ++ /// Create a new tag in the repository from an object ++ /// ++ /// A new reference will also be created pointing to this tag object. If ++ /// `force` is true and a reference already exists with the given name, ++ /// it'll be replaced. ++ /// ++ /// The message will not be cleaned up. ++ /// ++ /// The tag name will be checked for validity. You must avoid the characters ++ /// '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences ".." and " @ ++ /// {" which have special meaning to revparse. ++ pub fn tag(&self, name: &str, target: &Object, ++ tagger: &Signature, message: &str, ++ force: bool) -> Result { ++ let name = try!(CString::new(name)); ++ let message = try!(CString::new(message)); ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_tag_create(&mut raw, self.raw, name, ++ target.raw(), tagger.raw(), ++ message, force)); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++ ++ /// Create a new lightweight tag pointing at a target object ++ /// ++ /// A new direct reference will be created pointing to this target object. ++ /// If force is true and a reference already exists with the given name, ++ /// it'll be replaced. ++ pub fn tag_lightweight(&self, ++ name: &str, ++ target: &Object, ++ force: bool) -> Result { ++ let name = try!(CString::new(name)); ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_tag_create_lightweight(&mut raw, self.raw, name, ++ target.raw(), force)); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++ ++ /// Lookup a tag object from the repository. ++ pub fn find_tag(&self, id: Oid) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_tag_lookup(&mut raw, self.raw, id.raw())); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Delete an existing tag reference. ++ /// ++ /// The tag name will be checked for validity, see `tag` for some rules ++ /// about valid names. ++ pub fn tag_delete(&self, name: &str) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_tag_delete(self.raw, name)); ++ Ok(()) ++ } ++ } ++ ++ /// Get a list with all the tags in the repository. ++ /// ++ /// An optional fnmatch pattern can also be specified. ++ pub fn tag_names(&self, pattern: Option<&str>) -> Result { ++ let mut arr = raw::git_strarray { ++ strings: 0 as *mut *mut c_char, ++ count: 0, ++ }; ++ unsafe { ++ match pattern { ++ Some(s) => { ++ let s = try!(CString::new(s)); ++ try_call!(raw::git_tag_list_match(&mut arr, s, self.raw)); ++ } ++ None => { try_call!(raw::git_tag_list(&mut arr, self.raw)); } ++ } ++ Ok(Binding::from_raw(arr)) ++ } ++ } ++ ++ /// Updates files in the index and the working tree to match the content of ++ /// the commit pointed at by HEAD. ++ pub fn checkout_head(&self, opts: Option<&mut CheckoutBuilder>) ++ -> Result<(), Error> { ++ unsafe { ++ let mut raw_opts = mem::zeroed(); ++ try_call!(raw::git_checkout_init_options(&mut raw_opts, ++ raw::GIT_CHECKOUT_OPTIONS_VERSION)); ++ if let Some(c) = opts { ++ c.configure(&mut raw_opts); ++ } ++ ++ try_call!(raw::git_checkout_head(self.raw, &raw_opts)); ++ } ++ Ok(()) ++ } ++ ++ /// Updates files in the working tree to match the content of the index. ++ /// ++ /// If the index is `None`, the repository's index will be used. ++ pub fn checkout_index(&self, ++ index: Option<&mut Index>, ++ opts: Option<&mut CheckoutBuilder>) -> Result<(), Error> { ++ unsafe { ++ let mut raw_opts = mem::zeroed(); ++ try_call!(raw::git_checkout_init_options(&mut raw_opts, ++ raw::GIT_CHECKOUT_OPTIONS_VERSION)); ++ if let Some(c) = opts { ++ c.configure(&mut raw_opts); ++ } ++ ++ try_call!(raw::git_checkout_index(self.raw, ++ index.map(|i| &mut *i.raw()), ++ &raw_opts)); ++ } ++ Ok(()) ++ } ++ ++ /// Updates files in the index and working tree to match the content of the ++ /// tree pointed at by the treeish. ++ pub fn checkout_tree(&self, ++ treeish: &Object, ++ opts: Option<&mut CheckoutBuilder>) -> Result<(), Error> { ++ unsafe { ++ let mut raw_opts = mem::zeroed(); ++ try_call!(raw::git_checkout_init_options(&mut raw_opts, ++ raw::GIT_CHECKOUT_OPTIONS_VERSION)); ++ if let Some(c) = opts { ++ c.configure(&mut raw_opts); ++ } ++ ++ try_call!(raw::git_checkout_tree(self.raw, &*treeish.raw(), ++ &raw_opts)); ++ } ++ Ok(()) ++ } ++ ++ /// Merges the given commit(s) into HEAD, writing the results into the ++ /// working directory. Any changes are staged for commit and any conflicts ++ /// are written to the index. Callers should inspect the repository's index ++ /// after this completes, resolve any conflicts and prepare a commit. ++ /// ++ /// For compatibility with git, the repository is put into a merging state. ++ /// Once the commit is done (or if the uses wishes to abort), you should ++ /// clear this state by calling git_repository_state_cleanup(). ++ pub fn merge(&self, ++ annotated_commits: &[&AnnotatedCommit], ++ merge_opts: Option<&mut MergeOptions>, ++ checkout_opts: Option<&mut CheckoutBuilder>) ++ -> Result<(), Error> ++ { ++ unsafe { ++ let mut raw_checkout_opts = mem::zeroed(); ++ try_call!(raw::git_checkout_init_options(&mut raw_checkout_opts, ++ raw::GIT_CHECKOUT_OPTIONS_VERSION)); ++ if let Some(c) = checkout_opts { ++ c.configure(&mut raw_checkout_opts); ++ } ++ ++ let mut commit_ptrs = annotated_commits.iter().map(|c| { ++ c.raw() as *const raw::git_annotated_commit ++ }).collect::>(); ++ ++ try_call!(raw::git_merge(self.raw, ++ commit_ptrs.as_mut_ptr(), ++ annotated_commits.len() as size_t, ++ merge_opts.map(|o| o.raw()) ++ .unwrap_or(ptr::null()), ++ &raw_checkout_opts)); ++ } ++ Ok(()) ++ } ++ ++ /// Merge two commits, producing an index that reflects the result of ++ /// the merge. The index may be written as-is to the working directory or ++ /// checked out. If the index is to be converted to a tree, the caller ++ /// should resolve any conflicts that arose as part of the merge. ++ pub fn merge_commits(&self, our_commit: &Commit, their_commit: &Commit, ++ opts: Option<&MergeOptions>) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_merge_commits(&mut raw, self.raw, ++ our_commit.raw(), ++ their_commit.raw(), ++ opts.map(|o| o.raw()))); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Remove all the metadata associated with an ongoing command like merge, ++ /// revert, cherry-pick, etc. For example: MERGE_HEAD, MERGE_MSG, etc. ++ pub fn cleanup_state(&self) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_repository_state_cleanup(self.raw)); ++ } ++ Ok(()) ++ } ++ ++ /// Analyzes the given branch(es) and determines the opportunities for ++ /// merging them into the HEAD of the repository. ++ pub fn merge_analysis(&self, ++ their_heads: &[&AnnotatedCommit]) ++ -> Result<(MergeAnalysis, MergePreference), Error> { ++ unsafe { ++ let mut raw_merge_analysis = 0 as raw::git_merge_analysis_t; ++ let mut raw_merge_preference = 0 as raw::git_merge_preference_t; ++ let mut their_heads = their_heads ++ .iter() ++ .map(|v| v.raw() as *const _) ++ .collect::>(); ++ try_call!(raw::git_merge_analysis(&mut raw_merge_analysis, ++ &mut raw_merge_preference, ++ self.raw, ++ their_heads.as_mut_ptr() as *mut _, ++ their_heads.len())); ++ Ok((MergeAnalysis::from_bits_truncate(raw_merge_analysis as u32), MergePreference::from_bits_truncate(raw_merge_preference as u32))) ++ } ++ } ++ ++ /// Add a note for an object ++ /// ++ /// The `notes_ref` argument is the canonical name of the reference to use, ++ /// defaulting to "refs/notes/commits". If `force` is specified then ++ /// previous notes are overwritten. ++ pub fn note(&self, ++ author: &Signature, ++ committer: &Signature, ++ notes_ref: Option<&str>, ++ oid: Oid, ++ note: &str, ++ force: bool) -> Result { ++ let notes_ref = try!(::opt_cstr(notes_ref)); ++ let note = try!(CString::new(note)); ++ let mut ret = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_note_create(&mut ret, ++ self.raw, ++ notes_ref, ++ author.raw(), ++ committer.raw(), ++ oid.raw(), ++ note, ++ force)); ++ Ok(Binding::from_raw(&ret as *const _)) ++ } ++ } ++ ++ /// Get the default notes reference for this repository ++ pub fn note_default_ref(&self) -> Result { ++ let ret = Buf::new(); ++ unsafe { ++ try_call!(raw::git_note_default_ref(ret.raw(), self.raw)); ++ } ++ Ok(str::from_utf8(&ret).unwrap().to_string()) ++ } ++ ++ /// Creates a new iterator for notes in this repository. ++ /// ++ /// The `notes_ref` argument is the canonical name of the reference to use, ++ /// defaulting to "refs/notes/commits". ++ /// ++ /// The iterator returned yields pairs of (Oid, Oid) where the first element ++ /// is the id of the note and the second id is the id the note is ++ /// annotating. ++ pub fn notes(&self, notes_ref: Option<&str>) -> Result { ++ let notes_ref = try!(::opt_cstr(notes_ref)); ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_note_iterator_new(&mut ret, self.raw, notes_ref)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Read the note for an object. ++ /// ++ /// The `notes_ref` argument is the canonical name of the reference to use, ++ /// defaulting to "refs/notes/commits". ++ /// ++ /// The id specified is the Oid of the git object to read the note from. ++ pub fn find_note(&self, notes_ref: Option<&str>, id: Oid) ++ -> Result { ++ let notes_ref = try!(::opt_cstr(notes_ref)); ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_note_read(&mut ret, self.raw, notes_ref, ++ id.raw())); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Remove the note for an object. ++ /// ++ /// The `notes_ref` argument is the canonical name of the reference to use, ++ /// defaulting to "refs/notes/commits". ++ /// ++ /// The id specified is the Oid of the git object to remove the note from. ++ pub fn note_delete(&self, ++ id: Oid, ++ notes_ref: Option<&str>, ++ author: &Signature, ++ committer: &Signature) -> Result<(), Error> { ++ let notes_ref = try!(::opt_cstr(notes_ref)); ++ unsafe { ++ try_call!(raw::git_note_remove(self.raw, notes_ref, author.raw(), ++ committer.raw(), id.raw())); ++ Ok(()) ++ } ++ } ++ ++ /// Create a revwalk that can be used to traverse the commit graph. ++ pub fn revwalk(&self) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_revwalk_new(&mut raw, self.raw())); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Get the blame for a single file. ++ pub fn blame_file(&self, path: &Path, opts: Option<&mut BlameOptions>) ++ -> Result { ++ let path = try!(path.into_c_string()); ++ let mut raw = ptr::null_mut(); ++ ++ unsafe { ++ try_call!(raw::git_blame_file(&mut raw, ++ self.raw(), ++ path, ++ opts.map(|s| s.raw()))); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Find a merge base between two commits ++ pub fn merge_base(&self, one: Oid, two: Oid) -> Result { ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_merge_base(&mut raw, self.raw, ++ one.raw(), two.raw())); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++ ++ /// Find all merge bases between two commits ++ pub fn merge_bases(&self, one: Oid, two: Oid) -> Result { ++ let mut arr = raw::git_oidarray { ++ ids: ptr::null_mut(), ++ count: 0, ++ }; ++ unsafe { ++ try_call!(raw::git_merge_bases(&mut arr, self.raw, ++ one.raw(), two.raw())); ++ Ok(Binding::from_raw(arr)) ++ } ++ } ++ ++ ++ /// Count the number of unique commits between two commit objects ++ /// ++ /// There is no need for branches containing the commits to have any ++ /// upstream relationship, but it helps to think of one as a branch and the ++ /// other as its upstream, the ahead and behind values will be what git ++ /// would report for the branches. ++ pub fn graph_ahead_behind(&self, local: Oid, upstream: Oid) ++ -> Result<(usize, usize), Error> { ++ unsafe { ++ let mut ahead: size_t = 0; ++ let mut behind: size_t = 0; ++ try_call!(raw::git_graph_ahead_behind(&mut ahead, &mut behind, ++ self.raw(), local.raw(), ++ upstream.raw())); ++ Ok((ahead as usize, behind as usize)) ++ } ++ } ++ ++ /// Determine if a commit is the descendant of another commit ++ pub fn graph_descendant_of(&self, commit: Oid, ancestor: Oid) ++ -> Result { ++ unsafe { ++ let rv = try_call!(raw::git_graph_descendant_of(self.raw(), ++ commit.raw(), ++ ancestor.raw())); ++ Ok(rv != 0) ++ } ++ } ++ ++ /// Read the reflog for the given reference ++ /// ++ /// If there is no reflog file for the given reference yet, an empty reflog ++ /// object will be returned. ++ pub fn reflog(&self, name: &str) -> Result { ++ let name = try!(CString::new(name)); ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_reflog_read(&mut ret, self.raw, name)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Delete the reflog for the given reference ++ pub fn reflog_delete(&self, name: &str) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ unsafe { try_call!(raw::git_reflog_delete(self.raw, name)); } ++ Ok(()) ++ } ++ ++ /// Rename a reflog ++ /// ++ /// The reflog to be renamed is expected to already exist. ++ pub fn reflog_rename(&self, old_name: &str, new_name: &str) ++ -> Result<(), Error> { ++ let old_name = try!(CString::new(old_name)); ++ let new_name = try!(CString::new(new_name)); ++ unsafe { ++ try_call!(raw::git_reflog_rename(self.raw, old_name, new_name)); ++ } ++ Ok(()) ++ } ++ ++ /// Check if the given reference has a reflog. ++ pub fn reference_has_log(&self, name: &str) -> Result { ++ let name = try!(CString::new(name)); ++ let ret = unsafe { ++ try_call!(raw::git_reference_has_log(self.raw, name)) ++ }; ++ Ok(ret != 0) ++ } ++ ++ /// Ensure that the given reference has a reflog. ++ pub fn reference_ensure_log(&self, name: &str) -> Result<(), Error> { ++ let name = try!(CString::new(name)); ++ unsafe { ++ try_call!(raw::git_reference_ensure_log(self.raw, name)); ++ } ++ Ok(()) ++ } ++ ++ /// Describes a commit ++ /// ++ /// Performs a describe operation on the current commit and the worktree. ++ /// After performing a describe on HEAD, a status is run and description is ++ /// considered to be dirty if there are. ++ pub fn describe(&self, opts: &DescribeOptions) -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_describe_workdir(&mut ret, self.raw, opts.raw())); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Create a diff with the difference between two tree objects. ++ /// ++ /// This is equivalent to `git diff ` ++ /// ++ /// The first tree will be used for the "old_file" side of the delta and the ++ /// second tree will be used for the "new_file" side of the delta. You can ++ /// pass `None` to indicate an empty tree, although it is an error to pass ++ /// `None` for both the `old_tree` and `new_tree`. ++ pub fn diff_tree_to_tree(&self, ++ old_tree: Option<&Tree>, ++ new_tree: Option<&Tree>, ++ opts: Option<&mut DiffOptions>) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_diff_tree_to_tree(&mut ret, ++ self.raw(), ++ old_tree.map(|s| s.raw()), ++ new_tree.map(|s| s.raw()), ++ opts.map(|s| s.raw()))); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Create a diff between a tree and repository index. ++ /// ++ /// This is equivalent to `git diff --cached ` or if you pass ++ /// the HEAD tree, then like `git diff --cached`. ++ /// ++ /// The tree you pass will be used for the "old_file" side of the delta, and ++ /// the index will be used for the "new_file" side of the delta. ++ /// ++ /// If you pass `None` for the index, then the existing index of the `repo` ++ /// will be used. In this case, the index will be refreshed from disk ++ /// (if it has changed) before the diff is generated. ++ /// ++ /// If the tree is `None`, then it is considered an empty tree. ++ pub fn diff_tree_to_index(&self, ++ old_tree: Option<&Tree>, ++ index: Option<&Index>, ++ opts: Option<&mut DiffOptions>) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_diff_tree_to_index(&mut ret, ++ self.raw(), ++ old_tree.map(|s| s.raw()), ++ index.map(|s| s.raw()), ++ opts.map(|s| s.raw()))); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Create a diff between two index objects. ++ /// ++ /// The first index will be used for the "old_file" side of the delta, and ++ /// the second index will be used for the "new_file" side of the delta. ++ pub fn diff_index_to_index(&self, ++ old_index: &Index, ++ new_index: &Index, ++ opts: Option<&mut DiffOptions>) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_diff_index_to_index(&mut ret, ++ self.raw(), ++ old_index.raw(), ++ new_index.raw(), ++ opts.map(|s| s.raw()))); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Create a diff between the repository index and the workdir directory. ++ /// ++ /// This matches the `git diff` command. See the note below on ++ /// `tree_to_workdir` for a discussion of the difference between ++ /// `git diff` and `git diff HEAD` and how to emulate a `git diff ` ++ /// using libgit2. ++ /// ++ /// The index will be used for the "old_file" side of the delta, and the ++ /// working directory will be used for the "new_file" side of the delta. ++ /// ++ /// If you pass `None` for the index, then the existing index of the `repo` ++ /// will be used. In this case, the index will be refreshed from disk ++ /// (if it has changed) before the diff is generated. ++ pub fn diff_index_to_workdir(&self, ++ index: Option<&Index>, ++ opts: Option<&mut DiffOptions>) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_diff_index_to_workdir(&mut ret, ++ self.raw(), ++ index.map(|s| s.raw()), ++ opts.map(|s| s.raw()))); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Create a diff between a tree and the working directory. ++ /// ++ /// The tree you provide will be used for the "old_file" side of the delta, ++ /// and the working directory will be used for the "new_file" side. ++ /// ++ /// This is not the same as `git diff ` or `git diff-index ++ /// `. Those commands use information from the index, whereas this ++ /// function strictly returns the differences between the tree and the files ++ /// in the working directory, regardless of the state of the index. Use ++ /// `tree_to_workdir_with_index` to emulate those commands. ++ /// ++ /// To see difference between this and `tree_to_workdir_with_index`, ++ /// consider the example of a staged file deletion where the file has then ++ /// been put back into the working dir and further modified. The ++ /// tree-to-workdir diff for that file is 'modified', but `git diff` would ++ /// show status 'deleted' since there is a staged delete. ++ /// ++ /// If `None` is passed for `tree`, then an empty tree is used. ++ pub fn diff_tree_to_workdir(&self, ++ old_tree: Option<&Tree>, ++ opts: Option<&mut DiffOptions>) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_diff_tree_to_workdir(&mut ret, ++ self.raw(), ++ old_tree.map(|s| s.raw()), ++ opts.map(|s| s.raw()))); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Create a diff between a tree and the working directory using index data ++ /// to account for staged deletes, tracked files, etc. ++ /// ++ /// This emulates `git diff ` by diffing the tree to the index and ++ /// the index to the working directory and blending the results into a ++ /// single diff that includes staged deleted, etc. ++ pub fn diff_tree_to_workdir_with_index(&self, ++ old_tree: Option<&Tree>, ++ opts: Option<&mut DiffOptions>) ++ -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_diff_tree_to_workdir_with_index(&mut ret, ++ self.raw(), old_tree.map(|s| s.raw()), opts.map(|s| s.raw()))); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Create a PackBuilder ++ pub fn packbuilder(&self) -> Result { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_packbuilder_new(&mut ret, self.raw())); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Save the local modifications to a new stash. ++ pub fn stash_save(&mut self, ++ stasher: &Signature, ++ message: &str, ++ flags: Option) ++ -> Result { ++ unsafe { ++ let mut raw_oid = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ let message = try!(CString::new(message)); ++ let flags = flags.unwrap_or_else(StashFlags::empty); ++ try_call!(raw::git_stash_save(&mut raw_oid, ++ self.raw(), ++ stasher.raw(), ++ message, ++ flags.bits() as c_uint)); ++ Ok(Binding::from_raw(&raw_oid as *const _)) ++ } ++ } ++ ++ /// Apply a single stashed state from the stash list. ++ pub fn stash_apply(&mut self, ++ index: usize, ++ opts: Option<&mut StashApplyOptions>) ++ -> Result<(), Error> { ++ unsafe { ++ let opts = opts.map(|opts| opts.raw()); ++ try_call!(raw::git_stash_apply(self.raw(), index, opts)); ++ Ok(()) ++ } ++ } ++ ++ /// Loop over all the stashed states and issue a callback for each one. ++ /// ++ /// Return `true` to continue iterating or `false` to stop. ++ pub fn stash_foreach(&mut self, mut callback: C) -> Result<(), Error> ++ where C: FnMut(usize, &str, &Oid) -> bool ++ { ++ unsafe { ++ let mut data = StashCbData { callback: &mut callback }; ++ try_call!(raw::git_stash_foreach(self.raw(), ++ stash_cb, ++ &mut data as *mut _ as *mut _)); ++ Ok(()) ++ } ++ } ++ ++ /// Remove a single stashed state from the stash list. ++ pub fn stash_drop(&mut self, index: usize) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_stash_drop(self.raw(), index)); ++ Ok(()) ++ } ++ } ++ ++ /// Apply a single stashed state from the stash list and remove it from the list if successful. ++ pub fn stash_pop(&mut self, ++ index: usize, ++ opts: Option<&mut StashApplyOptions>) ++ -> Result<(), Error> { ++ unsafe { ++ let opts = opts.map(|opts| opts.raw()); ++ try_call!(raw::git_stash_pop(self.raw(), index, opts)); ++ Ok(()) ++ } ++ } ++} ++ ++impl Binding for Repository { ++ type Raw = *mut raw::git_repository; ++ unsafe fn from_raw(ptr: *mut raw::git_repository) -> Repository { ++ Repository { raw: ptr } ++ } ++ fn raw(&self) -> *mut raw::git_repository { self.raw } ++} ++ ++impl Drop for Repository { ++ fn drop(&mut self) { ++ unsafe { raw::git_repository_free(self.raw) } ++ } ++} ++ ++impl RepositoryInitOptions { ++ /// Creates a default set of initialization options. ++ /// ++ /// By default this will set flags for creating all necessary directories ++ /// and initializing a directory from the user-configured templates path. ++ pub fn new() -> RepositoryInitOptions { ++ RepositoryInitOptions { ++ flags: raw::GIT_REPOSITORY_INIT_MKDIR as u32 | ++ raw::GIT_REPOSITORY_INIT_MKPATH as u32 | ++ raw::GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE as u32, ++ mode: 0, ++ workdir_path: None, ++ description: None, ++ template_path: None, ++ initial_head: None, ++ origin_url: None, ++ } ++ } ++ ++ /// Create a bare repository with no working directory. ++ /// ++ /// Defaults to false. ++ pub fn bare(&mut self, bare: bool) -> &mut RepositoryInitOptions { ++ self.flag(raw::GIT_REPOSITORY_INIT_BARE, bare) ++ } ++ ++ /// Return an error if the repository path appears to already be a git ++ /// repository. ++ /// ++ /// Defaults to false. ++ pub fn no_reinit(&mut self, enabled: bool) -> &mut RepositoryInitOptions { ++ self.flag(raw::GIT_REPOSITORY_INIT_NO_REINIT, enabled) ++ } ++ ++ /// Normally a '/.git/' will be appended to the repo apth for non-bare repos ++ /// (if it is not already there), but passing this flag prevents that ++ /// behavior. ++ /// ++ /// Defaults to false. ++ pub fn no_dotgit_dir(&mut self, enabled: bool) -> &mut RepositoryInitOptions { ++ self.flag(raw::GIT_REPOSITORY_INIT_NO_DOTGIT_DIR, enabled) ++ } ++ ++ /// Make the repo path (and workdir path) as needed. The ".git" directory ++ /// will always be created regardless of this flag. ++ /// ++ /// Defaults to true. ++ pub fn mkdir(&mut self, enabled: bool) -> &mut RepositoryInitOptions { ++ self.flag(raw::GIT_REPOSITORY_INIT_MKDIR, enabled) ++ } ++ ++ /// Recursively make all components of the repo and workdir path sas ++ /// necessary. ++ /// ++ /// Defaults to true. ++ pub fn mkpath(&mut self, enabled: bool) -> &mut RepositoryInitOptions { ++ self.flag(raw::GIT_REPOSITORY_INIT_MKPATH, enabled) ++ } ++ ++ /// Set to one of the `RepositoryInit` constants, or a custom value. ++ pub fn mode(&mut self, mode: RepositoryInitMode) ++ -> &mut RepositoryInitOptions { ++ self.mode = mode.bits(); ++ self ++ } ++ ++ /// Enable or disable using external templates. ++ /// ++ /// If enabled, then the `template_path` option will be queried first, then ++ /// `init.templatedir` from the global config, and finally ++ /// `/usr/share/git-core-templates` will be used (if it exists). ++ /// ++ /// Defaults to true. ++ pub fn external_template(&mut self, enabled: bool) ++ -> &mut RepositoryInitOptions { ++ self.flag(raw::GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE, enabled) ++ } ++ ++ fn flag(&mut self, flag: raw::git_repository_init_flag_t, on: bool) ++ -> &mut RepositoryInitOptions { ++ if on { ++ self.flags |= flag as u32; ++ } else { ++ self.flags &= !(flag as u32); ++ } ++ self ++ } ++ ++ /// The path do the working directory. ++ /// ++ /// If this is a relative path it will be evaulated relative to the repo ++ /// path. If this is not the "natural" working directory, a .git gitlink ++ /// file will be created here linking to the repo path. ++ pub fn workdir_path(&mut self, path: &Path) -> &mut RepositoryInitOptions { ++ self.workdir_path = Some(path.into_c_string().unwrap()); ++ self ++ } ++ ++ /// If set, this will be used to initialize the "description" file in the ++ /// repository instead of using the template content. ++ pub fn description(&mut self, desc: &str) -> &mut RepositoryInitOptions { ++ self.description = Some(CString::new(desc).unwrap()); ++ self ++ } ++ ++ /// When the `external_template` option is set, this is the first location ++ /// to check for the template directory. ++ /// ++ /// If this is not configured, then the default locations will be searched ++ /// instead. ++ pub fn template_path(&mut self, path: &Path) -> &mut RepositoryInitOptions { ++ self.template_path = Some(path.into_c_string().unwrap()); ++ self ++ } ++ ++ /// The name of the head to point HEAD at. ++ /// ++ /// If not configured, this will be treated as `master` and the HEAD ref ++ /// will be set to `refs/heads/master`. If this begins with `refs/` it will ++ /// be used verbatim; otherwise `refs/heads/` will be prefixed ++ pub fn initial_head(&mut self, head: &str) -> &mut RepositoryInitOptions { ++ self.initial_head = Some(CString::new(head).unwrap()); ++ self ++ } ++ ++ /// If set, then after the rest of the repository initialization is ++ /// completed an `origin` remote will be added pointing to this URL. ++ pub fn origin_url(&mut self, url: &str) -> &mut RepositoryInitOptions { ++ self.origin_url = Some(CString::new(url).unwrap()); ++ self ++ } ++ ++ /// Creates a set of raw init options to be used with ++ /// `git_repository_init_ext`. ++ /// ++ /// This method is unsafe as the returned value may have pointers to the ++ /// interior of this structure. ++ pub unsafe fn raw(&self) -> raw::git_repository_init_options { ++ let mut opts = mem::zeroed(); ++ assert_eq!(raw::git_repository_init_init_options(&mut opts, ++ raw::GIT_REPOSITORY_INIT_OPTIONS_VERSION), 0); ++ opts.flags = self.flags; ++ opts.mode = self.mode; ++ opts.workdir_path = ::call::convert(&self.workdir_path); ++ opts.description = ::call::convert(&self.description); ++ opts.template_path = ::call::convert(&self.template_path); ++ opts.initial_head = ::call::convert(&self.initial_head); ++ opts.origin_url = ::call::convert(&self.origin_url); ++ opts ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::ffi::OsStr; ++ use std::fs; ++ use std::path::Path; ++ use tempdir::TempDir; ++ use {Repository, Oid, ObjectType, ResetType}; ++ use build::CheckoutBuilder; ++ ++ #[test] ++ fn smoke_init() { ++ let td = TempDir::new("test").unwrap(); ++ let path = td.path(); ++ ++ let repo = Repository::init(path).unwrap(); ++ assert!(!repo.is_bare()); ++ } ++ ++ #[test] ++ fn smoke_init_bare() { ++ let td = TempDir::new("test").unwrap(); ++ let path = td.path(); ++ ++ let repo = Repository::init_bare(path).unwrap(); ++ assert!(repo.is_bare()); ++ assert!(repo.namespace().is_none()); ++ } ++ ++ #[test] ++ fn smoke_open() { ++ let td = TempDir::new("test").unwrap(); ++ let path = td.path(); ++ Repository::init(td.path()).unwrap(); ++ let repo = Repository::open(path).unwrap(); ++ assert!(!repo.is_bare()); ++ assert!(!repo.is_shallow()); ++ assert!(repo.is_empty().unwrap()); ++ assert_eq!(::test::realpath(&repo.path()).unwrap(), ++ ::test::realpath(&td.path().join(".git/")).unwrap()); ++ assert_eq!(repo.state(), ::RepositoryState::Clean); ++ } ++ ++ #[test] ++ fn smoke_open_bare() { ++ let td = TempDir::new("test").unwrap(); ++ let path = td.path(); ++ Repository::init_bare(td.path()).unwrap(); ++ ++ let repo = Repository::open(path).unwrap(); ++ assert!(repo.is_bare()); ++ assert_eq!(::test::realpath(&repo.path()).unwrap(), ++ ::test::realpath(&td.path().join("")).unwrap()); ++ } ++ ++ #[test] ++ fn smoke_checkout() { ++ let (_td, repo) = ::test::repo_init(); ++ repo.checkout_head(None).unwrap(); ++ } ++ ++ #[test] ++ fn smoke_revparse() { ++ let (_td, repo) = ::test::repo_init(); ++ let rev = repo.revparse("HEAD").unwrap(); ++ assert!(rev.to().is_none()); ++ let from = rev.from().unwrap(); ++ assert!(rev.from().is_some()); ++ ++ assert_eq!(repo.revparse_single("HEAD").unwrap().id(), from.id()); ++ let obj = repo.find_object(from.id(), None).unwrap().clone(); ++ obj.peel(ObjectType::Any).unwrap(); ++ obj.short_id().unwrap(); ++ repo.reset(&obj, ResetType::Hard, None).unwrap(); ++ let mut opts = CheckoutBuilder::new(); ++ t!(repo.reset(&obj, ResetType::Soft, Some(&mut opts))); ++ } ++ ++ #[test] ++ fn makes_dirs() { ++ let td = TempDir::new("foo").unwrap(); ++ Repository::init(&td.path().join("a/b/c/d")).unwrap(); ++ } ++ ++ #[test] ++ fn smoke_discover() { ++ let td = TempDir::new("test").unwrap(); ++ let subdir = td.path().join("subdi"); ++ fs::create_dir(&subdir).unwrap(); ++ Repository::init_bare(td.path()).unwrap(); ++ let repo = Repository::discover(&subdir).unwrap(); ++ assert_eq!(::test::realpath(&repo.path()).unwrap(), ++ ::test::realpath(&td.path().join("")).unwrap()); ++ } ++ ++ #[test] ++ fn smoke_open_ext() { ++ let td = TempDir::new("test").unwrap(); ++ let subdir = td.path().join("subdir"); ++ fs::create_dir(&subdir).unwrap(); ++ Repository::init(td.path()).unwrap(); ++ ++ let repo = Repository::open_ext(&subdir, ::RepositoryOpenFlags::empty(), &[] as &[&OsStr]).unwrap(); ++ assert!(!repo.is_bare()); ++ assert_eq!(::test::realpath(&repo.path()).unwrap(), ++ ::test::realpath(&td.path().join(".git")).unwrap()); ++ ++ let repo = Repository::open_ext(&subdir, ::REPOSITORY_OPEN_BARE, &[] as &[&OsStr]).unwrap(); ++ assert!(repo.is_bare()); ++ assert_eq!(::test::realpath(&repo.path()).unwrap(), ++ ::test::realpath(&td.path().join(".git")).unwrap()); ++ ++ let err = Repository::open_ext(&subdir, ::REPOSITORY_OPEN_NO_SEARCH, &[] as &[&OsStr]).err().unwrap(); ++ assert_eq!(err.code(), ::ErrorCode::NotFound); ++ ++ assert!(Repository::open_ext(&subdir, ++ ::RepositoryOpenFlags::empty(), ++ &[&subdir]).is_ok()); ++ } ++ ++ fn graph_repo_init() -> (TempDir, Repository) { ++ let (_td, repo) = ::test::repo_init(); ++ { ++ let head = repo.head().unwrap().target().unwrap(); ++ let head = repo.find_commit(head).unwrap(); ++ ++ let mut index = repo.index().unwrap(); ++ let id = index.write_tree().unwrap(); ++ ++ let tree = repo.find_tree(id).unwrap(); ++ let sig = repo.signature().unwrap(); ++ repo.commit(Some("HEAD"), &sig, &sig, "second", ++ &tree, &[&head]).unwrap(); ++ } ++ (_td, repo) ++ } ++ ++ #[test] ++ fn smoke_graph_ahead_behind() { ++ let (_td, repo) = graph_repo_init(); ++ let head = repo.head().unwrap().target().unwrap(); ++ let head = repo.find_commit(head).unwrap(); ++ let head_id = head.id(); ++ let head_parent_id = head.parent(0).unwrap().id(); ++ let (ahead, behind) = repo.graph_ahead_behind(head_id, ++ head_parent_id).unwrap(); ++ assert_eq!(ahead, 1); ++ assert_eq!(behind, 0); ++ let (ahead, behind) = repo.graph_ahead_behind(head_parent_id, ++ head_id).unwrap(); ++ assert_eq!(ahead, 0); ++ assert_eq!(behind, 1); ++ } ++ ++ #[test] ++ fn smoke_graph_descendant_of() { ++ let (_td, repo) = graph_repo_init(); ++ let head = repo.head().unwrap().target().unwrap(); ++ let head = repo.find_commit(head).unwrap(); ++ let head_id = head.id(); ++ let head_parent_id = head.parent(0).unwrap().id(); ++ assert!(repo.graph_descendant_of(head_id, head_parent_id).unwrap()); ++ assert!(!repo.graph_descendant_of(head_parent_id, head_id).unwrap()); ++ } ++ ++ #[test] ++ fn smoke_reference_has_log_ensure_log() { ++ let (_td, repo) = ::test::repo_init(); ++ ++ assert_eq!(repo.reference_has_log("HEAD").unwrap(), true); ++ assert_eq!(repo.reference_has_log("refs/heads/master").unwrap(), true); ++ assert_eq!(repo.reference_has_log("NOT_HEAD").unwrap(), false); ++ let master_oid = repo.revparse_single("master").unwrap().id(); ++ assert!(repo.reference("NOT_HEAD", master_oid, false, "creating a new branch").is_ok()); ++ assert_eq!(repo.reference_has_log("NOT_HEAD").unwrap(), false); ++ assert!(repo.reference_ensure_log("NOT_HEAD").is_ok()); ++ assert_eq!(repo.reference_has_log("NOT_HEAD").unwrap(), true); ++ } ++ ++ #[test] ++ fn smoke_set_head() { ++ let (_td, repo) = ::test::repo_init(); ++ ++ assert!(repo.set_head("refs/heads/does-not-exist").is_ok()); ++ assert!(repo.head().is_err()); ++ ++ assert!(repo.set_head("refs/heads/master").is_ok()); ++ assert!(repo.head().is_ok()); ++ ++ assert!(repo.set_head("*").is_err()); ++ } ++ ++ #[test] ++ fn smoke_set_head_detached() { ++ let (_td, repo) = ::test::repo_init(); ++ ++ let void_oid = Oid::from_bytes(b"00000000000000000000").unwrap(); ++ assert!(repo.set_head_detached(void_oid).is_err()); ++ ++ let master_oid = repo.revparse_single("master").unwrap().id(); ++ assert!(repo.set_head_detached(master_oid).is_ok()); ++ assert_eq!(repo.head().unwrap().target().unwrap(), master_oid); ++ } ++ ++ /// create an octopus: ++ /// /---o2-o4 ++ /// o1 X ++ /// \---o3-o5 ++ /// and checks that the merge bases of (o4,o5) are (o2,o3) ++ #[test] ++ fn smoke_merge_bases() { ++ let (_td, repo) = graph_repo_init(); ++ let sig = repo.signature().unwrap(); ++ ++ // let oid1 = head ++ let oid1 = repo.head().unwrap().target().unwrap(); ++ let commit1 = repo.find_commit(oid1).unwrap(); ++ println!("created oid1 {:?}", oid1); ++ ++ repo.branch("branch_a", &commit1, true).unwrap(); ++ repo.branch("branch_b", &commit1, true).unwrap(); ++ ++ // create commit oid2 on branchA ++ let mut index = repo.index().unwrap(); ++ let p = Path::new(repo.workdir().unwrap()).join("file_a"); ++ println!("using path {:?}", p); ++ fs::File::create(&p).unwrap(); ++ index.add_path(Path::new("file_a")).unwrap(); ++ let id_a = index.write_tree().unwrap(); ++ let tree_a = repo.find_tree(id_a).unwrap(); ++ let oid2 = repo.commit(Some("refs/heads/branch_a"), &sig, &sig, ++ "commit 2", &tree_a, &[&commit1]).unwrap(); ++ let commit2 = repo.find_commit(oid2).unwrap(); ++ println!("created oid2 {:?}", oid2); ++ ++ t!(repo.reset(commit1.as_object(), ResetType::Hard, None)); ++ ++ // create commit oid3 on branchB ++ let mut index = repo.index().unwrap(); ++ let p = Path::new(repo.workdir().unwrap()).join("file_b"); ++ fs::File::create(&p).unwrap(); ++ index.add_path(Path::new("file_b")).unwrap(); ++ let id_b = index.write_tree().unwrap(); ++ let tree_b = repo.find_tree(id_b).unwrap(); ++ let oid3 = repo.commit(Some("refs/heads/branch_b"), &sig, &sig, ++ "commit 3", &tree_b, &[&commit1]).unwrap(); ++ let commit3 = repo.find_commit(oid3).unwrap(); ++ println!("created oid3 {:?}", oid3); ++ ++ // create merge commit oid4 on branchA with parents oid2 and oid3 ++ //let mut index4 = repo.merge_commits(&commit2, &commit3, None).unwrap(); ++ repo.set_head("refs/heads/branch_a").unwrap(); ++ repo.checkout_head(None).unwrap(); ++ let oid4 = repo.commit(Some("refs/heads/branch_a"), &sig, &sig, ++ "commit 4", &tree_a, ++ &[&commit2, &commit3]).unwrap(); ++ //index4.write_tree_to(&repo).unwrap(); ++ println!("created oid4 {:?}", oid4); ++ ++ // create merge commit oid5 on branchB with parents oid2 and oid3 ++ //let mut index5 = repo.merge_commits(&commit3, &commit2, None).unwrap(); ++ repo.set_head("refs/heads/branch_b").unwrap(); ++ repo.checkout_head(None).unwrap(); ++ let oid5 = repo.commit(Some("refs/heads/branch_b"), &sig, &sig, ++ "commit 5", &tree_a, ++ &[&commit3, &commit2]).unwrap(); ++ //index5.write_tree_to(&repo).unwrap(); ++ println!("created oid5 {:?}", oid5); ++ ++ // merge bases of (oid4,oid5) should be (oid2,oid3) ++ let merge_bases = repo.merge_bases(oid4, oid5).unwrap(); ++ let mut found_oid2 = false; ++ let mut found_oid3 = false; ++ for mg in merge_bases.iter() { ++ println!("found merge base {:?}", mg); ++ if mg == &oid2 { ++ found_oid2 = true; ++ } else if mg == &oid3 { ++ found_oid3 = true; ++ } else { ++ assert!(false); ++ } ++ } ++ assert!(found_oid2); ++ assert!(found_oid3); ++ assert_eq!(merge_bases.len(), 2); ++ } ++ ++ #[test] ++ fn smoke_revparse_ext() { ++ let (_td, repo) = graph_repo_init(); ++ ++ { ++ let short_refname = "master"; ++ let expected_refname = "refs/heads/master"; ++ let (obj, reference) = repo.revparse_ext(short_refname).unwrap(); ++ let expected_obj = repo.revparse_single(expected_refname).unwrap(); ++ assert_eq!(obj.id(), expected_obj.id()); ++ assert_eq!(reference.unwrap().name().unwrap(), expected_refname); ++ } ++ { ++ let missing_refname = "refs/heads/does-not-exist"; ++ assert!(repo.revparse_ext(missing_refname).is_err()); ++ } ++ { ++ let (_obj, reference) = repo.revparse_ext("HEAD^").unwrap(); ++ assert!(reference.is_none()); ++ } ++ } ++} diff --cc vendor/git2-0.6.8/src/revspec.rs index 000000000,000000000..eb18492ef new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/revspec.rs @@@ -1,0 -1,0 +1,26 @@@ ++use {Object, RevparseMode}; ++ ++/// A revspec represents a range of revisions within a repository. ++pub struct Revspec<'repo> { ++ from: Option>, ++ to: Option>, ++ mode: RevparseMode, ++} ++ ++impl<'repo> Revspec<'repo> { ++ /// Assembles a new revspec from the from/to components. ++ pub fn from_objects(from: Option>, ++ to: Option>, ++ mode: RevparseMode) -> Revspec<'repo> { ++ Revspec { from: from, to: to, mode: mode } ++ } ++ ++ /// Access the `from` range of this revspec. ++ pub fn from(&self) -> Option<&Object<'repo>> { self.from.as_ref() } ++ ++ /// Access the `to` range of this revspec. ++ pub fn to(&self) -> Option<&Object<'repo>> { self.to.as_ref() } ++ ++ /// Returns the intent of the revspec. ++ pub fn mode(&self) -> RevparseMode { self.mode } ++} diff --cc vendor/git2-0.6.8/src/revwalk.rs index 000000000,000000000..1e661db52 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/revwalk.rs @@@ -1,0 -1,0 +1,203 @@@ ++use std::marker; ++use std::ffi::CString; ++use libc::c_uint; ++ ++use {raw, Error, Sort, Oid, Repository}; ++use util::Binding; ++ ++/// A revwalk allows traversal of the commit graph defined by including one or ++/// more leaves and excluding one or more roots. ++pub struct Revwalk<'repo> { ++ raw: *mut raw::git_revwalk, ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++impl<'repo> Revwalk<'repo> { ++ /// Reset a revwalk to allow re-configuring it. ++ /// ++ /// The revwalk is automatically reset when iteration of its commits ++ /// completes. ++ pub fn reset(&mut self) { ++ unsafe { raw::git_revwalk_reset(self.raw()) } ++ } ++ ++ /// Set the order in which commits are visited. ++ pub fn set_sorting(&mut self, sort_mode: Sort) { ++ unsafe { ++ raw::git_revwalk_sorting(self.raw(), sort_mode.bits() as c_uint) ++ } ++ } ++ ++ /// Simplify the history by first-parent ++ /// ++ /// No parents other than the first for each commit will be enqueued. ++ pub fn simplify_first_parent(&mut self) { ++ unsafe { raw::git_revwalk_simplify_first_parent(self.raw) } ++ } ++ ++ /// Mark a commit to start traversal from. ++ /// ++ /// The given OID must belong to a committish on the walked repository. ++ /// ++ /// The given commit will be used as one of the roots when starting the ++ /// revision walk. At least one commit must be pushed onto the walker before ++ /// a walk can be started. ++ pub fn push(&mut self, oid: Oid) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_revwalk_push(self.raw(), oid.raw())); ++ } ++ Ok(()) ++ } ++ ++ /// Push the repository's HEAD ++ /// ++ /// For more information, see `push`. ++ pub fn push_head(&mut self) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_revwalk_push_head(self.raw())); ++ } ++ Ok(()) ++ } ++ ++ /// Push matching references ++ /// ++ /// The OIDs pointed to by the references that match the given glob pattern ++ /// will be pushed to the revision walker. ++ /// ++ /// A leading 'refs/' is implied if not present as well as a trailing `/ \ ++ /// *` if the glob lacks '?', ' \ *' or '['. ++ /// ++ /// Any references matching this glob which do not point to a committish ++ /// will be ignored. ++ pub fn push_glob(&mut self, glob: &str) -> Result<(), Error> { ++ let glob = try!(CString::new(glob)); ++ unsafe { ++ try_call!(raw::git_revwalk_push_glob(self.raw, glob)); ++ } ++ Ok(()) ++ } ++ ++ /// Push and hide the respective endpoints of the given range. ++ /// ++ /// The range should be of the form `..` where each ++ /// `` is in the form accepted by `revparse_single`. The left-hand ++ /// commit will be hidden and the right-hand commit pushed. ++ pub fn push_range(&mut self, range: &str) -> Result<(), Error> { ++ let range = try!(CString::new(range)); ++ unsafe { ++ try_call!(raw::git_revwalk_push_range(self.raw, range)); ++ } ++ Ok(()) ++ } ++ ++ /// Push the OID pointed to by a reference ++ /// ++ /// The reference must point to a committish. ++ pub fn push_ref(&mut self, reference: &str) -> Result<(), Error> { ++ let reference = try!(CString::new(reference)); ++ unsafe { ++ try_call!(raw::git_revwalk_push_ref(self.raw, reference)); ++ } ++ Ok(()) ++ } ++ ++ /// Mark a commit as not of interest to this revwalk. ++ pub fn hide(&mut self, oid: Oid) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_revwalk_hide(self.raw(), oid.raw())); ++ } ++ Ok(()) ++ } ++ ++ /// Hide the repository's HEAD ++ /// ++ /// For more information, see `hide`. ++ pub fn hide_head(&mut self) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_revwalk_hide_head(self.raw())); ++ } ++ Ok(()) ++ } ++ ++ /// Hide matching references. ++ /// ++ /// The OIDs pointed to by the references that match the given glob pattern ++ /// and their ancestors will be hidden from the output on the revision walk. ++ /// ++ /// A leading 'refs/' is implied if not present as well as a trailing `/ \ ++ /// *` if the glob lacks '?', ' \ *' or '['. ++ /// ++ /// Any references matching this glob which do not point to a committish ++ /// will be ignored. ++ pub fn hide_glob(&mut self, glob: &str) -> Result<(), Error> { ++ let glob = try!(CString::new(glob)); ++ unsafe { ++ try_call!(raw::git_revwalk_hide_glob(self.raw, glob)); ++ } ++ Ok(()) ++ } ++ ++ /// Hide the OID pointed to by a reference. ++ /// ++ /// The reference must point to a committish. ++ pub fn hide_ref(&mut self, reference: &str) -> Result<(), Error> { ++ let reference = try!(CString::new(reference)); ++ unsafe { ++ try_call!(raw::git_revwalk_hide_ref(self.raw, reference)); ++ } ++ Ok(()) ++ } ++} ++ ++impl<'repo> Binding for Revwalk<'repo> { ++ type Raw = *mut raw::git_revwalk; ++ unsafe fn from_raw(raw: *mut raw::git_revwalk) -> Revwalk<'repo> { ++ Revwalk { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *mut raw::git_revwalk { self.raw } ++} ++ ++impl<'repo> Drop for Revwalk<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_revwalk_free(self.raw) } ++ } ++} ++ ++impl<'repo> Iterator for Revwalk<'repo> { ++ type Item = Result; ++ fn next(&mut self) -> Option> { ++ let mut out: raw::git_oid = raw::git_oid{ id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call_iter!(raw::git_revwalk_next(&mut out, self.raw())); ++ Some(Ok(Binding::from_raw(&out as *const _))) ++ } ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ let head = repo.head().unwrap(); ++ let target = head.target().unwrap(); ++ ++ let mut walk = repo.revwalk().unwrap(); ++ walk.push(target).unwrap(); ++ ++ let oids: Vec<::Oid> = walk.by_ref().collect::, _>>() ++ .unwrap(); ++ ++ assert_eq!(oids.len(), 1); ++ assert_eq!(oids[0], target); ++ ++ walk.reset(); ++ walk.push_head().unwrap(); ++ assert_eq!(walk.by_ref().count(), 1); ++ ++ walk.reset(); ++ walk.push_head().unwrap(); ++ walk.hide_head().unwrap(); ++ assert_eq!(walk.by_ref().count(), 0); ++ } ++} diff --cc vendor/git2-0.6.8/src/signature.rs index 000000000,000000000..61e7a8948 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/signature.rs @@@ -1,0 -1,0 +1,175 @@@ ++use std::ffi::CString; ++use std::marker; ++use std::mem; ++use std::ptr; ++use std::str; ++use std::fmt; ++use libc; ++ ++use {raw, Error, Time}; ++use util::Binding; ++ ++/// A Signature is used to indicate authorship of various actions throughout the ++/// library. ++/// ++/// Signatures contain a name, email, and timestamp. All fields can be specified ++/// with `new` while the `now` constructor omits the timestamp. The ++/// [`Repository::signature`] method can be used to create a default signature ++/// with name and email values read from the configuration. ++/// ++/// [`Repository::signature`]: struct.Repository.html#method.signature ++pub struct Signature<'a> { ++ raw: *mut raw::git_signature, ++ _marker: marker::PhantomData<&'a str>, ++ owned: bool, ++} ++ ++impl<'a> Signature<'a> { ++ /// Create a new action signature with a timestamp of 'now'. ++ /// ++ /// See `new` for more information ++ pub fn now(name: &str, email: &str) -> Result, Error> { ++ ::init(); ++ let mut ret = ptr::null_mut(); ++ let name = try!(CString::new(name)); ++ let email = try!(CString::new(email)); ++ unsafe { ++ try_call!(raw::git_signature_now(&mut ret, name, email)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Create a new action signature. ++ /// ++ /// The `time` specified is in seconds since the epoch, and the `offset` is ++ /// the time zone offset in minutes. ++ /// ++ /// Returns error if either `name` or `email` contain angle brackets. ++ pub fn new(name: &str, email: &str, time: &Time) ++ -> Result, Error> { ++ ::init(); ++ let mut ret = ptr::null_mut(); ++ let name = try!(CString::new(name)); ++ let email = try!(CString::new(email)); ++ unsafe { ++ try_call!(raw::git_signature_new(&mut ret, name, email, ++ time.seconds() as raw::git_time_t, ++ time.offset_minutes() as libc::c_int)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Gets the name on the signature. ++ /// ++ /// Returns `None` if the name is not valid utf-8 ++ pub fn name(&self) -> Option<&str> { ++ str::from_utf8(self.name_bytes()).ok() ++ } ++ ++ /// Gets the name on the signature as a byte slice. ++ pub fn name_bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, (*self.raw).name).unwrap() } ++ } ++ ++ /// Gets the email on the signature. ++ /// ++ /// Returns `None` if the email is not valid utf-8 ++ pub fn email(&self) -> Option<&str> { ++ str::from_utf8(self.email_bytes()).ok() ++ } ++ ++ /// Gets the email on the signature as a byte slice. ++ pub fn email_bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, (*self.raw).email).unwrap() } ++ } ++ ++ /// Get the `when` of this signature. ++ pub fn when(&self) -> Time { ++ unsafe { Binding::from_raw((*self.raw).when) } ++ } ++ ++ /// Convert a signature of any lifetime into an owned signature with a ++ /// static lifetime. ++ pub fn to_owned(&self) -> Signature<'static> { ++ unsafe { ++ let me = mem::transmute::<&Signature<'a>, &Signature<'static>>(self); ++ me.clone() ++ } ++ } ++} ++ ++impl<'a> Binding for Signature<'a> { ++ type Raw = *mut raw::git_signature; ++ unsafe fn from_raw(raw: *mut raw::git_signature) -> Signature<'a> { ++ Signature { ++ raw: raw, ++ _marker: marker::PhantomData, ++ owned: true, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_signature { self.raw } ++} ++ ++/// Creates a new signature from the give raw pointer, tied to the lifetime ++/// of the given object. ++/// ++/// This function is unsafe as there is no guarantee that `raw` is valid for ++/// `'a` nor if it's a valid pointer. ++pub unsafe fn from_raw_const<'b, T>(_lt: &'b T, ++ raw: *const raw::git_signature) ++ -> Signature<'b> { ++ Signature { ++ raw: raw as *mut raw::git_signature, ++ _marker: marker::PhantomData, ++ owned: false, ++ } ++} ++ ++impl Clone for Signature<'static> { ++ fn clone(&self) -> Signature<'static> { ++ // TODO: can this be defined for 'a and just do a plain old copy if the ++ // lifetime isn't static? ++ let mut raw = ptr::null_mut(); ++ let rc = unsafe { raw::git_signature_dup(&mut raw, &*self.raw) }; ++ assert_eq!(rc, 0); ++ unsafe { Binding::from_raw(raw) } ++ } ++} ++ ++impl<'a> Drop for Signature<'a> { ++ fn drop(&mut self) { ++ if self.owned { ++ unsafe { raw::git_signature_free(self.raw) } ++ } ++ } ++} ++ ++impl<'a> fmt::Display for Signature<'a> { ++ ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "{} <{}>", ++ String::from_utf8_lossy(self.name_bytes()), ++ String::from_utf8_lossy(self.email_bytes())) ++ } ++ ++} ++ ++#[cfg(test)] ++mod tests { ++ use {Signature, Time}; ++ ++ #[test] ++ fn smoke() { ++ Signature::new("foo", "bar", &Time::new(89, 0)).unwrap(); ++ Signature::now("foo", "bar").unwrap(); ++ assert!(Signature::new("", "bar", &Time::new(89, 0)).is_err()); ++ assert!(Signature::now("", "bar").is_err()); ++ ++ let s = Signature::now("foo", "bar").unwrap(); ++ assert_eq!(s.name(), Some("foo")); ++ assert_eq!(s.email(), Some("bar")); ++ ++ drop(s.clone()); ++ drop(s.to_owned()); ++ } ++} diff --cc vendor/git2-0.6.8/src/stash.rs index 000000000,000000000..b1d04f1aa new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/stash.rs @@@ -1,0 -1,0 +1,210 @@@ ++use {raw, panic, Oid, StashApplyProgress}; ++use std::ffi::{CStr}; ++use util::{Binding}; ++use libc::{c_int, c_char, size_t, c_void}; ++use build::{CheckoutBuilder}; ++use std::mem; ++ ++/// Stash application progress notification function. ++/// ++/// Return `true` to continue processing, or `false` to ++/// abort the stash application. ++pub type StashApplyProgressCb<'a> = FnMut(StashApplyProgress) -> bool + 'a; ++ ++/// This is a callback function you can provide to iterate over all the ++/// stashed states that will be invoked per entry. ++pub type StashCb<'a> = FnMut(usize, &str, &Oid) -> bool + 'a; ++ ++#[allow(unused)] ++/// Stash application options structure ++pub struct StashApplyOptions<'cb> { ++ progress: Option>>, ++ checkout_options: Option>, ++ raw_opts: raw::git_stash_apply_options ++} ++ ++impl<'cb> Default for StashApplyOptions<'cb> { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl<'cb> StashApplyOptions<'cb> { ++ /// Creates a default set of merge options. ++ pub fn new() -> StashApplyOptions<'cb> { ++ let mut opts = StashApplyOptions { ++ progress: None, ++ checkout_options: None, ++ raw_opts: unsafe { mem::zeroed() }, ++ }; ++ assert_eq!(unsafe { ++ raw::git_stash_apply_init_options(&mut opts.raw_opts, 1) ++ }, 0); ++ opts ++ } ++ ++ /// Set stash application flag to GIT_STASH_APPLY_REINSTATE_INDEX ++ pub fn reinstantiate_index(&mut self) -> &mut StashApplyOptions<'cb> { ++ self.raw_opts.flags = raw::GIT_STASH_APPLY_REINSTATE_INDEX; ++ self ++ } ++ ++ /// Options to use when writing files to the working directory ++ pub fn checkout_options(&mut self, opts: CheckoutBuilder<'cb>) -> &mut StashApplyOptions<'cb> { ++ self.checkout_options = Some(opts); ++ self ++ } ++ ++ /// Optional callback to notify the consumer of application progress. ++ /// ++ /// Return `true` to continue processing, or `false` to ++ /// abort the stash application. ++ pub fn progress_cb(&mut self, callback: C) -> &mut StashApplyOptions<'cb> ++ where C: FnMut(StashApplyProgress) -> bool + 'cb ++ { ++ self.progress = Some(Box::new(callback) as Box>); ++ self.raw_opts.progress_cb = stash_apply_progress_cb; ++ self.raw_opts.progress_payload = self as *mut _ as *mut _; ++ self ++ } ++ ++ /// Pointer to a raw git_stash_apply_options ++ pub fn raw(&mut self) -> &raw::git_stash_apply_options { ++ unsafe { ++ if let Some(opts) = self.checkout_options.as_mut() { ++ opts.configure(&mut self.raw_opts.checkout_options); ++ } ++ } ++ &self.raw_opts ++ } ++} ++ ++#[allow(unused)] ++pub struct StashCbData<'a> { ++ pub callback: &'a mut StashCb<'a> ++} ++ ++#[allow(unused)] ++pub extern fn stash_cb(index: size_t, ++ message: *const c_char, ++ stash_id: *const raw::git_oid, ++ payload: *mut c_void) ++ -> c_int ++{ ++ panic::wrap(|| unsafe { ++ let mut data = &mut *(payload as *mut StashCbData); ++ let res = { ++ let mut callback = &mut data.callback; ++ callback(index, ++ CStr::from_ptr(message).to_str().unwrap(), ++ &Binding::from_raw(stash_id)) ++ }; ++ ++ if res { 0 } else { 1 } ++ }).unwrap_or(1) ++} ++ ++fn convert_progress(progress: raw::git_stash_apply_progress_t) -> StashApplyProgress { ++ match progress { ++ raw::GIT_STASH_APPLY_PROGRESS_NONE => StashApplyProgress::None, ++ raw::GIT_STASH_APPLY_PROGRESS_LOADING_STASH => StashApplyProgress::LoadingStash, ++ raw::GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX => StashApplyProgress::AnalyzeIndex, ++ raw::GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED => StashApplyProgress::AnalyzeModified, ++ raw::GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED => StashApplyProgress::AnalyzeUntracked, ++ raw::GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED => StashApplyProgress::CheckoutUntracked, ++ raw::GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED => StashApplyProgress::CheckoutModified, ++ raw::GIT_STASH_APPLY_PROGRESS_DONE => StashApplyProgress::Done, ++ ++ _ => StashApplyProgress::None ++ } ++} ++ ++#[allow(unused)] ++extern fn stash_apply_progress_cb(progress: raw::git_stash_apply_progress_t, ++ payload: *mut c_void) ++ -> c_int ++{ ++ panic::wrap(|| unsafe { ++ let mut options = &mut *(payload as *mut StashApplyOptions); ++ let res = { ++ let mut callback = options.progress.as_mut().unwrap(); ++ callback(convert_progress(progress)) ++ }; ++ ++ if res { 0 } else { -1 } ++ }).unwrap_or(-1) ++} ++ ++#[cfg(test)] ++mod tests { ++ use stash::{StashApplyOptions}; ++ use std::io::{Write}; ++ use std::fs; ++ use std::path::Path; ++ use test::{repo_init}; ++ use {Repository, STATUS_WT_NEW, STASH_INCLUDE_UNTRACKED}; ++ ++ fn make_stash(next: C) where C: FnOnce(&mut Repository) { ++ let (_td, mut repo) = repo_init(); ++ let signature = repo.signature().unwrap(); ++ ++ let p = Path::new(repo.workdir().unwrap()).join("file_b.txt"); ++ println!("using path {:?}", p); ++ fs::File::create(&p).unwrap() ++ .write("data".as_bytes()).unwrap(); ++ ++ let rel_p = Path::new("file_b.txt"); ++ assert!(repo.status_file(&rel_p).unwrap() == STATUS_WT_NEW); ++ ++ repo.stash_save(&signature, "msg1", Some(STASH_INCLUDE_UNTRACKED)).unwrap(); ++ ++ assert!(repo.status_file(&rel_p).is_err()); ++ ++ let mut count = 0; ++ repo.stash_foreach(|index, name, _oid| { ++ count += 1; ++ assert!(index == 0); ++ assert!(name == "On master: msg1"); ++ true ++ }).unwrap(); ++ ++ assert!(count == 1); ++ next(&mut repo); ++ } ++ ++ fn count_stash(repo: &mut Repository) -> usize { ++ let mut count = 0; ++ repo.stash_foreach(|_, _, _| { count += 1; true }).unwrap(); ++ count ++ } ++ ++ #[test] ++ fn smoke_stash_save_drop() { ++ make_stash(|repo| { ++ repo.stash_drop(0).unwrap(); ++ assert!(count_stash(repo) == 0) ++ }) ++ } ++ ++ #[test] ++ fn smoke_stash_save_pop() { ++ make_stash(|repo| { ++ repo.stash_pop(0, None).unwrap(); ++ assert!(count_stash(repo) == 0) ++ }) ++ } ++ ++ #[test] ++ fn smoke_stash_save_apply() { ++ make_stash(|repo| { ++ let mut options = StashApplyOptions::new(); ++ options.progress_cb(|progress| { ++ println!("{:?}", progress); ++ true ++ }); ++ ++ repo.stash_apply(0, Some(&mut options)).unwrap(); ++ assert!(count_stash(repo) == 1) ++ }) ++ } ++} diff --cc vendor/git2-0.6.8/src/status.rs index 000000000,000000000..b613c0a97 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/status.rs @@@ -1,0 -1,0 +1,407 @@@ ++use std::ffi::CString; ++use std::ops::Range; ++use std::marker; ++use std::mem; ++use std::str; ++use libc::{c_char, size_t, c_uint}; ++ ++use {raw, Status, DiffDelta, IntoCString, Repository}; ++use util::Binding; ++ ++/// Options that can be provided to `repo.statuses()` to control how the status ++/// information is gathered. ++pub struct StatusOptions { ++ raw: raw::git_status_options, ++ pathspec: Vec, ++ ptrs: Vec<*const c_char>, ++} ++ ++/// Enumeration of possible methods of what can be shown through a status ++/// operation. ++#[derive(Copy, Clone)] ++pub enum StatusShow { ++ /// Only gives status based on HEAD to index comparison, not looking at ++ /// working directory changes. ++ Index, ++ ++ /// Only gives status based on index to working directory comparison, not ++ /// comparing the index to the HEAD. ++ Workdir, ++ ++ /// The default, this roughly matches `git status --porcelain` regarding ++ /// which files are included and in what order. ++ IndexAndWorkdir, ++} ++ ++/// A container for a list of status information about a repository. ++/// ++/// Each instance appears as if it were a collection, having a length and ++/// allowing indexing, as well as providing an iterator. ++pub struct Statuses<'repo> { ++ raw: *mut raw::git_status_list, ++ ++ // Hm, not currently present, but can't hurt? ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++/// An iterator over the statuses in a `Statuses` instance. ++pub struct StatusIter<'statuses> { ++ statuses: &'statuses Statuses<'statuses>, ++ range: Range, ++} ++ ++/// A structure representing an entry in the `Statuses` structure. ++/// ++/// Instances are created through the `.iter()` method or the `.get()` method. ++pub struct StatusEntry<'statuses> { ++ raw: *const raw::git_status_entry, ++ _marker: marker::PhantomData<&'statuses DiffDelta<'statuses>>, ++} ++ ++impl Default for StatusOptions { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++impl StatusOptions { ++ /// Creates a new blank set of status options. ++ pub fn new() -> StatusOptions { ++ unsafe { ++ let mut raw = mem::zeroed(); ++ let r = raw::git_status_init_options(&mut raw, ++ raw::GIT_STATUS_OPTIONS_VERSION); ++ assert_eq!(r, 0); ++ StatusOptions { ++ raw: raw, ++ pathspec: Vec::new(), ++ ptrs: Vec::new(), ++ } ++ } ++ } ++ ++ /// Select the files on which to report status. ++ /// ++ /// The default, if unspecified, is to show the index and the working ++ /// directory. ++ pub fn show(&mut self, show: StatusShow) -> &mut StatusOptions { ++ self.raw.show = match show { ++ StatusShow::Index => raw::GIT_STATUS_SHOW_INDEX_ONLY, ++ StatusShow::Workdir => raw::GIT_STATUS_SHOW_WORKDIR_ONLY, ++ StatusShow::IndexAndWorkdir => raw::GIT_STATUS_SHOW_INDEX_AND_WORKDIR, ++ }; ++ self ++ } ++ ++ /// Add a path pattern to match (using fnmatch-style matching). ++ /// ++ /// If the `disable_pathspec_match` option is given, then this is a literal ++ /// path to match. If this is not called, then there will be no patterns to ++ /// match and the entire directory will be used. ++ pub fn pathspec(&mut self, pathspec: T) ++ -> &mut StatusOptions { ++ let s = pathspec.into_c_string().unwrap(); ++ self.ptrs.push(s.as_ptr()); ++ self.pathspec.push(s); ++ self ++ } ++ ++ fn flag(&mut self, flag: raw::git_status_opt_t, val: bool) ++ -> &mut StatusOptions { ++ if val { ++ self.raw.flags |= flag as c_uint; ++ } else { ++ self.raw.flags &= !(flag as c_uint); ++ } ++ self ++ } ++ ++ /// Flag whether untracked files will be included. ++ /// ++ /// Untracked files will only be included if the workdir files are included ++ /// in the status "show" option. ++ pub fn include_untracked(&mut self, include: bool) -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNTRACKED, include) ++ } ++ ++ /// Flag whether ignored files will be included. ++ /// ++ /// The files will only be included if the workdir files are included ++ /// in the status "show" option. ++ pub fn include_ignored(&mut self, include: bool) -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_INCLUDE_IGNORED, include) ++ } ++ ++ /// Flag to include unmodified files. ++ pub fn include_unmodified(&mut self, include: bool) -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNMODIFIED, include) ++ } ++ ++ /// Flag that submodules should be skipped. ++ /// ++ /// This only applies if there are no pending typechanges to the submodule ++ /// (either from or to another type). ++ pub fn exclude_submodules(&mut self, exclude: bool) -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_EXCLUDE_SUBMODULES, exclude) ++ } ++ ++ /// Flag that all files in untracked directories should be included. ++ /// ++ /// Normally if an entire directory is new then just the top-level directory ++ /// is included (with a trailing slash on the entry name). ++ pub fn recurse_untracked_dirs(&mut self, include: bool) ++ -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS, include) ++ } ++ ++ /// Indicates that the given paths should be treated as literals paths, note ++ /// patterns. ++ pub fn disable_pathspec_match(&mut self, include: bool) ++ -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH, include) ++ } ++ ++ /// Indicates that the contents of ignored directories should be included in ++ /// the status. ++ pub fn recurse_ignored_dirs(&mut self, include: bool) ++ -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_RECURSE_IGNORED_DIRS, include) ++ } ++ ++ /// Indicates that rename detection should be processed between the head. ++ pub fn renames_head_to_index(&mut self, include: bool) ++ -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX, include) ++ } ++ ++ /// Indicates that rename detection should be run between the index and the ++ /// working directory. ++ pub fn renames_index_to_workdir(&mut self, include: bool) ++ -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR, include) ++ } ++ ++ /// Override the native case sensitivity for the file system and force the ++ /// output to be in case sensitive order. ++ pub fn sort_case_sensitively(&mut self, include: bool) ++ -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_SORT_CASE_SENSITIVELY, include) ++ } ++ ++ /// Override the native case sensitivity for the file system and force the ++ /// output to be in case-insensitive order. ++ pub fn sort_case_insensitively(&mut self, include: bool) ++ -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY, include) ++ } ++ ++ /// Indicates that rename detection should include rewritten files. ++ pub fn renames_from_rewrites(&mut self, include: bool) ++ -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_RENAMES_FROM_REWRITES, include) ++ } ++ ++ /// Bypasses the default status behavior of doing a "soft" index reload. ++ pub fn no_refresh(&mut self, include: bool) -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_NO_REFRESH, include) ++ } ++ ++ /// Refresh the stat cache in the index for files are unchanged but have ++ /// out of date stat information in the index. ++ /// ++ /// This will result in less work being done on subsequent calls to fetching ++ /// the status. ++ pub fn update_index(&mut self, include: bool) -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_UPDATE_INDEX, include) ++ } ++ ++ // erm... ++ #[allow(missing_docs)] ++ pub fn include_unreadable(&mut self, include: bool) -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNREADABLE, include) ++ } ++ ++ // erm... ++ #[allow(missing_docs)] ++ pub fn include_unreadable_as_untracked(&mut self, include: bool) ++ -> &mut StatusOptions { ++ self.flag(raw::GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED, include) ++ } ++ ++ /// Get a pointer to the inner list of status options. ++ /// ++ /// This function is unsafe as the returned structure has interior pointers ++ /// and may no longer be valid if these options continue to be mutated. ++ pub unsafe fn raw(&mut self) -> *const raw::git_status_options { ++ self.raw.pathspec.strings = self.ptrs.as_ptr() as *mut _; ++ self.raw.pathspec.count = self.ptrs.len() as size_t; ++ &self.raw ++ } ++} ++ ++impl<'repo> Statuses<'repo> { ++ /// Gets a status entry from this list at the specified index. ++ /// ++ /// Returns `None` if the index is out of bounds. ++ pub fn get(&self, index: usize) -> Option { ++ unsafe { ++ let p = raw::git_status_byindex(self.raw, index as size_t); ++ Binding::from_raw_opt(p) ++ } ++ } ++ ++ /// Gets the count of status entries in this list. ++ /// ++ /// If there are no changes in status (according to the options given ++ /// when the status list was created), this should return 0. ++ pub fn len(&self) -> usize { ++ unsafe { raw::git_status_list_entrycount(self.raw) as usize } ++ } ++ ++ /// Return `true` if there is no status entry in this list. ++ pub fn is_empty(&self) -> bool { ++ self.len() == 0 ++ } ++ ++ /// Returns an iterator over the statuses in this list. ++ pub fn iter(&self) -> StatusIter { ++ StatusIter { ++ statuses: self, ++ range: 0..self.len(), ++ } ++ } ++} ++ ++impl<'repo> Binding for Statuses<'repo> { ++ type Raw = *mut raw::git_status_list; ++ unsafe fn from_raw(raw: *mut raw::git_status_list) -> Statuses<'repo> { ++ Statuses { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *mut raw::git_status_list { self.raw } ++} ++ ++impl<'repo> Drop for Statuses<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_status_list_free(self.raw); } ++ } ++} ++ ++impl<'a> Iterator for StatusIter<'a> { ++ type Item = StatusEntry<'a>; ++ fn next(&mut self) -> Option> { ++ self.range.next().and_then(|i| self.statuses.get(i)) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++impl<'a> DoubleEndedIterator for StatusIter<'a> { ++ fn next_back(&mut self) -> Option> { ++ self.range.next_back().and_then(|i| self.statuses.get(i)) ++ } ++} ++impl<'a> ExactSizeIterator for StatusIter<'a> {} ++ ++impl<'statuses> StatusEntry<'statuses> { ++ /// Access the bytes for this entry's corresponding pathname ++ pub fn path_bytes(&self) -> &[u8] { ++ unsafe { ++ if (*self.raw).head_to_index.is_null() { ++ ::opt_bytes(self, (*(*self.raw).index_to_workdir).old_file.path) ++ } else { ++ ::opt_bytes(self, (*(*self.raw).head_to_index).old_file.path) ++ }.unwrap() ++ } ++ } ++ ++ /// Access this entry's path name as a string. ++ /// ++ /// Returns `None` if the path is not valid utf-8. ++ pub fn path(&self) -> Option<&str> { str::from_utf8(self.path_bytes()).ok() } ++ ++ /// Access the status flags for this file ++ pub fn status(&self) -> Status { ++ Status::from_bits_truncate(unsafe { (*self.raw).status as u32 }) ++ } ++ ++ /// Access detailed information about the differences between the file in ++ /// HEAD and the file in the index. ++ pub fn head_to_index(&self) -> Option> { ++ unsafe { ++ Binding::from_raw_opt((*self.raw).head_to_index) ++ } ++ } ++ ++ /// Access detailed information about the differences between the file in ++ /// the index and the file in the working directory. ++ pub fn index_to_workdir(&self) -> Option> { ++ unsafe { ++ Binding::from_raw_opt((*self.raw).index_to_workdir) ++ } ++ } ++} ++ ++impl<'statuses> Binding for StatusEntry<'statuses> { ++ type Raw = *const raw::git_status_entry; ++ ++ unsafe fn from_raw(raw: *const raw::git_status_entry) ++ -> StatusEntry<'statuses> { ++ StatusEntry { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *const raw::git_status_entry { self.raw } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::fs::File; ++ use std::path::Path; ++ use std::io::prelude::*; ++ use super::StatusOptions; ++ ++ #[test] ++ fn smoke() { ++ let (td, repo) = ::test::repo_init(); ++ assert_eq!(repo.statuses(None).unwrap().len(), 0); ++ File::create(&td.path().join("foo")).unwrap(); ++ let statuses = repo.statuses(None).unwrap(); ++ assert_eq!(statuses.iter().count(), 1); ++ let status = statuses.iter().next().unwrap(); ++ assert_eq!(status.path(), Some("foo")); ++ assert!(status.status().contains(::STATUS_WT_NEW)); ++ assert!(!status.status().contains(::STATUS_INDEX_NEW)); ++ assert!(status.head_to_index().is_none()); ++ let diff = status.index_to_workdir().unwrap(); ++ assert_eq!(diff.old_file().path_bytes().unwrap(), b"foo"); ++ assert_eq!(diff.new_file().path_bytes().unwrap(), b"foo"); ++ } ++ ++ #[test] ++ fn filter() { ++ let (td, repo) = ::test::repo_init(); ++ t!(File::create(&td.path().join("foo"))); ++ t!(File::create(&td.path().join("bar"))); ++ let mut opts = StatusOptions::new(); ++ opts.include_untracked(true) ++ .pathspec("foo"); ++ ++ let statuses = t!(repo.statuses(Some(&mut opts))); ++ assert_eq!(statuses.iter().count(), 1); ++ let status = statuses.iter().next().unwrap(); ++ assert_eq!(status.path(), Some("foo")); ++ } ++ ++ #[test] ++ fn gitignore() { ++ let (td, repo) = ::test::repo_init(); ++ t!(t!(File::create(td.path().join(".gitignore"))).write_all(b"foo\n")); ++ assert!(!t!(repo.status_should_ignore(Path::new("bar")))); ++ assert!(t!(repo.status_should_ignore(Path::new("foo")))); ++ } ++ ++ #[test] ++ fn status_file() { ++ let (td, repo) = ::test::repo_init(); ++ assert!(repo.status_file(Path::new("foo")).is_err()); ++ t!(File::create(td.path().join("foo"))); ++ let status = t!(repo.status_file(Path::new("foo"))); ++ assert!(status.contains(::STATUS_WT_NEW)); ++ } ++} diff --cc vendor/git2-0.6.8/src/string_array.rs index 000000000,000000000..a77269338 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/string_array.rs @@@ -1,0 -1,0 +1,109 @@@ ++//! Bindings to libgit2's raw `git_strarray` type ++ ++use std::str; ++use std::ops::Range; ++ ++use raw; ++use util::Binding; ++ ++/// A string array structure used by libgit2 ++/// ++/// Some apis return arrays of strings which originate from libgit2. This ++/// wrapper type behaves a little like `Vec<&str>` but does so without copying ++/// the underlying strings until necessary. ++pub struct StringArray { ++ raw: raw::git_strarray, ++} ++ ++/// A forward iterator over the strings of an array, casted to `&str`. ++pub struct Iter<'a> { ++ range: Range, ++ arr: &'a StringArray, ++} ++ ++/// A forward iterator over the strings of an array, casted to `&[u8]`. ++pub struct IterBytes<'a> { ++ range: Range, ++ arr: &'a StringArray, ++} ++ ++impl StringArray { ++ /// Returns None if the i'th string is not utf8 or if i is out of bounds. ++ pub fn get(&self, i: usize) -> Option<&str> { ++ self.get_bytes(i).and_then(|s| str::from_utf8(s).ok()) ++ } ++ ++ /// Returns None if `i` is out of bounds. ++ pub fn get_bytes(&self, i: usize) -> Option<&[u8]> { ++ if i < self.raw.count as usize { ++ unsafe { ++ let ptr = *self.raw.strings.offset(i as isize) as *const _; ++ Some(::opt_bytes(self, ptr).unwrap()) ++ } ++ } else { ++ None ++ } ++ } ++ ++ /// Returns an iterator over the strings contained within this array. ++ /// ++ /// The iterator yields `Option<&str>` as it is unknown whether the contents ++ /// are utf-8 or not. ++ pub fn iter(&self) -> Iter { ++ Iter { range: 0..self.len(), arr: self } ++ } ++ ++ /// Returns an iterator over the strings contained within this array, ++ /// yielding byte slices. ++ pub fn iter_bytes(&self) -> IterBytes { ++ IterBytes { range: 0..self.len(), arr: self } ++ } ++ ++ /// Returns the number of strings in this array. ++ pub fn len(&self) -> usize { self.raw.count as usize } ++ ++ /// Return `true` if this array is empty. ++ pub fn is_empty(&self) -> bool { self.len() == 0 } ++} ++ ++impl Binding for StringArray { ++ type Raw = raw::git_strarray; ++ unsafe fn from_raw(raw: raw::git_strarray) -> StringArray { ++ StringArray { raw: raw } ++ } ++ fn raw(&self) -> raw::git_strarray { self.raw } ++} ++ ++impl<'a> Iterator for Iter<'a> { ++ type Item = Option<&'a str>; ++ fn next(&mut self) -> Option> { ++ self.range.next().map(|i| self.arr.get(i)) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++impl<'a> DoubleEndedIterator for Iter<'a> { ++ fn next_back(&mut self) -> Option> { ++ self.range.next_back().map(|i| self.arr.get(i)) ++ } ++} ++impl<'a> ExactSizeIterator for Iter<'a> {} ++ ++impl<'a> Iterator for IterBytes<'a> { ++ type Item = &'a [u8]; ++ fn next(&mut self) -> Option<&'a [u8]> { ++ self.range.next().and_then(|i| self.arr.get_bytes(i)) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++impl<'a> DoubleEndedIterator for IterBytes<'a> { ++ fn next_back(&mut self) -> Option<&'a [u8]> { ++ self.range.next_back().and_then(|i| self.arr.get_bytes(i)) ++ } ++} ++impl<'a> ExactSizeIterator for IterBytes<'a> {} ++ ++impl Drop for StringArray { ++ fn drop(&mut self) { ++ unsafe { raw::git_strarray_free(&mut self.raw) } ++ } ++} diff --cc vendor/git2-0.6.8/src/submodule.rs index 000000000,000000000..dfe272a6b new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/submodule.rs @@@ -1,0 -1,0 +1,315 @@@ ++use std::marker; ++use std::mem; ++use std::ptr; ++use std::str; ++use std::os::raw::c_int; ++use std::path::Path; ++ ++use {raw, Oid, Repository, Error, FetchOptions}; ++use build::CheckoutBuilder; ++use util::{self, Binding}; ++ ++/// A structure to represent a git [submodule][1] ++/// ++/// [1]: http://git-scm.com/book/en/Git-Tools-Submodules ++pub struct Submodule<'repo> { ++ raw: *mut raw::git_submodule, ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++impl<'repo> Submodule<'repo> { ++ /// Get the submodule's branch. ++ /// ++ /// Returns `None` if the branch is not valid utf-8 or if the branch is not ++ /// yet available. ++ pub fn branch(&self) -> Option<&str> { ++ self.branch_bytes().and_then(|s| str::from_utf8(s).ok()) ++ } ++ ++ /// Get the branch for the submodule. ++ /// ++ /// Returns `None` if the branch is not yet available. ++ pub fn branch_bytes(&self) -> Option<&[u8]> { ++ unsafe { ++ ::opt_bytes(self, raw::git_submodule_branch(self.raw)) ++ } ++ } ++ ++ /// Get the submodule's url. ++ /// ++ /// Returns `None` if the url is not valid utf-8 ++ pub fn url(&self) -> Option<&str> { str::from_utf8(self.url_bytes()).ok() } ++ ++ /// Get the url for the submodule. ++ pub fn url_bytes(&self) -> &[u8] { ++ unsafe { ++ ::opt_bytes(self, raw::git_submodule_url(self.raw)).unwrap() ++ } ++ } ++ ++ /// Get the submodule's name. ++ /// ++ /// Returns `None` if the name is not valid utf-8 ++ pub fn name(&self) -> Option<&str> { str::from_utf8(self.name_bytes()).ok() } ++ ++ /// Get the name for the submodule. ++ pub fn name_bytes(&self) -> &[u8] { ++ unsafe { ++ ::opt_bytes(self, raw::git_submodule_name(self.raw)).unwrap() ++ } ++ } ++ ++ /// Get the path for the submodule. ++ pub fn path(&self) -> &Path { ++ util::bytes2path(unsafe { ++ ::opt_bytes(self, raw::git_submodule_path(self.raw)).unwrap() ++ }) ++ } ++ ++ /// Get the OID for the submodule in the current HEAD tree. ++ pub fn head_id(&self) -> Option { ++ unsafe { ++ Binding::from_raw_opt(raw::git_submodule_head_id(self.raw)) ++ } ++ } ++ ++ /// Get the OID for the submodule in the index. ++ pub fn index_id(&self) -> Option { ++ unsafe { ++ Binding::from_raw_opt(raw::git_submodule_index_id(self.raw)) ++ } ++ } ++ ++ /// Get the OID for the submodule in the current working directory. ++ /// ++ /// This returns the OID that corresponds to looking up 'HEAD' in the ++ /// checked out submodule. If there are pending changes in the index or ++ /// anything else, this won't notice that. ++ pub fn workdir_id(&self) -> Option { ++ unsafe { ++ Binding::from_raw_opt(raw::git_submodule_wd_id(self.raw)) ++ } ++ } ++ ++ /// Copy submodule info into ".git/config" file. ++ /// ++ /// Just like "git submodule init", this copies information about the ++ /// submodule into ".git/config". You can use the accessor functions above ++ /// to alter the in-memory git_submodule object and control what is written ++ /// to the config, overriding what is in .gitmodules. ++ /// ++ /// By default, existing entries will not be overwritten, but passing `true` ++ /// for `overwrite` forces them to be updated. ++ pub fn init(&mut self, overwrite: bool) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_submodule_init(self.raw, overwrite)); ++ } ++ Ok(()) ++ } ++ ++ /// Open the repository for a submodule. ++ /// ++ /// This will only work if the submodule is checked out into the working ++ /// directory. ++ pub fn open(&self) -> Result { ++ let mut raw = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_submodule_open(&mut raw, self.raw)); ++ Ok(Binding::from_raw(raw)) ++ } ++ } ++ ++ /// Reread submodule info from config, index, and HEAD. ++ /// ++ /// Call this to reread cached submodule information for this submodule if ++ /// you have reason to believe that it has changed. ++ /// ++ /// If `force` is `true`, then data will be reloaded even if it doesn't seem ++ /// out of date ++ pub fn reload(&mut self, force: bool) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_submodule_reload(self.raw, force)); ++ } ++ Ok(()) ++ } ++ ++ /// Copy submodule remote info into submodule repo. ++ /// ++ /// This copies the information about the submodules URL into the checked ++ /// out submodule config, acting like "git submodule sync". This is useful ++ /// if you have altered the URL for the submodule (or it has been altered ++ /// by a fetch of upstream changes) and you need to update your local repo. ++ pub fn sync(&mut self) -> Result<(), Error> { ++ unsafe { try_call!(raw::git_submodule_sync(self.raw)); } ++ Ok(()) ++ } ++ ++ /// Add current submodule HEAD commit to index of superproject. ++ /// ++ /// If `write_index` is true, then the index file will be immediately ++ /// written. Otherwise you must explicitly call `write()` on an `Index` ++ /// later on. ++ pub fn add_to_index(&mut self, write_index: bool) -> Result<(), Error> { ++ unsafe { ++ try_call!(raw::git_submodule_add_to_index(self.raw, write_index)); ++ } ++ Ok(()) ++ } ++ ++ /// Resolve the setup of a new git submodule. ++ /// ++ /// This should be called on a submodule once you have called add setup and ++ /// done the clone of the submodule. This adds the .gitmodules file and the ++ /// newly cloned submodule to the index to be ready to be committed (but ++ /// doesn't actually do the commit). ++ pub fn add_finalize(&mut self) -> Result<(), Error> { ++ unsafe { try_call!(raw::git_submodule_add_finalize(self.raw)); } ++ Ok(()) ++ } ++ ++ /// Update submodule. ++ /// ++ /// This will clone a missing submodule and check out the subrepository to ++ /// the commit specified in the index of the containing repository. If ++ /// the submodule repository doesn't contain the target commit, then the ++ /// submodule is fetched using the fetch options supplied in `opts`. ++ /// ++ /// `init` indicates if the submodule should be initialized first if it has ++ /// not been initialized yet. ++ pub fn update(&mut self, init: bool, ++ opts: Option<&mut SubmoduleUpdateOptions>) ++ -> Result<(), Error> { ++ unsafe { ++ let mut raw_opts = opts.map(|o| o.raw()); ++ try_call!(raw::git_submodule_update(self.raw, init as c_int, ++ raw_opts.as_mut().map_or(ptr::null_mut(), |o| o))); ++ } ++ Ok(()) ++ } ++} ++ ++impl<'repo> Binding for Submodule<'repo> { ++ type Raw = *mut raw::git_submodule; ++ unsafe fn from_raw(raw: *mut raw::git_submodule) -> Submodule<'repo> { ++ Submodule { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *mut raw::git_submodule { self.raw } ++} ++ ++impl<'repo> Drop for Submodule<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_submodule_free(self.raw) } ++ } ++} ++ ++/// Options to update a submodule. ++pub struct SubmoduleUpdateOptions<'cb> { ++ checkout_builder: CheckoutBuilder<'cb>, ++ fetch_opts: FetchOptions<'cb>, ++ allow_fetch: bool, ++} ++ ++impl<'cb> SubmoduleUpdateOptions<'cb> { ++ /// Return default options. ++ pub fn new() -> Self { ++ SubmoduleUpdateOptions { ++ checkout_builder: CheckoutBuilder::new(), ++ fetch_opts: FetchOptions::new(), ++ allow_fetch: true, ++ } ++ } ++ ++ unsafe fn raw(&mut self) -> raw::git_submodule_update_options { ++ let mut checkout_opts: raw::git_checkout_options = mem::zeroed(); ++ let init_res = raw::git_checkout_init_options(&mut checkout_opts, ++ raw::GIT_CHECKOUT_OPTIONS_VERSION); ++ assert_eq!(0, init_res); ++ self.checkout_builder.configure(&mut checkout_opts); ++ let opts = raw::git_submodule_update_options { ++ version: raw::GIT_SUBMODULE_UPDATE_OPTIONS_VERSION, ++ checkout_opts, ++ fetch_opts: self.fetch_opts.raw(), ++ allow_fetch: self.allow_fetch as c_int, ++ }; ++ opts ++ } ++ ++ /// Set checkout options. ++ pub fn checkout(&mut self, opts: CheckoutBuilder<'cb>) -> &mut Self { ++ self.checkout_builder = opts; ++ self ++ } ++ ++ /// Set fetch options and allow fetching. ++ pub fn fetch(&mut self, opts: FetchOptions<'cb>) -> &mut Self { ++ self.fetch_opts = opts; ++ self.allow_fetch = true; ++ self ++ } ++ ++ /// Allow or disallow fetching. ++ pub fn allow_fetch(&mut self, b: bool) -> &mut Self { ++ self.allow_fetch = b; ++ self ++ } ++} ++ ++impl<'cb> Default for SubmoduleUpdateOptions<'cb> { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::path::Path; ++ use std::fs; ++ use tempdir::TempDir; ++ use url::Url; ++ ++ use Repository; ++ ++ #[test] ++ fn smoke() { ++ let td = TempDir::new("test").unwrap(); ++ let repo = Repository::init(td.path()).unwrap(); ++ let mut s1 = repo.submodule("/path/to/nowhere", ++ Path::new("foo"), true).unwrap(); ++ s1.init(false).unwrap(); ++ s1.sync().unwrap(); ++ ++ let s2 = repo.submodule("/path/to/nowhere", ++ Path::new("bar"), true).unwrap(); ++ drop((s1, s2)); ++ ++ let mut submodules = repo.submodules().unwrap(); ++ assert_eq!(submodules.len(), 2); ++ let mut s = submodules.remove(0); ++ assert_eq!(s.name(), Some("bar")); ++ assert_eq!(s.url(), Some("/path/to/nowhere")); ++ assert_eq!(s.branch(), None); ++ assert!(s.head_id().is_none()); ++ assert!(s.index_id().is_none()); ++ assert!(s.workdir_id().is_none()); ++ ++ repo.find_submodule("bar").unwrap(); ++ s.open().unwrap(); ++ assert!(s.path() == Path::new("bar")); ++ s.reload(true).unwrap(); ++ } ++ ++ #[test] ++ fn add_a_submodule() { ++ let (_td, repo1) = ::test::repo_init(); ++ let (td, repo2) = ::test::repo_init(); ++ ++ let url = Url::from_file_path(&repo1.workdir().unwrap()).unwrap(); ++ let mut s = repo2.submodule(&url.to_string(), Path::new("bar"), ++ true).unwrap(); ++ t!(fs::remove_dir_all(td.path().join("bar"))); ++ t!(Repository::clone(&url.to_string(), ++ td.path().join("bar"))); ++ t!(s.add_to_index(false)); ++ t!(s.add_finalize()); ++ } ++} diff --cc vendor/git2-0.6.8/src/tag.rs index 000000000,000000000..2b2716de9 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/tag.rs @@@ -1,0 -1,0 +1,174 @@@ ++use std::marker; ++use std::mem; ++use std::ptr; ++use std::str; ++ ++use {raw, signature, Error, Oid, Object, Signature, ObjectType}; ++use util::Binding; ++ ++/// A structure to represent a git [tag][1] ++/// ++/// [1]: http://git-scm.com/book/en/Git-Basics-Tagging ++pub struct Tag<'repo> { ++ raw: *mut raw::git_tag, ++ _marker: marker::PhantomData>, ++} ++ ++impl<'repo> Tag<'repo> { ++ /// Get the id (SHA1) of a repository tag ++ pub fn id(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_tag_id(&*self.raw)) } ++ } ++ ++ /// Get the message of a tag ++ /// ++ /// Returns None if there is no message or if it is not valid utf8 ++ pub fn message(&self) -> Option<&str> { ++ self.message_bytes().and_then(|s| str::from_utf8(s).ok()) ++ } ++ ++ /// Get the message of a tag ++ /// ++ /// Returns None if there is no message ++ pub fn message_bytes(&self) -> Option<&[u8]> { ++ unsafe { ::opt_bytes(self, raw::git_tag_message(&*self.raw)) } ++ } ++ ++ /// Get the name of a tag ++ /// ++ /// Returns None if it is not valid utf8 ++ pub fn name(&self) -> Option<&str> { ++ str::from_utf8(self.name_bytes()).ok() ++ } ++ ++ /// Get the name of a tag ++ pub fn name_bytes(&self) -> &[u8] { ++ unsafe { ::opt_bytes(self, raw::git_tag_name(&*self.raw)).unwrap() } ++ } ++ ++ /// Recursively peel a tag until a non tag git_object is found ++ pub fn peel(&self) -> Result, Error> { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_tag_peel(&mut ret, &*self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Get the tagger (author) of a tag ++ /// ++ /// If the author is unspecified, then `None` is returned. ++ pub fn tagger(&self) -> Option { ++ unsafe { ++ let ptr = raw::git_tag_tagger(&*self.raw); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(signature::from_raw_const(self, ptr)) ++ } ++ } ++ } ++ ++ /// Get the tagged object of a tag ++ /// ++ /// This method performs a repository lookup for the given object and ++ /// returns it ++ pub fn target(&self) -> Result, Error> { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_tag_target(&mut ret, &*self.raw)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Get the OID of the tagged object of a tag ++ pub fn target_id(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_tag_target_id(&*self.raw)) } ++ } ++ ++ /// Get the OID of the tagged object of a tag ++ pub fn target_type(&self) -> Option { ++ unsafe { ObjectType::from_raw(raw::git_tag_target_type(&*self.raw)) } ++ } ++ ++ /// Casts this Tag to be usable as an `Object` ++ pub fn as_object(&self) -> &Object<'repo> { ++ unsafe { ++ &*(self as *const _ as *const Object<'repo>) ++ } ++ } ++ ++ /// Consumes Tag to be returned as an `Object` ++ pub fn into_object(self) -> Object<'repo> { ++ assert_eq!(mem::size_of_val(&self), mem::size_of::()); ++ unsafe { ++ mem::transmute(self) ++ } ++ } ++} ++ ++impl<'repo> Binding for Tag<'repo> { ++ type Raw = *mut raw::git_tag; ++ unsafe fn from_raw(raw: *mut raw::git_tag) -> Tag<'repo> { ++ Tag { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *mut raw::git_tag { self.raw } ++} ++ ++impl<'repo> Drop for Tag<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_tag_free(self.raw) } ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ let head = repo.head().unwrap(); ++ let id = head.target().unwrap(); ++ assert!(repo.find_tag(id).is_err()); ++ ++ let obj = repo.find_object(id, None).unwrap(); ++ let sig = repo.signature().unwrap(); ++ let tag_id = repo.tag("foo", &obj, &sig, "msg", false).unwrap(); ++ let tag = repo.find_tag(tag_id).unwrap(); ++ assert_eq!(tag.id(), tag_id); ++ ++ let tags = repo.tag_names(None).unwrap(); ++ assert_eq!(tags.len(), 1); ++ assert_eq!(tags.get(0), Some("foo")); ++ ++ assert_eq!(tag.name(), Some("foo")); ++ assert_eq!(tag.message(), Some("msg")); ++ assert_eq!(tag.peel().unwrap().id(), obj.id()); ++ assert_eq!(tag.target_id(), obj.id()); ++ assert_eq!(tag.target_type(), Some(::ObjectType::Commit)); ++ ++ assert_eq!(tag.tagger().unwrap().name(), sig.name()); ++ tag.target().unwrap(); ++ tag.into_object(); ++ ++ repo.find_object(tag_id, None).unwrap().as_tag().unwrap(); ++ repo.find_object(tag_id, None).unwrap().into_tag().ok().unwrap(); ++ ++ repo.tag_delete("foo").unwrap(); ++ } ++ ++ #[test] ++ fn lite() { ++ let (_td, repo) = ::test::repo_init(); ++ let head = t!(repo.head()); ++ let id = head.target().unwrap(); ++ let obj = t!(repo.find_object(id, None)); ++ let tag_id = t!(repo.tag_lightweight("foo", &obj, false)); ++ assert!(repo.find_tag(tag_id).is_err()); ++ assert_eq!(t!(repo.refname_to_id("refs/tags/foo")), id); ++ ++ let tags = t!(repo.tag_names(Some("f*"))); ++ assert_eq!(tags.len(), 1); ++ let tags = t!(repo.tag_names(Some("b*"))); ++ assert_eq!(tags.len(), 0); ++ } ++} diff --cc vendor/git2-0.6.8/src/test.rs index 000000000,000000000..4f8813fda new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/test.rs @@@ -1,0 -1,0 +1,61 @@@ ++use std::path::{Path, PathBuf}; ++use std::io; ++#[cfg(unix)] ++use std::ptr; ++use tempdir::TempDir; ++use url::Url; ++ ++use Repository; ++ ++macro_rules! t { ++ ($e:expr) => (match $e { ++ Ok(e) => e, ++ Err(e) => panic!("{} failed with {}", stringify!($e), e), ++ }) ++} ++ ++pub fn repo_init() -> (TempDir, Repository) { ++ let td = TempDir::new("test").unwrap(); ++ let repo = Repository::init(td.path()).unwrap(); ++ { ++ let mut config = repo.config().unwrap(); ++ config.set_str("user.name", "name").unwrap(); ++ config.set_str("user.email", "email").unwrap(); ++ let mut index = repo.index().unwrap(); ++ let id = index.write_tree().unwrap(); ++ ++ let tree = repo.find_tree(id).unwrap(); ++ let sig = repo.signature().unwrap(); ++ repo.commit(Some("HEAD"), &sig, &sig, "initial", ++ &tree, &[]).unwrap(); ++ } ++ (td, repo) ++} ++ ++pub fn path2url(path: &Path) -> String { ++ Url::from_file_path(path).unwrap().to_string() ++} ++ ++#[cfg(windows)] ++pub fn realpath(original: &Path) -> io::Result { ++ Ok(original.to_path_buf()) ++} ++#[cfg(unix)] ++pub fn realpath(original: &Path) -> io::Result { ++ use std::ffi::{CStr, OsString, CString}; ++ use std::os::unix::prelude::*; ++ use libc::{self, c_char}; ++ extern { ++ fn realpath(name: *const c_char, resolved: *mut c_char) -> *mut c_char; ++ } ++ unsafe { ++ let cstr = try!(CString::new(original.as_os_str().as_bytes())); ++ let ptr = realpath(cstr.as_ptr(), ptr::null_mut()); ++ if ptr.is_null() { ++ return Err(io::Error::last_os_error()) ++ } ++ let bytes = CStr::from_ptr(ptr).to_bytes().to_vec(); ++ libc::free(ptr as *mut _); ++ Ok(PathBuf::from(OsString::from_vec(bytes))) ++ } ++} diff --cc vendor/git2-0.6.8/src/time.rs index 000000000,000000000..e344aa3b1 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/time.rs @@@ -1,0 -1,0 +1,95 @@@ ++use std::cmp::Ordering; ++ ++use libc::c_int; ++ ++use raw; ++use util::Binding; ++ ++/// Time in a signature ++#[derive(Copy, Clone, Eq, PartialEq)] ++pub struct Time { ++ raw: raw::git_time, ++} ++ ++/// Time structure used in a git index entry. ++#[derive(Copy, Clone, Eq, PartialEq)] ++pub struct IndexTime { ++ raw: raw::git_index_time, ++} ++ ++impl Time { ++ /// Creates a new time structure from its components. ++ pub fn new(time: i64, offset: i32) -> Time { ++ unsafe { ++ Binding::from_raw(raw::git_time { ++ time: time as raw::git_time_t, ++ offset: offset as c_int, ++ }) ++ } ++ } ++ ++ /// Return the time, in seconds, from epoch ++ pub fn seconds(&self) -> i64 { self.raw.time as i64 } ++ ++ /// Return the timezone offset, in minutes ++ pub fn offset_minutes(&self) -> i32 { self.raw.offset as i32 } ++} ++ ++impl PartialOrd for Time { ++ fn partial_cmp(&self, other: &Time) -> Option { ++ Some(self.cmp(other)) ++ } ++} ++ ++impl Ord for Time { ++ fn cmp(&self, other: &Time) -> Ordering { ++ (self.raw.time, self.raw.offset).cmp(&(other.raw.time, other.raw.offset)) ++ } ++} ++ ++impl Binding for Time { ++ type Raw = raw::git_time; ++ unsafe fn from_raw(raw: raw::git_time) -> Time { ++ Time { raw: raw } ++ } ++ fn raw(&self) -> raw::git_time { self.raw } ++} ++ ++impl IndexTime { ++ /// Creates a new time structure from its components. ++ pub fn new(seconds: i32, nanoseconds: u32) -> IndexTime { ++ unsafe { ++ Binding::from_raw(raw::git_index_time { ++ seconds: seconds, ++ nanoseconds: nanoseconds, ++ }) ++ } ++ } ++ ++ /// Returns the number of seconds in the second component of this time. ++ pub fn seconds(&self) -> i32 { self.raw.seconds } ++ /// Returns the nanosecond component of this time. ++ pub fn nanoseconds(&self) -> u32 { self.raw.nanoseconds } ++} ++ ++impl Binding for IndexTime { ++ type Raw = raw::git_index_time; ++ unsafe fn from_raw(raw: raw::git_index_time) -> IndexTime { ++ IndexTime { raw: raw } ++ } ++ fn raw(&self) -> raw::git_index_time { self.raw } ++} ++ ++impl PartialOrd for IndexTime { ++ fn partial_cmp(&self, other: &IndexTime) -> Option { ++ Some(self.cmp(other)) ++ } ++} ++ ++impl Ord for IndexTime { ++ fn cmp(&self, other: &IndexTime) -> Ordering { ++ let me = (self.raw.seconds, self.raw.nanoseconds); ++ let other = (other.raw.seconds, other.raw.nanoseconds); ++ me.cmp(&other) ++ } ++} diff --cc vendor/git2-0.6.8/src/transport.rs index 000000000,000000000..1b9dbd5a5 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/transport.rs @@@ -1,0 -1,0 +1,326 @@@ ++//! Interfaces for adding custom transports to libgit2 ++ ++use std::ffi::{CStr, CString}; ++use std::io::prelude::*; ++use std::io; ++use std::mem; ++use std::slice; ++use std::ptr; ++use std::str; ++use libc::{c_int, c_void, c_uint, c_char, size_t}; ++ ++use {raw, panic, Error, Remote}; ++use util::Binding; ++ ++/// A transport is a structure which knows how to transfer data to and from a ++/// remote. ++/// ++/// This transport is a representation of the raw transport underneath it, which ++/// is similar to a trait object in Rust. ++#[allow(missing_copy_implementations)] ++pub struct Transport { ++ raw: *mut raw::git_transport, ++ owned: bool, ++} ++ ++/// Interfaced used by smart transports. ++/// ++/// The full-fledged definiton of transports has to deal with lots of ++/// nitty-gritty details of the git protocol, but "smart transports" largely ++/// only need to deal with read() and write() of data over a channel. ++/// ++/// A smart subtransport is contained within an instance of a smart transport ++/// and is delegated to in order to actually conduct network activity to push or ++/// pull data from a remote. ++pub trait SmartSubtransport: Send + 'static { ++ /// Indicates that this subtransport will be performing the specified action ++ /// on the specified URL. ++ /// ++ /// This function is responsible for making any network connections and ++ /// returns a stream which can be read and written from in order to ++ /// negotiate the git protocol. ++ fn action(&self, url: &str, action: Service) ++ -> Result, Error>; ++ ++ /// Terminates a connection with the remote. ++ /// ++ /// Each subtransport is guaranteed a call to close() between calls to ++ /// action(), except for the following tow natural progressions of actions ++ /// against a constant URL. ++ /// ++ /// 1. UploadPackLs -> UploadPack ++ /// 2. ReceivePackLs -> ReceivePack ++ fn close(&self) -> Result<(), Error>; ++} ++ ++/// Actions that a smart transport can ask a subtransport to perform ++#[derive(Copy, Clone)] ++#[allow(missing_docs)] ++pub enum Service { ++ UploadPackLs, ++ UploadPack, ++ ReceivePackLs, ++ ReceivePack, ++} ++ ++/// An instance of a stream over which a smart transport will communicate with a ++/// remote. ++/// ++/// Currently this only requires the standard `Read` and `Write` traits. This ++/// trait also does not need to be implemented manually as long as the `Read` ++/// and `Write` traits are implemented. ++pub trait SmartSubtransportStream: Read + Write + Send + 'static {} ++ ++impl SmartSubtransportStream for T {} ++ ++type TransportFactory = Fn(&Remote) -> Result + Send + Sync + ++ 'static; ++ ++/// Boxed data payload used for registering new transports. ++/// ++/// Currently only contains a field which knows how to create transports. ++struct TransportData { ++ factory: Box, ++} ++ ++/// Instance of a `git_smart_subtransport`, must use `#[repr(C)]` to ensure that ++/// the C fields come first. ++#[repr(C)] ++struct RawSmartSubtransport { ++ raw: raw::git_smart_subtransport, ++ obj: Box, ++} ++ ++/// Instance of a `git_smart_subtransport_stream`, must use `#[repr(C)]` to ++/// ensure that the C fields come first. ++#[repr(C)] ++struct RawSmartSubtransportStream { ++ raw: raw::git_smart_subtransport_stream, ++ obj: Box, ++} ++ ++/// Add a custom transport definition, to be used in addition to the built-in ++/// set of transports that come with libgit2. ++/// ++/// This function is unsafe as it needs to be externally synchronized with calls ++/// to creation of other transports. ++pub unsafe fn register(prefix: &str, factory: F) -> Result<(), Error> ++ where F: Fn(&Remote) -> Result + Send + Sync + 'static ++{ ++ let mut data = Box::new(TransportData { ++ factory: Box::new(factory), ++ }); ++ let prefix = try!(CString::new(prefix)); ++ let datap = (&mut *data) as *mut TransportData as *mut c_void; ++ try_call!(raw::git_transport_register(prefix, ++ transport_factory, ++ datap)); ++ mem::forget(data); ++ Ok(()) ++} ++ ++impl Transport { ++ /// Creates a new transport which will use the "smart" transport protocol ++ /// for transferring data. ++ /// ++ /// A smart transport requires a *subtransport* over which data is actually ++ /// communicated, but this subtransport largely just needs to be able to ++ /// read() and write(). The subtransport provided will be used to make ++ /// connections which can then be read/written from. ++ /// ++ /// The `rpc` argument is `true` if the protocol is stateless, false ++ /// otherwise. For example `http://` is stateless but `git://` is not. ++ pub fn smart(remote: &Remote, ++ rpc: bool, ++ subtransport: S) -> Result ++ where S: SmartSubtransport ++ { ++ let mut ret = ptr::null_mut(); ++ ++ let mut raw = Box::new(RawSmartSubtransport { ++ raw: raw::git_smart_subtransport { ++ action: subtransport_action, ++ close: subtransport_close, ++ free: subtransport_free, ++ }, ++ obj: Box::new(subtransport), ++ }); ++ let mut defn = raw::git_smart_subtransport_definition { ++ callback: smart_factory, ++ rpc: rpc as c_uint, ++ param: &mut *raw as *mut _ as *mut _, ++ }; ++ ++ // Currently there's no way to pass a paload via the ++ // git_smart_subtransport_definition structure, but it's only used as a ++ // configuration for the initial creation of the smart transport (verified ++ // by reading the current code, hopefully it doesn't change!). ++ // ++ // We, however, need some state (gotta pass in our ++ // `RawSmartSubtransport`). This also means that this block must be ++ // entirely synchronized with a lock (boo!) ++ unsafe { ++ try_call!(raw::git_transport_smart(&mut ret, remote.raw(), ++ &mut defn as *mut _ as *mut _)); ++ mem::forget(raw); // ownership transport to `ret` ++ } ++ return Ok(Transport { raw: ret, owned: true }); ++ ++ extern fn smart_factory(out: *mut *mut raw::git_smart_subtransport, ++ _owner: *mut raw::git_transport, ++ ptr: *mut c_void) -> c_int { ++ unsafe { ++ *out = ptr as *mut raw::git_smart_subtransport; ++ 0 ++ } ++ } ++ } ++} ++ ++impl Drop for Transport { ++ fn drop(&mut self) { ++ if self.owned { ++ unsafe { ++ ((*self.raw).free)(self.raw) ++ } ++ } ++ } ++} ++ ++// callback used by register() to create new transports ++extern fn transport_factory(out: *mut *mut raw::git_transport, ++ owner: *mut raw::git_remote, ++ param: *mut c_void) -> c_int { ++ struct Bomb<'a> { remote: Option> } ++ impl<'a> Drop for Bomb<'a> { ++ fn drop(&mut self) { ++ // TODO: maybe a method instead? ++ mem::forget(self.remote.take()); ++ } ++ } ++ ++ panic::wrap(|| unsafe { ++ let remote = Bomb { remote: Some(Binding::from_raw(owner)) }; ++ let data = &mut *(param as *mut TransportData); ++ match (data.factory)(remote.remote.as_ref().unwrap()) { ++ Ok(mut transport) => { ++ *out = transport.raw; ++ transport.owned = false; ++ 0 ++ } ++ Err(e) => e.raw_code() as c_int, ++ } ++ }).unwrap_or(-1) ++} ++ ++// callback used by smart transports to delegate an action to a ++// `SmartSubtransport` trait object. ++extern fn subtransport_action(stream: *mut *mut raw::git_smart_subtransport_stream, ++ raw_transport: *mut raw::git_smart_subtransport, ++ url: *const c_char, ++ action: raw::git_smart_service_t) -> c_int { ++ panic::wrap(|| unsafe { ++ let url = CStr::from_ptr(url).to_bytes(); ++ let url = match str::from_utf8(url).ok() { ++ Some(s) => s, ++ None => return -1, ++ }; ++ let action = match action { ++ raw::GIT_SERVICE_UPLOADPACK_LS => Service::UploadPackLs, ++ raw::GIT_SERVICE_UPLOADPACK => Service::UploadPack, ++ raw::GIT_SERVICE_RECEIVEPACK_LS => Service::ReceivePackLs, ++ raw::GIT_SERVICE_RECEIVEPACK => Service::ReceivePack, ++ n => panic!("unknown action: {}", n), ++ }; ++ let transport = &mut *(raw_transport as *mut RawSmartSubtransport); ++ let obj = match transport.obj.action(url, action) { ++ Ok(s) => s, ++ Err(e) => return e.raw_code() as c_int, ++ }; ++ *stream = mem::transmute(Box::new(RawSmartSubtransportStream { ++ raw: raw::git_smart_subtransport_stream { ++ subtransport: raw_transport, ++ read: stream_read, ++ write: stream_write, ++ free: stream_free, ++ }, ++ obj: obj, ++ })); ++ 0 ++ }).unwrap_or(-1) ++} ++ ++// callback used by smart transports to close a `SmartSubtransport` trait ++// object. ++extern fn subtransport_close(transport: *mut raw::git_smart_subtransport) ++ -> c_int { ++ let ret = panic::wrap(|| unsafe { ++ let transport = &mut *(transport as *mut RawSmartSubtransport); ++ transport.obj.close() ++ }); ++ match ret { ++ Some(Ok(())) => 0, ++ Some(Err(e)) => e.raw_code() as c_int, ++ None => -1, ++ } ++} ++ ++// callback used by smart transports to free a `SmartSubtransport` trait ++// object. ++extern fn subtransport_free(transport: *mut raw::git_smart_subtransport) { ++ let _ = panic::wrap(|| unsafe { ++ mem::transmute::<_, Box>(transport); ++ }); ++} ++ ++// callback used by smart transports to read from a `SmartSubtransportStream` ++// object. ++extern fn stream_read(stream: *mut raw::git_smart_subtransport_stream, ++ buffer: *mut c_char, ++ buf_size: size_t, ++ bytes_read: *mut size_t) -> c_int { ++ let ret = panic::wrap(|| unsafe { ++ let transport = &mut *(stream as *mut RawSmartSubtransportStream); ++ let buf = slice::from_raw_parts_mut(buffer as *mut u8, ++ buf_size as usize); ++ match transport.obj.read(buf) { ++ Ok(n) => { *bytes_read = n as size_t; Ok(n) } ++ e => e, ++ } ++ }); ++ match ret { ++ Some(Ok(_)) => 0, ++ Some(Err(e)) => unsafe { set_err(&e); -2 }, ++ None => -1, ++ } ++} ++ ++// callback used by smart transports to write to a `SmartSubtransportStream` ++// object. ++extern fn stream_write(stream: *mut raw::git_smart_subtransport_stream, ++ buffer: *const c_char, ++ len: size_t) -> c_int { ++ let ret = panic::wrap(|| unsafe { ++ let transport = &mut *(stream as *mut RawSmartSubtransportStream); ++ let buf = slice::from_raw_parts(buffer as *const u8, len as usize); ++ transport.obj.write_all(buf) ++ }); ++ match ret { ++ Some(Ok(())) => 0, ++ Some(Err(e)) => unsafe { set_err(&e); -2 }, ++ None => -1, ++ } ++} ++ ++unsafe fn set_err(e: &io::Error) { ++ let s = CString::new(e.to_string()).unwrap(); ++ raw::giterr_set_str(raw::GITERR_NET as c_int, s.as_ptr()) ++} ++ ++// callback used by smart transports to free a `SmartSubtransportStream` ++// object. ++extern fn stream_free(stream: *mut raw::git_smart_subtransport_stream) { ++ let _ = panic::wrap(|| unsafe { ++ mem::transmute::<_, Box>(stream); ++ }); ++} diff --cc vendor/git2-0.6.8/src/tree.rs index 000000000,000000000..a7aaed235 new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/tree.rs @@@ -1,0 -1,0 +1,394 @@@ ++use std::mem; ++use std::cmp::Ordering; ++use std::ffi::CString; ++use std::ops::Range; ++use std::marker; ++use std::path::Path; ++use std::ptr; ++use std::str; ++use libc; ++ ++use {raw, Oid, Repository, Error, Object, ObjectType}; ++use util::{Binding, IntoCString}; ++ ++/// A structure to represent a git [tree][1] ++/// ++/// [1]: http://git-scm.com/book/en/Git-Internals-Git-Objects ++pub struct Tree<'repo> { ++ raw: *mut raw::git_tree, ++ _marker: marker::PhantomData>, ++} ++ ++/// A structure representing an entry inside of a tree. An entry is borrowed ++/// from a tree. ++pub struct TreeEntry<'tree> { ++ raw: *mut raw::git_tree_entry, ++ owned: bool, ++ _marker: marker::PhantomData<&'tree raw::git_tree_entry>, ++} ++ ++/// An iterator over the entries in a tree. ++pub struct TreeIter<'tree> { ++ range: Range, ++ tree: &'tree Tree<'tree>, ++} ++ ++impl<'repo> Tree<'repo> { ++ /// Get the id (SHA1) of a repository object ++ pub fn id(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_tree_id(&*self.raw)) } ++ } ++ ++ /// Get the number of entries listed in this tree. ++ pub fn len(&self) -> usize { ++ unsafe { raw::git_tree_entrycount(&*self.raw) as usize } ++ } ++ ++ /// Return `true` if there is not entry ++ pub fn is_empty(&self) -> bool { ++ self.len() == 0 ++ } ++ ++ /// Returns an iterator over the entries in this tree. ++ pub fn iter(&self) -> TreeIter { ++ TreeIter { range: 0..self.len(), tree: self } ++ } ++ ++ /// Lookup a tree entry by SHA value. ++ pub fn get_id(&self, id: Oid) -> Option { ++ unsafe { ++ let ptr = raw::git_tree_entry_byid(&*self.raw(), &*id.raw()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(entry_from_raw_const(ptr)) ++ } ++ } ++ } ++ ++ /// Lookup a tree entry by its position in the tree ++ pub fn get(&self, n: usize) -> Option { ++ unsafe { ++ let ptr = raw::git_tree_entry_byindex(&*self.raw(), ++ n as libc::size_t); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(entry_from_raw_const(ptr)) ++ } ++ } ++ } ++ ++ /// Lookup a tree entry by its filename ++ pub fn get_name(&self, filename: &str) -> Option { ++ let filename = CString::new(filename).unwrap(); ++ unsafe { ++ let ptr = call!(raw::git_tree_entry_byname(&*self.raw(), filename)); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(entry_from_raw_const(ptr)) ++ } ++ } ++ } ++ ++ /// Retrieve a tree entry contained in a tree or in any of its subtrees, ++ /// given its relative path. ++ pub fn get_path(&self, path: &Path) -> Result, Error> { ++ let path = try!(path.into_c_string()); ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_tree_entry_bypath(&mut ret, &*self.raw(), path)); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Casts this Tree to be usable as an `Object` ++ pub fn as_object(&self) -> &Object<'repo> { ++ unsafe { ++ &*(self as *const _ as *const Object<'repo>) ++ } ++ } ++ ++ /// Consumes Commit to be returned as an `Object` ++ pub fn into_object(self) -> Object<'repo> { ++ assert_eq!(mem::size_of_val(&self), mem::size_of::()); ++ unsafe { ++ mem::transmute(self) ++ } ++ } ++} ++ ++impl<'repo> Binding for Tree<'repo> { ++ type Raw = *mut raw::git_tree; ++ ++ unsafe fn from_raw(raw: *mut raw::git_tree) -> Tree<'repo> { ++ Tree { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *mut raw::git_tree { self.raw } ++} ++ ++impl<'repo> Drop for Tree<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_tree_free(self.raw) } ++ } ++} ++ ++impl<'repo, 'iter> IntoIterator for &'iter Tree<'repo> { ++ type Item = TreeEntry<'iter>; ++ type IntoIter = TreeIter<'iter>; ++ fn into_iter(self) -> Self::IntoIter { ++ self.iter() ++ } ++} ++ ++/// Create a new tree entry from the raw pointer provided. ++/// ++/// The lifetime of the entry is tied to the tree provided and the function ++/// is unsafe because the validity of the pointer cannot be guaranteed. ++pub unsafe fn entry_from_raw_const<'tree>(raw: *const raw::git_tree_entry) ++ -> TreeEntry<'tree> { ++ TreeEntry { ++ raw: raw as *mut raw::git_tree_entry, ++ owned: false, ++ _marker: marker::PhantomData, ++ } ++} ++ ++impl<'tree> TreeEntry<'tree> { ++ /// Get the id of the object pointed by the entry ++ pub fn id(&self) -> Oid { ++ unsafe { Binding::from_raw(raw::git_tree_entry_id(&*self.raw)) } ++ } ++ ++ /// Get the filename of a tree entry ++ /// ++ /// Returns `None` if the name is not valid utf-8 ++ pub fn name(&self) -> Option<&str> { ++ str::from_utf8(self.name_bytes()).ok() ++ } ++ ++ /// Get the filename of a tree entry ++ pub fn name_bytes(&self) -> &[u8] { ++ unsafe { ++ ::opt_bytes(self, raw::git_tree_entry_name(&*self.raw())).unwrap() ++ } ++ } ++ ++ /// Convert a tree entry to the object it points to. ++ pub fn to_object<'a>(&self, repo: &'a Repository) ++ -> Result, Error> { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ try_call!(raw::git_tree_entry_to_object(&mut ret, repo.raw(), ++ &*self.raw())); ++ Ok(Binding::from_raw(ret)) ++ } ++ } ++ ++ /// Get the type of the object pointed by the entry ++ pub fn kind(&self) -> Option { ++ ObjectType::from_raw(unsafe { raw::git_tree_entry_type(&*self.raw) }) ++ } ++ ++ /// Get the UNIX file attributes of a tree entry ++ pub fn filemode(&self) -> i32 { ++ unsafe { raw::git_tree_entry_filemode(&*self.raw) as i32 } ++ } ++ ++ /// Get the raw UNIX file attributes of a tree entry ++ pub fn filemode_raw(&self) -> i32 { ++ unsafe { raw::git_tree_entry_filemode_raw(&*self.raw) as i32 } ++ } ++ ++ /// Convert this entry of any lifetime into an owned signature with a static ++ /// lifetime. ++ /// ++ /// This will use the `Clone::clone` implementation under the hood. ++ pub fn to_owned(&self) -> TreeEntry<'static> { ++ unsafe { ++ let me = mem::transmute::<&TreeEntry<'tree>, &TreeEntry<'static>>(self); ++ me.clone() ++ } ++ } ++} ++ ++impl<'a> Binding for TreeEntry<'a> { ++ type Raw = *mut raw::git_tree_entry; ++ unsafe fn from_raw(raw: *mut raw::git_tree_entry) -> TreeEntry<'a> { ++ TreeEntry { ++ raw: raw, ++ owned: true, ++ _marker: marker::PhantomData, ++ } ++ } ++ fn raw(&self) -> *mut raw::git_tree_entry { self.raw } ++} ++ ++impl<'a> Clone for TreeEntry<'a> { ++ fn clone(&self) -> TreeEntry<'a> { ++ let mut ret = ptr::null_mut(); ++ unsafe { ++ assert_eq!(raw::git_tree_entry_dup(&mut ret, &*self.raw()), 0); ++ Binding::from_raw(ret) ++ } ++ } ++} ++ ++impl<'a> PartialOrd for TreeEntry<'a> { ++ fn partial_cmp(&self, other: &TreeEntry<'a>) -> Option { ++ Some(self.cmp(other)) ++ } ++} ++impl<'a> Ord for TreeEntry<'a> { ++ fn cmp(&self, other: &TreeEntry<'a>) -> Ordering { ++ match unsafe { raw::git_tree_entry_cmp(&*self.raw(), &*other.raw()) } { ++ 0 => Ordering::Equal, ++ n if n < 0 => Ordering::Less, ++ _ => Ordering::Greater, ++ } ++ } ++} ++ ++impl<'a> PartialEq for TreeEntry<'a> { ++ fn eq(&self, other: &TreeEntry<'a>) -> bool { ++ self.cmp(other) == Ordering::Equal ++ } ++} ++impl<'a> Eq for TreeEntry<'a> {} ++ ++impl<'a> Drop for TreeEntry<'a> { ++ fn drop(&mut self) { ++ if self.owned { ++ unsafe { raw::git_tree_entry_free(self.raw) } ++ } ++ } ++} ++ ++impl<'tree> Iterator for TreeIter<'tree> { ++ type Item = TreeEntry<'tree>; ++ fn next(&mut self) -> Option> { ++ self.range.next().and_then(|i| self.tree.get(i)) ++ } ++ fn size_hint(&self) -> (usize, Option) { self.range.size_hint() } ++} ++impl<'tree> DoubleEndedIterator for TreeIter<'tree> { ++ fn next_back(&mut self) -> Option> { ++ self.range.next_back().and_then(|i| self.tree.get(i)) ++ } ++} ++impl<'tree> ExactSizeIterator for TreeIter<'tree> {} ++ ++#[cfg(test)] ++mod tests { ++ use {Repository,Tree,TreeEntry,ObjectType,Object}; ++ use tempdir::TempDir; ++ use std::fs::File; ++ use std::io::prelude::*; ++ use std::path::Path; ++ ++ pub struct TestTreeIter<'a> { ++ entries: Vec>, ++ repo: &'a Repository, ++ } ++ ++ impl<'a> Iterator for TestTreeIter<'a> { ++ type Item = TreeEntry<'a>; ++ ++ fn next(&mut self) -> Option > { ++ if self.entries.is_empty() { ++ None ++ } else { ++ let entry = self.entries.remove(0); ++ ++ match entry.kind() { ++ Some(ObjectType::Tree) => { ++ let obj: Object<'a> = entry.to_object(self.repo).unwrap(); ++ ++ let tree: &Tree<'a> = obj.as_tree().unwrap(); ++ ++ for entry in tree.iter() { ++ self.entries.push(entry.to_owned()); ++ } ++ } ++ _ => {} ++ } ++ ++ Some(entry) ++ } ++ } ++ } ++ ++ fn tree_iter<'repo>(tree: &Tree<'repo>, repo: &'repo Repository) ++ -> TestTreeIter<'repo> { ++ let mut initial = vec![]; ++ ++ for entry in tree.iter() { ++ initial.push(entry.to_owned()); ++ } ++ ++ TestTreeIter { ++ entries: initial, ++ repo: repo, ++ } ++ } ++ ++ #[test] ++ fn smoke_tree_iter() { ++ let (td, repo) = ::test::repo_init(); ++ ++ setup_repo(&td, &repo); ++ ++ let head = repo.head().unwrap(); ++ let target = head.target().unwrap(); ++ let commit = repo.find_commit(target).unwrap(); ++ ++ let tree = repo.find_tree(commit.tree_id()).unwrap(); ++ assert_eq!(tree.id(), commit.tree_id()); ++ assert_eq!(tree.len(), 1); ++ ++ for entry in tree_iter(&tree, &repo) { ++ println!("iter entry {:?}", entry.name()); ++ } ++ } ++ ++ fn setup_repo(td: &TempDir, repo: &Repository) { ++ let mut index = repo.index().unwrap(); ++ File::create(&td.path().join("foo")).unwrap().write_all(b"foo").unwrap(); ++ index.add_path(Path::new("foo")).unwrap(); ++ let id = index.write_tree().unwrap(); ++ let sig = repo.signature().unwrap(); ++ let tree = repo.find_tree(id).unwrap(); ++ let parent = repo.find_commit(repo.head().unwrap().target() ++ .unwrap()).unwrap(); ++ repo.commit(Some("HEAD"), &sig, &sig, "another commit", ++ &tree, &[&parent]).unwrap(); ++ } ++ ++ #[test] ++ fn smoke() { ++ let (td, repo) = ::test::repo_init(); ++ ++ setup_repo(&td, &repo); ++ ++ let head = repo.head().unwrap(); ++ let target = head.target().unwrap(); ++ let commit = repo.find_commit(target).unwrap(); ++ ++ let tree = repo.find_tree(commit.tree_id()).unwrap(); ++ assert_eq!(tree.id(), commit.tree_id()); ++ assert_eq!(tree.len(), 1); ++ { ++ let e1 = tree.get(0).unwrap(); ++ assert!(e1 == tree.get_id(e1.id()).unwrap()); ++ assert!(e1 == tree.get_name("foo").unwrap()); ++ assert!(e1 == tree.get_path(Path::new("foo")).unwrap()); ++ assert_eq!(e1.name(), Some("foo")); ++ e1.to_object(&repo).unwrap(); ++ } ++ tree.into_object(); ++ ++ repo.find_object(commit.tree_id(), None).unwrap().as_tree().unwrap(); ++ repo.find_object(commit.tree_id(), None).unwrap().into_tree().ok().unwrap(); ++ } ++} diff --cc vendor/git2-0.6.8/src/treebuilder.rs index 000000000,000000000..e8ea1057c new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/treebuilder.rs @@@ -1,0 -1,0 +1,199 @@@ ++use std::marker; ++use std::ptr; ++ ++use libc::{c_int, c_void}; ++ ++use {panic, raw, tree, Error, Oid, Repository, TreeEntry}; ++use util::{Binding, IntoCString}; ++ ++/// Constructor for in-memory trees ++pub struct TreeBuilder<'repo> { ++ raw: *mut raw::git_treebuilder, ++ _marker: marker::PhantomData<&'repo Repository>, ++} ++ ++impl<'repo> TreeBuilder<'repo> { ++ /// Clear all the entries in the builder ++ pub fn clear(&mut self) { ++ unsafe { raw::git_treebuilder_clear(self.raw) } ++ } ++ ++ /// Get the number of entries ++ pub fn len(&self) -> usize { ++ unsafe { raw::git_treebuilder_entrycount(self.raw) as usize } ++ } ++ ++ /// Return `true` if there is no entry ++ pub fn is_empty(&self) -> bool { ++ self.len() == 0 ++ } ++ ++ /// Get en entry from the builder from its filename ++ pub fn get

(&self, filename: P) -> Result, Error> ++ where P: IntoCString ++ { ++ let filename = try!(filename.into_c_string()); ++ unsafe { ++ let ret = raw::git_treebuilder_get(self.raw, filename.as_ptr()); ++ if ret.is_null() { ++ Ok(None) ++ } else { ++ Ok(Some(tree::entry_from_raw_const(ret))) ++ } ++ } ++ } ++ ++ /// Add or update an entry in the builder ++ /// ++ /// No attempt is made to ensure that the provided Oid points to ++ /// an object of a reasonable type (or any object at all). ++ /// ++ /// The mode given must be one of 0o040000, 0o100644, 0o100755, 0o120000 or ++ /// 0o160000 currently. ++ pub fn insert(&mut self, filename: P, oid: Oid, ++ filemode: i32) -> Result { ++ let filename = try!(filename.into_c_string()); ++ let filemode = filemode as raw::git_filemode_t; ++ ++ let mut ret = ptr::null(); ++ unsafe { ++ try_call!(raw::git_treebuilder_insert(&mut ret, self.raw, filename, ++ oid.raw(), filemode)); ++ Ok(tree::entry_from_raw_const(ret)) ++ } ++ } ++ ++ /// Remove an entry from the builder by its filename ++ pub fn remove(&mut self, filename: P) -> Result<(), Error> { ++ let filename = try!(filename.into_c_string()); ++ unsafe { ++ try_call!(raw::git_treebuilder_remove(self.raw, filename)); ++ } ++ Ok(()) ++ } ++ ++ /// Selectively remove entries from the tree ++ /// ++ /// Values for which the filter returns `true` will be kept. Note ++ /// that this behavior is different from the libgit2 C interface. ++ pub fn filter(&mut self, mut filter: F) ++ where F: FnMut(&TreeEntry) -> bool ++ { ++ let mut cb: &mut FilterCb = &mut filter; ++ let ptr = &mut cb as *mut _; ++ unsafe { ++ raw::git_treebuilder_filter(self.raw, filter_cb, ptr as *mut _); ++ panic::check(); ++ } ++ } ++ ++ /// Write the contents of the TreeBuilder as a Tree object and ++ /// return its Oid ++ pub fn write(&self) -> Result { ++ let mut raw = raw::git_oid { id: [0; raw::GIT_OID_RAWSZ] }; ++ unsafe { ++ try_call!(raw::git_treebuilder_write(&mut raw, self.raw())); ++ Ok(Binding::from_raw(&raw as *const _)) ++ } ++ } ++} ++ ++type FilterCb<'a> = FnMut(&TreeEntry) -> bool + 'a; ++ ++extern fn filter_cb(entry: *const raw::git_tree_entry, ++ payload: *mut c_void) -> c_int { ++ let ret = panic::wrap(|| unsafe { ++ // There's no way to return early from git_treebuilder_filter. ++ if panic::panicked() { ++ true ++ } else { ++ let entry = tree::entry_from_raw_const(entry); ++ let payload = payload as *mut &mut FilterCb; ++ (*payload)(&entry) ++ } ++ }); ++ if ret == Some(false) {1} else {0} ++} ++ ++impl<'repo> Binding for TreeBuilder<'repo> { ++ type Raw = *mut raw::git_treebuilder; ++ ++ unsafe fn from_raw(raw: *mut raw::git_treebuilder) -> TreeBuilder<'repo> { ++ TreeBuilder { raw: raw, _marker: marker::PhantomData } ++ } ++ fn raw(&self) -> *mut raw::git_treebuilder { self.raw } ++} ++ ++impl<'repo> Drop for TreeBuilder<'repo> { ++ fn drop(&mut self) { ++ unsafe { raw::git_treebuilder_free(self.raw) } ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use ObjectType; ++ ++ #[test] ++ fn smoke() { ++ let (_td, repo) = ::test::repo_init(); ++ ++ let mut builder = repo.treebuilder(None).unwrap(); ++ assert_eq!(builder.len(), 0); ++ let blob = repo.blob(b"data").unwrap(); ++ { ++ let entry = builder.insert("a", blob, 0o100644).unwrap(); ++ assert_eq!(entry.kind(), Some(ObjectType::Blob)); ++ } ++ builder.insert("b", blob, 0o100644).unwrap(); ++ assert_eq!(builder.len(), 2); ++ builder.remove("a").unwrap(); ++ assert_eq!(builder.len(), 1); ++ assert_eq!(builder.get("b").unwrap().unwrap().id(), blob); ++ builder.clear(); ++ assert_eq!(builder.len(), 0); ++ } ++ ++ #[test] ++ fn write() { ++ let (_td, repo) = ::test::repo_init(); ++ ++ let mut builder = repo.treebuilder(None).unwrap(); ++ let data = repo.blob(b"data").unwrap(); ++ builder.insert("name", data, 0o100644).unwrap(); ++ let tree = builder.write().unwrap(); ++ let tree = repo.find_tree(tree).unwrap(); ++ let entry = tree.get(0).unwrap(); ++ assert_eq!(entry.name(), Some("name")); ++ let blob = entry.to_object(&repo).unwrap(); ++ let blob = blob.as_blob().unwrap(); ++ assert_eq!(blob.content(), b"data"); ++ ++ let builder = repo.treebuilder(Some(&tree)).unwrap(); ++ assert_eq!(builder.len(), 1); ++ } ++ ++ #[test] ++ fn filter() { ++ let (_td, repo) = ::test::repo_init(); ++ ++ let mut builder = repo.treebuilder(None).unwrap(); ++ let blob = repo.blob(b"data").unwrap(); ++ let tree = { ++ let head = repo.head().unwrap() ++ .peel(ObjectType::Commit).unwrap(); ++ let head = head.as_commit().unwrap(); ++ head.tree_id() ++ }; ++ builder.insert("blob", blob, 0o100644).unwrap(); ++ builder.insert("dir", tree, 0o040000).unwrap(); ++ builder.insert("dir2", tree, 0o040000).unwrap(); ++ ++ builder.filter(|_| true); ++ assert_eq!(builder.len(), 3); ++ builder.filter(|e| e.kind().unwrap() != ObjectType::Blob); ++ assert_eq!(builder.len(), 2); ++ builder.filter(|_| false); ++ assert_eq!(builder.len(), 0); ++ } ++} diff --cc vendor/git2-0.6.8/src/util.rs index 000000000,000000000..e111628ea new file mode 100644 --- /dev/null +++ b/vendor/git2-0.6.8/src/util.rs @@@ -1,0 -1,0 +1,152 @@@ ++use std::ffi::{CString, OsStr, OsString}; ++use std::iter::IntoIterator; ++use std::path::{Path, PathBuf}; ++use libc::{c_char, size_t}; ++ ++use {raw, Error}; ++ ++#[doc(hidden)] ++pub trait IsNull { ++ fn is_ptr_null(&self) -> bool; ++} ++impl IsNull for *const T { ++ fn is_ptr_null(&self) -> bool { ++ self.is_null() ++ } ++} ++impl IsNull for *mut T { ++ fn is_ptr_null(&self) -> bool { ++ self.is_null() ++ } ++} ++ ++#[doc(hidden)] ++pub trait Binding: Sized { ++ type Raw; ++ ++ unsafe fn from_raw(raw: Self::Raw) -> Self; ++ fn raw(&self) -> Self::Raw; ++ ++ unsafe fn from_raw_opt(raw: T) -> Option ++ where T: Copy + IsNull, Self: Binding ++ { ++ if raw.is_ptr_null() { ++ None ++ } else { ++ Some(Binding::from_raw(raw)) ++ } ++ } ++} ++ ++pub fn iter2cstrs(iter: I) -> Result<(Vec, Vec<*const c_char>, ++ raw::git_strarray), Error> ++ where T: IntoCString, I: IntoIterator ++{ ++ let cstrs: Vec<_> = try!(iter.into_iter().map(|i| i.into_c_string()).collect()); ++ let ptrs = cstrs.iter().map(|i| i.as_ptr()).collect::>(); ++ let raw = raw::git_strarray { ++ strings: ptrs.as_ptr() as *mut _, ++ count: ptrs.len() as size_t, ++ }; ++ Ok((cstrs, ptrs, raw)) ++} ++ ++#[cfg(unix)] ++pub fn bytes2path(b: &[u8]) -> &Path { ++ use std::os::unix::prelude::*; ++ Path::new(OsStr::from_bytes(b)) ++} ++#[cfg(windows)] ++pub fn bytes2path(b: &[u8]) -> &Path { ++ use std::str; ++ Path::new(str::from_utf8(b).unwrap()) ++} ++ ++/// A class of types that can be converted to C strings. ++/// ++/// These types are represented internally as byte slices and it is quite rare ++/// for them to contain an interior 0 byte. ++pub trait IntoCString { ++ /// Consume this container, converting it into a CString ++ fn into_c_string(self) -> Result; ++} ++ ++impl<'a, T: IntoCString + Clone> IntoCString for &'a T { ++ fn into_c_string(self) -> Result { ++ self.clone().into_c_string() ++ } ++} ++ ++impl<'a> IntoCString for &'a str { ++ fn into_c_string(self) -> Result { ++ Ok(try!(CString::new(self))) ++ } ++} ++ ++impl IntoCString for String { ++ fn into_c_string(self) -> Result { ++ Ok(try!(CString::new(self.into_bytes()))) ++ } ++} ++ ++impl IntoCString for CString { ++ fn into_c_string(self) -> Result { Ok(self) } ++} ++ ++impl<'a> IntoCString for &'a Path { ++ fn into_c_string(self) -> Result { ++ let s: &OsStr = self.as_ref(); ++ s.into_c_string() ++ } ++} ++ ++impl IntoCString for PathBuf { ++ fn into_c_string(self) -> Result { ++ let s: OsString = self.into(); ++ s.into_c_string() ++ } ++} ++ ++impl<'a> IntoCString for &'a OsStr { ++ fn into_c_string(self) -> Result { ++ self.to_os_string().into_c_string() ++ } ++} ++ ++impl IntoCString for OsString { ++ #[cfg(unix)] ++ fn into_c_string(self) -> Result { ++ use std::os::unix::prelude::*; ++ let s: &OsStr = self.as_ref(); ++ Ok(try!(CString::new(s.as_bytes()))) ++ } ++ #[cfg(windows)] ++ fn into_c_string(self) -> Result { ++ match self.to_str() { ++ Some(s) => s.into_c_string(), ++ None => Err(Error::from_str("only valid unicode paths are accepted \ ++ on windows")), ++ } ++ } ++} ++ ++impl<'a> IntoCString for &'a [u8] { ++ fn into_c_string(self) -> Result { ++ Ok(try!(CString::new(self))) ++ } ++} ++ ++impl IntoCString for Vec { ++ fn into_c_string(self) -> Result { ++ Ok(try!(CString::new(self))) ++ } ++} ++ ++pub fn into_opt_c_string(opt_s: Option) -> Result, Error> ++ where S: IntoCString ++{ ++ match opt_s { ++ None => Ok(None), ++ Some(s) => Ok(Some(try!(s.into_c_string()))), ++ } ++} diff --cc vendor/itoa-0.3.4/.cargo-checksum.json index 000000000,000000000..9d19f173c new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c"} diff --cc vendor/itoa-0.3.4/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/.cargo-ok diff --cc vendor/itoa-0.3.4/.travis.yml index 000000000,000000000..6a5a6dba7 new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/.travis.yml @@@ -1,0 -1,0 +1,17 @@@ ++sudo: false ++language: rust ++ ++matrix: ++ include: ++ - rust: stable ++ - rust: beta ++ - rust: nightly ++ env: ++ - FEATURES="i128" ++ - BUILD_BENCH="true" ++ ++script: ++ - cargo build --verbose --features "$FEATURES" ++ - cargo test --verbose --features "$FEATURES" ++ - if [ "$BUILD_BENCH" == "true" ]; then cargo bench --verbose --no-run --features "$FEATURES"; fi ++ diff --cc vendor/itoa-0.3.4/Cargo.toml index 000000000,000000000..00b16c459 new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/Cargo.toml @@@ -1,0 -1,0 +1,26 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "itoa" ++version = "0.3.4" ++authors = ["David Tolnay "] ++exclude = ["performance.png"] ++description = "Fast functions for printing integer primitives to an io::Write" ++documentation = "https://github.com/dtolnay/itoa" ++readme = "README.md" ++categories = ["value-formatting"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/dtolnay/itoa" ++ ++[features] ++i128 = [] diff --cc vendor/itoa-0.3.4/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/itoa-0.3.4/LICENSE-MIT index 000000000,000000000..d1c35df03 new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++Copyright (c) 2016 Itoa 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 --cc vendor/itoa-0.3.4/README.md index 000000000,000000000..524957bfc new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/README.md @@@ -1,0 -1,0 +1,71 @@@ ++itoa ++==== ++ ++[![Build Status](https://api.travis-ci.org/dtolnay/itoa.svg?branch=master)](https://travis-ci.org/dtolnay/itoa) ++[![Latest Version](https://img.shields.io/crates/v/itoa.svg)](https://crates.io/crates/itoa) ++ ++This crate provides fast functions for printing integer primitives to an ++[`io::Write`](https://doc.rust-lang.org/std/io/trait.Write.html). The ++implementation comes straight from ++[libcore](https://github.com/rust-lang/rust/blob/b8214dc6c6fc20d0a660fb5700dca9ebf51ebe89/src/libcore/fmt/num.rs#L201-L254) ++but avoids the performance penalty of going through ++[`fmt::Formatter`](https://doc.rust-lang.org/std/fmt/struct.Formatter.html). ++ ++See also [`dtoa`](https://github.com/dtolnay/dtoa) for printing floating point ++primitives. ++ ++## Performance (lower is better) ++ ++![performance](https://raw.githubusercontent.com/dtolnay/itoa/master/performance.png) ++ ++## Functions ++ ++```rust ++extern crate itoa; ++ ++// write to a vector or other io::Write ++let mut buf = Vec::new(); ++itoa::write(&mut buf, 128u64)?; ++println!("{:?}", buf); ++ ++// write to a stack buffer ++let mut bytes = [b'\0'; 20]; ++let n = itoa::write(&mut bytes[..], 128u64)?; ++println!("{:?}", &bytes[..n]); ++``` ++ ++The function signature is: ++ ++```rust ++fn write(writer: W, value: V) -> io::Result ++``` ++ ++where `itoa::Integer` is implemented for `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, ++`i64`, `u64`, `i128`, `u128`, `isize` and `usize`. 128-bit integer support is ++only available with the nightly compiler when the `i128` feature is enabled for ++this crate. The return value gives the number of bytes written. ++ ++## Dependency ++ ++Itoa is available on [crates.io](https://crates.io/crates/itoa). Use the ++following in `Cargo.toml`: ++ ++```toml ++[dependencies] ++itoa = "0.3" ++``` ++ ++## 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 itoa by you, as defined in the Apache-2.0 license, shall be ++dual licensed as above, without any additional terms or conditions. diff --cc vendor/itoa-0.3.4/benches/bench.rs index 000000000,000000000..815b5a367 new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/benches/bench.rs @@@ -1,0 -1,0 +1,68 @@@ ++#![cfg_attr(feature = "i128", feature(i128_type, i128))] ++ ++#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))] ++ ++#![feature(test)] ++#![allow(non_snake_case)] ++ ++extern crate itoa; ++extern crate test; ++ ++macro_rules! benches { ++ ( ++ $( ++ $(#[$attr:meta])* ++ $name:ident($value:expr) ++ ),* ++ ) => { ++ mod bench_itoa { ++ use test::{Bencher, black_box}; ++ $( ++ $(#[$attr])* ++ #[bench] ++ fn $name(b: &mut Bencher) { ++ use itoa; ++ ++ let mut buf = Vec::with_capacity(40); ++ ++ b.iter(|| { ++ buf.clear(); ++ itoa::write(&mut buf, black_box($value)).unwrap() ++ }); ++ } ++ )* ++ } ++ ++ mod bench_fmt { ++ use test::{Bencher, black_box}; ++ $( ++ $(#[$attr])* ++ #[bench] ++ fn $name(b: &mut Bencher) { ++ use std::io::Write; ++ ++ let mut buf = Vec::with_capacity(40); ++ ++ b.iter(|| { ++ buf.clear(); ++ write!(&mut buf, "{}", black_box($value)).unwrap() ++ }); ++ } ++ )* ++ } ++ } ++} ++ ++benches!{ ++ bench_u64_0(0u64), ++ bench_u64_half(::max_value() as u64), ++ bench_u64_max(::max_value()), ++ ++ bench_i16_0(0i16), ++ bench_i16_min(::min_value()), ++ ++ #[cfg(feature = "i128")] ++ bench_u128_0(0u128), ++ #[cfg(feature = "i128")] ++ bench_u128_max(::max_value()) ++} diff --cc vendor/itoa-0.3.4/src/lib.rs index 000000000,000000000..722847f5d new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/src/lib.rs @@@ -1,0 -1,0 +1,196 @@@ ++// Copyright 2016 Itoa Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++#![doc(html_root_url = "https://docs.rs/itoa/0.3.4")] ++ ++#![cfg_attr(feature = "i128", feature(i128_type, i128))] ++ ++#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless, unreadable_literal))] ++ ++#[cfg(feature = "i128")] ++mod udiv128; ++ ++use std::{io, mem, ptr, slice}; ++ ++#[inline] ++pub fn write(wr: W, value: V) -> io::Result { ++ value.write(wr) ++} ++ ++pub trait Integer { ++ fn write(self, W) -> io::Result; ++} ++ ++trait IntegerPrivate { ++ fn write_to(self, buf: &mut [u8; MAX_LEN]) -> &[u8]; ++} ++ ++const DEC_DIGITS_LUT: &'static[u8] = ++ b"0001020304050607080910111213141516171819\ ++ 2021222324252627282930313233343536373839\ ++ 4041424344454647484950515253545556575859\ ++ 6061626364656667686970717273747576777879\ ++ 8081828384858687888990919293949596979899"; ++ ++const MAX_LEN: usize = 40; // i128::MIN (including minus sign) ++ ++// Adaptation of the original implementation at ++// https://github.com/rust-lang/rust/blob/b8214dc6c6fc20d0a660fb5700dca9ebf51ebe89/src/libcore/fmt/num.rs#L188-L266 ++macro_rules! impl_Integer { ++ ($($t:ident),* as $conv_fn:ident) => {$( ++ impl Integer for $t { ++ fn write(self, mut wr: W) -> io::Result { ++ let mut buf = unsafe { mem::uninitialized() }; ++ let bytes = self.write_to(&mut buf); ++ try!(wr.write_all(bytes)); ++ Ok(bytes.len()) ++ } ++ } ++ ++ impl IntegerPrivate for $t { ++ #[allow(unused_comparisons)] ++ fn write_to(self, buf: &mut [u8; MAX_LEN]) -> &[u8] { ++ let is_nonnegative = self >= 0; ++ let mut n = if is_nonnegative { ++ self as $conv_fn ++ } else { ++ // convert the negative num to positive by summing 1 to it's 2 complement ++ (!(self as $conv_fn)).wrapping_add(1) ++ }; ++ let mut curr = buf.len() as isize; ++ let buf_ptr = buf.as_mut_ptr(); ++ let lut_ptr = DEC_DIGITS_LUT.as_ptr(); ++ ++ unsafe { ++ // need at least 16 bits for the 4-characters-at-a-time to work. ++ if mem::size_of::<$t>() >= 2 { ++ // eagerly decode 4 characters at a time ++ while n >= 10000 { ++ let rem = (n % 10000) as isize; ++ n /= 10000; ++ ++ let d1 = (rem / 100) << 1; ++ let d2 = (rem % 100) << 1; ++ curr -= 4; ++ ptr::copy_nonoverlapping(lut_ptr.offset(d1), buf_ptr.offset(curr), 2); ++ ptr::copy_nonoverlapping(lut_ptr.offset(d2), buf_ptr.offset(curr + 2), 2); ++ } ++ } ++ ++ // if we reach here numbers are <= 9999, so at most 4 chars long ++ let mut n = n as isize; // possibly reduce 64bit math ++ ++ // decode 2 more chars, if > 2 chars ++ if n >= 100 { ++ let d1 = (n % 100) << 1; ++ n /= 100; ++ curr -= 2; ++ ptr::copy_nonoverlapping(lut_ptr.offset(d1), buf_ptr.offset(curr), 2); ++ } ++ ++ // decode last 1 or 2 chars ++ if n < 10 { ++ curr -= 1; ++ *buf_ptr.offset(curr) = (n as u8) + b'0'; ++ } else { ++ let d1 = n << 1; ++ curr -= 2; ++ ptr::copy_nonoverlapping(lut_ptr.offset(d1), buf_ptr.offset(curr), 2); ++ } ++ ++ if !is_nonnegative { ++ curr -= 1; ++ *buf_ptr.offset(curr) = b'-'; ++ } ++ } ++ ++ let len = buf.len() - curr as usize; ++ unsafe { slice::from_raw_parts(buf_ptr.offset(curr), len) } ++ } ++ } ++ )*}; ++} ++ ++impl_Integer!(i8, u8, i16, u16, i32, u32 as u32); ++impl_Integer!(i64, u64 as u64); ++#[cfg(target_pointer_width = "16")] ++impl_Integer!(isize, usize as u16); ++#[cfg(target_pointer_width = "32")] ++impl_Integer!(isize, usize as u32); ++#[cfg(target_pointer_width = "64")] ++impl_Integer!(isize, usize as u64); ++ ++#[cfg(all(feature = "i128"))] ++macro_rules! impl_Integer128 { ++ ($($t:ident),*) => {$( ++ impl Integer for $t { ++ fn write(self, mut wr: W) -> io::Result { ++ let mut buf = unsafe { mem::uninitialized() }; ++ let bytes = self.write_to(&mut buf); ++ try!(wr.write_all(bytes)); ++ Ok(bytes.len()) ++ } ++ } ++ ++ impl IntegerPrivate for $t { ++ #[allow(unused_comparisons)] ++ fn write_to(self, buf: &mut [u8; MAX_LEN]) -> &[u8] { ++ let is_nonnegative = self >= 0; ++ let n = if is_nonnegative { ++ self as u128 ++ } else { ++ // convert the negative num to positive by summing 1 to it's 2 complement ++ (!(self as u128)).wrapping_add(1) ++ }; ++ let mut curr = buf.len() as isize; ++ let buf_ptr = buf.as_mut_ptr(); ++ ++ unsafe { ++ // Divide by 10^19 which is the highest power less than 2^64. ++ let (n, rem) = udiv128::udivmod_1e19(n); ++ curr -= rem.write_to(buf).len() as isize; ++ ++ if n != 0 { ++ // Memset the base10 leading zeros of rem. ++ let target = buf.len() as isize - 19; ++ ptr::write_bytes(buf_ptr.offset(target), b'0', (curr - target) as usize); ++ curr = target; ++ ++ // Divide by 10^19 again. ++ let (n, rem) = udiv128::udivmod_1e19(n); ++ let buf2 = buf_ptr.offset(curr - buf.len() as isize) as *mut _; ++ curr -= rem.write_to(&mut *buf2).len() as isize; ++ ++ if n != 0 { ++ // Memset the leading zeros. ++ let target = buf.len() as isize - 38; ++ ptr::write_bytes(buf_ptr.offset(target), b'0', (curr - target) as usize); ++ curr = target; ++ ++ // There is at most one digit left ++ // because u128::max / 10^19 / 10^19 is 3. ++ curr -= 1; ++ *buf_ptr.offset(curr) = (n as u8) + b'0'; ++ } ++ } ++ ++ if !is_nonnegative { ++ curr -= 1; ++ *buf_ptr.offset(curr) = b'-'; ++ } ++ ++ let len = buf.len() - curr as usize; ++ slice::from_raw_parts(buf_ptr.offset(curr), len) ++ } ++ } ++ } ++ )*}; ++} ++ ++#[cfg(all(feature = "i128"))] ++impl_Integer128!(i128, u128); diff --cc vendor/itoa-0.3.4/src/udiv128.rs index 000000000,000000000..24233c68c new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/src/udiv128.rs @@@ -1,0 -1,0 +1,62 @@@ ++// Copyright 2009-2016 compiler-builtins Developers ++// ++// The compiler-builtins crate is dual licensed under both the University of ++// Illinois "BSD-Like" license and the MIT license. As a user of this code you may ++// choose to use it under either license. As a contributor, you agree to allow ++// your code to be used under both. ++// ++// Full text of the relevant licenses is found here: ++// https://github.com/rust-lang-nursery/compiler-builtins/blob/master/LICENSE.TXT ++// ++// ++// ++// The following code is based on Rust’s [compiler-builtins crate] ++// (https://github.com/rust-lang-nursery/compiler-builtins) which ++// provides runtime functions for the Rust programs. The Rust ++// compiler will automatically link your programs against this crate. ++// ++// We copied the implementation of '__udivmodti4()' which is an intrinsic ++// implementing division with remainder for architectures without 128-bit integer support. ++// We have done this two reasons, to work around [bad optimization by LLVM] ++// (https://github.com/rust-lang/rust/issues/44545) and to allow function ++// inlining which doesn’t happen with the intrinsic. ++ ++pub fn udivmod_1e19(n: u128) -> (u128, u64) { ++ let d = 10_000_000_000_000_000_000_u64; // 10^19 ++ ++ let high = (n >> 64) as u64; ++ if high == 0 { ++ let low = n as u64; ++ return ((low / d) as u128, low % d); ++ } ++ ++ let sr = 65 - high.leading_zeros(); ++ ++ // 2 <= sr <= 65 ++ let mut q: u128 = n << (128 - sr); ++ let mut r: u128 = n >> sr; ++ let mut carry: u64 = 0; ++ ++ // Don't use a range because they may generate references to memcpy in unoptimized code ++ // ++ // Loop invariants: r < d; carry is 0 or 1 ++ let mut i = 0; ++ while i < sr { ++ i += 1; ++ ++ // r:q = ((r:q) << 1) | carry ++ r = (r << 1) | (q >> 127); ++ q = (q << 1) | carry as u128; ++ ++ // carry = 0 ++ // if r >= d { ++ // r -= d; ++ // carry = 1; ++ // } ++ let s = (d as u128).wrapping_sub(r).wrapping_sub(1) as i128 >> 127; ++ carry = (s & 1) as u64; ++ r -= (d as u128) & s as u128; ++ } ++ ++ ((q << 1) | carry as u128, r as u64) ++} diff --cc vendor/itoa-0.3.4/tests/test.rs index 000000000,000000000..a3602932a new file mode 100644 --- /dev/null +++ b/vendor/itoa-0.3.4/tests/test.rs @@@ -1,0 -1,0 +1,43 @@@ ++#![cfg_attr(feature = "i128", feature(i128_type, i128))] ++ ++#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless, string_lit_as_bytes))] ++ ++#![allow(non_snake_case)] ++ ++extern crate itoa; ++ ++macro_rules! test { ++ ( ++ $( ++ $(#[$attr:meta])* ++ $name:ident($value:expr, $expected:expr) ++ ),* ++ ) => { ++ $( ++ $(#[$attr])* ++ #[test] ++ fn $name() { ++ let mut buf = [b'\0'; 40]; ++ let len = itoa::write(&mut buf[..], $value).unwrap(); ++ assert_eq!(&buf[0..len], $expected.as_bytes()); ++ } ++ )* ++ } ++} ++ ++test!{ ++ test_u64_0(0u64, "0"), ++ test_u64_half(::max_value() as u64, "4294967295"), ++ test_u64_max(::max_value(), "18446744073709551615"), ++ test_i64_min(::min_value(), "-9223372036854775808"), ++ ++ test_i16_0(0i16, "0"), ++ test_i16_min(::min_value(), "-32768"), ++ ++ #[cfg(feature = "i128")] ++ test_u128_0(0u128, "0"), ++ #[cfg(feature = "i128")] ++ test_u128_max(::max_value(), "340282366920938463463374607431768211455"), ++ #[cfg(feature = "i128")] ++ test_i128_min(::min_value(), "-170141183460469231731687303715884105728") ++} diff --cc vendor/lazy_static-0.2.9/.cargo-checksum.json index 000000000,000000000..a934204d7 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"c9e5e58fa1a4c3b915a561a78a22ee0cac6ab97dca2504428bc1cb074375f8d5"} diff --cc vendor/lazy_static-0.2.9/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/.cargo-ok diff --cc vendor/lazy_static-0.2.9/.travis.yml index 000000000,000000000..f0dc1f304 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/.travis.yml @@@ -1,0 -1,0 +1,27 @@@ ++language: rust ++rust: ++- nightly ++- beta ++- stable ++before_script: ++- | ++ pip install 'travis-cargo<0.2' --user && ++ export PATH=`python -m site --user-base`/bin:$PATH ++script: ++- | ++ travis-cargo build && ++ travis-cargo test && ++ travis-cargo bench && ++ travis-cargo --only nightly build -- --features spin_no_std && ++ travis-cargo --only nightly test -- --features spin_no_std && ++ travis-cargo --only nightly bench -- --features spin_no_std && ++ travis-cargo --only stable doc ++after_success: ++- travis-cargo --only stable doc-upload ++env: ++ global: ++ - TRAVIS_CARGO_NIGHTLY_FEATURE=nightly ++ - secure: YXu24LptjeYirjWYjWGsMT2m3mB7LvQATE6TVo7VEUXv8GYoy2ORIHD83PeImxC93MmZ01QeUezRzuCW51ZcK92VnNSBttlF60SvIX18VsJrV92tsAhievFstqYQ+fB8DIuQ8noU0jPz7GpI+R9dlTRSImAqWOnVIghA+Wzz7Js= ++os: ++ - linux ++ - osx diff --cc vendor/lazy_static-0.2.9/Cargo.toml index 000000000,000000000..8a8e73983 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/Cargo.toml @@@ -1,0 -1,0 +1,35 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "lazy_static" ++version = "0.2.9" ++authors = ["Marvin Löbel "] ++description = "A macro for declaring lazily evaluated statics in Rust." ++documentation = "https://docs.rs/lazy_static" ++readme = "README.md" ++keywords = ["macro", "lazy", "static"] ++categories = ["no-std", "rust-patterns"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/rust-lang-nursery/lazy-static.rs" ++[dependencies.spin] ++version = "0.4" ++optional = true ++ ++[features] ++spin_no_std = ["nightly", "spin"] ++nightly = [] ++[badges.appveyor] ++repository = "rust-lang-nursery/lazy-static.rs" ++ ++[badges.travis-ci] ++repository = "rust-lang-nursery/lazy-static.rs" diff --cc vendor/lazy_static-0.2.9/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/lazy_static-0.2.9/LICENSE-MIT index 000000000,000000000..25597d583 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++Copyright (c) 2010 The Rust Project Developers ++ ++Permission is hereby granted, free of charge, to any ++person obtaining a copy of this software and associated ++documentation files (the "Software"), to deal in the ++Software without restriction, including without ++limitation the rights to use, copy, modify, merge, ++publish, distribute, sublicense, and/or sell copies of ++the Software, and to permit persons to whom the Software ++is furnished to do so, subject to the following ++conditions: ++ ++The above copyright notice and this permission notice ++shall be included in all copies or substantial portions ++of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ++ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED ++TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A ++PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT ++SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY ++CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR ++IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ++DEALINGS IN THE SOFTWARE. diff --cc vendor/lazy_static-0.2.9/README.md index 000000000,000000000..ad5380ee1 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/README.md @@@ -1,0 -1,0 +1,69 @@@ ++lazy-static.rs ++============== ++ ++A macro for declaring lazily evaluated statics in Rust. ++ ++Using this macro, it is possible to have `static`s that require code to be ++executed at runtime in order to be initialized. ++This includes anything requiring heap allocations, like vectors or hash maps, ++as well as anything that requires non-const function calls to be computed. ++ ++[![Travis-CI Status](https://travis-ci.org/rust-lang-nursery/lazy-static.rs.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/lazy-static.rs) ++ ++# Getting Started ++ ++[lazy-static.rs is available on crates.io](https://crates.io/crates/lazy_static). ++It is recommended to look there for the newest released version, as well as links to the newest builds of the docs. ++ ++At the point of the last update of this README, the latest published version could be used like this: ++ ++Add the following dependency to your Cargo manifest... ++ ++```toml ++[dependencies] ++lazy_static = "0.2" ++``` ++ ++...and see the [docs](https://docs.rs/lazy_static) for how to use it. ++ ++# Example ++ ++```rust ++#[macro_use] ++extern crate lazy_static; ++ ++use std::collections::HashMap; ++ ++lazy_static! { ++ static ref HASHMAP: HashMap = { ++ let mut m = HashMap::new(); ++ m.insert(0, "foo"); ++ m.insert(1, "bar"); ++ m.insert(2, "baz"); ++ m ++ }; ++} ++ ++fn main() { ++ // First access to `HASHMAP` initializes it ++ println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap()); ++ ++ // Any further access to `HASHMAP` just returns the computed value ++ println!("The entry for `1` is \"{}\".", HASHMAP.get(&1).unwrap()); ++} ++``` ++ ++## License ++ ++Licensed under either of ++ ++ * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) ++ * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) ++ ++at your option. ++ ++### Contribution ++ ++Unless you explicitly state otherwise, any contribution intentionally submitted ++for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any ++additional terms or conditions. diff --cc vendor/lazy_static-0.2.9/appveyor.yml index 000000000,000000000..69b720e65 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/appveyor.yml @@@ -1,0 -1,0 +1,51 @@@ ++environment: ++ global: ++ PROJECT_NAME: lazy_static ++ matrix: ++ # Stable channel ++ - TARGET: i686-pc-windows-gnu ++ CHANNEL: stable ++ - TARGET: i686-pc-windows-msvc ++ CHANNEL: stable ++ - TARGET: x86_64-pc-windows-gnu ++ CHANNEL: stable ++ - TARGET: x86_64-pc-windows-msvc ++ CHANNEL: stable ++ # Beta channel ++ - TARGET: i686-pc-windows-gnu ++ CHANNEL: beta ++ - TARGET: i686-pc-windows-msvc ++ CHANNEL: beta ++ - TARGET: x86_64-pc-windows-gnu ++ CHANNEL: beta ++ - TARGET: x86_64-pc-windows-msvc ++ CHANNEL: beta ++ # Nightly channel ++ - TARGET: i686-pc-windows-gnu ++ CHANNEL: nightly ++ - TARGET: i686-pc-windows-msvc ++ CHANNEL: nightly ++ - TARGET: x86_64-pc-windows-gnu ++ CHANNEL: nightly ++ - TARGET: x86_64-pc-windows-msvc ++ CHANNEL: nightly ++ ++# Install Rust and Cargo ++# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml) ++install: ++ - ps: Start-FileDownload "https://static.rust-lang.org/dist/channel-rust-stable" ++ - ps: $env:RUST_VERSION = Get-Content channel-rust-stable | select -first 1 | %{$_.split('-')[1]} ++ - if NOT "%CHANNEL%" == "stable" set RUST_VERSION=%CHANNEL% ++ - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:RUST_VERSION}-${env:TARGET}.exe" ++ - rust-%RUST_VERSION%-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" ++ - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin ++ - if "%TARGET%" == "i686-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw32\bin ++ - if "%TARGET%" == "x86_64-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw64\bin ++ - rustc -V ++ - cargo -V ++ ++build: false ++ ++test_script: ++ - cargo build --verbose ++ - cargo test diff --cc vendor/lazy_static-0.2.9/src/core_lazy.rs index 000000000,000000000..34a942c44 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/src/core_lazy.rs @@@ -1,0 -1,0 +1,35 @@@ ++// Copyright 2016 lazy-static.rs Developers ++// ++// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be ++// copied, modified, or distributed except according to those terms. ++ ++extern crate spin; ++ ++use self::spin::Once; ++ ++pub struct Lazy(Once); ++ ++impl Lazy { ++ #[inline(always)] ++ pub const fn new() -> Self { ++ Lazy(Once::new()) ++ } ++ ++ #[inline(always)] ++ pub fn get(&'static self, builder: F) -> &T ++ where F: FnOnce() -> T ++ { ++ self.0.call_once(builder) ++ } ++} ++ ++#[macro_export] ++#[allow_internal_unstable] ++#[doc(hidden)] ++macro_rules! __lazy_static_create { ++ ($NAME:ident, $T:ty) => { ++ static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::new(); ++ } ++} diff --cc vendor/lazy_static-0.2.9/src/lazy.rs index 000000000,000000000..43b7b8656 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/src/lazy.rs @@@ -1,0 -1,0 +1,40 @@@ ++// Copyright 2016 lazy-static.rs Developers ++// ++// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be ++// copied, modified, or distributed except according to those terms. ++ ++extern crate std; ++ ++use self::std::prelude::v1::*; ++use self::std::sync::Once; ++ ++pub struct Lazy(pub *const T, pub Once); ++ ++impl Lazy { ++ #[inline(always)] ++ pub fn get(&'static mut self, f: F) -> &T ++ where F: FnOnce() -> T ++ { ++ unsafe { ++ let r = &mut self.0; ++ self.1.call_once(|| { ++ *r = Box::into_raw(Box::new(f())); ++ }); ++ ++ &*self.0 ++ } ++ } ++} ++ ++unsafe impl Sync for Lazy {} ++ ++#[macro_export] ++#[doc(hidden)] ++macro_rules! __lazy_static_create { ++ ($NAME:ident, $T:ty) => { ++ use std::sync::ONCE_INIT; ++ static mut $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy(0 as *const $T, ONCE_INIT); ++ } ++} diff --cc vendor/lazy_static-0.2.9/src/lib.rs index 000000000,000000000..51d66efc0 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/src/lib.rs @@@ -1,0 -1,0 +1,241 @@@ ++// Copyright 2016 lazy-static.rs Developers ++// ++// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be ++// copied, modified, or distributed except according to those terms. ++ ++/*! ++A macro for declaring lazily evaluated statics. ++ ++Using this macro, it is possible to have `static`s that require code to be ++executed at runtime in order to be initialized. ++This includes anything requiring heap allocations, like vectors or hash maps, ++as well as anything that requires function calls to be computed. ++ ++# Syntax ++ ++```ignore ++lazy_static! { ++ [pub] static ref NAME_1: TYPE_1 = EXPR_1; ++ [pub] static ref NAME_2: TYPE_2 = EXPR_2; ++ ... ++ [pub] static ref NAME_N: TYPE_N = EXPR_N; ++} ++``` ++ ++Attributes (including doc comments) are supported as well: ++ ++```rust ++# #[macro_use] ++# extern crate lazy_static; ++# fn main() { ++lazy_static! { ++ /// This is an example for using doc comment attributes ++ static ref EXAMPLE: u8 = 42; ++} ++# } ++``` ++ ++# Semantics ++ ++For a given `static ref NAME: TYPE = EXPR;`, the macro generates a unique type that ++implements `Deref` and stores it in a static with name `NAME`. (Attributes end up ++attaching to this type.) ++ ++On first deref, `EXPR` gets evaluated and stored internally, such that all further derefs ++can return a reference to the same object. Note that this can lead to deadlocks ++if you have multiple lazy statics that depend on each other in their initialization. ++ ++Apart from the lazy initialization, the resulting "static ref" variables ++have generally the same properties as regular "static" variables: ++ ++- Any type in them needs to fulfill the `Sync` trait. ++- If the type has a destructor, then it will not run when the process exits. ++ ++# Example ++ ++Using the macro: ++ ++```rust ++#[macro_use] ++extern crate lazy_static; ++ ++use std::collections::HashMap; ++ ++lazy_static! { ++ static ref HASHMAP: HashMap = { ++ let mut m = HashMap::new(); ++ m.insert(0, "foo"); ++ m.insert(1, "bar"); ++ m.insert(2, "baz"); ++ m ++ }; ++ static ref COUNT: usize = HASHMAP.len(); ++ static ref NUMBER: u32 = times_two(21); ++} ++ ++fn times_two(n: u32) -> u32 { n * 2 } ++ ++fn main() { ++ println!("The map has {} entries.", *COUNT); ++ println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap()); ++ println!("A expensive calculation on a static results in: {}.", *NUMBER); ++} ++``` ++ ++# Implementation details ++ ++The `Deref` implementation uses a hidden static variable that is guarded by a atomic check on each access. On stable Rust, the macro may need to allocate each static on the heap. ++ ++*/ ++ ++#![cfg_attr(feature="nightly", feature(const_fn, allow_internal_unstable, core_intrinsics, const_unsafe_cell_new))] ++ ++#![doc(html_root_url = "https://docs.rs/lazy_static/0.2.8")] ++#![no_std] ++ ++#[cfg(not(feature="nightly"))] ++#[doc(hidden)] ++pub mod lazy; ++ ++#[cfg(all(feature="nightly", not(feature="spin_no_std")))] ++#[path="nightly_lazy.rs"] ++#[doc(hidden)] ++pub mod lazy; ++ ++#[cfg(all(feature="nightly", feature="spin_no_std"))] ++#[path="core_lazy.rs"] ++#[doc(hidden)] ++pub mod lazy; ++ ++#[doc(hidden)] ++pub use core::ops::Deref as __Deref; ++ ++#[macro_export] ++#[cfg_attr(feature="nightly", allow_internal_unstable)] ++#[doc(hidden)] ++macro_rules! __lazy_static_internal { ++ ($(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { ++ __lazy_static_internal!(@PRIV, $(#[$attr])* static ref $N : $T = $e; $($t)*); ++ }; ++ ($(#[$attr:meta])* pub(in $pub_in:path) static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { ++ __lazy_static_internal!(@PUB_IN, $pub_in, $(#[$attr])* static ref $N : $T = $e; $($t)*); ++ }; ++ ($(#[$attr:meta])* pub static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { ++ __lazy_static_internal!(@PUB, $(#[$attr])* static ref $N : $T = $e; $($t)*); ++ }; ++ (@PUB_IN, $pub_in:path, $(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { ++ __lazy_static_internal!(@MAKE TY, PUB_IN, $pub_in, $(#[$attr])*, $N); ++ __lazy_static_internal!(@TAIL, $N : $T = $e); ++ __lazy_static_internal!($($t)*); ++ }; ++ (@$VIS:ident, $(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { ++ __lazy_static_internal!(@MAKE TY, $VIS, $(#[$attr])*, $N); ++ __lazy_static_internal!(@TAIL, $N : $T = $e); ++ __lazy_static_internal!($($t)*); ++ }; ++ (@TAIL, $N:ident : $T:ty = $e:expr) => { ++ impl $crate::__Deref for $N { ++ type Target = $T; ++ #[allow(unsafe_code)] ++ fn deref(&self) -> &$T { ++ unsafe { ++ #[inline(always)] ++ fn __static_ref_initialize() -> $T { $e } ++ ++ #[inline(always)] ++ unsafe fn __stability() -> &'static $T { ++ __lazy_static_create!(LAZY, $T); ++ LAZY.get(__static_ref_initialize) ++ } ++ __stability() ++ } ++ } ++ } ++ impl $crate::LazyStatic for $N { ++ fn initialize(lazy: &Self) { ++ let _ = &**lazy; ++ } ++ } ++ }; ++ (@MAKE TY, PUB, $(#[$attr:meta])*, $N:ident) => { ++ #[allow(missing_copy_implementations)] ++ #[allow(non_camel_case_types)] ++ #[allow(dead_code)] ++ $(#[$attr])* ++ pub struct $N {__private_field: ()} ++ #[doc(hidden)] ++ pub static $N: $N = $N {__private_field: ()}; ++ }; ++ (@MAKE TY, PUB_IN, $pub_in:path, $(#[$attr:meta])*, $N:ident) => { ++ #[allow(missing_copy_implementations)] ++ #[allow(non_camel_case_types)] ++ #[allow(dead_code)] ++ $(#[$attr])* ++ pub(in $pub_in) struct $N {__private_field: ()} ++ #[doc(hidden)] ++ pub(in $pub_in) static $N: $N = $N {__private_field: ()}; ++ }; ++ (@MAKE TY, PRIV, $(#[$attr:meta])*, $N:ident) => { ++ #[allow(missing_copy_implementations)] ++ #[allow(non_camel_case_types)] ++ #[allow(dead_code)] ++ $(#[$attr])* ++ struct $N {__private_field: ()} ++ #[doc(hidden)] ++ static $N: $N = $N {__private_field: ()}; ++ }; ++ () => () ++} ++ ++#[macro_export] ++#[cfg_attr(feature="nightly", allow_internal_unstable)] ++macro_rules! lazy_static { ++ ($(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { ++ __lazy_static_internal!(@PRIV, $(#[$attr])* static ref $N : $T = $e; $($t)*); ++ }; ++ ($(#[$attr:meta])* pub (in $pub_in:path) static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { ++ __lazy_static_internal!(@PUB_IN, $pub_in, $(#[$attr])* static ref $N : $T = $e; $($t)*); ++ }; ++ ($(#[$attr:meta])* pub static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => { ++ __lazy_static_internal!(@PUB, $(#[$attr])* static ref $N : $T = $e; $($t)*); ++ }; ++ () => () ++} ++ ++/// Support trait for enabling a few common operation on lazy static values. ++/// ++/// This is implemented by each defined lazy static, and ++/// used by the free functions in this crate. ++pub trait LazyStatic { ++ #[doc(hidden)] ++ fn initialize(lazy: &Self); ++} ++ ++/// Takes a shared reference to a lazy static and initializes ++/// it if it has not been already. ++/// ++/// This can be used to control the initialization point of a lazy static. ++/// ++/// Example: ++/// ++/// ```rust ++/// #[macro_use] ++/// extern crate lazy_static; ++/// ++/// lazy_static! { ++/// static ref BUFFER: Vec = (0..65537).collect(); ++/// } ++/// ++/// fn main() { ++/// lazy_static::initialize(&BUFFER); ++/// ++/// // ... ++/// work_with_initialized_data(&BUFFER); ++/// } ++/// # fn work_with_initialized_data(_: &[u8]) {} ++/// ``` ++pub fn initialize(lazy: &T) { ++ LazyStatic::initialize(lazy); ++} diff --cc vendor/lazy_static-0.2.9/src/nightly_lazy.rs index 000000000,000000000..ee2c2bcb8 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/src/nightly_lazy.rs @@@ -1,0 -1,0 +1,48 @@@ ++// Copyright 2016 lazy-static.rs Developers ++// ++// Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be ++// copied, modified, or distributed except according to those terms. ++ ++extern crate std; ++ ++use self::std::prelude::v1::*; ++use self::std::cell::UnsafeCell; ++use self::std::sync::{Once, ONCE_INIT}; ++ ++pub struct Lazy(UnsafeCell>, Once); ++ ++impl Lazy { ++ #[inline(always)] ++ pub const fn new() -> Self { ++ Lazy(UnsafeCell::new(None), ONCE_INIT) ++ } ++ ++ #[inline(always)] ++ pub fn get(&'static self, f: F) -> &T ++ where F: FnOnce() -> T ++ { ++ unsafe { ++ self.1.call_once(|| { ++ *self.0.get() = Some(f()); ++ }); ++ ++ match *self.0.get() { ++ Some(ref x) => x, ++ None => std::intrinsics::unreachable(), ++ } ++ } ++ } ++} ++ ++unsafe impl Sync for Lazy {} ++ ++#[macro_export] ++#[allow_internal_unstable] ++#[doc(hidden)] ++macro_rules! __lazy_static_create { ++ ($NAME:ident, $T:ty) => { ++ static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::new(); ++ } ++} diff --cc vendor/lazy_static-0.2.9/tests/no_std.rs index 000000000,000000000..b460e7932 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/tests/no_std.rs @@@ -1,0 -1,0 +1,21 @@@ ++#![cfg(feature="spin_no_std")] ++#![feature(const_fn)] ++ ++#![no_std] ++ ++#[macro_use] ++extern crate lazy_static; ++ ++lazy_static! { ++ /// Documentation! ++ pub static ref NUMBER: u32 = times_two(3); ++} ++ ++fn times_two(n: u32) -> u32 { ++ n * 2 ++} ++ ++#[test] ++fn test_basic() { ++ assert_eq!(*NUMBER, 6); ++} diff --cc vendor/lazy_static-0.2.9/tests/test.rs index 000000000,000000000..6f36cc326 new file mode 100644 --- /dev/null +++ b/vendor/lazy_static-0.2.9/tests/test.rs @@@ -1,0 -1,0 +1,158 @@@ ++#![cfg_attr(feature="nightly", feature(const_fn))] ++ ++#[macro_use] ++extern crate lazy_static; ++use std::collections::HashMap; ++ ++lazy_static! { ++ /// Documentation! ++ pub static ref NUMBER: u32 = times_two(3); ++ ++ static ref ARRAY_BOXES: [Box; 3] = [Box::new(1), Box::new(2), Box::new(3)]; ++ ++ /// More documentation! ++ #[allow(unused_variables)] ++ #[derive(Copy, Clone, Debug)] ++ pub static ref STRING: String = "hello".to_string(); ++ ++ static ref HASHMAP: HashMap = { ++ let mut m = HashMap::new(); ++ m.insert(0, "abc"); ++ m.insert(1, "def"); ++ m.insert(2, "ghi"); ++ m ++ }; ++ ++ // This should not compile if the unsafe is removed. ++ static ref UNSAFE: u32 = unsafe { ++ std::mem::transmute::(-1) ++ }; ++ ++ // This *should* triggger warn(dead_code) by design. ++ static ref UNUSED: () = (); ++ ++} ++ ++lazy_static! { ++ static ref S1: &'static str = "a"; ++ static ref S2: &'static str = "b"; ++} ++lazy_static! { ++ static ref S3: String = [*S1, *S2].join(""); ++} ++ ++#[test] ++fn s3() { ++ assert_eq!(&*S3, "ab"); ++} ++ ++fn times_two(n: u32) -> u32 { ++ n * 2 ++} ++ ++#[test] ++fn test_basic() { ++ assert_eq!(&**STRING, "hello"); ++ assert_eq!(*NUMBER, 6); ++ assert!(HASHMAP.get(&1).is_some()); ++ assert!(HASHMAP.get(&3).is_none()); ++ assert_eq!(&*ARRAY_BOXES, &[Box::new(1), Box::new(2), Box::new(3)]); ++ assert_eq!(*UNSAFE, std::u32::MAX); ++} ++ ++#[test] ++fn test_repeat() { ++ assert_eq!(*NUMBER, 6); ++ assert_eq!(*NUMBER, 6); ++ assert_eq!(*NUMBER, 6); ++} ++ ++#[test] ++fn test_meta() { ++ // this would not compile if STRING were not marked #[derive(Copy, Clone)] ++ let copy_of_string = STRING; ++ // just to make sure it was copied ++ assert!(&STRING as *const _ != ©_of_string as *const _); ++ ++ // this would not compile if STRING were not marked #[derive(Debug)] ++ assert_eq!(format!("{:?}", STRING), "STRING { __private_field: () }".to_string()); ++} ++ ++mod visibility { ++ lazy_static! { ++ pub static ref FOO: Box = Box::new(0); ++ static ref BAR: Box = Box::new(98); ++ } ++ ++ #[test] ++ fn sub_test() { ++ assert_eq!(**FOO, 0); ++ assert_eq!(**BAR, 98); ++ } ++} ++ ++#[test] ++fn test_visibility() { ++ assert_eq!(*visibility::FOO, Box::new(0)); ++} ++ ++// This should not cause a warning about a missing Copy implementation ++lazy_static! { ++ pub static ref VAR: i32 = { 0 }; ++} ++ ++#[derive(Copy, Clone, Debug, PartialEq)] ++struct X; ++struct Once(X); ++const ONCE_INIT: Once = Once(X); ++static DATA: X = X; ++static ONCE: X = X; ++fn require_sync() -> X { X } ++fn transmute() -> X { X } ++fn __static_ref_initialize() -> X { X } ++fn test(_: Vec) -> X { X } ++ ++// All these names should not be shadowed ++lazy_static! { ++ static ref ITEM_NAME_TEST: X = { ++ test(vec![X, Once(X).0, ONCE_INIT.0, DATA, ONCE, ++ require_sync(), transmute(), ++ // Except this, which will sadly be shadowed by internals: ++ // __static_ref_initialize() ++ ]) ++ }; ++} ++ ++#[test] ++fn item_name_shadowing() { ++ assert_eq!(*ITEM_NAME_TEST, X); ++} ++ ++use std::sync::atomic::AtomicBool; ++use std::sync::atomic::ATOMIC_BOOL_INIT; ++use std::sync::atomic::Ordering::SeqCst; ++ ++static PRE_INIT_FLAG: AtomicBool = ATOMIC_BOOL_INIT; ++ ++lazy_static! { ++ static ref PRE_INIT: () = { ++ PRE_INIT_FLAG.store(true, SeqCst); ++ () ++ }; ++} ++ ++#[test] ++fn pre_init() { ++ assert_eq!(PRE_INIT_FLAG.load(SeqCst), false); ++ lazy_static::initialize(&PRE_INIT); ++ assert_eq!(PRE_INIT_FLAG.load(SeqCst), true); ++} ++ ++lazy_static! { ++ static ref LIFETIME_NAME: for<'a> fn(&'a u8) = { fn f(_: &u8) {} f }; ++} ++ ++#[test] ++fn lifetime_name() { ++ let _ = LIFETIME_NAME; ++} diff --cc vendor/libc-0.2.31/.cargo-checksum.json index 000000000,000000000..a3a49ec99 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"d1419b2939a0bc44b77feb34661583c7546b532b192feab36249ab584b86856c"} diff --cc vendor/libc-0.2.31/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/.cargo-ok diff --cc vendor/libc-0.2.31/.travis.yml index 000000000,000000000..978772867 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/.travis.yml @@@ -1,0 -1,0 +1,100 @@@ ++language: rust ++rust: stable ++sudo: required ++dist: trusty ++services: ++ - docker ++install: ++ - if [ -z "$NO_ADD" ]; then rustup target add $TARGET; fi ++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 ++env: ++ global: ++ secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps=" ++matrix: ++ include: ++ # 1.0.0 compat ++ - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 ++ rust: 1.0.0 ++ script: cargo build ++ install: ++ ++ # build documentation ++ - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 ++ rust: nightly ++ script: sh ci/dox.sh ++ ++ # stable compat ++ - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 ++ - env: TARGET=i686-unknown-linux-gnu ++ - os: osx ++ env: TARGET=x86_64-apple-darwin NO_ADD=1 ++ osx_image: xcode8.3 ++ - os: osx ++ env: TARGET=i686-apple-darwin ++ osx_image: xcode8.3 ++ - env: TARGET=arm-linux-androideabi ++ - env: TARGET=aarch64-linux-android ++ - env: TARGET=i686-linux-android ++ - env: TARGET=x86_64-linux-android ++ - env: TARGET=x86_64-unknown-linux-musl ++ - env: TARGET=i686-unknown-linux-musl ++ - env: TARGET=arm-unknown-linux-gnueabihf ++ - env: TARGET=aarch64-unknown-linux-gnu ++ - os: osx ++ osx_image: xcode8.2 ++ env: TARGET=i386-apple-ios ++ CARGO_TARGET_I386_APPLE_IOS_RUNNER=$HOME/runtest ++ RUSTFLAGS=-Clink-arg=-mios-simulator-version-min=7.0 ++ before_install: ++ rustc ./ci/ios/deploy_and_run_on_ios_simulator.rs -o $HOME/runtest ++ - os: osx ++ osx_image: xcode8.2 ++ env: TARGET=x86_64-apple-ios ++ CARGO_TARGET_X86_64_APPLE_IOS_RUNNER=$HOME/runtest ++ RUSTFLAGS=-Clink-arg=-mios-simulator-version-min=7.0 ++ before_install: ++ rustc ./ci/ios/deploy_and_run_on_ios_simulator.rs -o $HOME/runtest ++ - env: TARGET=x86_64-rumprun-netbsd ++ - env: TARGET=powerpc-unknown-linux-gnu ++ - env: TARGET=powerpc64-unknown-linux-gnu ++ - env: TARGET=mips-unknown-linux-musl ++ - env: TARGET=mipsel-unknown-linux-musl ++ - env: TARGET=mips64-unknown-linux-gnuabi64 ++ - env: TARGET=mips-unknown-linux-gnu ++ - env: TARGET=s390x-unknown-linux-gnu ++ - env: TARGET=asmjs-unknown-emscripten ++ - env: TARGET=wasm32-unknown-emscripten ++ ++ # beta ++ - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 ++ rust: beta ++ - os: osx ++ env: TARGET=x86_64-apple-darwin NO_ADD=1 ++ osx_image: xcode8.3 ++ rust: beta ++ ++ # nightly ++ - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 ++ rust: nightly ++ - os: osx ++ env: TARGET=x86_64-apple-darwin NO_ADD=1 ++ osx_image: xcode8.3 ++ rust: nightly ++ ++ # QEMU based targets that compile in an emulator ++ - env: TARGET=x86_64-unknown-freebsd ++ ++notifications: ++ email: ++ on_success: never ++ webhooks: https://buildbot.rust-lang.org/homu/travis diff --cc vendor/libc-0.2.31/Cargo.toml index 000000000,000000000..d317e6688 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/Cargo.toml @@@ -1,0 -1,0 +1,31 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "libc" ++version = "0.2.31" ++authors = ["The Rust Project Developers"] ++description = "A library for types and bindings to native C functions often found in libc or\nother common platform libraries.\n" ++homepage = "https://github.com/rust-lang/libc" ++documentation = "http://doc.rust-lang.org/libc" ++readme = "README.md" ++license = "MIT/Apache-2.0" ++repository = "https://github.com/rust-lang/libc" ++ ++[features] ++default = ["use_std"] ++use_std = [] ++[badges.appveyor] ++repository = "rust-lang-libs/libc" ++ ++[badges.travis-ci] ++repository = "rust-lang/libc" diff --cc vendor/libc-0.2.31/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/libc-0.2.31/LICENSE-MIT index 000000000,000000000..39d4bdb5a new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/libc-0.2.31/README.md index 000000000,000000000..7b2d778ea new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/README.md @@@ -1,0 -1,0 +1,156 @@@ ++libc ++==== ++ ++A Rust library with native bindings to the types and functions commonly found on ++various systems, including libc. ++ ++[![Build Status](https://travis-ci.org/rust-lang/libc.svg?branch=master)](https://travis-ci.org/rust-lang/libc) ++[![Build status](https://ci.appveyor.com/api/projects/status/github/rust-lang/libc?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/libc) ++ ++[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 test` ++ - Use the `skip_*()` functions in `build.rs` if you really need a workaround. ++2. Style checker ++ - `rustc ci/style.rs && ./style src` ++ ++### Releasing your change to crates.io ++ ++Now that you've done the amazing job of landing your new API or your new ++platform in this crate, the next step is to get that sweet, sweet usage from ++crates.io! The only next step is to bump the version of libc and then publish ++it. If you'd like to get a release out ASAP you can follow these steps: ++ ++1. Update the version number in `Cargo.toml`, you'll just be bumping the patch ++ version number. ++2. Run `cargo update` to regenerate the lockfile to encode your version bump in ++ the lock file. You may pull in some other updated dependencies, that's ok. ++3. Send a PR to this repository. It should [look like this][example], but it'd ++ also be nice to fill out the description with a small rationale for the ++ release (any rationale is ok though!) ++4. Once merged the release will be tagged and published by one of the libc crate ++ maintainers. ++ ++[example]: https://github.com/rust-lang/libc/pull/583 ++ ++## 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) ++ * `i386-apple-ios` ++ * `x86_64-apple-ios` ++ * [`i686-unknown-linux-gnu`](https://doc.rust-lang.org/libc/i686-unknown-linux-gnu/libc/) ++ * [`x86_64-unknown-linux-gnu`](https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu/libc/) ++ (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 --cc vendor/libc-0.2.31/appveyor.yml index 000000000,000000000..3121825b9 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/appveyor.yml @@@ -1,0 -1,0 +1,31 @@@ ++environment: ++ # When this was added there were revocation check failures when using the ++ # libcurl backend as libcurl checks by default, but rustup doesn't provide the ++ # switch to turn this off. Switch to Hyper which looks to not check for ++ # revocation by default like libcurl does. ++ RUSTUP_USE_HYPER: 1 ++ CARGO_HTTP_CHECK_REVOKE: false ++ matrix: ++ - TARGET: x86_64-pc-windows-gnu ++ MSYS2_BITS: 64 ++ - TARGET: i686-pc-windows-gnu ++ MSYS2_BITS: 32 ++ - TARGET: x86_64-pc-windows-msvc ++ - TARGET: i686-pc-windows-msvc ++install: ++ - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe ++ - rustup-init.exe -y --default-host %TARGET% ++ - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin ++ - if defined MSYS2_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS2_BITS%\bin ++ - rustc -V ++ - cargo -V ++ ++build: false ++ ++test_script: ++ - cargo test --target %TARGET% ++ - cargo test --manifest-path libc-test/Cargo.toml --target %TARGET% ++ ++cache: ++ - target ++ - C:\Users\appveyor\.cargo\registry diff --cc vendor/libc-0.2.31/ci/README.md index 000000000,000000000..13c7c8da5 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/README.md @@@ -1,0 -1,0 +1,203 @@@ ++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-` 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 --cc vendor/libc-0.2.31/ci/android-accept-licenses.sh index 000000000,000000000..8d8f60a5e new file mode 100755 --- /dev/null +++ b/vendor/libc-0.2.31/ci/android-accept-licenses.sh @@@ -1,0 -1,0 +1,15 @@@ ++#!/usr/bin/expect -f ++# ignore-license ++ ++set timeout 1800 ++set cmd [lindex $argv 0] ++set licenses [lindex $argv 1] ++ ++spawn {*}$cmd ++expect { ++ "Do you accept the license '*'*" { ++ exp_send "y\r" ++ exp_continue ++ } ++ eof ++} diff --cc vendor/libc-0.2.31/ci/android-install-ndk.sh index 000000000,000000000..873f6c52c new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/android-install-ndk.sh @@@ -1,0 -1,0 +1,37 @@@ ++#!/bin/sh ++# Copyright 2016 The Rust Project Developers. See the COPYRIGHT ++# file at the top-level directory of this distribution and at ++# http://rust-lang.org/COPYRIGHT. ++# ++# Licensed under the Apache License, Version 2.0 or the MIT license ++# , at your ++# option. This file may not be copied, modified, or distributed ++# except according to those terms. ++ ++set -ex ++ ++curl -O https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip ++unzip -q android-ndk-r15b-linux-x86_64.zip ++ ++case "$1" in ++ aarch64) ++ arch=arm64 ++ ;; ++ ++ i686) ++ arch=x86 ++ ;; ++ ++ *) ++ arch=$1 ++ ;; ++esac; ++ ++android-ndk-r15b/build/tools/make_standalone_toolchain.py \ ++ --unified-headers \ ++ --install-dir /android/ndk-$1 \ ++ --arch $arch \ ++ --api 24 ++ ++rm -rf ./android-ndk-r15b-linux-x86_64.zip ./android-ndk-r15b diff --cc vendor/libc-0.2.31/ci/android-install-sdk.sh index 000000000,000000000..d03b7623b new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/android-install-sdk.sh @@@ -1,0 -1,0 +1,57 @@@ ++#!/bin/sh ++# Copyright 2016 The Rust Project Developers. See the COPYRIGHT ++# file at the top-level directory of this distribution and at ++# http://rust-lang.org/COPYRIGHT. ++# ++# Licensed under the Apache License, Version 2.0 or the MIT license ++# , at your ++# option. This file may not be copied, modified, or distributed ++# except according to those terms. ++ ++set -ex ++ ++# Prep the SDK and emulator ++# ++# Note that the update process requires that we accept a bunch of licenses, and ++# we can't just pipe `yes` into it for some reason, so we take the same strategy ++# located in https://github.com/appunite/docker by just wrapping it in a script ++# which apparently magically accepts the licenses. ++ ++mkdir sdk ++curl https://dl.google.com/android/repository/tools_r25.2.5-linux.zip -O ++unzip -d sdk tools_r25.2.5-linux.zip ++ ++filter="platform-tools,android-24" ++ ++case "$1" in ++ arm | armv7) ++ abi=armeabi-v7a ++ ;; ++ ++ aarch64) ++ abi=arm64-v8a ++ ;; ++ ++ i686) ++ abi=x86 ++ ;; ++ ++ x86_64) ++ abi=x86_64 ++ ;; ++ ++ *) ++ echo "invalid arch: $1" ++ exit 1 ++ ;; ++esac; ++ ++filter="$filter,sys-img-$abi-android-24" ++ ++./android-accept-licenses.sh "android - update sdk -a --no-ui --filter $filter" ++ ++echo "no" | android create avd \ ++ --name $1 \ ++ --target android-24 \ ++ --abi $abi diff --cc vendor/libc-0.2.31/ci/android-sysimage.sh index 000000000,000000000..9611dfeb0 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/android-sysimage.sh @@@ -1,0 -1,0 +1,52 @@@ ++# Copyright 2017 The Rust Project Developers. See the COPYRIGHT ++# file at the top-level directory of this distribution and at ++# http://rust-lang.org/COPYRIGHT. ++# ++# Licensed under the Apache License, Version 2.0 or the MIT license ++# , at your ++# option. This file may not be copied, modified, or distributed ++# except according to those terms. ++ ++set -ex ++ ++URL=https://dl.google.com/android/repository/sys-img/android ++ ++main() { ++ local arch=$1 ++ local name=$2 ++ local dest=/system ++ local td=$(mktemp -d) ++ ++ apt-get install --no-install-recommends e2tools ++ ++ pushd $td ++ curl -O $URL/$name ++ unzip -q $name ++ ++ local system=$(find . -name system.img) ++ mkdir -p $dest/{bin,lib,lib64} ++ ++ # Extract android linker and libraries to /system ++ # This allows android executables to be run directly (or with qemu) ++ if [ $arch = "x86_64" -o $arch = "arm64" ]; then ++ e2cp -p $system:/bin/linker64 $dest/bin/ ++ e2cp -p $system:/lib64/libdl.so $dest/lib64/ ++ e2cp -p $system:/lib64/libc.so $dest/lib64/ ++ e2cp -p $system:/lib64/libm.so $dest/lib64/ ++ else ++ e2cp -p $system:/bin/linker $dest/bin/ ++ e2cp -p $system:/lib/libdl.so $dest/lib/ ++ e2cp -p $system:/lib/libc.so $dest/lib/ ++ e2cp -p $system:/lib/libm.so $dest/lib/ ++ fi ++ ++ # clean up ++ apt-get purge --auto-remove -y e2tools ++ ++ popd ++ ++ rm -rf $td ++} ++ ++main "${@}" diff --cc vendor/libc-0.2.31/ci/docker/aarch64-linux-android/Dockerfile index 000000000,000000000..345540a3f new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/aarch64-linux-android/Dockerfile @@@ -1,0 -1,0 +1,45 @@@ ++FROM ubuntu:16.04 ++ ++RUN dpkg --add-architecture i386 && \ ++ apt-get update && \ ++ apt-get install -y --no-install-recommends \ ++ file \ ++ curl \ ++ ca-certificates \ ++ python \ ++ unzip \ ++ expect \ ++ openjdk-9-jre \ ++ libstdc++6:i386 \ ++ libpulse0 \ ++ gcc \ ++ libc6-dev ++ ++WORKDIR /android/ ++COPY android* /android/ ++ ++ENV ANDROID_ARCH=aarch64 ++ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools ++ ++RUN sh /android/android-install-ndk.sh $ANDROID_ARCH ++RUN sh /android/android-install-sdk.sh $ANDROID_ARCH ++RUN mv /root/.android /tmp ++RUN chmod 777 -R /tmp/.android ++RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/* ++ ++ENV PATH=$PATH:/rust/bin \ ++ CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \ ++ CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER=/tmp/runtest \ ++ HOME=/tmp ++ ++ADD runtest-android.rs /tmp/runtest.rs ++ENTRYPOINT [ \ ++ "bash", \ ++ "-c", \ ++ # set SHELL so android can detect a 64bits system, see ++ # http://stackoverflow.com/a/41789144 ++ "SHELL=/bin/dash emulator @aarch64 -no-window & \ ++ rustc /tmp/runtest.rs -o /tmp/runtest && \ ++ exec \"$@\"", \ ++ "--" \ ++] diff --cc vendor/libc-0.2.31/ci/docker/aarch64-unknown-linux-gnu/Dockerfile index 000000000,000000000..18214a3e6 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@@ -1,0 -1,0 +1,7 @@@ ++FROM ubuntu:17.10 ++RUN apt-get update && apt-get install -y --no-install-recommends \ ++ gcc libc6-dev ca-certificates \ ++ gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user ++ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ ++ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" \ ++ PATH=$PATH:/rust/bin diff --cc vendor/libc-0.2.31/ci/docker/arm-linux-androideabi/Dockerfile index 000000000,000000000..554f07872 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/arm-linux-androideabi/Dockerfile @@@ -1,0 -1,0 +1,45 @@@ ++FROM ubuntu:16.04 ++ ++RUN dpkg --add-architecture i386 && \ ++ apt-get update && \ ++ apt-get install -y --no-install-recommends \ ++ file \ ++ curl \ ++ ca-certificates \ ++ python \ ++ unzip \ ++ expect \ ++ openjdk-9-jre \ ++ libstdc++6:i386 \ ++ libpulse0 \ ++ gcc \ ++ libc6-dev ++ ++WORKDIR /android/ ++COPY android* /android/ ++ ++ENV ANDROID_ARCH=arm ++ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools ++ ++RUN sh /android/android-install-ndk.sh $ANDROID_ARCH ++RUN sh /android/android-install-sdk.sh $ANDROID_ARCH ++RUN mv /root/.android /tmp ++RUN chmod 777 -R /tmp/.android ++RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/* ++ ++ENV PATH=$PATH:/rust/bin \ ++ CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \ ++ CARGO_TARGET_ARM_LINUX_ANDROIDEABI_RUNNER=/tmp/runtest \ ++ HOME=/tmp ++ ++ADD runtest-android.rs /tmp/runtest.rs ++ENTRYPOINT [ \ ++ "bash", \ ++ "-c", \ ++ # set SHELL so android can detect a 64bits system, see ++ # http://stackoverflow.com/a/41789144 ++ "SHELL=/bin/dash emulator @arm -no-window & \ ++ rustc /tmp/runtest.rs -o /tmp/runtest && \ ++ exec \"$@\"", \ ++ "--" \ ++] diff --cc vendor/libc-0.2.31/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile index 000000000,000000000..9fe71dcf8 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile @@@ -1,0 -1,0 +1,7 @@@ ++FROM ubuntu:17.10 ++RUN apt-get update && apt-get install -y --no-install-recommends \ ++ gcc libc6-dev ca-certificates \ ++ gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user ++ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ ++ CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" \ ++ PATH=$PATH:/rust/bin diff --cc vendor/libc-0.2.31/ci/docker/asmjs-unknown-emscripten/Dockerfile index 000000000,000000000..3088fc53c new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/asmjs-unknown-emscripten/Dockerfile @@@ -1,0 -1,0 +1,20 @@@ ++FROM ubuntu:16.04 ++ ++RUN apt-get update && \ ++ apt-get install -y --no-install-recommends \ ++ ca-certificates \ ++ curl \ ++ gcc \ ++ git \ ++ libc6-dev \ ++ python \ ++ xz-utils ++ ++COPY emscripten.sh / ++RUN bash /emscripten.sh ++ ++ENV PATH=$PATH:/rust/bin \ ++ CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node ++ ++COPY emscripten-entry.sh / ++ENTRYPOINT ["/emscripten-entry.sh"] diff --cc vendor/libc-0.2.31/ci/docker/i686-linux-android/Dockerfile index 000000000,000000000..7671f78b4 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/i686-linux-android/Dockerfile @@@ -1,0 -1,0 +1,45 @@@ ++FROM ubuntu:16.04 ++ ++RUN dpkg --add-architecture i386 && \ ++ apt-get update && \ ++ apt-get install -y --no-install-recommends \ ++ file \ ++ curl \ ++ ca-certificates \ ++ python \ ++ unzip \ ++ expect \ ++ openjdk-9-jre \ ++ libstdc++6:i386 \ ++ libpulse0 \ ++ gcc \ ++ libc6-dev ++ ++WORKDIR /android/ ++COPY android* /android/ ++ ++ENV ANDROID_ARCH=i686 ++ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin:/android/sdk/tools:/android/sdk/platform-tools ++ ++RUN sh /android/android-install-ndk.sh $ANDROID_ARCH ++RUN sh /android/android-install-sdk.sh $ANDROID_ARCH ++RUN mv /root/.android /tmp ++RUN chmod 777 -R /tmp/.android ++RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/* ++ ++ENV PATH=$PATH:/rust/bin \ ++ CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \ ++ CARGO_TARGET_I686_LINUX_ANDROID_RUNNER=/tmp/runtest \ ++ HOME=/tmp ++ ++ADD runtest-android.rs /tmp/runtest.rs ++ENTRYPOINT [ \ ++ "bash", \ ++ "-c", \ ++ # set SHELL so android can detect a 64bits system, see ++ # http://stackoverflow.com/a/41789144 ++ "SHELL=/bin/dash emulator @i686 -no-window -no-accel & \ ++ rustc /tmp/runtest.rs -o /tmp/runtest && \ ++ exec \"$@\"", \ ++ "--" \ ++] diff --cc vendor/libc-0.2.31/ci/docker/i686-unknown-linux-gnu/Dockerfile index 000000000,000000000..1af41343e new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/i686-unknown-linux-gnu/Dockerfile @@@ -1,0 -1,0 +1,5 @@@ ++FROM ubuntu:17.04 ++RUN apt-get update ++RUN apt-get install -y --no-install-recommends \ ++ gcc-multilib libc6-dev ca-certificates ++ENV PATH=$PATH:/rust/bin diff --cc vendor/libc-0.2.31/ci/docker/i686-unknown-linux-musl/Dockerfile index 000000000,000000000..3adb92004 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/i686-unknown-linux-musl/Dockerfile @@@ -1,0 -1,0 +1,30 @@@ ++FROM ubuntu:17.10 ++ ++RUN dpkg --add-architecture i386 ++RUN apt-get update ++RUN apt-get install -y --no-install-recommends \ ++ gcc-multilib make libc6-dev git curl ca-certificates libc6:i386 ++# 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 && \ ++# Install linux kernel headers sanitized for use with musl ++ curl -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-5.tar.gz | \ ++ tar xzf - && \ ++ cd kernel-headers-3.12.6-5 && \ ++ make ARCH=i386 prefix=/musl-i686 install -j4 && \ ++ cd .. && \ ++ rm -rf kernel-headers-3.12.6-5 ++ENV PATH=$PATH:/musl-i686/bin:/rust/bin \ ++ CC_i686_unknown_linux_musl=musl-gcc diff --cc vendor/libc-0.2.31/ci/docker/mips-unknown-linux-gnu/Dockerfile index 000000000,000000000..c66abd471 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/mips-unknown-linux-gnu/Dockerfile @@@ -1,0 -1,0 +1,10 @@@ ++FROM ubuntu:17.10 ++ ++RUN apt-get update && apt-get install -y --no-install-recommends \ ++ gcc libc6-dev qemu-user ca-certificates \ ++ gcc-mips-linux-gnu libc6-dev-mips-cross \ ++ qemu-system-mips ++ ++ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ ++ CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu" \ ++ PATH=$PATH:/rust/bin diff --cc vendor/libc-0.2.31/ci/docker/mips-unknown-linux-musl/Dockerfile index 000000000,000000000..91ffd5817 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/mips-unknown-linux-musl/Dockerfile @@@ -1,0 -1,0 +1,17 @@@ ++FROM ubuntu:17.10 ++ ++RUN apt-get update && apt-get install -y --no-install-recommends \ ++ gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \ ++ bzip2 ++ ++RUN mkdir /toolchain ++ ++# Note that this originally came from: ++# https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 ++RUN curl -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ ++ tar xjf - -C /toolchain --strip-components=1 ++ ++ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \ ++ CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ ++ CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=mips-openwrt-linux-gcc \ ++ CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15" diff --cc vendor/libc-0.2.31/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile index 000000000,000000000..b9921fcc5 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@@ -1,0 -1,0 +1,11 @@@ ++FROM ubuntu:17.10 ++ ++RUN apt-get update && apt-get install -y --no-install-recommends \ ++ gcc libc6-dev qemu-user ca-certificates \ ++ gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ ++ qemu-system-mips64 ++ ++ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ ++ CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" \ ++ CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \ ++ PATH=$PATH:/rust/bin diff --cc vendor/libc-0.2.31/ci/docker/mipsel-unknown-linux-musl/Dockerfile index 000000000,000000000..3642fa8ca new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/mipsel-unknown-linux-musl/Dockerfile @@@ -1,0 -1,0 +1,17 @@@ ++FROM ubuntu:17.10 ++ ++RUN apt-get update && apt-get install -y --no-install-recommends \ ++ gcc libc6-dev qemu-user ca-certificates qemu-system-mips curl \ ++ bzip2 ++ ++RUN mkdir /toolchain ++ ++# Note that this originally came from: ++# https://downloads.openwrt.org/snapshots/trunk/malta/generic/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 ++RUN curl -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ ++ tar xjf - -C /toolchain --strip-components=2 ++ ++ENV PATH=$PATH:/rust/bin:/toolchain/bin \ ++ CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ ++ CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=mipsel-openwrt-linux-gcc \ ++ CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mipsel -L /toolchain" diff --cc vendor/libc-0.2.31/ci/docker/powerpc-unknown-linux-gnu/Dockerfile index 000000000,000000000..106ada444 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/powerpc-unknown-linux-gnu/Dockerfile @@@ -1,0 -1,0 +1,10 @@@ ++FROM ubuntu:17.10 ++ ++RUN apt-get update && apt-get install -y --no-install-recommends \ ++ gcc libc6-dev qemu-user ca-certificates \ ++ gcc-powerpc-linux-gnu libc6-dev-powerpc-cross \ ++ qemu-system-ppc ++ ++ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ ++ CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -L /usr/powerpc-linux-gnu" \ ++ PATH=$PATH:/rust/bin diff --cc vendor/libc-0.2.31/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile index 000000000,000000000..a6ab66a9a new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile @@@ -1,0 -1,0 +1,11 @@@ ++FROM ubuntu:17.10 ++ ++RUN apt-get update && apt-get install -y --no-install-recommends \ ++ gcc libc6-dev qemu-user ca-certificates \ ++ gcc-powerpc64-linux-gnu libc6-dev-ppc64-cross \ ++ qemu-system-ppc ++ ++ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ ++ CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -L /usr/powerpc64-linux-gnu" \ ++ CC=powerpc64-linux-gnu-gcc \ ++ PATH=$PATH:/rust/bin diff --cc vendor/libc-0.2.31/ci/docker/s390x-unknown-linux-gnu/Dockerfile index 000000000,000000000..49a277d88 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@@ -1,0 -1,0 +1,12 @@@ ++FROM ubuntu:17.10 ++ ++RUN apt-get update && apt-get install -y --no-install-recommends \ ++ gcc libc6-dev qemu-user ca-certificates \ ++ gcc-s390x-linux-gnu libc6-dev-s390x-cross ++ ++ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ ++ # TODO: in theory we should execute this, but qemu segfaults immediately :( ++ # CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="qemu-s390x -L /usr/s390x-linux-gnu" \ ++ CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER=true \ ++ CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \ ++ PATH=$PATH:/rust/bin diff --cc vendor/libc-0.2.31/ci/docker/wasm32-unknown-emscripten/Dockerfile index 000000000,000000000..59bf7d9a2 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/wasm32-unknown-emscripten/Dockerfile @@@ -1,0 -1,0 +1,21 @@@ ++FROM ubuntu:16.04 ++ ++RUN apt-get update && \ ++ apt-get install -y --no-install-recommends \ ++ ca-certificates \ ++ curl \ ++ gcc \ ++ git \ ++ libc6-dev \ ++ python \ ++ xz-utils ++ ++COPY emscripten.sh / ++RUN bash /emscripten.sh ++ ++ENV PATH=$PATH:/rust/bin \ ++ CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node-wrapper.sh ++ ++COPY emscripten-entry.sh / ++COPY docker/wasm32-unknown-emscripten/node-wrapper.sh /usr/local/bin/node-wrapper.sh ++ENTRYPOINT ["/emscripten-entry.sh"] diff --cc vendor/libc-0.2.31/ci/docker/wasm32-unknown-emscripten/node-wrapper.sh index 000000000,000000000..b1936f041 new file mode 100755 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/wasm32-unknown-emscripten/node-wrapper.sh @@@ -1,0 -1,0 +1,11 @@@ ++#!/bin/sh ++ ++set -e ++ ++me=$1 ++shift ++dir=$(dirname $me) ++file=$(basename $me) ++ ++cd $dir ++exec node $file "$@" diff --cc vendor/libc-0.2.31/ci/docker/x86_64-linux-android/Dockerfile index 000000000,000000000..0cfbc4820 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/x86_64-linux-android/Dockerfile @@@ -1,0 -1,0 +1,26 @@@ ++FROM ubuntu:16.04 ++ ++RUN apt-get update && \ ++ apt-get install -y --no-install-recommends \ ++ ca-certificates \ ++ curl \ ++ gcc \ ++ libc-dev \ ++ python \ ++ unzip ++ ++WORKDIR /android/ ++ENV ANDROID_ARCH=x86_64 ++COPY android-install-ndk.sh /android/ ++RUN sh /android/android-install-ndk.sh $ANDROID_ARCH ++ ++# We do not run x86_64-linux-android tests on an android emulator. ++# See ci/android-sysimage.sh for informations about how tests are run. ++COPY android-sysimage.sh /android/ ++RUN bash /android/android-sysimage.sh x86_64 x86_64-24_r07.zip ++ ++ENV PATH=$PATH:/rust/bin:/android/ndk-$ANDROID_ARCH/bin \ ++ CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-gcc \ ++ CC_x86_64_linux_android=x86_64-linux-android-gcc \ ++ CXX_x86_64_linux_android=x86_64-linux-android-g++ \ ++ HOME=/tmp diff --cc vendor/libc-0.2.31/ci/docker/x86_64-rumprun-netbsd/Dockerfile index 000000000,000000000..a486d05b2 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/x86_64-rumprun-netbsd/Dockerfile @@@ -1,0 -1,0 +1,10 @@@ ++FROM mato/rumprun-toolchain-hw-x86_64 ++USER root ++RUN apt-get update ++RUN apt-get install -y --no-install-recommends \ ++ qemu ++ENV PATH=$PATH:/rust/bin \ ++ CARGO_TARGET_X86_64_RUMPRUN_NETBSD_RUNNER=/tmp/runtest ++ ++ADD docker/x86_64-rumprun-netbsd/runtest.rs /tmp/ ++ENTRYPOINT ["sh", "-c", "rustc /tmp/runtest.rs -o /tmp/runtest && exec \"$@\"", "--"] diff --cc vendor/libc-0.2.31/ci/docker/x86_64-rumprun-netbsd/runtest.rs index 000000000,000000000..94b594608 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/x86_64-rumprun-netbsd/runtest.rs @@@ -1,0 -1,0 +1,54 @@@ ++use std::env; ++use std::process::{Command, Stdio}; ++use std::sync::mpsc; ++use std::thread; ++use std::time::Duration; ++use std::io::{BufRead, BufReader, Read}; ++ ++fn main() { ++ assert_eq!(env::args().len(), 2); ++ ++ let status = Command::new("rumprun-bake") ++ .arg("hw_virtio") ++ .arg("/tmp/libc-test.img") ++ .arg(env::args().nth(1).unwrap()) ++ .status() ++ .expect("failed to run rumprun-bake"); ++ assert!(status.success()); ++ ++ let mut child = Command::new("qemu-system-x86_64") ++ .arg("-nographic") ++ .arg("-vga").arg("none") ++ .arg("-m").arg("64") ++ .arg("-kernel").arg("/tmp/libc-test.img") ++ .stdout(Stdio::piped()) ++ .stderr(Stdio::piped()) ++ .spawn() ++ .expect("failed to spawn qemu"); ++ ++ let mut stdout = child.stdout.take().unwrap(); ++ let mut stderr = child.stderr.take().unwrap(); ++ let (tx, rx) = mpsc::channel(); ++ let tx2 = tx.clone(); ++ let t1 = thread::spawn(move || find_ok(&mut stdout, tx)); ++ let t2 = thread::spawn(move || find_ok(&mut stderr, tx2)); ++ ++ let res = rx.recv_timeout(Duration::new(5, 0)); ++ child.kill().unwrap(); ++ t1.join().unwrap(); ++ t2.join().unwrap(); ++ ++ if res.is_err() { ++ panic!("didn't find success"); ++ } ++} ++ ++fn find_ok(input: &mut Read, tx: mpsc::Sender<()>) { ++ for line in BufReader::new(input).lines() { ++ let line = line.unwrap(); ++ println!("{}", line); ++ if line.starts_with("PASSED ") && line.contains(" tests") { ++ tx.send(()).unwrap(); ++ } ++ } ++} diff --cc vendor/libc-0.2.31/ci/docker/x86_64-unknown-freebsd/Dockerfile index 000000000,000000000..7ad3faff3 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/x86_64-unknown-freebsd/Dockerfile @@@ -1,0 -1,0 +1,13 @@@ ++FROM alexcrichton/port-prebuilt-freebsd:2017-09-16 ++ ++RUN apt-get update ++RUN apt-get install -y --no-install-recommends \ ++ qemu genext2fs ++RUN apt-get install -y curl ca-certificates gcc ++ ++ENTRYPOINT ["sh"] ++ ++ENV PATH=$PATH:/rust/bin \ ++ QEMU=2016-11-06/freebsd.qcow2.gz \ ++ CAN_CROSS=1 \ ++ CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd10-gcc diff --cc vendor/libc-0.2.31/ci/docker/x86_64-unknown-linux-gnu/Dockerfile index 000000000,000000000..c5ec6826d new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@@ -1,0 -1,0 +1,5 @@@ ++FROM ubuntu:17.04 ++RUN apt-get update ++RUN apt-get install -y --no-install-recommends \ ++ gcc libc6-dev ca-certificates ++ENV PATH=$PATH:/rust/bin diff --cc vendor/libc-0.2.31/ci/docker/x86_64-unknown-linux-musl/Dockerfile index 000000000,000000000..d9d651138 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@@ -1,0 -1,0 +1,20 @@@ ++FROM ubuntu:17.10 ++ ++RUN apt-get update ++RUN apt-get install -y --no-install-recommends \ ++ gcc make libc6-dev git curl ca-certificates ++RUN curl https://www.musl-libc.org/releases/musl-1.1.15.tar.gz | \ ++ tar xzf - && \ ++ cd musl-1.1.15 && \ ++ ./configure --prefix=/musl-x86_64 && \ ++ make install -j4 && \ ++ cd .. && \ ++ rm -rf musl-1.1.15 && \ ++# Install linux kernel headers sanitized for use with musl ++ curl -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-5.tar.gz | \ ++ tar xzf - && \ ++ cd kernel-headers-3.12.6-5 && \ ++ make ARCH=x86_64 prefix=/musl-x86_64 install -j4 && \ ++ cd .. && \ ++ rm -rf kernel-headers-3.12.6-5 ++ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin diff --cc vendor/libc-0.2.31/ci/dox.sh index 000000000,000000000..85e924394 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/dox.sh @@@ -1,0 -1,0 +1,33 @@@ ++#!/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 "

  • $target
  • " \ ++ >> 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 --install-option="--prefix=$HOME/.local" ++ $HOME/.local/bin/ghp-import -n target/doc ++ git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages ++fi diff --cc vendor/libc-0.2.31/ci/emscripten-entry.sh index 000000000,000000000..acaebfe8c new file mode 100755 --- /dev/null +++ b/vendor/libc-0.2.31/ci/emscripten-entry.sh @@@ -1,0 -1,0 +1,19 @@@ ++#!/bin/bash ++# Copyright 2017 The Rust Project Developers. See the COPYRIGHT ++# file at the top-level directory of this distribution and at ++# http://rust-lang.org/COPYRIGHT. ++# ++# Licensed under the Apache License, Version 2.0 or the MIT license ++# , at your ++# option. This file may not be copied, modified, or distributed ++# except according to those terms. ++ ++set -ex ++ ++source /emsdk-portable/emsdk_env.sh &> /dev/null ++ ++# emsdk-portable provides a node binary, but we need version 8 to run wasm ++export PATH="/node-v8.0.0-linux-x64/bin:$PATH" ++ ++exec "$@" diff --cc vendor/libc-0.2.31/ci/emscripten.sh index 000000000,000000000..d80258584 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/emscripten.sh @@@ -1,0 -1,0 +1,54 @@@ ++# Copyright 2017 The Rust Project Developers. See the COPYRIGHT ++# file at the top-level directory of this distribution and at ++# http://rust-lang.org/COPYRIGHT. ++# ++# Licensed under the Apache License, Version 2.0 or the MIT license ++# , at your ++# option. This file may not be copied, modified, or distributed ++# except according to those terms. ++ ++set -ex ++ ++hide_output() { ++ set +x ++ on_err=" ++echo ERROR: An error was encountered with the build. ++cat /tmp/build.log ++exit 1 ++" ++ trap "$on_err" ERR ++ bash -c "while true; do sleep 30; echo \$(date) - building ...; done" & ++ PING_LOOP_PID=$! ++ $@ &> /tmp/build.log ++ trap - ERR ++ kill $PING_LOOP_PID ++ rm -f /tmp/build.log ++ set -x ++} ++ ++cd / ++curl -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | \ ++ tar -xz ++ ++cd /emsdk-portable ++./emsdk update ++hide_output ./emsdk install sdk-1.37.20-64bit ++./emsdk activate sdk-1.37.20-64bit ++ ++# Compile and cache libc ++source ./emsdk_env.sh ++echo "main(){}" > a.c ++HOME=/emsdk-portable/ emcc a.c ++HOME=/emsdk-portable/ emcc -s BINARYEN=1 a.c ++rm -f a.* ++ ++# Make emsdk usable by any user ++cp /root/.emscripten /emsdk-portable ++chmod a+rxw -R /emsdk-portable ++ ++# node 8 is required to run wasm ++cd / ++curl -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ ++ tar -xJ ++ diff --cc vendor/libc-0.2.31/ci/ios/deploy_and_run_on_ios_simulator.rs index 000000000,000000000..b14615036 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/ios/deploy_and_run_on_ios_simulator.rs @@@ -1,0 -1,0 +1,171 @@@ ++// Copyright 2017 The Rust Project Developers. See the COPYRIGHT ++// file at the top-level directory of this distribution and at ++// http://rust-lang.org/COPYRIGHT. ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++// This is a script to deploy and execute a binary on an iOS simulator. ++// The primary use of this is to be able to run unit tests on the simulator and ++// retrieve the results. ++// ++// To do this through Cargo instead, use Dinghy ++// (https://github.com/snipsco/dinghy): cargo dinghy install, then cargo dinghy ++// test. ++ ++use std::env; ++use std::fs::{self, File}; ++use std::io::Write; ++use std::path::Path; ++use std::process; ++use std::process::Command; ++ ++macro_rules! t { ++ ($e:expr) => (match $e { ++ Ok(e) => e, ++ Err(e) => panic!("{} failed with: {}", stringify!($e), e), ++ }) ++} ++ ++// Step one: Wrap as an app ++fn package_as_simulator_app(crate_name: &str, test_binary_path: &Path) { ++ println!("Packaging simulator app"); ++ drop(fs::remove_dir_all("ios_simulator_app")); ++ t!(fs::create_dir("ios_simulator_app")); ++ t!(fs::copy(test_binary_path, ++ Path::new("ios_simulator_app").join(crate_name))); ++ ++ let mut f = t!(File::create("ios_simulator_app/Info.plist")); ++ t!(f.write_all(format!(r#" ++ ++ ++ ++ ++ CFBundleExecutable ++ {} ++ CFBundleIdentifier ++ com.rust.unittests ++ ++ ++ "#, crate_name).as_bytes())); ++} ++ ++// Step two: Start the iOS simulator ++fn start_simulator() { ++ println!("Looking for iOS simulator"); ++ let output = t!(Command::new("xcrun").arg("simctl").arg("list").output()); ++ assert!(output.status.success()); ++ let mut simulator_exists = false; ++ let mut simulator_booted = false; ++ let mut found_rust_sim = false; ++ let stdout = t!(String::from_utf8(output.stdout)); ++ for line in stdout.lines() { ++ if line.contains("rust_ios") { ++ if found_rust_sim { ++ panic!("Duplicate rust_ios simulators found. Please \ ++ double-check xcrun simctl list."); ++ } ++ simulator_exists = true; ++ simulator_booted = line.contains("(Booted)"); ++ found_rust_sim = true; ++ } ++ } ++ ++ if simulator_exists == false { ++ println!("Creating iOS simulator"); ++ Command::new("xcrun") ++ .arg("simctl") ++ .arg("create") ++ .arg("rust_ios") ++ .arg("com.apple.CoreSimulator.SimDeviceType.iPhone-SE") ++ .arg("com.apple.CoreSimulator.SimRuntime.iOS-10-2") ++ .check_status(); ++ } else if simulator_booted == true { ++ println!("Shutting down already-booted simulator"); ++ Command::new("xcrun") ++ .arg("simctl") ++ .arg("shutdown") ++ .arg("rust_ios") ++ .check_status(); ++ } ++ ++ println!("Starting iOS simulator"); ++ // We can't uninstall the app (if present) as that will hang if the ++ // simulator isn't completely booted; just erase the simulator instead. ++ Command::new("xcrun").arg("simctl").arg("erase").arg("rust_ios").check_status(); ++ Command::new("xcrun").arg("simctl").arg("boot").arg("rust_ios").check_status(); ++} ++ ++// Step three: Install the app ++fn install_app_to_simulator() { ++ println!("Installing app to simulator"); ++ Command::new("xcrun") ++ .arg("simctl") ++ .arg("install") ++ .arg("booted") ++ .arg("ios_simulator_app/") ++ .check_status(); ++} ++ ++// Step four: Run the app ++fn run_app_on_simulator() { ++ println!("Running app"); ++ let output = t!(Command::new("xcrun") ++ .arg("simctl") ++ .arg("launch") ++ .arg("--console") ++ .arg("booted") ++ .arg("com.rust.unittests") ++ .output()); ++ ++ println!("stdout --\n{}\n", String::from_utf8_lossy(&output.stdout)); ++ println!("stderr --\n{}\n", String::from_utf8_lossy(&output.stderr)); ++ ++ let stdout = String::from_utf8_lossy(&output.stdout); ++ let passed = stdout.lines() ++ .find(|l| l.contains("PASSED")) ++ .map(|l| l.contains("tests")) ++ .unwrap_or(false); ++ ++ println!("Shutting down simulator"); ++ Command::new("xcrun") ++ .arg("simctl") ++ .arg("shutdown") ++ .arg("rust_ios") ++ .check_status(); ++ if !passed { ++ panic!("tests didn't pass"); ++ } ++} ++ ++trait CheckStatus { ++ fn check_status(&mut self); ++} ++ ++impl CheckStatus for Command { ++ fn check_status(&mut self) { ++ println!("\trunning: {:?}", self); ++ assert!(t!(self.status()).success()); ++ } ++} ++ ++fn main() { ++ let args: Vec = env::args().collect(); ++ if args.len() != 2 { ++ println!("Usage: {} ", args[0]); ++ process::exit(-1); ++ } ++ ++ let test_binary_path = Path::new(&args[1]); ++ let crate_name = test_binary_path.file_name().unwrap(); ++ ++ package_as_simulator_app(crate_name.to_str().unwrap(), test_binary_path); ++ start_simulator(); ++ install_app_to_simulator(); ++ run_app_on_simulator(); ++} diff --cc vendor/libc-0.2.31/ci/landing-page-footer.html index 000000000,000000000..941cc8d2b new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/landing-page-footer.html @@@ -1,0 -1,0 +1,3 @@@ ++ ++ ++ diff --cc vendor/libc-0.2.31/ci/landing-page-head.html index 000000000,000000000..fc69fa88e new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/landing-page-head.html @@@ -1,0 -1,0 +1,7 @@@ ++ ++ ++ ++ ++ ++ ++
      diff --cc vendor/libc-0.2.31/ci/run-docker.sh index 000000000,000000000..662a1d491 new file mode 100755 --- /dev/null +++ b/vendor/libc-0.2.31/ci/run-docker.sh @@@ -1,0 -1,0 +1,36 @@@ ++# Small script to run tests for a target (or all targets) inside all the ++# respective docker images. ++ ++set -ex ++ ++run() { ++ echo $1 ++ # use -f so we can use ci/ as build context ++ docker build -t libc -f ci/docker/$1/Dockerfile ci/ ++ mkdir -p target ++ if [ -w /dev/kvm ]; then ++ kvm="--volume /dev/kvm:/dev/kvm" ++ fi ++ docker run \ ++ --user `id -u`:`id -g` \ ++ --rm \ ++ --init \ ++ --volume $HOME/.cargo:/cargo \ ++ $kvm \ ++ --env CARGO_HOME=/cargo \ ++ --volume `rustc --print sysroot`:/rust:ro \ ++ --volume `pwd`:/checkout:ro \ ++ --volume `pwd`/target:/checkout/target \ ++ --env CARGO_TARGET_DIR=/checkout/target \ ++ --workdir /checkout \ ++ libc \ ++ ci/run.sh $1 ++} ++ ++if [ -z "$1" ]; then ++ for d in `ls ci/docker/`; do ++ run $d ++ done ++else ++ run $1 ++fi diff --cc vendor/libc-0.2.31/ci/run-qemu.sh index 000000000,000000000..b2f457df9 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/run-qemu.sh @@@ -1,0 -1,0 +1,32 @@@ ++# 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 --cc vendor/libc-0.2.31/ci/run.sh index 000000000,000000000..51a2c6871 new file mode 100755 --- /dev/null +++ b/vendor/libc-0.2.31/ci/run.sh @@@ -1,0 -1,0 +1,71 @@@ ++#!/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://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/$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://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/$QEMU \ ++ > $tmpdir/$qemufile ++ fi ++ fi ++ ++ # Create a mount a fresh new filesystem image that we'll later pass to QEMU. ++ # This will have a `run.sh` script will which use the artifacts inside to run ++ # on the host. ++ rm -f $tmpdir/libc-test.img ++ mkdir $tmpdir/mount ++ ++ # Do the standard rigamarole of cross-compiling an executable and then the ++ # script to run just executes the binary. ++ cargo build --manifest-path libc-test/Cargo.toml --target $TARGET --tests ++ cp $CARGO_TARGET_DIR/$TARGET/debug/main-* $tmpdir/mount/libc-test ++ echo 'exec $1/libc-test' > $tmpdir/mount/run.sh ++ ++ du -sh $tmpdir/mount ++ genext2fs \ ++ --root $tmpdir/mount \ ++ --size-in-blocks 100000 \ ++ $tmpdir/libc-test.img ++ ++ # Pass -snapshot to prevent tampering with the disk images, this helps when ++ # running this script in development. The two drives are then passed next, ++ # first is the OS and second is the one we just made. Next the network is ++ # configured to work (I'm not entirely sure how), and then finally we turn off ++ # graphics and redirect the serial console output to out.log. ++ qemu-system-x86_64 \ ++ -m 1024 \ ++ -snapshot \ ++ -drive if=virtio,file=$tmpdir/$qemufile \ ++ -drive if=virtio,file=$tmpdir/libc-test.img \ ++ -net nic,model=virtio \ ++ -net user \ ++ -nographic \ ++ -vga none 2>&1 | tee $CARGO_TARGET_DIR/out.log ++ exec grep "^PASSED .* tests" $CARGO_TARGET_DIR/out.log ++fi ++ ++exec cargo test --manifest-path libc-test/Cargo.toml --target $TARGET diff --cc vendor/libc-0.2.31/ci/runtest-android.rs index 000000000,000000000..a8f8db83f new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/runtest-android.rs @@@ -1,0 -1,0 +1,41 @@@ ++use std::env; ++use std::process::Command; ++use std::path::{Path, PathBuf}; ++ ++fn main() { ++ assert_eq!(env::args_os().len(), 2); ++ let test = PathBuf::from(env::args_os().nth(1).unwrap()); ++ let dst = Path::new("/data/local/tmp").join(test.file_name().unwrap()); ++ ++ let status = Command::new("adb") ++ .arg("wait-for-device") ++ .status() ++ .expect("failed to run rumprun-bake"); ++ assert!(status.success()); ++ ++ let status = Command::new("adb") ++ .arg("push") ++ .arg(&test) ++ .arg(&dst) ++ .status() ++ .expect("failed to run rumprun-bake"); ++ assert!(status.success()); ++ ++ let output = Command::new("adb") ++ .arg("shell") ++ .arg(&dst) ++ .output() ++ .expect("failed to run rumprun-bake"); ++ assert!(status.success()); ++ ++ println!("status: {}\nstdout ---\n{}\nstderr ---\n{}", ++ output.status, ++ String::from_utf8_lossy(&output.stdout), ++ String::from_utf8_lossy(&output.stderr)); ++ ++ let stdout = String::from_utf8_lossy(&output.stdout); ++ let mut lines = stdout.lines().filter(|l| l.starts_with("PASSED ")); ++ if !lines.any(|l| l.contains(" tests")) { ++ panic!("failed to find successful test run"); ++ } ++} diff --cc vendor/libc-0.2.31/ci/style.rs index 000000000,000000000..32e4ba772 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/ci/style.rs @@@ -1,0 -1,0 +1,204 @@@ ++//! 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 --cc vendor/libc-0.2.31/src/dox.rs index 000000000,000000000..41aac385f new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/dox.rs @@@ -1,0 -1,0 +1,175 @@@ ++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 { ++ Some(T), ++ None, ++ } ++ impl Copy for Option {} ++ impl Clone for Option { ++ fn clone(&self) -> Option { loop {} } ++ } ++ ++ pub trait Clone { ++ fn clone(&self) -> Self; ++ } ++ ++ #[lang = "copy"] ++ pub trait Copy {} ++ ++ #[lang = "freeze"] ++ pub trait Freeze {} ++ ++ #[lang = "sync"] ++ pub trait Sync {} ++ impl Sync for T {} ++ ++ #[lang = "sized"] ++ pub trait Sized {} ++ ++ macro_rules! each_int { ++ ($mac:ident) => ( ++ $mac!(u8); ++ $mac!(u16); ++ $mac!(u32); ++ $mac!(u64); ++ $mac!(usize); ++ each_signed_int!($mac); ++ ) ++ } ++ ++ macro_rules! each_signed_int { ++ ($mac:ident) => ( ++ $mac!(i8); ++ $mac!(i16); ++ $mac!(i32); ++ $mac!(i64); ++ $mac!(isize); ++ ) ++ } ++ ++ #[lang = "div"] ++ pub trait Div { ++ 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 { ++ 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 { ++ 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 { ++ 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 { ++ 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); ++ ++ #[lang = "neg"] ++ pub trait Neg { ++ type Output; ++ fn neg(self) -> Self::Output; ++ } ++ ++ macro_rules! impl_neg { ++ ($($i:ident)*) => ($( ++ impl Neg for $i { ++ type Output = $i; ++ fn neg(self) -> $i { -self } ++ } ++ )*) ++ } ++ each_signed_int!(impl_neg); ++ ++ #[lang = "not"] ++ pub trait Not { ++ type Output; ++ fn not(self) -> Self::Output; ++ } ++ ++ macro_rules! impl_not { ++ ($($i:ident)*) => ($( ++ impl Not for $i { ++ type Output = $i; ++ fn not(self) -> $i { !self } ++ } ++ )*) ++ } ++ each_int!(impl_not); ++ ++ pub mod mem { ++ pub fn size_of_val(_: &T) -> usize { 4 } ++ } ++} diff --cc vendor/libc-0.2.31/src/lib.rs index 000000000,000000000..366ccff17 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/lib.rs @@@ -1,0 -1,0 +1,288 @@@ ++// 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 or the MIT license ++// , 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" ++))] ++#![cfg_attr(all(target_os = "emscripten", target_arch = "asmjs"), doc( ++ html_root_url = "https://doc.rust-lang.org/libc/asmjs-unknown-emscripten" ++))] ++#![cfg_attr(all(target_os = "emscripten", target_arch = "wasm32"), doc( ++ html_root_url = "https://doc.rust-lang.org/libc/wasm32-unknown-emscripten" ++))] ++#![cfg_attr(all(target_os = "linux", target_arch = "xparc64"), doc( ++ html_root_url = "https://doc.rust-lang.org/libc/sparc64-unknown-linux-gnu" ++))] ++ ++// Attributes needed when building as part of the standard library ++#![cfg_attr(feature = "stdbuild", feature(no_std, staged_api, custom_attribute, cfg_target_vendor))] ++#![cfg_attr(feature = "stdbuild", feature(link_cfg))] ++#![cfg_attr(feature = "stdbuild", no_std)] ++#![cfg_attr(feature = "stdbuild", staged_api)] ++#![cfg_attr(feature = "stdbuild", allow(warnings))] ++#![cfg_attr(feature = "stdbuild", unstable(feature = "libc", ++ reason = "use `libc` from crates.io", ++ issue = "27783"))] ++ ++#![cfg_attr(not(feature = "use_std"), no_std)] ++ ++#[cfg(all(not(dox), feature = "use_std"))] ++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 wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> ::size_t; ++ ++ pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; ++ pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; ++ pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; ++ pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; ++ pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; ++} ++ ++// These are all inline functions on android, so they end up just being entirely ++// missing on that platform. ++#[cfg(not(target_os = "android"))] ++extern { ++ pub fn abs(i: c_int) -> c_int; ++ pub fn atof(s: *const c_char) -> c_double; ++ pub fn labs(i: c_long) -> c_long; ++ pub fn rand() -> c_int; ++ pub fn srand(seed: c_uint); ++} ++ ++cfg_if! { ++ if #[cfg(windows)] { ++ mod windows; ++ pub use windows::*; ++ } else if #[cfg(target_os = "redox")] { ++ mod redox; ++ pub use redox::*; ++ } else if #[cfg(unix)] { ++ mod unix; ++ pub use unix::*; ++ } else { ++ // Unknown target_family ++ } ++} diff --cc vendor/libc-0.2.31/src/macros.rs index 000000000,000000000..842944201 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/macros.rs @@@ -1,0 -1,0 +1,71 @@@ ++/// 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) ++} diff --cc vendor/libc-0.2.31/src/redox.rs index 000000000,000000000..7ff4ea05f new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/redox.rs @@@ -1,0 -1,0 +1,96 @@@ ++pub type c_char = i8; ++pub type c_long = i64; ++pub type c_ulong = u64; ++ ++pub type wchar_t = i16; ++ ++pub type off_t = c_long; ++pub type mode_t = u16; ++pub type time_t = i64; ++pub type pid_t = usize; ++pub type gid_t = usize; ++pub type uid_t = usize; ++ ++pub type in_addr_t = u32; ++pub type in_port_t = u16; ++ ++pub type socklen_t = u32; ++pub type sa_family_t = u16; ++ ++s! { ++ pub struct in_addr { ++ pub s_addr: in_addr_t, ++ } ++ ++ pub struct in6_addr { ++ pub s6_addr: [u8; 16], ++ __align: [u32; 0], ++ } ++ ++ 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 const STDIN_FILENO: ::c_int = 0; ++pub const STDOUT_FILENO: ::c_int = 1; ++pub const STDERR_FILENO: ::c_int = 2; ++ ++pub const EXIT_FAILURE: ::c_int = 1; ++pub const EXIT_SUCCESS: ::c_int = 0; ++ ++pub const S_ISUID: ::c_int = 0x800; ++pub const S_ISGID: ::c_int = 0x400; ++pub const S_ISVTX: ::c_int = 0x200; ++ ++pub const S_IFIFO: mode_t = 0x1000; ++pub const S_IFCHR: mode_t = 0x2000; ++pub const S_IFBLK: mode_t = 0x6000; ++pub const S_IFDIR: mode_t = 0x4000; ++pub const S_IFREG: mode_t = 0x8000; ++pub const S_IFLNK: mode_t = 0xA000; ++pub const S_IFSOCK: mode_t = 0xC000; ++pub const S_IFMT: mode_t = 0xF000; ++pub const S_IEXEC: mode_t = 0x40; ++pub const S_IWRITE: mode_t = 0x80; ++pub const S_IREAD: mode_t = 0x100; ++pub const S_IRWXU: mode_t = 0x1C0; ++pub const S_IXUSR: mode_t = 0x40; ++pub const S_IWUSR: mode_t = 0x80; ++pub const S_IRUSR: mode_t = 0x100; ++pub const S_IRWXG: mode_t = 0x38; ++pub const S_IXGRP: mode_t = 0x8; ++pub const S_IWGRP: mode_t = 0x10; ++pub const S_IRGRP: mode_t = 0x20; ++pub const S_IRWXO: mode_t = 0x7; ++pub const S_IXOTH: mode_t = 0x1; ++pub const S_IWOTH: mode_t = 0x2; ++pub const S_IROTH: mode_t = 0x4; ++ ++extern { ++ pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; ++ pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) ++ -> ::ssize_t; ++ pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) ++ -> ::ssize_t; ++} ++ ++#[link(name = "c")] ++#[link(name = "m")] ++extern {} diff --cc vendor/libc-0.2.31/src/unix/bsd/apple/b32.rs index 000000000,000000000..53fc0ae19 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/apple/b32.rs @@@ -1,0 -1,0 +1,53 @@@ ++//! 32-bit specific Apple (ios/darwin) definitions ++ ++pub type c_long = i32; ++pub type c_ulong = u32; ++pub type boolean_t = ::c_int; ++ ++s! { ++ pub struct pthread_attr_t { ++ __sig: c_long, ++ __opaque: [::c_char; 36] ++ } ++ ++ pub struct if_data { ++ pub ifi_type: ::c_uchar, ++ pub ifi_typelen: ::c_uchar, ++ pub ifi_physical: ::c_uchar, ++ pub ifi_addrlen: ::c_uchar, ++ pub ifi_hdrlen: ::c_uchar, ++ pub ifi_recvquota: ::c_uchar, ++ pub ifi_xmitquota: ::c_uchar, ++ pub ifi_unused1: ::c_uchar, ++ pub ifi_mtu: u32, ++ pub ifi_metric: u32, ++ pub ifi_baudrate: u32, ++ pub ifi_ipackets: u32, ++ pub ifi_ierrors: u32, ++ pub ifi_opackets: u32, ++ pub ifi_oerrors: u32, ++ pub ifi_collisions: u32, ++ pub ifi_ibytes: u32, ++ pub ifi_obytes: u32, ++ pub ifi_imcasts: u32, ++ pub ifi_omcasts: u32, ++ pub ifi_iqdrops: u32, ++ pub ifi_noproto: u32, ++ pub ifi_recvtiming: u32, ++ pub ifi_xmittiming: u32, ++ pub ifi_lastchange: ::timeval, ++ pub ifi_unused2: u32, ++ pub ifi_hwassist: u32, ++ pub ifi_reserved1: u32, ++ pub ifi_reserved2: u32, ++ } ++} ++ ++pub const __PTHREAD_MUTEX_SIZE__: usize = 40; ++pub const __PTHREAD_COND_SIZE__: usize = 24; ++pub const __PTHREAD_CONDATTR_SIZE__: usize = 4; ++pub const __PTHREAD_RWLOCK_SIZE__: usize = 124; ++pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12; ++ ++pub const TIOCTIMESTAMP: ::c_ulong = 0x40087459; ++pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40087458; diff --cc vendor/libc-0.2.31/src/unix/bsd/apple/b64.rs index 000000000,000000000..e4a398194 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/apple/b64.rs @@@ -1,0 -1,0 +1,60 @@@ ++//! 64-bit specific Apple (ios/darwin) definitions ++ ++pub type c_long = i64; ++pub type c_ulong = u64; ++pub type boolean_t = ::c_uint; ++ ++s! { ++ pub struct pthread_attr_t { ++ __sig: c_long, ++ __opaque: [::c_char; 56] ++ } ++ ++ pub struct timeval32 { ++ pub tv_sec: i32, ++ pub tv_usec: i32, ++ } ++ ++ pub struct if_data { ++ pub ifi_type: ::c_uchar, ++ pub ifi_typelen: ::c_uchar, ++ pub ifi_physical: ::c_uchar, ++ pub ifi_addrlen: ::c_uchar, ++ pub ifi_hdrlen: ::c_uchar, ++ pub ifi_recvquota: ::c_uchar, ++ pub ifi_xmitquota: ::c_uchar, ++ pub ifi_unused1: ::c_uchar, ++ pub ifi_mtu: u32, ++ pub ifi_metric: u32, ++ pub ifi_baudrate: u32, ++ pub ifi_ipackets: u32, ++ pub ifi_ierrors: u32, ++ pub ifi_opackets: u32, ++ pub ifi_oerrors: u32, ++ pub ifi_collisions: u32, ++ pub ifi_ibytes: u32, ++ pub ifi_obytes: u32, ++ pub ifi_imcasts: u32, ++ pub ifi_omcasts: u32, ++ pub ifi_iqdrops: u32, ++ pub ifi_noproto: u32, ++ pub ifi_recvtiming: u32, ++ pub ifi_xmittiming: u32, ++ pub ifi_lastchange: timeval32, ++ pub ifi_unused2: u32, ++ pub ifi_hwassist: u32, ++ pub ifi_reserved1: u32, ++ pub ifi_reserved2: u32, ++ } ++} ++ ++pub const __PTHREAD_MUTEX_SIZE__: usize = 56; ++pub const __PTHREAD_COND_SIZE__: usize = 40; ++pub const __PTHREAD_CONDATTR_SIZE__: usize = 8; ++pub const __PTHREAD_RWLOCK_SIZE__: usize = 192; ++pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16; ++ ++pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; ++pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40107458; ++ ++pub const FIONREAD: ::c_ulong = 0x4004667f; diff --cc vendor/libc-0.2.31/src/unix/bsd/apple/mod.rs index 000000000,000000000..0caef9fbd new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/apple/mod.rs @@@ -1,0 -1,0 +1,2147 @@@ ++//! 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 type idtype_t = ::c_uint; ++ ++pub enum timezone {} ++ ++s! { ++ pub struct aiocb { ++ pub aio_fildes: ::c_int, ++ pub aio_offset: ::off_t, ++ pub aio_buf: *mut ::c_void, ++ pub aio_nbytes: ::size_t, ++ pub aio_reqprio: ::c_int, ++ pub aio_sigevent: sigevent, ++ pub aio_lio_opcode: ::c_int ++ } ++ ++ 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 pthread_rwlockattr_t { ++ __sig: ::c_long, ++ __opaque: [u8; __PTHREAD_RWLOCKATTR_SIZE__], ++ } ++ ++ pub struct siginfo_t { ++ pub si_signo: ::c_int, ++ pub si_errno: ::c_int, ++ pub si_code: ::c_int, ++ pub si_pid: ::pid_t, ++ pub si_uid: ::uid_t, ++ pub si_status: ::c_int, ++ pub si_addr: *mut ::c_void, ++ _pad: [usize; 9], ++ } ++ ++ pub struct sigaction { ++ 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 if_msghdr { ++ pub ifm_msglen: ::c_ushort, ++ pub ifm_version: ::c_uchar, ++ pub ifm_type: ::c_uchar, ++ pub ifm_addrs: ::c_int, ++ pub ifm_flags: ::c_int, ++ pub ifm_index: ::c_ushort, ++ pub ifm_data: if_data, ++ } ++ ++ pub struct termios { ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ pub c_ispeed: ::speed_t, ++ pub c_ospeed: ::speed_t, ++ } ++ ++ pub struct flock { ++ pub l_start: ::off_t, ++ pub l_len: ::off_t, ++ pub l_pid: ::pid_t, ++ pub l_type: ::c_short, ++ pub l_whence: ::c_short, ++ } ++ ++ pub struct sf_hdtr { ++ pub headers: *mut ::iovec, ++ pub hdr_cnt: ::c_int, ++ pub trailers: *mut ::iovec, ++ pub trl_cnt: ::c_int, ++ } ++ ++ pub struct lconv { ++ pub decimal_point: *mut ::c_char, ++ pub thousands_sep: *mut ::c_char, ++ pub grouping: *mut ::c_char, ++ pub int_curr_symbol: *mut ::c_char, ++ pub currency_symbol: *mut ::c_char, ++ pub mon_decimal_point: *mut ::c_char, ++ pub mon_thousands_sep: *mut ::c_char, ++ pub mon_grouping: *mut ::c_char, ++ pub positive_sign: *mut ::c_char, ++ pub negative_sign: *mut ::c_char, ++ pub int_frac_digits: ::c_char, ++ pub frac_digits: ::c_char, ++ pub p_cs_precedes: ::c_char, ++ pub p_sep_by_space: ::c_char, ++ pub n_cs_precedes: ::c_char, ++ pub n_sep_by_space: ::c_char, ++ pub p_sign_posn: ::c_char, ++ pub n_sign_posn: ::c_char, ++ pub int_p_cs_precedes: ::c_char, ++ pub int_n_cs_precedes: ::c_char, ++ pub int_p_sep_by_space: ::c_char, ++ pub int_n_sep_by_space: ::c_char, ++ pub int_p_sign_posn: ::c_char, ++ pub int_n_sign_posn: ::c_char, ++ } ++ ++ pub struct sigevent { ++ pub sigev_notify: ::c_int, ++ pub sigev_signo: ::c_int, ++ pub sigev_value: ::sigval, ++ __unused1: *mut ::c_void, //actually a function pointer ++ pub sigev_notify_attributes: *mut ::pthread_attr_t ++ } ++ ++ pub struct proc_taskinfo { ++ pub pti_virtual_size: u64, ++ pub pti_resident_size: u64, ++ pub pti_total_user: u64, ++ pub pti_total_system: u64, ++ pub pti_threads_user: u64, ++ pub pti_threads_system: u64, ++ pub pti_policy: i32, ++ pub pti_faults: i32, ++ pub pti_pageins: i32, ++ pub pti_cow_faults: i32, ++ pub pti_messages_sent: i32, ++ pub pti_messages_received: i32, ++ pub pti_syscalls_mach: i32, ++ pub pti_syscalls_unix: i32, ++ pub pti_csw: i32, ++ pub pti_threadnum: i32, ++ pub pti_numrunning: i32, ++ pub pti_priority: i32, ++ } ++ ++ pub struct proc_bsdinfo { ++ pub pbi_flags: u32, ++ pub pbi_status: u32, ++ pub pbi_xstatus: u32, ++ pub pbi_pid: u32, ++ pub pbi_ppid: u32, ++ pub pbi_uid: ::uid_t, ++ pub pbi_gid: ::gid_t, ++ pub pbi_ruid: ::uid_t, ++ pub pbi_rgid: ::gid_t, ++ pub pbi_svuid: ::uid_t, ++ pub pbi_svgid: ::gid_t, ++ pub rfu_1: u32, ++ pub pbi_comm: [::c_char; MAXCOMLEN], ++ pub pbi_name: [::c_char; 32], // MAXCOMLEN * 2, but macro isn't happy... ++ pub pbi_nfiles: u32, ++ pub pbi_pgid: u32, ++ pub pbi_pjobc: u32, ++ pub e_tdev: u32, ++ pub e_tpgid: u32, ++ pub pbi_nice: i32, ++ pub pbi_start_tvsec: u64, ++ pub pbi_start_tvusec: u64, ++ } ++ ++ pub struct proc_taskallinfo { ++ pub pbsd: proc_bsdinfo, ++ pub ptinfo: proc_taskinfo, ++ } ++ ++ pub struct proc_threadinfo { ++ pub pth_user_time: u64, ++ pub pth_system_time: u64, ++ pub pth_cpu_usage: i32, ++ pub pth_policy: i32, ++ pub pth_run_state: i32, ++ pub pth_flags: i32, ++ pub pth_sleep_time: i32, ++ pub pth_curpri: i32, ++ pub pth_priority: i32, ++ pub pth_maxpriority: i32, ++ pub pth_name: [::c_char; MAXTHREADNAMESIZE], ++ } ++ ++ pub struct xsw_usage { ++ pub xsu_total: u64, ++ pub xsu_avail: u64, ++ pub xsu_used: u64, ++ pub xsu_pagesize: u32, ++ pub xsu_encrypted: ::boolean_t, ++ } ++} ++ ++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_DSYNC: ::c_int = 0x400000; ++pub const O_NOCTTY: ::c_int = 0x20000; ++pub const O_CLOEXEC: ::c_int = 0x1000000; ++pub const O_DIRECTORY: ::c_int = 0x100000; ++pub const S_IFIFO: mode_t = 4096; ++pub const S_IFCHR: mode_t = 8192; ++pub const S_IFBLK: mode_t = 24576; ++pub const S_IFDIR: mode_t = 16384; ++pub const S_IFREG: mode_t = 32768; ++pub const S_IFLNK: mode_t = 40960; ++pub const S_IFSOCK: mode_t = 49152; ++pub const S_IFMT: mode_t = 61440; ++pub const S_IEXEC: mode_t = 64; ++pub const S_IWRITE: mode_t = 128; ++pub const S_IREAD: mode_t = 256; ++pub const S_IRWXU: mode_t = 448; ++pub const S_IXUSR: mode_t = 64; ++pub const S_IWUSR: mode_t = 128; ++pub const S_IRUSR: mode_t = 256; ++pub const S_IRWXG: mode_t = 56; ++pub const S_IXGRP: mode_t = 8; ++pub const S_IWGRP: mode_t = 16; ++pub const S_IRGRP: mode_t = 32; ++pub const S_IRWXO: mode_t = 7; ++pub const S_IXOTH: mode_t = 1; ++pub const S_IWOTH: mode_t = 2; ++pub const S_IROTH: mode_t = 4; ++pub const F_OK: ::c_int = 0; ++pub const R_OK: ::c_int = 4; ++pub const W_OK: ::c_int = 2; ++pub const X_OK: ::c_int = 1; ++pub const STDIN_FILENO: ::c_int = 0; ++pub const STDOUT_FILENO: ::c_int = 1; ++pub const STDERR_FILENO: ::c_int = 2; ++pub const F_LOCK: ::c_int = 1; ++pub const F_TEST: ::c_int = 3; ++pub const F_TLOCK: ::c_int = 2; ++pub const F_ULOCK: ::c_int = 0; ++pub const F_GETLK: ::c_int = 7; ++pub const F_SETLK: ::c_int = 8; ++pub const F_SETLKW: ::c_int = 9; ++pub const SIGHUP: ::c_int = 1; ++pub const SIGINT: ::c_int = 2; ++pub const SIGQUIT: ::c_int = 3; ++pub const SIGILL: ::c_int = 4; ++pub const SIGABRT: ::c_int = 6; ++pub const SIGEMT: ::c_int = 7; ++pub const SIGFPE: ::c_int = 8; ++pub const SIGKILL: ::c_int = 9; ++pub const SIGSEGV: ::c_int = 11; ++pub const SIGPIPE: ::c_int = 13; ++pub const SIGALRM: ::c_int = 14; ++pub const SIGTERM: ::c_int = 15; ++ ++pub const PROT_NONE: ::c_int = 0; ++pub const PROT_READ: ::c_int = 1; ++pub const PROT_WRITE: ::c_int = 2; ++pub const PROT_EXEC: ::c_int = 4; ++ ++pub const 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 VM_FLAGS_FIXED: ::c_int = 0x0000; ++pub const VM_FLAGS_ANYWHERE: ::c_int = 0x0001; ++pub const VM_FLAGS_PURGABLE: ::c_int = 0x0002; ++pub const VM_FLAGS_RANDOM_ADDR: ::c_int = 0x0008; ++pub const VM_FLAGS_NO_CACHE: ::c_int = 0x0010; ++pub const VM_FLAGS_RESILIENT_CODESIGN: ::c_int = 0x0020; ++pub const VM_FLAGS_RESILIENT_MEDIA: ::c_int = 0x0040; ++pub const VM_FLAGS_OVERWRITE: ::c_int = 0x4000; ++pub const VM_FLAGS_SUPERPAGE_MASK: ::c_int = 0x70000; ++pub const VM_FLAGS_RETURN_DATA_ADDR: ::c_int = 0x100000; ++pub const VM_FLAGS_RETURN_4K_DATA_ADDR: ::c_int = 0x800000; ++pub const VM_FLAGS_ALIAS_MASK: ::c_int = 0xFF000000; ++pub const VM_FLAGS_USER_ALLOCATE: ::c_int = VM_FLAGS_FIXED | VM_FLAGS_ANYWHERE | ++ VM_FLAGS_PURGABLE | ++ VM_FLAGS_RANDOM_ADDR | ++ VM_FLAGS_NO_CACHE | ++ VM_FLAGS_OVERWRITE | ++ VM_FLAGS_SUPERPAGE_MASK | ++ VM_FLAGS_ALIAS_MASK; ++pub const VM_FLAGS_USER_MAP: ::c_int = VM_FLAGS_USER_ALLOCATE | ++ VM_FLAGS_RETURN_4K_DATA_ADDR | ++ VM_FLAGS_RETURN_DATA_ADDR; ++pub const VM_FLAGS_USER_REMAP: ::c_int = VM_FLAGS_FIXED | VM_FLAGS_ANYWHERE | ++ VM_FLAGS_RANDOM_ADDR | ++ VM_FLAGS_OVERWRITE | ++ VM_FLAGS_RETURN_DATA_ADDR | ++ VM_FLAGS_RESILIENT_CODESIGN; ++ ++pub const VM_FLAGS_SUPERPAGE_SHIFT: ::c_int = 16; ++pub const SUPERPAGE_NONE: ::c_int = 0; ++pub const SUPERPAGE_SIZE_ANY: ::c_int = 1; ++pub const VM_FLAGS_SUPERPAGE_NONE: ::c_int = SUPERPAGE_NONE << ++ VM_FLAGS_SUPERPAGE_SHIFT; ++pub const VM_FLAGS_SUPERPAGE_SIZE_ANY: ::c_int = SUPERPAGE_SIZE_ANY << ++ VM_FLAGS_SUPERPAGE_SHIFT; ++pub const SUPERPAGE_SIZE_2MB: ::c_int = 2; ++pub const VM_FLAGS_SUPERPAGE_SIZE_2MB: ::c_int = SUPERPAGE_SIZE_2MB << ++ VM_FLAGS_SUPERPAGE_SHIFT; ++ ++pub const VM_MEMORY_MALLOC: ::c_int = 1; ++pub const VM_MEMORY_MALLOC_SMALL: ::c_int = 2; ++pub const VM_MEMORY_MALLOC_LARGE: ::c_int = 3; ++pub const VM_MEMORY_MALLOC_HUGE: ::c_int = 4; ++pub const VM_MEMORY_SBRK: ::c_int = 5; ++pub const VM_MEMORY_REALLOC: ::c_int = 6; ++pub const VM_MEMORY_MALLOC_TINY: ::c_int = 7; ++pub const VM_MEMORY_MALLOC_LARGE_REUSABLE: ::c_int = 8; ++pub const VM_MEMORY_MALLOC_LARGE_REUSED: ::c_int = 9; ++pub const VM_MEMORY_ANALYSIS_TOOL: ::c_int = 10; ++pub const VM_MEMORY_MALLOC_NANO: ::c_int = 11; ++pub const VM_MEMORY_MACH_MSG: ::c_int = 20; ++pub const VM_MEMORY_IOKIT: ::c_int = 21; ++pub const VM_MEMORY_STACK: ::c_int = 30; ++pub const VM_MEMORY_GUARD: ::c_int = 31; ++pub const VM_MEMORY_SHARED_PMAP: ::c_int = 32; ++pub const VM_MEMORY_DYLIB: ::c_int = 33; ++pub const VM_MEMORY_OBJC_DISPATCHERS: ::c_int = 34; ++pub const VM_MEMORY_UNSHARED_PMAP: ::c_int = 35; ++pub const VM_MEMORY_APPKIT: ::c_int = 40; ++pub const VM_MEMORY_FOUNDATION: ::c_int = 41; ++pub const VM_MEMORY_COREGRAPHICS: ::c_int = 42; ++pub const VM_MEMORY_CORESERVICES: ::c_int = 43; ++pub const VM_MEMORY_CARBON: ::c_int = VM_MEMORY_CORESERVICES; ++pub const VM_MEMORY_JAVA: ::c_int = 44; ++pub const VM_MEMORY_COREDATA: ::c_int = 45; ++pub const VM_MEMORY_COREDATA_OBJECTIDS: ::c_int = 46; ++pub const VM_MEMORY_ATS: ::c_int = 50; ++pub const VM_MEMORY_LAYERKIT: ::c_int = 51; ++pub const VM_MEMORY_CGIMAGE: ::c_int = 52; ++pub const VM_MEMORY_TCMALLOC: ::c_int = 53; ++pub const VM_MEMORY_COREGRAPHICS_DATA: ::c_int = 54; ++pub const VM_MEMORY_COREGRAPHICS_SHARED: ::c_int = 55; ++pub const VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS: ::c_int = 56; ++pub const VM_MEMORY_COREGRAPHICS_BACKINGSTORES: ::c_int = 57; ++pub const VM_MEMORY_COREGRAPHICS_XALLOC: ::c_int = 58; ++pub const VM_MEMORY_COREGRAPHICS_MISC: ::c_int = VM_MEMORY_COREGRAPHICS; ++pub const VM_MEMORY_DYLD: ::c_int = 60; ++pub const VM_MEMORY_DYLD_MALLOC: ::c_int = 61; ++pub const VM_MEMORY_SQLITE: ::c_int = 62; ++pub const VM_MEMORY_JAVASCRIPT_CORE: ::c_int = 63; ++pub const VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR: ::c_int = 64; ++pub const VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE: ::c_int = 65; ++pub const VM_MEMORY_GLSL: ::c_int = 66; ++pub const VM_MEMORY_OPENCL: ::c_int = 67; ++pub const VM_MEMORY_COREIMAGE: ::c_int = 68; ++pub const VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS: ::c_int = 69; ++pub const VM_MEMORY_IMAGEIO: ::c_int = 70; ++pub const VM_MEMORY_COREPROFILE: ::c_int = 71; ++pub const VM_MEMORY_ASSETSD: ::c_int = 72; ++pub const VM_MEMORY_OS_ALLOC_ONCE: ::c_int = 73; ++pub const VM_MEMORY_LIBDISPATCH: ::c_int = 74; ++pub const VM_MEMORY_ACCELERATE: ::c_int = 75; ++pub const VM_MEMORY_COREUI: ::c_int = 76; ++pub const VM_MEMORY_COREUIFILE: ::c_int = 77; ++pub const VM_MEMORY_GENEALOGY: ::c_int = 78; ++pub const VM_MEMORY_RAWCAMERA: ::c_int = 79; ++pub const VM_MEMORY_CORPSEINFO: ::c_int = 80; ++pub const VM_MEMORY_ASL: ::c_int = 81; ++pub const VM_MEMORY_SWIFT_RUNTIME: ::c_int = 82; ++pub const VM_MEMORY_SWIFT_METADATA: ::c_int = 83; ++pub const VM_MEMORY_DHMM: ::c_int = 84; ++pub const VM_MEMORY_SCENEKIT: ::c_int = 86; ++pub const VM_MEMORY_SKYWALK: ::c_int = 87; ++pub const VM_MEMORY_APPLICATION_SPECIFIC_1: ::c_int = 240; ++pub const VM_MEMORY_APPLICATION_SPECIFIC_16: ::c_int = 255; ++ ++pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const MS_ASYNC: ::c_int = 0x0001; ++pub const MS_INVALIDATE: ::c_int = 0x0002; ++pub const MS_SYNC: ::c_int = 0x0010; ++ ++pub const MS_KILLPAGES: ::c_int = 0x0004; ++pub const MS_DEACTIVATE: ::c_int = 0x0008; ++ ++pub const EPERM: ::c_int = 1; ++pub const ENOENT: ::c_int = 2; ++pub const ESRCH: ::c_int = 3; ++pub const EINTR: ::c_int = 4; ++pub const EIO: ::c_int = 5; ++pub const ENXIO: ::c_int = 6; ++pub const E2BIG: ::c_int = 7; ++pub const ENOEXEC: ::c_int = 8; ++pub const EBADF: ::c_int = 9; ++pub const ECHILD: ::c_int = 10; ++pub const EDEADLK: ::c_int = 11; ++pub const ENOMEM: ::c_int = 12; ++pub const EACCES: ::c_int = 13; ++pub const EFAULT: ::c_int = 14; ++pub const ENOTBLK: ::c_int = 15; ++pub const EBUSY: ::c_int = 16; ++pub const EEXIST: ::c_int = 17; ++pub const EXDEV: ::c_int = 18; ++pub const ENODEV: ::c_int = 19; ++pub const ENOTDIR: ::c_int = 20; ++pub const EISDIR: ::c_int = 21; ++pub const EINVAL: ::c_int = 22; ++pub const ENFILE: ::c_int = 23; ++pub const EMFILE: ::c_int = 24; ++pub const ENOTTY: ::c_int = 25; ++pub const ETXTBSY: ::c_int = 26; ++pub const EFBIG: ::c_int = 27; ++pub const ENOSPC: ::c_int = 28; ++pub const ESPIPE: ::c_int = 29; ++pub const EROFS: ::c_int = 30; ++pub const EMLINK: ::c_int = 31; ++pub const EPIPE: ::c_int = 32; ++pub const EDOM: ::c_int = 33; ++pub const ERANGE: ::c_int = 34; ++pub const EAGAIN: ::c_int = 35; ++pub const EWOULDBLOCK: ::c_int = EAGAIN; ++pub const EINPROGRESS: ::c_int = 36; ++pub const EALREADY: ::c_int = 37; ++pub const ENOTSOCK: ::c_int = 38; ++pub const EDESTADDRREQ: ::c_int = 39; ++pub const EMSGSIZE: ::c_int = 40; ++pub const EPROTOTYPE: ::c_int = 41; ++pub const ENOPROTOOPT: ::c_int = 42; ++pub const EPROTONOSUPPORT: ::c_int = 43; ++pub const ESOCKTNOSUPPORT: ::c_int = 44; ++pub const ENOTSUP: ::c_int = 45; ++pub const EPFNOSUPPORT: ::c_int = 46; ++pub const EAFNOSUPPORT: ::c_int = 47; ++pub const EADDRINUSE: ::c_int = 48; ++pub const EADDRNOTAVAIL: ::c_int = 49; ++pub const ENETDOWN: ::c_int = 50; ++pub const ENETUNREACH: ::c_int = 51; ++pub const ENETRESET: ::c_int = 52; ++pub const ECONNABORTED: ::c_int = 53; ++pub const ECONNRESET: ::c_int = 54; ++pub const ENOBUFS: ::c_int = 55; ++pub const EISCONN: ::c_int = 56; ++pub const ENOTCONN: ::c_int = 57; ++pub const ESHUTDOWN: ::c_int = 58; ++pub const ETOOMANYREFS: ::c_int = 59; ++pub const ETIMEDOUT: ::c_int = 60; ++pub const ECONNREFUSED: ::c_int = 61; ++pub const ELOOP: ::c_int = 62; ++pub const ENAMETOOLONG: ::c_int = 63; ++pub const EHOSTDOWN: ::c_int = 64; ++pub const EHOSTUNREACH: ::c_int = 65; ++pub const ENOTEMPTY: ::c_int = 66; ++pub const EPROCLIM: ::c_int = 67; ++pub const EUSERS: ::c_int = 68; ++pub const EDQUOT: ::c_int = 69; ++pub const ESTALE: ::c_int = 70; ++pub const EREMOTE: ::c_int = 71; ++pub const EBADRPC: ::c_int = 72; ++pub const ERPCMISMATCH: ::c_int = 73; ++pub const EPROGUNAVAIL: ::c_int = 74; ++pub const EPROGMISMATCH: ::c_int = 75; ++pub const EPROCUNAVAIL: ::c_int = 76; ++pub const ENOLCK: ::c_int = 77; ++pub const ENOSYS: ::c_int = 78; ++pub const EFTYPE: ::c_int = 79; ++pub const EAUTH: ::c_int = 80; ++pub const ENEEDAUTH: ::c_int = 81; ++pub const EPWROFF: ::c_int = 82; ++pub const EDEVERR: ::c_int = 83; ++pub const EOVERFLOW: ::c_int = 84; ++pub const EBADEXEC: ::c_int = 85; ++pub const EBADARCH: ::c_int = 86; ++pub const ESHLIBVERS: ::c_int = 87; ++pub const EBADMACHO: ::c_int = 88; ++pub const ECANCELED: ::c_int = 89; ++pub const EIDRM: ::c_int = 90; ++pub const ENOMSG: ::c_int = 91; ++pub const EILSEQ: ::c_int = 92; ++pub const ENOATTR: ::c_int = 93; ++pub const EBADMSG: ::c_int = 94; ++pub const EMULTIHOP: ::c_int = 95; ++pub const ENODATA: ::c_int = 96; ++pub const ENOLINK: ::c_int = 97; ++pub const ENOSR: ::c_int = 98; ++pub const ENOSTR: ::c_int = 99; ++pub const EPROTO: ::c_int = 100; ++pub const ETIME: ::c_int = 101; ++pub const EOPNOTSUPP: ::c_int = 102; ++pub const ENOPOLICY: ::c_int = 103; ++pub const ENOTRECOVERABLE: ::c_int = 104; ++pub const EOWNERDEAD: ::c_int = 105; ++pub const EQFULL: ::c_int = 106; ++pub const ELAST: ::c_int = 106; ++ ++pub const EAI_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 AT_FDCWD: ::c_int = -2; ++pub const AT_EACCESS: ::c_int = 0x0010; ++pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x0020; ++pub const AT_SYMLINK_FOLLOW: ::c_int = 0x0040; ++pub const AT_REMOVEDIR: ::c_int = 0x0080; ++ ++pub const TIOCMODG: ::c_ulong = 0x40047403; ++pub const TIOCMODS: ::c_ulong = 0x80047404; ++pub const TIOCM_LE: ::c_int = 0x1; ++pub const TIOCM_DTR: ::c_int = 0x2; ++pub const TIOCM_RTS: ::c_int = 0x4; ++pub const TIOCM_ST: ::c_int = 0x8; ++pub const TIOCM_SR: ::c_int = 0x10; ++pub const TIOCM_CTS: ::c_int = 0x20; ++pub const TIOCM_CAR: ::c_int = 0x40; ++pub const TIOCM_CD: ::c_int = 0x40; ++pub const TIOCM_RNG: ::c_int = 0x80; ++pub const TIOCM_RI: ::c_int = 0x80; ++pub const TIOCM_DSR: ::c_int = 0x100; ++pub const TIOCEXCL: ::c_int = 0x2000740d; ++pub const TIOCNXCL: ::c_int = 0x2000740e; ++pub const TIOCFLUSH: ::c_ulong = 0x80047410; ++pub const TIOCGETD: ::c_ulong = 0x4004741a; ++pub const TIOCSETD: ::c_ulong = 0x8004741b; ++pub const TIOCIXON: ::c_uint = 0x20007481; ++pub const TIOCIXOFF: ::c_uint = 0x20007480; ++pub const TIOCSBRK: ::c_uint = 0x2000747b; ++pub const TIOCCBRK: ::c_uint = 0x2000747a; ++pub const TIOCSDTR: ::c_uint = 0x20007479; ++pub const TIOCCDTR: ::c_uint = 0x20007478; ++pub const TIOCGPGRP: ::c_ulong = 0x40047477; ++pub const TIOCSPGRP: ::c_ulong = 0x80047476; ++pub const TIOCOUTQ: ::c_ulong = 0x40047473; ++pub const TIOCSTI: ::c_ulong = 0x80017472; ++pub const TIOCNOTTY: ::c_uint = 0x20007471; ++pub const TIOCPKT: ::c_ulong = 0x80047470; ++pub const TIOCPKT_DATA: ::c_int = 0x0; ++pub const TIOCPKT_FLUSHREAD: ::c_int = 0x1; ++pub const TIOCPKT_FLUSHWRITE: ::c_int = 0x2; ++pub const TIOCPKT_STOP: ::c_int = 0x4; ++pub const TIOCPKT_START: ::c_int = 0x8; ++pub const TIOCPKT_NOSTOP: ::c_int = 0x10; ++pub const TIOCPKT_DOSTOP: ::c_int = 0x20; ++pub const TIOCPKT_IOCTL: ::c_int = 0x40; ++pub const TIOCSTOP: ::c_uint = 0x2000746f; ++pub const TIOCSTART: ::c_uint = 0x2000746e; ++pub const TIOCMSET: ::c_ulong = 0x8004746d; ++pub const TIOCMBIS: ::c_ulong = 0x8004746c; ++pub const TIOCMBIC: ::c_ulong = 0x8004746b; ++pub const TIOCMGET: ::c_ulong = 0x4004746a; ++pub const TIOCREMOTE: ::c_ulong = 0x80047469; ++pub const TIOCGWINSZ: ::c_ulong = 0x40087468; ++pub const TIOCSWINSZ: ::c_ulong = 0x80087467; ++pub const TIOCUCNTL: ::c_ulong = 0x80047466; ++pub const TIOCSTAT: ::c_uint = 0x20007465; ++pub const TIOCSCONS: ::c_uint = 0x20007463; ++pub const TIOCCONS: ::c_ulong = 0x80047462; ++pub const TIOCSCTTY: ::c_uint = 0x20007461; ++pub const TIOCEXT: ::c_ulong = 0x80047460; ++pub const TIOCSIG: ::c_uint = 0x2000745f; ++pub const TIOCDRAIN: ::c_uint = 0x2000745e; ++pub const TIOCMSDTRWAIT: ::c_ulong = 0x8004745b; ++pub const TIOCMGDTRWAIT: ::c_ulong = 0x4004745a; ++pub const TIOCSDRAINWAIT: ::c_ulong = 0x80047457; ++pub const TIOCGDRAINWAIT: ::c_ulong = 0x40047456; ++pub const TIOCDSIMICROCODE: ::c_uint = 0x20007455; ++pub const TIOCPTYGRANT: ::c_uint = 0x20007454; ++pub const TIOCPTYGNAME: ::c_uint = 0x40807453; ++pub const TIOCPTYUNLK: ::c_uint = 0x20007452; ++ ++pub const B0: speed_t = 0; ++pub const B50: speed_t = 50; ++pub const B75: speed_t = 75; ++pub const B110: speed_t = 110; ++pub const B134: speed_t = 134; ++pub const B150: speed_t = 150; ++pub const B200: speed_t = 200; ++pub const B300: speed_t = 300; ++pub const B600: speed_t = 600; ++pub const B1200: speed_t = 1200; ++pub const B1800: speed_t = 1800; ++pub const B2400: speed_t = 2400; ++pub const B4800: speed_t = 4800; ++pub const B9600: speed_t = 9600; ++pub const B19200: speed_t = 19200; ++pub const B38400: speed_t = 38400; ++pub const B7200: speed_t = 7200; ++pub const B14400: speed_t = 14400; ++pub const B28800: speed_t = 28800; ++pub const B57600: speed_t = 57600; ++pub const B76800: speed_t = 76800; ++pub const B115200: speed_t = 115200; ++pub const B230400: speed_t = 230400; ++pub const EXTA: speed_t = 19200; ++pub const EXTB: speed_t = 38400; ++ ++pub const SIGTRAP: ::c_int = 5; ++ ++pub const GLOB_APPEND : ::c_int = 0x0001; ++pub const GLOB_DOOFFS : ::c_int = 0x0002; ++pub const GLOB_ERR : ::c_int = 0x0004; ++pub const GLOB_MARK : ::c_int = 0x0008; ++pub const GLOB_NOCHECK : ::c_int = 0x0010; ++pub const GLOB_NOSORT : ::c_int = 0x0020; ++pub const GLOB_NOESCAPE: ::c_int = 0x2000; ++ ++pub const GLOB_NOSPACE : ::c_int = -1; ++pub const GLOB_ABORTED : ::c_int = -2; ++pub const GLOB_NOMATCH : ::c_int = -3; ++ ++pub const POSIX_MADV_NORMAL: ::c_int = 0; ++pub const POSIX_MADV_RANDOM: ::c_int = 1; ++pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; ++pub const POSIX_MADV_WILLNEED: ::c_int = 3; ++pub const POSIX_MADV_DONTNEED: ::c_int = 4; ++ ++pub const _SC_IOV_MAX: ::c_int = 56; ++pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70; ++pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71; ++pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; ++pub const _SC_MQ_PRIO_MAX: ::c_int = 75; ++pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 82; ++pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 83; ++pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 85; ++pub const _SC_THREAD_KEYS_MAX: ::c_int = 86; ++pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 87; ++pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 88; ++pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 89; ++pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 90; ++pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 91; ++pub const _SC_THREAD_STACK_MIN: ::c_int = 93; ++pub const _SC_THREAD_THREADS_MAX: ::c_int = 94; ++pub const _SC_THREADS: ::c_int = 96; ++pub const _SC_TTY_NAME_MAX: ::c_int = 101; ++pub const _SC_ATEXIT_MAX: ::c_int = 107; ++pub const _SC_XOPEN_CRYPT: ::c_int = 108; ++pub const _SC_XOPEN_ENH_I18N: ::c_int = 109; ++pub const _SC_XOPEN_LEGACY: ::c_int = 110; ++pub const _SC_XOPEN_REALTIME: ::c_int = 111; ++pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 112; ++pub const _SC_XOPEN_SHM: ::c_int = 113; ++pub const _SC_XOPEN_UNIX: ::c_int = 115; ++pub const _SC_XOPEN_VERSION: ::c_int = 116; ++pub const _SC_XOPEN_XCU_VERSION: ::c_int = 121; ++ ++pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 2; ++pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; ++pub const PTHREAD_CREATE_JOINABLE: ::c_int = 1; ++pub const PTHREAD_CREATE_DETACHED: ::c_int = 2; ++pub const PTHREAD_STACK_MIN: ::size_t = 8192; ++ ++pub const RLIMIT_CPU: ::c_int = 0; ++pub const RLIMIT_FSIZE: ::c_int = 1; ++pub const RLIMIT_DATA: ::c_int = 2; ++pub const RLIMIT_STACK: ::c_int = 3; ++pub const RLIMIT_CORE: ::c_int = 4; ++pub const RLIMIT_AS: ::c_int = 5; ++pub const RLIMIT_RSS: ::c_int = RLIMIT_AS; ++pub const RLIMIT_MEMLOCK: ::c_int = 6; ++pub const RLIMIT_NPROC: ::c_int = 7; ++pub const RLIMIT_NOFILE: ::c_int = 8; ++pub const RLIM_NLIMITS: ::c_int = 9; ++pub const _RLIMIT_POSIX_FLAG: ::c_int = 0x1000; ++ ++pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; ++ ++pub const RUSAGE_SELF: ::c_int = 0; ++pub const RUSAGE_CHILDREN: ::c_int = -1; ++ ++pub const MADV_NORMAL: ::c_int = 0; ++pub const MADV_RANDOM: ::c_int = 1; ++pub const MADV_SEQUENTIAL: ::c_int = 2; ++pub const MADV_WILLNEED: ::c_int = 3; ++pub const MADV_DONTNEED: ::c_int = 4; ++pub const MADV_FREE: ::c_int = 5; ++pub const MADV_ZERO_WIRED_PAGES: ::c_int = 6; ++pub const MADV_FREE_REUSABLE: ::c_int = 7; ++pub const MADV_FREE_REUSE: ::c_int = 8; ++pub const MADV_CAN_REUSE: ::c_int = 9; ++ ++pub const MINCORE_INCORE: ::c_int = 0x1; ++pub const MINCORE_REFERENCED: ::c_int = 0x2; ++pub const MINCORE_MODIFIED: ::c_int = 0x4; ++pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; ++pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; ++ ++// ++// sys/netinet/in.h ++// Protocols (RFC 1700) ++// NOTE: These are in addition to the constants defined in src/unix/mod.rs ++ ++// IPPROTO_IP defined in src/unix/mod.rs ++/// IP6 hop-by-hop options ++pub const IPPROTO_HOPOPTS: ::c_int = 0; ++// IPPROTO_ICMP defined in src/unix/mod.rs ++/// group mgmt protocol ++pub const IPPROTO_IGMP: ::c_int = 2; ++/// gateway^2 (deprecated) ++pub const IPPROTO_GGP: ::c_int = 3; ++/// for compatibility ++pub const IPPROTO_IPIP: ::c_int = 4; ++// IPPROTO_TCP defined in src/unix/mod.rs ++/// Stream protocol II. ++pub const IPPROTO_ST: ::c_int = 7; ++/// exterior gateway protocol ++pub const IPPROTO_EGP: ::c_int = 8; ++/// private interior gateway ++pub const IPPROTO_PIGP: ::c_int = 9; ++/// BBN RCC Monitoring ++pub const IPPROTO_RCCMON: ::c_int = 10; ++/// network voice protocol ++pub const IPPROTO_NVPII: ::c_int = 11; ++/// pup ++pub const IPPROTO_PUP: ::c_int = 12; ++/// Argus ++pub const IPPROTO_ARGUS: ::c_int = 13; ++/// EMCON ++pub const IPPROTO_EMCON: ::c_int = 14; ++/// Cross Net Debugger ++pub const IPPROTO_XNET: ::c_int = 15; ++/// Chaos ++pub const IPPROTO_CHAOS: ::c_int = 16; ++// IPPROTO_UDP defined in src/unix/mod.rs ++/// Multiplexing ++pub const IPPROTO_MUX: ::c_int = 18; ++/// DCN Measurement Subsystems ++pub const IPPROTO_MEAS: ::c_int = 19; ++/// Host Monitoring ++pub const IPPROTO_HMP: ::c_int = 20; ++/// Packet Radio Measurement ++pub const IPPROTO_PRM: ::c_int = 21; ++/// xns idp ++pub const IPPROTO_IDP: ::c_int = 22; ++/// Trunk-1 ++pub const IPPROTO_TRUNK1: ::c_int = 23; ++/// Trunk-2 ++pub const IPPROTO_TRUNK2: ::c_int = 24; ++/// Leaf-1 ++pub const IPPROTO_LEAF1: ::c_int = 25; ++/// Leaf-2 ++pub const IPPROTO_LEAF2: ::c_int = 26; ++/// Reliable Data ++pub const IPPROTO_RDP: ::c_int = 27; ++/// Reliable Transaction ++pub const IPPROTO_IRTP: ::c_int = 28; ++/// tp-4 w/ class negotiation ++pub const IPPROTO_TP: ::c_int = 29; ++/// Bulk Data Transfer ++pub const IPPROTO_BLT: ::c_int = 30; ++/// Network Services ++pub const IPPROTO_NSP: ::c_int = 31; ++/// Merit Internodal ++pub const IPPROTO_INP: ::c_int = 32; ++/// Sequential Exchange ++pub const IPPROTO_SEP: ::c_int = 33; ++/// Third Party Connect ++pub const IPPROTO_3PC: ::c_int = 34; ++/// InterDomain Policy Routing ++pub const IPPROTO_IDPR: ::c_int = 35; ++/// XTP ++pub const IPPROTO_XTP: ::c_int = 36; ++/// Datagram Delivery ++pub const IPPROTO_DDP: ::c_int = 37; ++/// Control Message Transport ++pub const IPPROTO_CMTP: ::c_int = 38; ++/// TP++ Transport ++pub const IPPROTO_TPXX: ::c_int = 39; ++/// IL transport protocol ++pub const IPPROTO_IL: ::c_int = 40; ++// IPPROTO_IPV6 defined in src/unix/mod.rs ++/// Source Demand Routing ++pub const IPPROTO_SDRP: ::c_int = 42; ++/// IP6 routing header ++pub const IPPROTO_ROUTING: ::c_int = 43; ++/// IP6 fragmentation header ++pub const IPPROTO_FRAGMENT: ::c_int = 44; ++/// InterDomain Routing ++pub const IPPROTO_IDRP: ::c_int = 45; ++/// resource reservation ++pub const IPPROTO_RSVP: ::c_int = 46; ++/// General Routing Encap. ++pub const IPPROTO_GRE: ::c_int = 47; ++/// Mobile Host Routing ++pub const IPPROTO_MHRP: ::c_int = 48; ++/// BHA ++pub const IPPROTO_BHA: ::c_int = 49; ++/// IP6 Encap Sec. Payload ++pub const IPPROTO_ESP: ::c_int = 50; ++/// IP6 Auth Header ++pub const IPPROTO_AH: ::c_int = 51; ++/// Integ. Net Layer Security ++pub const IPPROTO_INLSP: ::c_int = 52; ++/// IP with encryption ++pub const IPPROTO_SWIPE: ::c_int = 53; ++/// Next Hop Resolution ++pub const IPPROTO_NHRP: ::c_int = 54; ++/* 55-57: Unassigned */ ++// IPPROTO_ICMPV6 defined in src/unix/mod.rs ++/// IP6 no next header ++pub const IPPROTO_NONE: ::c_int = 59; ++/// IP6 destination option ++pub const IPPROTO_DSTOPTS: ::c_int = 60; ++/// any host internal protocol ++pub const IPPROTO_AHIP: ::c_int = 61; ++/// CFTP ++pub const IPPROTO_CFTP: ::c_int = 62; ++/// "hello" routing protocol ++pub const IPPROTO_HELLO: ::c_int = 63; ++/// SATNET/Backroom EXPAK ++pub const IPPROTO_SATEXPAK: ::c_int = 64; ++/// Kryptolan ++pub const IPPROTO_KRYPTOLAN: ::c_int = 65; ++/// Remote Virtual Disk ++pub const IPPROTO_RVD: ::c_int = 66; ++/// Pluribus Packet Core ++pub const IPPROTO_IPPC: ::c_int = 67; ++/// Any distributed FS ++pub const IPPROTO_ADFS: ::c_int = 68; ++/// Satnet Monitoring ++pub const IPPROTO_SATMON: ::c_int = 69; ++/// VISA Protocol ++pub const IPPROTO_VISA: ::c_int = 70; ++/// Packet Core Utility ++pub const IPPROTO_IPCV: ::c_int = 71; ++/// Comp. Prot. Net. Executive ++pub const IPPROTO_CPNX: ::c_int = 72; ++/// Comp. Prot. HeartBeat ++pub const IPPROTO_CPHB: ::c_int = 73; ++/// Wang Span Network ++pub const IPPROTO_WSN: ::c_int = 74; ++/// Packet Video Protocol ++pub const IPPROTO_PVP: ::c_int = 75; ++/// BackRoom SATNET Monitoring ++pub const IPPROTO_BRSATMON: ::c_int = 76; ++/// Sun net disk proto (temp.) ++pub const IPPROTO_ND: ::c_int = 77; ++/// WIDEBAND Monitoring ++pub const IPPROTO_WBMON: ::c_int = 78; ++/// WIDEBAND EXPAK ++pub const IPPROTO_WBEXPAK: ::c_int = 79; ++/// ISO cnlp ++pub const IPPROTO_EON: ::c_int = 80; ++/// VMTP ++pub const IPPROTO_VMTP: ::c_int = 81; ++/// Secure VMTP ++pub const IPPROTO_SVMTP: ::c_int = 82; ++/// Banyon VINES ++pub const IPPROTO_VINES: ::c_int = 83; ++/// TTP ++pub const IPPROTO_TTP: ::c_int = 84; ++/// NSFNET-IGP ++pub const IPPROTO_IGP: ::c_int = 85; ++/// dissimilar gateway prot. ++pub const IPPROTO_DGP: ::c_int = 86; ++/// TCF ++pub const IPPROTO_TCF: ::c_int = 87; ++/// Cisco/GXS IGRP ++pub const IPPROTO_IGRP: ::c_int = 88; ++/// OSPFIGP ++pub const IPPROTO_OSPFIGP: ::c_int = 89; ++/// Strite RPC protocol ++pub const IPPROTO_SRPC: ::c_int = 90; ++/// Locus Address Resoloution ++pub const IPPROTO_LARP: ::c_int = 91; ++/// Multicast Transport ++pub const IPPROTO_MTP: ::c_int = 92; ++/// AX.25 Frames ++pub const IPPROTO_AX25: ::c_int = 93; ++/// IP encapsulated in IP ++pub const IPPROTO_IPEIP: ::c_int = 94; ++/// Mobile Int.ing control ++pub const IPPROTO_MICP: ::c_int = 95; ++/// Semaphore Comm. security ++pub const IPPROTO_SCCSP: ::c_int = 96; ++/// Ethernet IP encapsulation ++pub const IPPROTO_ETHERIP: ::c_int = 97; ++/// encapsulation header ++pub const IPPROTO_ENCAP: ::c_int = 98; ++/// any private encr. scheme ++pub const IPPROTO_APES: ::c_int = 99; ++/// GMTP ++pub const IPPROTO_GMTP: ::c_int = 100; ++ ++/* 101-254: Partly Unassigned */ ++/// Protocol Independent Mcast ++pub const IPPROTO_PIM: ::c_int = 103; ++/// payload compression (IPComp) ++pub const IPPROTO_IPCOMP: ::c_int = 108; ++/// PGM ++pub const IPPROTO_PGM: ::c_int = 113; ++/// SCTP ++pub const IPPROTO_SCTP: ::c_int = 132; ++ ++/* 255: Reserved */ ++/* BSD Private, local use, namespace incursion */ ++/// divert pseudo-protocol ++pub const IPPROTO_DIVERT: ::c_int = 254; ++/// raw IP packet ++pub const IPPROTO_RAW: ::c_int = 255; ++pub const IPPROTO_MAX: ::c_int = 256; ++/// last return value of *_input(), meaning "all job for this pkt is done". ++pub const IPPROTO_DONE: ::c_int = 257; ++ ++pub const AF_UNSPEC: ::c_int = 0; ++pub const AF_LOCAL: ::c_int = 1; ++pub const AF_UNIX: ::c_int = AF_LOCAL; ++pub const AF_INET: ::c_int = 2; ++pub const AF_IMPLINK: ::c_int = 3; ++pub const AF_PUP: ::c_int = 4; ++pub const AF_CHAOS: ::c_int = 5; ++pub const AF_NS: ::c_int = 6; ++pub const AF_ISO: ::c_int = 7; ++pub const AF_OSI: ::c_int = AF_ISO; ++pub const AF_ECMA: ::c_int = 8; ++pub const AF_DATAKIT: ::c_int = 9; ++pub const AF_CCITT: ::c_int = 10; ++pub const AF_SNA: ::c_int = 11; ++pub const AF_DECnet: ::c_int = 12; ++pub const AF_DLI: ::c_int = 13; ++pub const AF_LAT: ::c_int = 14; ++pub const AF_HYLINK: ::c_int = 15; ++pub const AF_APPLETALK: ::c_int = 16; ++pub const AF_ROUTE: ::c_int = 17; ++pub const AF_LINK: ::c_int = 18; ++pub const pseudo_AF_XTP: ::c_int = 19; ++pub const AF_COIP: ::c_int = 20; ++pub const AF_CNT: ::c_int = 21; ++pub const pseudo_AF_RTIP: ::c_int = 22; ++pub const AF_IPX: ::c_int = 23; ++pub const AF_SIP: ::c_int = 24; ++pub const pseudo_AF_PIP: ::c_int = 25; ++pub const AF_ISDN: ::c_int = 28; ++pub const AF_E164: ::c_int = AF_ISDN; ++pub const pseudo_AF_KEY: ::c_int = 29; ++pub const AF_INET6: ::c_int = 30; ++pub const AF_NATM: ::c_int = 31; ++pub const AF_SYSTEM: ::c_int = 32; ++pub const AF_NETBIOS: ::c_int = 33; ++pub const AF_PPP: ::c_int = 34; ++pub const pseudo_AF_HDRCMPLT: ::c_int = 35; ++#[doc(hidden)] ++pub const AF_MAX: ::c_int = 40; ++pub const AF_SYS_CONTROL: ::c_int = 2; ++ ++pub const SYSPROTO_EVENT: ::c_int = 1; ++pub const SYSPROTO_CONTROL: ::c_int = 2; ++ ++pub const PF_UNSPEC: ::c_int = AF_UNSPEC; ++pub const PF_LOCAL: ::c_int = AF_LOCAL; ++pub const PF_UNIX: ::c_int = PF_LOCAL; ++pub const PF_INET: ::c_int = AF_INET; ++pub const PF_IMPLINK: ::c_int = AF_IMPLINK; ++pub const PF_PUP: ::c_int = AF_PUP; ++pub const PF_CHAOS: ::c_int = AF_CHAOS; ++pub const PF_NS: ::c_int = AF_NS; ++pub const PF_ISO: ::c_int = AF_ISO; ++pub const PF_OSI: ::c_int = AF_ISO; ++pub const PF_ECMA: ::c_int = AF_ECMA; ++pub const PF_DATAKIT: ::c_int = AF_DATAKIT; ++pub const PF_CCITT: ::c_int = AF_CCITT; ++pub const PF_SNA: ::c_int = AF_SNA; ++pub const PF_DECnet: ::c_int = AF_DECnet; ++pub const PF_DLI: ::c_int = AF_DLI; ++pub const PF_LAT: ::c_int = AF_LAT; ++pub const PF_HYLINK: ::c_int = AF_HYLINK; ++pub const PF_APPLETALK: ::c_int = AF_APPLETALK; ++pub const PF_ROUTE: ::c_int = AF_ROUTE; ++pub const PF_LINK: ::c_int = AF_LINK; ++pub const PF_XTP: ::c_int = pseudo_AF_XTP; ++pub const PF_COIP: ::c_int = AF_COIP; ++pub const PF_CNT: ::c_int = AF_CNT; ++pub const PF_SIP: ::c_int = AF_SIP; ++pub const PF_IPX: ::c_int = AF_IPX; ++pub const PF_RTIP: ::c_int = pseudo_AF_RTIP; ++pub const PF_PIP: ::c_int = pseudo_AF_PIP; ++pub const PF_ISDN: ::c_int = AF_ISDN; ++pub const PF_KEY: ::c_int = pseudo_AF_KEY; ++pub const PF_INET6: ::c_int = AF_INET6; ++pub const PF_NATM: ::c_int = AF_NATM; ++pub const PF_SYSTEM: ::c_int = AF_SYSTEM; ++pub const PF_NETBIOS: ::c_int = AF_NETBIOS; ++pub const PF_PPP: ::c_int = AF_PPP; ++#[doc(hidden)] ++pub const PF_MAX: ::c_int = AF_MAX; ++ ++#[doc(hidden)] ++pub const NET_MAXID: ::c_int = AF_MAX; ++ ++pub const NET_RT_DUMP: ::c_int = 1; ++pub const NET_RT_FLAGS: ::c_int = 2; ++pub const NET_RT_IFLIST: ::c_int = 3; ++#[doc(hidden)] ++pub const NET_RT_MAXID: ::c_int = 10; ++ ++pub const SOMAXCONN: ::c_int = 128; ++ ++pub const SOCK_MAXADDRLEN: ::c_int = 255; ++ ++pub const SOCK_STREAM: ::c_int = 1; ++pub const SOCK_DGRAM: ::c_int = 2; ++pub const SOCK_RAW: ::c_int = 3; ++pub const SOCK_RDM: ::c_int = 4; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++pub const IP_TTL: ::c_int = 4; ++pub const IP_HDRINCL: ::c_int = 2; ++pub const IP_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_TIMESTAMP: ::c_int = 0x0400; ++pub const SO_TIMESTAMP_MONOTONIC: ::c_int = 0x0800; ++pub const SO_DONTTRUNC: ::c_int = 0x2000; ++pub const SO_WANTMORE: ::c_int = 0x4000; ++pub const SO_WANTOOBFLAG: ::c_int = 0x8000; ++pub const SO_SNDBUF: ::c_int = 0x1001; ++pub const SO_RCVBUF: ::c_int = 0x1002; ++pub const SO_SNDLOWAT: ::c_int = 0x1003; ++pub const SO_RCVLOWAT: ::c_int = 0x1004; ++pub const SO_SNDTIMEO: ::c_int = 0x1005; ++pub const SO_RCVTIMEO: ::c_int = 0x1006; ++pub const SO_ERROR: ::c_int = 0x1007; ++pub const SO_TYPE: ::c_int = 0x1008; ++pub const SO_LABEL: ::c_int = 0x1010; ++pub const SO_PEERLABEL: ::c_int = 0x1011; ++pub const SO_NREAD: ::c_int = 0x1020; ++pub const SO_NKE: ::c_int = 0x1021; ++pub const SO_NOSIGPIPE: ::c_int = 0x1022; ++pub const SO_NOADDRERR: ::c_int = 0x1023; ++pub const SO_NWRITE: ::c_int = 0x1024; ++pub const SO_REUSESHAREUID: ::c_int = 0x1025; ++pub const SO_NOTIFYCONFLICT: ::c_int = 0x1026; ++pub const SO_RANDOMPORT: ::c_int = 0x1082; ++pub const SO_NP_EXTENSIONS: ::c_int = 0x1083; ++ ++pub const MSG_OOB: ::c_int = 0x1; ++pub const MSG_PEEK: ::c_int = 0x2; ++pub const MSG_DONTROUTE: ::c_int = 0x4; ++pub const MSG_EOR: ::c_int = 0x8; ++pub const MSG_TRUNC: ::c_int = 0x10; ++pub const MSG_CTRUNC: ::c_int = 0x20; ++pub const MSG_WAITALL: ::c_int = 0x40; ++pub const MSG_DONTWAIT: ::c_int = 0x80; ++pub const MSG_EOF: ::c_int = 0x100; ++pub const MSG_FLUSH: ::c_int = 0x400; ++pub const MSG_HOLD: ::c_int = 0x800; ++pub const MSG_SEND: ::c_int = 0x1000; ++pub const MSG_HAVEMORE: ::c_int = 0x2000; ++pub const MSG_RCVMORE: ::c_int = 0x4000; ++// pub const MSG_COMPAT: ::c_int = 0x8000; ++ ++pub const SCM_TIMESTAMP: ::c_int = 0x02; ++pub const SCM_CREDS: ::c_int = 0x03; ++ ++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 MAP_COPY: ::c_int = 0x0002; ++pub const MAP_RENAME: ::c_int = 0x0020; ++pub const MAP_NORESERVE: ::c_int = 0x0040; ++pub const MAP_NOEXTEND: ::c_int = 0x0100; ++pub const MAP_HASSEMAPHORE: ::c_int = 0x0200; ++pub const MAP_NOCACHE: ::c_int = 0x0400; ++pub const MAP_JIT: ::c_int = 0x0800; ++ ++pub const _SC_ARG_MAX: ::c_int = 1; ++pub const _SC_CHILD_MAX: ::c_int = 2; ++pub const _SC_CLK_TCK: ::c_int = 3; ++pub const _SC_NGROUPS_MAX: ::c_int = 4; ++pub const _SC_OPEN_MAX: ::c_int = 5; ++pub const _SC_JOB_CONTROL: ::c_int = 6; ++pub const _SC_SAVED_IDS: ::c_int = 7; ++pub const _SC_VERSION: ::c_int = 8; ++pub const _SC_BC_BASE_MAX: ::c_int = 9; ++pub const _SC_BC_DIM_MAX: ::c_int = 10; ++pub const _SC_BC_SCALE_MAX: ::c_int = 11; ++pub const _SC_BC_STRING_MAX: ::c_int = 12; ++pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13; ++pub const _SC_EXPR_NEST_MAX: ::c_int = 14; ++pub const _SC_LINE_MAX: ::c_int = 15; ++pub const _SC_RE_DUP_MAX: ::c_int = 16; ++pub const _SC_2_VERSION: ::c_int = 17; ++pub const _SC_2_C_BIND: ::c_int = 18; ++pub const _SC_2_C_DEV: ::c_int = 19; ++pub const _SC_2_CHAR_TERM: ::c_int = 20; ++pub const _SC_2_FORT_DEV: ::c_int = 21; ++pub const _SC_2_FORT_RUN: ::c_int = 22; ++pub const _SC_2_LOCALEDEF: ::c_int = 23; ++pub const _SC_2_SW_DEV: ::c_int = 24; ++pub const _SC_2_UPE: ::c_int = 25; ++pub const _SC_STREAM_MAX: ::c_int = 26; ++pub const _SC_TZNAME_MAX: ::c_int = 27; ++pub const _SC_ASYNCHRONOUS_IO: ::c_int = 28; ++pub const _SC_PAGESIZE: ::c_int = 29; ++pub const _SC_MEMLOCK: ::c_int = 30; ++pub const _SC_MEMLOCK_RANGE: ::c_int = 31; ++pub const _SC_MEMORY_PROTECTION: ::c_int = 32; ++pub const _SC_MESSAGE_PASSING: ::c_int = 33; ++pub const _SC_PRIORITIZED_IO: ::c_int = 34; ++pub const _SC_PRIORITY_SCHEDULING: ::c_int = 35; ++pub const _SC_REALTIME_SIGNALS: ::c_int = 36; ++pub const _SC_SEMAPHORES: ::c_int = 37; ++pub const _SC_FSYNC: ::c_int = 38; ++pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 39; ++pub const _SC_SYNCHRONIZED_IO: ::c_int = 40; ++pub const _SC_TIMERS: ::c_int = 41; ++pub const _SC_AIO_LISTIO_MAX: ::c_int = 42; ++pub const _SC_AIO_MAX: ::c_int = 43; ++pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44; ++pub const _SC_DELAYTIMER_MAX: ::c_int = 45; ++pub const _SC_MQ_OPEN_MAX: ::c_int = 46; ++pub const _SC_MAPPED_FILES: ::c_int = 47; ++pub const _SC_RTSIG_MAX: ::c_int = 48; ++pub const _SC_SEM_NSEMS_MAX: ::c_int = 49; ++pub const _SC_SEM_VALUE_MAX: ::c_int = 50; ++pub const _SC_SIGQUEUE_MAX: ::c_int = 51; ++pub const _SC_TIMER_MAX: ::c_int = 52; ++pub const _SC_NPROCESSORS_CONF: ::c_int = 57; ++pub const _SC_NPROCESSORS_ONLN: ::c_int = 58; ++pub const _SC_2_PBS: ::c_int = 59; ++pub const _SC_2_PBS_ACCOUNTING: ::c_int = 60; ++pub const _SC_2_PBS_CHECKPOINT: ::c_int = 61; ++pub const _SC_2_PBS_LOCATE: ::c_int = 62; ++pub const _SC_2_PBS_MESSAGE: ::c_int = 63; ++pub const _SC_2_PBS_TRACK: ::c_int = 64; ++pub const _SC_ADVISORY_INFO: ::c_int = 65; ++pub const _SC_BARRIERS: ::c_int = 66; ++pub const _SC_CLOCK_SELECTION: ::c_int = 67; ++pub const _SC_CPUTIME: ::c_int = 68; ++pub const _SC_FILE_LOCKING: ::c_int = 69; ++pub const _SC_HOST_NAME_MAX: ::c_int = 72; ++pub const _SC_MONOTONIC_CLOCK: ::c_int = 74; ++pub const _SC_READER_WRITER_LOCKS: ::c_int = 76; ++pub const _SC_REGEXP: ::c_int = 77; ++pub const _SC_SHELL: ::c_int = 78; ++pub const _SC_SPAWN: ::c_int = 79; ++pub const _SC_SPIN_LOCKS: ::c_int = 80; ++pub const _SC_SPORADIC_SERVER: ::c_int = 81; ++pub const _SC_THREAD_CPUTIME: ::c_int = 84; ++pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 92; ++pub const _SC_TIMEOUTS: ::c_int = 95; ++pub const _SC_TRACE: ::c_int = 97; ++pub const _SC_TRACE_EVENT_FILTER: ::c_int = 98; ++pub const _SC_TRACE_INHERIT: ::c_int = 99; ++pub const _SC_TRACE_LOG: ::c_int = 100; ++pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 102; ++pub const _SC_V6_ILP32_OFF32: ::c_int = 103; ++pub const _SC_V6_ILP32_OFFBIG: ::c_int = 104; ++pub const _SC_V6_LP64_OFF64: ::c_int = 105; ++pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 106; ++pub const _SC_IPV6: ::c_int = 118; ++pub const _SC_RAW_SOCKETS: ::c_int = 119; ++pub const _SC_SYMLOOP_MAX: ::c_int = 120; ++pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; ++pub const _SC_XOPEN_STREAMS: ::c_int = 114; ++pub const _SC_XBS5_ILP32_OFF32: ::c_int = 122; ++pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 123; ++pub const _SC_XBS5_LP64_OFF64: ::c_int = 124; ++pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 125; ++pub const _SC_SS_REPL_MAX: ::c_int = 126; ++pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 127; ++pub const _SC_TRACE_NAME_MAX: ::c_int = 128; ++pub const _SC_TRACE_SYS_MAX: ::c_int = 129; ++pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 130; ++pub const _SC_PASS_MAX: ::c_int = 131; ++ ++pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; ++pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; ++pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; ++pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; ++pub const _PTHREAD_MUTEX_SIG_init: ::c_long = 0x32AAABA7; ++pub const _PTHREAD_COND_SIG_init: ::c_long = 0x3CB0B1BB; ++pub const _PTHREAD_RWLOCK_SIG_init: ::c_long = 0x2DA8B3B4; ++pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ++ __sig: _PTHREAD_MUTEX_SIG_init, ++ __opaque: [0; __PTHREAD_MUTEX_SIZE__], ++}; ++pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { ++ __sig: _PTHREAD_COND_SIG_init, ++ __opaque: [0; __PTHREAD_COND_SIZE__], ++}; ++pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { ++ __sig: _PTHREAD_RWLOCK_SIG_init, ++ __opaque: [0; __PTHREAD_RWLOCK_SIZE__], ++}; ++ ++pub const SIGSTKSZ: ::size_t = 131072; ++ ++pub const FD_SETSIZE: usize = 1024; ++ ++pub const ST_NOSUID: ::c_ulong = 2; ++ ++pub const EVFILT_READ: ::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 OCRNL: ::c_int = 0x00000010; ++pub const ONOCR: ::c_int = 0x00000020; ++pub const ONLRET: ::c_int = 0x00000040; ++pub const OFILL: ::c_int = 0x00000080; ++pub const NLDLY: ::c_int = 0x00000300; ++pub const TABDLY: ::c_int = 0x00000c04; ++pub const CRDLY: ::c_int = 0x00003000; ++pub const FFDLY: ::c_int = 0x00004000; ++pub const BSDLY: ::c_int = 0x00008000; ++pub const VTDLY: ::c_int = 0x00010000; ++pub const OFDEL: ::c_int = 0x00020000; ++ ++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 PRIO_DARWIN_THREAD: ::c_int = 3; ++pub const PRIO_DARWIN_PROCESS: ::c_int = 4; ++pub const PRIO_DARWIN_BG: ::c_int = 0x1000; ++pub const PRIO_DARWIN_NONUI: ::c_int = 0x1001; ++ ++pub const SEM_FAILED: *mut sem_t = -1isize as *mut ::sem_t; ++ ++pub const SIGEV_NONE: ::c_int = 0; ++pub const SIGEV_SIGNAL: ::c_int = 1; ++pub const SIGEV_THREAD: ::c_int = 3; ++ ++pub const AIO_CANCELED: ::c_int = 2; ++pub const AIO_NOTCANCELED: ::c_int = 4; ++pub const AIO_ALLDONE: ::c_int = 1; ++pub const AIO_LISTIO_MAX: ::c_int = 16; ++pub const LIO_NOP: ::c_int = 0; ++pub const LIO_WRITE: ::c_int = 2; ++pub const LIO_READ: ::c_int = 1; ++pub const LIO_WAIT: ::c_int = 2; ++pub const LIO_NOWAIT: ::c_int = 1; ++ ++pub const WEXITED: ::c_int = 0x00000004; ++pub const WSTOPPED: ::c_int = 0x00000008; ++pub const WCONTINUED: ::c_int = 0x00000010; ++pub const WNOWAIT: ::c_int = 0x00000020; ++ ++pub const P_ALL: idtype_t = 0; ++pub const P_PID: idtype_t = 1; ++pub const P_PGID: idtype_t = 2; ++ ++pub const XATTR_NOFOLLOW: ::c_int = 0x0001; ++pub const XATTR_CREATE: ::c_int = 0x0002; ++pub const XATTR_REPLACE: ::c_int = 0x0004; ++pub const XATTR_NOSECURITY: ::c_int = 0x0008; ++pub const XATTR_NODEFAULT: ::c_int = 0x0010; ++pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020; ++ ++pub const NET_RT_IFLIST2: ::c_int = 0x0006; ++pub const RTM_IFINFO2: ::c_int = 0x0012; ++ ++pub const KERN_PROCARGS2: ::c_int = 49; ++ ++pub const PROC_PIDTASKALLINFO: ::c_int = 2; ++pub const PROC_PIDTASKINFO: ::c_int = 4; ++pub const PROC_PIDTHREADINFO: ::c_int = 5; ++pub const MAXCOMLEN: usize = 16; ++pub const MAXTHREADNAMESIZE: usize = 64; ++ ++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 aio_read(aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; ++ pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "aio_suspend$UNIX2003")] ++ pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; ++ pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, ++ nitems: ::c_int, sevp: *mut sigevent) -> ::c_int; ++ ++ pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; ++ ++ pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; ++ ++ pub fn 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 pthread_condattr_setpshared(attr: *mut pthread_condattr_t, ++ pshared: ::c_int) -> ::c_int; ++ pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, ++ pshared: *mut ::c_int) -> ::c_int; ++ pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, ++ pshared: ::c_int) -> ::c_int; ++ pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, ++ pshared: *mut ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t, ++ val: *mut ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, ++ val: ::c_int) -> ::c_int; ++ pub fn __error() -> *mut ::c_int; ++ pub fn backtrace(buf: *mut *mut ::c_void, ++ sz: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "macos", link_name = "statfs$INODE64")] ++ pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; ++ #[cfg_attr(target_os = "macos", link_name = "fstatfs$INODE64")] ++ pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; ++ pub fn kevent(kq: ::c_int, ++ changelist: *const ::kevent, ++ nchanges: ::c_int, ++ eventlist: *mut ::kevent, ++ nevents: ::c_int, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn kevent64(kq: ::c_int, ++ changelist: *const ::kevent64_s, ++ nchanges: ::c_int, ++ eventlist: *mut ::kevent64_s, ++ nevents: ::c_int, ++ flags: ::c_uint, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn mount(src: *const ::c_char, ++ target: *const ::c_char, ++ flags: ::c_int, ++ data: *mut ::c_void) -> ::c_int; ++ pub fn ptrace(request: ::c_int, ++ pid: ::pid_t, ++ addr: *mut ::c_char, ++ data: ::c_int) -> ::c_int; ++ pub fn quotactl(special: *const ::c_char, ++ cmd: ::c_int, ++ id: ::c_int, ++ data: *mut ::c_char) -> ::c_int; ++ pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; ++ pub fn sendfile(fd: ::c_int, ++ s: ::c_int, ++ offset: ::off_t, ++ len: *mut ::off_t, ++ hdtr: *mut ::sf_hdtr, ++ flags: ::c_int) -> ::c_int; ++ pub fn 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 getxattr(path: *const ::c_char, name: *const ::c_char, ++ value: *mut ::c_void, size: ::size_t, position: u32, ++ flags: ::c_int) -> ::ssize_t; ++ pub fn fgetxattr(filedes: ::c_int, name: *const ::c_char, ++ value: *mut ::c_void, size: ::size_t, position: u32, ++ flags: ::c_int) -> ::ssize_t; ++ pub fn setxattr(path: *const ::c_char, name: *const ::c_char, ++ value: *const ::c_void, size: ::size_t, position: u32, ++ flags: ::c_int) -> ::c_int; ++ pub fn fsetxattr(filedes: ::c_int, name: *const ::c_char, ++ value: *const ::c_void, size: ::size_t, position: u32, ++ flags: ::c_int) -> ::c_int; ++ pub fn listxattr(path: *const ::c_char, list: *mut ::c_char, ++ size: ::size_t, flags: ::c_int) -> ::ssize_t; ++ pub fn flistxattr(filedes: ::c_int, list: *mut ::c_char, ++ size: ::size_t, flags: ::c_int) -> ::ssize_t; ++ pub fn removexattr(path: *const ::c_char, name: *const ::c_char, ++ flags: ::c_int) -> ::c_int; ++ pub fn fremovexattr(filedes: ::c_int, name: *const ::c_char, ++ flags: ::c_int) -> ::c_int; ++ ++ pub fn getgrouplist(name: *const ::c_char, ++ basegid: ::c_int, ++ groups: *mut ::c_int, ++ ngroups: *mut ::c_int) -> ::c_int; ++ pub fn initgroups(user: *const ::c_char, basegroup: ::c_int) -> ::c_int; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "waitid$UNIX2003")] ++ pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, ++ options: ::c_int) -> ::c_int; ++ pub fn brk(addr: *const ::c_void) -> *mut ::c_void; ++ pub fn sbrk(increment: ::c_int) -> *mut ::c_void; ++ pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; ++} ++ ++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 --cc vendor/libc-0.2.31/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 000000000,000000000..ebfcd4b9d new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@@ -1,0 -1,0 +1,703 @@@ ++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; ++ ++pub type sem_t = *mut sem; ++ ++pub enum sem {} ++ ++s! { ++ ++ pub struct exit_status { ++ pub e_termination: u16, ++ pub e_exit: u16 ++ } ++ ++ pub struct utmpx { ++ pub ut_name: [::c_char; 32], ++ pub ut_id: [::c_char; 4], ++ ++ pub ut_line: [::c_char; 32], ++ pub ut_host: [::c_char; 256], ++ ++ pub ut_unused: [u8; 16], ++ pub ut_session: u16, ++ pub ut_type: u16, ++ pub ut_pid: ::pid_t, ++ ut_exit: exit_status, ++ ut_ss: ::sockaddr_storage, ++ pub ut_tv: ::timeval, ++ pub ut_unused2: [u8; 16], ++ } ++ ++ pub struct aiocb { ++ pub aio_fildes: ::c_int, ++ pub aio_offset: ::off_t, ++ pub aio_buf: *mut ::c_void, ++ pub aio_nbytes: ::size_t, ++ pub aio_sigevent: sigevent, ++ pub aio_lio_opcode: ::c_int, ++ pub aio_reqprio: ::c_int, ++ _aio_val: ::c_int, ++ _aio_err: ::c_int ++ } ++ ++ pub struct 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 sigevent { ++ pub sigev_notify: ::c_int, ++ // The union is 8-byte in size, so it is aligned at a 8-byte offset. ++ #[cfg(target_pointer_width = "64")] ++ __unused1: ::c_int, ++ pub sigev_signo: ::c_int, //actually a union ++ // pad the union ++ #[cfg(target_pointer_width = "64")] ++ __unused2: ::c_int, ++ pub sigev_value: ::sigval, ++ __unused3: *mut ::c_void //actually a function pointer ++ } ++ ++ pub struct statvfs { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_favail: ::fsfilcnt_t, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ pub f_owner: ::uid_t, ++ pub f_type: ::c_uint, ++ pub f_syncreads: u64, ++ pub f_syncwrites: u64, ++ pub f_asyncreads: u64, ++ pub f_asyncwrites: u64, ++ pub f_fsid_uuid: ::uuid_t, ++ pub f_uid_uuid: ::uuid_t, ++ } ++ ++ pub struct stat { ++ pub st_ino: ::ino_t, ++ pub st_nlink: ::nlink_t, ++ pub st_dev: ::dev_t, ++ pub st_mode: ::mode_t, ++ pub st_padding1: ::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 struct if_data { ++ pub ifi_type: ::c_uchar, ++ pub ifi_physical: ::c_uchar, ++ pub ifi_addrlen: ::c_uchar, ++ pub ifi_hdrlen: ::c_uchar, ++ pub ifi_recvquota: ::c_uchar, ++ pub ifi_xmitquota: ::c_uchar, ++ pub ifi_mtu: ::c_ulong, ++ pub ifi_metric: ::c_ulong, ++ pub ifi_link_state: ::c_ulong, ++ pub ifi_baudrate: u64, ++ pub ifi_ipackets: ::c_ulong, ++ pub ifi_ierrors: ::c_ulong, ++ pub ifi_opackets: ::c_ulong, ++ pub ifi_oerrors: ::c_ulong, ++ pub ifi_collisions: ::c_ulong, ++ pub ifi_ibytes: ::c_ulong, ++ pub ifi_obytes: ::c_ulong, ++ pub ifi_imcasts: ::c_ulong, ++ pub ifi_omcasts: ::c_ulong, ++ pub ifi_iqdrops: ::c_ulong, ++ pub ifi_noproto: ::c_ulong, ++ pub ifi_hwassist: ::c_ulong, ++ pub ifi_oqdrops: ::c_ulong, ++ pub ifi_lastchange: ::timeval, ++ } ++ ++ pub struct if_msghdr { ++ pub ifm_msglen: ::c_ushort, ++ pub ifm_version: ::c_uchar, ++ pub ifm_type: ::c_uchar, ++ pub ifm_addrs: ::c_int, ++ pub ifm_flags: ::c_int, ++ pub ifm_index: ::c_ushort, ++ pub ifm_data: if_data, ++ } ++} ++ ++pub const RAND_MAX: ::c_int = 0x7fff_ffff; ++pub const PTHREAD_STACK_MIN: ::size_t = 16384; ++pub const SIGSTKSZ: ::size_t = 40960; ++pub const MADV_INVAL: ::c_int = 10; ++pub const O_CLOEXEC: ::c_int = 0x00020000; ++pub const O_DIRECTORY: ::c_int = 0x08000000; ++pub const F_GETLK: ::c_int = 7; ++pub const F_SETLK: ::c_int = 8; ++pub const F_SETLKW: ::c_int = 9; ++pub const 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_EXCEPT: ::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 SO_SNDSPACE: ::c_int = 0x100a; ++pub const SO_CPUHINT: ::c_int = 0x1030; ++ ++// ++// sys/netinet/in.h ++// Protocols (RFC 1700) ++// NOTE: These are in addition to the constants defined in src/unix/mod.rs ++ ++// IPPROTO_IP defined in src/unix/mod.rs ++/// IP6 hop-by-hop options ++pub const IPPROTO_HOPOPTS: ::c_int = 0; ++// IPPROTO_ICMP defined in src/unix/mod.rs ++/// group mgmt protocol ++pub const IPPROTO_IGMP: ::c_int = 2; ++/// gateway^2 (deprecated) ++pub const IPPROTO_GGP: ::c_int = 3; ++/// for compatibility ++pub const IPPROTO_IPIP: ::c_int = 4; ++// IPPROTO_TCP defined in src/unix/mod.rs ++/// Stream protocol II. ++pub const IPPROTO_ST: ::c_int = 7; ++/// exterior gateway protocol ++pub const IPPROTO_EGP: ::c_int = 8; ++/// private interior gateway ++pub const IPPROTO_PIGP: ::c_int = 9; ++/// BBN RCC Monitoring ++pub const IPPROTO_RCCMON: ::c_int = 10; ++/// network voice protocol ++pub const IPPROTO_NVPII: ::c_int = 11; ++/// pup ++pub const IPPROTO_PUP: ::c_int = 12; ++/// Argus ++pub const IPPROTO_ARGUS: ::c_int = 13; ++/// EMCON ++pub const IPPROTO_EMCON: ::c_int = 14; ++/// Cross Net Debugger ++pub const IPPROTO_XNET: ::c_int = 15; ++/// Chaos ++pub const IPPROTO_CHAOS: ::c_int = 16; ++// IPPROTO_UDP defined in src/unix/mod.rs ++/// Multiplexing ++pub const IPPROTO_MUX: ::c_int = 18; ++/// DCN Measurement Subsystems ++pub const IPPROTO_MEAS: ::c_int = 19; ++/// Host Monitoring ++pub const IPPROTO_HMP: ::c_int = 20; ++/// Packet Radio Measurement ++pub const IPPROTO_PRM: ::c_int = 21; ++/// xns idp ++pub const IPPROTO_IDP: ::c_int = 22; ++/// Trunk-1 ++pub const IPPROTO_TRUNK1: ::c_int = 23; ++/// Trunk-2 ++pub const IPPROTO_TRUNK2: ::c_int = 24; ++/// Leaf-1 ++pub const IPPROTO_LEAF1: ::c_int = 25; ++/// Leaf-2 ++pub const IPPROTO_LEAF2: ::c_int = 26; ++/// Reliable Data ++pub const IPPROTO_RDP: ::c_int = 27; ++/// Reliable Transaction ++pub const IPPROTO_IRTP: ::c_int = 28; ++/// tp-4 w/ class negotiation ++pub const IPPROTO_TP: ::c_int = 29; ++/// Bulk Data Transfer ++pub const IPPROTO_BLT: ::c_int = 30; ++/// Network Services ++pub const IPPROTO_NSP: ::c_int = 31; ++/// Merit Internodal ++pub const IPPROTO_INP: ::c_int = 32; ++/// Sequential Exchange ++pub const IPPROTO_SEP: ::c_int = 33; ++/// Third Party Connect ++pub const IPPROTO_3PC: ::c_int = 34; ++/// InterDomain Policy Routing ++pub const IPPROTO_IDPR: ::c_int = 35; ++/// XTP ++pub const IPPROTO_XTP: ::c_int = 36; ++/// Datagram Delivery ++pub const IPPROTO_DDP: ::c_int = 37; ++/// Control Message Transport ++pub const IPPROTO_CMTP: ::c_int = 38; ++/// TP++ Transport ++pub const IPPROTO_TPXX: ::c_int = 39; ++/// IL transport protocol ++pub const IPPROTO_IL: ::c_int = 40; ++// IPPROTO_IPV6 defined in src/unix/mod.rs ++/// Source Demand Routing ++pub const IPPROTO_SDRP: ::c_int = 42; ++/// IP6 routing header ++pub const IPPROTO_ROUTING: ::c_int = 43; ++/// IP6 fragmentation header ++pub const IPPROTO_FRAGMENT: ::c_int = 44; ++/// InterDomain Routing ++pub const IPPROTO_IDRP: ::c_int = 45; ++/// resource reservation ++pub const IPPROTO_RSVP: ::c_int = 46; ++/// General Routing Encap. ++pub const IPPROTO_GRE: ::c_int = 47; ++/// Mobile Host Routing ++pub const IPPROTO_MHRP: ::c_int = 48; ++/// BHA ++pub const IPPROTO_BHA: ::c_int = 49; ++/// IP6 Encap Sec. Payload ++pub const IPPROTO_ESP: ::c_int = 50; ++/// IP6 Auth Header ++pub const IPPROTO_AH: ::c_int = 51; ++/// Integ. Net Layer Security ++pub const IPPROTO_INLSP: ::c_int = 52; ++/// IP with encryption ++pub const IPPROTO_SWIPE: ::c_int = 53; ++/// Next Hop Resolution ++pub const IPPROTO_NHRP: ::c_int = 54; ++/// IP Mobility ++pub const IPPROTO_MOBILE: ::c_int = 55; ++/// Transport Layer Security ++pub const IPPROTO_TLSP: ::c_int = 56; ++/// SKIP ++pub const IPPROTO_SKIP: ::c_int = 57; ++// IPPROTO_ICMPV6 defined in src/unix/mod.rs ++/// IP6 no next header ++pub const IPPROTO_NONE: ::c_int = 59; ++/// IP6 destination option ++pub const IPPROTO_DSTOPTS: ::c_int = 60; ++/// any host internal protocol ++pub const IPPROTO_AHIP: ::c_int = 61; ++/// CFTP ++pub const IPPROTO_CFTP: ::c_int = 62; ++/// "hello" routing protocol ++pub const IPPROTO_HELLO: ::c_int = 63; ++/// SATNET/Backroom EXPAK ++pub const IPPROTO_SATEXPAK: ::c_int = 64; ++/// Kryptolan ++pub const IPPROTO_KRYPTOLAN: ::c_int = 65; ++/// Remote Virtual Disk ++pub const IPPROTO_RVD: ::c_int = 66; ++/// Pluribus Packet Core ++pub const IPPROTO_IPPC: ::c_int = 67; ++/// Any distributed FS ++pub const IPPROTO_ADFS: ::c_int = 68; ++/// Satnet Monitoring ++pub const IPPROTO_SATMON: ::c_int = 69; ++/// VISA Protocol ++pub const IPPROTO_VISA: ::c_int = 70; ++/// Packet Core Utility ++pub const IPPROTO_IPCV: ::c_int = 71; ++/// Comp. Prot. Net. Executive ++pub const IPPROTO_CPNX: ::c_int = 72; ++/// Comp. Prot. HeartBeat ++pub const IPPROTO_CPHB: ::c_int = 73; ++/// Wang Span Network ++pub const IPPROTO_WSN: ::c_int = 74; ++/// Packet Video Protocol ++pub const IPPROTO_PVP: ::c_int = 75; ++/// BackRoom SATNET Monitoring ++pub const IPPROTO_BRSATMON: ::c_int = 76; ++/// Sun net disk proto (temp.) ++pub const IPPROTO_ND: ::c_int = 77; ++/// WIDEBAND Monitoring ++pub const IPPROTO_WBMON: ::c_int = 78; ++/// WIDEBAND EXPAK ++pub const IPPROTO_WBEXPAK: ::c_int = 79; ++/// ISO cnlp ++pub const IPPROTO_EON: ::c_int = 80; ++/// VMTP ++pub const IPPROTO_VMTP: ::c_int = 81; ++/// Secure VMTP ++pub const IPPROTO_SVMTP: ::c_int = 82; ++/// Banyon VINES ++pub const IPPROTO_VINES: ::c_int = 83; ++/// TTP ++pub const IPPROTO_TTP: ::c_int = 84; ++/// NSFNET-IGP ++pub const IPPROTO_IGP: ::c_int = 85; ++/// dissimilar gateway prot. ++pub const IPPROTO_DGP: ::c_int = 86; ++/// TCF ++pub const IPPROTO_TCF: ::c_int = 87; ++/// Cisco/GXS IGRP ++pub const IPPROTO_IGRP: ::c_int = 88; ++/// OSPFIGP ++pub const IPPROTO_OSPFIGP: ::c_int = 89; ++/// Strite RPC protocol ++pub const IPPROTO_SRPC: ::c_int = 90; ++/// Locus Address Resoloution ++pub const IPPROTO_LARP: ::c_int = 91; ++/// Multicast Transport ++pub const IPPROTO_MTP: ::c_int = 92; ++/// AX.25 Frames ++pub const IPPROTO_AX25: ::c_int = 93; ++/// IP encapsulated in IP ++pub const IPPROTO_IPEIP: ::c_int = 94; ++/// Mobile Int.ing control ++pub const IPPROTO_MICP: ::c_int = 95; ++/// Semaphore Comm. security ++pub const IPPROTO_SCCSP: ::c_int = 96; ++/// Ethernet IP encapsulation ++pub const IPPROTO_ETHERIP: ::c_int = 97; ++/// encapsulation header ++pub const IPPROTO_ENCAP: ::c_int = 98; ++/// any private encr. scheme ++pub const IPPROTO_APES: ::c_int = 99; ++/// GMTP ++pub const IPPROTO_GMTP: ::c_int = 100; ++/// payload compression (IPComp) ++pub const IPPROTO_IPCOMP: ::c_int = 108; ++ ++/* 101-254: Partly Unassigned */ ++/// Protocol Independent Mcast ++pub const IPPROTO_PIM: ::c_int = 103; ++/// CARP ++pub const IPPROTO_CARP: ::c_int = 112; ++/// PGM ++pub const IPPROTO_PGM: ::c_int = 113; ++/// PFSYNC ++pub const IPPROTO_PFSYNC: ::c_int = 240; ++ ++/* 255: Reserved */ ++/* BSD Private, local use, namespace incursion, no longer used */ ++/// divert pseudo-protocol ++pub const IPPROTO_DIVERT: ::c_int = 254; ++pub const IPPROTO_MAX: ::c_int = 256; ++/// last return value of *_input(), meaning "all job for this pkt is done". ++pub const IPPROTO_DONE: ::c_int = 257; ++ ++/// Used by RSS: the layer3 protocol is unknown ++pub const IPPROTO_UNKNOWN: ::c_int = 258; ++ ++pub const AF_BLUETOOTH: ::c_int = 33; ++pub const AF_MPLS: ::c_int = 34; ++pub const AF_IEEE80211: ::c_int = 35; ++pub const AF_MAX: ::c_int = 36; ++ ++pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; ++pub const PF_MAX: ::c_int = AF_MAX; ++ ++pub const NET_RT_DUMP: ::c_int = 1; ++pub const NET_RT_FLAGS: ::c_int = 2; ++pub const NET_RT_IFLIST: ::c_int = 3; ++pub const NET_RT_MAXID: ::c_int = 4; ++ ++pub const SOMAXOPT_SIZE: ::c_int = 65536; ++ ++#[doc(hidden)] ++pub const NET_MAXID: ::c_int = AF_MAX; ++ ++pub const MSG_UNUSED09: ::c_int = 0x00000200; ++pub const MSG_NOSIGNAL: ::c_int = 0x00000400; ++pub const MSG_SYNC: ::c_int = 0x00000800; ++pub const MSG_CMSG_CLOEXEC: ::c_int = 0x00001000; ++pub const MSG_FBLOCKING: ::c_int = 0x00010000; ++pub const MSG_FNONBLOCKING: ::c_int = 0x00020000; ++pub const MSG_FMASK: ::c_int = 0xFFFF0000; ++ ++pub const EMPTY: ::c_short = 0; ++pub const RUN_LVL: ::c_short = 1; ++pub const BOOT_TIME: ::c_short = 2; ++pub const OLD_TIME: ::c_short = 3; ++pub const NEW_TIME: ::c_short = 4; ++pub const INIT_PROCESS: ::c_short = 5; ++pub const LOGIN_PROCESS: ::c_short = 6; ++pub const USER_PROCESS: ::c_short = 7; ++pub const DEAD_PROCESS: ::c_short = 8; ++ ++pub const LC_COLLATE_MASK: ::c_int = (1 << 0); ++pub const LC_CTYPE_MASK: ::c_int = (1 << 1); ++pub const LC_MONETARY_MASK: ::c_int = (1 << 2); ++pub const LC_NUMERIC_MASK: ::c_int = (1 << 3); ++pub const LC_TIME_MASK: ::c_int = (1 << 4); ++pub const LC_MESSAGES_MASK: ::c_int = (1 << 5); ++pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK ++ | LC_CTYPE_MASK ++ | LC_MESSAGES_MASK ++ | LC_MONETARY_MASK ++ | LC_NUMERIC_MASK ++ | LC_TIME_MASK; ++ ++pub const TIOCSIG: ::c_uint = 0x2000745f; ++pub const BTUARTDISC: ::c_int = 0x7; ++pub const TIOCDCDTIMESTAMP: ::c_uint = 0x40107458; ++pub const TIOCISPTMASTER: ::c_uint = 0x20007455; ++pub const TIOCMODG: ::c_uint = 0x40047403; ++pub const TIOCMODS: ::c_ulong = 0x80047404; ++pub const TIOCREMOTE: ::c_ulong = 0x80047469; ++ ++// Constants used by "at" family of system calls. ++pub const AT_FDCWD: ::c_int = 0xFFFAFDCD; // invalid file descriptor ++pub const AT_SYMLINK_NOFOLLOW: ::c_int = 1; ++pub const AT_REMOVEDIR: ::c_int = 2; ++pub const AT_EACCESS: ::c_int = 4; ++pub const AT_SYMLINK_FOLLOW: ::c_int = 8; ++ ++pub const VCHECKPT: usize = 19; ++ ++pub const _PC_2_SYMLINKS: ::c_int = 22; ++pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 23; ++ ++pub const _SC_V7_ILP32_OFF32: ::c_int = 122; ++pub const _SC_V7_ILP32_OFFBIG: ::c_int = 123; ++pub const _SC_V7_LP64_OFF64: ::c_int = 124; ++pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 125; ++pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 126; ++pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 127; ++ ++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; ++ pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; ++ ++ pub fn setutxdb(_type: ::c_uint, file: *mut ::c_char) -> ::c_int; ++ ++ pub fn aio_waitcomplete(iocbp: *mut *mut aiocb, ++ timeout: *mut ::timespec) -> ::c_int; ++ ++ pub fn freelocale(loc: ::locale_t); ++} diff --cc vendor/libc-0.2.31/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 000000000,000000000..3d61f889d new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@@ -1,0 -1,0 +1,32 @@@ ++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, ++ } ++} ++ ++pub const MAP_32BIT: ::c_int = 0x00080000; diff --cc vendor/libc-0.2.31/src/unix/bsd/freebsdlike/freebsd/mod.rs index 000000000,000000000..2fe221422 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/freebsdlike/freebsd/mod.rs @@@ -1,0 -1,0 +1,834 @@@ ++pub type fflags_t = u32; ++pub type clock_t = i32; ++pub type ino_t = u32; ++pub type lwpid_t = i32; ++pub type nlink_t = u16; ++pub type blksize_t = u32; ++pub type clockid_t = ::c_int; ++pub type sem_t = _sem; ++ ++pub type fsblkcnt_t = ::uint64_t; ++pub type fsfilcnt_t = ::uint64_t; ++pub type idtype_t = ::c_uint; ++ ++pub type key_t = ::c_long; ++pub type msglen_t = ::c_ulong; ++pub type msgqnum_t = ::c_ulong; ++ ++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 aiocb { ++ pub aio_fildes: ::c_int, ++ pub aio_offset: ::off_t, ++ pub aio_buf: *mut ::c_void, ++ pub aio_nbytes: ::size_t, ++ __unused1: [::c_int; 2], ++ __unused2: *mut ::c_void, ++ pub aio_lio_opcode: ::c_int, ++ pub aio_reqprio: ::c_int, ++ // unused 3 through 5 are the __aiocb_private structure ++ __unused3: ::c_long, ++ __unused4: ::c_long, ++ __unused5: *mut ::c_void, ++ pub aio_sigevent: sigevent ++ } ++ ++ pub struct 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 jail { ++ pub version: u32, ++ pub path: *mut ::c_char, ++ pub hostname: *mut ::c_char, ++ pub jailname: *mut ::c_char, ++ pub ip4s: ::c_uint, ++ pub ip6s: ::c_uint, ++ pub ip4: *mut ::in_addr, ++ pub ip6: *mut ::in6_addr, ++ } ++ ++ pub struct sigevent { ++ pub sigev_notify: ::c_int, ++ pub sigev_signo: ::c_int, ++ pub sigev_value: ::sigval, ++ //The rest of the structure is actually a union. We expose only ++ //sigev_notify_thread_id because it's the most useful union member. ++ pub sigev_notify_thread_id: ::lwpid_t, ++ #[cfg(target_pointer_width = "64")] ++ __unused1: ::c_int, ++ __unused2: [::c_long; 7] ++ } ++ ++ pub struct statvfs { ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_favail: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_bsize: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_fsid: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ } ++ ++ // internal structure has changed over time ++ pub struct _sem { ++ data: [u32; 4], ++ } ++ ++ pub struct ipc_perm { ++ pub cuid: ::uid_t, ++ pub cgid: ::gid_t, ++ pub uid: ::uid_t, ++ pub gid: ::gid_t, ++ pub mode: ::mode_t, ++ pub seq: ::c_ushort, ++ pub key: ::key_t, ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ __unused1: *mut ::c_void, ++ __unused2: *mut ::c_void, ++ pub msg_cbytes: ::msglen_t, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ pub msg_stime: ::time_t, ++ pub msg_rtime: ::time_t, ++ pub msg_ctime: ::time_t, ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_cpid: ::pid_t, ++ pub shm_nattch: ::c_int, ++ pub shm_atime: ::time_t, ++ pub shm_dtime: ::time_t, ++ pub shm_ctime: ::time_t, ++ } ++} ++ ++pub const SIGEV_THREAD_ID: ::c_int = 4; ++ ++pub const RAND_MAX: ::c_int = 0x7fff_fffd; ++pub const PTHREAD_STACK_MIN: ::size_t = 2048; ++pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4; ++pub const SIGSTKSZ: ::size_t = 34816; ++pub const SF_NODISKIO: ::c_int = 0x00000001; ++pub const SF_MNOWAIT: ::c_int = 0x00000002; ++pub const SF_SYNC: ::c_int = 0x00000004; ++pub const O_CLOEXEC: ::c_int = 0x00100000; ++pub const O_DIRECTORY: ::c_int = 0x00020000; ++pub const O_EXEC: ::c_int = 0x00040000; ++pub const O_TTY_INIT: ::c_int = 0x00080000; ++pub const F_GETLK: ::c_int = 11; ++pub const F_SETLK: ::c_int = 12; ++pub const F_SETLKW: ::c_int = 13; ++pub const 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 POLLINIGNEOF: ::c_short = 0x2000; ++ ++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 KERN_OSTYPE: ::c_int = 1; ++pub const KERN_OSRELEASE: ::c_int = 2; ++pub const KERN_OSREV: ::c_int = 3; ++pub const KERN_VERSION: ::c_int = 4; ++pub const KERN_MAXVNODES: ::c_int = 5; ++pub const KERN_MAXPROC: ::c_int = 6; ++pub const KERN_MAXFILES: ::c_int = 7; ++pub const KERN_ARGMAX: ::c_int = 8; ++pub const KERN_SECURELVL: ::c_int = 9; ++pub const KERN_HOSTNAME: ::c_int = 10; ++pub const KERN_HOSTID: ::c_int = 11; ++pub const KERN_CLOCKRATE: ::c_int = 12; ++pub const KERN_VNODE: ::c_int = 13; ++pub const KERN_PROC: ::c_int = 14; ++pub const KERN_FILE: ::c_int = 15; ++pub const KERN_PROF: ::c_int = 16; ++pub const KERN_POSIX1: ::c_int = 17; ++pub const KERN_NGROUPS: ::c_int = 18; ++pub const KERN_JOB_CONTROL: ::c_int = 19; ++pub const KERN_SAVED_IDS: ::c_int = 20; ++pub const KERN_BOOTTIME: ::c_int = 21; ++pub const KERN_NISDOMAINNAME: ::c_int = 22; ++pub const KERN_UPDATEINTERVAL: ::c_int = 23; ++pub const KERN_OSRELDATE: ::c_int = 24; ++pub const KERN_NTP_PLL: ::c_int = 25; ++pub const KERN_BOOTFILE: ::c_int = 26; ++pub const KERN_MAXFILESPERPROC: ::c_int = 27; ++pub const KERN_MAXPROCPERUID: ::c_int = 28; ++pub const KERN_DUMPDEV: ::c_int = 29; ++pub const KERN_IPC: ::c_int = 30; ++pub const KERN_DUMMY: ::c_int = 31; ++pub const KERN_PS_STRINGS: ::c_int = 32; ++pub const KERN_USRSTACK: ::c_int = 33; ++pub const KERN_LOGSIGEXIT: ::c_int = 34; ++pub const KERN_IOV_MAX: ::c_int = 35; ++pub const KERN_HOSTUUID: ::c_int = 36; ++pub const KERN_ARND: ::c_int = 37; ++pub const KERN_PROC_ALL: ::c_int = 0; ++pub const KERN_PROC_PID: ::c_int = 1; ++pub const KERN_PROC_PGRP: ::c_int = 2; ++pub const KERN_PROC_SESSION: ::c_int = 3; ++pub const KERN_PROC_TTY: ::c_int = 4; ++pub const KERN_PROC_UID: ::c_int = 5; ++pub const KERN_PROC_RUID: ::c_int = 6; ++pub const KERN_PROC_ARGS: ::c_int = 7; ++pub const KERN_PROC_PROC: ::c_int = 8; ++pub const KERN_PROC_SV_NAME: ::c_int = 9; ++pub const KERN_PROC_RGID: ::c_int = 10; ++pub const KERN_PROC_GID: ::c_int = 11; ++pub const KERN_PROC_PATHNAME: ::c_int = 12; ++pub const KERN_PROC_OVMMAP: ::c_int = 13; ++pub const KERN_PROC_OFILEDESC: ::c_int = 14; ++pub const KERN_PROC_KSTACK: ::c_int = 15; ++pub const KERN_PROC_INC_THREAD: ::c_int = 0x10; ++pub const KERN_PROC_VMMAP: ::c_int = 32; ++pub const KERN_PROC_FILEDESC: ::c_int = 33; ++pub const KERN_PROC_GROUPS: ::c_int = 34; ++pub const KERN_PROC_ENV: ::c_int = 35; ++pub const KERN_PROC_AUXV: ::c_int = 36; ++pub const KERN_PROC_RLIMIT: ::c_int = 37; ++pub const KERN_PROC_PS_STRINGS: ::c_int = 38; ++pub const KERN_PROC_UMASK: ::c_int = 39; ++pub const KERN_PROC_OSREL: ::c_int = 40; ++pub const KERN_PROC_SIGTRAMP: ::c_int = 41; ++pub const KIPC_MAXSOCKBUF: ::c_int = 1; ++pub const KIPC_SOCKBUF_WASTE: ::c_int = 2; ++pub const KIPC_SOMAXCONN: ::c_int = 3; ++pub const KIPC_MAX_LINKHDR: ::c_int = 4; ++pub const KIPC_MAX_PROTOHDR: ::c_int = 5; ++pub const KIPC_MAX_HDR: ::c_int = 6; ++pub const KIPC_MAX_DATALEN: ::c_int = 7; ++pub const HW_MACHINE: ::c_int = 1; ++pub const HW_MODEL: ::c_int = 2; ++pub const HW_NCPU: ::c_int = 3; ++pub const HW_BYTEORDER: ::c_int = 4; ++pub const HW_PHYSMEM: ::c_int = 5; ++pub const HW_USERMEM: ::c_int = 6; ++pub const HW_PAGESIZE: ::c_int = 7; ++pub const HW_DISKNAMES: ::c_int = 8; ++pub const HW_DISKSTATS: ::c_int = 9; ++pub const HW_FLOATINGPT: ::c_int = 10; ++pub const HW_MACHINE_ARCH: ::c_int = 11; ++pub const HW_REALMEM: ::c_int = 12; ++pub const USER_CS_PATH: ::c_int = 1; ++pub const USER_BC_BASE_MAX: ::c_int = 2; ++pub const USER_BC_DIM_MAX: ::c_int = 3; ++pub const USER_BC_SCALE_MAX: ::c_int = 4; ++pub const USER_BC_STRING_MAX: ::c_int = 5; ++pub const USER_COLL_WEIGHTS_MAX: ::c_int = 6; ++pub const USER_EXPR_NEST_MAX: ::c_int = 7; ++pub const USER_LINE_MAX: ::c_int = 8; ++pub const USER_RE_DUP_MAX: ::c_int = 9; ++pub const USER_POSIX2_VERSION: ::c_int = 10; ++pub const USER_POSIX2_C_BIND: ::c_int = 11; ++pub const USER_POSIX2_C_DEV: ::c_int = 12; ++pub const USER_POSIX2_CHAR_TERM: ::c_int = 13; ++pub const USER_POSIX2_FORT_DEV: ::c_int = 14; ++pub const USER_POSIX2_FORT_RUN: ::c_int = 15; ++pub const USER_POSIX2_LOCALEDEF: ::c_int = 16; ++pub const USER_POSIX2_SW_DEV: ::c_int = 17; ++pub const USER_POSIX2_UPE: ::c_int = 18; ++pub const USER_STREAM_MAX: ::c_int = 19; ++pub const USER_TZNAME_MAX: ::c_int = 20; ++pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1; ++pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2; ++pub const CTL_P1003_1B_MEMLOCK: ::c_int = 3; ++pub const CTL_P1003_1B_MEMLOCK_RANGE: ::c_int = 4; ++pub const CTL_P1003_1B_MEMORY_PROTECTION: ::c_int = 5; ++pub const CTL_P1003_1B_MESSAGE_PASSING: ::c_int = 6; ++pub const CTL_P1003_1B_PRIORITIZED_IO: ::c_int = 7; ++pub const CTL_P1003_1B_PRIORITY_SCHEDULING: ::c_int = 8; ++pub const CTL_P1003_1B_REALTIME_SIGNALS: ::c_int = 9; ++pub const CTL_P1003_1B_SEMAPHORES: ::c_int = 10; ++pub const CTL_P1003_1B_FSYNC: ::c_int = 11; ++pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: ::c_int = 12; ++pub const CTL_P1003_1B_SYNCHRONIZED_IO: ::c_int = 13; ++pub const CTL_P1003_1B_TIMERS: ::c_int = 14; ++pub const CTL_P1003_1B_AIO_LISTIO_MAX: ::c_int = 15; ++pub const CTL_P1003_1B_AIO_MAX: ::c_int = 16; ++pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: ::c_int = 17; ++pub const CTL_P1003_1B_DELAYTIMER_MAX: ::c_int = 18; ++pub const CTL_P1003_1B_MQ_OPEN_MAX: ::c_int = 19; ++pub const CTL_P1003_1B_PAGESIZE: ::c_int = 20; ++pub const CTL_P1003_1B_RTSIG_MAX: ::c_int = 21; ++pub const CTL_P1003_1B_SEM_NSEMS_MAX: ::c_int = 22; ++pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23; ++pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24; ++pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25; ++pub const TIOCGPTN: ::c_uint = 0x4004740f; ++pub const TIOCPTMASTER: ::c_uint = 0x2000741c; ++pub const TIOCSIG: ::c_uint = 0x2004745f; ++pub const TIOCM_DCD: ::c_int = 0x40; ++pub const H4DISC: ::c_int = 0x7; ++ ++pub const JAIL_API_VERSION: u32 = 2; ++pub const JAIL_CREATE: ::c_int = 0x01; ++pub const JAIL_UPDATE: ::c_int = 0x02; ++pub const JAIL_ATTACH: ::c_int = 0x04; ++pub const JAIL_DYING: ::c_int = 0x08; ++pub const JAIL_SET_MASK: ::c_int = 0x0f; ++pub const JAIL_GET_MASK: ::c_int = 0x08; ++pub const JAIL_SYS_DISABLE: ::c_int = 0; ++pub const JAIL_SYS_NEW: ::c_int = 1; ++pub const JAIL_SYS_INHERIT: ::c_int = 2; ++ ++pub const SO_BINTIME: ::c_int = 0x2000; ++pub const SO_NO_OFFLOAD: ::c_int = 0x4000; ++pub const SO_NO_DDP: ::c_int = 0x8000; ++pub const SO_LABEL: ::c_int = 0x1009; ++pub const SO_PEERLABEL: ::c_int = 0x1010; ++pub const SO_LISTENQLIMIT: ::c_int = 0x1011; ++pub const SO_LISTENQLEN: ::c_int = 0x1012; ++pub const SO_LISTENINCQLEN: ::c_int = 0x1013; ++pub const SO_SETFIB: ::c_int = 0x1014; ++pub const SO_USER_COOKIE: ::c_int = 0x1015; ++pub const SO_PROTOCOL: ::c_int = 0x1016; ++pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL; ++pub const SO_VENDOR: ::c_int = 0x80000000; ++ ++pub const AF_SLOW: ::c_int = 33; ++pub const AF_SCLUSTER: ::c_int = 34; ++pub const AF_ARP: ::c_int = 35; ++pub const AF_BLUETOOTH: ::c_int = 36; ++pub const AF_IEEE80211: ::c_int = 37; ++pub const AF_INET_SDP: ::c_int = 40; ++pub const AF_INET6_SDP: ::c_int = 42; ++#[doc(hidden)] ++pub const AF_MAX: ::c_int = 42; ++ ++// sys/netinet/in.h ++// Protocols (RFC 1700) ++// NOTE: These are in addition to the constants defined in src/unix/mod.rs ++ ++// IPPROTO_IP defined in src/unix/mod.rs ++/// IP6 hop-by-hop options ++pub const IPPROTO_HOPOPTS: ::c_int = 0; ++// IPPROTO_ICMP defined in src/unix/mod.rs ++/// group mgmt protocol ++pub const IPPROTO_IGMP: ::c_int = 2; ++/// gateway^2 (deprecated) ++pub const IPPROTO_GGP: ::c_int = 3; ++/// for compatibility ++pub const IPPROTO_IPIP: ::c_int = 4; ++// IPPROTO_TCP defined in src/unix/mod.rs ++/// Stream protocol II. ++pub const IPPROTO_ST: ::c_int = 7; ++/// exterior gateway protocol ++pub const IPPROTO_EGP: ::c_int = 8; ++/// private interior gateway ++pub const IPPROTO_PIGP: ::c_int = 9; ++/// BBN RCC Monitoring ++pub const IPPROTO_RCCMON: ::c_int = 10; ++/// network voice protocol ++pub const IPPROTO_NVPII: ::c_int = 11; ++/// pup ++pub const IPPROTO_PUP: ::c_int = 12; ++/// Argus ++pub const IPPROTO_ARGUS: ::c_int = 13; ++/// EMCON ++pub const IPPROTO_EMCON: ::c_int = 14; ++/// Cross Net Debugger ++pub const IPPROTO_XNET: ::c_int = 15; ++/// Chaos ++pub const IPPROTO_CHAOS: ::c_int = 16; ++// IPPROTO_UDP defined in src/unix/mod.rs ++/// Multiplexing ++pub const IPPROTO_MUX: ::c_int = 18; ++/// DCN Measurement Subsystems ++pub const IPPROTO_MEAS: ::c_int = 19; ++/// Host Monitoring ++pub const IPPROTO_HMP: ::c_int = 20; ++/// Packet Radio Measurement ++pub const IPPROTO_PRM: ::c_int = 21; ++/// xns idp ++pub const IPPROTO_IDP: ::c_int = 22; ++/// Trunk-1 ++pub const IPPROTO_TRUNK1: ::c_int = 23; ++/// Trunk-2 ++pub const IPPROTO_TRUNK2: ::c_int = 24; ++/// Leaf-1 ++pub const IPPROTO_LEAF1: ::c_int = 25; ++/// Leaf-2 ++pub const IPPROTO_LEAF2: ::c_int = 26; ++/// Reliable Data ++pub const IPPROTO_RDP: ::c_int = 27; ++/// Reliable Transaction ++pub const IPPROTO_IRTP: ::c_int = 28; ++/// tp-4 w/ class negotiation ++pub const IPPROTO_TP: ::c_int = 29; ++/// Bulk Data Transfer ++pub const IPPROTO_BLT: ::c_int = 30; ++/// Network Services ++pub const IPPROTO_NSP: ::c_int = 31; ++/// Merit Internodal ++pub const IPPROTO_INP: ::c_int = 32; ++/// Sequential Exchange ++pub const IPPROTO_SEP: ::c_int = 33; ++/// Third Party Connect ++pub const IPPROTO_3PC: ::c_int = 34; ++/// InterDomain Policy Routing ++pub const IPPROTO_IDPR: ::c_int = 35; ++/// XTP ++pub const IPPROTO_XTP: ::c_int = 36; ++/// Datagram Delivery ++pub const IPPROTO_DDP: ::c_int = 37; ++/// Control Message Transport ++pub const IPPROTO_CMTP: ::c_int = 38; ++/// TP++ Transport ++pub const IPPROTO_TPXX: ::c_int = 39; ++/// IL transport protocol ++pub const IPPROTO_IL: ::c_int = 40; ++// IPPROTO_IPV6 defined in src/unix/mod.rs ++/// Source Demand Routing ++pub const IPPROTO_SDRP: ::c_int = 42; ++/// IP6 routing header ++pub const IPPROTO_ROUTING: ::c_int = 43; ++/// IP6 fragmentation header ++pub const IPPROTO_FRAGMENT: ::c_int = 44; ++/// InterDomain Routing ++pub const IPPROTO_IDRP: ::c_int = 45; ++/// resource reservation ++pub const IPPROTO_RSVP: ::c_int = 46; ++/// General Routing Encap. ++pub const IPPROTO_GRE: ::c_int = 47; ++/// Mobile Host Routing ++pub const IPPROTO_MHRP: ::c_int = 48; ++/// BHA ++pub const IPPROTO_BHA: ::c_int = 49; ++/// IP6 Encap Sec. Payload ++pub const IPPROTO_ESP: ::c_int = 50; ++/// IP6 Auth Header ++pub const IPPROTO_AH: ::c_int = 51; ++/// Integ. Net Layer Security ++pub const IPPROTO_INLSP: ::c_int = 52; ++/// IP with encryption ++pub const IPPROTO_SWIPE: ::c_int = 53; ++/// Next Hop Resolution ++pub const IPPROTO_NHRP: ::c_int = 54; ++/// IP Mobility ++pub const IPPROTO_MOBILE: ::c_int = 55; ++/// Transport Layer Security ++pub const IPPROTO_TLSP: ::c_int = 56; ++/// SKIP ++pub const IPPROTO_SKIP: ::c_int = 57; ++// IPPROTO_ICMPV6 defined in src/unix/mod.rs ++/// IP6 no next header ++pub const IPPROTO_NONE: ::c_int = 59; ++/// IP6 destination option ++pub const IPPROTO_DSTOPTS: ::c_int = 60; ++/// any host internal protocol ++pub const IPPROTO_AHIP: ::c_int = 61; ++/// CFTP ++pub const IPPROTO_CFTP: ::c_int = 62; ++/// "hello" routing protocol ++pub const IPPROTO_HELLO: ::c_int = 63; ++/// SATNET/Backroom EXPAK ++pub const IPPROTO_SATEXPAK: ::c_int = 64; ++/// Kryptolan ++pub const IPPROTO_KRYPTOLAN: ::c_int = 65; ++/// Remote Virtual Disk ++pub const IPPROTO_RVD: ::c_int = 66; ++/// Pluribus Packet Core ++pub const IPPROTO_IPPC: ::c_int = 67; ++/// Any distributed FS ++pub const IPPROTO_ADFS: ::c_int = 68; ++/// Satnet Monitoring ++pub const IPPROTO_SATMON: ::c_int = 69; ++/// VISA Protocol ++pub const IPPROTO_VISA: ::c_int = 70; ++/// Packet Core Utility ++pub const IPPROTO_IPCV: ::c_int = 71; ++/// Comp. Prot. Net. Executive ++pub const IPPROTO_CPNX: ::c_int = 72; ++/// Comp. Prot. HeartBeat ++pub const IPPROTO_CPHB: ::c_int = 73; ++/// Wang Span Network ++pub const IPPROTO_WSN: ::c_int = 74; ++/// Packet Video Protocol ++pub const IPPROTO_PVP: ::c_int = 75; ++/// BackRoom SATNET Monitoring ++pub const IPPROTO_BRSATMON: ::c_int = 76; ++/// Sun net disk proto (temp.) ++pub const IPPROTO_ND: ::c_int = 77; ++/// WIDEBAND Monitoring ++pub const IPPROTO_WBMON: ::c_int = 78; ++/// WIDEBAND EXPAK ++pub const IPPROTO_WBEXPAK: ::c_int = 79; ++/// ISO cnlp ++pub const IPPROTO_EON: ::c_int = 80; ++/// VMTP ++pub const IPPROTO_VMTP: ::c_int = 81; ++/// Secure VMTP ++pub const IPPROTO_SVMTP: ::c_int = 82; ++/// Banyon VINES ++pub const IPPROTO_VINES: ::c_int = 83; ++/// TTP ++pub const IPPROTO_TTP: ::c_int = 84; ++/// NSFNET-IGP ++pub const IPPROTO_IGP: ::c_int = 85; ++/// dissimilar gateway prot. ++pub const IPPROTO_DGP: ::c_int = 86; ++/// TCF ++pub const IPPROTO_TCF: ::c_int = 87; ++/// Cisco/GXS IGRP ++pub const IPPROTO_IGRP: ::c_int = 88; ++/// OSPFIGP ++pub const IPPROTO_OSPFIGP: ::c_int = 89; ++/// Strite RPC protocol ++pub const IPPROTO_SRPC: ::c_int = 90; ++/// Locus Address Resoloution ++pub const IPPROTO_LARP: ::c_int = 91; ++/// Multicast Transport ++pub const IPPROTO_MTP: ::c_int = 92; ++/// AX.25 Frames ++pub const IPPROTO_AX25: ::c_int = 93; ++/// IP encapsulated in IP ++pub const IPPROTO_IPEIP: ::c_int = 94; ++/// Mobile Int.ing control ++pub const IPPROTO_MICP: ::c_int = 95; ++/// Semaphore Comm. security ++pub const IPPROTO_SCCSP: ::c_int = 96; ++/// Ethernet IP encapsulation ++pub const IPPROTO_ETHERIP: ::c_int = 97; ++/// encapsulation header ++pub const IPPROTO_ENCAP: ::c_int = 98; ++/// any private encr. scheme ++pub const IPPROTO_APES: ::c_int = 99; ++/// GMTP ++pub const IPPROTO_GMTP: ::c_int = 100; ++/// payload compression (IPComp) ++pub const IPPROTO_IPCOMP: ::c_int = 108; ++/// SCTP ++pub const IPPROTO_SCTP: ::c_int = 132; ++/// IPv6 Mobility Header ++pub const IPPROTO_MH: ::c_int = 135; ++/// UDP-Lite ++pub const IPPROTO_UDPLITE: ::c_int = 136; ++/// IP6 Host Identity Protocol ++pub const IPPROTO_HIP: ::c_int = 139; ++/// IP6 Shim6 Protocol ++pub const IPPROTO_SHIM6: ::c_int = 140; ++ ++/* 101-254: Partly Unassigned */ ++/// Protocol Independent Mcast ++pub const IPPROTO_PIM: ::c_int = 103; ++/// CARP ++pub const IPPROTO_CARP: ::c_int = 112; ++/// PGM ++pub const IPPROTO_PGM: ::c_int = 113; ++/// MPLS-in-IP ++pub const IPPROTO_MPLS: ::c_int = 137; ++/// PFSYNC ++pub const IPPROTO_PFSYNC: ::c_int = 240; ++ ++/* 255: Reserved */ ++/* BSD Private, local use, namespace incursion, no longer used */ ++/// OLD divert pseudo-proto ++pub const IPPROTO_OLD_DIVERT: ::c_int = 254; ++pub const IPPROTO_MAX: ::c_int = 256; ++/// last return value of *_input(), meaning "all job for this pkt is done". ++pub const IPPROTO_DONE: ::c_int = 257; ++ ++/* Only used internally, so can be outside the range of valid IP protocols. */ ++/// divert pseudo-protocol ++pub const IPPROTO_DIVERT: ::c_int = 258; ++/// SeND pseudo-protocol ++pub const IPPROTO_SEND: ::c_int = 259; ++ ++pub const PF_SLOW: ::c_int = AF_SLOW; ++pub const PF_SCLUSTER: ::c_int = AF_SCLUSTER; ++pub const PF_ARP: ::c_int = AF_ARP; ++pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; ++pub const PF_IEEE80211: ::c_int = AF_IEEE80211; ++pub const PF_INET_SDP: ::c_int = AF_INET_SDP; ++pub const PF_INET6_SDP: ::c_int = AF_INET6_SDP; ++#[doc(hidden)] ++pub const PF_MAX: ::c_int = AF_MAX; ++ ++pub const NET_RT_DUMP: ::c_int = 1; ++pub const NET_RT_FLAGS: ::c_int = 2; ++pub const NET_RT_IFLIST: ::c_int = 3; ++pub const NET_RT_IFMALIST: ::c_int = 4; ++pub const NET_RT_IFLISTL: ::c_int = 5; ++ ++// System V IPC ++pub const IPC_PRIVATE: ::key_t = 0; ++pub const IPC_CREAT: ::c_int = 0o1000; ++pub const IPC_EXCL: ::c_int = 0o2000; ++pub const IPC_NOWAIT: ::c_int = 0o4000; ++pub const IPC_RMID: ::c_int = 0; ++pub const IPC_SET: ::c_int = 1; ++pub const IPC_STAT: ::c_int = 2; ++pub const IPC_INFO: ::c_int = 3; ++pub const IPC_R : ::c_int = 0o400; ++pub const IPC_W : ::c_int = 0o200; ++pub const IPC_M : ::c_int = 0o10000; ++pub const MSG_NOERROR: ::c_int = 0o10000; ++pub const SHM_RDONLY: ::c_int = 0o10000; ++pub const SHM_RND: ::c_int = 0o20000; ++pub const SHM_R: ::c_int = 0o400; ++pub const SHM_W: ::c_int = 0o200; ++pub const SHM_LOCK: ::c_int = 11; ++pub const SHM_UNLOCK: ::c_int = 12; ++pub const SHM_STAT: ::c_int = 13; ++pub const SHM_INFO: ::c_int = 14; ++ ++// The *_MAXID constants never should've been used outside of the ++// FreeBSD base system. And with the exception of CTL_P1003_1B_MAXID, ++// they were all removed in svn r262489. They remain here for backwards ++// compatibility only, and are scheduled to be removed in libc 1.0.0. ++#[doc(hidden)] ++pub const NET_MAXID: ::c_int = AF_MAX; ++#[doc(hidden)] ++pub const CTL_MAXID: ::c_int = 10; ++#[doc(hidden)] ++pub const KERN_MAXID: ::c_int = 38; ++#[doc(hidden)] ++pub const HW_MAXID: ::c_int = 13; ++#[doc(hidden)] ++pub const USER_MAXID: ::c_int = 21; ++#[doc(hidden)] ++pub const CTL_P1003_1B_MAXID: ::c_int = 26; ++ ++pub const MSG_NOTIFICATION: ::c_int = 0x00002000; ++pub const MSG_NBIO: ::c_int = 0x00004000; ++pub const MSG_COMPAT: ::c_int = 0x00008000; ++pub const MSG_CMSG_CLOEXEC: ::c_int = 0x00040000; ++pub const MSG_NOSIGNAL: ::c_int = 0x20000; ++ ++pub const EMPTY: ::c_short = 0; ++pub const BOOT_TIME: ::c_short = 1; ++pub const OLD_TIME: ::c_short = 2; ++pub const NEW_TIME: ::c_short = 3; ++pub const USER_PROCESS: ::c_short = 4; ++pub const INIT_PROCESS: ::c_short = 5; ++pub const LOGIN_PROCESS: ::c_short = 6; ++pub const DEAD_PROCESS: ::c_short = 7; ++pub const SHUTDOWN_TIME: ::c_short = 8; ++ ++pub const LC_COLLATE_MASK: ::c_int = (1 << 0); ++pub const LC_CTYPE_MASK: ::c_int = (1 << 1); ++pub const LC_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 WSTOPPED: ::c_int = 2; // same as WUNTRACED ++pub const WCONTINUED: ::c_int = 4; ++pub const WNOWAIT: ::c_int = 8; ++pub const WEXITED: ::c_int = 16; ++pub const WTRAPPED: ::c_int = 32; ++ ++// FreeBSD defines a great many more of these, we only expose the ++// standardized ones. ++pub const P_PID: idtype_t = 0; ++pub const P_PGID: idtype_t = 2; ++pub const P_ALL: idtype_t = 7; ++ ++pub const B460800: ::speed_t = 460800; ++pub const B921600: ::speed_t = 921600; ++ ++pub const AT_FDCWD: ::c_int = -100; ++pub const AT_EACCESS: ::c_int = 0x100; ++pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200; ++pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; ++pub const AT_REMOVEDIR: ::c_int = 0x800; ++ ++pub const TABDLY: ::tcflag_t = 0x00000004; ++pub const TAB0: ::tcflag_t = 0x00000000; ++pub const TAB3: ::tcflag_t = 0x00000004; ++ ++pub const _PC_ACL_NFS4: ::c_int = 64; ++ ++pub const _SC_CPUSET_SIZE: ::c_int = 122; ++ ++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 clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; ++ ++ pub fn jail(jail: *mut ::jail) -> ::c_int; ++ pub fn jail_attach(jid: ::c_int) -> ::c_int; ++ pub fn jail_remove(jid: ::c_int) -> ::c_int; ++ pub fn jail_get(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int) ++ -> ::c_int; ++ pub fn jail_set(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int) ++ -> ::c_int; ++ ++ pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, ++ len: ::off_t) -> ::c_int; ++ pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, ++ advise: ::c_int) -> ::c_int; ++ pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; ++ pub fn mkostemps(template: *mut ::c_char, ++ suffixlen: ::c_int, ++ flags: ::c_int) -> ::c_int; ++ ++ pub fn getutxuser(user: *const ::c_char) -> *mut utmpx; ++ pub fn setutxdb(_type: ::c_int, file: *const ::c_char) -> ::c_int; ++ ++ pub fn aio_waitcomplete(iocbp: *mut *mut aiocb, ++ timeout: *mut ::timespec) -> ::ssize_t; ++ ++ pub fn freelocale(loc: ::locale_t) -> ::c_int; ++ pub fn waitid(idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t, ++ options: ::c_int) -> ::c_int; ++ ++ pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t; ++ pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; ++ pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, ++ shmflg: ::c_int) -> *mut ::c_void; ++ pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; ++ pub fn shmctl(shmid: ::c_int, cmd: ::c_int, ++ buf: *mut ::shmid_ds) -> ::c_int; ++ pub fn msgctl(msqid: ::c_int, cmd: ::c_int, ++ buf: *mut ::msqid_ds) -> ::c_int; ++ pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; ++ pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t, ++ msgtyp: ::c_long, msgflg: ::c_int) -> ::c_int; ++ pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t, ++ msgflg: ::c_int) -> ::c_int; ++ pub fn cfmakesane(termios: *mut ::termios); ++} ++ ++cfg_if! { ++ if #[cfg(target_arch = "x86")] { ++ mod x86; ++ pub use self::x86::*; ++ } else if #[cfg(target_arch = "x86_64")] { ++ mod x86_64; ++ pub use self::x86_64::*; ++ } else if #[cfg(target_arch = "aarch64")] { ++ mod aarch64; ++ pub use self::aarch64::*; ++ } else { ++ // Unknown target_arch ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/bsd/freebsdlike/freebsd/x86.rs index 000000000,000000000..8a5e5f9fb new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/freebsdlike/freebsd/x86.rs @@@ -1,0 -1,0 +1,31 @@@ ++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 --cc vendor/libc-0.2.31/src/unix/bsd/freebsdlike/freebsd/x86_64.rs index 000000000,000000000..3d61f889d new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/freebsdlike/freebsd/x86_64.rs @@@ -1,0 -1,0 +1,32 @@@ ++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, ++ } ++} ++ ++pub const MAP_32BIT: ::c_int = 0x00080000; diff --cc vendor/libc-0.2.31/src/unix/bsd/freebsdlike/mod.rs index 000000000,000000000..8cc87ce9f new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/freebsdlike/mod.rs @@@ -1,0 -1,0 +1,1125 @@@ ++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_rwlockattr_t = *mut ::c_void; ++pub type pthread_key_t = ::c_int; ++pub type tcflag_t = ::c_uint; ++pub type speed_t = ::c_uint; ++pub type nl_item = ::c_int; ++pub type id_t = i64; ++ ++pub enum timezone {} ++ ++s! { ++ pub struct glob_t { ++ pub gl_pathc: ::size_t, ++ pub gl_matchc: ::size_t, ++ pub gl_offs: ::size_t, ++ pub gl_flags: ::c_int, ++ pub gl_pathv: *mut *mut ::c_char, ++ __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 { ++ // In FreeBSD 11 and later, ss_sp is actually a void* ++ 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, ++ } ++} ++ ++pub const AIO_LISTIO_MAX: ::c_int = 16; ++pub const AIO_CANCELED: ::c_int = 1; ++pub const AIO_NOTCANCELED: ::c_int = 2; ++pub const AIO_ALLDONE: ::c_int = 3; ++pub const LIO_NOP: ::c_int = 0; ++pub const LIO_WRITE: ::c_int = 1; ++pub const LIO_READ: ::c_int = 2; ++pub const LIO_WAIT: ::c_int = 1; ++pub const LIO_NOWAIT: ::c_int = 0; ++ ++pub const SIGEV_NONE: ::c_int = 0; ++pub const SIGEV_SIGNAL: ::c_int = 1; ++pub const SIGEV_THREAD: ::c_int = 2; ++pub const SIGEV_KEVENT: ::c_int = 3; ++ ++pub const CODESET: ::nl_item = 0; ++pub const D_T_FMT: ::nl_item = 1; ++pub const D_FMT: ::nl_item = 2; ++pub const T_FMT: ::nl_item = 3; ++pub const T_FMT_AMPM: ::nl_item = 4; ++pub const AM_STR: ::nl_item = 5; ++pub const PM_STR: ::nl_item = 6; ++ ++pub const DAY_1: ::nl_item = 7; ++pub const DAY_2: ::nl_item = 8; ++pub const DAY_3: ::nl_item = 9; ++pub const DAY_4: ::nl_item = 10; ++pub const DAY_5: ::nl_item = 11; ++pub const DAY_6: ::nl_item = 12; ++pub const DAY_7: ::nl_item = 13; ++ ++pub const ABDAY_1: ::nl_item = 14; ++pub const ABDAY_2: ::nl_item = 15; ++pub const ABDAY_3: ::nl_item = 16; ++pub const ABDAY_4: ::nl_item = 17; ++pub const ABDAY_5: ::nl_item = 18; ++pub const ABDAY_6: ::nl_item = 19; ++pub const ABDAY_7: ::nl_item = 20; ++ ++pub const MON_1: ::nl_item = 21; ++pub const MON_2: ::nl_item = 22; ++pub const MON_3: ::nl_item = 23; ++pub const MON_4: ::nl_item = 24; ++pub const MON_5: ::nl_item = 25; ++pub const MON_6: ::nl_item = 26; ++pub const MON_7: ::nl_item = 27; ++pub const MON_8: ::nl_item = 28; ++pub const MON_9: ::nl_item = 29; ++pub const MON_10: ::nl_item = 30; ++pub const MON_11: ::nl_item = 31; ++pub const MON_12: ::nl_item = 32; ++ ++pub const ABMON_1: ::nl_item = 33; ++pub const ABMON_2: ::nl_item = 34; ++pub const ABMON_3: ::nl_item = 35; ++pub const ABMON_4: ::nl_item = 36; ++pub const ABMON_5: ::nl_item = 37; ++pub const ABMON_6: ::nl_item = 38; ++pub const ABMON_7: ::nl_item = 39; ++pub const ABMON_8: ::nl_item = 40; ++pub const ABMON_9: ::nl_item = 41; ++pub const ABMON_10: ::nl_item = 42; ++pub const ABMON_11: ::nl_item = 43; ++pub const ABMON_12: ::nl_item = 44; ++ ++pub const ERA: ::nl_item = 45; ++pub const ERA_D_FMT: ::nl_item = 46; ++pub const ERA_D_T_FMT: ::nl_item = 47; ++pub const ERA_T_FMT: ::nl_item = 48; ++pub const ALT_DIGITS: ::nl_item = 49; ++ ++pub const RADIXCHAR: ::nl_item = 50; ++pub const THOUSEP: ::nl_item = 51; ++ ++pub const YESEXPR: ::nl_item = 52; ++pub const NOEXPR: ::nl_item = 53; ++ ++pub const YESSTR: ::nl_item = 54; ++pub const NOSTR: ::nl_item = 55; ++ ++pub const CRNCYSTR: ::nl_item = 56; ++ ++pub const D_MD_ORDER: ::nl_item = 57; ++ ++pub const ALTMON_1: ::nl_item = 58; ++pub const ALTMON_2: ::nl_item = 59; ++pub const ALTMON_3: ::nl_item = 60; ++pub const ALTMON_4: ::nl_item = 61; ++pub const ALTMON_5: ::nl_item = 62; ++pub const ALTMON_6: ::nl_item = 63; ++pub const ALTMON_7: ::nl_item = 64; ++pub const ALTMON_8: ::nl_item = 65; ++pub const ALTMON_9: ::nl_item = 66; ++pub const ALTMON_10: ::nl_item = 67; ++pub const ALTMON_11: ::nl_item = 68; ++pub const ALTMON_12: ::nl_item = 69; ++ ++pub const EXIT_FAILURE: ::c_int = 1; ++pub const EXIT_SUCCESS: ::c_int = 0; ++pub const EOF: ::c_int = -1; ++pub const SEEK_SET: ::c_int = 0; ++pub const SEEK_CUR: ::c_int = 1; ++pub const SEEK_END: ::c_int = 2; ++pub const SEEK_DATA: ::c_int = 3; ++pub const SEEK_HOLE: ::c_int = 4; ++pub const _IOFBF: ::c_int = 0; ++pub const _IONBF: ::c_int = 2; ++pub const _IOLBF: ::c_int = 1; ++pub const BUFSIZ: ::c_uint = 1024; ++pub const FOPEN_MAX: ::c_uint = 20; ++pub const FILENAME_MAX: ::c_uint = 1024; ++pub const L_tmpnam: ::c_uint = 1024; ++pub const TMP_MAX: ::c_uint = 308915776; ++ ++pub const O_NOCTTY: ::c_int = 32768; ++pub const O_DIRECT: ::c_int = 0x00010000; ++ ++pub const S_IFIFO: mode_t = 4096; ++pub const S_IFCHR: mode_t = 8192; ++pub const S_IFBLK: mode_t = 24576; ++pub const S_IFDIR: mode_t = 16384; ++pub const S_IFREG: mode_t = 32768; ++pub const S_IFLNK: mode_t = 40960; ++pub const S_IFSOCK: mode_t = 49152; ++pub const S_IFMT: mode_t = 61440; ++pub const S_IEXEC: mode_t = 64; ++pub const S_IWRITE: mode_t = 128; ++pub const S_IREAD: mode_t = 256; ++pub const S_IRWXU: mode_t = 448; ++pub const S_IXUSR: mode_t = 64; ++pub const S_IWUSR: mode_t = 128; ++pub const S_IRUSR: mode_t = 256; ++pub const S_IRWXG: mode_t = 56; ++pub const S_IXGRP: mode_t = 8; ++pub const S_IWGRP: mode_t = 16; ++pub const S_IRGRP: mode_t = 32; ++pub const S_IRWXO: mode_t = 7; ++pub const S_IXOTH: mode_t = 1; ++pub const S_IWOTH: mode_t = 2; ++pub const S_IROTH: mode_t = 4; ++pub const F_OK: ::c_int = 0; ++pub const R_OK: ::c_int = 4; ++pub const W_OK: ::c_int = 2; ++pub const X_OK: ::c_int = 1; ++pub const STDIN_FILENO: ::c_int = 0; ++pub const STDOUT_FILENO: ::c_int = 1; ++pub const STDERR_FILENO: ::c_int = 2; ++pub const F_LOCK: ::c_int = 1; ++pub const F_TEST: ::c_int = 3; ++pub const F_TLOCK: ::c_int = 2; ++pub const F_ULOCK: ::c_int = 0; ++pub const F_DUPFD_CLOEXEC: ::c_int = 17; ++pub const SIGHUP: ::c_int = 1; ++pub const SIGINT: ::c_int = 2; ++pub const SIGQUIT: ::c_int = 3; ++pub const SIGILL: ::c_int = 4; ++pub const SIGABRT: ::c_int = 6; ++pub const SIGEMT: ::c_int = 7; ++pub const SIGFPE: ::c_int = 8; ++pub const SIGKILL: ::c_int = 9; ++pub const SIGSEGV: ::c_int = 11; ++pub const SIGPIPE: ::c_int = 13; ++pub const SIGALRM: ::c_int = 14; ++pub const SIGTERM: ::c_int = 15; ++ ++pub const PROT_NONE: ::c_int = 0; ++pub const PROT_READ: ::c_int = 1; ++pub const PROT_WRITE: ::c_int = 2; ++pub const PROT_EXEC: ::c_int = 4; ++ ++pub const MAP_FILE: ::c_int = 0x0000; ++pub const MAP_SHARED: ::c_int = 0x0001; ++pub const MAP_PRIVATE: ::c_int = 0x0002; ++pub const MAP_FIXED: ::c_int = 0x0010; ++pub const MAP_ANON: ::c_int = 0x1000; ++pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; ++ ++pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const MS_SYNC: ::c_int = 0x0000; ++pub const MS_ASYNC: ::c_int = 0x0001; ++pub const MS_INVALIDATE: ::c_int = 0x0002; ++ ++pub const EPERM: ::c_int = 1; ++pub const ENOENT: ::c_int = 2; ++pub const ESRCH: ::c_int = 3; ++pub const EINTR: ::c_int = 4; ++pub const EIO: ::c_int = 5; ++pub const ENXIO: ::c_int = 6; ++pub const E2BIG: ::c_int = 7; ++pub const ENOEXEC: ::c_int = 8; ++pub const EBADF: ::c_int = 9; ++pub const ECHILD: ::c_int = 10; ++pub const EDEADLK: ::c_int = 11; ++pub const ENOMEM: ::c_int = 12; ++pub const EACCES: ::c_int = 13; ++pub const EFAULT: ::c_int = 14; ++pub const ENOTBLK: ::c_int = 15; ++pub const EBUSY: ::c_int = 16; ++pub const EEXIST: ::c_int = 17; ++pub const EXDEV: ::c_int = 18; ++pub const ENODEV: ::c_int = 19; ++pub const ENOTDIR: ::c_int = 20; ++pub const EISDIR: ::c_int = 21; ++pub const EINVAL: ::c_int = 22; ++pub const ENFILE: ::c_int = 23; ++pub const EMFILE: ::c_int = 24; ++pub const ENOTTY: ::c_int = 25; ++pub const ETXTBSY: ::c_int = 26; ++pub const EFBIG: ::c_int = 27; ++pub const ENOSPC: ::c_int = 28; ++pub const ESPIPE: ::c_int = 29; ++pub const EROFS: ::c_int = 30; ++pub const EMLINK: ::c_int = 31; ++pub const EPIPE: ::c_int = 32; ++pub const EDOM: ::c_int = 33; ++pub const ERANGE: ::c_int = 34; ++pub const EAGAIN: ::c_int = 35; ++pub const EWOULDBLOCK: ::c_int = 35; ++pub const EINPROGRESS: ::c_int = 36; ++pub const EALREADY: ::c_int = 37; ++pub const ENOTSOCK: ::c_int = 38; ++pub const EDESTADDRREQ: ::c_int = 39; ++pub const EMSGSIZE: ::c_int = 40; ++pub const EPROTOTYPE: ::c_int = 41; ++pub const ENOPROTOOPT: ::c_int = 42; ++pub const EPROTONOSUPPORT: ::c_int = 43; ++pub const ESOCKTNOSUPPORT: ::c_int = 44; ++pub const EOPNOTSUPP: ::c_int = 45; ++pub const ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EPFNOSUPPORT: ::c_int = 46; ++pub const EAFNOSUPPORT: ::c_int = 47; ++pub const EADDRINUSE: ::c_int = 48; ++pub const EADDRNOTAVAIL: ::c_int = 49; ++pub const ENETDOWN: ::c_int = 50; ++pub const ENETUNREACH: ::c_int = 51; ++pub const ENETRESET: ::c_int = 52; ++pub const ECONNABORTED: ::c_int = 53; ++pub const ECONNRESET: ::c_int = 54; ++pub const ENOBUFS: ::c_int = 55; ++pub const EISCONN: ::c_int = 56; ++pub const ENOTCONN: ::c_int = 57; ++pub const ESHUTDOWN: ::c_int = 58; ++pub const ETOOMANYREFS: ::c_int = 59; ++pub const ETIMEDOUT: ::c_int = 60; ++pub const ECONNREFUSED: ::c_int = 61; ++pub const ELOOP: ::c_int = 62; ++pub const ENAMETOOLONG: ::c_int = 63; ++pub const EHOSTDOWN: ::c_int = 64; ++pub const EHOSTUNREACH: ::c_int = 65; ++pub const ENOTEMPTY: ::c_int = 66; ++pub const EPROCLIM: ::c_int = 67; ++pub const EUSERS: ::c_int = 68; ++pub const EDQUOT: ::c_int = 69; ++pub const ESTALE: ::c_int = 70; ++pub const EREMOTE: ::c_int = 71; ++pub const EBADRPC: ::c_int = 72; ++pub const ERPCMISMATCH: ::c_int = 73; ++pub const EPROGUNAVAIL: ::c_int = 74; ++pub const EPROGMISMATCH: ::c_int = 75; ++pub const EPROCUNAVAIL: ::c_int = 76; ++pub const ENOLCK: ::c_int = 77; ++pub const ENOSYS: ::c_int = 78; ++pub const EFTYPE: ::c_int = 79; ++pub const EAUTH: ::c_int = 80; ++pub const ENEEDAUTH: ::c_int = 81; ++pub const EIDRM: ::c_int = 82; ++pub const ENOMSG: ::c_int = 83; ++pub const EOVERFLOW: ::c_int = 84; ++pub const ECANCELED: ::c_int = 85; ++pub const EILSEQ: ::c_int = 86; ++pub const ENOATTR: ::c_int = 87; ++pub const EDOOFUS: ::c_int = 88; ++pub const EBADMSG: ::c_int = 89; ++pub const EMULTIHOP: ::c_int = 90; ++pub const ENOLINK: ::c_int = 91; ++pub const EPROTO: ::c_int = 92; ++ ++pub const POLLSTANDARD: ::c_short = ::POLLIN | ::POLLPRI | ::POLLOUT | ++ ::POLLRDNORM | ::POLLRDBAND | ::POLLWRBAND | ::POLLERR | ++ ::POLLHUP | ::POLLNVAL; ++ ++pub const EAI_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 PTHREAD_PROCESS_PRIVATE: ::c_int = 0; ++pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; ++pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; ++pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; ++ ++pub const RLIMIT_CPU: ::c_int = 0; ++pub const RLIMIT_FSIZE: ::c_int = 1; ++pub const RLIMIT_DATA: ::c_int = 2; ++pub const RLIMIT_STACK: ::c_int = 3; ++pub const RLIMIT_CORE: ::c_int = 4; ++pub const RLIMIT_RSS: ::c_int = 5; ++pub const RLIMIT_MEMLOCK: ::c_int = 6; ++pub const RLIMIT_NPROC: ::c_int = 7; ++pub const RLIMIT_NOFILE: ::c_int = 8; ++pub const RLIMIT_SBSIZE: ::c_int = 9; ++pub const RLIMIT_VMEM: ::c_int = 10; ++pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM; ++pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; ++ ++pub const RUSAGE_SELF: ::c_int = 0; ++pub const RUSAGE_CHILDREN: ::c_int = -1; ++ ++pub const MADV_NORMAL: ::c_int = 0; ++pub const MADV_RANDOM: ::c_int = 1; ++pub const MADV_SEQUENTIAL: ::c_int = 2; ++pub const MADV_WILLNEED: ::c_int = 3; ++pub const MADV_DONTNEED: ::c_int = 4; ++pub const MADV_FREE: ::c_int = 5; ++pub const MADV_NOSYNC: ::c_int = 6; ++pub const MADV_AUTOSYNC: ::c_int = 7; ++pub const MADV_NOCORE: ::c_int = 8; ++pub const MADV_CORE: ::c_int = 9; ++ ++pub const MINCORE_INCORE: ::c_int = 0x1; ++pub const MINCORE_REFERENCED: ::c_int = 0x2; ++pub const MINCORE_MODIFIED: ::c_int = 0x4; ++pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; ++pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; ++pub const MINCORE_SUPER: ::c_int = 0x20; ++ ++pub const AF_UNSPEC: ::c_int = 0; ++pub const AF_LOCAL: ::c_int = 1; ++pub const AF_UNIX: ::c_int = AF_LOCAL; ++pub const AF_INET: ::c_int = 2; ++pub const AF_IMPLINK: ::c_int = 3; ++pub const AF_PUP: ::c_int = 4; ++pub const AF_CHAOS: ::c_int = 5; ++pub const AF_NETBIOS: ::c_int = 6; ++pub const AF_ISO: ::c_int = 7; ++pub const AF_OSI: ::c_int = AF_ISO; ++pub const AF_ECMA: ::c_int = 8; ++pub const AF_DATAKIT: ::c_int = 9; ++pub const AF_CCITT: ::c_int = 10; ++pub const AF_SNA: ::c_int = 11; ++pub const AF_DECnet: ::c_int = 12; ++pub const AF_DLI: ::c_int = 13; ++pub const AF_LAT: ::c_int = 14; ++pub const AF_HYLINK: ::c_int = 15; ++pub const AF_APPLETALK: ::c_int = 16; ++pub const AF_ROUTE: ::c_int = 17; ++pub const AF_LINK: ::c_int = 18; ++pub const pseudo_AF_XTP: ::c_int = 19; ++pub const AF_COIP: ::c_int = 20; ++pub const AF_CNT: ::c_int = 21; ++pub const pseudo_AF_RTIP: ::c_int = 22; ++pub const AF_IPX: ::c_int = 23; ++pub const AF_SIP: ::c_int = 24; ++pub const pseudo_AF_PIP: ::c_int = 25; ++pub const AF_ISDN: ::c_int = 26; ++pub const AF_E164: ::c_int = AF_ISDN; ++pub const pseudo_AF_KEY: ::c_int = 27; ++pub const AF_INET6: ::c_int = 28; ++pub const AF_NATM: ::c_int = 29; ++pub const AF_ATM: ::c_int = 30; ++pub const pseudo_AF_HDRCMPLT: ::c_int = 31; ++pub const AF_NETGRAPH: ::c_int = 32; ++ ++pub const PF_UNSPEC: ::c_int = AF_UNSPEC; ++pub const PF_LOCAL: ::c_int = AF_LOCAL; ++pub const PF_UNIX: ::c_int = PF_LOCAL; ++pub const PF_INET: ::c_int = AF_INET; ++pub const PF_IMPLINK: ::c_int = AF_IMPLINK; ++pub const PF_PUP: ::c_int = AF_PUP; ++pub const PF_CHAOS: ::c_int = AF_CHAOS; ++pub const PF_NETBIOS: ::c_int = AF_NETBIOS; ++pub const PF_ISO: ::c_int = AF_ISO; ++pub const PF_OSI: ::c_int = AF_ISO; ++pub const PF_ECMA: ::c_int = AF_ECMA; ++pub const PF_DATAKIT: ::c_int = AF_DATAKIT; ++pub const PF_CCITT: ::c_int = AF_CCITT; ++pub const PF_SNA: ::c_int = AF_SNA; ++pub const PF_DECnet: ::c_int = AF_DECnet; ++pub const PF_DLI: ::c_int = AF_DLI; ++pub const PF_LAT: ::c_int = AF_LAT; ++pub const PF_HYLINK: ::c_int = AF_HYLINK; ++pub const PF_APPLETALK: ::c_int = AF_APPLETALK; ++pub const PF_ROUTE: ::c_int = AF_ROUTE; ++pub const PF_LINK: ::c_int = AF_LINK; ++pub const PF_XTP: ::c_int = pseudo_AF_XTP; ++pub const PF_COIP: ::c_int = AF_COIP; ++pub const PF_CNT: ::c_int = AF_CNT; ++pub const PF_SIP: ::c_int = AF_SIP; ++pub const PF_IPX: ::c_int = AF_IPX; ++pub const PF_RTIP: ::c_int = pseudo_AF_RTIP; ++pub const PF_PIP: ::c_int = pseudo_AF_PIP; ++pub const PF_ISDN: ::c_int = AF_ISDN; ++pub const PF_KEY: ::c_int = pseudo_AF_KEY; ++pub const PF_INET6: ::c_int = AF_INET6; ++pub const PF_NATM: ::c_int = AF_NATM; ++pub const PF_ATM: ::c_int = AF_ATM; ++pub const PF_NETGRAPH: ::c_int = AF_NETGRAPH; ++ ++pub const SOMAXCONN: ::c_int = 128; ++ ++pub const MSG_OOB: ::c_int = 0x00000001; ++pub const MSG_PEEK: ::c_int = 0x00000002; ++pub const MSG_DONTROUTE: ::c_int = 0x00000004; ++pub const MSG_EOR: ::c_int = 0x00000008; ++pub const MSG_TRUNC: ::c_int = 0x00000010; ++pub const MSG_CTRUNC: ::c_int = 0x00000020; ++pub const MSG_WAITALL: ::c_int = 0x00000040; ++pub const MSG_DONTWAIT: ::c_int = 0x00000080; ++pub const MSG_EOF: ::c_int = 0x00000100; ++ ++pub const SCM_TIMESTAMP: ::c_int = 0x02; ++ ++pub const SOCK_STREAM: ::c_int = 1; ++pub const SOCK_DGRAM: ::c_int = 2; ++pub const SOCK_RAW: ::c_int = 3; ++pub const SOCK_RDM: ::c_int = 4; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++pub const SOCK_CLOEXEC: ::c_int = 0x10000000; ++pub const SOCK_NONBLOCK: ::c_int = 0x20000000; ++pub const SOCK_MAXADDRLEN: ::c_int = 255; ++pub const IP_TTL: ::c_int = 4; ++pub const IP_HDRINCL: ::c_int = 2; ++pub const IP_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_TIMESTAMP: ::c_int = 0x0400; ++pub const SO_NOSIGPIPE: ::c_int = 0x0800; ++pub const SO_ACCEPTFILTER: ::c_int = 0x1000; ++pub const SO_SNDBUF: ::c_int = 0x1001; ++pub const SO_RCVBUF: ::c_int = 0x1002; ++pub const SO_SNDLOWAT: ::c_int = 0x1003; ++pub const SO_RCVLOWAT: ::c_int = 0x1004; ++pub const SO_SNDTIMEO: ::c_int = 0x1005; ++pub const SO_RCVTIMEO: ::c_int = 0x1006; ++pub const SO_ERROR: ::c_int = 0x1007; ++pub const SO_TYPE: ::c_int = 0x1008; ++ ++pub const 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 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 _PC_LINK_MAX: ::c_int = 1; ++pub const _PC_MAX_CANON: ::c_int = 2; ++pub const _PC_MAX_INPUT: ::c_int = 3; ++pub const _PC_NAME_MAX: ::c_int = 4; ++pub const _PC_PATH_MAX: ::c_int = 5; ++pub const _PC_PIPE_BUF: ::c_int = 6; ++pub const _PC_CHOWN_RESTRICTED: ::c_int = 7; ++pub const _PC_NO_TRUNC: ::c_int = 8; ++pub const _PC_VDISABLE: ::c_int = 9; ++pub const _PC_ALLOC_SIZE_MIN: ::c_int = 10; ++pub const _PC_FILESIZEBITS: ::c_int = 12; ++pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14; ++pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15; ++pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16; ++pub const _PC_REC_XFER_ALIGN: ::c_int = 17; ++pub const _PC_SYMLINK_MAX: ::c_int = 18; ++pub const _PC_MIN_HOLE_SIZE: ::c_int = 21; ++pub const _PC_ASYNC_IO: ::c_int = 53; ++pub const _PC_PRIO_IO: ::c_int = 54; ++pub const _PC_SYNC_IO: ::c_int = 55; ++pub const _PC_ACL_EXTENDED: ::c_int = 59; ++pub const _PC_ACL_PATH_MAX: ::c_int = 60; ++pub const _PC_CAP_PRESENT: ::c_int = 61; ++pub const _PC_INF_PRESENT: ::c_int = 62; ++pub const _PC_MAC_PRESENT: ::c_int = 63; ++ ++pub const _SC_ARG_MAX: ::c_int = 1; ++pub const _SC_CHILD_MAX: ::c_int = 2; ++pub const _SC_CLK_TCK: ::c_int = 3; ++pub const _SC_NGROUPS_MAX: ::c_int = 4; ++pub const _SC_OPEN_MAX: ::c_int = 5; ++pub const _SC_JOB_CONTROL: ::c_int = 6; ++pub const _SC_SAVED_IDS: ::c_int = 7; ++pub const _SC_VERSION: ::c_int = 8; ++pub const _SC_BC_BASE_MAX: ::c_int = 9; ++pub const _SC_BC_DIM_MAX: ::c_int = 10; ++pub const _SC_BC_SCALE_MAX: ::c_int = 11; ++pub const _SC_BC_STRING_MAX: ::c_int = 12; ++pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 13; ++pub const _SC_EXPR_NEST_MAX: ::c_int = 14; ++pub const _SC_LINE_MAX: ::c_int = 15; ++pub const _SC_RE_DUP_MAX: ::c_int = 16; ++pub const _SC_2_VERSION: ::c_int = 17; ++pub const _SC_2_C_BIND: ::c_int = 18; ++pub const _SC_2_C_DEV: ::c_int = 19; ++pub const _SC_2_CHAR_TERM: ::c_int = 20; ++pub const _SC_2_FORT_DEV: ::c_int = 21; ++pub const _SC_2_FORT_RUN: ::c_int = 22; ++pub const _SC_2_LOCALEDEF: ::c_int = 23; ++pub const _SC_2_SW_DEV: ::c_int = 24; ++pub const _SC_2_UPE: ::c_int = 25; ++pub const _SC_STREAM_MAX: ::c_int = 26; ++pub const _SC_TZNAME_MAX: ::c_int = 27; ++pub const _SC_ASYNCHRONOUS_IO: ::c_int = 28; ++pub const _SC_MAPPED_FILES: ::c_int = 29; ++pub const _SC_MEMLOCK: ::c_int = 30; ++pub const _SC_MEMLOCK_RANGE: ::c_int = 31; ++pub const _SC_MEMORY_PROTECTION: ::c_int = 32; ++pub const _SC_MESSAGE_PASSING: ::c_int = 33; ++pub const _SC_PRIORITIZED_IO: ::c_int = 34; ++pub const _SC_PRIORITY_SCHEDULING: ::c_int = 35; ++pub const _SC_REALTIME_SIGNALS: ::c_int = 36; ++pub const _SC_SEMAPHORES: ::c_int = 37; ++pub const _SC_FSYNC: ::c_int = 38; ++pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 39; ++pub const _SC_SYNCHRONIZED_IO: ::c_int = 40; ++pub const _SC_TIMERS: ::c_int = 41; ++pub const _SC_AIO_LISTIO_MAX: ::c_int = 42; ++pub const _SC_AIO_MAX: ::c_int = 43; ++pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 44; ++pub const _SC_DELAYTIMER_MAX: ::c_int = 45; ++pub const _SC_MQ_OPEN_MAX: ::c_int = 46; ++pub const _SC_PAGESIZE: ::c_int = 47; ++pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; ++pub const _SC_RTSIG_MAX: ::c_int = 48; ++pub const _SC_SEM_NSEMS_MAX: ::c_int = 49; ++pub const _SC_SEM_VALUE_MAX: ::c_int = 50; ++pub const _SC_SIGQUEUE_MAX: ::c_int = 51; ++pub const _SC_TIMER_MAX: ::c_int = 52; ++pub const _SC_IOV_MAX: ::c_int = 56; ++pub const _SC_NPROCESSORS_CONF: ::c_int = 57; ++pub const _SC_2_PBS: ::c_int = 59; ++pub const _SC_2_PBS_ACCOUNTING: ::c_int = 60; ++pub const _SC_2_PBS_CHECKPOINT: ::c_int = 61; ++pub const _SC_2_PBS_LOCATE: ::c_int = 62; ++pub const _SC_2_PBS_MESSAGE: ::c_int = 63; ++pub const _SC_2_PBS_TRACK: ::c_int = 64; ++pub const _SC_ADVISORY_INFO: ::c_int = 65; ++pub const _SC_BARRIERS: ::c_int = 66; ++pub const _SC_CLOCK_SELECTION: ::c_int = 67; ++pub const _SC_CPUTIME: ::c_int = 68; ++pub const _SC_FILE_LOCKING: ::c_int = 69; ++pub const _SC_NPROCESSORS_ONLN: ::c_int = 58; ++pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70; ++pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71; ++pub const _SC_HOST_NAME_MAX: ::c_int = 72; ++pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; ++pub const _SC_MONOTONIC_CLOCK: ::c_int = 74; ++pub const _SC_MQ_PRIO_MAX: ::c_int = 75; ++pub const _SC_READER_WRITER_LOCKS: ::c_int = 76; ++pub const _SC_REGEXP: ::c_int = 77; ++pub const _SC_SHELL: ::c_int = 78; ++pub const _SC_SPAWN: ::c_int = 79; ++pub const _SC_SPIN_LOCKS: ::c_int = 80; ++pub const _SC_SPORADIC_SERVER: ::c_int = 81; ++pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 82; ++pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 83; ++pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 85; ++pub const _SC_THREAD_KEYS_MAX: ::c_int = 86; ++pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 87; ++pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 88; ++pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 89; ++pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 90; ++pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 91; ++pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 92; ++pub const _SC_THREAD_STACK_MIN: ::c_int = 93; ++pub const _SC_THREAD_THREADS_MAX: ::c_int = 94; ++pub const _SC_TIMEOUTS: ::c_int = 95; ++pub const _SC_THREADS: ::c_int = 96; ++pub const _SC_TRACE: ::c_int = 97; ++pub const _SC_TRACE_EVENT_FILTER: ::c_int = 98; ++pub const _SC_TRACE_INHERIT: ::c_int = 99; ++pub const _SC_TRACE_LOG: ::c_int = 100; ++pub const _SC_TTY_NAME_MAX: ::c_int = 101; ++pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 102; ++pub const _SC_V6_ILP32_OFF32: ::c_int = 103; ++pub const _SC_V6_ILP32_OFFBIG: ::c_int = 104; ++pub const _SC_V6_LP64_OFF64: ::c_int = 105; ++pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 106; ++pub const _SC_ATEXIT_MAX: ::c_int = 107; ++pub const _SC_XOPEN_CRYPT: ::c_int = 108; ++pub const _SC_XOPEN_ENH_I18N: ::c_int = 109; ++pub const _SC_XOPEN_LEGACY: ::c_int = 110; ++pub const _SC_XOPEN_REALTIME: ::c_int = 111; ++pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 112; ++pub const _SC_XOPEN_SHM: ::c_int = 113; ++pub const _SC_XOPEN_STREAMS: ::c_int = 114; ++pub const _SC_XOPEN_UNIX: ::c_int = 115; ++pub const _SC_XOPEN_VERSION: ::c_int = 116; ++pub const _SC_XOPEN_XCU_VERSION: ::c_int = 117; ++pub const _SC_IPV6: ::c_int = 118; ++pub const _SC_RAW_SOCKETS: ::c_int = 119; ++pub const _SC_SYMLOOP_MAX: ::c_int = 120; ++pub const _SC_PHYS_PAGES: ::c_int = 121; ++ ++pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; ++pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; ++pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; ++pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; ++pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; ++pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3; ++pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_ERRORCHECK; ++ ++pub const SCHED_FIFO: ::c_int = 1; ++pub const SCHED_OTHER: ::c_int = 2; ++pub const SCHED_RR: ::c_int = 3; ++ ++pub const FD_SETSIZE: usize = 1024; ++ ++pub const ST_NOSUID: ::c_ulong = 2; ++ ++pub const NI_MAXHOST: ::size_t = 1025; ++ ++pub const RTLD_LOCAL: ::c_int = 0; ++pub const RTLD_NODELETE: ::c_int = 0x1000; ++pub const RTLD_NOLOAD: ::c_int = 0x2000; ++pub const RTLD_GLOBAL: ::c_int = 0x100; ++ ++pub const LOG_NTP: ::c_int = 12 << 3; ++pub const LOG_SECURITY: ::c_int = 13 << 3; ++pub const LOG_CONSOLE: ::c_int = 14 << 3; ++pub const LOG_NFACILITIES: ::c_int = 24; ++ ++pub const TIOCEXCL: ::c_uint = 0x2000740d; ++pub const TIOCNXCL: ::c_uint = 0x2000740e; ++pub const TIOCFLUSH: ::c_ulong = 0x80047410; ++pub const TIOCGETA: ::c_uint = 0x402c7413; ++pub const TIOCSETA: ::c_ulong = 0x802c7414; ++pub const TIOCSETAW: ::c_ulong = 0x802c7415; ++pub const TIOCSETAF: ::c_ulong = 0x802c7416; ++pub const TIOCGETD: ::c_uint = 0x4004741a; ++pub const TIOCSETD: ::c_ulong = 0x8004741b; ++pub const TIOCGDRAINWAIT: ::c_uint = 0x40047456; ++pub const TIOCSDRAINWAIT: ::c_ulong = 0x80047457; ++pub const TIOCTIMESTAMP: ::c_uint = 0x40107459; ++pub const TIOCMGDTRWAIT: ::c_uint = 0x4004745a; ++pub const TIOCMSDTRWAIT: ::c_ulong = 0x8004745b; ++pub const TIOCDRAIN: ::c_uint = 0x2000745e; ++pub const TIOCEXT: ::c_ulong = 0x80047460; ++pub const TIOCSCTTY: ::c_uint = 0x20007461; ++pub const TIOCCONS: ::c_ulong = 0x80047462; ++pub const TIOCGSID: ::c_uint = 0x40047463; ++pub const TIOCSTAT: ::c_uint = 0x20007465; ++pub const TIOCUCNTL: ::c_ulong = 0x80047466; ++pub const TIOCSWINSZ: ::c_ulong = 0x80087467; ++pub const TIOCGWINSZ: ::c_uint = 0x40087468; ++pub const TIOCMGET: ::c_uint = 0x4004746a; ++pub const TIOCM_LE: ::c_int = 0x1; ++pub const TIOCM_DTR: ::c_int = 0x2; ++pub const TIOCM_RTS: ::c_int = 0x4; ++pub const TIOCM_ST: ::c_int = 0x8; ++pub const TIOCM_SR: ::c_int = 0x10; ++pub const TIOCM_CTS: ::c_int = 0x20; ++pub const TIOCM_RI: ::c_int = 0x80; ++pub const TIOCM_DSR: ::c_int = 0x100; ++pub const TIOCM_CD: ::c_int = 0x40; ++pub const TIOCM_CAR: ::c_int = 0x40; ++pub const TIOCM_RNG: ::c_int = 0x80; ++pub const TIOCMBIC: ::c_ulong = 0x8004746b; ++pub const TIOCMBIS: ::c_ulong = 0x8004746c; ++pub const TIOCMSET: ::c_ulong = 0x8004746d; ++pub const TIOCSTART: ::c_uint = 0x2000746e; ++pub const TIOCSTOP: ::c_uint = 0x2000746f; ++pub const TIOCPKT: ::c_ulong = 0x80047470; ++pub const TIOCPKT_DATA: ::c_int = 0x0; ++pub const TIOCPKT_FLUSHREAD: ::c_int = 0x1; ++pub const TIOCPKT_FLUSHWRITE: ::c_int = 0x2; ++pub const TIOCPKT_STOP: ::c_int = 0x4; ++pub const TIOCPKT_START: ::c_int = 0x8; ++pub const TIOCPKT_NOSTOP: ::c_int = 0x10; ++pub const TIOCPKT_DOSTOP: ::c_int = 0x20; ++pub const TIOCPKT_IOCTL: ::c_int = 0x40; ++pub const TIOCNOTTY: ::c_uint = 0x20007471; ++pub const TIOCSTI: ::c_ulong = 0x80017472; ++pub const TIOCOUTQ: ::c_uint = 0x40047473; ++pub const TIOCSPGRP: ::c_ulong = 0x80047476; ++pub const TIOCGPGRP: ::c_uint = 0x40047477; ++pub const TIOCCDTR: ::c_uint = 0x20007478; ++pub const TIOCSDTR: ::c_uint = 0x20007479; ++pub const TIOCCBRK: ::c_uint = 0x2000747a; ++pub const TIOCSBRK: ::c_uint = 0x2000747b; ++pub const TTYDISC: ::c_int = 0x0; ++pub const SLIPDISC: ::c_int = 0x4; ++pub const PPPDISC: ::c_int = 0x5; ++pub const NETGRAPHDISC: ::c_int = 0x6; ++ ++pub const B0: speed_t = 0; ++pub const B50: speed_t = 50; ++pub const B75: speed_t = 75; ++pub const B110: speed_t = 110; ++pub const B134: speed_t = 134; ++pub const B150: speed_t = 150; ++pub const B200: speed_t = 200; ++pub const B300: speed_t = 300; ++pub const B600: speed_t = 600; ++pub const B1200: speed_t = 1200; ++pub const B1800: speed_t = 1800; ++pub const B2400: speed_t = 2400; ++pub const B4800: speed_t = 4800; ++pub const B9600: speed_t = 9600; ++pub const B19200: speed_t = 19200; ++pub const B38400: speed_t = 38400; ++pub const B7200: speed_t = 7200; ++pub const B14400: speed_t = 14400; ++pub const B28800: speed_t = 28800; ++pub const B57600: speed_t = 57600; ++pub const B76800: speed_t = 76800; ++pub const B115200: speed_t = 115200; ++pub const B230400: speed_t = 230400; ++pub const EXTA: speed_t = 19200; ++pub const EXTB: speed_t = 38400; ++ ++pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; ++ ++pub const CRTSCTS: ::tcflag_t = 0x00030000; ++pub const CCTS_OFLOW: ::tcflag_t = 0x00010000; ++pub const CRTS_IFLOW: ::tcflag_t = 0x00020000; ++pub const CDTR_IFLOW: ::tcflag_t = 0x00040000; ++pub const CDSR_OFLOW: ::tcflag_t = 0x00080000; ++pub const CCAR_OFLOW: ::tcflag_t = 0x00100000; ++pub const VERASE2: usize = 7; ++pub const OCRNL: ::tcflag_t = 0x10; ++pub const ONOCR: ::tcflag_t = 0x20; ++pub const ONLRET: ::tcflag_t = 0x40; ++ ++f! { ++ pub fn WIFCONTINUED(status: ::c_int) -> bool { ++ status == 0x13 ++ } ++ ++ pub fn WSTOPSIG(status: ::c_int) -> ::c_int { ++ status >> 8 ++ } ++ ++ pub fn WIFSIGNALED(status: ::c_int) -> bool { ++ (status & 0o177) != 0o177 && (status & 0o177) != 0 ++ } ++ ++ pub fn WIFSTOPPED(status: ::c_int) -> bool { ++ (status & 0o177) == 0o177 ++ } ++} ++ ++extern { ++ pub fn 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 setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; ++ pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; ++ pub fn getgrouplist(name: *const ::c_char, ++ basegid: ::gid_t, ++ groups: *mut ::gid_t, ++ ngroups: *mut ::c_int) -> ::c_int; ++ pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; ++} ++ ++#[link(name = "util")] ++extern { ++ pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; ++ pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; ++ pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; ++ pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, ++ nitems: ::c_int, sevp: *mut sigevent) -> ::c_int; ++ pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; ++ pub fn getnameinfo(sa: *const ::sockaddr, ++ salen: ::socklen_t, ++ host: *mut ::c_char, ++ hostlen: ::size_t, ++ serv: *mut ::c_char, ++ servlen: ::size_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn kevent(kq: ::c_int, ++ changelist: *const ::kevent, ++ nchanges: ::c_int, ++ eventlist: *mut ::kevent, ++ nevents: ::c_int, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn mincore(addr: *const ::c_void, len: ::size_t, ++ vec: *mut ::c_char) -> ::c_int; ++ pub fn pwritev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int, ++ offset: ::off_t) -> ::ssize_t; ++ pub fn preadv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int, ++ offset: ::off_t) -> ::ssize_t; ++ pub fn sysctlnametomib(name: *const ::c_char, ++ mibp: *mut ::c_int, ++ sizep: *mut ::size_t) ++ -> ::c_int; ++ pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) ++ -> ::c_int; ++ pub fn sysctl(name: *const ::c_int, ++ namelen: ::c_uint, ++ oldp: *mut ::c_void, ++ oldlenp: *mut ::size_t, ++ newp: *const ::c_void, ++ newlen: ::size_t) ++ -> ::c_int; ++ pub fn sysctlbyname(name: *const ::c_char, ++ oldp: *mut ::c_void, ++ oldlenp: *mut ::size_t, ++ newp: *const ::c_void, ++ newlen: ::size_t) ++ -> ::c_int; ++ pub fn 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 newlocale(mask: ::c_int, ++ locale: *const ::c_char, ++ base: ::locale_t) -> ::locale_t; ++ pub fn uselocale(loc: ::locale_t) -> ::locale_t; ++ pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; ++ pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, ++ addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; ++ pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); ++ pub fn pthread_attr_get_np(tid: ::pthread_t, ++ attr: *mut ::pthread_attr_t) -> ::c_int; ++ pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, ++ guardsize: *mut ::size_t) -> ::c_int; ++ pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, ++ stackaddr: *mut *mut ::c_void, ++ stacksize: *mut ::size_t) -> ::c_int; ++ pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, ++ pshared: ::c_int) -> ::c_int; ++ pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, ++ pshared: *mut ::c_int) -> ::c_int; ++ pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, ++ pshared: ::c_int) -> ::c_int; ++ pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, ++ pshared: *mut ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t, ++ val: *mut ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, ++ val: ::c_int) -> ::c_int; ++ pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; ++ pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int; ++ ++ pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; ++ ++ pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t, dev: dev_t) -> ::c_int; ++ pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t) -> ::c_int; ++ pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, ++ clock_id: *mut clockid_t) -> ::c_int; ++ pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, ++ clock_id: ::clockid_t) -> ::c_int; ++ pub fn sethostname(name: *const ::c_char, len: ::c_int) -> ::c_int; ++ pub fn sem_timedwait(sem: *mut sem_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; ++ pub fn ppoll(fds: *mut ::pollfd, ++ nfds: ::nfds_t, ++ timeout: *const ::timespec, ++ sigmask: *const sigset_t) -> ::c_int; ++ pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; ++ pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, ++ envp: *const *const ::c_char) ++ -> ::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 --cc vendor/libc-0.2.31/src/unix/bsd/mod.rs index 000000000,000000000..ef8dafee5 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/mod.rs @@@ -1,0 -1,0 +1,539 @@@ ++use dox::{mem, Option}; ++ ++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 cmsghdr { ++ pub cmsg_len: ::socklen_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::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 IP_MULTICAST_IF: ::c_int = 9; ++pub const IP_MULTICAST_TTL: ::c_int = 10; ++pub const IP_MULTICAST_LOOP: ::c_int = 11; ++ ++pub const IPV6_MULTICAST_LOOP: ::c_int = 11; ++pub const IPV6_V6ONLY: ::c_int = 27; ++ ++pub const ST_RDONLY: ::c_ulong = 1; ++ ++pub const SCM_RIGHTS: ::c_int = 0x01; ++ ++pub const NCCS: usize = 20; ++ ++pub const O_ACCMODE: ::c_int = 0x3; ++pub const O_RDONLY: ::c_int = 0; ++pub const O_WRONLY: ::c_int = 1; ++pub const O_RDWR: ::c_int = 2; ++pub const O_APPEND: ::c_int = 8; ++pub const O_CREAT: ::c_int = 512; ++pub const O_TRUNC: ::c_int = 1024; ++pub const O_EXCL: ::c_int = 2048; ++pub const O_ASYNC: ::c_int = 0x40; ++pub const O_SYNC: ::c_int = 0x80; ++pub const O_NONBLOCK: ::c_int = 0x4; ++pub const O_NOFOLLOW: ::c_int = 0x100; ++pub const O_SHLOCK: ::c_int = 0x10; ++pub const O_EXLOCK: ::c_int = 0x20; ++pub const O_FSYNC: ::c_int = O_SYNC; ++pub const O_NDELAY: ::c_int = O_NONBLOCK; ++ ++pub const F_GETOWN: ::c_int = 5; ++pub const F_SETOWN: ::c_int = 6; ++ ++pub const MNT_FORCE: ::c_int = 0x80000; ++ ++pub const Q_SYNC: ::c_int = 0x600; ++pub const Q_QUOTAON: ::c_int = 0x100; ++pub const Q_QUOTAOFF: ::c_int = 0x200; ++ ++pub const TCIOFF: ::c_int = 3; ++pub const TCION: ::c_int = 4; ++pub const TCOOFF: ::c_int = 1; ++pub const TCOON: ::c_int = 2; ++pub const TCIFLUSH: ::c_int = 1; ++pub const TCOFLUSH: ::c_int = 2; ++pub const TCIOFLUSH: ::c_int = 3; ++pub const TCSANOW: ::c_int = 0; ++pub const TCSADRAIN: ::c_int = 1; ++pub const TCSAFLUSH: ::c_int = 2; ++pub const VEOF: usize = 0; ++pub const VEOL: usize = 1; ++pub const VEOL2: usize = 2; ++pub const VERASE: usize = 3; ++pub const VWERASE: usize = 4; ++pub const VKILL: usize = 5; ++pub const VREPRINT: usize = 6; ++pub const VINTR: usize = 8; ++pub const VQUIT: usize = 9; ++pub const VSUSP: usize = 10; ++pub const VDSUSP: usize = 11; ++pub const VSTART: usize = 12; ++pub const VSTOP: usize = 13; ++pub const VLNEXT: usize = 14; ++pub const VDISCARD: usize = 15; ++pub const VMIN: usize = 16; ++pub const VTIME: usize = 17; ++pub const VSTATUS: usize = 18; ++pub const _POSIX_VDISABLE: ::cc_t = 0xff; ++pub const IGNBRK: ::tcflag_t = 0x00000001; ++pub const BRKINT: ::tcflag_t = 0x00000002; ++pub const IGNPAR: ::tcflag_t = 0x00000004; ++pub const PARMRK: ::tcflag_t = 0x00000008; ++pub const INPCK: ::tcflag_t = 0x00000010; ++pub const ISTRIP: ::tcflag_t = 0x00000020; ++pub const INLCR: ::tcflag_t = 0x00000040; ++pub const IGNCR: ::tcflag_t = 0x00000080; ++pub const ICRNL: ::tcflag_t = 0x00000100; ++pub const IXON: ::tcflag_t = 0x00000200; ++pub const IXOFF: ::tcflag_t = 0x00000400; ++pub const IXANY: ::tcflag_t = 0x00000800; ++pub const IMAXBEL: ::tcflag_t = 0x00002000; ++pub const OPOST: ::tcflag_t = 0x1; ++pub const ONLCR: ::tcflag_t = 0x2; ++pub const OXTABS: ::tcflag_t = 0x4; ++pub const ONOEOT: ::tcflag_t = 0x8; ++pub const CIGNORE: ::tcflag_t = 0x00000001; ++pub const CSIZE: ::tcflag_t = 0x00000300; ++pub const CS5: ::tcflag_t = 0x00000000; ++pub const CS6: ::tcflag_t = 0x00000100; ++pub const CS7: ::tcflag_t = 0x00000200; ++pub const CS8: ::tcflag_t = 0x00000300; ++pub const CSTOPB: ::tcflag_t = 0x00000400; ++pub const CREAD: ::tcflag_t = 0x00000800; ++pub const PARENB: ::tcflag_t = 0x00001000; ++pub const PARODD: ::tcflag_t = 0x00002000; ++pub const HUPCL: ::tcflag_t = 0x00004000; ++pub const CLOCAL: ::tcflag_t = 0x00008000; ++pub const ECHOKE: ::tcflag_t = 0x00000001; ++pub const ECHOE: ::tcflag_t = 0x00000002; ++pub const ECHOK: ::tcflag_t = 0x00000004; ++pub const ECHO: ::tcflag_t = 0x00000008; ++pub const ECHONL: ::tcflag_t = 0x00000010; ++pub const ECHOPRT: ::tcflag_t = 0x00000020; ++pub const ECHOCTL: ::tcflag_t = 0x00000040; ++pub const ISIG: ::tcflag_t = 0x00000080; ++pub const ICANON: ::tcflag_t = 0x00000100; ++pub const ALTWERASE: ::tcflag_t = 0x00000200; ++pub const IEXTEN: ::tcflag_t = 0x00000400; ++pub const EXTPROC: ::tcflag_t = 0x00000800; ++pub const TOSTOP: ::tcflag_t = 0x00400000; ++pub const FLUSHO: ::tcflag_t = 0x00800000; ++pub const NOKERNINFO: ::tcflag_t = 0x02000000; ++pub const PENDIN: ::tcflag_t = 0x20000000; ++pub const NOFLSH: ::tcflag_t = 0x80000000; ++pub const MDMBUF: ::tcflag_t = 0x00100000; ++ ++pub const WNOHANG: ::c_int = 0x00000001; ++pub const WUNTRACED: ::c_int = 0x00000002; ++ ++pub const RTLD_NOW: ::c_int = 0x2; ++pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void; ++pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void; ++pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void; ++ ++pub const LOG_CRON: ::c_int = 9 << 3; ++pub const LOG_AUTHPRIV: ::c_int = 10 << 3; ++pub const LOG_FTP: ::c_int = 11 << 3; ++pub const LOG_PERROR: ::c_int = 0x20; ++ ++pub const TCP_MAXSEG: ::c_int = 2; ++ ++pub const PIPE_BUF: usize = 512; ++ ++pub const POLLRDNORM: ::c_short = 0x040; ++pub const POLLWRNORM: ::c_short = 0x004; ++pub const POLLRDBAND: ::c_short = 0x080; ++pub const POLLWRBAND: ::c_short = 0x100; ++ ++f! { ++ pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { ++ let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ let fd = fd as usize; ++ (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); ++ return ++ } ++ ++ pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { ++ let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ let fd = fd as usize; ++ return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0 ++ } ++ ++ pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { ++ let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ let fd = fd as usize; ++ (*set).fds_bits[fd / bits] |= 1 << (fd % bits); ++ return ++ } ++ ++ pub fn FD_ZERO(set: *mut fd_set) -> () { ++ for slot in (*set).fds_bits.iter_mut() { ++ *slot = 0; ++ } ++ } ++ ++ pub fn WTERMSIG(status: ::c_int) -> ::c_int { ++ status & 0o177 ++ } ++ ++ pub fn WIFEXITED(status: ::c_int) -> bool { ++ (status & 0o177) == 0 ++ } ++ ++ pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { ++ status >> 8 ++ } ++ ++ pub fn WCOREDUMP(status: ::c_int) -> bool { ++ (status & 0o200) != 0 ++ } ++ ++ pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { ++ (cmd << 8) | (type_ & 0x00ff) ++ } ++} ++ ++extern { ++ pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; ++ pub fn freeifaddrs(ifa: *mut ::ifaddrs); ++ pub fn setgroups(ngroups: ::c_int, ++ ptr: *const ::gid_t) -> ::c_int; ++ pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; ++ pub fn kqueue() -> ::c_int; ++ pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int; ++ pub fn syscall(num: ::c_int, ...) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")] ++ pub fn getpwent() -> *mut passwd; ++ pub fn setpwent(); ++ pub fn endpwent(); ++ pub fn getprogname() -> *const ::c_char; ++ pub fn setprogname(name: *const ::c_char); ++ pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; ++ pub fn if_nameindex() -> *mut if_nameindex; ++ pub fn if_freenameindex(ptr: *mut if_nameindex); ++ ++ pub fn getpeereid(socket: ::c_int, ++ euid: *mut ::uid_t, ++ egid: *mut ::gid_t) -> ::c_int; ++ ++ #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] ++ pub fn glob(pattern: *const ::c_char, ++ flags: ::c_int, ++ errfunc: Option ::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 madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) ++ -> ::c_int; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "msync$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__msync13")] ++ pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "recvfrom$UNIX2003")] ++ pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, ++ flags: ::c_int, addr: *mut ::sockaddr, ++ addrlen: *mut ::socklen_t) -> ::ssize_t; ++ pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; ++ pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; ++ pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "bind$UNIX2003")] ++ pub fn bind(socket: ::c_int, address: *const ::sockaddr, ++ address_len: ::socklen_t) -> ::c_int; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "writev$UNIX2003")] ++ pub fn writev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "readv$UNIX2003")] ++ pub fn readv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "sendmsg$UNIX2003")] ++ pub fn sendmsg(fd: ::c_int, ++ msg: *const ::msghdr, ++ flags: ::c_int) -> ::ssize_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "recvmsg$UNIX2003")] ++ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) ++ -> ::ssize_t; ++ ++ pub fn sync(); ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] ++ pub fn getgrgid_r(uid: ::uid_t, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "sigaltstack$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] ++ pub fn sigaltstack(ss: *const stack_t, ++ oss: *mut stack_t) -> ::c_int; ++ pub fn sem_close(sem: *mut sem_t) -> ::c_int; ++ pub fn getdtablesize() -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] ++ pub fn getgrnam_r(name: *const ::c_char, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_sigmask$UNIX2003")] ++ pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, ++ oldset: *mut sigset_t) -> ::c_int; ++ pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; ++ pub fn getgrnam(name: *const ::c_char) -> *mut ::group; ++ pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; ++ pub fn sem_unlink(name: *const ::c_char) -> ::c_int; ++ pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] ++ pub fn getpwnam_r(name: *const ::c_char, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] ++ pub fn getpwuid_r(uid: ::uid_t, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch ="x86"), ++ link_name = "sigwait$UNIX2003")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] ++ pub fn sigwait(set: *const sigset_t, ++ sig: *mut ::c_int) -> ::c_int; ++ pub fn pthread_atfork(prepare: Option, ++ parent: Option, ++ child: Option) -> ::c_int; ++ pub fn getgrgid(gid: ::gid_t) -> *mut ::group; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "popen$UNIX2003")] ++ pub fn popen(command: *const c_char, ++ mode: *const c_char) -> *mut ::FILE; ++ pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::c_int, flags: ::c_int) -> ::c_int; ++ pub fn pthread_create(native: *mut ::pthread_t, ++ attr: *const ::pthread_attr_t, ++ f: extern fn(*mut ::c_void) -> *mut ::c_void, ++ value: *mut ::c_void) -> ::c_int; ++} ++ ++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 --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/mod.rs index 000000000,000000000..e43f2aba8 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/mod.rs @@@ -1,0 -1,0 +1,640 @@@ ++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_NOCTTY : ::c_int = 32768; ++pub const S_IFIFO : mode_t = 4096; ++pub const S_IFCHR : mode_t = 8192; ++pub const S_IFBLK : mode_t = 24576; ++pub const S_IFDIR : mode_t = 16384; ++pub const S_IFREG : mode_t = 32768; ++pub const S_IFLNK : mode_t = 40960; ++pub const S_IFSOCK : mode_t = 49152; ++pub const S_IFMT : mode_t = 61440; ++pub const S_IEXEC : mode_t = 64; ++pub const S_IWRITE : mode_t = 128; ++pub const S_IREAD : mode_t = 256; ++pub const S_IRWXU : mode_t = 448; ++pub const S_IXUSR : mode_t = 64; ++pub const S_IWUSR : mode_t = 128; ++pub const S_IRUSR : mode_t = 256; ++pub const S_IRWXG : mode_t = 56; ++pub const S_IXGRP : mode_t = 8; ++pub const S_IWGRP : mode_t = 16; ++pub const S_IRGRP : mode_t = 32; ++pub const S_IRWXO : mode_t = 7; ++pub const S_IXOTH : mode_t = 1; ++pub const S_IWOTH : mode_t = 2; ++pub const S_IROTH : mode_t = 4; ++pub const F_OK : ::c_int = 0; ++pub const R_OK : ::c_int = 4; ++pub const W_OK : ::c_int = 2; ++pub const X_OK : ::c_int = 1; ++pub const STDIN_FILENO : ::c_int = 0; ++pub const STDOUT_FILENO : ::c_int = 1; ++pub const STDERR_FILENO : ::c_int = 2; ++pub const F_LOCK : ::c_int = 1; ++pub const F_TEST : ::c_int = 3; ++pub const F_TLOCK : ::c_int = 2; ++pub const F_ULOCK : ::c_int = 0; ++pub const F_GETLK: ::c_int = 7; ++pub const F_SETLK: ::c_int = 8; ++pub const F_SETLKW: ::c_int = 9; ++pub const SIGHUP : ::c_int = 1; ++pub const SIGINT : ::c_int = 2; ++pub const SIGQUIT : ::c_int = 3; ++pub const SIGILL : ::c_int = 4; ++pub const SIGABRT : ::c_int = 6; ++pub const SIGEMT: ::c_int = 7; ++pub const SIGFPE : ::c_int = 8; ++pub const SIGKILL : ::c_int = 9; ++pub const SIGSEGV : ::c_int = 11; ++pub const SIGPIPE : ::c_int = 13; ++pub const SIGALRM : ::c_int = 14; ++pub const SIGTERM : ::c_int = 15; ++pub const 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 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_UNSPEC: ::c_int = 0; ++pub const AF_LOCAL: ::c_int = 1; ++pub const AF_UNIX: ::c_int = AF_LOCAL; ++pub const AF_INET: ::c_int = 2; ++pub const AF_IMPLINK: ::c_int = 3; ++pub const AF_PUP: ::c_int = 4; ++pub const AF_CHAOS: ::c_int = 5; ++pub const AF_NS: ::c_int = 6; ++pub const AF_ISO: ::c_int = 7; ++pub const AF_OSI: ::c_int = AF_ISO; ++pub const AF_DATAKIT: ::c_int = 9; ++pub const AF_CCITT: ::c_int = 10; ++pub const AF_SNA: ::c_int = 11; ++pub const AF_DECnet: ::c_int = 12; ++pub const AF_DLI: ::c_int = 13; ++pub const AF_LAT: ::c_int = 14; ++pub const AF_HYLINK: ::c_int = 15; ++pub const AF_APPLETALK: ::c_int = 16; ++pub const AF_LINK: ::c_int = 18; ++pub const pseudo_AF_XTP: ::c_int = 19; ++pub const AF_COIP: ::c_int = 20; ++pub const AF_CNT: ::c_int = 21; ++pub const pseudo_AF_RTIP: ::c_int = 22; ++pub const AF_IPX: ::c_int = 23; ++pub const AF_INET6: ::c_int = 24; ++pub const pseudo_AF_PIP: ::c_int = 25; ++pub const AF_ISDN: ::c_int = 26; ++pub const AF_E164: ::c_int = AF_ISDN; ++pub const AF_NATM: ::c_int = 27; ++ ++pub const PF_UNSPEC: ::c_int = AF_UNSPEC; ++pub const PF_LOCAL: ::c_int = AF_LOCAL; ++pub const PF_UNIX: ::c_int = PF_LOCAL; ++pub const PF_INET: ::c_int = AF_INET; ++pub const PF_IMPLINK: ::c_int = AF_IMPLINK; ++pub const PF_PUP: ::c_int = AF_PUP; ++pub const PF_CHAOS: ::c_int = AF_CHAOS; ++pub const PF_NS: ::c_int = AF_NS; ++pub const PF_ISO: ::c_int = AF_ISO; ++pub const PF_OSI: ::c_int = AF_ISO; ++pub const PF_DATAKIT: ::c_int = AF_DATAKIT; ++pub const PF_CCITT: ::c_int = AF_CCITT; ++pub const PF_SNA: ::c_int = AF_SNA; ++pub const PF_DECnet: ::c_int = AF_DECnet; ++pub const PF_DLI: ::c_int = AF_DLI; ++pub const PF_LAT: ::c_int = AF_LAT; ++pub const PF_HYLINK: ::c_int = AF_HYLINK; ++pub const PF_APPLETALK: ::c_int = AF_APPLETALK; ++pub const PF_LINK: ::c_int = AF_LINK; ++pub const PF_XTP: ::c_int = pseudo_AF_XTP; ++pub const PF_COIP: ::c_int = AF_COIP; ++pub const PF_CNT: ::c_int = AF_CNT; ++pub const PF_IPX: ::c_int = AF_IPX; ++pub const PF_INET6: ::c_int = AF_INET6; ++pub const PF_RTIP: ::c_int = pseudo_AF_RTIP; ++pub const PF_PIP: ::c_int = pseudo_AF_PIP; ++pub const PF_ISDN: ::c_int = AF_ISDN; ++pub const PF_NATM: ::c_int = AF_NATM; ++ ++pub const SOCK_STREAM: ::c_int = 1; ++pub const SOCK_DGRAM: ::c_int = 2; ++pub const SOCK_RAW: ::c_int = 3; ++pub const SOCK_RDM: ::c_int = 4; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++pub const IP_TTL: ::c_int = 4; ++pub const IP_HDRINCL: ::c_int = 2; ++pub const IP_ADD_MEMBERSHIP: ::c_int = 12; ++pub const IP_DROP_MEMBERSHIP: ::c_int = 13; ++ ++pub const 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 SOMAXCONN: ::c_int = 128; ++ ++pub const MSG_OOB: ::c_int = 0x1; ++pub const MSG_PEEK: ::c_int = 0x2; ++pub const MSG_DONTROUTE: ::c_int = 0x4; ++pub const MSG_EOR: ::c_int = 0x8; ++pub const MSG_TRUNC: ::c_int = 0x10; ++pub const MSG_CTRUNC: ::c_int = 0x20; ++pub const MSG_WAITALL: ::c_int = 0x40; ++pub const MSG_DONTWAIT: ::c_int = 0x80; ++pub const MSG_BCAST: ::c_int = 0x100; ++pub const MSG_MCAST: ::c_int = 0x200; ++pub const MSG_NOSIGNAL: ::c_int = 0x400; ++pub const MSG_CMSG_CLOEXEC: ::c_int = 0x800; ++ ++pub const 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 IPPROTO_RAW : ::c_int = 255; ++ ++pub const _SC_ARG_MAX : ::c_int = 1; ++pub const _SC_CHILD_MAX : ::c_int = 2; ++pub const _SC_NGROUPS_MAX : ::c_int = 4; ++pub const _SC_OPEN_MAX : ::c_int = 5; ++pub const _SC_JOB_CONTROL : ::c_int = 6; ++pub const _SC_SAVED_IDS : ::c_int = 7; ++pub const _SC_VERSION : ::c_int = 8; ++pub const _SC_BC_BASE_MAX : ::c_int = 9; ++pub const _SC_BC_DIM_MAX : ::c_int = 10; ++pub const _SC_BC_SCALE_MAX : ::c_int = 11; ++pub const _SC_BC_STRING_MAX : ::c_int = 12; ++pub const _SC_COLL_WEIGHTS_MAX : ::c_int = 13; ++pub const _SC_EXPR_NEST_MAX : ::c_int = 14; ++pub const _SC_LINE_MAX : ::c_int = 15; ++pub const _SC_RE_DUP_MAX : ::c_int = 16; ++pub const _SC_2_VERSION : ::c_int = 17; ++pub const _SC_2_C_BIND : ::c_int = 18; ++pub const _SC_2_C_DEV : ::c_int = 19; ++pub const _SC_2_CHAR_TERM : ::c_int = 20; ++pub const _SC_2_FORT_DEV : ::c_int = 21; ++pub const _SC_2_FORT_RUN : ::c_int = 22; ++pub const _SC_2_LOCALEDEF : ::c_int = 23; ++pub const _SC_2_SW_DEV : ::c_int = 24; ++pub const _SC_2_UPE : ::c_int = 25; ++pub const _SC_STREAM_MAX : ::c_int = 26; ++pub const _SC_TZNAME_MAX : ::c_int = 27; ++pub const _SC_PAGESIZE : ::c_int = 28; ++pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; ++pub const _SC_FSYNC : ::c_int = 29; ++pub const _SC_XOPEN_SHM : ::c_int = 30; ++ ++pub const Q_GETQUOTA: ::c_int = 0x300; ++pub const Q_SETQUOTA: ::c_int = 0x400; ++ ++pub const RTLD_GLOBAL: ::c_int = 0x100; ++ ++pub const LOG_NFACILITIES: ::c_int = 24; ++ ++pub const HW_NCPU: ::c_int = 3; ++ ++pub const B0: speed_t = 0; ++pub const B50: speed_t = 50; ++pub const B75: speed_t = 75; ++pub const B110: speed_t = 110; ++pub const B134: speed_t = 134; ++pub const B150: speed_t = 150; ++pub const B200: speed_t = 200; ++pub const B300: speed_t = 300; ++pub const B600: speed_t = 600; ++pub const B1200: speed_t = 1200; ++pub const B1800: speed_t = 1800; ++pub const B2400: speed_t = 2400; ++pub const B4800: speed_t = 4800; ++pub const B9600: speed_t = 9600; ++pub const B19200: speed_t = 19200; ++pub const B38400: speed_t = 38400; ++pub const B7200: speed_t = 7200; ++pub const B14400: speed_t = 14400; ++pub const B28800: speed_t = 28800; ++pub const B57600: speed_t = 57600; ++pub const B76800: speed_t = 76800; ++pub const B115200: speed_t = 115200; ++pub const B230400: speed_t = 230400; ++pub const EXTA: speed_t = 19200; ++pub const EXTB: speed_t = 38400; ++ ++pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; ++ ++pub const CRTSCTS: ::tcflag_t = 0x00010000; ++pub const CRTS_IFLOW: ::tcflag_t = CRTSCTS; ++pub const CCTS_OFLOW: ::tcflag_t = CRTSCTS; ++pub const OCRNL: ::tcflag_t = 0x10; ++ ++pub const TIOCM_LE: ::c_int = 0o0001; ++pub const TIOCM_DTR: ::c_int = 0o0002; ++pub const TIOCM_RTS: ::c_int = 0o0004; ++pub const TIOCM_ST: ::c_int = 0o0010; ++pub const TIOCM_SR: ::c_int = 0o0020; ++pub const TIOCM_CTS: ::c_int = 0o0040; ++pub const TIOCM_CAR: ::c_int = 0o0100; ++pub const TIOCM_RNG: ::c_int = 0o0200; ++pub const TIOCM_DSR: ::c_int = 0o0400; ++pub const TIOCM_CD: ::c_int = TIOCM_CAR; ++pub const TIOCM_RI: ::c_int = TIOCM_RNG; ++ ++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; ++ #[cfg_attr(target_os = "netbsd", link_name = "__clock_settime50")] ++ pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; ++ pub fn __errno() -> *mut ::c_int; ++ pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) ++ -> ::c_int; ++ pub fn memrchr(cx: *const ::c_void, ++ c: ::c_int, ++ n: ::size_t) -> *mut ::c_void; ++ pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; ++ pub fn mkostemps(template: *mut ::c_char, ++ suffixlen: ::c_int, ++ flags: ::c_int) -> ::c_int; ++ pub fn pwritev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int, ++ offset: ::off_t) -> ::ssize_t; ++ pub fn preadv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int, ++ offset: ::off_t) -> ::ssize_t; ++ pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; ++ pub fn 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 fdopendir(fd: ::c_int) -> *mut ::DIR; ++ ++ pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t, dev: dev_t) -> ::c_int; ++ pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t) -> ::c_int; ++ pub fn sem_timedwait(sem: *mut sem_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, ++ clock_id: ::clockid_t) -> ::c_int; ++ pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; ++ pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; ++ ++ pub fn getgrouplist(name: *const ::c_char, ++ basegid: ::gid_t, ++ groups: *mut ::gid_t, ++ ngroups: *mut ::c_int) -> ::c_int; ++ pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; ++ pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, ++ envp: *const *const ::c_char) ++ -> ::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 --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/netbsd/mod.rs index 000000000,000000000..df9bbcb9b new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/netbsd/mod.rs @@@ -1,0 -1,0 +1,911 @@@ ++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; ++pub type idtype_t = ::c_int; ++ ++s! { ++ pub struct aiocb { ++ pub aio_offset: ::off_t, ++ pub aio_buf: *mut ::c_void, ++ pub aio_nbytes: ::size_t, ++ pub aio_fildes: ::c_int, ++ pub aio_lio_opcode: ::c_int, ++ pub aio_reqprio: ::c_int, ++ pub aio_sigevent: ::sigevent, ++ _state: ::c_int, ++ _errno: ::c_int, ++ _retval: ::ssize_t ++ } ++ ++ pub struct 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 sigevent { ++ pub sigev_notify: ::c_int, ++ pub sigev_signo: ::c_int, ++ pub sigev_value: ::sigval, ++ __unused1: *mut ::c_void, //actually a function pointer ++ pub sigev_notify_attributes: *mut ::c_void ++ } ++ ++ pub struct sigset_t { ++ __bits: [u32; 4], ++ } ++ ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ pub st_mode: ::mode_t, ++ pub st_ino: ::ino_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ pub st_atime: ::time_t, ++ pub st_atimensec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtimensec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctimensec: ::c_long, ++ pub st_birthtime: ::time_t, ++ pub st_birthtimensec: ::c_long, ++ pub st_size: ::off_t, ++ pub st_blocks: ::blkcnt_t, ++ pub st_blksize: ::blksize_t, ++ pub st_flags: ::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_rwlockattr_t { ++ ptra_magic: ::c_uint, ++ ptra_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 struct if_data { ++ pub ifi_type: ::c_uchar, ++ pub ifi_addrlen: ::c_uchar, ++ pub ifi_hdrlen: ::c_uchar, ++ pub ifi_link_state: ::c_int, ++ pub ifi_mtu: u64, ++ pub ifi_metric: u64, ++ pub ifi_baudrate: u64, ++ pub ifi_ipackets: u64, ++ pub ifi_ierrors: u64, ++ pub ifi_opackets: u64, ++ pub ifi_oerrors: u64, ++ pub ifi_collisions: u64, ++ pub ifi_ibytes: u64, ++ pub ifi_obytes: u64, ++ pub ifi_imcasts: u64, ++ pub ifi_omcasts: u64, ++ pub ifi_iqdrops: u64, ++ pub ifi_noproto: u64, ++ pub ifi_lastchange: ::timespec, ++ } ++ ++ pub struct if_msghdr { ++ pub ifm_msglen: ::c_ushort, ++ pub ifm_version: ::c_uchar, ++ pub ifm_type: ::c_uchar, ++ pub ifm_addrs: ::c_int, ++ pub ifm_flags: ::c_int, ++ pub ifm_index: ::c_ushort, ++ pub ifm_data: if_data, ++ } ++} ++ ++pub const AT_FDCWD: ::c_int = -100; ++pub const AT_EACCESS: ::c_int = 0x100; ++pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200; ++pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; ++pub const AT_REMOVEDIR: ::c_int = 0x800; ++ ++pub const LC_COLLATE_MASK: ::c_int = (1 << ::LC_COLLATE); ++pub const LC_CTYPE_MASK: ::c_int = (1 << ::LC_CTYPE); ++pub const LC_MONETARY_MASK: ::c_int = (1 << ::LC_MONETARY); ++pub const LC_NUMERIC_MASK: ::c_int = (1 << ::LC_NUMERIC); ++pub const LC_TIME_MASK: ::c_int = (1 << ::LC_TIME); ++pub const LC_MESSAGES_MASK: ::c_int = (1 << ::LC_MESSAGES); ++pub const LC_ALL_MASK: ::c_int = !0; ++ ++pub const ERA: ::nl_item = 52; ++pub const ERA_D_FMT: ::nl_item = 53; ++pub const ERA_D_T_FMT: ::nl_item = 54; ++pub const ERA_T_FMT: ::nl_item = 55; ++pub const ALT_DIGITS: ::nl_item = 56; ++ ++pub const O_CLOEXEC: ::c_int = 0x400000; ++pub const O_ALT_IO: ::c_int = 0x40000; ++pub const O_NOSIGPIPE: ::c_int = 0x1000000; ++pub const O_SEARCH: ::c_int = 0x800000; ++pub const O_DIRECTORY: ::c_int = 0x200000; ++pub const O_DIRECT : ::c_int = 0x00080000; ++pub const O_RSYNC : ::c_int = 0x00020000; ++ ++pub const MS_SYNC : ::c_int = 0x4; ++pub const MS_INVALIDATE : ::c_int = 0x2; ++ ++pub const RLIM_NLIMITS: ::c_int = 12; ++ ++pub const 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 SOCK_CONN_DGRAM: ::c_int = 6; ++pub const SOCK_DCCP: ::c_int = SOCK_CONN_DGRAM; ++pub const SOCK_NOSIGPIPE: ::c_int = 0x40000000; ++pub const SOCK_FLAGS_MASK: ::c_int = 0xf0000000; ++ ++pub const SO_SNDTIMEO: ::c_int = 0x100b; ++pub const SO_RCVTIMEO: ::c_int = 0x100c; ++pub const SO_ACCEPTFILTER: ::c_int = 0x1000; ++pub const SO_TIMESTAMP: ::c_int = 0x2000; ++pub const SO_OVERFLOWED: ::c_int = 0x1009; ++pub const SO_NOHEADER: ::c_int = 0x100a; ++ ++// sys/netinet/in.h ++// Protocols (RFC 1700) ++// NOTE: These are in addition to the constants defined in src/unix/mod.rs ++ ++// IPPROTO_IP defined in src/unix/mod.rs ++/// Hop-by-hop option header ++pub const IPPROTO_HOPOPTS: ::c_int = 0; ++// IPPROTO_ICMP defined in src/unix/mod.rs ++/// group mgmt protocol ++pub const IPPROTO_IGMP: ::c_int = 2; ++/// gateway^2 (deprecated) ++pub const IPPROTO_GGP: ::c_int = 3; ++/// for compatibility ++pub const IPPROTO_IPIP: ::c_int = 4; ++// IPPROTO_TCP defined in src/unix/mod.rs ++/// exterior gateway protocol ++pub const IPPROTO_EGP: ::c_int = 8; ++/// pup ++pub const IPPROTO_PUP: ::c_int = 12; ++// IPPROTO_UDP defined in src/unix/mod.rs ++/// xns idp ++pub const IPPROTO_IDP: ::c_int = 22; ++/// tp-4 w/ class negotiation ++pub const IPPROTO_TP: ::c_int = 29; ++/// DCCP ++pub const IPPROTO_DCCP: ::c_int = 33; ++// IPPROTO_IPV6 defined in src/unix/mod.rs ++/// IP6 routing header ++pub const IPPROTO_ROUTING: ::c_int = 43; ++/// IP6 fragmentation header ++pub const IPPROTO_FRAGMENT: ::c_int = 44; ++/// resource reservation ++pub const IPPROTO_RSVP: ::c_int = 46; ++/// General Routing Encap. ++pub const IPPROTO_GRE: ::c_int = 47; ++/// IP6 Encap Sec. Payload ++pub const IPPROTO_ESP: ::c_int = 50; ++/// IP6 Auth Header ++pub const IPPROTO_AH: ::c_int = 51; ++/// IP Mobility RFC 2004 ++pub const IPPROTO_MOBILE: ::c_int = 55; ++/// IPv6 ICMP ++pub const IPPROTO_IPV6_ICMP: ::c_int = 58; ++// IPPROTO_ICMPV6 defined in src/unix/mod.rs ++/// IP6 no next header ++pub const IPPROTO_NONE: ::c_int = 59; ++/// IP6 destination option ++pub const IPPROTO_DSTOPTS: ::c_int = 60; ++/// ISO cnlp ++pub const IPPROTO_EON: ::c_int = 80; ++/// Ethernet-in-IP ++pub const IPPROTO_ETHERIP: ::c_int = 97; ++/// encapsulation header ++pub const IPPROTO_ENCAP: ::c_int = 98; ++/// Protocol indep. multicast ++pub const IPPROTO_PIM: ::c_int = 103; ++/// IP Payload Comp. Protocol ++pub const IPPROTO_IPCOMP: ::c_int = 108; ++/// VRRP RFC 2338 ++pub const IPPROTO_VRRP: ::c_int = 112; ++/// Common Address Resolution Protocol ++pub const IPPROTO_CARP: ::c_int = 112; ++/// L2TPv3 ++// TEMP: Disabled for now; this constant was added to NetBSD on 2017-02-16, ++// but isn't yet supported by the NetBSD rumprun kernel image used for ++// libc testing. ++//pub const IPPROTO_L2TP: ::c_int = 115; ++/// SCTP ++pub const IPPROTO_SCTP: ::c_int = 132; ++/// PFSYNC ++pub const IPPROTO_PFSYNC: ::c_int = 240; ++pub const IPPROTO_MAX: ::c_int = 256; ++ ++/// last return value of *_input(), meaning "all job for this pkt is done". ++pub const IPPROTO_DONE: ::c_int = 257; ++ ++/// sysctl placeholder for (FAST_)IPSEC ++pub const CTL_IPPROTO_IPSEC: ::c_int = 258; ++ ++pub const AF_OROUTE: ::c_int = 17; ++pub const AF_ARP: ::c_int = 28; ++pub const pseudo_AF_KEY: ::c_int = 29; ++pub const pseudo_AF_HDRCMPLT: ::c_int = 30; ++pub const AF_BLUETOOTH: ::c_int = 31; ++pub const AF_IEEE80211: ::c_int = 32; ++pub const AF_MPLS: ::c_int = 33; ++pub const AF_ROUTE: ::c_int = 34; ++pub const AF_MAX: ::c_int = 35; ++ ++pub const NET_MAXID: ::c_int = AF_MAX; ++pub const NET_RT_DUMP: ::c_int = 1; ++pub const NET_RT_FLAGS: ::c_int = 2; ++pub const NET_RT_OOIFLIST: ::c_int = 3; ++pub const NET_RT_OIFLIST: ::c_int = 4; ++pub const NET_RT_IFLIST: ::c_int = 5; ++pub const NET_RT_MAXID: ::c_int = 6; ++ ++pub const PF_OROUTE: ::c_int = AF_OROUTE; ++pub const PF_ARP: ::c_int = AF_ARP; ++pub const PF_KEY: ::c_int = pseudo_AF_KEY; ++pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; ++pub const PF_MPLS: ::c_int = AF_MPLS; ++pub const PF_ROUTE: ::c_int = AF_ROUTE; ++pub const PF_MAX: ::c_int = AF_MAX; ++ ++pub const MSG_NBIO: ::c_int = 0x1000; ++pub const MSG_WAITFORONE: ::c_int = 0x2000; ++pub const MSG_NOTIFICATION: ::c_int = 0x4000; ++ ++pub const SCM_TIMESTAMP: ::c_int = 0x08; ++pub const SCM_CREDS: ::c_int = 0x10; ++ ++pub const O_DSYNC : ::c_int = 0x10000; ++ ++pub const MAP_RENAME : ::c_int = 0x20; ++pub const MAP_NORESERVE : ::c_int = 0x40; ++pub const MAP_HASSEMAPHORE : ::c_int = 0x200; ++pub const MAP_WIRED: ::c_int = 0x800; ++ ++pub const _PC_LINK_MAX : ::c_int = 1; ++pub const _PC_MAX_CANON : ::c_int = 2; ++pub const _PC_MAX_INPUT : ::c_int = 3; ++pub const _PC_NAME_MAX : ::c_int = 4; ++pub const _PC_PATH_MAX : ::c_int = 5; ++pub const _PC_PIPE_BUF : ::c_int = 6; ++pub const _PC_CHOWN_RESTRICTED : ::c_int = 7; ++pub const _PC_NO_TRUNC : ::c_int = 8; ++pub const _PC_VDISABLE : ::c_int = 9; ++pub const _PC_SYNC_IO : ::c_int = 10; ++pub const _PC_FILESIZEBITS : ::c_int = 11; ++pub const _PC_SYMLINK_MAX : ::c_int = 12; ++pub const _PC_2_SYMLINKS : ::c_int = 13; ++pub const _PC_ACL_EXTENDED : ::c_int = 14; ++pub const _PC_MIN_HOLE_SIZE : ::c_int = 15; ++ ++pub const _SC_SYNCHRONIZED_IO : ::c_int = 31; ++pub const _SC_IOV_MAX : ::c_int = 32; ++pub const _SC_MAPPED_FILES : ::c_int = 33; ++pub const _SC_MEMLOCK : ::c_int = 34; ++pub const _SC_MEMLOCK_RANGE : ::c_int = 35; ++pub const _SC_MEMORY_PROTECTION : ::c_int = 36; ++pub const _SC_LOGIN_NAME_MAX : ::c_int = 37; ++pub const _SC_MONOTONIC_CLOCK : ::c_int = 38; ++pub const _SC_CLK_TCK : ::c_int = 39; ++pub const _SC_ATEXIT_MAX : ::c_int = 40; ++pub const _SC_THREADS : ::c_int = 41; ++pub const _SC_SEMAPHORES : ::c_int = 42; ++pub const _SC_BARRIERS : ::c_int = 43; ++pub const _SC_TIMERS : ::c_int = 44; ++pub const _SC_SPIN_LOCKS : ::c_int = 45; ++pub const _SC_READER_WRITER_LOCKS : ::c_int = 46; ++pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 47; ++pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 48; ++pub const _SC_CLOCK_SELECTION : ::c_int = 49; ++pub const _SC_ASYNCHRONOUS_IO : ::c_int = 50; ++pub const _SC_AIO_LISTIO_MAX : ::c_int = 51; ++pub const _SC_AIO_MAX : ::c_int = 52; ++pub const _SC_MESSAGE_PASSING : ::c_int = 53; ++pub const _SC_MQ_OPEN_MAX : ::c_int = 54; ++pub const _SC_MQ_PRIO_MAX : ::c_int = 55; ++pub const _SC_PRIORITY_SCHEDULING : ::c_int = 56; ++pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 57; ++pub const _SC_THREAD_KEYS_MAX : ::c_int = 58; ++pub const _SC_THREAD_STACK_MIN : ::c_int = 59; ++pub const _SC_THREAD_THREADS_MAX : ::c_int = 60; ++pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 61; ++pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 62; ++pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 63; ++pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 64; ++pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 65; ++pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 66; ++pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 67; ++pub const _SC_TTY_NAME_MAX : ::c_int = 68; ++pub const _SC_HOST_NAME_MAX : ::c_int = 69; ++pub const _SC_PASS_MAX : ::c_int = 70; ++pub const _SC_REGEXP : ::c_int = 71; ++pub const _SC_SHELL : ::c_int = 72; ++pub const _SC_SYMLOOP_MAX : ::c_int = 73; ++pub const _SC_V6_ILP32_OFF32 : ::c_int = 74; ++pub const _SC_V6_ILP32_OFFBIG : ::c_int = 75; ++pub const _SC_V6_LP64_OFF64 : ::c_int = 76; ++pub const _SC_V6_LPBIG_OFFBIG : ::c_int = 77; ++pub const _SC_2_PBS : ::c_int = 80; ++pub const _SC_2_PBS_ACCOUNTING : ::c_int = 81; ++pub const _SC_2_PBS_CHECKPOINT : ::c_int = 82; ++pub const _SC_2_PBS_LOCATE : ::c_int = 83; ++pub const _SC_2_PBS_MESSAGE : ::c_int = 84; ++pub const _SC_2_PBS_TRACK : ::c_int = 85; ++pub const _SC_SPAWN : ::c_int = 86; ++pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 87; ++pub const _SC_TIMER_MAX : ::c_int = 88; ++pub const _SC_SEM_NSEMS_MAX : ::c_int = 89; ++pub const _SC_CPUTIME : ::c_int = 90; ++pub const _SC_THREAD_CPUTIME : ::c_int = 91; ++pub const _SC_DELAYTIMER_MAX : ::c_int = 92; ++// These two variables will be supported in NetBSD 8.0 ++// pub const _SC_SIGQUEUE_MAX : ::c_int = 93; ++// pub const _SC_REALTIME_SIGNALS : ::c_int = 94; ++pub const _SC_PHYS_PAGES : ::c_int = 121; ++pub const _SC_NPROCESSORS_CONF : ::c_int = 1001; ++pub const _SC_NPROCESSORS_ONLN : ::c_int = 1002; ++pub const _SC_SCHED_RT_TS : ::c_int = 2001; ++pub const _SC_SCHED_PRI_MIN : ::c_int = 2002; ++pub const _SC_SCHED_PRI_MAX : ::c_int = 2003; ++ ++pub const FD_SETSIZE: usize = 0x100; ++ ++pub const ST_NOSUID: ::c_ulong = 8; ++ ++pub const 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 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; ++ ++pub const AIO_CANCELED: ::c_int = 1; ++pub const AIO_NOTCANCELED: ::c_int = 2; ++pub const AIO_ALLDONE: ::c_int = 3; ++pub const LIO_NOP: ::c_int = 0; ++pub const LIO_WRITE: ::c_int = 1; ++pub const LIO_READ: ::c_int = 2; ++pub const LIO_WAIT: ::c_int = 1; ++pub const LIO_NOWAIT: ::c_int = 0; ++ ++pub const SIGEV_NONE: ::c_int = 0; ++pub const SIGEV_SIGNAL: ::c_int = 1; ++pub const SIGEV_THREAD: ::c_int = 2; ++ ++pub const WSTOPPED: ::c_int = 0x00000002; // same as WUNTRACED ++pub const WCONTINUED: ::c_int = 0x00000010; ++pub const WEXITED: ::c_int = 0x000000020; ++pub const WNOWAIT: ::c_int = 0x00010000; ++ ++pub const P_ALL: idtype_t = 0; ++pub const P_PID: idtype_t = 1; ++pub const P_PGID: idtype_t = 4; ++ ++pub const B460800: ::speed_t = 460800; ++pub const B921600: ::speed_t = 921600; ++ ++pub const ONOCR: ::tcflag_t = 0x20; ++pub const ONLRET: ::tcflag_t = 0x40; ++pub const CDTRCTS: ::tcflag_t = 0x00020000; ++pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS; ++ ++pub const SOCK_CLOEXEC: ::c_int = 0x10000000; ++pub const SOCK_NONBLOCK: ::c_int = 0x20000000; ++ ++// dirfd() is a macro on netbsd to access ++// the first field of the struct where dirp points to: ++// http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36 ++f! { ++ pub fn dirfd(dirp: *mut ::DIR) -> ::c_int { ++ unsafe { *(dirp as *const ::c_int) } ++ } ++ ++ pub fn WIFCONTINUED(status: ::c_int) -> bool { ++ status == 0xffff ++ } ++} ++ ++extern { ++ pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; ++ pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; ++ #[link_name = "__aio_suspend50"] ++ pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; ++ pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, ++ nitems: ::c_int, sevp: *mut sigevent) -> ::c_int; ++ ++ 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(request: ::c_int, ++ pid: ::pid_t, ++ addr: *mut ::c_void, ++ data: ::c_int) -> ::c_int; ++ pub fn pthread_setname_np(t: ::pthread_t, ++ name: *const ::c_char, ++ arg: *mut ::c_void) -> ::c_int; ++ pub fn pthread_getattr_np(native: ::pthread_t, ++ attr: *mut ::pthread_attr_t) -> ::c_int; ++ pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, ++ guardsize: *mut ::size_t) -> ::c_int; ++ pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, ++ stackaddr: *mut *mut ::c_void, ++ stacksize: *mut ::size_t) -> ::c_int; ++ #[link_name = "__sigtimedwait50"] ++ pub fn sigtimedwait(set: *const sigset_t, ++ info: *mut siginfo_t, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn sigwaitinfo(set: *const sigset_t, ++ info: *mut siginfo_t) -> ::c_int; ++ pub fn duplocale(base: ::locale_t) -> ::locale_t; ++ pub fn freelocale(loc: ::locale_t); ++ pub fn localeconv_l(loc: ::locale_t) -> *mut lconv; ++ pub fn newlocale(mask: ::c_int, ++ locale: *const ::c_char, ++ base: ::locale_t) -> ::locale_t; ++ #[link_name = "__settimeofday50"] ++ pub fn settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int; ++} ++ ++mod other; ++pub use self::other::*; diff --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/netbsd/other/b32/mod.rs index 000000000,000000000..9b0b338b9 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/netbsd/other/b32/mod.rs @@@ -1,0 -1,0 +1,2 @@@ ++pub type c_long = i32; ++pub type c_ulong = u32; diff --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/netbsd/other/b64/mod.rs index 000000000,000000000..b07c476aa new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/netbsd/other/b64/mod.rs @@@ -1,0 -1,0 +1,2 @@@ ++pub type c_long = i64; ++pub type c_ulong = u64; diff --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/netbsd/other/mod.rs index 000000000,000000000..3a9bf0866 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/netbsd/other/mod.rs @@@ -1,0 -1,0 +1,14 @@@ ++cfg_if! { ++ if #[cfg(any(target_arch = "sparc64", ++ target_arch = "x86_64"))] { ++ mod b64; ++ pub use self::b64::*; ++ } else if #[cfg(any(target_arch = "arm", ++ target_arch = "powerpc", ++ target_arch = "x86"))] { ++ mod b32; ++ pub use self::b32::*; ++ } else { ++ // Unknown target_arch ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/bitrig.rs index 000000000,000000000..695cf68dc new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/bitrig.rs @@@ -1,0 -1,0 +1,75 @@@ ++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 --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/mod.rs index 000000000,000000000..227e8b365 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/mod.rs @@@ -1,0 -1,0 +1,708 @@@ ++use unix::bsd::O_SYNC; ++ ++pub type clock_t = i64; ++pub type suseconds_t = ::c_long; ++pub type dev_t = i32; ++pub type sigset_t = ::c_uint; ++pub type blksize_t = ::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; ++pub type pthread_rwlockattr_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, ++ #[cfg(target_pointer_width = "32")] ++ __pad: [u8; 112], ++ #[cfg(target_pointer_width = "64")] ++ __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 struct if_data { ++ pub ifi_type: ::c_uchar, ++ pub ifi_addrlen: ::c_uchar, ++ pub ifi_hdrlen: ::c_uchar, ++ pub ifi_link_state: ::c_uchar, ++ pub ifi_mtu: u32, ++ pub ifi_metric: u32, ++ pub ifi_rdomain: u32, ++ pub ifi_baudrate: u64, ++ pub ifi_ipackets: u64, ++ pub ifi_ierrors: u64, ++ pub ifi_opackets: u64, ++ pub ifi_oerrors: u64, ++ pub ifi_collisions: u64, ++ pub ifi_ibytes: u64, ++ pub ifi_obytes: u64, ++ pub ifi_imcasts: u64, ++ pub ifi_omcasts: u64, ++ pub ifi_iqdrops: u64, ++ pub ifi_oqdrops: u64, ++ pub ifi_noproto: u64, ++ pub ifi_capabilities: u32, ++ pub ifi_lastchange: ::timeval, ++ } ++ ++ pub struct if_msghdr { ++ pub ifm_msglen: ::c_ushort, ++ pub ifm_version: ::c_uchar, ++ pub ifm_type: ::c_uchar, ++ pub ifm_hdrlen: ::c_ushort, ++ pub ifm_index: ::c_ushort, ++ pub ifm_tableid: ::c_ushort, ++ pub ifm_pad1: ::c_uchar, ++ pub ifm_pad2: ::c_uchar, ++ pub ifm_addrs: ::c_int, ++ pub ifm_flags: ::c_int, ++ pub ifm_xflags: ::c_int, ++ pub ifm_data: if_data, ++ } ++} ++ ++pub const UT_NAMESIZE: usize = 32; ++pub const UT_LINESIZE: usize = 8; ++pub const UT_HOSTSIZE: usize = 256; ++ ++pub const O_CLOEXEC: ::c_int = 0x10000; ++pub const O_DIRECTORY: ::c_int = 0x20000; ++pub const O_RSYNC: ::c_int = O_SYNC; ++ ++pub const MS_SYNC : ::c_int = 0x0002; ++pub const MS_INVALIDATE : ::c_int = 0x0004; ++ ++pub const PTHREAD_STACK_MIN : ::size_t = 2048; ++ ++pub const POLLNORM: ::c_short = ::POLLRDNORM; ++ ++pub const ENOATTR : ::c_int = 83; ++pub const EILSEQ : ::c_int = 84; ++pub const EOVERFLOW : ::c_int = 87; ++pub const ECANCELED : ::c_int = 88; ++pub const EIDRM : ::c_int = 89; ++pub const ENOMSG : ::c_int = 90; ++pub const ENOTSUP : ::c_int = 91; ++pub const ELAST : ::c_int = 91; ++ ++pub const F_DUPFD_CLOEXEC : ::c_int = 10; ++ ++pub const AT_FDCWD: ::c_int = -100; ++pub const AT_EACCESS: ::c_int = 0x01; ++pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x02; ++pub const AT_SYMLINK_FOLLOW: ::c_int = 0x04; ++pub const AT_REMOVEDIR: ::c_int = 0x08; ++ ++pub const RLIM_NLIMITS: ::c_int = 9; ++ ++pub const SO_TIMESTAMP: ::c_int = 0x0800; ++pub const SO_SNDTIMEO: ::c_int = 0x1005; ++pub const SO_RCVTIMEO: ::c_int = 0x1006; ++pub const SO_BINDANY: ::c_int = 0x1000; ++pub const SO_NETPROC: ::c_int = 0x1020; ++pub const SO_RTABLE: ::c_int = 0x1021; ++pub const SO_PEERCRED: ::c_int = 0x1022; ++pub const SO_SPLICE: ::c_int = 0x1023; ++ ++// sys/netinet/in.h ++// Protocols (RFC 1700) ++// NOTE: These are in addition to the constants defined in src/unix/mod.rs ++ ++// IPPROTO_IP defined in src/unix/mod.rs ++/// Hop-by-hop option header ++pub const IPPROTO_HOPOPTS: ::c_int = 0; ++// IPPROTO_ICMP defined in src/unix/mod.rs ++/// group mgmt protocol ++pub const IPPROTO_IGMP: ::c_int = 2; ++/// gateway^2 (deprecated) ++pub const IPPROTO_GGP: ::c_int = 3; ++/// for compatibility ++pub const IPPROTO_IPIP: ::c_int = 4; ++// IPPROTO_TCP defined in src/unix/mod.rs ++/// exterior gateway protocol ++pub const IPPROTO_EGP: ::c_int = 8; ++/// pup ++pub const IPPROTO_PUP: ::c_int = 12; ++// IPPROTO_UDP defined in src/unix/mod.rs ++/// xns idp ++pub const IPPROTO_IDP: ::c_int = 22; ++/// tp-4 w/ class negotiation ++pub const IPPROTO_TP: ::c_int = 29; ++// IPPROTO_IPV6 defined in src/unix/mod.rs ++/// IP6 routing header ++pub const IPPROTO_ROUTING: ::c_int = 43; ++/// IP6 fragmentation header ++pub const IPPROTO_FRAGMENT: ::c_int = 44; ++/// resource reservation ++pub const IPPROTO_RSVP: ::c_int = 46; ++/// General Routing Encap. ++pub const IPPROTO_GRE: ::c_int = 47; ++/// IP6 Encap Sec. Payload ++pub const IPPROTO_ESP: ::c_int = 50; ++/// IP6 Auth Header ++pub const IPPROTO_AH: ::c_int = 51; ++/// IP Mobility RFC 2004 ++pub const IPPROTO_MOBILE: ::c_int = 55; ++// IPPROTO_ICMPV6 defined in src/unix/mod.rs ++/// IP6 no next header ++pub const IPPROTO_NONE: ::c_int = 59; ++/// IP6 destination option ++pub const IPPROTO_DSTOPTS: ::c_int = 60; ++/// ISO cnlp ++pub const IPPROTO_EON: ::c_int = 80; ++/// Ethernet-in-IP ++pub const IPPROTO_ETHERIP: ::c_int = 97; ++/// encapsulation header ++pub const IPPROTO_ENCAP: ::c_int = 98; ++/// Protocol indep. multicast ++pub const IPPROTO_PIM: ::c_int = 103; ++/// IP Payload Comp. Protocol ++pub const IPPROTO_IPCOMP: ::c_int = 108; ++/// CARP ++pub const IPPROTO_CARP: ::c_int = 112; ++/// unicast MPLS packet ++pub const IPPROTO_MPLS: ::c_int = 137; ++/// PFSYNC ++pub const IPPROTO_PFSYNC: ::c_int = 240; ++pub const IPPROTO_MAX: ::c_int = 256; ++ ++/* Only used internally, so it can be outside the range of valid IP protocols */ ++/// Divert sockets ++pub const IPPROTO_DIVERT: ::c_int = 258; ++ ++pub const AF_ECMA: ::c_int = 8; ++pub const AF_ROUTE: ::c_int = 17; ++pub const AF_ENCAP: ::c_int = 28; ++pub const AF_SIP: ::c_int = 29; ++pub const AF_KEY: ::c_int = 30; ++pub const pseudo_AF_HDRCMPLT: ::c_int = 31; ++pub const AF_BLUETOOTH: ::c_int = 32; ++pub const AF_MPLS: ::c_int = 33; ++pub const pseudo_AF_PFLOW: ::c_int = 34; ++pub const pseudo_AF_PIPEX: ::c_int = 35; ++#[doc(hidden)] ++pub const AF_MAX: ::c_int = 36; ++ ++#[doc(hidden)] ++pub const NET_MAXID: ::c_int = AF_MAX; ++pub const NET_RT_DUMP: ::c_int = 1; ++pub const NET_RT_FLAGS: ::c_int = 2; ++pub const NET_RT_IFLIST: ::c_int = 3; ++pub const NET_RT_STATS: ::c_int = 4; ++pub const NET_RT_TABLE: ::c_int = 5; ++pub const NET_RT_IFNAMES: ::c_int = 6; ++#[doc(hidden)] ++pub const NET_RT_MAXID: ::c_int = 7; ++ ++pub const IPV6_JOIN_GROUP: ::c_int = 12; ++pub const IPV6_LEAVE_GROUP: ::c_int = 13; ++ ++pub const PF_ROUTE: ::c_int = AF_ROUTE; ++pub const PF_ECMA: ::c_int = AF_ECMA; ++pub const PF_ENCAP: ::c_int = AF_ENCAP; ++pub const PF_SIP: ::c_int = AF_SIP; ++pub const PF_KEY: ::c_int = AF_KEY; ++pub const PF_BPF: ::c_int = pseudo_AF_HDRCMPLT; ++pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; ++pub const PF_MPLS: ::c_int = AF_MPLS; ++pub const PF_PFLOW: ::c_int = pseudo_AF_PFLOW; ++pub const PF_PIPEX: ::c_int = pseudo_AF_PIPEX; ++#[doc(hidden)] ++pub const PF_MAX: ::c_int = AF_MAX; ++ ++pub const SCM_TIMESTAMP: ::c_int = 0x04; ++ ++pub const O_DSYNC : ::c_int = 128; ++ ++pub const MAP_RENAME : ::c_int = 0x0000; ++pub const MAP_NORESERVE : ::c_int = 0x0000; ++pub const MAP_HASSEMAPHORE : ::c_int = 0x0000; ++ ++pub const EIPSEC : ::c_int = 82; ++pub const ENOMEDIUM : ::c_int = 85; ++pub const EMEDIUMTYPE : ::c_int = 86; ++ ++pub const EAI_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 _PC_LINK_MAX : ::c_int = 1; ++pub const _PC_MAX_CANON : ::c_int = 2; ++pub const _PC_MAX_INPUT : ::c_int = 3; ++pub const _PC_NAME_MAX : ::c_int = 4; ++pub const _PC_PATH_MAX : ::c_int = 5; ++pub const _PC_PIPE_BUF : ::c_int = 6; ++pub const _PC_CHOWN_RESTRICTED : ::c_int = 7; ++pub const _PC_NO_TRUNC : ::c_int = 8; ++pub const _PC_VDISABLE : ::c_int = 9; ++pub const _PC_2_SYMLINKS : ::c_int = 10; ++pub const _PC_ALLOC_SIZE_MIN : ::c_int = 11; ++pub const _PC_ASYNC_IO : ::c_int = 12; ++pub const _PC_FILESIZEBITS : ::c_int = 13; ++pub const _PC_PRIO_IO : ::c_int = 14; ++pub const _PC_REC_INCR_XFER_SIZE : ::c_int = 15; ++pub const _PC_REC_MAX_XFER_SIZE : ::c_int = 16; ++pub const _PC_REC_MIN_XFER_SIZE : ::c_int = 17; ++pub const _PC_REC_XFER_ALIGN : ::c_int = 18; ++pub const _PC_SYMLINK_MAX : ::c_int = 19; ++pub const _PC_SYNC_IO : ::c_int = 20; ++pub const _PC_TIMESTAMP_RESOLUTION : ::c_int = 21; ++ ++pub const _SC_CLK_TCK : ::c_int = 3; ++pub const _SC_SEM_NSEMS_MAX : ::c_int = 31; ++pub const _SC_SEM_VALUE_MAX : ::c_int = 32; ++pub const _SC_HOST_NAME_MAX : ::c_int = 33; ++pub const _SC_MONOTONIC_CLOCK : ::c_int = 34; ++pub const _SC_2_PBS : ::c_int = 35; ++pub const _SC_2_PBS_ACCOUNTING : ::c_int = 36; ++pub const _SC_2_PBS_CHECKPOINT : ::c_int = 37; ++pub const _SC_2_PBS_LOCATE : ::c_int = 38; ++pub const _SC_2_PBS_MESSAGE : ::c_int = 39; ++pub const _SC_2_PBS_TRACK : ::c_int = 40; ++pub const _SC_ADVISORY_INFO : ::c_int = 41; ++pub const _SC_AIO_LISTIO_MAX : ::c_int = 42; ++pub const _SC_AIO_MAX : ::c_int = 43; ++pub const _SC_AIO_PRIO_DELTA_MAX : ::c_int = 44; ++pub const _SC_ASYNCHRONOUS_IO : ::c_int = 45; ++pub const _SC_ATEXIT_MAX : ::c_int = 46; ++pub const _SC_BARRIERS : ::c_int = 47; ++pub const _SC_CLOCK_SELECTION : ::c_int = 48; ++pub const _SC_CPUTIME : ::c_int = 49; ++pub const _SC_DELAYTIMER_MAX : ::c_int = 50; ++pub const _SC_IOV_MAX : ::c_int = 51; ++pub const _SC_IPV6 : ::c_int = 52; ++pub const _SC_MAPPED_FILES : ::c_int = 53; ++pub const _SC_MEMLOCK : ::c_int = 54; ++pub const _SC_MEMLOCK_RANGE : ::c_int = 55; ++pub const _SC_MEMORY_PROTECTION : ::c_int = 56; ++pub const _SC_MESSAGE_PASSING : ::c_int = 57; ++pub const _SC_MQ_OPEN_MAX : ::c_int = 58; ++pub const _SC_MQ_PRIO_MAX : ::c_int = 59; ++pub const _SC_PRIORITIZED_IO : ::c_int = 60; ++pub const _SC_PRIORITY_SCHEDULING : ::c_int = 61; ++pub const _SC_RAW_SOCKETS : ::c_int = 62; ++pub const _SC_READER_WRITER_LOCKS : ::c_int = 63; ++pub const _SC_REALTIME_SIGNALS : ::c_int = 64; ++pub const _SC_REGEXP : ::c_int = 65; ++pub const _SC_RTSIG_MAX : ::c_int = 66; ++pub const _SC_SEMAPHORES : ::c_int = 67; ++pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 68; ++pub const _SC_SHELL : ::c_int = 69; ++pub const _SC_SIGQUEUE_MAX : ::c_int = 70; ++pub const _SC_SPAWN : ::c_int = 71; ++pub const _SC_SPIN_LOCKS : ::c_int = 72; ++pub const _SC_SPORADIC_SERVER : ::c_int = 73; ++pub const _SC_SS_REPL_MAX : ::c_int = 74; ++pub const _SC_SYNCHRONIZED_IO : ::c_int = 75; ++pub const _SC_SYMLOOP_MAX : ::c_int = 76; ++pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 77; ++pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 78; ++pub const _SC_THREAD_CPUTIME : ::c_int = 79; ++pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 80; ++pub const _SC_THREAD_KEYS_MAX : ::c_int = 81; ++pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 82; ++pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 83; ++pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 84; ++pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 85; ++pub const _SC_THREAD_ROBUST_PRIO_INHERIT : ::c_int = 86; ++pub const _SC_THREAD_ROBUST_PRIO_PROTECT : ::c_int = 87; ++pub const _SC_THREAD_SPORADIC_SERVER : ::c_int = 88; ++pub const _SC_THREAD_STACK_MIN : ::c_int = 89; ++pub const _SC_THREAD_THREADS_MAX : ::c_int = 90; ++pub const _SC_THREADS : ::c_int = 91; ++pub const _SC_TIMEOUTS : ::c_int = 92; ++pub const _SC_TIMER_MAX : ::c_int = 93; ++pub const _SC_TIMERS : ::c_int = 94; ++pub const _SC_TRACE : ::c_int = 95; ++pub const _SC_TRACE_EVENT_FILTER : ::c_int = 96; ++pub const _SC_TRACE_EVENT_NAME_MAX : ::c_int = 97; ++pub const _SC_TRACE_INHERIT : ::c_int = 98; ++pub const _SC_TRACE_LOG : ::c_int = 99; ++pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 100; ++pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 101; ++pub const _SC_LOGIN_NAME_MAX : ::c_int = 102; ++pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 103; ++pub const _SC_TRACE_NAME_MAX : ::c_int = 104; ++pub const _SC_TRACE_SYS_MAX : ::c_int = 105; ++pub const _SC_TRACE_USER_EVENT_MAX : ::c_int = 106; ++pub const _SC_TTY_NAME_MAX : ::c_int = 107; ++pub const _SC_TYPED_MEMORY_OBJECTS : ::c_int = 108; ++pub const _SC_V6_ILP32_OFF32 : ::c_int = 109; ++pub const _SC_V6_ILP32_OFFBIG : ::c_int = 110; ++pub const _SC_V6_LP64_OFF64 : ::c_int = 111; ++pub const _SC_V6_LPBIG_OFFBIG : ::c_int = 112; ++pub const _SC_V7_ILP32_OFF32 : ::c_int = 113; ++pub const _SC_V7_ILP32_OFFBIG : ::c_int = 114; ++pub const _SC_V7_LP64_OFF64 : ::c_int = 115; ++pub const _SC_V7_LPBIG_OFFBIG : ::c_int = 116; ++pub const _SC_XOPEN_CRYPT : ::c_int = 117; ++pub const _SC_XOPEN_ENH_I18N : ::c_int = 118; ++pub const _SC_XOPEN_LEGACY : ::c_int = 119; ++pub const _SC_XOPEN_REALTIME : ::c_int = 120; ++pub const _SC_XOPEN_REALTIME_THREADS : ::c_int = 121; ++pub const _SC_XOPEN_STREAMS : ::c_int = 122; ++pub const _SC_XOPEN_UNIX : ::c_int = 123; ++pub const _SC_XOPEN_UUCP : ::c_int = 124; ++pub const _SC_XOPEN_VERSION : ::c_int = 125; ++pub const _SC_PHYS_PAGES : ::c_int = 500; ++pub const _SC_AVPHYS_PAGES : ::c_int = 501; ++pub const _SC_NPROCESSORS_CONF : ::c_int = 502; ++pub const _SC_NPROCESSORS_ONLN : ::c_int = 503; ++ ++pub const FD_SETSIZE: usize = 1024; ++ ++pub const ST_NOSUID: ::c_ulong = 2; ++ ++pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; ++pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; ++pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; ++ ++pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; ++pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; ++pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3; ++pub const PTHREAD_MUTEX_STRICT_NP: ::c_int = 4; ++pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_STRICT_NP; ++ ++pub const EVFILT_AIO: ::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_RECEIPT: ::uint16_t = 0x40; ++pub const EV_DISPATCH: ::uint16_t = 0x80; ++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; ++ ++pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS; ++pub const OLCUC: ::tcflag_t = 0x20; ++pub const ONOCR: ::tcflag_t = 0x40; ++pub const ONLRET: ::tcflag_t = 0x80; ++ ++pub const SOCK_CLOEXEC: ::c_int = 0x8000; ++pub const SOCK_NONBLOCK: ::c_int = 0x4000; ++pub const SOCK_DNS: ::c_int = 0x1000; ++ ++f! { ++ pub fn WIFCONTINUED(status: ::c_int) -> bool { ++ status & 0o177777 == 0o177777 ++ } ++} ++ ++extern { ++ pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; ++ pub fn getnameinfo(sa: *const ::sockaddr, ++ salen: ::socklen_t, ++ host: *mut ::c_char, ++ hostlen: ::size_t, ++ serv: *mut ::c_char, ++ servlen: ::size_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn kevent(kq: ::c_int, ++ changelist: *const ::kevent, ++ nchanges: ::c_int, ++ eventlist: *mut ::kevent, ++ nevents: ::c_int, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) ++ -> ::c_int; ++ pub fn pthread_main_np() -> ::c_int; ++ pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); ++ pub fn pthread_stackseg_np(thread: ::pthread_t, ++ sinfo: *mut ::stack_t) -> ::c_int; ++ pub fn sysctl(name: *const ::c_int, ++ namelen: ::c_uint, ++ oldp: *mut ::c_void, ++ oldlenp: *mut ::size_t, ++ newp: *mut ::c_void, ++ newlen: ::size_t) ++ -> ::c_int; ++ pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; ++ pub fn pledge(promises: *const ::c_char, ++ paths: *mut *const ::c_char) -> ::c_int; ++ pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; ++ pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; ++} ++ ++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 ++ } ++} ++ ++mod other; ++pub use self::other::*; diff --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/openbsd.rs index 000000000,000000000..5c804473a new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/openbsd.rs @@@ -1,0 -1,0 +1,35 @@@ ++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, ++ } ++} ++ ++extern { ++ pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, ++ addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; ++ pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char, ++ envp: *const *const ::c_char) -> ::c_int; ++} diff --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/other/b32/mod.rs index 000000000,000000000..9b0b338b9 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/other/b32/mod.rs @@@ -1,0 -1,0 +1,2 @@@ ++pub type c_long = i32; ++pub type c_ulong = u32; diff --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/other/b64/mod.rs index 000000000,000000000..b07c476aa new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/other/b64/mod.rs @@@ -1,0 -1,0 +1,2 @@@ ++pub type c_long = i64; ++pub type c_ulong = u64; diff --cc vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/other/mod.rs index 000000000,000000000..e4087da7b new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/bsd/netbsdlike/openbsdlike/other/mod.rs @@@ -1,0 -1,0 +1,11 @@@ ++cfg_if! { ++ if #[cfg(target_arch = "x86_64")] { ++ mod b64; ++ pub use self::b64::*; ++ } else if #[cfg(target_arch = "x86")] { ++ mod b32; ++ pub use self::b32::*; ++ } else { ++ // Unknown target_arch ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/haiku/b32.rs index 000000000,000000000..cce886488 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/haiku/b32.rs @@@ -1,0 -1,0 +1,3 @@@ ++pub type c_long = i32; ++pub type c_ulong = u32; ++pub type time_t = i32; diff --cc vendor/libc-0.2.31/src/unix/haiku/b64.rs index 000000000,000000000..3e66f14c9 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/haiku/b64.rs @@@ -1,0 -1,0 +1,3 @@@ ++pub type c_ulong = u64; ++pub type c_long = i64; ++pub type time_t = i64; diff --cc vendor/libc-0.2.31/src/unix/haiku/mod.rs index 000000000,000000000..bce79e7a8 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/haiku/mod.rs @@@ -1,0 -1,0 +1,949 @@@ ++use dox::{mem, Option}; ++ ++pub type rlim_t = ::uintptr_t; ++pub type sa_family_t = u8; ++pub type pthread_key_t = ::c_int; ++pub type nfds_t = ::c_long; ++pub type tcflag_t = ::c_uint; ++pub type speed_t = ::c_uint; ++pub type c_char = i8; ++pub type clock_t = i32; ++pub type clockid_t = i32; ++pub type suseconds_t = i32; ++pub type wchar_t = i32; ++pub type off_t = i64; ++pub type ino_t = i64; ++pub type blkcnt_t = i64; ++pub type blksize_t = i32; ++pub type dev_t = i32; ++pub type mode_t = u32; ++pub type nlink_t = i32; ++pub type useconds_t = u32; ++pub type socklen_t = u32; ++pub type pthread_t = ::uintptr_t; ++pub type pthread_mutexattr_t = ::uintptr_t; ++pub type pthread_rwlockattr_t = ::uintptr_t; ++pub type sigset_t = u64; ++pub type fsblkcnt_t = i64; ++pub type fsfilcnt_t = i64; ++pub type pthread_attr_t = *mut ::c_void; ++pub type nl_item = ::c_int; ++pub type id_t = i32; ++pub type idtype_t = ::c_uint; ++ ++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 cmsghdr { ++ pub cmsg_len: ::size_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct Dl_info { ++ pub dli_fname: *const ::c_char, ++ pub dli_fbase: *mut ::c_void, ++ pub dli_sname: *const ::c_char, ++ pub dli_saddr: *mut ::c_void, ++ } ++ ++ pub struct termios { ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_line: ::c_char, ++ pub c_ispeed: ::speed_t, ++ pub c_ospeed: ::speed_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ } ++ ++ pub struct 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 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 SIGCHLD: ::c_int = 5; ++pub const SIGABRT: ::c_int = 6; ++pub const SIGPIPE: ::c_int = 7; ++pub const SIGFPE: ::c_int = 8; ++pub const SIGKILL: ::c_int = 9; ++pub const SIGSTOP: ::c_int = 10; ++pub const SIGSEGV: ::c_int = 11; ++pub const SIGCONT: ::c_int = 12; ++pub const SIGTSTP: ::c_int = 13; ++pub const SIGALRM: ::c_int = 14; ++pub const SIGTERM: ::c_int = 15; ++pub const SIGTTIN: ::c_int = 16; ++pub const SIGTTOU: ::c_int = 17; ++pub const SIGUSR1: ::c_int = 18; ++pub const SIGUSR2: ::c_int = 19; ++pub const SIGWINCH: ::c_int = 20; ++pub const SIGKILLTHR: ::c_int = 21; ++pub const SIGTRAP: ::c_int = 22; ++pub const SIGPOLL: ::c_int = 23; ++pub const SIGPROF: ::c_int = 24; ++pub const SIGSYS: ::c_int = 25; ++pub const SIGURG: ::c_int = 26; ++pub const SIGVTALRM: ::c_int = 27; ++pub const SIGXCPU: ::c_int = 28; ++pub const SIGXFSZ: ::c_int = 29; ++pub const SIGBUS: ::c_int = 30; ++ ++pub const 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 E2BIG : ::c_int = -2147454975; ++pub const ECHILD : ::c_int = -2147454974; ++pub const EDEADLK : ::c_int = -2147454973; ++pub const EFBIG : ::c_int = -2147454972; ++pub const EMLINK : ::c_int = -2147454971; ++pub const ENFILE : ::c_int = -2147454970; ++pub const ENODEV : ::c_int = -2147454969; ++pub const ENOLCK : ::c_int = -2147454968; ++pub const ENOSYS : ::c_int = -2147454967; ++pub const ENOTTY : ::c_int = -2147454966; ++pub const ENXIO : ::c_int = -2147454965; ++pub const ESPIPE : ::c_int = -2147454964; ++pub const ESRCH : ::c_int = -2147454963; ++pub const EFPOS : ::c_int = -2147457962; ++pub const ESIGPARM : ::c_int = -2147457961; ++pub const EDOM : ::c_int = -2147454960; ++pub const ERANGE : ::c_int = -2147454959; ++pub const EPROTOTYPE : ::c_int = -2147454958; ++pub const EPROTONOSUPPORT : ::c_int = -2147454957; ++pub const EPFNOSUPPORT : ::c_int = -2147454956; ++pub const EAFNOSUPPORT : ::c_int = -2147454955; ++pub const EADDRINUSE : ::c_int = -2147454954; ++pub const EADDRNOTAVAIL : ::c_int = -2147454953; ++pub const ENETDOWN : ::c_int = -2147454952; ++pub const ENETUNREACH : ::c_int = -2147454951; ++pub const ENETRESET : ::c_int = -2147454950; ++pub const ECONNABORTED : ::c_int = -2147454949; ++pub const ECONNRESET : ::c_int = -2147454948; ++pub const EISCONN : ::c_int = -2147454947; ++pub const ENOTCONN : ::c_int = -2147454946; ++pub const ESHUTDOWN : ::c_int = -2147454945; ++pub const ECONNREFUSED : ::c_int = -2147454944; ++pub const EHOSTUNREACH : ::c_int = -2147454943; ++pub const ENOPROTOOPT : ::c_int = -2147454942; ++pub const ENOBUFS : ::c_int = -2147454941; ++pub const EINPROGRESS : ::c_int = -2147454940; ++pub const EALREADY : ::c_int = -2147454939; ++pub const EILSEQ : ::c_int = -2147454938; ++pub const ENOMSG : ::c_int = -2147454937; ++pub const ESTALE : ::c_int = -2147454936; ++pub const EOVERFLOW : ::c_int = -2147454935; ++pub const EMSGSIZE : ::c_int = -2147454934; ++pub const EOPNOTSUPP : ::c_int = -2147454933; ++pub const ENOTSOCK : ::c_int = -2147454932; ++pub const EHOSTDOWN : ::c_int = -2147454931; ++pub const EBADMSG : ::c_int = -2147454930; ++pub const ECANCELED : ::c_int = -2147454929; ++pub const EDESTADDRREQ : ::c_int = -2147454928; ++pub const EDQUOT : ::c_int = -2147454927; ++pub const EIDRM : ::c_int = -2147454926; ++pub const EMULTIHOP : ::c_int = -2147454925; ++pub const ENODATA : ::c_int = -2147454924; ++pub const ENOLINK : ::c_int = -2147454923; ++pub const ENOSR : ::c_int = -2147454922; ++pub const ENOSTR : ::c_int = -2147454921; ++pub const ENOTSUP : ::c_int = -2147454920; ++pub const EPROTO : ::c_int = -2147454919; ++pub const ETIME : ::c_int = -2147454918; ++pub const ETXTBSY : ::c_int = -2147454917; ++pub const ENOATTR : ::c_int = -2147454916; ++ ++// INT_MIN ++pub const ENOMEM : ::c_int = -2147454976; ++ ++// POSIX errors that can be mapped to BeOS error codes ++pub const EACCES : ::c_int = -2147483646; ++pub const EINTR : ::c_int = -2147483638; ++pub const EIO : ::c_int = -2147483647; ++pub const EBUSY : ::c_int = -2147483634; ++pub const EFAULT : ::c_int = -2147478783; ++pub const ETIMEDOUT : ::c_int = -2147483639; ++pub const EAGAIN : ::c_int = -2147483637; ++pub const EWOULDBLOCK : ::c_int = -2147483637; ++pub const EBADF : ::c_int = -2147459072; ++pub const EEXIST : ::c_int = -2147459070; ++pub const EINVAL : ::c_int = -2147483643; ++pub const ENAMETOOLONG : ::c_int = -2147459068; ++pub const ENOENT : ::c_int = -2147459069; ++pub const EPERM : ::c_int = -2147483633; ++pub const ENOTDIR : ::c_int = -2147459067; ++pub const EISDIR : ::c_int = -2147459063; ++pub const ENOTEMPTY : ::c_int = -2147459066; ++pub const ENOSPC : ::c_int = -2147459065; ++pub const EROFS : ::c_int = -2147459064; ++pub const EMFILE : ::c_int = -214745962; ++pub const EXDEV : ::c_int = -2147459061; ++pub const ELOOP : ::c_int = -2147459060; ++pub const ENOEXEC : ::c_int = -2147478782; ++pub const EPIPE : ::c_int = -2147459059; ++ ++pub const IPPROTO_RAW: ::c_int = 255; ++ ++// These are prefixed with POSIX_ on Haiku ++pub const MADV_NORMAL: ::c_int = 1; ++pub const MADV_SEQUENTIAL: ::c_int = 2; ++pub const MADV_RANDOM: ::c_int = 3; ++pub const MADV_WILLNEED: ::c_int = 4; ++pub const MADV_DONTNEED: ::c_int = 5; ++ ++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 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_PEEK: ::c_int = 0x2; ++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: -1, ++ lock_sem: 0, ++ lock_count: 0, ++ reader_count: 0, ++ writer_count: 0, ++ waiters: [0 as *mut _; 2], ++}; ++ ++pub const PTHREAD_MUTEX_DEFAULT: ::c_int = 0; ++pub const PTHREAD_MUTEX_NORMAL: ::c_int = 1; ++pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; ++pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 3; ++ ++pub const FIOCLEX: c_ulong = 0; // TODO: does not exist on Haiku! ++ ++pub const SA_ONSTACK: c_ulong = 0x20; ++pub const SA_SIGINFO: c_ulong = 0x40; ++pub const SA_NOCLDWAIT: c_ulong = 0x02; ++ ++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 SOCK_RAW: ::c_int = 3; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++ ++pub const SOL_SOCKET: ::c_int = -1; ++pub const SO_ACCEPTCONN: ::c_int = 0x00000001; ++pub const SO_BROADCAST: ::c_int = 0x00000002; ++pub const SO_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; ++ ++pub const WNOHANG: ::c_int = 0x01; ++pub const WUNTRACED: ::c_int = 0x02; ++pub const WCONTINUED: ::c_int = 0x04; ++pub const WEXITED: ::c_int = 0x08; ++pub const WSTOPPED: ::c_int = 0x10; ++pub const WNOWAIT: ::c_int = 0x20; ++ ++pub const P_ALL: idtype_t = 0; ++pub const P_PID: idtype_t = 1; ++pub const P_PGID: idtype_t = 2; ++ ++pub const VINTR: usize = 0; ++pub const VQUIT: usize = 1; ++pub const VERASE: usize = 2; ++pub const VKILL: usize = 3; ++pub const VEOF: usize = 4; ++pub const VEOL: usize = 5; ++pub const VMIN: usize = 4; ++pub const VTIME: usize = 5; ++pub const VEOL2: usize = 6; ++pub const VSWTCH: usize = 7; ++pub const VSTART: usize = 8; ++pub const VSTOP: usize = 9; ++pub const VSUSP: usize = 10; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const OCRNL: ::tcflag_t = 0o000010; ++pub const ONOCR: ::tcflag_t = 0o000020; ++pub const ONLRET: ::tcflag_t = 0o000040; ++pub const OFILL: ::tcflag_t = 0o000100; ++pub const OFDEL: ::tcflag_t = 0o000200; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const NL0: ::tcflag_t = 0o000000; ++pub const NL1: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const CR0: ::tcflag_t = 0o000000; ++pub const CR1: ::tcflag_t = 0o001000; ++pub const CR2: ::tcflag_t = 0o002000; ++pub const CR3: ::tcflag_t = 0o003000; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const TAB0: ::tcflag_t = 0o000000; ++pub const TAB1: ::tcflag_t = 0o004000; ++pub const TAB2: ::tcflag_t = 0o010000; ++pub const TAB3: ::tcflag_t = 0o014000; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const BS0: ::tcflag_t = 0o000000; ++pub const BS1: ::tcflag_t = 0o020000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const FF0: ::tcflag_t = 0o000000; ++pub const FF1: ::tcflag_t = 0o100000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const VT0: ::tcflag_t = 0o000000; ++pub const VT1: ::tcflag_t = 0o040000; ++ ++pub const TCGB_CTS: ::c_int = 0x01; ++pub const TCGB_DSR: ::c_int = 0x02; ++pub const TCGB_RI: ::c_int = 0x04; ++pub const TCGB_DCD: ::c_int = 0x08; ++pub const TIOCM_CTS: ::c_int = TCGB_CTS; ++pub const TIOCM_CD: ::c_int = TCGB_DCD; ++pub const TIOCM_CAR: ::c_int = TIOCM_CD; ++pub const TIOCM_RI: ::c_int = TCGB_RI; ++pub const TIOCM_DSR: ::c_int = TCGB_DSR; ++pub const TIOCM_DTR: ::c_int = 0x10; ++pub const TIOCM_RTS: ::c_int = 0x20; ++ ++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 clock_settime(clk_id: ::c_int, tp: *const ::timespec) -> ::c_int; ++ pub fn pthread_create(thread: *mut ::pthread_t, ++ attr: *const ::pthread_attr_t, ++ f: extern fn(*mut ::c_void) -> *mut ::c_void, ++ value: *mut ::c_void) -> ::c_int; ++ pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, ++ guardsize: *mut ::size_t) -> ::c_int; ++ pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, ++ stackaddr: *mut *mut ::c_void, ++ stacksize: *mut ::size_t) -> ::c_int; ++ pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, ++ clock_id: *mut clockid_t) -> ::c_int; ++ pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, ++ clock_id: ::clockid_t) -> ::c_int; ++ pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; ++ pub fn setgroups(ngroups: ::size_t, ++ ptr: *const ::gid_t) -> ::c_int; ++ pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; ++ pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) ++ -> ::c_int; ++ pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; ++ pub fn getnameinfo(sa: *const ::sockaddr, ++ salen: ::socklen_t, ++ host: *mut ::c_char, ++ hostlen: ::size_t, ++ serv: *mut ::c_char, ++ sevlen: ::size_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, ++ options: ::c_int) -> ::c_int; ++ ++ pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; ++ pub fn glob(pattern: *const ::c_char, ++ flags: ::c_int, ++ errfunc: Option ::c_int>, ++ pglob: *mut ::glob_t) -> ::c_int; ++ pub fn globfree(pglob: *mut ::glob_t); ++ ++ pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) ++ -> ::c_int; ++ ++ pub fn shm_unlink(name: *const ::c_char) -> ::c_int; ++ ++ pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); ++ ++ pub fn telldir(dirp: *mut ::DIR) -> ::c_long; ++ pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) ++ -> ::c_int; ++ ++ pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; ++ ++ pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, ++ flags: ::c_int, addr: *mut ::sockaddr, ++ addrlen: *mut ::socklen_t) -> ::ssize_t; ++ pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; ++ pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; ++ pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; ++ ++ pub fn bind(socket: ::c_int, address: *const ::sockaddr, ++ address_len: ::socklen_t) -> ::c_int; ++ ++ pub fn writev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ pub fn readv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ ++ pub fn sendmsg(fd: ::c_int, ++ msg: *const ::msghdr, ++ flags: ::c_int) -> ::ssize_t; ++ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) ++ -> ::ssize_t; ++ pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char, ++ environment: *const *const ::c_char) -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] ++ pub fn getgrgid_r(uid: ::uid_t, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "sigaltstack$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] ++ pub fn sigaltstack(ss: *const stack_t, ++ oss: *mut stack_t) -> ::c_int; ++ pub fn sem_close(sem: *mut sem_t) -> ::c_int; ++ pub fn getdtablesize() -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] ++ pub fn getgrnam_r(name: *const ::c_char, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_sigmask$UNIX2003")] ++ pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, ++ oldset: *mut sigset_t) -> ::c_int; ++ pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; ++ pub fn getgrnam(name: *const ::c_char) -> *mut ::group; ++ pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; ++ pub fn sem_unlink(name: *const ::c_char) -> ::c_int; ++ pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] ++ pub fn getpwnam_r(name: *const ::c_char, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] ++ pub fn getpwuid_r(uid: ::uid_t, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch ="x86"), ++ link_name = "sigwait$UNIX2003")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] ++ pub fn sigwait(set: *const sigset_t, ++ sig: *mut ::c_int) -> ::c_int; ++ pub fn pthread_atfork(prepare: Option, ++ parent: Option, ++ child: Option) -> ::c_int; ++ pub fn getgrgid(gid: ::gid_t) -> *mut ::group; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "popen$UNIX2003")] ++ pub fn popen(command: *const c_char, ++ mode: *const c_char) -> *mut ::FILE; ++} ++ ++cfg_if! { ++ if #[cfg(target_pointer_width = "64")] { ++ mod b64; ++ pub use self::b64::*; ++ } else { ++ mod b32; ++ pub use self::b32::*; ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/mod.rs index 000000000,000000000..f60985c4b new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/mod.rs @@@ -1,0 -1,0 +1,900 @@@ ++//! 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", target_os = "emscripten"))] ++ __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 struct sigval { ++ // Actually a union of an int and a void* ++ pub sival_ptr: *mut ::c_void ++ } ++ ++ // ++ pub struct itimerval { ++ pub it_interval: ::timeval, ++ pub it_value: ::timeval, ++ } ++ ++ // ++ pub struct tms { ++ pub tms_utime: ::clock_t, ++ pub tms_stime: ::clock_t, ++ pub tms_cutime: ::clock_t, ++ pub tms_cstime: ::clock_t, ++ } ++} ++ ++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; ++ ++pub const IPPROTO_ICMP: ::c_int = 1; ++pub const IPPROTO_ICMPV6: ::c_int = 58; ++pub const IPPROTO_TCP: ::c_int = 6; ++pub const IPPROTO_UDP: ::c_int = 17; ++pub const IPPROTO_IP: ::c_int = 0; ++pub const IPPROTO_IPV6: ::c_int = 41; ++ ++pub const INADDR_LOOPBACK: in_addr_t = 2130706433; ++pub const INADDR_ANY: in_addr_t = 0; ++pub const INADDR_BROADCAST: in_addr_t = 4294967295; ++pub const INADDR_NONE: in_addr_t = 4294967295; ++ ++cfg_if! { ++ if #[cfg(dox)] { ++ // on dox builds don't pull in anything ++ } else if #[cfg(target_os = "l4re")] { ++ // required libraries for L4Re are linked externally, ATM ++ } else if #[cfg(feature = "use_std")] { ++ // cargo build, don't pull in anything extra as the libstd dep ++ // already pulls in all libs. ++ } else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] { ++ #[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))] ++ #[link(name = "c", cfg(not(target_feature = "crt-static")))] ++ 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 if #[cfg(target_os = "fuchsia")] { ++ #[link(name = "c")] ++ #[link(name = "fdio")] ++ extern {} ++ } else if #[cfg(target_env = "newlib")] { ++ #[link(name = "c")] ++ #[link(name = "m")] ++ extern {} ++ } else { ++ #[link(name = "c")] ++ #[link(name = "m")] ++ #[link(name = "rt")] ++ #[link(name = "pthread")] ++ extern {} ++ } ++} ++ ++extern { ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")] ++ pub fn getpwnam(name: *const ::c_char) -> *mut passwd; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")] ++ pub fn getpwuid(uid: ::uid_t) -> *mut passwd; ++ ++ pub fn fprintf(stream: *mut ::FILE, ++ format: *const ::c_char, ...) -> ::c_int; ++ pub fn printf(format: *const ::c_char, ...) -> ::c_int; ++ pub fn snprintf(s: *mut ::c_char, n: ::size_t, ++ format: *const ::c_char, ...) -> ::c_int; ++ pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int; ++ 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 = "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; ++ ++ pub fn pclose(stream: *mut ::FILE) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "fdopen$UNIX2003")] ++ pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; ++ pub fn fileno(stream: *mut ::FILE) -> ::c_int; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "open$UNIX2003")] ++ pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "creat$UNIX2003")] ++ pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "fcntl$UNIX2003")] ++ pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), ++ link_name = "opendir$INODE64")] ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "opendir$INODE64$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")] ++ pub fn opendir(dirname: *const c_char) -> *mut ::DIR; ++ #[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] ++ pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent; ++ #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_readdir_r")] ++ pub fn readdir_r(dirp: *mut ::DIR, entry: *mut ::dirent, ++ result: *mut *mut ::dirent) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "closedir$UNIX2003")] ++ pub fn closedir(dirp: *mut ::DIR) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), ++ link_name = "rewinddir$INODE64")] ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "rewinddir$INODE64$UNIX2003")] ++ pub fn rewinddir(dirp: *mut ::DIR); ++ ++ pub fn openat(dirfd: ::c_int, pathname: *const ::c_char, ++ flags: ::c_int, ...) -> ::c_int; ++ pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t, flags: ::c_int) -> ::c_int; ++ pub fn fchown(fd: ::c_int, ++ owner: ::uid_t, ++ group: ::gid_t) -> ::c_int; ++ pub fn fchownat(dirfd: ::c_int, pathname: *const ::c_char, ++ owner: ::uid_t, group: ::gid_t, ++ flags: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")] ++ pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char, ++ buf: *mut stat, flags: ::c_int) -> ::c_int; ++ pub fn linkat(olddirfd: ::c_int, oldpath: *const ::c_char, ++ newdirfd: ::c_int, newpath: *const ::c_char, ++ flags: ::c_int) -> ::c_int; ++ pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t) -> ::c_int; ++ pub fn readlinkat(dirfd: ::c_int, pathname: *const ::c_char, ++ buf: *mut ::c_char, bufsiz: ::size_t) -> ::ssize_t; ++ pub fn renameat(olddirfd: ::c_int, oldpath: *const ::c_char, ++ newdirfd: ::c_int, newpath: *const ::c_char) ++ -> ::c_int; ++ pub fn symlinkat(target: *const ::c_char, newdirfd: ::c_int, ++ linkpath: *const ::c_char) -> ::c_int; ++ pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char, ++ flags: ::c_int) -> ::c_int; ++ ++ pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; ++ pub fn alarm(seconds: ::c_uint) -> ::c_uint; ++ pub fn chdir(dir: *const c_char) -> ::c_int; ++ pub fn fchdir(dirfd: ::c_int) -> ::c_int; ++ pub fn chown(path: *const c_char, uid: uid_t, ++ gid: gid_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "lchown$UNIX2003")] ++ pub fn lchown(path: *const c_char, uid: uid_t, ++ gid: gid_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "close$NOCANCEL$UNIX2003")] ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), ++ link_name = "close$NOCANCEL")] ++ pub fn close(fd: ::c_int) -> ::c_int; ++ pub fn dup(fd: ::c_int) -> ::c_int; ++ pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int; ++ pub fn execl(path: *const c_char, ++ arg0: *const c_char, ...) -> ::c_int; ++ pub fn execle(path: *const ::c_char, ++ arg0: *const ::c_char, ...) -> ::c_int; ++ pub fn execlp(file: *const ::c_char, ++ arg0: *const ::c_char, ...) -> ::c_int; ++ pub fn execv(prog: *const c_char, ++ argv: *const *const c_char) -> ::c_int; ++ pub fn execve(prog: *const c_char, argv: *const *const c_char, ++ envp: *const *const c_char) ++ -> ::c_int; ++ pub fn execvp(c: *const c_char, ++ argv: *const *const c_char) -> ::c_int; ++ pub fn fork() -> pid_t; ++ pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; ++ pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; ++ pub fn getegid() -> gid_t; ++ pub fn geteuid() -> uid_t; ++ pub fn getgid() -> gid_t; ++ pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) ++ -> ::c_int; ++ pub fn getlogin() -> *mut c_char; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "getopt$UNIX2003")] ++ pub fn getopt(argc: ::c_int, argv: *const *mut c_char, ++ optstr: *const c_char) -> ::c_int; ++ pub fn getpgid(pid: pid_t) -> pid_t; ++ pub fn getpgrp() -> pid_t; ++ pub fn getpid() -> pid_t; ++ pub fn getppid() -> pid_t; ++ pub fn getuid() -> uid_t; ++ pub fn isatty(fd: ::c_int) -> ::c_int; ++ pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int; ++ pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t; ++ pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pause$UNIX2003")] ++ pub fn pause() -> ::c_int; ++ pub fn pipe(fds: *mut ::c_int) -> ::c_int; ++ pub fn posix_memalign(memptr: *mut *mut ::c_void, ++ align: ::size_t, ++ size: ::size_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "read$UNIX2003")] ++ pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) ++ -> ::ssize_t; ++ pub fn rmdir(path: *const c_char) -> ::c_int; ++ pub fn seteuid(uid: uid_t) -> ::c_int; ++ pub fn setgid(gid: gid_t) -> ::c_int; ++ pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int; ++ pub fn setsid() -> pid_t; ++ pub fn setuid(uid: uid_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "sleep$UNIX2003")] ++ pub fn sleep(secs: ::c_uint) -> ::c_uint; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "nanosleep$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")] ++ pub fn nanosleep(rqtp: *const timespec, ++ rmtp: *mut timespec) -> ::c_int; ++ pub fn tcgetpgrp(fd: ::c_int) -> pid_t; ++ pub fn tcsetpgrp(fd: ::c_int, pgrp: ::pid_t) -> ::c_int; ++ pub fn ttyname(fd: ::c_int) -> *mut c_char; ++ pub fn unlink(c: *const c_char) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "wait$UNIX2003")] ++ pub fn wait(status: *mut ::c_int) -> pid_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "waitpid$UNIX2003")] ++ pub fn waitpid(pid: pid_t, status: *mut ::c_int, options: ::c_int) ++ -> pid_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "write$UNIX2003")] ++ pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) ++ -> ::ssize_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pread$UNIX2003")] ++ pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, ++ offset: off_t) -> ::ssize_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pwrite$UNIX2003")] ++ pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, ++ offset: off_t) -> ::ssize_t; ++ pub fn umask(mask: mode_t) -> mode_t; ++ ++ #[cfg_attr(target_os = "netbsd", link_name = "__utime50")] ++ pub fn utime(file: *const c_char, buf: *const utimbuf) -> ::c_int; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "kill$UNIX2003")] ++ pub fn kill(pid: pid_t, sig: ::c_int) -> ::c_int; ++ ++ 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; ++ ++ #[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; ++ #[cfg_attr(target_os = "netbsd", link_name = "__times13")] ++ pub fn times(buf: *mut ::tms) -> ::clock_t; ++ ++ pub fn pthread_self() -> ::pthread_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_join$UNIX2003")] ++ pub fn pthread_join(native: ::pthread_t, ++ value: *mut *mut ::c_void) -> ::c_int; ++ pub fn pthread_exit(value: *mut ::c_void); ++ pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; ++ pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; ++ pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, ++ stack_size: ::size_t) -> ::c_int; ++ pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, ++ state: ::c_int) -> ::c_int; ++ pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")] ++ pub fn sched_yield() -> ::c_int; ++ pub fn pthread_key_create(key: *mut pthread_key_t, ++ dtor: Option) ++ -> ::c_int; ++ pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int; ++ pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; ++ pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void) ++ -> ::c_int; ++ pub fn pthread_mutex_init(lock: *mut pthread_mutex_t, ++ attr: *const pthread_mutexattr_t) -> ::c_int; ++ pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int; ++ pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int; ++ pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int; ++ pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int; ++ ++ pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_mutexattr_destroy$UNIX2003")] ++ pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int; ++ pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, ++ _type: ::c_int) -> ::c_int; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_cond_init$UNIX2003")] ++ pub fn pthread_cond_init(cond: *mut pthread_cond_t, ++ attr: *const pthread_condattr_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_cond_wait$UNIX2003")] ++ pub fn pthread_cond_wait(cond: *mut pthread_cond_t, ++ lock: *mut pthread_mutex_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_cond_timedwait$UNIX2003")] ++ pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t, ++ lock: *mut pthread_mutex_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int; ++ pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int; ++ pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int; ++ pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int; ++ pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_rwlock_init$UNIX2003")] ++ pub fn pthread_rwlock_init(lock: *mut pthread_rwlock_t, ++ attr: *const pthread_rwlockattr_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_rwlock_destroy$UNIX2003")] ++ pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_rwlock_rdlock$UNIX2003")] ++ pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_rwlock_tryrdlock$UNIX2003")] ++ pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_rwlock_wrlock$UNIX2003")] ++ pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_rwlock_trywrlock$UNIX2003")] ++ pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_rwlock_unlock$UNIX2003")] ++ pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int; ++ pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int; ++ pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) ++ -> ::c_int; ++ #[cfg_attr(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(target_os = "netbsd", link_name = "__utimes50")] ++ pub fn utimes(filename: *const ::c_char, ++ times: *const ::timeval) -> ::c_int; ++ pub fn dlopen(filename: *const ::c_char, ++ flag: ::c_int) -> *mut ::c_void; ++ pub fn dlerror() -> *mut ::c_char; ++ pub fn dlsym(handle: *mut ::c_void, ++ symbol: *const ::c_char) -> *mut ::c_void; ++ pub fn dlclose(handle: *mut ::c_void) -> ::c_int; ++ pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int; ++ ++ pub fn getaddrinfo(node: *const c_char, ++ service: *const c_char, ++ hints: *const addrinfo, ++ res: *mut *mut addrinfo) -> ::c_int; ++ pub fn freeaddrinfo(res: *mut addrinfo); ++ pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; ++ #[cfg_attr(any( ++ all(target_os = "linux", not(target_env = "musl")), ++ target_os = "freebsd", ++ target_os = "dragonfly", ++ target_os = "haiku"), ++ link_name = "__res_init")] ++ #[cfg_attr(any(target_os = "macos", target_os = "ios"), ++ link_name = "res_9_init")] ++ pub fn res_init() -> ::c_int; ++ ++ #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] ++ pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; ++ #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")] ++ pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "mktime$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")] ++ pub fn mktime(tm: *mut tm) -> time_t; ++ #[cfg_attr(target_os = "netbsd", link_name = "__time50")] ++ pub fn time(time: *mut time_t) -> time_t; ++ #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")] ++ pub fn gmtime(time_p: *const time_t) -> *mut tm; ++ #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")] ++ pub fn localtime(time_p: *const time_t) -> *mut tm; ++ ++ #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] ++ pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, ++ dev: ::dev_t) -> ::c_int; ++ pub fn uname(buf: *mut ::utsname) -> ::c_int; ++ pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; ++ pub fn chroot(name: *const ::c_char) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "usleep$UNIX2003")] ++ pub fn usleep(secs: ::c_uint) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "send$UNIX2003")] ++ pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, ++ flags: ::c_int) -> ::ssize_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "recv$UNIX2003")] ++ pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, ++ flags: ::c_int) -> ::ssize_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "putenv$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")] ++ pub fn putenv(string: *mut c_char) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "poll$UNIX2003")] ++ pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), ++ link_name = "select$1050")] ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "select$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__select50")] ++ pub fn select(nfds: ::c_int, ++ readfs: *mut fd_set, ++ writefds: *mut fd_set, ++ errorfds: *mut fd_set, ++ timeout: *mut timeval) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")] ++ pub fn setlocale(category: ::c_int, ++ locale: *const ::c_char) -> *mut ::c_char; ++ pub fn localeconv() -> *mut lconv; ++ ++ pub fn sem_destroy(sem: *mut sem_t) -> ::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; ++ pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int; ++ pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int; ++ ++ pub fn readlink(path: *const c_char, ++ buf: *mut c_char, ++ bufsz: ::size_t) ++ -> ::ssize_t; ++ ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] ++ pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")] ++ pub fn sigaddset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")] ++ pub fn sigfillset(set: *mut sigset_t) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")] ++ pub fn sigdelset(set: *mut sigset_t, signum: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")] ++ pub fn sigismember(set: *const sigset_t, signum: ::c_int) -> ::c_int; ++ ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")] ++ pub fn sigprocmask(how: ::c_int, ++ set: *const sigset_t, ++ oldset: *mut sigset_t) ++ -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")] ++ pub fn sigpending(set: *mut sigset_t) -> ::c_int; ++ ++ #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] ++ pub fn timegm(tm: *mut ::tm) -> time_t; ++ ++ pub fn getsid(pid: pid_t) -> pid_t; ++ ++ pub fn sysconf(name: ::c_int) -> ::c_long; ++ ++ pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int; ++ ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"), ++ link_name = "pselect$1050")] ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pselect$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")] ++ pub fn pselect(nfds: ::c_int, ++ readfs: *mut fd_set, ++ writefds: *mut fd_set, ++ errorfds: *mut fd_set, ++ timeout: *const timespec, ++ sigmask: *const sigset_t) -> ::c_int; ++ pub fn fseeko(stream: *mut ::FILE, ++ offset: ::off_t, ++ whence: ::c_int) -> ::c_int; ++ pub fn ftello(stream: *mut ::FILE) -> ::off_t; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "tcdrain$UNIX2003")] ++ pub fn tcdrain(fd: ::c_int) -> ::c_int; ++ pub fn cfgetispeed(termios: *const ::termios) -> ::speed_t; ++ pub fn cfgetospeed(termios: *const ::termios) -> ::speed_t; ++ pub fn cfmakeraw(termios: *mut ::termios); ++ pub fn cfsetispeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; ++ pub fn cfsetospeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; ++ pub fn cfsetspeed(termios: *mut ::termios, speed: ::speed_t) -> ::c_int; ++ pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int; ++ pub fn tcsetattr(fd: ::c_int, ++ optional_actions: ::c_int, ++ termios: *const ::termios) -> ::c_int; ++ pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int; ++ pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int; ++ pub fn tcgetsid(fd: ::c_int) -> ::pid_t; ++ pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int; ++ pub fn mkstemp(template: *mut ::c_char) -> ::c_int; ++ pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char; ++ ++ pub fn tmpnam(ptr: *mut ::c_char) -> *mut ::c_char; ++ ++ pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int); ++ pub fn closelog(); ++ pub fn setlogmask(maskpri: ::c_int) -> ::c_int; ++ pub fn syslog(priority: ::c_int, message: *const ::c_char, ...); ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "nice$UNIX2003")] ++ pub fn nice(incr: ::c_int) -> ::c_int; ++ ++ pub fn grantpt(fd: ::c_int) -> ::c_int; ++ pub fn posix_openpt(flags: ::c_int) -> ::c_int; ++ pub fn ptsname(fd: ::c_int) -> *mut ::c_char; ++ pub fn unlockpt(fd: ::c_int) -> ::c_int; ++} ++ ++cfg_if! { ++ if #[cfg(target_env = "uclibc")] { ++ mod uclibc; ++ pub use self::uclibc::*; ++ } else if #[cfg(target_env = "newlib")] { ++ mod newlib; ++ pub use self::newlib::*; ++ } else if #[cfg(any(target_os = "linux", ++ target_os = "android", ++ target_os = "emscripten", ++ target_os = "fuchsia"))] { ++ 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 --cc vendor/libc-0.2.31/src/unix/newlib/arm/mod.rs index 000000000,000000000..372a48c4b new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/newlib/arm/mod.rs @@@ -1,0 -1,0 +1,5 @@@ ++pub type c_char = u8; ++pub type wchar_t = u32; ++ ++pub type c_long = i32; ++pub type c_ulong = u32; diff --cc vendor/libc-0.2.31/src/unix/newlib/mod.rs index 000000000,000000000..aec3bca36 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/newlib/mod.rs @@@ -1,0 -1,0 +1,658 @@@ ++use dox::mem; ++ ++pub type blkcnt_t = i32; ++pub type blksize_t = i32; ++pub type clock_t = i32; ++pub type clockid_t = ::c_ulong; ++pub type dev_t = u32; ++pub type fsblkcnt_t = u64; ++pub type fsfilcnt_t = u32; ++pub type id_t = u32; ++pub type ino_t = u32; ++pub type key_t = ::c_int; ++pub type loff_t = ::c_longlong; ++pub type mode_t = ::c_uint; ++pub type nfds_t = u32; ++pub type nlink_t = ::c_ushort; ++pub type off_t = i64; ++pub type pthread_t = ::c_ulong; ++pub type pthread_key_t = ::c_uint; ++pub type rlim_t = u32; ++pub type sa_family_t = u8; ++pub type socklen_t = u32; ++pub type speed_t = u32; ++pub type suseconds_t = i32; ++pub type tcflag_t = ::c_uint; ++pub type time_t = i32; ++pub type useconds_t = u32; ++ ++s! { ++ pub struct sockaddr { ++ pub sa_family: sa_family_t, ++ pub sa_data: [::c_char; 14], ++ } ++ ++ pub struct sockaddr_in { ++ pub sin_family: sa_family_t, ++ pub sin_port: ::in_port_t, ++ pub sin_addr: ::in_addr, ++ pub sin_zero: [u8; 8], ++ } ++ ++ pub struct sockaddr_in6 { // Unverified ++ pub sin6_family: sa_family_t, ++ pub sin6_port: ::in_port_t, ++ pub sin6_flowinfo: u32, ++ pub sin6_addr: ::in6_addr, ++ pub sin6_scope_id: u32, ++ } ++ ++ pub struct sockaddr_storage { ++ pub ss_family: sa_family_t, ++ pub __ss_padding: [u8; 26], ++ } ++ ++ pub struct addrinfo { ++ pub ai_flags: ::c_int, ++ pub ai_family: ::c_int, ++ pub ai_socktype: ::c_int, ++ pub ai_protocol: ::c_int, ++ pub ai_addrlen: socklen_t, ++ pub ai_canonname: *mut ::c_char, ++ pub ai_addr: *mut sockaddr, ++ pub ai_next: *mut addrinfo, ++ } ++ ++ pub struct ip_mreq { ++ pub imr_multiaddr: in_addr, ++ pub imr_interface: in_addr, ++ } ++ ++ pub struct linger { ++ pub l_onoff: ::c_int, ++ pub l_linger: ::c_int, ++ } ++ ++ pub struct in_addr { ++ pub s_addr: ::in_addr_t, ++ } ++ ++ pub struct hostent { ++ pub h_name: *mut ::c_char, ++ pub h_aliases: *mut *mut ::c_char, ++ pub h_addrtype: ::c_int, ++ pub h_length: ::c_int, ++ pub h_addr_list: *mut *mut ::c_char, ++ pub h_addr: *mut ::c_char, ++ } ++ ++ pub struct pollfd { ++ pub fd: ::c_int, ++ pub events: ::c_int, ++ pub revents: ::c_int, ++ } ++ ++ pub struct lconv { ++ pub decimal_point: *mut ::c_char, ++ pub thousands_sep: *mut ::c_char, ++ pub grouping: *mut ::c_char, ++ pub int_curr_symbol: *mut ::c_char, ++ pub currency_symbol: *mut ::c_char, ++ pub mon_decimal_point: *mut ::c_char, ++ pub mon_thousands_sep: *mut ::c_char, ++ pub mon_grouping: *mut ::c_char, ++ pub positive_sign: *mut ::c_char, ++ pub negative_sign: *mut ::c_char, ++ pub int_frac_digits: ::c_char, ++ pub frac_digits: ::c_char, ++ pub p_cs_precedes: ::c_char, ++ pub p_sep_by_space: ::c_char, ++ pub n_cs_precedes: ::c_char, ++ pub n_sep_by_space: ::c_char, ++ pub p_sign_posn: ::c_char, ++ pub n_sign_posn: ::c_char, ++ pub int_n_cs_precedes: ::c_char, ++ pub int_n_sep_by_space: ::c_char, ++ pub int_n_sign_posn: ::c_char, ++ pub int_p_cs_precedes: ::c_char, ++ pub int_p_sep_by_space: ::c_char, ++ pub int_p_sign_posn: ::c_char, ++ } ++ ++ pub struct tm { ++ pub tm_sec: ::c_int, ++ pub tm_min: ::c_int, ++ pub tm_hour: ::c_int, ++ pub tm_mday: ::c_int, ++ pub tm_mon: ::c_int, ++ pub tm_year: ::c_int, ++ pub tm_wday: ::c_int, ++ pub tm_yday: ::c_int, ++ pub tm_isdst: ::c_int, ++ } ++ ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: dev_t, ++ pub st_size: off_t, ++ pub st_atime: time_t, ++ pub st_spare1: ::c_long, ++ pub st_mtime: time_t, ++ pub st_spare2: ::c_long, ++ pub st_ctime: time_t, ++ pub st_spare3: ::c_long, ++ pub st_blksize: blksize_t, ++ pub st_blocks: blkcnt_t, ++ pub st_spare4: [::c_long; 2usize], ++ } ++ ++ pub struct statvfs { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: fsblkcnt_t, ++ pub f_bfree: fsblkcnt_t, ++ pub f_bavail: fsblkcnt_t, ++ pub f_files: fsfilcnt_t, ++ pub f_ffree: fsfilcnt_t, ++ pub f_favail: fsfilcnt_t, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ } ++ ++ pub struct sigset_t { ++ __val: [::c_ulong; 16], ++ } ++ ++ pub struct sigaction { ++ pub sa_handler: extern fn(arg1: ::c_int), ++ pub sa_mask: sigset_t, ++ pub sa_flags: ::c_int, ++ } ++ ++ pub struct dirent { ++ pub d_ino: ino_t, ++ pub d_type: ::c_uchar, ++ pub d_name: [::c_char; 256usize], ++ } ++ ++ pub struct stack_t { ++ pub ss_sp: *mut ::c_void, ++ pub ss_flags: ::c_int, ++ pub ss_size: usize, ++ } ++ ++ pub struct fd_set { // Unverified ++ fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], ++ } ++ ++ pub struct passwd { // Unverified ++ pub pw_name: *mut ::c_char, ++ pub pw_passwd: *mut ::c_char, ++ pub pw_uid: ::uid_t, ++ pub pw_gid: ::gid_t, ++ pub pw_gecos: *mut ::c_char, ++ pub pw_dir: *mut ::c_char, ++ pub pw_shell: *mut ::c_char, ++ } ++ ++ pub struct termios { // Unverified ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_line: ::cc_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ } ++ ++ pub struct sem_t { // Unverified ++ __size: [::c_char; 16], ++ } ++ ++ pub struct Dl_info { // Unverified ++ pub dli_fname: *const ::c_char, ++ pub dli_fbase: *mut ::c_void, ++ pub dli_sname: *const ::c_char, ++ pub dli_saddr: *mut ::c_void, ++ } ++ ++ pub struct utsname { // Unverified ++ pub sysname: [::c_char; 65], ++ pub nodename: [::c_char; 65], ++ pub release: [::c_char; 65], ++ pub version: [::c_char; 65], ++ pub machine: [::c_char; 65], ++ pub domainname: [::c_char; 65] ++ } ++ ++ pub struct cpu_set_t { // Unverified ++ bits: [u32; 32], ++ } ++ ++ pub struct pthread_attr_t { // Unverified ++ __size: [u64; 7] ++ } ++ ++ pub struct pthread_mutex_t { // Unverified ++ #[cfg(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc"))] ++ __align: [::c_long; 0], ++ #[cfg(not(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc")))] ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_MUTEX_T], ++ } ++ ++ pub struct pthread_rwlock_t { // Unverified ++ #[cfg(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc"))] ++ __align: [::c_long; 0], ++ #[cfg(not(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc")))] ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], ++ } ++ ++ pub struct pthread_mutexattr_t { // Unverified ++ #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", ++ target_arch = "mips64", target_arch = "s390x", ++ target_arch = "sparc64"))] ++ __align: [::c_int; 0], ++ #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", ++ target_arch = "mips64", target_arch = "s390x", ++ target_arch = "sparc64")))] ++ __align: [::c_long; 0], ++ size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], ++ } ++ ++ pub struct pthread_rwlockattr_t { // Unverified ++ __lockkind: ::c_int, ++ __pshared: ::c_int, ++ } ++ ++ pub struct pthread_cond_t { // Unverified ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_COND_T], ++ } ++ ++ pub struct pthread_condattr_t { // Unverified ++ __align: [::c_int; 0], ++ size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], ++ } ++ ++} ++ ++// unverified constants ++pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ++ __align: [], ++ size: [0; __SIZEOF_PTHREAD_MUTEX_T], ++}; ++pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { ++ __align: [], ++ size: [0; __SIZEOF_PTHREAD_COND_T], ++}; ++pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { ++ __align: [], ++ size: [0; __SIZEOF_PTHREAD_RWLOCK_T], ++}; ++pub const NCCS: usize = 32; ++pub const __SIZEOF_PTHREAD_ATTR_T: usize = 56; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_COND_T: usize = 48; ++pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; ++pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; ++pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; ++pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; ++pub const __PTHREAD_MUTEX_HAVE_PREV: usize = 1; ++pub const __PTHREAD_RWLOCK_INT_FLAGS_SHARED: usize = 1; ++pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; ++pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; ++pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; ++pub const FD_SETSIZE: usize = 1024; ++// intentionally not public, only used for fd_set ++const ULONG_SIZE: usize = 32; ++ ++// Other constants ++pub const EPERM: ::c_int = 1; ++pub const ENOENT: ::c_int = 2; ++pub const ESRCH: ::c_int = 3; ++pub const EINTR: ::c_int = 4; ++pub const EIO: ::c_int = 5; ++pub const ENXIO: ::c_int = 6; ++pub const E2BIG: ::c_int = 7; ++pub const ENOEXEC: ::c_int = 8; ++pub const EBADF: ::c_int = 9; ++pub const ECHILD: ::c_int = 10; ++pub const EAGAIN: ::c_int = 11; ++pub const ENOMEM: ::c_int = 12; ++pub const EACCES: ::c_int = 13; ++pub const EFAULT: ::c_int = 14; ++pub const EBUSY: ::c_int = 16; ++pub const EEXIST: ::c_int = 17; ++pub const EXDEV: ::c_int = 18; ++pub const ENODEV: ::c_int = 19; ++pub const ENOTDIR: ::c_int = 20; ++pub const EISDIR: ::c_int = 21; ++pub const EINVAL: ::c_int = 22; ++pub const ENFILE: ::c_int = 23; ++pub const EMFILE: ::c_int = 24; ++pub const ENOTTY: ::c_int = 25; ++pub const ETXTBSY: ::c_int = 26; ++pub const EFBIG: ::c_int = 27; ++pub const ENOSPC: ::c_int = 28; ++pub const ESPIPE: ::c_int = 29; ++pub const EROFS: ::c_int = 30; ++pub const EMLINK: ::c_int = 31; ++pub const EPIPE: ::c_int = 32; ++pub const EDOM: ::c_int = 33; ++pub const ERANGE: ::c_int = 34; ++pub const ENOMSG: ::c_int = 35; ++pub const EIDRM: ::c_int = 36; ++pub const EDEADLK: ::c_int = 45; ++pub const ENOLCK: ::c_int = 46; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENOLINK: ::c_int = 67; ++pub const EPROTO: ::c_int = 71; ++pub const EMULTIHOP: ::c_int = 74; ++pub const EBADMSG: ::c_int = 77; ++pub const EFTYPE: ::c_int = 79; ++pub const ENOSYS: ::c_int = 88; ++pub const ENOTEMPTY: ::c_int = 90; ++pub const ENAMETOOLONG: ::c_int = 91; ++pub const ELOOP: ::c_int = 92; ++pub const EOPNOTSUPP: ::c_int = 95; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const ECONNRESET: ::c_int = 104; ++pub const ENOBUFS: ::c_int = 105; ++pub const EAFNOSUPPORT: ::c_int = 106; ++pub const EPROTOTYPE: ::c_int = 107; ++pub const ENOTSOCK: ::c_int = 108; ++pub const ENOPROTOOPT: ::c_int = 109; ++pub const ECONNREFUSED: ::c_int = 111; ++pub const EADDRINUSE: ::c_int = 112; ++pub const ECONNABORTED: ::c_int = 113; ++pub const ENETUNREACH: ::c_int = 114; ++pub const ENETDOWN: ::c_int = 115; ++pub const ETIMEDOUT: ::c_int = 116; ++pub const EHOSTDOWN: ::c_int = 117; ++pub const EHOSTUNREACH: ::c_int = 118; ++pub const EINPROGRESS: ::c_int = 119; ++pub const EALREADY: ::c_int = 120; ++pub const EDESTADDRREQ: ::c_int = 121; ++pub const EMSGSIZE: ::c_int = 122; ++pub const EPROTONOSUPPORT: ::c_int = 123; ++pub const EADDRNOTAVAIL: ::c_int = 125; ++pub const ENETRESET: ::c_int = 126; ++pub const EISCONN: ::c_int = 127; ++pub const ENOTCONN: ::c_int = 128; ++pub const ETOOMANYREFS: ::c_int = 129; ++pub const EDQUOT: ::c_int = 132; ++pub const ESTALE: ::c_int = 133; ++pub const ENOTSUP: ::c_int = 134; ++pub const EILSEQ: ::c_int = 138; ++pub const EOVERFLOW: ::c_int = 139; ++pub const ECANCELED: ::c_int = 140; ++pub const ENOTRECOVERABLE: ::c_int = 141; ++pub const EOWNERDEAD: ::c_int = 142; ++pub const EWOULDBLOCK: ::c_int = 11; ++ ++pub const F_DUPFD: ::c_int = 0; ++pub const F_GETFD: ::c_int = 1; ++pub const F_SETFD: ::c_int = 2; ++pub const F_GETFL: ::c_int = 3; ++pub const F_SETFL: ::c_int = 4; ++pub const F_GETOWN: ::c_int = 5; ++pub const F_SETOWN: ::c_int = 6; ++pub const F_GETLK: ::c_int = 7; ++pub const F_SETLK: ::c_int = 8; ++pub const F_SETLKW: ::c_int = 9; ++pub const F_RGETLK: ::c_int = 10; ++pub const F_RSETLK: ::c_int = 11; ++pub const F_CNVT: ::c_int = 12; ++pub const F_RSETLKW: ::c_int = 13; ++pub const F_DUPFD_CLOEXEC: ::c_int = 14; ++ ++pub const O_RDONLY: ::c_int = 0; ++pub const O_WRONLY: ::c_int = 1; ++pub const O_RDWR: ::c_int = 2; ++pub const O_APPEND: ::c_int = 8; ++pub const O_CREAT: ::c_int = 512; ++pub const O_TRUNC: ::c_int = 1024; ++pub const O_EXCL: ::c_int = 2048; ++pub const O_SYNC: ::c_int = 8192; ++pub const O_NONBLOCK: ::c_int = 16384; ++ ++pub const O_ACCMODE: ::c_int = 3; ++pub const O_CLOEXEC: ::c_int = 0x80000; ++ ++pub const STDIN_FILENO: ::c_int = 0; ++pub const STDOUT_FILENO: ::c_int = 1; ++pub const STDERR_FILENO: ::c_int = 2; ++ ++pub const SEEK_SET: ::c_int = 0; ++pub const SEEK_CUR: ::c_int = 1; ++pub const SEEK_END: ::c_int = 2; ++ ++pub const FIONBIO: ::c_int = 1; ++ ++pub const S_BLKSIZE: ::mode_t = 1024; ++pub const S_IREAD: ::mode_t = 256; ++pub const S_IWRITE: ::mode_t = 128; ++pub const S_IEXEC: ::mode_t = 64; ++pub const S_ENFMT: ::mode_t = 1024; ++pub const S_IFMT: ::mode_t = 61440; ++pub const S_IFDIR: ::mode_t = 16384; ++pub const S_IFCHR: ::mode_t = 8192; ++pub const S_IFBLK: ::mode_t = 24576; ++pub const S_IFREG: ::mode_t = 32768; ++pub const S_IFLNK: ::mode_t = 40960; ++pub const S_IFSOCK: ::mode_t = 49152; ++pub const S_IFIFO: ::mode_t = 4096; ++pub const S_IRUSR: ::mode_t = 256; ++pub const S_IWUSR: ::mode_t = 128; ++pub const S_IXUSR: ::mode_t = 64; ++pub const S_IRGRP: ::mode_t = 32; ++pub const S_IWGRP: ::mode_t = 16; ++pub const S_IXGRP: ::mode_t = 8; ++pub const S_IROTH: ::mode_t = 4; ++pub const S_IWOTH: ::mode_t = 2; ++pub const S_IXOTH: ::mode_t = 1; ++ ++pub const SOL_SOCKET: ::c_int = 65535; ++pub const SOL_TCP: ::c_int = 6; ++ ++pub const PF_UNSPEC: ::c_int = 0; ++pub const PF_INET: ::c_int = 2; ++pub const PF_INET6: ::c_int = 23; ++ ++pub const AF_UNSPEC: ::c_int = 0; ++pub const AF_INET: ::c_int = 2; ++pub const AF_INET6: ::c_int = 23; ++ ++pub const SOCK_STREAM: ::c_int = 1; ++pub const SOCK_DGRAM: ::c_int = 2; ++ ++pub const MSG_OOB: ::c_int = 1; ++pub const MSG_PEEK: ::c_int = 2; ++pub const MSG_DONTWAIT: ::c_int = 4; ++pub const MSG_DONTROUTE: ::c_int = 0; ++pub const MSG_WAITALL: ::c_int = 0; ++pub const MSG_MORE: ::c_int = 0; ++pub const MSG_NOSIGNAL: ::c_int = 0; ++ ++pub const SHUT_RD: ::c_int = 0; ++pub const SHUT_WR: ::c_int = 1; ++pub const SHUT_RDWR: ::c_int = 2; ++ ++pub const SO_REUSEADDR: ::c_int = 4; ++pub const SO_LINGER: ::c_int = 128; ++pub const SO_OOBINLINE: ::c_int = 256; ++pub const SO_SNDBUF: ::c_int = 4097; ++pub const SO_RCVBUF: ::c_int = 4098; ++pub const SO_SNDLOWAT: ::c_int = 4099; ++pub const SO_RCVLOWAT: ::c_int = 4100; ++pub const SO_TYPE: ::c_int = 4104; ++pub const SO_ERROR: ::c_int = 4105; ++ ++pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; ++ ++pub const INET_ADDRSTRLEN: ::c_int = 16; ++ ++pub const IPPROTO_IP: ::c_int = 0; ++pub const IPPROTO_UDP: ::c_int = 17; ++pub const IPPROTO_TCP: ::c_int = 6; ++ ++pub const TCP_NODELAY: ::c_int = 8193; ++pub const TCP_MAXSEG: ::c_int = 8194; ++ ++pub const IP_TOS: ::c_int = 7; ++pub const IP_TTL: ::c_int = 8; ++pub const IP_MULTICAST_LOOP: ::c_int = 9; ++pub const IP_MULTICAST_TTL: ::c_int = 10; ++pub const IP_ADD_MEMBERSHIP: ::c_int = 11; ++pub const IP_DROP_MEMBERSHIP: ::c_int = 12; ++ ++pub const HOST_NOT_FOUND: ::c_int = 1; ++pub const NO_DATA: ::c_int = 2; ++pub const NO_ADDRESS: ::c_int = 2; ++pub const NO_RECOVERY: ::c_int = 3; ++pub const TRY_AGAIN: ::c_int = 4; ++ ++pub const AI_PASSIVE: ::c_int = 1; ++pub const AI_CANONNAME: ::c_int = 2; ++pub const AI_NUMERICHOST: ::c_int = 4; ++pub const AI_NUMERICSERV: ::c_int = 0; ++pub const AI_ADDRCONFIG: ::c_int = 0; ++ ++pub const NI_MAXHOST: ::c_int = 1025; ++pub const NI_MAXSERV: ::c_int = 32; ++pub const NI_NOFQDN: ::c_int = 1; ++pub const NI_NUMERICHOST: ::c_int = 2; ++pub const NI_NAMEREQD: ::c_int = 4; ++pub const NI_NUMERICSERV: ::c_int = 0; ++pub const NI_DGRAM: ::c_int = 0; ++ ++pub const EAI_FAMILY: ::c_int = -303; ++pub const EAI_MEMORY: ::c_int = -304; ++pub const EAI_NONAME: ::c_int = -305; ++pub const EAI_SOCKTYPE: ::c_int = -307; ++ ++f! { ++ pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { ++ let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ let fd = fd as usize; ++ (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); ++ return ++ } ++ ++ pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { ++ let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ let fd = fd as usize; ++ return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0 ++ } ++ ++ pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { ++ let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ let fd = fd as usize; ++ (*set).fds_bits[fd / bits] |= 1 << (fd % bits); ++ return ++ } ++ ++ pub fn FD_ZERO(set: *mut fd_set) -> () { ++ for slot in (*set).fds_bits.iter_mut() { ++ *slot = 0; ++ } ++ } ++} ++ ++extern { ++ pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int; ++ pub fn closesocket(sockfd: ::c_int) -> ::c_int; ++ pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; ++ pub fn recvfrom(fd: ::c_int, buf: *mut ::c_void, n: usize, flags: ::c_int, ++ addr: *mut sockaddr, addr_len: *mut socklen_t) -> isize; ++ pub fn getnameinfo(sa: *const sockaddr, salen: socklen_t, ++ host: *mut ::c_char, hostlen: socklen_t, ++ serv: *mut ::c_char, servlen: socklen_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; ++ pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, ++ envp: *const *const ::c_char) ++ -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] ++ pub fn getgrgid_r(uid: ::uid_t, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "sigaltstack$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] ++ pub fn sigaltstack(ss: *const stack_t, ++ oss: *mut stack_t) -> ::c_int; ++ pub fn sem_close(sem: *mut sem_t) -> ::c_int; ++ pub fn getdtablesize() -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] ++ pub fn getgrnam_r(name: *const ::c_char, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_sigmask$UNIX2003")] ++ pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, ++ oldset: *mut sigset_t) -> ::c_int; ++ pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; ++ pub fn getgrnam(name: *const ::c_char) -> *mut ::group; ++ pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; ++ pub fn sem_unlink(name: *const ::c_char) -> ::c_int; ++ pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] ++ pub fn getpwnam_r(name: *const ::c_char, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] ++ pub fn getpwuid_r(uid: ::uid_t, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch ="x86"), ++ link_name = "sigwait$UNIX2003")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] ++ pub fn sigwait(set: *const sigset_t, ++ sig: *mut ::c_int) -> ::c_int; ++ pub fn pthread_atfork(prepare: Option, ++ parent: Option, ++ child: Option) -> ::c_int; ++ pub fn getgrgid(gid: ::gid_t) -> *mut ::group; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "popen$UNIX2003")] ++ pub fn popen(command: *const c_char, ++ mode: *const c_char) -> *mut ::FILE; ++} ++ ++cfg_if! { ++ if #[cfg(target_arch = "arm")] { ++ mod arm; ++ pub use self::arm::*; ++ } else { ++ // Only tested on ARM so far. Other platforms might have different ++ // definitions for types and constants. ++ pub use target_arch_not_implemented; ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/android/b32/arm.rs index 000000000,000000000..c38f64428 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/android/b32/arm.rs @@@ -1,0 -1,0 +1,12 @@@ ++pub type c_char = u8; ++pub type wchar_t = u32; ++ ++pub const O_DIRECT: ::c_int = 0x10000; ++pub const O_DIRECTORY: ::c_int = 0x4000; ++pub const O_NOFOLLOW: ::c_int = 0x8000; ++pub const O_LARGEFILE: ::c_int = 0o400000; ++ ++pub const SYS_pivot_root: ::c_long = 218; ++pub const SYS_gettid: ::c_long = 224; ++pub const SYS_perf_event_open: ::c_long = 364; ++pub const SYS_memfd_create: ::c_long = 385; diff --cc vendor/libc-0.2.31/src/unix/notbsd/android/b32/mod.rs index 000000000,000000000..99af6d8ab new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/android/b32/mod.rs @@@ -1,0 -1,0 +1,230 @@@ ++// The following definitions are correct for arm and i686, ++// but may be wrong for mips ++ ++pub type c_long = i32; ++pub type c_ulong = u32; ++pub type mode_t = u16; ++pub type off64_t = ::c_longlong; ++pub type sigset_t = ::c_ulong; ++pub type socklen_t = i32; ++pub type time64_t = i64; ++ ++s! { ++ pub struct sigaction { ++ pub sa_sigaction: ::sighandler_t, ++ pub sa_mask: ::sigset_t, ++ pub sa_flags: ::c_ulong, ++ pub sa_restorer: ::dox::Option, ++ } ++ ++ pub struct rlimit64 { ++ pub rlim_cur: u64, ++ pub rlim_max: u64, ++ } ++ ++ pub struct stat { ++ pub st_dev: ::c_ulonglong, ++ __pad0: [::c_uchar; 4], ++ __st_ino: ::ino_t, ++ pub st_mode: ::c_uint, ++ pub st_nlink: ::c_uint, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::c_ulonglong, ++ __pad3: [::c_uchar; 4], ++ pub st_size: ::c_longlong, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::c_ulonglong, ++ pub st_atime: ::c_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 statfs64 { ++ pub f_type: u32, ++ pub f_bsize: u32, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ f_fsid: [u32; 2], ++ pub f_namelen: u32, ++ pub f_frsize: u32, ++ pub f_flags: u32, ++ pub f_spare: [u32; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: ::c_ulong, ++ pub f_bfree: ::c_ulong, ++ pub f_bavail: ::c_ulong, ++ pub f_files: ::c_ulong, ++ pub f_ffree: ::c_ulong, ++ pub f_favail: ::c_ulong, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ } ++ ++ pub struct pthread_attr_t { ++ pub flags: ::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 RTLD_GLOBAL: ::c_int = 2; ++pub const RTLD_NOW: ::c_int = 0; ++pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void; ++ ++pub const PTRACE_GETFPREGS: ::c_int = 14; ++pub const PTRACE_SETFPREGS: ::c_int = 15; ++pub const PTRACE_GETREGS: ::c_int = 12; ++pub const PTRACE_SETREGS: ::c_int = 13; ++ ++pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ++ value: 0, ++}; ++pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { ++ value: 0, ++}; ++pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { ++ lock: PTHREAD_MUTEX_INITIALIZER, ++ cond: PTHREAD_COND_INITIALIZER, ++ numLocks: 0, ++ writerThreadId: 0, ++ pendingReaders: 0, ++ pendingWriters: 0, ++ attr: 0, ++ __reserved: [0; 12], ++}; ++pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2; ++pub const CPU_SETSIZE: ::size_t = 32; ++pub const __CPU_BITS: ::size_t = 32; ++ ++pub const UT_LINESIZE: usize = 8; ++pub const UT_NAMESIZE: usize = 8; ++pub const UT_HOSTSIZE: usize = 16; ++ ++pub const SIGSTKSZ: ::size_t = 8192; ++pub const MINSIGSTKSZ: ::size_t = 2048; ++ ++extern { ++ pub fn bind(socket: ::c_int, address: *const ::sockaddr, ++ address_len: socklen_t) -> ::c_int; ++ ++ pub fn writev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ pub fn readv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ ++ pub fn sendmsg(fd: ::c_int, ++ msg: *const ::msghdr, ++ flags: ::c_int) -> ::ssize_t; ++ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) ++ -> ::ssize_t; ++ ++ pub fn timegm64(tm: *const ::tm) -> ::time64_t; ++} ++ ++cfg_if! { ++ if #[cfg(target_arch = "x86")] { ++ mod x86; ++ pub use self::x86::*; ++ } else if #[cfg(target_arch = "arm")] { ++ mod arm; ++ pub use self::arm::*; ++ } else { ++ // Unknown target_arch ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/android/b32/x86.rs index 000000000,000000000..a56fa0045 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/android/b32/x86.rs @@@ -1,0 -1,0 +1,415 @@@ ++pub type c_char = i8; ++pub type wchar_t = i32; ++ ++pub const O_DIRECT: ::c_int = 0x4000; ++pub const O_DIRECTORY: ::c_int = 0x10000; ++pub const O_NOFOLLOW: ::c_int = 0x20000; ++pub const O_LARGEFILE: ::c_int = 0o0100000; ++ ++pub const MAP_32BIT: ::c_int = 0x40; ++ ++// Syscall table ++pub const SYS_restart_syscall: ::c_long = 0; ++pub const SYS_exit: ::c_long = 1; ++pub const SYS_fork: ::c_long = 2; ++pub const SYS_read: ::c_long = 3; ++pub const SYS_write: ::c_long = 4; ++pub const SYS_open: ::c_long = 5; ++pub const SYS_close: ::c_long = 6; ++pub const SYS_waitpid: ::c_long = 7; ++pub const SYS_creat: ::c_long = 8; ++pub const SYS_link: ::c_long = 9; ++pub const SYS_unlink: ::c_long = 10; ++pub const SYS_execve: ::c_long = 11; ++pub const SYS_chdir: ::c_long = 12; ++pub const SYS_time: ::c_long = 13; ++pub const SYS_mknod: ::c_long = 14; ++pub const SYS_chmod: ::c_long = 15; ++pub const SYS_lchown: ::c_long = 16; ++pub const SYS_break: ::c_long = 17; ++pub const SYS_oldstat: ::c_long = 18; ++pub const SYS_lseek: ::c_long = 19; ++pub const SYS_getpid: ::c_long = 20; ++pub const SYS_mount: ::c_long = 21; ++pub const SYS_umount: ::c_long = 22; ++pub const SYS_setuid: ::c_long = 23; ++pub const SYS_getuid: ::c_long = 24; ++pub const SYS_stime: ::c_long = 25; ++pub const SYS_ptrace: ::c_long = 26; ++pub const SYS_alarm: ::c_long = 27; ++pub const SYS_oldfstat: ::c_long = 28; ++pub const SYS_pause: ::c_long = 29; ++pub const SYS_utime: ::c_long = 30; ++pub const SYS_stty: ::c_long = 31; ++pub const SYS_gtty: ::c_long = 32; ++pub const SYS_access: ::c_long = 33; ++pub const SYS_nice: ::c_long = 34; ++pub const SYS_ftime: ::c_long = 35; ++pub const SYS_sync: ::c_long = 36; ++pub const SYS_kill: ::c_long = 37; ++pub const SYS_rename: ::c_long = 38; ++pub const SYS_mkdir: ::c_long = 39; ++pub const SYS_rmdir: ::c_long = 40; ++pub const SYS_dup: ::c_long = 41; ++pub const SYS_pipe: ::c_long = 42; ++pub const SYS_times: ::c_long = 43; ++pub const SYS_prof: ::c_long = 44; ++pub const SYS_brk: ::c_long = 45; ++pub const SYS_setgid: ::c_long = 46; ++pub const SYS_getgid: ::c_long = 47; ++pub const SYS_signal: ::c_long = 48; ++pub const SYS_geteuid: ::c_long = 49; ++pub const SYS_getegid: ::c_long = 50; ++pub const SYS_acct: ::c_long = 51; ++pub const SYS_umount2: ::c_long = 52; ++pub const SYS_lock: ::c_long = 53; ++pub const SYS_ioctl: ::c_long = 54; ++pub const SYS_fcntl: ::c_long = 55; ++pub const SYS_mpx: ::c_long = 56; ++pub const SYS_setpgid: ::c_long = 57; ++pub const SYS_ulimit: ::c_long = 58; ++pub const SYS_oldolduname: ::c_long = 59; ++pub const SYS_umask: ::c_long = 60; ++pub const SYS_chroot: ::c_long = 61; ++pub const SYS_ustat: ::c_long = 62; ++pub const SYS_dup2: ::c_long = 63; ++pub const SYS_getppid: ::c_long = 64; ++pub const SYS_getpgrp: ::c_long = 65; ++pub const SYS_setsid: ::c_long = 66; ++pub const SYS_sigaction: ::c_long = 67; ++pub const SYS_sgetmask: ::c_long = 68; ++pub const SYS_ssetmask: ::c_long = 69; ++pub const SYS_setreuid: ::c_long = 70; ++pub const SYS_setregid: ::c_long = 71; ++pub const SYS_sigsuspend: ::c_long = 72; ++pub const SYS_sigpending: ::c_long = 73; ++pub const SYS_sethostname: ::c_long = 74; ++pub const SYS_setrlimit: ::c_long = 75; ++pub const SYS_getrlimit: ::c_long = 76; ++pub const SYS_getrusage: ::c_long = 77; ++pub const SYS_gettimeofday: ::c_long = 78; ++pub const SYS_settimeofday: ::c_long = 79; ++pub const SYS_getgroups: ::c_long = 80; ++pub const SYS_setgroups: ::c_long = 81; ++pub const SYS_select: ::c_long = 82; ++pub const SYS_symlink: ::c_long = 83; ++pub const SYS_oldlstat: ::c_long = 84; ++pub const SYS_readlink: ::c_long = 85; ++pub const SYS_uselib: ::c_long = 86; ++pub const SYS_swapon: ::c_long = 87; ++pub const SYS_reboot: ::c_long = 88; ++pub const SYS_readdir: ::c_long = 89; ++pub const SYS_mmap: ::c_long = 90; ++pub const SYS_munmap: ::c_long = 91; ++pub const SYS_truncate: ::c_long = 92; ++pub const SYS_ftruncate: ::c_long = 93; ++pub const SYS_fchmod: ::c_long = 94; ++pub const SYS_fchown: ::c_long = 95; ++pub const SYS_getpriority: ::c_long = 96; ++pub const SYS_setpriority: ::c_long = 97; ++pub const SYS_profil: ::c_long = 98; ++pub const SYS_statfs: ::c_long = 99; ++pub const SYS_fstatfs: ::c_long = 100; ++pub const SYS_ioperm: ::c_long = 101; ++pub const SYS_socketcall: ::c_long = 102; ++pub const SYS_syslog: ::c_long = 103; ++pub const SYS_setitimer: ::c_long = 104; ++pub const SYS_getitimer: ::c_long = 105; ++pub const SYS_stat: ::c_long = 106; ++pub const SYS_lstat: ::c_long = 107; ++pub const SYS_fstat: ::c_long = 108; ++pub const SYS_olduname: ::c_long = 109; ++pub const SYS_iopl: ::c_long = 110; ++pub const SYS_vhangup: ::c_long = 111; ++pub const SYS_idle: ::c_long = 112; ++pub const SYS_vm86old: ::c_long = 113; ++pub const SYS_wait4: ::c_long = 114; ++pub const SYS_swapoff: ::c_long = 115; ++pub const SYS_sysinfo: ::c_long = 116; ++pub const SYS_ipc: ::c_long = 117; ++pub const SYS_fsync: ::c_long = 118; ++pub const SYS_sigreturn: ::c_long = 119; ++pub const SYS_clone: ::c_long = 120; ++pub const SYS_setdomainname: ::c_long = 121; ++pub const SYS_uname: ::c_long = 122; ++pub const SYS_modify_ldt: ::c_long = 123; ++pub const SYS_adjtimex: ::c_long = 124; ++pub const SYS_mprotect: ::c_long = 125; ++pub const SYS_sigprocmask: ::c_long = 126; ++pub const SYS_create_module: ::c_long = 127; ++pub const SYS_init_module: ::c_long = 128; ++pub const SYS_delete_module: ::c_long = 129; ++pub const SYS_get_kernel_syms: ::c_long = 130; ++pub const SYS_quotactl: ::c_long = 131; ++pub const SYS_getpgid: ::c_long = 132; ++pub const SYS_fchdir: ::c_long = 133; ++pub const SYS_bdflush: ::c_long = 134; ++pub const SYS_sysfs: ::c_long = 135; ++pub const SYS_personality: ::c_long = 136; ++pub const SYS_afs_syscall: ::c_long = 137; ++pub const SYS_setfsuid: ::c_long = 138; ++pub const SYS_setfsgid: ::c_long = 139; ++// FIXME: SYS__llseek is in the NDK sources but for some reason is ++// not available in the tests ++// pub const SYS__llseek: ::c_long = 140; ++pub const SYS_getdents: ::c_long = 141; ++// FIXME: SYS__newselect is in the NDK sources but for some reason is ++// not available in the tests ++// pub const SYS__newselect: ::c_long = 142; ++pub const SYS_flock: ::c_long = 143; ++pub const SYS_msync: ::c_long = 144; ++pub const SYS_readv: ::c_long = 145; ++pub const SYS_writev: ::c_long = 146; ++pub const SYS_getsid: ::c_long = 147; ++pub const SYS_fdatasync: ::c_long = 148; ++// FIXME: SYS__llseek is in the NDK sources but for some reason is ++// not available in the tests ++// pub const SYS__sysctl: ::c_long = 149; ++pub const SYS_mlock: ::c_long = 150; ++pub const SYS_munlock: ::c_long = 151; ++pub const SYS_mlockall: ::c_long = 152; ++pub const SYS_munlockall: ::c_long = 153; ++pub const SYS_sched_setparam: ::c_long = 154; ++pub const SYS_sched_getparam: ::c_long = 155; ++pub const SYS_sched_setscheduler: ::c_long = 156; ++pub const SYS_sched_getscheduler: ::c_long = 157; ++pub const SYS_sched_yield: ::c_long = 158; ++pub const SYS_sched_get_priority_max: ::c_long = 159; ++pub const SYS_sched_get_priority_min: ::c_long = 160; ++pub const SYS_sched_rr_get_interval: ::c_long = 161; ++pub const SYS_nanosleep: ::c_long = 162; ++pub const SYS_mremap: ::c_long = 163; ++pub const SYS_setresuid: ::c_long = 164; ++pub const SYS_getresuid: ::c_long = 165; ++pub const SYS_vm86: ::c_long = 166; ++pub const SYS_query_module: ::c_long = 167; ++pub const SYS_poll: ::c_long = 168; ++pub const SYS_nfsservctl: ::c_long = 169; ++pub const SYS_setresgid: ::c_long = 170; ++pub const SYS_getresgid: ::c_long = 171; ++pub const SYS_prctl: ::c_long = 172; ++pub const SYS_rt_sigreturn: ::c_long = 173; ++pub const SYS_rt_sigaction: ::c_long = 174; ++pub const SYS_rt_sigprocmask: ::c_long = 175; ++pub const SYS_rt_sigpending: ::c_long = 176; ++pub const SYS_rt_sigtimedwait: ::c_long = 177; ++pub const SYS_rt_sigqueueinfo: ::c_long = 178; ++pub const SYS_rt_sigsuspend: ::c_long = 179; ++pub const SYS_pread64: ::c_long = 180; ++pub const SYS_pwrite64: ::c_long = 181; ++pub const SYS_chown: ::c_long = 182; ++pub const SYS_getcwd: ::c_long = 183; ++pub const SYS_capget: ::c_long = 184; ++pub const SYS_capset: ::c_long = 185; ++pub const SYS_sigaltstack: ::c_long = 186; ++pub const SYS_sendfile: ::c_long = 187; ++pub const SYS_getpmsg: ::c_long = 188; ++pub const SYS_putpmsg: ::c_long = 189; ++pub const SYS_vfork: ::c_long = 190; ++pub const SYS_ugetrlimit: ::c_long = 191; ++pub const SYS_mmap2: ::c_long = 192; ++pub const SYS_truncate64: ::c_long = 193; ++pub const SYS_ftruncate64: ::c_long = 194; ++pub const SYS_stat64: ::c_long = 195; ++pub const SYS_lstat64: ::c_long = 196; ++pub const SYS_fstat64: ::c_long = 197; ++pub const SYS_lchown32: ::c_long = 198; ++pub const SYS_getuid32: ::c_long = 199; ++pub const SYS_getgid32: ::c_long = 200; ++pub const SYS_geteuid32: ::c_long = 201; ++pub const SYS_getegid32: ::c_long = 202; ++pub const SYS_setreuid32: ::c_long = 203; ++pub const SYS_setregid32: ::c_long = 204; ++pub const SYS_getgroups32: ::c_long = 205; ++pub const SYS_setgroups32: ::c_long = 206; ++pub const SYS_fchown32: ::c_long = 207; ++pub const SYS_setresuid32: ::c_long = 208; ++pub const SYS_getresuid32: ::c_long = 209; ++pub const SYS_setresgid32: ::c_long = 210; ++pub const SYS_getresgid32: ::c_long = 211; ++pub const SYS_chown32: ::c_long = 212; ++pub const SYS_setuid32: ::c_long = 213; ++pub const SYS_setgid32: ::c_long = 214; ++pub const SYS_setfsuid32: ::c_long = 215; ++pub const SYS_setfsgid32: ::c_long = 216; ++pub const SYS_pivot_root: ::c_long = 217; ++pub const SYS_mincore: ::c_long = 218; ++pub const SYS_madvise: ::c_long = 219; ++pub const SYS_getdents64: ::c_long = 220; ++pub const SYS_fcntl64: ::c_long = 221; ++pub const SYS_gettid: ::c_long = 224; ++pub const SYS_readahead: ::c_long = 225; ++pub const SYS_setxattr: ::c_long = 226; ++pub const SYS_lsetxattr: ::c_long = 227; ++pub const SYS_fsetxattr: ::c_long = 228; ++pub const SYS_getxattr: ::c_long = 229; ++pub const SYS_lgetxattr: ::c_long = 230; ++pub const SYS_fgetxattr: ::c_long = 231; ++pub const SYS_listxattr: ::c_long = 232; ++pub const SYS_llistxattr: ::c_long = 233; ++pub const SYS_flistxattr: ::c_long = 234; ++pub const SYS_removexattr: ::c_long = 235; ++pub const SYS_lremovexattr: ::c_long = 236; ++pub const SYS_fremovexattr: ::c_long = 237; ++pub const SYS_tkill: ::c_long = 238; ++pub const SYS_sendfile64: ::c_long = 239; ++pub const SYS_futex: ::c_long = 240; ++pub const SYS_sched_setaffinity: ::c_long = 241; ++pub const SYS_sched_getaffinity: ::c_long = 242; ++pub const SYS_set_thread_area: ::c_long = 243; ++pub const SYS_get_thread_area: ::c_long = 244; ++pub const SYS_io_setup: ::c_long = 245; ++pub const SYS_io_destroy: ::c_long = 246; ++pub const SYS_io_getevents: ::c_long = 247; ++pub const SYS_io_submit: ::c_long = 248; ++pub const SYS_io_cancel: ::c_long = 249; ++pub const SYS_fadvise64: ::c_long = 250; ++pub const SYS_exit_group: ::c_long = 252; ++pub const SYS_lookup_dcookie: ::c_long = 253; ++pub const SYS_epoll_create: ::c_long = 254; ++pub const SYS_epoll_ctl: ::c_long = 255; ++pub const SYS_epoll_wait: ::c_long = 256; ++pub const SYS_remap_file_pages: ::c_long = 257; ++pub const SYS_set_tid_address: ::c_long = 258; ++pub const SYS_timer_create: ::c_long = 259; ++pub const SYS_timer_settime: ::c_long = 260; ++pub const SYS_timer_gettime: ::c_long = 261; ++pub const SYS_timer_getoverrun: ::c_long = 262; ++pub const SYS_timer_delete: ::c_long = 263; ++pub const SYS_clock_settime: ::c_long = 264; ++pub const SYS_clock_gettime: ::c_long = 265; ++pub const SYS_clock_getres: ::c_long = 266; ++pub const SYS_clock_nanosleep: ::c_long = 267; ++pub const SYS_statfs64: ::c_long = 268; ++pub const SYS_fstatfs64: ::c_long = 269; ++pub const SYS_tgkill: ::c_long = 270; ++pub const SYS_utimes: ::c_long = 271; ++pub const SYS_fadvise64_64: ::c_long = 272; ++pub const SYS_vserver: ::c_long = 273; ++pub const SYS_mbind: ::c_long = 274; ++pub const SYS_get_mempolicy: ::c_long = 275; ++pub const SYS_set_mempolicy: ::c_long = 276; ++pub const SYS_mq_open: ::c_long = 277; ++pub const SYS_mq_unlink: ::c_long = 278; ++pub const SYS_mq_timedsend: ::c_long = 279; ++pub const SYS_mq_timedreceive: ::c_long = 280; ++pub const SYS_mq_notify: ::c_long = 281; ++pub const SYS_mq_getsetattr: ::c_long = 282; ++pub const SYS_kexec_load: ::c_long = 283; ++pub const SYS_waitid: ::c_long = 284; ++pub const SYS_add_key: ::c_long = 286; ++pub const SYS_request_key: ::c_long = 287; ++pub const SYS_keyctl: ::c_long = 288; ++pub const SYS_ioprio_set: ::c_long = 289; ++pub const SYS_ioprio_get: ::c_long = 290; ++pub const SYS_inotify_init: ::c_long = 291; ++pub const SYS_inotify_add_watch: ::c_long = 292; ++pub const SYS_inotify_rm_watch: ::c_long = 293; ++pub const SYS_migrate_pages: ::c_long = 294; ++pub const SYS_openat: ::c_long = 295; ++pub const SYS_mkdirat: ::c_long = 296; ++pub const SYS_mknodat: ::c_long = 297; ++pub const SYS_fchownat: ::c_long = 298; ++pub const SYS_futimesat: ::c_long = 299; ++pub const SYS_fstatat64: ::c_long = 300; ++pub const SYS_unlinkat: ::c_long = 301; ++pub const SYS_renameat: ::c_long = 302; ++pub const SYS_linkat: ::c_long = 303; ++pub const SYS_symlinkat: ::c_long = 304; ++pub const SYS_readlinkat: ::c_long = 305; ++pub const SYS_fchmodat: ::c_long = 306; ++pub const SYS_faccessat: ::c_long = 307; ++pub const SYS_pselect6: ::c_long = 308; ++pub const SYS_ppoll: ::c_long = 309; ++pub const SYS_unshare: ::c_long = 310; ++pub const SYS_set_robust_list: ::c_long = 311; ++pub const SYS_get_robust_list: ::c_long = 312; ++pub const SYS_splice: ::c_long = 313; ++pub const SYS_sync_file_range: ::c_long = 314; ++pub const SYS_tee: ::c_long = 315; ++pub const SYS_vmsplice: ::c_long = 316; ++pub const SYS_move_pages: ::c_long = 317; ++pub const SYS_getcpu: ::c_long = 318; ++pub const SYS_epoll_pwait: ::c_long = 319; ++pub const SYS_utimensat: ::c_long = 320; ++pub const SYS_signalfd: ::c_long = 321; ++pub const SYS_timerfd_create: ::c_long = 322; ++pub const SYS_eventfd: ::c_long = 323; ++pub const SYS_fallocate: ::c_long = 324; ++pub const SYS_timerfd_settime: ::c_long = 325; ++pub const SYS_timerfd_gettime: ::c_long = 326; ++pub const SYS_signalfd4: ::c_long = 327; ++pub const SYS_eventfd2: ::c_long = 328; ++pub const SYS_epoll_create1: ::c_long = 329; ++pub const SYS_dup3: ::c_long = 330; ++pub const SYS_pipe2: ::c_long = 331; ++pub const SYS_inotify_init1: ::c_long = 332; ++pub const SYS_preadv: ::c_long = 333; ++pub const SYS_pwritev: ::c_long = 334; ++pub const SYS_rt_tgsigqueueinfo: ::c_long = 335; ++pub const SYS_perf_event_open: ::c_long = 336; ++pub const SYS_recvmmsg: ::c_long = 337; ++pub const SYS_fanotify_init: ::c_long = 338; ++pub const SYS_fanotify_mark: ::c_long = 339; ++pub const SYS_prlimit64: ::c_long = 340; ++pub const SYS_name_to_handle_at: ::c_long = 341; ++pub const SYS_open_by_handle_at: ::c_long = 342; ++pub const SYS_clock_adjtime: ::c_long = 343; ++pub const SYS_syncfs: ::c_long = 344; ++pub const SYS_sendmmsg: ::c_long = 345; ++pub const SYS_setns: ::c_long = 346; ++pub const SYS_process_vm_readv: ::c_long = 347; ++pub const SYS_process_vm_writev: ::c_long = 348; ++pub const SYS_kcmp: ::c_long = 349; ++pub const SYS_finit_module: ::c_long = 350; ++pub const SYS_sched_setattr: ::c_long = 351; ++pub const SYS_sched_getattr: ::c_long = 352; ++pub const SYS_renameat2: ::c_long = 353; ++pub const SYS_seccomp: ::c_long = 354; ++pub const SYS_getrandom: ::c_long = 355; ++pub const SYS_memfd_create: ::c_long = 356; ++pub const SYS_bpf: ::c_long = 357; ++pub const SYS_execveat: ::c_long = 358; ++pub const SYS_socket: ::c_long = 359; ++pub const SYS_socketpair: ::c_long = 360; ++pub const SYS_bind: ::c_long = 361; ++pub const SYS_connect: ::c_long = 362; ++pub const SYS_listen: ::c_long = 363; ++pub const SYS_accept4: ::c_long = 364; ++pub const SYS_getsockopt: ::c_long = 365; ++pub const SYS_setsockopt: ::c_long = 366; ++pub const SYS_getsockname: ::c_long = 367; ++pub const SYS_getpeername: ::c_long = 368; ++pub const SYS_sendto: ::c_long = 369; ++pub const SYS_sendmsg: ::c_long = 370; ++pub const SYS_recvfrom: ::c_long = 371; ++pub const SYS_recvmsg: ::c_long = 372; ++pub const SYS_shutdown: ::c_long = 373; ++pub const SYS_userfaultfd: ::c_long = 374; ++pub const SYS_membarrier: ::c_long = 375; ++pub const SYS_mlock2: ::c_long = 376; ++pub const SYS_copy_file_range: ::c_long = 377; ++pub const SYS_preadv2: ::c_long = 378; ++pub const SYS_pwritev2: ::c_long = 379; ++pub const SYS_pkey_mprotect: ::c_long = 380; ++pub const SYS_pkey_alloc: ::c_long = 381; ++pub const SYS_pkey_free: ::c_long = 382; ++ ++// offsets in user_regs_structs, from sys/reg.h ++pub const EBX: ::c_int = 0; ++pub const ECX: ::c_int = 1; ++pub const EDX: ::c_int = 2; ++pub const ESI: ::c_int = 3; ++pub const EDI: ::c_int = 4; ++pub const EBP: ::c_int = 5; ++pub const EAX: ::c_int = 6; ++pub const DS: ::c_int = 7; ++pub const ES: ::c_int = 8; ++pub const FS: ::c_int = 9; ++pub const GS: ::c_int = 10; ++pub const ORIG_EAX: ::c_int = 11; ++pub const EIP: ::c_int = 12; ++pub const CS: ::c_int = 13; ++pub const EFL: ::c_int = 14; ++pub const UESP: ::c_int = 15; ++pub const SS: ::c_int = 16; diff --cc vendor/libc-0.2.31/src/unix/notbsd/android/b64/aarch64.rs index 000000000,000000000..f08f4f1cc new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/android/b64/aarch64.rs @@@ -1,0 -1,0 +1,63 @@@ ++pub type c_char = u8; ++pub type wchar_t = u32; ++ ++s! { ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino_t, ++ pub st_mode: ::c_uint, ++ pub st_nlink: ::c_uint, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ __pad1: ::c_ulong, ++ pub st_size: ::off64_t, ++ pub st_blksize: ::c_int, ++ __pad2: ::c_int, ++ pub st_blocks: ::c_long, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_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 const O_DIRECT: ::c_int = 0x10000; ++pub const O_DIRECTORY: ::c_int = 0x4000; ++pub const O_NOFOLLOW: ::c_int = 0x8000; ++pub const O_LARGEFILE: ::c_int = 0o400000; ++ ++pub const SYS_pivot_root: ::c_long = 41; ++pub const SYS_gettid: ::c_long = 178; ++pub const SYS_perf_event_open: ::c_long = 241; ++pub const SYS_memfd_create: ::c_long = 279; ++ ++pub const SIGSTKSZ: ::size_t = 16384; ++pub const MINSIGSTKSZ: ::size_t = 5120; diff --cc vendor/libc-0.2.31/src/unix/notbsd/android/b64/mod.rs index 000000000,000000000..4aa69977a new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/android/b64/mod.rs @@@ -1,0 -1,0 +1,192 @@@ ++// The following definitions are correct for aarch64 and x86_64, ++// but may be wrong for mips64 ++ ++pub type c_long = i64; ++pub type c_ulong = u64; ++pub type mode_t = u32; ++pub type off64_t = i64; ++pub type socklen_t = u32; ++ ++s! { ++ pub struct sigset_t { ++ __val: [::c_ulong; 1], ++ } ++ ++ pub struct sigaction { ++ pub sa_flags: ::c_uint, ++ pub sa_sigaction: ::sighandler_t, ++ pub sa_mask: ::sigset_t, ++ pub sa_restorer: ::dox::Option, ++ } ++ ++ pub struct rlimit64 { ++ pub rlim_cur: ::c_ulonglong, ++ pub rlim_max: ::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, ++ __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 struct statfs64 { ++ pub f_type: u64, ++ pub f_bsize: u64, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ f_fsid: [u32; 2], ++ pub f_namelen: u64, ++ pub f_frsize: u64, ++ pub f_flags: u64, ++ pub f_spare: [u64; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++} ++ ++pub const RTLD_GLOBAL: ::c_int = 0x00100; ++pub const RTLD_NOW: ::c_int = 2; ++pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; ++ ++pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ++ value: 0, ++ __reserved: [0; 36], ++}; ++pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { ++ value: 0, ++ __reserved: [0; 44], ++}; ++pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { ++ numLocks: 0, ++ writerThreadId: 0, ++ pendingReaders: 0, ++ pendingWriters: 0, ++ attr: 0, ++ __reserved: [0; 36], ++}; ++pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 4; ++pub const CPU_SETSIZE: ::size_t = 1024; ++pub const __CPU_BITS: ::size_t = 64; ++ ++pub const UT_LINESIZE: usize = 32; ++pub const UT_NAMESIZE: usize = 32; ++pub const UT_HOSTSIZE: usize = 256; ++ ++// Some weirdness in Android ++extern { ++ // address_len should be socklen_t, but it is c_int! ++ pub fn bind(socket: ::c_int, address: *const ::sockaddr, ++ address_len: ::c_int) -> ::c_int; ++ ++ // the return type should be ::ssize_t, but it is c_int! ++ pub fn writev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::c_int; ++ ++ // the return type should be ::ssize_t, but it is c_int! ++ pub fn readv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::c_int; ++ ++ // the return type should be ::ssize_t, but it is c_int! ++ pub fn sendmsg(fd: ::c_int, ++ msg: *const ::msghdr, ++ flags: ::c_int) -> ::c_int; ++ ++ // the return type should be ::ssize_t, but it is c_int! ++ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::c_int; ++} ++ ++cfg_if! { ++ if #[cfg(target_arch = "x86_64")] { ++ mod x86_64; ++ pub use self::x86_64::*; ++ } else if #[cfg(target_arch = "aarch64")] { ++ mod aarch64; ++ pub use self::aarch64::*; ++ } else { ++ // Unknown target_arch ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/android/b64/x86_64.rs index 000000000,000000000..c813e7da3 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/android/b64/x86_64.rs @@@ -1,0 -1,0 +1,420 @@@ ++pub type c_char = i8; ++pub type wchar_t = i32; ++ ++s! { ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino_t, ++ pub st_nlink: ::c_ulong, ++ pub st_mode: ::c_uint, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ pub st_size: ::off64_t, ++ pub st_blksize: ::c_long, ++ pub st_blocks: ::c_long, ++ pub st_atime: ::c_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, ++ __unused: [::c_long; 3], ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino_t, ++ pub st_nlink: ::c_ulong, ++ pub st_mode: ::c_uint, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ pub st_size: ::off64_t, ++ pub st_blksize: ::c_long, ++ pub st_blocks: ::c_long, ++ pub st_atime: ::c_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, ++ __unused: [::c_long; 3], ++ } ++} ++ ++pub const O_DIRECT: ::c_int = 0x4000; ++pub const O_DIRECTORY: ::c_int = 0x10000; ++pub const O_NOFOLLOW: ::c_int = 0x20000; ++pub const O_LARGEFILE: ::c_int = 0o0100000; ++ ++pub const SIGSTKSZ: ::size_t = 8192; ++pub const MINSIGSTKSZ: ::size_t = 2048; ++ ++pub const MAP_32BIT: ::c_int = 0x40; ++ ++// Syscall table ++ ++pub const SYS_read: ::c_long = 0; ++pub const SYS_write: ::c_long = 1; ++pub const SYS_open: ::c_long = 2; ++pub const SYS_close: ::c_long = 3; ++pub const SYS_stat: ::c_long = 4; ++pub const SYS_fstat: ::c_long = 5; ++pub const SYS_lstat: ::c_long = 6; ++pub const SYS_poll: ::c_long = 7; ++pub const SYS_lseek: ::c_long = 8; ++pub const SYS_mmap: ::c_long = 9; ++pub const SYS_mprotect: ::c_long = 10; ++pub const SYS_munmap: ::c_long = 11; ++pub const SYS_brk: ::c_long = 12; ++pub const SYS_rt_sigaction: ::c_long = 13; ++pub const SYS_rt_sigprocmask: ::c_long = 14; ++pub const SYS_rt_sigreturn: ::c_long = 15; ++pub const SYS_ioctl: ::c_long = 16; ++pub const SYS_pread64: ::c_long = 17; ++pub const SYS_pwrite64: ::c_long = 18; ++pub const SYS_readv: ::c_long = 19; ++pub const SYS_writev: ::c_long = 20; ++pub const SYS_access: ::c_long = 21; ++pub const SYS_pipe: ::c_long = 22; ++pub const SYS_select: ::c_long = 23; ++pub const SYS_sched_yield: ::c_long = 24; ++pub const SYS_mremap: ::c_long = 25; ++pub const SYS_msync: ::c_long = 26; ++pub const SYS_mincore: ::c_long = 27; ++pub const SYS_madvise: ::c_long = 28; ++pub const SYS_shmget: ::c_long = 29; ++pub const SYS_shmat: ::c_long = 30; ++pub const SYS_shmctl: ::c_long = 31; ++pub const SYS_dup: ::c_long = 32; ++pub const SYS_dup2: ::c_long = 33; ++pub const SYS_pause: ::c_long = 34; ++pub const SYS_nanosleep: ::c_long = 35; ++pub const SYS_getitimer: ::c_long = 36; ++pub const SYS_alarm: ::c_long = 37; ++pub const SYS_setitimer: ::c_long = 38; ++pub const SYS_getpid: ::c_long = 39; ++pub const SYS_sendfile: ::c_long = 40; ++pub const SYS_socket: ::c_long = 41; ++pub const SYS_connect: ::c_long = 42; ++pub const SYS_accept: ::c_long = 43; ++pub const SYS_sendto: ::c_long = 44; ++pub const SYS_recvfrom: ::c_long = 45; ++pub const SYS_sendmsg: ::c_long = 46; ++pub const SYS_recvmsg: ::c_long = 47; ++pub const SYS_shutdown: ::c_long = 48; ++pub const SYS_bind: ::c_long = 49; ++pub const SYS_listen: ::c_long = 50; ++pub const SYS_getsockname: ::c_long = 51; ++pub const SYS_getpeername: ::c_long = 52; ++pub const SYS_socketpair: ::c_long = 53; ++pub const SYS_setsockopt: ::c_long = 54; ++pub const SYS_getsockopt: ::c_long = 55; ++pub const SYS_clone: ::c_long = 56; ++pub const SYS_fork: ::c_long = 57; ++pub const SYS_vfork: ::c_long = 58; ++pub const SYS_execve: ::c_long = 59; ++pub const SYS_exit: ::c_long = 60; ++pub const SYS_wait4: ::c_long = 61; ++pub const SYS_kill: ::c_long = 62; ++pub const SYS_uname: ::c_long = 63; ++pub const SYS_semget: ::c_long = 64; ++pub const SYS_semop: ::c_long = 65; ++pub const SYS_semctl: ::c_long = 66; ++pub const SYS_shmdt: ::c_long = 67; ++pub const SYS_msgget: ::c_long = 68; ++pub const SYS_msgsnd: ::c_long = 69; ++pub const SYS_msgrcv: ::c_long = 70; ++pub const SYS_msgctl: ::c_long = 71; ++pub const SYS_fcntl: ::c_long = 72; ++pub const SYS_flock: ::c_long = 73; ++pub const SYS_fsync: ::c_long = 74; ++pub const SYS_fdatasync: ::c_long = 75; ++pub const SYS_truncate: ::c_long = 76; ++pub const SYS_ftruncate: ::c_long = 77; ++pub const SYS_getdents: ::c_long = 78; ++pub const SYS_getcwd: ::c_long = 79; ++pub const SYS_chdir: ::c_long = 80; ++pub const SYS_fchdir: ::c_long = 81; ++pub const SYS_rename: ::c_long = 82; ++pub const SYS_mkdir: ::c_long = 83; ++pub const SYS_rmdir: ::c_long = 84; ++pub const SYS_creat: ::c_long = 85; ++pub const SYS_link: ::c_long = 86; ++pub const SYS_unlink: ::c_long = 87; ++pub const SYS_symlink: ::c_long = 88; ++pub const SYS_readlink: ::c_long = 89; ++pub const SYS_chmod: ::c_long = 90; ++pub const SYS_fchmod: ::c_long = 91; ++pub const SYS_chown: ::c_long = 92; ++pub const SYS_fchown: ::c_long = 93; ++pub const SYS_lchown: ::c_long = 94; ++pub const SYS_umask: ::c_long = 95; ++pub const SYS_gettimeofday: ::c_long = 96; ++pub const SYS_getrlimit: ::c_long = 97; ++pub const SYS_getrusage: ::c_long = 98; ++pub const SYS_sysinfo: ::c_long = 99; ++pub const SYS_times: ::c_long = 100; ++pub const SYS_ptrace: ::c_long = 101; ++pub const SYS_getuid: ::c_long = 102; ++pub const SYS_syslog: ::c_long = 103; ++pub const SYS_getgid: ::c_long = 104; ++pub const SYS_setuid: ::c_long = 105; ++pub const SYS_setgid: ::c_long = 106; ++pub const SYS_geteuid: ::c_long = 107; ++pub const SYS_getegid: ::c_long = 108; ++pub const SYS_setpgid: ::c_long = 109; ++pub const SYS_getppid: ::c_long = 110; ++pub const SYS_getpgrp: ::c_long = 111; ++pub const SYS_setsid: ::c_long = 112; ++pub const SYS_setreuid: ::c_long = 113; ++pub const SYS_setregid: ::c_long = 114; ++pub const SYS_getgroups: ::c_long = 115; ++pub const SYS_setgroups: ::c_long = 116; ++pub const SYS_setresuid: ::c_long = 117; ++pub const SYS_getresuid: ::c_long = 118; ++pub const SYS_setresgid: ::c_long = 119; ++pub const SYS_getresgid: ::c_long = 120; ++pub const SYS_getpgid: ::c_long = 121; ++pub const SYS_setfsuid: ::c_long = 122; ++pub const SYS_setfsgid: ::c_long = 123; ++pub const SYS_getsid: ::c_long = 124; ++pub const SYS_capget: ::c_long = 125; ++pub const SYS_capset: ::c_long = 126; ++pub const SYS_rt_sigpending: ::c_long = 127; ++pub const SYS_rt_sigtimedwait: ::c_long = 128; ++pub const SYS_rt_sigqueueinfo: ::c_long = 129; ++pub const SYS_rt_sigsuspend: ::c_long = 130; ++pub const SYS_sigaltstack: ::c_long = 131; ++pub const SYS_utime: ::c_long = 132; ++pub const SYS_mknod: ::c_long = 133; ++pub const SYS_uselib: ::c_long = 134; ++pub const SYS_personality: ::c_long = 135; ++pub const SYS_ustat: ::c_long = 136; ++pub const SYS_statfs: ::c_long = 137; ++pub const SYS_fstatfs: ::c_long = 138; ++pub const SYS_sysfs: ::c_long = 139; ++pub const SYS_getpriority: ::c_long = 140; ++pub const SYS_setpriority: ::c_long = 141; ++pub const SYS_sched_setparam: ::c_long = 142; ++pub const SYS_sched_getparam: ::c_long = 143; ++pub const SYS_sched_setscheduler: ::c_long = 144; ++pub const SYS_sched_getscheduler: ::c_long = 145; ++pub const SYS_sched_get_priority_max: ::c_long = 146; ++pub const SYS_sched_get_priority_min: ::c_long = 147; ++pub const SYS_sched_rr_get_interval: ::c_long = 148; ++pub const SYS_mlock: ::c_long = 149; ++pub const SYS_munlock: ::c_long = 150; ++pub const SYS_mlockall: ::c_long = 151; ++pub const SYS_munlockall: ::c_long = 152; ++pub const SYS_vhangup: ::c_long = 153; ++pub const SYS_modify_ldt: ::c_long = 154; ++pub const SYS_pivot_root: ::c_long = 155; ++// FIXME: SYS__sysctl is in the NDK sources but for some reason is ++// not available in the tests ++// pub const SYS__sysctl: ::c_long = 156; ++pub const SYS_prctl: ::c_long = 157; ++pub const SYS_arch_prctl: ::c_long = 158; ++pub const SYS_adjtimex: ::c_long = 159; ++pub const SYS_setrlimit: ::c_long = 160; ++pub const SYS_chroot: ::c_long = 161; ++pub const SYS_sync: ::c_long = 162; ++pub const SYS_acct: ::c_long = 163; ++pub const SYS_settimeofday: ::c_long = 164; ++pub const SYS_mount: ::c_long = 165; ++pub const SYS_umount2: ::c_long = 166; ++pub const SYS_swapon: ::c_long = 167; ++pub const SYS_swapoff: ::c_long = 168; ++pub const SYS_reboot: ::c_long = 169; ++pub const SYS_sethostname: ::c_long = 170; ++pub const SYS_setdomainname: ::c_long = 171; ++pub const SYS_iopl: ::c_long = 172; ++pub const SYS_ioperm: ::c_long = 173; ++pub const SYS_create_module: ::c_long = 174; ++pub const SYS_init_module: ::c_long = 175; ++pub const SYS_delete_module: ::c_long = 176; ++pub const SYS_get_kernel_syms: ::c_long = 177; ++pub const SYS_query_module: ::c_long = 178; ++pub const SYS_quotactl: ::c_long = 179; ++pub const SYS_nfsservctl: ::c_long = 180; ++pub const SYS_getpmsg: ::c_long = 181; ++pub const SYS_putpmsg: ::c_long = 182; ++pub const SYS_afs_syscall: ::c_long = 183; ++pub const SYS_tuxcall: ::c_long = 184; ++pub const SYS_security: ::c_long = 185; ++pub const SYS_gettid: ::c_long = 186; ++pub const SYS_readahead: ::c_long = 187; ++pub const SYS_setxattr: ::c_long = 188; ++pub const SYS_lsetxattr: ::c_long = 189; ++pub const SYS_fsetxattr: ::c_long = 190; ++pub const SYS_getxattr: ::c_long = 191; ++pub const SYS_lgetxattr: ::c_long = 192; ++pub const SYS_fgetxattr: ::c_long = 193; ++pub const SYS_listxattr: ::c_long = 194; ++pub const SYS_llistxattr: ::c_long = 195; ++pub const SYS_flistxattr: ::c_long = 196; ++pub const SYS_removexattr: ::c_long = 197; ++pub const SYS_lremovexattr: ::c_long = 198; ++pub const SYS_fremovexattr: ::c_long = 199; ++pub const SYS_tkill: ::c_long = 200; ++pub const SYS_time: ::c_long = 201; ++pub const SYS_futex: ::c_long = 202; ++pub const SYS_sched_setaffinity: ::c_long = 203; ++pub const SYS_sched_getaffinity: ::c_long = 204; ++pub const SYS_set_thread_area: ::c_long = 205; ++pub const SYS_io_setup: ::c_long = 206; ++pub const SYS_io_destroy: ::c_long = 207; ++pub const SYS_io_getevents: ::c_long = 208; ++pub const SYS_io_submit: ::c_long = 209; ++pub const SYS_io_cancel: ::c_long = 210; ++pub const SYS_get_thread_area: ::c_long = 211; ++pub const SYS_lookup_dcookie: ::c_long = 212; ++pub const SYS_epoll_create: ::c_long = 213; ++pub const SYS_epoll_ctl_old: ::c_long = 214; ++pub const SYS_epoll_wait_old: ::c_long = 215; ++pub const SYS_remap_file_pages: ::c_long = 216; ++pub const SYS_getdents64: ::c_long = 217; ++pub const SYS_set_tid_address: ::c_long = 218; ++pub const SYS_restart_syscall: ::c_long = 219; ++pub const SYS_semtimedop: ::c_long = 220; ++pub const SYS_fadvise64: ::c_long = 221; ++pub const SYS_timer_create: ::c_long = 222; ++pub const SYS_timer_settime: ::c_long = 223; ++pub const SYS_timer_gettime: ::c_long = 224; ++pub const SYS_timer_getoverrun: ::c_long = 225; ++pub const SYS_timer_delete: ::c_long = 226; ++pub const SYS_clock_settime: ::c_long = 227; ++pub const SYS_clock_gettime: ::c_long = 228; ++pub const SYS_clock_getres: ::c_long = 229; ++pub const SYS_clock_nanosleep: ::c_long = 230; ++pub const SYS_exit_group: ::c_long = 231; ++pub const SYS_epoll_wait: ::c_long = 232; ++pub const SYS_epoll_ctl: ::c_long = 233; ++pub const SYS_tgkill: ::c_long = 234; ++pub const SYS_utimes: ::c_long = 235; ++pub const SYS_vserver: ::c_long = 236; ++pub const SYS_mbind: ::c_long = 237; ++pub const SYS_set_mempolicy: ::c_long = 238; ++pub const SYS_get_mempolicy: ::c_long = 239; ++pub const SYS_mq_open: ::c_long = 240; ++pub const SYS_mq_unlink: ::c_long = 241; ++pub const SYS_mq_timedsend: ::c_long = 242; ++pub const SYS_mq_timedreceive: ::c_long = 243; ++pub const SYS_mq_notify: ::c_long = 244; ++pub const SYS_mq_getsetattr: ::c_long = 245; ++pub const SYS_kexec_load: ::c_long = 246; ++pub const SYS_waitid: ::c_long = 247; ++pub const SYS_add_key: ::c_long = 248; ++pub const SYS_request_key: ::c_long = 249; ++pub const SYS_keyctl: ::c_long = 250; ++pub const SYS_ioprio_set: ::c_long = 251; ++pub const SYS_ioprio_get: ::c_long = 252; ++pub const SYS_inotify_init: ::c_long = 253; ++pub const SYS_inotify_add_watch: ::c_long = 254; ++pub const SYS_inotify_rm_watch: ::c_long = 255; ++pub const SYS_migrate_pages: ::c_long = 256; ++pub const SYS_openat: ::c_long = 257; ++pub const SYS_mkdirat: ::c_long = 258; ++pub const SYS_mknodat: ::c_long = 259; ++pub const SYS_fchownat: ::c_long = 260; ++pub const SYS_futimesat: ::c_long = 261; ++pub const SYS_newfstatat: ::c_long = 262; ++pub const SYS_unlinkat: ::c_long = 263; ++pub const SYS_renameat: ::c_long = 264; ++pub const SYS_linkat: ::c_long = 265; ++pub const SYS_symlinkat: ::c_long = 266; ++pub const SYS_readlinkat: ::c_long = 267; ++pub const SYS_fchmodat: ::c_long = 268; ++pub const SYS_faccessat: ::c_long = 269; ++pub const SYS_pselect6: ::c_long = 270; ++pub const SYS_ppoll: ::c_long = 271; ++pub const SYS_unshare: ::c_long = 272; ++pub const SYS_set_robust_list: ::c_long = 273; ++pub const SYS_get_robust_list: ::c_long = 274; ++pub const SYS_splice: ::c_long = 275; ++pub const SYS_tee: ::c_long = 276; ++pub const SYS_sync_file_range: ::c_long = 277; ++pub const SYS_vmsplice: ::c_long = 278; ++pub const SYS_move_pages: ::c_long = 279; ++pub const SYS_utimensat: ::c_long = 280; ++pub const SYS_epoll_pwait: ::c_long = 281; ++pub const SYS_signalfd: ::c_long = 282; ++pub const SYS_timerfd_create: ::c_long = 283; ++pub const SYS_eventfd: ::c_long = 284; ++pub const SYS_fallocate: ::c_long = 285; ++pub const SYS_timerfd_settime: ::c_long = 286; ++pub const SYS_timerfd_gettime: ::c_long = 287; ++pub const SYS_accept4: ::c_long = 288; ++pub const SYS_signalfd4: ::c_long = 289; ++pub const SYS_eventfd2: ::c_long = 290; ++pub const SYS_epoll_create1: ::c_long = 291; ++pub const SYS_dup3: ::c_long = 292; ++pub const SYS_pipe2: ::c_long = 293; ++pub const SYS_inotify_init1: ::c_long = 294; ++pub const SYS_preadv: ::c_long = 295; ++pub const SYS_pwritev: ::c_long = 296; ++pub const SYS_rt_tgsigqueueinfo: ::c_long = 297; ++pub const SYS_perf_event_open: ::c_long = 298; ++pub const SYS_recvmmsg: ::c_long = 299; ++pub const SYS_fanotify_init: ::c_long = 300; ++pub const SYS_fanotify_mark: ::c_long = 301; ++pub const SYS_prlimit64: ::c_long = 302; ++pub const SYS_name_to_handle_at: ::c_long = 303; ++pub const SYS_open_by_handle_at: ::c_long = 304; ++pub const SYS_clock_adjtime: ::c_long = 305; ++pub const SYS_syncfs: ::c_long = 306; ++pub const SYS_sendmmsg: ::c_long = 307; ++pub const SYS_setns: ::c_long = 308; ++pub const SYS_getcpu: ::c_long = 309; ++pub const SYS_process_vm_readv: ::c_long = 310; ++pub const SYS_process_vm_writev: ::c_long = 311; ++pub const SYS_kcmp: ::c_long = 312; ++pub const SYS_finit_module: ::c_long = 313; ++pub const SYS_sched_setattr: ::c_long = 314; ++pub const SYS_sched_getattr: ::c_long = 315; ++pub const SYS_renameat2: ::c_long = 316; ++pub const SYS_seccomp: ::c_long = 317; ++pub const SYS_getrandom: ::c_long = 318; ++pub const SYS_memfd_create: ::c_long = 319; ++pub const SYS_kexec_file_load: ::c_long = 320; ++pub const SYS_bpf: ::c_long = 321; ++pub const SYS_execveat: ::c_long = 322; ++pub const SYS_userfaultfd: ::c_long = 323; ++pub const SYS_membarrier: ::c_long = 324; ++pub const SYS_mlock2: ::c_long = 325; ++pub const SYS_copy_file_range: ::c_long = 326; ++pub const SYS_preadv2: ::c_long = 327; ++pub const SYS_pwritev2: ::c_long = 328; ++pub const SYS_pkey_mprotect: ::c_long = 329; ++pub const SYS_pkey_alloc: ::c_long = 330; ++pub const SYS_pkey_free: ::c_long = 331; ++ ++// offsets in user_regs_structs, from sys/reg.h ++pub const R15: ::c_int = 0; ++pub const R14: ::c_int = 1; ++pub const R13: ::c_int = 2; ++pub const R12: ::c_int = 3; ++pub const RBP: ::c_int = 4; ++pub const RBX: ::c_int = 5; ++pub const R11: ::c_int = 6; ++pub const R10: ::c_int = 7; ++pub const R9: ::c_int = 8; ++pub const R8: ::c_int = 9; ++pub const RAX: ::c_int = 10; ++pub const RCX: ::c_int = 11; ++pub const RDX: ::c_int = 12; ++pub const RSI: ::c_int = 13; ++pub const RDI: ::c_int = 14; ++pub const ORIG_RAX: ::c_int = 15; ++pub const RIP: ::c_int = 16; ++pub const CS: ::c_int = 17; ++pub const EFLAGS: ::c_int = 18; ++pub const RSP: ::c_int = 19; ++pub const SS: ::c_int = 20; ++pub const FS_BASE: ::c_int = 21; ++pub const GS_BASE: ::c_int = 22; ++pub const DS: ::c_int = 23; ++pub const ES: ::c_int = 24; ++pub const FS: ::c_int = 25; ++pub const GS: ::c_int = 26; diff --cc vendor/libc-0.2.31/src/unix/notbsd/android/mod.rs index 000000000,000000000..a038d6678 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/android/mod.rs @@@ -1,0 -1,0 +1,1093 @@@ ++//! Android-specific definitions for linux-like values ++ ++use dox::{mem, Option}; ++ ++pub type clock_t = ::c_long; ++pub type time_t = ::c_long; ++pub type suseconds_t = ::c_long; ++pub type off_t = ::c_long; ++pub type blkcnt_t = ::c_ulong; ++pub type blksize_t = ::c_ulong; ++pub type nlink_t = u32; ++pub type useconds_t = u32; ++pub type pthread_t = ::c_long; ++pub type pthread_mutexattr_t = ::c_long; ++pub type pthread_rwlockattr_t = ::c_long; ++pub type pthread_condattr_t = ::c_long; ++pub type fsfilcnt_t = ::c_ulong; ++pub type fsblkcnt_t = ::c_ulong; ++pub type nfds_t = ::c_uint; ++pub type rlim_t = ::c_ulong; ++pub type dev_t = ::c_ulong; ++pub type ino_t = ::c_ulong; ++pub type __CPU_BITTYPE = ::c_ulong; ++pub type idtype_t = ::c_int; ++pub type loff_t = ::c_longlong; ++ ++s! { ++ pub struct 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 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 __fsid_t { ++ __val: [::c_int; 2], ++ } ++ ++ pub struct msghdr { ++ pub msg_name: *mut ::c_void, ++ pub msg_namelen: ::socklen_t, ++ pub msg_iov: *mut ::iovec, ++ pub msg_iovlen: ::size_t, ++ pub msg_control: *mut ::c_void, ++ pub msg_controllen: ::size_t, ++ pub msg_flags: ::c_int, ++ } ++ ++ pub struct cmsghdr { ++ pub cmsg_len: ::size_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct termios { ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_line: ::cc_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ } ++ ++ pub struct flock { ++ pub l_type: ::c_short, ++ pub l_whence: ::c_short, ++ pub l_start: ::off_t, ++ pub l_len: ::off_t, ++ pub l_pid: ::pid_t, ++ } ++ ++ pub struct cpu_set_t { ++ #[cfg(target_pointer_width = "64")] ++ __bits: [__CPU_BITTYPE; 16], ++ #[cfg(target_pointer_width = "32")] ++ __bits: [__CPU_BITTYPE; 1], ++ } ++ ++ pub struct sem_t { ++ count: ::c_uint, ++ #[cfg(target_pointer_width = "64")] ++ __reserved: [::c_int; 3], ++ } ++ ++ pub struct 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 struct statvfs { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_favail: ::fsfilcnt_t, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ #[cfg(target_pointer_width = "64")] ++ __f_reserved: [u32; 6], ++ } ++ ++ pub struct signalfd_siginfo { ++ pub ssi_signo: ::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: ::c_ulonglong, ++ pub ssi_utime: ::c_ulonglong, ++ pub ssi_stime: ::c_ulonglong, ++ pub ssi_addr: ::c_ulonglong, ++ pub ssi_addr_lsb: ::uint16_t, ++ _pad: [::uint8_t; 46], ++ } ++} ++ ++pub const O_TRUNC: ::c_int = 512; ++pub const O_CLOEXEC: ::c_int = 0x80000; ++pub const O_PATH: ::c_int = 0o10000000; ++pub const O_NOATIME: ::c_int = 0o1000000; ++ ++pub const EBFONT: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const EDOTDOT: ::c_int = 73; ++ ++pub const SA_NODEFER: ::c_int = 0x40000000; ++pub const SA_RESETHAND: ::c_int = 0x80000000; ++pub const SA_RESTART: ::c_int = 0x10000000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000001; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x80000; ++pub const EPOLLONESHOT: ::c_int = 0x40000000; ++pub const EPOLLRDHUP: ::c_int = 0x00002000; ++pub const EPOLLWAKEUP: ::c_int = 0x20000000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x80000; ++ ++pub const USER_PROCESS: ::c_short = 7; ++ ++pub const 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_2_SYMLINKS: ::c_int = 7; ++pub const _PC_ALLOC_SIZE_MIN: ::c_int = 8; ++pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 9; ++pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 10; ++pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 11; ++pub const _PC_REC_XFER_ALIGN: ::c_int = 12; ++pub const _PC_SYMLINK_MAX: ::c_int = 13; ++pub const _PC_CHOWN_RESTRICTED: ::c_int = 14; ++pub const _PC_NO_TRUNC: ::c_int = 15; ++pub const _PC_VDISABLE: ::c_int = 16; ++pub const _PC_ASYNC_IO: ::c_int = 17; ++pub const _PC_PRIO_IO: ::c_int = 18; ++pub const _PC_SYNC_IO: ::c_int = 19; ++ ++pub const FIONBIO: ::c_int = 0x5421; ++ ++pub const _SC_ARG_MAX: ::c_int = 0; ++pub const _SC_BC_BASE_MAX: ::c_int = 1; ++pub const _SC_BC_DIM_MAX: ::c_int = 2; ++pub const _SC_BC_SCALE_MAX: ::c_int = 3; ++pub const _SC_BC_STRING_MAX: ::c_int = 4; ++pub const _SC_CHILD_MAX: ::c_int = 5; ++pub const _SC_CLK_TCK: ::c_int = 6; ++pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 7; ++pub const _SC_EXPR_NEST_MAX: ::c_int = 8; ++pub const _SC_LINE_MAX: ::c_int = 9; ++pub const _SC_NGROUPS_MAX: ::c_int = 10; ++pub const _SC_OPEN_MAX: ::c_int = 11; ++pub const _SC_PASS_MAX: ::c_int = 12; ++pub const _SC_2_C_BIND: ::c_int = 13; ++pub const _SC_2_C_DEV: ::c_int = 14; ++pub const _SC_2_C_VERSION: ::c_int = 15; ++pub const _SC_2_CHAR_TERM: ::c_int = 16; ++pub const _SC_2_FORT_DEV: ::c_int = 17; ++pub const _SC_2_FORT_RUN: ::c_int = 18; ++pub const _SC_2_LOCALEDEF: ::c_int = 19; ++pub const _SC_2_SW_DEV: ::c_int = 20; ++pub const _SC_2_UPE: ::c_int = 21; ++pub const _SC_2_VERSION: ::c_int = 22; ++pub const _SC_JOB_CONTROL: ::c_int = 23; ++pub const _SC_SAVED_IDS: ::c_int = 24; ++pub const _SC_VERSION: ::c_int = 25; ++pub const _SC_RE_DUP_MAX: ::c_int = 26; ++pub const _SC_STREAM_MAX: ::c_int = 27; ++pub const _SC_TZNAME_MAX: ::c_int = 28; ++pub const _SC_XOPEN_CRYPT: ::c_int = 29; ++pub const _SC_XOPEN_ENH_I18N: ::c_int = 30; ++pub const _SC_XOPEN_SHM: ::c_int = 31; ++pub const _SC_XOPEN_VERSION: ::c_int = 32; ++pub const _SC_XOPEN_XCU_VERSION: ::c_int = 33; ++pub const _SC_XOPEN_REALTIME: ::c_int = 34; ++pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 35; ++pub const _SC_XOPEN_LEGACY: ::c_int = 36; ++pub const _SC_ATEXIT_MAX: ::c_int = 37; ++pub const _SC_IOV_MAX: ::c_int = 38; ++pub const _SC_PAGESIZE: ::c_int = 39; ++pub const _SC_PAGE_SIZE: ::c_int = 40; ++pub const _SC_XOPEN_UNIX: ::c_int = 41; ++pub const _SC_XBS5_ILP32_OFF32: ::c_int = 42; ++pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 43; ++pub const _SC_XBS5_LP64_OFF64: ::c_int = 44; ++pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 45; ++pub const _SC_AIO_LISTIO_MAX: ::c_int = 46; ++pub const _SC_AIO_MAX: ::c_int = 47; ++pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 48; ++pub const _SC_DELAYTIMER_MAX: ::c_int = 49; ++pub const _SC_MQ_OPEN_MAX: ::c_int = 50; ++pub const _SC_MQ_PRIO_MAX: ::c_int = 51; ++pub const _SC_RTSIG_MAX: ::c_int = 52; ++pub const _SC_SEM_NSEMS_MAX: ::c_int = 53; ++pub const _SC_SEM_VALUE_MAX: ::c_int = 54; ++pub const _SC_SIGQUEUE_MAX: ::c_int = 55; ++pub const _SC_TIMER_MAX: ::c_int = 56; ++pub const _SC_ASYNCHRONOUS_IO: ::c_int = 57; ++pub const _SC_FSYNC: ::c_int = 58; ++pub const _SC_MAPPED_FILES: ::c_int = 59; ++pub const _SC_MEMLOCK: ::c_int = 60; ++pub const _SC_MEMLOCK_RANGE: ::c_int = 61; ++pub const _SC_MEMORY_PROTECTION: ::c_int = 62; ++pub const _SC_MESSAGE_PASSING: ::c_int = 63; ++pub const _SC_PRIORITIZED_IO: ::c_int = 64; ++pub const _SC_PRIORITY_SCHEDULING: ::c_int = 65; ++pub const _SC_REALTIME_SIGNALS: ::c_int = 66; ++pub const _SC_SEMAPHORES: ::c_int = 67; ++pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 68; ++pub const _SC_SYNCHRONIZED_IO: ::c_int = 69; ++pub const _SC_TIMERS: ::c_int = 70; ++pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 71; ++pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 72; ++pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; ++pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 74; ++pub const _SC_THREAD_KEYS_MAX: ::c_int = 75; ++pub const _SC_THREAD_STACK_MIN: ::c_int = 76; ++pub const _SC_THREAD_THREADS_MAX: ::c_int = 77; ++pub const _SC_TTY_NAME_MAX: ::c_int = 78; ++pub const _SC_THREADS: ::c_int = 79; ++pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 80; ++pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 81; ++pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 82; ++pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 83; ++pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84; ++pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85; ++pub const _SC_NPROCESSORS_CONF: ::c_int = 96; ++pub const _SC_NPROCESSORS_ONLN: ::c_int = 97; ++pub const _SC_PHYS_PAGES: ::c_int = 98; ++pub const _SC_AVPHYS_PAGES: ::c_int = 99; ++pub const _SC_MONOTONIC_CLOCK: ::c_int = 100; ++ ++pub const 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 ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const EAFNOSUPPORT: ::c_int = 97; ++pub const EADDRINUSE: ::c_int = 98; ++pub const EADDRNOTAVAIL: ::c_int = 99; ++pub const ENETDOWN: ::c_int = 100; ++pub const ENETUNREACH: ::c_int = 101; ++pub const ENETRESET: ::c_int = 102; ++pub const ECONNABORTED: ::c_int = 103; ++pub const ECONNRESET: ::c_int = 104; ++pub const ENOBUFS: ::c_int = 105; ++pub const EISCONN: ::c_int = 106; ++pub const ENOTCONN: ::c_int = 107; ++pub const ESHUTDOWN: ::c_int = 108; ++pub const ETOOMANYREFS: ::c_int = 109; ++pub const ETIMEDOUT: ::c_int = 110; ++pub const ECONNREFUSED: ::c_int = 111; ++pub const EHOSTDOWN: ::c_int = 112; ++pub const EHOSTUNREACH: ::c_int = 113; ++pub const EALREADY: ::c_int = 114; ++pub const EINPROGRESS: ::c_int = 115; ++pub const ESTALE: ::c_int = 116; ++pub const EUCLEAN: ::c_int = 117; ++pub const ENOTNAM: ::c_int = 118; ++pub const ENAVAIL: ::c_int = 119; ++pub const EISNAM: ::c_int = 120; ++pub const EREMOTEIO: ::c_int = 121; ++pub const EDQUOT: ::c_int = 122; ++pub const ENOMEDIUM: ::c_int = 123; ++pub const EMEDIUMTYPE: ::c_int = 124; ++pub const ECANCELED: ::c_int = 125; ++pub const ENOKEY: ::c_int = 126; ++pub const EKEYEXPIRED: ::c_int = 127; ++pub const EKEYREVOKED: ::c_int = 128; ++pub const EKEYREJECTED: ::c_int = 129; ++pub const EOWNERDEAD: ::c_int = 130; ++pub const ENOTRECOVERABLE: ::c_int = 131; ++ ++pub const SOCK_STREAM: ::c_int = 1; ++pub const SOCK_DGRAM: ::c_int = 2; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++ ++pub const SOL_SOCKET: ::c_int = 1; ++pub const SOL_SCTP: ::c_int = 132; ++pub const SOL_IPX: ::c_int = 256; ++pub const SOL_AX25: ::c_int = 257; ++pub const SOL_ATALK: ::c_int = 258; ++pub const SOL_NETROM: ::c_int = 259; ++pub const SOL_ROSE: ::c_int = 260; ++ ++#[doc(hidden)] ++pub const AF_MAX: ::c_int = 43; ++#[doc(hidden)] ++pub const PF_MAX: ::c_int = AF_MAX; ++ ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_TYPE: ::c_int = 3; ++pub const SO_ERROR: ::c_int = 4; ++pub const SO_DONTROUTE: ::c_int = 5; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SO_SNDBUF: ::c_int = 7; ++pub const SO_RCVBUF: ::c_int = 8; ++pub const SO_KEEPALIVE: ::c_int = 9; ++pub const SO_OOBINLINE: ::c_int = 10; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_LINGER: ::c_int = 13; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_REUSEPORT: ::c_int = 15; ++pub const SO_PASSCRED: ::c_int = 16; ++pub const SO_PEERCRED: ::c_int = 17; ++pub const SO_RCVLOWAT: ::c_int = 18; ++pub const SO_SNDLOWAT: ::c_int = 19; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_SNDTIMEO: ::c_int = 21; ++pub const SO_BINDTODEVICE: ::c_int = 25; ++pub const SO_TIMESTAMP: ::c_int = 29; ++pub const SO_ACCEPTCONN: ::c_int = 30; ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_MARK: ::c_int = 36; ++pub const SO_PROTOCOL: ::c_int = 38; ++pub const SO_DOMAIN: ::c_int = 39; ++pub const SO_RXQ_OVFL: ::c_int = 40; ++pub const SO_PEEK_OFF: ::c_int = 42; ++pub const SO_BUSY_POLL: ::c_int = 46; ++ ++pub const O_ACCMODE: ::c_int = 3; ++pub const O_APPEND: ::c_int = 1024; ++pub const O_CREAT: ::c_int = 64; ++pub const O_EXCL: ::c_int = 128; ++pub const O_NOCTTY: ::c_int = 256; ++pub const O_NONBLOCK: ::c_int = 2048; ++pub const O_SYNC: ::c_int = 0x101000; ++pub const O_ASYNC: ::c_int = 0x2000; ++pub const O_NDELAY: ::c_int = 0x800; ++pub const O_DSYNC: ::c_int = 4096; ++ ++pub const NI_MAXHOST: ::size_t = 1025; ++ ++pub const NCCS: usize = 19; ++pub const TCSBRKP: ::c_int = 0x5425; ++pub const TCSANOW: ::c_int = 0; ++pub const TCSADRAIN: ::c_int = 0x1; ++pub const TCSAFLUSH: ::c_int = 0x2; ++pub const VEOF: usize = 4; ++pub const VEOL: usize = 11; ++pub const VEOL2: usize = 16; ++pub const VMIN: usize = 6; ++pub const IEXTEN: ::tcflag_t = 0x00008000; ++pub const TOSTOP: ::tcflag_t = 0x00000100; ++pub const FLUSHO: ::tcflag_t = 0x00001000; ++pub const EXTPROC: ::tcflag_t = 0o200000; ++ ++pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; ++pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; ++pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; ++pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; ++pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; ++pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; ++pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; ++pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; ++pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; ++pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; ++pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; ++pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; ++pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; ++pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; ++pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; ++pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; ++pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; ++pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; ++pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; ++pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; ++pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; ++pub const TMPFS_MAGIC: ::c_long = 0x01021994; ++pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; ++ ++pub const MAP_HUGETLB: ::c_int = 0x040000; ++ ++pub const PTRACE_TRACEME: ::c_int = 0; ++pub const PTRACE_PEEKTEXT: ::c_int = 1; ++pub const PTRACE_PEEKDATA: ::c_int = 2; ++pub const PTRACE_PEEKUSER: ::c_int = 3; ++pub const PTRACE_POKETEXT: ::c_int = 4; ++pub const PTRACE_POKEDATA: ::c_int = 5; ++pub const PTRACE_POKEUSER: ::c_int = 6; ++pub const PTRACE_CONT: ::c_int = 7; ++pub const PTRACE_KILL: ::c_int = 8; ++pub const PTRACE_SINGLESTEP: ::c_int = 9; ++pub const PTRACE_ATTACH: ::c_int = 16; ++pub const PTRACE_DETACH: ::c_int = 17; ++pub const PTRACE_SYSCALL: ::c_int = 24; ++pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; ++pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; ++pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; ++pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; ++ ++pub const EFD_NONBLOCK: ::c_int = 0x800; ++ ++pub const F_GETLK: ::c_int = 5; ++pub const F_GETOWN: ::c_int = 9; ++pub const F_SETOWN: ::c_int = 8; ++pub const F_SETLK: ::c_int = 6; ++pub const F_SETLKW: ::c_int = 7; ++ ++pub const 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_NOLOAD: ::c_int = 0x4; ++ ++pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; ++ ++pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; ++pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793; ++pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278; ++pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448; ++pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216; ++ ++pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567; ++pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123; ++pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF; ++pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000; ++pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC; ++pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4; ++pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2; ++pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const CBAUD: ::tcflag_t = 0o0010017; ++pub const TAB1: ::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 VSWTC: usize = 7; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const XTABS: ::tcflag_t = 0o014000; ++ ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const B57600: ::speed_t = 0o010001; ++pub const B115200: ::speed_t = 0o010002; ++pub const B230400: ::speed_t = 0o010003; ++pub const B460800: ::speed_t = 0o010004; ++pub const B500000: ::speed_t = 0o010005; ++pub const B576000: ::speed_t = 0o010006; ++pub const B921600: ::speed_t = 0o010007; ++pub const B1000000: ::speed_t = 0o010010; ++pub const B1152000: ::speed_t = 0o010011; ++pub const B1500000: ::speed_t = 0o010012; ++pub const B2000000: ::speed_t = 0o010013; ++pub const B2500000: ::speed_t = 0o010014; ++pub const B3000000: ::speed_t = 0o010015; ++pub const B3500000: ::speed_t = 0o010016; ++pub const B4000000: ::speed_t = 0o010017; ++ ++pub const 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); ++ ++pub const SIGEV_THREAD_ID: ::c_int = 4; ++ ++pub const CIBAUD: ::tcflag_t = 0o02003600000; ++pub const CBAUDEX: ::tcflag_t = 0o010000; ++ ++pub const TIOCM_LE: ::c_int = 0x001; ++pub const TIOCM_DTR: ::c_int = 0x002; ++pub const TIOCM_RTS: ::c_int = 0x004; ++pub const TIOCM_ST: ::c_int = 0x008; ++pub const TIOCM_SR: ::c_int = 0x010; ++pub const TIOCM_CTS: ::c_int = 0x020; ++pub const TIOCM_CAR: ::c_int = 0x040; ++pub const TIOCM_RNG: ::c_int = 0x080; ++pub const TIOCM_DSR: ::c_int = 0x100; ++pub const TIOCM_CD: ::c_int = TIOCM_CAR; ++pub const TIOCM_RI: ::c_int = TIOCM_RNG; ++ ++pub const POLLWRNORM: ::c_short = 0x100; ++pub const POLLWRBAND: ::c_short = 0x200; ++ ++pub const SFD_CLOEXEC: ::c_int = O_CLOEXEC; ++pub const SFD_NONBLOCK: ::c_int = O_NONBLOCK; ++ ++pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; ++ ++pub const SO_ORIGINAL_DST: ::c_int = 80; ++pub const IUTF8: ::tcflag_t = 0x00004000; ++pub const CMSPAR: ::tcflag_t = 0o10000000000; ++pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; ++ ++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]); ++ let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits); ++ cpuset.__bits[idx] |= 1 << offset; ++ () ++ } ++ ++ pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { ++ let size_in___bits = 8 * mem::size_of_val(&cpuset.__bits[0]); ++ let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits); ++ cpuset.__bits[idx] &= !(1 << offset); ++ () ++ } ++ ++ pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { ++ let size_in___bits = 8 * mem::size_of_val(&cpuset.__bits[0]); ++ let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits); ++ 0 != (cpuset.__bits[idx] & (1 << offset)) ++ } ++ ++ pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { ++ set1.__bits == set2.__bits ++ } ++ pub fn major(dev: ::dev_t) -> ::c_int { ++ ((dev >> 8) & 0xfff) as ::c_int ++ } ++ pub fn minor(dev: ::dev_t) -> ::c_int { ++ ((dev & 0xff) | ((dev >> 12) & 0xfff00)) as ::c_int ++ } ++ pub fn makedev(ma: ::c_int, mi: ::c_int) -> ::dev_t { ++ let ma = ma as ::dev_t; ++ let mi = mi as ::dev_t; ++ ((ma & 0xfff) << 8) | (mi & 0xff) | ((mi & 0xfff00) << 12) ++ } ++} ++ ++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 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 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; ++ ++ pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, ++ len: ::off_t) -> ::c_int; ++ pub fn signalfd(fd: ::c_int, mask: *const ::sigset_t, flags: ::c_int) ++ -> ::c_int; ++ pub fn syscall(num: ::c_long, ...) -> ::c_long; ++ pub fn sched_getaffinity(pid: ::pid_t, ++ cpusetsize: ::size_t, ++ cpuset: *mut cpu_set_t) -> ::c_int; ++ pub fn sched_setaffinity(pid: ::pid_t, ++ cpusetsize: ::size_t, ++ cpuset: *const cpu_set_t) -> ::c_int; ++ pub fn epoll_create(size: ::c_int) -> ::c_int; ++ pub fn epoll_create1(flags: ::c_int) -> ::c_int; ++ pub fn epoll_wait(epfd: ::c_int, ++ events: *mut ::epoll_event, ++ maxevents: ::c_int, ++ timeout: ::c_int) -> ::c_int; ++ pub fn epoll_ctl(epfd: ::c_int, ++ op: ::c_int, ++ fd: ::c_int, ++ event: *mut ::epoll_event) -> ::c_int; ++ pub fn pthread_getschedparam(native: ::pthread_t, ++ policy: *mut ::c_int, ++ param: *mut ::sched_param) -> ::c_int; ++ pub fn unshare(flags: ::c_int) -> ::c_int; ++ pub fn umount(target: *const ::c_char) -> ::c_int; ++ pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; ++ pub fn tee(fd_in: ::c_int, ++ fd_out: ::c_int, ++ len: ::size_t, ++ flags: ::c_uint) -> ::ssize_t; ++ pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; ++ pub fn splice(fd_in: ::c_int, ++ off_in: *mut ::loff_t, ++ fd_out: ::c_int, ++ off_out: *mut ::loff_t, ++ len: ::size_t, ++ flags: ::c_uint) -> ::ssize_t; ++ pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; ++ pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int; ++ pub fn sem_timedwait(sem: *mut sem_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int; ++ pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; ++ pub fn swapoff(puath: *const ::c_char) -> ::c_int; ++ pub fn vmsplice(fd: ::c_int, ++ iov: *const ::iovec, ++ nr_segs: ::size_t, ++ flags: ::c_uint) -> ::ssize_t; ++ pub fn mount(src: *const ::c_char, ++ target: *const ::c_char, ++ fstype: *const ::c_char, ++ flags: ::c_ulong, ++ data: *const ::c_void) -> ::c_int; ++ pub fn personality(persona: ::c_ulong) -> ::c_int; ++ pub fn prctl(option: ::c_int, ...) -> ::c_int; ++ pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int; ++ pub fn ppoll(fds: *mut ::pollfd, ++ nfds: nfds_t, ++ timeout: *const ::timespec, ++ sigmask: *const sigset_t) -> ::c_int; ++ pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int, ++ child_stack: *mut ::c_void, ++ flags: ::c_int, ++ arg: *mut ::c_void, ...) -> ::c_int; ++ pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; ++ pub fn clock_nanosleep(clk_id: ::clockid_t, ++ flags: ::c_int, ++ rqtp: *const ::timespec, ++ rmtp: *mut ::timespec) -> ::c_int; ++ pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, ++ guardsize: *mut ::size_t) -> ::c_int; ++ pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; ++ pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; ++ pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, ++ pshared: *mut ::c_int) -> ::c_int; ++ pub fn sysinfo(info: *mut ::sysinfo) -> ::c_int; ++ pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; ++ pub fn pthread_setschedparam(native: ::pthread_t, ++ policy: ::c_int, ++ param: *const ::sched_param) -> ::c_int; ++ pub fn swapon(path: *const ::c_char, swapflags: ::c_int) -> ::c_int; ++ pub fn sched_setscheduler(pid: ::pid_t, ++ policy: ::c_int, ++ param: *const ::sched_param) -> ::c_int; ++ pub fn sendfile(out_fd: ::c_int, ++ in_fd: ::c_int, ++ offset: *mut off_t, ++ count: ::size_t) -> ::ssize_t; ++ pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] ++ pub fn getgrgid_r(uid: ::uid_t, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "sigaltstack$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] ++ pub fn sigaltstack(ss: *const stack_t, ++ oss: *mut stack_t) -> ::c_int; ++ pub fn sem_close(sem: *mut sem_t) -> ::c_int; ++ pub fn getdtablesize() -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] ++ pub fn getgrnam_r(name: *const ::c_char, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_sigmask$UNIX2003")] ++ pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, ++ oldset: *mut sigset_t) -> ::c_int; ++ pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; ++ pub fn getgrnam(name: *const ::c_char) -> *mut ::group; ++ pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; ++ pub fn sem_unlink(name: *const ::c_char) -> ::c_int; ++ pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] ++ pub fn getpwnam_r(name: *const ::c_char, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] ++ pub fn getpwuid_r(uid: ::uid_t, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch ="x86"), ++ link_name = "sigwait$UNIX2003")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] ++ pub fn sigwait(set: *const sigset_t, ++ sig: *mut ::c_int) -> ::c_int; ++ pub fn pthread_atfork(prepare: Option, ++ parent: Option, ++ child: Option) -> ::c_int; ++ pub fn getgrgid(gid: ::gid_t) -> *mut ::group; ++ pub fn getgrouplist(user: *const ::c_char, ++ group: ::gid_t, ++ groups: *mut ::gid_t, ++ ngroups: *mut ::c_int) -> ::c_int; ++ pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; ++ pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, ++ pshared: *mut ::c_int) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "popen$UNIX2003")] ++ pub fn popen(command: *const c_char, ++ mode: *const c_char) -> *mut ::FILE; ++ pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::c_int, flags: ::c_int) -> ::c_int; ++ pub fn pthread_create(native: *mut ::pthread_t, ++ attr: *const ::pthread_attr_t, ++ f: extern fn(*mut ::c_void) -> *mut ::c_void, ++ value: *mut ::c_void) -> ::c_int; ++} ++ ++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 --cc vendor/libc-0.2.31/src/unix/notbsd/emscripten.rs index 000000000,000000000..90c056caf new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/emscripten.rs @@@ -1,0 -1,0 +1,1667 @@@ ++use dox::{mem, Option}; ++ ++pub type c_char = i8; ++pub type wchar_t = i32; ++pub type useconds_t = u32; ++pub type dev_t = u32; ++pub type socklen_t = u32; ++pub type pthread_t = c_ulong; ++pub type mode_t = u32; ++pub type ino64_t = u32; ++pub type off64_t = i32; ++pub type blkcnt64_t = i32; ++pub type rlim64_t = u64; ++pub type shmatt_t = ::c_ulong; ++pub type mqd_t = ::c_int; ++pub type msgqnum_t = ::c_ulong; ++pub type msglen_t = ::c_ulong; ++pub type nfds_t = ::c_ulong; ++pub type nl_item = ::c_int; ++pub type idtype_t = ::c_uint; ++pub type loff_t = i32; ++ ++pub type clock_t = c_long; ++pub type time_t = c_long; ++pub type suseconds_t = c_long; ++pub type ino_t = u32; ++pub type off_t = i32; ++pub type blkcnt_t = i32; ++ ++pub type blksize_t = c_long; ++pub type fsblkcnt_t = u32; ++pub type fsfilcnt_t = u32; ++pub type rlim_t = ::c_ulonglong; ++pub type c_long = i32; ++pub type c_ulong = u32; ++pub type nlink_t = u32; ++ ++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 { ++ __align: [::c_long; 0], ++ size: [u8; __SIZEOF_PTHREAD_MUTEX_T], ++ } ++ ++ pub struct pthread_rwlock_t { ++ __align: [::c_long; 0], ++ size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], ++ } ++ ++ pub struct pthread_mutexattr_t { ++ __align: [::c_int; 0], ++ size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], ++ } ++ ++ pub struct pthread_rwlockattr_t { ++ __align: [::c_int; 0], ++ size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], ++ } ++ ++ pub struct pthread_cond_t { ++ __align: [*const ::c_void; 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, ++ pub f_fsid: ::c_ulong, ++ __f_unused: ::c_int, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct dqblk { ++ pub dqb_bhardlimit: ::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 { ++ bits: [u32; 32], ++ } ++ ++ pub struct if_nameindex { ++ pub if_index: ::c_uint, ++ pub if_name: *mut ::c_char, ++ } ++ ++ // System V IPC ++ pub struct msginfo { ++ pub msgpool: ::c_int, ++ pub msgmap: ::c_int, ++ pub msgmax: ::c_int, ++ pub msgmnb: ::c_int, ++ pub msgmni: ::c_int, ++ pub msgssz: ::c_int, ++ pub msgtql: ::c_int, ++ pub msgseg: ::c_ushort, ++ } ++ ++ pub struct mmsghdr { ++ pub msg_hdr: ::msghdr, ++ pub msg_len: ::c_uint, ++ } ++ ++ pub struct sembuf { ++ pub sem_num: ::c_ushort, ++ pub sem_op: ::c_short, ++ pub sem_flg: ::c_short, ++ } ++ ++ pub struct aiocb { ++ pub aio_fildes: ::c_int, ++ pub aio_lio_opcode: ::c_int, ++ pub aio_reqprio: ::c_int, ++ pub aio_buf: *mut ::c_void, ++ pub aio_nbytes: ::size_t, ++ pub aio_sigevent: ::sigevent, ++ __td: *mut ::c_void, ++ __lock: [::c_int; 2], ++ __err: ::c_int, ++ __ret: ::ssize_t, ++ pub aio_offset: off_t, ++ __next: *mut ::c_void, ++ __prev: *mut ::c_void, ++ __dummy4: [::c_char; 24], ++ } ++ ++ pub struct sigaction { ++ pub sa_sigaction: ::sighandler_t, ++ pub sa_mask: ::sigset_t, ++ pub sa_flags: ::c_int, ++ pub sa_restorer: ::dox::Option, ++ } ++ ++ 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 struct pthread_attr_t { ++ __size: [u32; 11] ++ } ++ ++ pub struct sigset_t { ++ __val: [::c_ulong; 32], ++ } ++ ++ pub struct msghdr { ++ pub msg_name: *mut ::c_void, ++ pub msg_namelen: ::socklen_t, ++ pub msg_iov: *mut ::iovec, ++ pub msg_iovlen: ::c_int, ++ pub msg_control: *mut ::c_void, ++ pub msg_controllen: ::socklen_t, ++ pub msg_flags: ::c_int, ++ } ++ ++ pub struct cmsghdr { ++ pub cmsg_len: ::socklen_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct sem_t { ++ __val: [::c_int; 4], ++ } ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ __st_dev_padding: ::c_int, ++ __st_ino_truncated: ::c_long, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ __st_rdev_padding: ::c_int, ++ pub st_size: ::off_t, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_ino: ::ino_t, ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::dev_t, ++ __st_dev_padding: ::c_int, ++ __st_ino_truncated: ::c_long, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ __st_rdev_padding: ::c_int, ++ pub st_size: ::off_t, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_ino: ::ino_t, ++ } ++ ++ pub struct stack_t { ++ pub ss_sp: *mut ::c_void, ++ pub ss_flags: ::c_int, ++ pub ss_size: ::size_t ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, ++ pub shm_atime: ::time_t, ++ __unused1: ::c_int, ++ pub shm_dtime: ::time_t, ++ __unused2: ::c_int, ++ pub shm_ctime: ::time_t, ++ __unused3: ::c_int, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::c_ulong, ++ __pad1: ::c_ulong, ++ __pad2: ::c_ulong, ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ pub msg_stime: ::time_t, ++ __unused1: ::c_int, ++ pub msg_rtime: ::time_t, ++ __unused2: ::c_int, ++ pub msg_ctime: ::time_t, ++ __unused3: ::c_int, ++ __msg_cbytes: ::c_ulong, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ __pad1: ::c_ulong, ++ __pad2: ::c_ulong, ++ } ++ ++ pub struct statfs { ++ pub f_type: ::c_ulong, ++ pub f_bsize: ::c_ulong, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_flags: ::c_ulong, ++ pub f_spare: [::c_ulong; 4], ++ } ++ ++ pub struct siginfo_t { ++ pub si_signo: ::c_int, ++ pub si_errno: ::c_int, ++ pub si_code: ::c_int, ++ pub _pad: [::c_int; 29], ++ _align: [usize; 0], ++ } ++ ++ pub struct statfs64 { ++ pub f_type: ::c_ulong, ++ pub f_bsize: ::c_ulong, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_flags: ::c_ulong, ++ pub f_spare: [::c_ulong; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u32, ++ pub f_bfree: u32, ++ pub f_bavail: u32, ++ pub f_files: u32, ++ pub f_ffree: u32, ++ pub f_favail: u32, ++ pub f_fsid: ::c_ulong, ++ __f_unused: ::c_int, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++} ++ ++pub const ABDAY_1: ::nl_item = 0x20000; ++pub const ABDAY_2: ::nl_item = 0x20001; ++pub const ABDAY_3: ::nl_item = 0x20002; ++pub const ABDAY_4: ::nl_item = 0x20003; ++pub const ABDAY_5: ::nl_item = 0x20004; ++pub const ABDAY_6: ::nl_item = 0x20005; ++pub const ABDAY_7: ::nl_item = 0x20006; ++ ++pub const DAY_1: ::nl_item = 0x20007; ++pub const DAY_2: ::nl_item = 0x20008; ++pub const DAY_3: ::nl_item = 0x20009; ++pub const DAY_4: ::nl_item = 0x2000A; ++pub const DAY_5: ::nl_item = 0x2000B; ++pub const DAY_6: ::nl_item = 0x2000C; ++pub const DAY_7: ::nl_item = 0x2000D; ++ ++pub const ABMON_1: ::nl_item = 0x2000E; ++pub const ABMON_2: ::nl_item = 0x2000F; ++pub const ABMON_3: ::nl_item = 0x20010; ++pub const ABMON_4: ::nl_item = 0x20011; ++pub const ABMON_5: ::nl_item = 0x20012; ++pub const ABMON_6: ::nl_item = 0x20013; ++pub const ABMON_7: ::nl_item = 0x20014; ++pub const ABMON_8: ::nl_item = 0x20015; ++pub const ABMON_9: ::nl_item = 0x20016; ++pub const ABMON_10: ::nl_item = 0x20017; ++pub const ABMON_11: ::nl_item = 0x20018; ++pub const ABMON_12: ::nl_item = 0x20019; ++ ++pub const MON_1: ::nl_item = 0x2001A; ++pub const MON_2: ::nl_item = 0x2001B; ++pub const MON_3: ::nl_item = 0x2001C; ++pub const MON_4: ::nl_item = 0x2001D; ++pub const MON_5: ::nl_item = 0x2001E; ++pub const MON_6: ::nl_item = 0x2001F; ++pub const MON_7: ::nl_item = 0x20020; ++pub const MON_8: ::nl_item = 0x20021; ++pub const MON_9: ::nl_item = 0x20022; ++pub const MON_10: ::nl_item = 0x20023; ++pub const MON_11: ::nl_item = 0x20024; ++pub const MON_12: ::nl_item = 0x20025; ++ ++pub const AM_STR: ::nl_item = 0x20026; ++pub const PM_STR: ::nl_item = 0x20027; ++ ++pub const D_T_FMT: ::nl_item = 0x20028; ++pub const D_FMT: ::nl_item = 0x20029; ++pub const T_FMT: ::nl_item = 0x2002A; ++pub const T_FMT_AMPM: ::nl_item = 0x2002B; ++ ++pub const ERA: ::nl_item = 0x2002C; ++pub const ERA_D_FMT: ::nl_item = 0x2002E; ++pub const ALT_DIGITS: ::nl_item = 0x2002F; ++pub const ERA_D_T_FMT: ::nl_item = 0x20030; ++pub const ERA_T_FMT: ::nl_item = 0x20031; ++ ++pub const CODESET: ::nl_item = 14; ++ ++pub const CRNCYSTR: ::nl_item = 0x4000F; ++ ++pub const RUSAGE_THREAD: ::c_int = 1; ++pub const RUSAGE_CHILDREN: ::c_int = -1; ++ ++pub const RADIXCHAR: ::nl_item = 0x10000; ++pub const THOUSEP: ::nl_item = 0x10001; ++ ++pub const YESEXPR: ::nl_item = 0x50000; ++pub const NOEXPR: ::nl_item = 0x50001; ++pub const YESSTR: ::nl_item = 0x50002; ++pub const NOSTR: ::nl_item = 0x50003; ++ ++pub const FILENAME_MAX: ::c_uint = 4096; ++pub const L_tmpnam: ::c_uint = 20; ++pub const _PC_LINK_MAX: ::c_int = 0; ++pub const _PC_MAX_CANON: ::c_int = 1; ++pub const _PC_MAX_INPUT: ::c_int = 2; ++pub const _PC_NAME_MAX: ::c_int = 3; ++pub const _PC_PATH_MAX: ::c_int = 4; ++pub const _PC_PIPE_BUF: ::c_int = 5; ++pub const _PC_CHOWN_RESTRICTED: ::c_int = 6; ++pub const _PC_NO_TRUNC: ::c_int = 7; ++pub const _PC_VDISABLE: ::c_int = 8; ++pub const _PC_SYNC_IO: ::c_int = 9; ++pub const _PC_ASYNC_IO: ::c_int = 10; ++pub const _PC_PRIO_IO: ::c_int = 11; ++pub const _PC_SOCK_MAXBUF: ::c_int = 12; ++pub const _PC_FILESIZEBITS: ::c_int = 13; ++pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14; ++pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15; ++pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16; ++pub const _PC_REC_XFER_ALIGN: ::c_int = 17; ++pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18; ++pub const _PC_SYMLINK_MAX: ::c_int = 19; ++pub const _PC_2_SYMLINKS: ::c_int = 20; ++ ++pub const _SC_ARG_MAX: ::c_int = 0; ++pub const _SC_CHILD_MAX: ::c_int = 1; ++pub const _SC_CLK_TCK: ::c_int = 2; ++pub const _SC_NGROUPS_MAX: ::c_int = 3; ++pub const _SC_OPEN_MAX: ::c_int = 4; ++pub const _SC_STREAM_MAX: ::c_int = 5; ++pub const _SC_TZNAME_MAX: ::c_int = 6; ++pub const _SC_JOB_CONTROL: ::c_int = 7; ++pub const _SC_SAVED_IDS: ::c_int = 8; ++pub const _SC_REALTIME_SIGNALS: ::c_int = 9; ++pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; ++pub const _SC_TIMERS: ::c_int = 11; ++pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; ++pub const _SC_PRIORITIZED_IO: ::c_int = 13; ++pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; ++pub const _SC_FSYNC: ::c_int = 15; ++pub const _SC_MAPPED_FILES: ::c_int = 16; ++pub const _SC_MEMLOCK: ::c_int = 17; ++pub const _SC_MEMLOCK_RANGE: ::c_int = 18; ++pub const _SC_MEMORY_PROTECTION: ::c_int = 19; ++pub const _SC_MESSAGE_PASSING: ::c_int = 20; ++pub const _SC_SEMAPHORES: ::c_int = 21; ++pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; ++pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; ++pub const _SC_AIO_MAX: ::c_int = 24; ++pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; ++pub const _SC_DELAYTIMER_MAX: ::c_int = 26; ++pub const _SC_MQ_OPEN_MAX: ::c_int = 27; ++pub const _SC_MQ_PRIO_MAX: ::c_int = 28; ++pub const _SC_VERSION: ::c_int = 29; ++pub const _SC_PAGESIZE: ::c_int = 30; ++pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; ++pub const _SC_RTSIG_MAX: ::c_int = 31; ++pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; ++pub const _SC_SEM_VALUE_MAX: ::c_int = 33; ++pub const _SC_SIGQUEUE_MAX: ::c_int = 34; ++pub const _SC_TIMER_MAX: ::c_int = 35; ++pub const _SC_BC_BASE_MAX: ::c_int = 36; ++pub const _SC_BC_DIM_MAX: ::c_int = 37; ++pub const _SC_BC_SCALE_MAX: ::c_int = 38; ++pub const _SC_BC_STRING_MAX: ::c_int = 39; ++pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; ++pub const _SC_EXPR_NEST_MAX: ::c_int = 42; ++pub const _SC_LINE_MAX: ::c_int = 43; ++pub const _SC_RE_DUP_MAX: ::c_int = 44; ++pub const _SC_2_VERSION: ::c_int = 46; ++pub const _SC_2_C_BIND: ::c_int = 47; ++pub const _SC_2_C_DEV: ::c_int = 48; ++pub const _SC_2_FORT_DEV: ::c_int = 49; ++pub const _SC_2_FORT_RUN: ::c_int = 50; ++pub const _SC_2_SW_DEV: ::c_int = 51; ++pub const _SC_2_LOCALEDEF: ::c_int = 52; ++pub const _SC_UIO_MAXIOV: ::c_int = 60; ++pub const _SC_IOV_MAX: ::c_int = 60; ++pub const _SC_THREADS: ::c_int = 67; ++pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; ++pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; ++pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; ++pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; ++pub const _SC_TTY_NAME_MAX: ::c_int = 72; ++pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; ++pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; ++pub const _SC_THREAD_STACK_MIN: ::c_int = 75; ++pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; ++pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; ++pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; ++pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; ++pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; ++pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; ++pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82; ++pub const _SC_NPROCESSORS_CONF: ::c_int = 83; ++pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; ++pub const _SC_PHYS_PAGES: ::c_int = 85; ++pub const _SC_AVPHYS_PAGES: ::c_int = 86; ++pub const _SC_ATEXIT_MAX: ::c_int = 87; ++pub const _SC_PASS_MAX: ::c_int = 88; ++pub const _SC_XOPEN_VERSION: ::c_int = 89; ++pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; ++pub const _SC_XOPEN_UNIX: ::c_int = 91; ++pub const _SC_XOPEN_CRYPT: ::c_int = 92; ++pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; ++pub const _SC_XOPEN_SHM: ::c_int = 94; ++pub const _SC_2_CHAR_TERM: ::c_int = 95; ++pub const _SC_2_UPE: ::c_int = 97; ++pub const _SC_XOPEN_XPG2: ::c_int = 98; ++pub const _SC_XOPEN_XPG3: ::c_int = 99; ++pub const _SC_XOPEN_XPG4: ::c_int = 100; ++pub const _SC_NZERO: ::c_int = 109; ++pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; ++pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; ++pub const _SC_XBS5_LP64_OFF64: ::c_int = 127; ++pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; ++pub const _SC_XOPEN_LEGACY: ::c_int = 129; ++pub const _SC_XOPEN_REALTIME: ::c_int = 130; ++pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; ++pub const _SC_ADVISORY_INFO: ::c_int = 132; ++pub const _SC_BARRIERS: ::c_int = 133; ++pub const _SC_CLOCK_SELECTION: ::c_int = 137; ++pub const _SC_CPUTIME: ::c_int = 138; ++pub const _SC_THREAD_CPUTIME: ::c_int = 139; ++pub const _SC_MONOTONIC_CLOCK: ::c_int = 149; ++pub const _SC_READER_WRITER_LOCKS: ::c_int = 153; ++pub const _SC_SPIN_LOCKS: ::c_int = 154; ++pub const _SC_REGEXP: ::c_int = 155; ++pub const _SC_SHELL: ::c_int = 157; ++pub const _SC_SPAWN: ::c_int = 159; ++pub const _SC_SPORADIC_SERVER: ::c_int = 160; ++pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161; ++pub const _SC_TIMEOUTS: ::c_int = 164; ++pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165; ++pub const _SC_2_PBS: ::c_int = 168; ++pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169; ++pub const _SC_2_PBS_LOCATE: ::c_int = 170; ++pub const _SC_2_PBS_MESSAGE: ::c_int = 171; ++pub const _SC_2_PBS_TRACK: ::c_int = 172; ++pub const _SC_SYMLOOP_MAX: ::c_int = 173; ++pub const _SC_STREAMS: ::c_int = 174; ++pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175; ++pub const _SC_V6_ILP32_OFF32: ::c_int = 176; ++pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177; ++pub const _SC_V6_LP64_OFF64: ::c_int = 178; ++pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179; ++pub const _SC_HOST_NAME_MAX: ::c_int = 180; ++pub const _SC_TRACE: ::c_int = 181; ++pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182; ++pub const _SC_TRACE_INHERIT: ::c_int = 183; ++pub const _SC_TRACE_LOG: ::c_int = 184; ++pub const _SC_IPV6: ::c_int = 235; ++pub const _SC_RAW_SOCKETS: ::c_int = 236; ++pub const _SC_V7_ILP32_OFF32: ::c_int = 237; ++pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238; ++pub const _SC_V7_LP64_OFF64: ::c_int = 239; ++pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240; ++pub const _SC_SS_REPL_MAX: ::c_int = 241; ++pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242; ++pub const _SC_TRACE_NAME_MAX: ::c_int = 243; ++pub const _SC_TRACE_SYS_MAX: ::c_int = 244; ++pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245; ++pub const _SC_XOPEN_STREAMS: ::c_int = 246; ++pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247; ++pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248; ++ ++pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; ++pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; ++ ++pub const GLOB_ERR: ::c_int = 1 << 0; ++pub const GLOB_MARK: ::c_int = 1 << 1; ++pub const GLOB_NOSORT: ::c_int = 1 << 2; ++pub const GLOB_DOOFFS: ::c_int = 1 << 3; ++pub const GLOB_NOCHECK: ::c_int = 1 << 4; ++pub const GLOB_APPEND: ::c_int = 1 << 5; ++pub const GLOB_NOESCAPE: ::c_int = 1 << 6; ++ ++pub const GLOB_NOSPACE: ::c_int = 1; ++pub const GLOB_ABORTED: ::c_int = 2; ++pub const GLOB_NOMATCH: ::c_int = 3; ++ ++pub const POSIX_MADV_NORMAL: ::c_int = 0; ++pub const POSIX_MADV_RANDOM: ::c_int = 1; ++pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; ++pub const POSIX_MADV_WILLNEED: ::c_int = 3; ++ ++pub const S_IEXEC: mode_t = 64; ++pub const S_IWRITE: mode_t = 128; ++pub const S_IREAD: mode_t = 256; ++ ++pub const F_LOCK: ::c_int = 1; ++pub const F_TEST: ::c_int = 3; ++pub const F_TLOCK: ::c_int = 2; ++pub const F_ULOCK: ::c_int = 0; ++ ++pub const ST_RDONLY: ::c_ulong = 1; ++pub const ST_NOSUID: ::c_ulong = 2; ++pub const ST_NODEV: ::c_ulong = 4; ++pub const ST_NOEXEC: ::c_ulong = 8; ++pub const ST_SYNCHRONOUS: ::c_ulong = 16; ++pub const ST_MANDLOCK: ::c_ulong = 64; ++pub const ST_WRITE: ::c_ulong = 128; ++pub const ST_APPEND: ::c_ulong = 256; ++pub const ST_IMMUTABLE: ::c_ulong = 512; ++pub const ST_NOATIME: ::c_ulong = 1024; ++pub const ST_NODIRATIME: ::c_ulong = 2048; ++ ++pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void; ++pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; ++pub const RTLD_NODELETE: ::c_int = 0x1000; ++pub const RTLD_NOW: ::c_int = 0x2; ++ ++pub const TCP_MD5SIG: ::c_int = 14; ++ ++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 PTHREAD_PROCESS_PRIVATE: ::c_int = 0; ++pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; ++pub const __SIZEOF_PTHREAD_COND_T: usize = 48; ++ ++pub const SCHED_OTHER: ::c_int = 0; ++pub const SCHED_FIFO: ::c_int = 1; ++pub const SCHED_RR: ::c_int = 2; ++pub const SCHED_BATCH: ::c_int = 3; ++pub const SCHED_IDLE: ::c_int = 5; ++ ++pub const AF_IB: ::c_int = 27; ++pub const AF_MPLS: ::c_int = 28; ++pub const AF_NFC: ::c_int = 39; ++pub const AF_VSOCK: ::c_int = 40; ++#[doc(hidden)] ++pub const AF_MAX: ::c_int = 42; ++pub const PF_IB: ::c_int = AF_IB; ++pub const PF_MPLS: ::c_int = AF_MPLS; ++pub const PF_NFC: ::c_int = AF_NFC; ++pub const PF_VSOCK: ::c_int = AF_VSOCK; ++#[doc(hidden)] ++pub const PF_MAX: ::c_int = AF_MAX; ++ ++// System V IPC ++pub const IPC_PRIVATE: ::key_t = 0; ++ ++pub const IPC_CREAT: ::c_int = 0o1000; ++pub const IPC_EXCL: ::c_int = 0o2000; ++pub const IPC_NOWAIT: ::c_int = 0o4000; ++ ++pub const IPC_RMID: ::c_int = 0; ++pub const IPC_SET: ::c_int = 1; ++pub const IPC_STAT: ::c_int = 2; ++pub const IPC_INFO: ::c_int = 3; ++pub const MSG_STAT: ::c_int = 11; ++pub const MSG_INFO: ::c_int = 12; ++ ++pub const MSG_NOERROR: ::c_int = 0o10000; ++pub const MSG_EXCEPT: ::c_int = 0o20000; ++pub const MSG_COPY: ::c_int = 0o40000; ++ ++pub const SHM_R: ::c_int = 0o400; ++pub const SHM_W: ::c_int = 0o200; ++ ++pub const SHM_RDONLY: ::c_int = 0o10000; ++pub const SHM_RND: ::c_int = 0o20000; ++pub const SHM_REMAP: ::c_int = 0o40000; ++pub const SHM_EXEC: ::c_int = 0o100000; ++ ++pub const SHM_LOCK: ::c_int = 11; ++pub const SHM_UNLOCK: ::c_int = 12; ++ ++pub const SHM_HUGETLB: ::c_int = 0o4000; ++pub const SHM_NORESERVE: ::c_int = 0o10000; ++ ++pub const EPOLLRDHUP: ::c_int = 0x2000; ++pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; ++pub const EPOLLONESHOT: ::c_int = 0x40000000; ++ ++pub const QFMT_VFS_OLD: ::c_int = 1; ++pub const QFMT_VFS_V0: ::c_int = 2; ++ ++pub const EFD_SEMAPHORE: ::c_int = 0x1; ++ ++pub const LOG_NFACILITIES: ::c_int = 24; ++ ++pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t; ++ ++pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32; ++pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32; ++pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32; ++pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32; ++pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32; ++pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32; ++pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32; ++ ++pub const AI_PASSIVE: ::c_int = 0x0001; ++pub const AI_CANONNAME: ::c_int = 0x0002; ++pub const AI_NUMERICHOST: ::c_int = 0x0004; ++pub const AI_V4MAPPED: ::c_int = 0x0008; ++pub const AI_ALL: ::c_int = 0x0010; ++pub const AI_ADDRCONFIG: ::c_int = 0x0020; ++ ++pub const AI_NUMERICSERV: ::c_int = 0x0400; ++ ++pub const EAI_BADFLAGS: ::c_int = -1; ++pub const EAI_NONAME: ::c_int = -2; ++pub const EAI_AGAIN: ::c_int = -3; ++pub const EAI_FAIL: ::c_int = -4; ++pub const EAI_FAMILY: ::c_int = -6; ++pub const EAI_SOCKTYPE: ::c_int = -7; ++pub const EAI_SERVICE: ::c_int = -8; ++pub const EAI_MEMORY: ::c_int = -10; ++pub const EAI_OVERFLOW: ::c_int = -12; ++ ++pub const NI_NUMERICHOST: ::c_int = 1; ++pub const NI_NUMERICSERV: ::c_int = 2; ++pub const NI_NOFQDN: ::c_int = 4; ++pub const NI_NAMEREQD: ::c_int = 8; ++pub const NI_DGRAM: ::c_int = 16; ++ ++pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1; ++pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2; ++pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4; ++ ++pub const EAI_SYSTEM: ::c_int = -11; ++ ++pub const AIO_CANCELED: ::c_int = 0; ++pub const AIO_NOTCANCELED: ::c_int = 1; ++pub const AIO_ALLDONE: ::c_int = 2; ++pub const LIO_READ: ::c_int = 0; ++pub const LIO_WRITE: ::c_int = 1; ++pub const LIO_NOP: ::c_int = 2; ++pub const LIO_WAIT: ::c_int = 0; ++pub const LIO_NOWAIT: ::c_int = 1; ++ ++pub const MREMAP_MAYMOVE: ::c_int = 1; ++pub const MREMAP_FIXED: ::c_int = 2; ++ ++pub const PR_SET_PDEATHSIG: ::c_int = 1; ++pub const PR_GET_PDEATHSIG: ::c_int = 2; ++ ++pub const PR_GET_DUMPABLE: ::c_int = 3; ++pub const PR_SET_DUMPABLE: ::c_int = 4; ++ ++pub const PR_GET_UNALIGN: ::c_int = 5; ++pub const PR_SET_UNALIGN: ::c_int = 6; ++pub const PR_UNALIGN_NOPRINT: ::c_int = 1; ++pub const PR_UNALIGN_SIGBUS: ::c_int = 2; ++ ++pub const PR_GET_KEEPCAPS: ::c_int = 7; ++pub const PR_SET_KEEPCAPS: ::c_int = 8; ++ ++pub const PR_GET_FPEMU: ::c_int = 9; ++pub const PR_SET_FPEMU: ::c_int = 10; ++pub const PR_FPEMU_NOPRINT: ::c_int = 1; ++pub const PR_FPEMU_SIGFPE: ::c_int = 2; ++ ++pub const PR_GET_FPEXC: ::c_int = 11; ++pub const PR_SET_FPEXC: ::c_int = 12; ++pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80; ++pub const PR_FP_EXC_DIV: ::c_int = 0x010000; ++pub const PR_FP_EXC_OVF: ::c_int = 0x020000; ++pub const PR_FP_EXC_UND: ::c_int = 0x040000; ++pub const PR_FP_EXC_RES: ::c_int = 0x080000; ++pub const PR_FP_EXC_INV: ::c_int = 0x100000; ++pub const PR_FP_EXC_DISABLED: ::c_int = 0; ++pub const PR_FP_EXC_NONRECOV: ::c_int = 1; ++pub const PR_FP_EXC_ASYNC: ::c_int = 2; ++pub const PR_FP_EXC_PRECISE: ::c_int = 3; ++ ++pub const PR_GET_TIMING: ::c_int = 13; ++pub const PR_SET_TIMING: ::c_int = 14; ++pub const PR_TIMING_STATISTICAL: ::c_int = 0; ++pub const PR_TIMING_TIMESTAMP: ::c_int = 1; ++ ++pub const PR_SET_NAME: ::c_int = 15; ++pub const PR_GET_NAME: ::c_int = 16; ++ ++pub const PR_GET_ENDIAN: ::c_int = 19; ++pub const PR_SET_ENDIAN: ::c_int = 20; ++pub const PR_ENDIAN_BIG: ::c_int = 0; ++pub const PR_ENDIAN_LITTLE: ::c_int = 1; ++pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2; ++ ++pub const PR_GET_SECCOMP: ::c_int = 21; ++pub const PR_SET_SECCOMP: ::c_int = 22; ++ ++pub const PR_CAPBSET_READ: ::c_int = 23; ++pub const PR_CAPBSET_DROP: ::c_int = 24; ++ ++pub const PR_GET_TSC: ::c_int = 25; ++pub const PR_SET_TSC: ::c_int = 26; ++pub const PR_TSC_ENABLE: ::c_int = 1; ++pub const PR_TSC_SIGSEGV: ::c_int = 2; ++ ++pub const PR_GET_SECUREBITS: ::c_int = 27; ++pub const PR_SET_SECUREBITS: ::c_int = 28; ++ ++pub const PR_SET_TIMERSLACK: ::c_int = 29; ++pub const PR_GET_TIMERSLACK: ::c_int = 30; ++ ++pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31; ++pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32; ++ ++pub const PR_MCE_KILL: ::c_int = 33; ++pub const PR_MCE_KILL_CLEAR: ::c_int = 0; ++pub const PR_MCE_KILL_SET: ::c_int = 1; ++ ++pub const PR_MCE_KILL_LATE: ::c_int = 0; ++pub const PR_MCE_KILL_EARLY: ::c_int = 1; ++pub const PR_MCE_KILL_DEFAULT: ::c_int = 2; ++ ++pub const PR_MCE_KILL_GET: ::c_int = 34; ++ ++pub const PR_SET_MM: ::c_int = 35; ++pub const PR_SET_MM_START_CODE: ::c_int = 1; ++pub const PR_SET_MM_END_CODE: ::c_int = 2; ++pub const PR_SET_MM_START_DATA: ::c_int = 3; ++pub const PR_SET_MM_END_DATA: ::c_int = 4; ++pub const PR_SET_MM_START_STACK: ::c_int = 5; ++pub const PR_SET_MM_START_BRK: ::c_int = 6; ++pub const PR_SET_MM_BRK: ::c_int = 7; ++pub const PR_SET_MM_ARG_START: ::c_int = 8; ++pub const PR_SET_MM_ARG_END: ::c_int = 9; ++pub const PR_SET_MM_ENV_START: ::c_int = 10; ++pub const PR_SET_MM_ENV_END: ::c_int = 11; ++pub const PR_SET_MM_AUXV: ::c_int = 12; ++pub const PR_SET_MM_EXE_FILE: ::c_int = 13; ++pub const PR_SET_MM_MAP: ::c_int = 14; ++pub const PR_SET_MM_MAP_SIZE: ::c_int = 15; ++ ++pub const PR_SET_PTRACER: ::c_int = 0x59616d61; ++ ++pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36; ++pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37; ++ ++pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38; ++pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39; ++ ++pub const PR_GET_TID_ADDRESS: ::c_int = 40; ++ ++pub const PR_SET_THP_DISABLE: ::c_int = 41; ++pub const PR_GET_THP_DISABLE: ::c_int = 42; ++ ++pub const PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43; ++pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44; ++ ++pub const PR_SET_FP_MODE: ::c_int = 45; ++pub const PR_GET_FP_MODE: ::c_int = 46; ++pub const PR_FP_MODE_FR: ::c_int = 1 << 0; ++pub const PR_FP_MODE_FRE: ::c_int = 1 << 1; ++ ++pub const PR_CAP_AMBIENT: ::c_int = 47; ++pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1; ++pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2; ++pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3; ++pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4; ++ ++pub const ITIMER_REAL: ::c_int = 0; ++pub const ITIMER_VIRTUAL: ::c_int = 1; ++pub const ITIMER_PROF: ::c_int = 2; ++ ++pub const XATTR_CREATE: ::c_int = 0x1; ++pub const XATTR_REPLACE: ::c_int = 0x2; ++ ++pub const _POSIX_VDISABLE: ::cc_t = 0; ++ ++pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; ++pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; ++pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08; ++pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10; ++pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20; ++pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40; ++ ++// On Linux, libc doesn't define this constant, libattr does instead. ++// We still define it for Linux as it's defined by libc on other platforms, ++// and it's mentioned in the man pages for getxattr and setxattr. ++pub const SFD_CLOEXEC: ::c_int = 0x080000; ++ ++pub const NCCS: usize = 32; ++ ++pub const O_TRUNC: ::c_int = 512; ++pub const O_NOATIME: ::c_int = 0o1000000; ++pub const O_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EBFONT: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const EDOTDOT: ::c_int = 73; ++ ++pub const SA_NODEFER: ::c_int = 0x40000000; ++pub const SA_RESETHAND: ::c_int = 0x80000000; ++pub const SA_RESTART: ::c_int = 0x10000000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000001; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x80000; ++ ++pub const BUFSIZ: ::c_uint = 1024; ++pub const TMP_MAX: ::c_uint = 10000; ++pub const FOPEN_MAX: ::c_uint = 1000; ++pub const O_PATH: ::c_int = 0o10000000; ++pub const O_EXEC: ::c_int = 0o10000000; ++pub const O_SEARCH: ::c_int = 0o10000000; ++pub const O_ACCMODE: ::c_int = 0o10000003; ++pub const O_NDELAY: ::c_int = O_NONBLOCK; ++pub const NI_MAXHOST: ::socklen_t = 255; ++pub const PTHREAD_STACK_MIN: ::size_t = 2048; ++pub const POSIX_FADV_DONTNEED: ::c_int = 4; ++pub const POSIX_FADV_NOREUSE: ::c_int = 5; ++ ++pub const POSIX_MADV_DONTNEED: ::c_int = 0; ++ ++pub const RLIM_INFINITY: ::rlim_t = !0; ++pub const RLIMIT_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 __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; ++ ++pub const CPU_SETSIZE: ::c_int = 128; ++ ++pub const QFMT_VFS_V1: ::c_int = 4; ++ ++pub const PTRACE_TRACEME: ::c_int = 0; ++pub const PTRACE_PEEKTEXT: ::c_int = 1; ++pub const PTRACE_PEEKDATA: ::c_int = 2; ++pub const PTRACE_PEEKUSER: ::c_int = 3; ++pub const PTRACE_POKETEXT: ::c_int = 4; ++pub const PTRACE_POKEDATA: ::c_int = 5; ++pub const PTRACE_POKEUSER: ::c_int = 6; ++pub const PTRACE_CONT: ::c_int = 7; ++pub const PTRACE_KILL: ::c_int = 8; ++pub const PTRACE_SINGLESTEP: ::c_int = 9; ++pub const PTRACE_ATTACH: ::c_int = 16; ++pub const PTRACE_DETACH: ::c_int = 17; ++pub const PTRACE_SYSCALL: ::c_int = 24; ++pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; ++pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; ++pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; ++pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; ++pub const PTRACE_GETREGSET: ::c_int = 0x4204; ++pub const PTRACE_SETREGSET: ::c_int = 0x4205; ++pub const PTRACE_SEIZE: ::c_int = 0x4206; ++pub const PTRACE_INTERRUPT: ::c_int = 0x4207; ++pub const PTRACE_LISTEN: ::c_int = 0x4208; ++pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; ++ ++pub const EPOLLWAKEUP: ::c_int = 0x20000000; ++ ++pub const PTRACE_GETFPREGS: ::c_uint = 14; ++pub const PTRACE_SETFPREGS: ::c_uint = 15; ++pub const PTRACE_GETFPXREGS: ::c_uint = 18; ++pub const PTRACE_SETFPXREGS: ::c_uint = 19; ++pub const PTRACE_GETREGS: ::c_uint = 12; ++pub const PTRACE_SETREGS: ::c_uint = 13; ++ ++pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK; ++ ++pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK; ++ ++pub const TCSANOW: ::c_int = 0; ++pub const TCSADRAIN: ::c_int = 1; ++pub const TCSAFLUSH: ::c_int = 2; ++ ++pub const TIOCINQ: ::c_int = ::FIONREAD; ++ ++pub const RTLD_GLOBAL: ::c_int = 0x100; ++pub const RTLD_NOLOAD: ::c_int = 0x4; ++ ++// TODO(#247) Temporarily musl-specific (available since musl 0.9.12 / Linux ++// kernel 3.10). See also notbsd/mod.rs ++pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; ++pub const CLOCK_TAI: ::clockid_t = 11; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const SIGSTKSZ: ::size_t = 8192; ++pub const MINSIGSTKSZ: ::size_t = 2048; ++pub const CBAUD: ::tcflag_t = 0o0010017; ++pub const TAB1: ::c_int = 0x00000800; ++pub const TAB2: ::c_int = 0x00001000; ++pub const TAB3: ::c_int = 0x00001800; ++pub const CR1: ::c_int = 0x00000200; ++pub const CR2: ::c_int = 0x00000400; ++pub const CR3: ::c_int = 0x00000600; ++pub const FF1: ::c_int = 0x00008000; ++pub const BS1: ::c_int = 0x00002000; ++pub const VT1: ::c_int = 0x00004000; ++pub const VWERASE: usize = 14; ++pub const VREPRINT: usize = 12; ++pub const VSUSP: usize = 10; ++pub const VSTART: usize = 8; ++pub const VSTOP: usize = 9; ++pub const VDISCARD: usize = 13; ++pub const VTIME: usize = 5; ++pub const IXON: ::tcflag_t = 0x00000400; ++pub const IXOFF: ::tcflag_t = 0x00001000; ++pub const ONLCR: ::tcflag_t = 0x4; ++pub const CSIZE: ::tcflag_t = 0x00000030; ++pub const CS6: ::tcflag_t = 0x00000010; ++pub const CS7: ::tcflag_t = 0x00000020; ++pub const CS8: ::tcflag_t = 0x00000030; ++pub const CSTOPB: ::tcflag_t = 0x00000040; ++pub const CREAD: ::tcflag_t = 0x00000080; ++pub const PARENB: ::tcflag_t = 0x00000100; ++pub const PARODD: ::tcflag_t = 0x00000200; ++pub const HUPCL: ::tcflag_t = 0x00000400; ++pub const CLOCAL: ::tcflag_t = 0x00000800; ++pub const ECHOKE: ::tcflag_t = 0x00000800; ++pub const ECHOE: ::tcflag_t = 0x00000010; ++pub const ECHOK: ::tcflag_t = 0x00000020; ++pub const ECHONL: ::tcflag_t = 0x00000040; ++pub const ECHOPRT: ::tcflag_t = 0x00000400; ++pub const ECHOCTL: ::tcflag_t = 0x00000200; ++pub const ISIG: ::tcflag_t = 0x00000001; ++pub const ICANON: ::tcflag_t = 0x00000002; ++pub const PENDIN: ::tcflag_t = 0x00004000; ++pub const NOFLSH: ::tcflag_t = 0x00000080; ++pub const CBAUDEX: ::tcflag_t = 0o010000; ++pub const VSWTC: usize = 7; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const XTABS: ::tcflag_t = 0o014000; ++ ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const B57600: ::speed_t = 0o010001; ++pub const B115200: ::speed_t = 0o010002; ++pub const B230400: ::speed_t = 0o010003; ++pub const B460800: ::speed_t = 0o010004; ++pub const B500000: ::speed_t = 0o010005; ++pub const B576000: ::speed_t = 0o010006; ++pub const B921600: ::speed_t = 0o010007; ++pub const B1000000: ::speed_t = 0o010010; ++pub const B1152000: ::speed_t = 0o010011; ++pub const B1500000: ::speed_t = 0o010012; ++pub const B2000000: ::speed_t = 0o010013; ++pub const B2500000: ::speed_t = 0o010014; ++pub const B3000000: ::speed_t = 0o010015; ++pub const B3500000: ::speed_t = 0o010016; ++pub const B4000000: ::speed_t = 0o010017; ++ ++pub const SO_BINDTODEVICE: ::c_int = 25; ++pub const SO_TIMESTAMP: ::c_int = 29; ++pub const SO_MARK: ::c_int = 36; ++pub const SO_RXQ_OVFL: ::c_int = 40; ++pub const SO_PEEK_OFF: ::c_int = 42; ++pub const SO_BUSY_POLL: ::c_int = 46; ++ ++pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 28; ++ ++pub const O_DIRECT: ::c_int = 0x4000; ++pub const O_DIRECTORY: ::c_int = 0x10000; ++pub const O_NOFOLLOW: ::c_int = 0x20000; ++pub const O_ASYNC: ::c_int = 0x2000; ++ ++pub const FIOCLEX: ::c_int = 0x5451; ++pub const FIONBIO: ::c_int = 0x5421; ++ ++pub const RLIMIT_RSS: ::c_int = 5; ++pub const RLIMIT_NOFILE: ::c_int = 7; ++pub const RLIMIT_AS: ::c_int = 9; ++pub const RLIMIT_NPROC: ::c_int = 6; ++pub const RLIMIT_MEMLOCK: ::c_int = 8; ++ ++pub const O_APPEND: ::c_int = 1024; ++pub const O_CREAT: ::c_int = 64; ++pub const O_EXCL: ::c_int = 128; ++pub const O_NOCTTY: ::c_int = 256; ++pub const O_NONBLOCK: ::c_int = 2048; ++pub const O_SYNC: ::c_int = 1052672; ++pub const O_RSYNC: ::c_int = 1052672; ++pub const O_DSYNC: ::c_int = 4096; ++ ++pub const SOCK_NONBLOCK: ::c_int = 2048; ++ ++pub const MAP_ANON: ::c_int = 0x0020; ++pub const MAP_GROWSDOWN: ::c_int = 0x0100; ++pub const MAP_DENYWRITE: ::c_int = 0x0800; ++pub const MAP_EXECUTABLE: ::c_int = 0x01000; ++pub const MAP_LOCKED: ::c_int = 0x02000; ++pub const MAP_NORESERVE: ::c_int = 0x04000; ++pub const MAP_POPULATE: ::c_int = 0x08000; ++pub const MAP_NONBLOCK: ::c_int = 0x010000; ++pub const MAP_STACK: ::c_int = 0x020000; ++ ++pub const SOCK_STREAM: ::c_int = 1; ++pub const SOCK_DGRAM: ::c_int = 2; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++ ++pub const SOL_SOCKET: ::c_int = 1; ++ ++pub const EDEADLK: ::c_int = 35; ++pub const ENAMETOOLONG: ::c_int = 36; ++pub const ENOLCK: ::c_int = 37; ++pub const ENOSYS: ::c_int = 38; ++pub const ENOTEMPTY: ::c_int = 39; ++pub const ELOOP: ::c_int = 40; ++pub const ENOMSG: ::c_int = 42; ++pub const EIDRM: ::c_int = 43; ++pub const ECHRNG: ::c_int = 44; ++pub const EL2NSYNC: ::c_int = 45; ++pub const EL3HLT: ::c_int = 46; ++pub const EL3RST: ::c_int = 47; ++pub const ELNRNG: ::c_int = 48; ++pub const EUNATCH: ::c_int = 49; ++pub const ENOCSI: ::c_int = 50; ++pub const EL2HLT: ::c_int = 51; ++pub const EBADE: ::c_int = 52; ++pub const EBADR: ::c_int = 53; ++pub const EXFULL: ::c_int = 54; ++pub const ENOANO: ::c_int = 55; ++pub const EBADRQC: ::c_int = 56; ++pub const EBADSLT: ::c_int = 57; ++pub const EDEADLOCK: ::c_int = EDEADLK; ++pub const EMULTIHOP: ::c_int = 72; ++pub const EBADMSG: ::c_int = 74; ++pub const EOVERFLOW: ::c_int = 75; ++pub const ENOTUNIQ: ::c_int = 76; ++pub const EBADFD: ::c_int = 77; ++pub const EREMCHG: ::c_int = 78; ++pub const ELIBACC: ::c_int = 79; ++pub const ELIBBAD: ::c_int = 80; ++pub const ELIBSCN: ::c_int = 81; ++pub const ELIBMAX: ::c_int = 82; ++pub const ELIBEXEC: ::c_int = 83; ++pub const EILSEQ: ::c_int = 84; ++pub const ERESTART: ::c_int = 85; ++pub const ESTRPIPE: ::c_int = 86; ++pub const EUSERS: ::c_int = 87; ++pub const ENOTSOCK: ::c_int = 88; ++pub const EDESTADDRREQ: ::c_int = 89; ++pub const EMSGSIZE: ::c_int = 90; ++pub const EPROTOTYPE: ::c_int = 91; ++pub const ENOPROTOOPT: ::c_int = 92; ++pub const EPROTONOSUPPORT: ::c_int = 93; ++pub const ESOCKTNOSUPPORT: ::c_int = 94; ++pub const EOPNOTSUPP: ::c_int = 95; ++pub const ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const EAFNOSUPPORT: ::c_int = 97; ++pub const EADDRINUSE: ::c_int = 98; ++pub const EADDRNOTAVAIL: ::c_int = 99; ++pub const ENETDOWN: ::c_int = 100; ++pub const ENETUNREACH: ::c_int = 101; ++pub const ENETRESET: ::c_int = 102; ++pub const ECONNABORTED: ::c_int = 103; ++pub const ECONNRESET: ::c_int = 104; ++pub const ENOBUFS: ::c_int = 105; ++pub const EISCONN: ::c_int = 106; ++pub const ENOTCONN: ::c_int = 107; ++pub const ESHUTDOWN: ::c_int = 108; ++pub const ETOOMANYREFS: ::c_int = 109; ++pub const ETIMEDOUT: ::c_int = 110; ++pub const ECONNREFUSED: ::c_int = 111; ++pub const EHOSTDOWN: ::c_int = 112; ++pub const EHOSTUNREACH: ::c_int = 113; ++pub const EALREADY: ::c_int = 114; ++pub const EINPROGRESS: ::c_int = 115; ++pub const ESTALE: ::c_int = 116; ++pub const EUCLEAN: ::c_int = 117; ++pub const ENOTNAM: ::c_int = 118; ++pub const ENAVAIL: ::c_int = 119; ++pub const EISNAM: ::c_int = 120; ++pub const EREMOTEIO: ::c_int = 121; ++pub const EDQUOT: ::c_int = 122; ++pub const ENOMEDIUM: ::c_int = 123; ++pub const EMEDIUMTYPE: ::c_int = 124; ++pub const ECANCELED: ::c_int = 125; ++pub const ENOKEY: ::c_int = 126; ++pub const EKEYEXPIRED: ::c_int = 127; ++pub const EKEYREVOKED: ::c_int = 128; ++pub const EKEYREJECTED: ::c_int = 129; ++pub const EOWNERDEAD: ::c_int = 130; ++pub const ENOTRECOVERABLE: ::c_int = 131; ++pub const ERFKILL: ::c_int = 132; ++pub const EHWPOISON: ::c_int = 133; ++ ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_TYPE: ::c_int = 3; ++pub const SO_ERROR: ::c_int = 4; ++pub const SO_DONTROUTE: ::c_int = 5; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SO_SNDBUF: ::c_int = 7; ++pub const SO_RCVBUF: ::c_int = 8; ++pub const SO_KEEPALIVE: ::c_int = 9; ++pub const SO_OOBINLINE: ::c_int = 10; ++pub const SO_LINGER: ::c_int = 13; ++pub const SO_REUSEPORT: ::c_int = 15; ++pub const SO_RCVLOWAT: ::c_int = 18; ++pub const SO_SNDLOWAT: ::c_int = 19; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_SNDTIMEO: ::c_int = 21; ++pub const SO_ACCEPTCONN: ::c_int = 30; ++ ++pub const SA_ONSTACK: ::c_int = 0x08000000; ++pub const SA_SIGINFO: ::c_int = 0x00000004; ++pub const SA_NOCLDWAIT: ::c_int = 0x00000002; ++ ++pub const SIGCHLD: ::c_int = 17; ++pub const SIGBUS: ::c_int = 7; ++pub const SIGTTIN: ::c_int = 21; ++pub const SIGTTOU: ::c_int = 22; ++pub const SIGXCPU: ::c_int = 24; ++pub const SIGXFSZ: ::c_int = 25; ++pub const SIGVTALRM: ::c_int = 26; ++pub const SIGPROF: ::c_int = 27; ++pub const SIGWINCH: ::c_int = 28; ++pub const SIGUSR1: ::c_int = 10; ++pub const SIGUSR2: ::c_int = 12; ++pub const SIGCONT: ::c_int = 18; ++pub const SIGSTOP: ::c_int = 19; ++pub const SIGTSTP: ::c_int = 20; ++pub const SIGURG: ::c_int = 23; ++pub const SIGIO: ::c_int = 29; ++pub const SIGSYS: ::c_int = 31; ++pub const SIGSTKFLT: ::c_int = 16; ++pub const SIGPOLL: ::c_int = 29; ++pub const SIGPWR: ::c_int = 30; ++pub const SIG_SETMASK: ::c_int = 2; ++pub const SIG_BLOCK: ::c_int = 0x000000; ++pub const SIG_UNBLOCK: ::c_int = 0x01; ++ ++pub const EXTPROC: ::tcflag_t = 0x00010000; ++ ++pub const MAP_HUGETLB: ::c_int = 0x040000; ++ ++pub const F_GETLK: ::c_int = 12; ++pub const F_GETOWN: ::c_int = 9; ++pub const F_SETLK: ::c_int = 13; ++pub const F_SETLKW: ::c_int = 14; ++pub const F_SETOWN: ::c_int = 8; ++ ++pub const VEOF: usize = 4; ++pub const VEOL: usize = 11; ++pub const VEOL2: usize = 16; ++pub const VMIN: usize = 6; ++pub const IEXTEN: ::tcflag_t = 0x00008000; ++pub const TOSTOP: ::tcflag_t = 0x00000100; ++pub const FLUSHO: ::tcflag_t = 0x00001000; ++ ++pub const TCGETS: ::c_int = 0x5401; ++pub const TCSETS: ::c_int = 0x5402; ++pub const TCSETSW: ::c_int = 0x5403; ++pub const TCSETSF: ::c_int = 0x5404; ++pub const TCGETA: ::c_int = 0x5405; ++pub const TCSETA: ::c_int = 0x5406; ++pub const TCSETAW: ::c_int = 0x5407; ++pub const TCSETAF: ::c_int = 0x5408; ++pub const TCSBRK: ::c_int = 0x5409; ++pub const TCXONC: ::c_int = 0x540A; ++pub const TCFLSH: ::c_int = 0x540B; ++pub const TIOCGSOFTCAR: ::c_int = 0x5419; ++pub const TIOCSSOFTCAR: ::c_int = 0x541A; ++pub const TIOCLINUX: ::c_int = 0x541C; ++pub const TIOCGSERIAL: ::c_int = 0x541E; ++pub const TIOCEXCL: ::c_int = 0x540C; ++pub const TIOCNXCL: ::c_int = 0x540D; ++pub const TIOCSCTTY: ::c_int = 0x540E; ++pub const TIOCGPGRP: ::c_int = 0x540F; ++pub const TIOCSPGRP: ::c_int = 0x5410; ++pub const TIOCOUTQ: ::c_int = 0x5411; ++pub const TIOCSTI: ::c_int = 0x5412; ++pub const TIOCGWINSZ: ::c_int = 0x5413; ++pub const TIOCSWINSZ: ::c_int = 0x5414; ++pub const TIOCMGET: ::c_int = 0x5415; ++pub const TIOCMBIS: ::c_int = 0x5416; ++pub const TIOCMBIC: ::c_int = 0x5417; ++pub const TIOCMSET: ::c_int = 0x5418; ++pub const FIONREAD: ::c_int = 0x541B; ++pub const TIOCCONS: ::c_int = 0x541D; ++ ++pub const SYS_gettid: ::c_long = 224; // Valid for arm (32-bit) and x86 (32-bit) ++ ++pub const POLLWRNORM: ::c_short = 0x100; ++pub const POLLWRBAND: ::c_short = 0x200; ++ ++pub const TIOCM_LE: ::c_int = 0x001; ++pub const TIOCM_DTR: ::c_int = 0x002; ++pub const TIOCM_RTS: ::c_int = 0x004; ++pub const TIOCM_ST: ::c_int = 0x008; ++pub const TIOCM_SR: ::c_int = 0x010; ++pub const TIOCM_CTS: ::c_int = 0x020; ++pub const TIOCM_CAR: ::c_int = 0x040; ++pub const TIOCM_RNG: ::c_int = 0x080; ++pub const TIOCM_DSR: ::c_int = 0x100; ++pub const TIOCM_CD: ::c_int = TIOCM_CAR; ++pub const TIOCM_RI: ::c_int = TIOCM_RNG; ++pub const O_TMPFILE: ::c_int = 0x400000; ++ ++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 ++ } ++ ++ pub fn major(dev: ::dev_t) -> ::c_uint { ++ // see ++ // https://github.com/kripken/emscripten/blob/ ++ // master/system/include/libc/sys/sysmacros.h ++ let mut major = 0; ++ major |= (dev & 0x00000fff) >> 8; ++ major |= (dev & 0xfffff000) >> 31 >> 1; ++ major as ::c_uint ++ } ++ ++ pub fn minor(dev: ::dev_t) -> ::c_uint { ++ // see ++ // https://github.com/kripken/emscripten/blob/ ++ // master/system/include/libc/sys/sysmacros.h ++ let mut minor = 0; ++ minor |= (dev & 0x000000ff) >> 0; ++ minor |= (dev & 0xffffff00) >> 12; ++ minor as ::c_uint ++ } ++ ++ pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t { ++ let major = major as ::dev_t; ++ let minor = minor as ::dev_t; ++ let mut dev = 0; ++ dev |= (major & 0x00000fff) << 8; ++ dev |= (major & 0xfffff000) << 31 << 1; ++ dev |= (minor & 0x000000ff) << 0; ++ dev |= (minor & 0xffffff00) << 12; ++ dev ++ } ++} ++ ++extern { ++ pub fn setpwent(); ++ pub fn endpwent(); ++ pub fn getpwent() -> *mut passwd; ++ ++ pub fn shm_open(name: *const c_char, oflag: ::c_int, ++ mode: mode_t) -> ::c_int; ++ ++ pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) ++ -> ::c_int; ++ pub fn __errno_location() -> *mut ::c_int; ++ ++ pub fn fopen64(filename: *const c_char, ++ mode: *const c_char) -> *mut ::FILE; ++ pub fn freopen64(filename: *const c_char, mode: *const c_char, ++ file: *mut ::FILE) -> *mut ::FILE; ++ pub fn tmpfile64() -> *mut ::FILE; ++ pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int; ++ pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int; ++ pub fn fseeko64(stream: *mut ::FILE, ++ offset: ::off64_t, ++ whence: ::c_int) -> ::c_int; ++ pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; ++ pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, ++ len: ::off_t) -> ::c_int; ++ pub fn pwritev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int, ++ offset: ::off_t) -> ::ssize_t; ++ pub fn preadv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int, ++ offset: ::off_t) -> ::ssize_t; ++ pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int; ++ pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; ++ pub fn mkostemps(template: *mut ::c_char, ++ suffixlen: ::c_int, ++ flags: ::c_int) -> ::c_int; ++ pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; ++ pub fn getnameinfo(sa: *const ::sockaddr, ++ salen: ::socklen_t, ++ host: *mut ::c_char, ++ hostlen: ::socklen_t, ++ serv: *mut ::c_char, ++ sevlen: ::socklen_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; ++ ++ // Not available now on Android ++ pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t) -> ::c_int; ++ pub fn if_nameindex() -> *mut if_nameindex; ++ pub fn if_freenameindex(ptr: *mut if_nameindex); ++ pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; ++ pub fn freeifaddrs(ifa: *mut ::ifaddrs); ++ ++ pub fn mremap(addr: *mut ::c_void, ++ len: ::size_t, ++ new_len: ::size_t, ++ flags: ::c_int, ++ ...) -> *mut ::c_void; ++ ++ pub fn glob(pattern: *const c_char, ++ flags: ::c_int, ++ errfunc: Option ::c_int>, ++ pglob: *mut ::glob_t) -> ::c_int; ++ pub fn globfree(pglob: *mut ::glob_t); ++ ++ pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) ++ -> ::c_int; ++ ++ pub fn shm_unlink(name: *const ::c_char) -> ::c_int; ++ ++ pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); ++ ++ pub fn telldir(dirp: *mut ::DIR) -> ::c_long; ++ pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) ++ -> ::c_int; ++ ++ pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; ++ ++ pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, ++ flags: ::c_int, addr: *mut ::sockaddr, ++ addrlen: *mut ::socklen_t) -> ::ssize_t; ++ pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; ++ pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; ++ ++ pub fn bind(socket: ::c_int, address: *const ::sockaddr, ++ address_len: ::socklen_t) -> ::c_int; ++ ++ pub fn writev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ pub fn readv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ ++ pub fn sendmsg(fd: ::c_int, ++ msg: *const ::msghdr, ++ flags: ::c_int) -> ::ssize_t; ++ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) ++ -> ::ssize_t; ++ pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; ++ pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; ++ pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint, ++ flags: ::c_int) -> ::c_int; ++ pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint, ++ flags: ::c_int, timeout: *mut ::timespec) -> ::c_int; ++ pub fn sync(); ++ pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; ++ pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; ++ pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; ++ pub fn pthread_create(native: *mut ::pthread_t, ++ attr: *const ::pthread_attr_t, ++ f: extern fn(*mut ::c_void) -> *mut ::c_void, ++ value: *mut ::c_void) -> ::c_int; ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/mips/mips32.rs index 000000000,000000000..0bfcc4f84 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/mips/mips32.rs @@@ -1,0 -1,0 +1,276 @@@ ++pub type c_char = i8; ++pub type c_long = i32; ++pub type c_ulong = u32; ++pub type clock_t = i32; ++pub type time_t = i32; ++pub type suseconds_t = i32; ++pub type wchar_t = i32; ++pub type off_t = i32; ++pub type ino_t = u32; ++pub type blkcnt_t = i32; ++pub type blksize_t = i32; ++pub type nlink_t = u32; ++pub type __u64 = ::c_ulonglong; ++ ++s! { ++ pub struct aiocb { ++ pub aio_fildes: ::c_int, ++ pub aio_lio_opcode: ::c_int, ++ pub aio_reqprio: ::c_int, ++ pub aio_buf: *mut ::c_void, ++ pub aio_nbytes: ::size_t, ++ pub aio_sigevent: ::sigevent, ++ __next_prio: *mut aiocb, ++ __abs_prio: ::c_int, ++ __policy: ::c_int, ++ __error_code: ::c_int, ++ __return_value: ::ssize_t, ++ pub aio_offset: off_t, ++ __unused1: [::c_char; 4], ++ __glibc_reserved: [::c_char; 32] ++ } ++ ++ pub struct stat { ++ pub st_dev: ::c_ulong, ++ st_pad1: [::c_long; 3], ++ pub st_ino: ::ino_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::c_ulong, ++ pub st_pad2: [::c_long; 2], ++ pub st_size: ::off_t, ++ st_pad3: ::c_long, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt_t, ++ st_pad5: [::c_long; 14], ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::c_ulong, ++ st_pad1: [::c_long; 3], ++ pub st_ino: ::ino64_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::c_ulong, ++ st_pad2: [::c_long; 2], ++ pub st_size: ::off64_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_blksize: ::blksize_t, ++ st_pad3: ::c_long, ++ pub st_blocks: ::blkcnt64_t, ++ st_pad5: [::c_long; 14], ++ } ++ ++ pub struct statfs64 { ++ pub f_type: ::c_long, ++ pub f_bsize: ::c_long, ++ pub f_frsize: ::c_long, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_bavail: u64, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::c_long, ++ pub f_flags: ::c_long, ++ pub f_spare: [::c_long; 5], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ #[cfg(target_endian = "little")] ++ pub f_fsid: ::c_ulong, ++ __f_unused: ::c_int, ++ #[cfg(target_endian = "big")] ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [u32; 9] ++ } ++ ++ pub struct sigaction { ++ pub sa_flags: ::c_int, ++ pub sa_sigaction: ::sighandler_t, ++ pub sa_mask: sigset_t, ++ pub sa_restorer: ::dox::Option, ++ _resv: [::c_int; 1], ++ } ++ ++ pub struct stack_t { ++ pub ss_sp: *mut ::c_void, ++ pub ss_size: ::size_t, ++ pub ss_flags: ::c_int, ++ } ++ ++ pub struct sigset_t { ++ __val: [::c_ulong; 32], ++ } ++ ++ pub struct siginfo_t { ++ pub si_signo: ::c_int, ++ pub si_code: ::c_int, ++ pub si_errno: ::c_int, ++ pub _pad: [::c_int; 29], ++ } ++ ++ pub struct ipc_perm { ++ pub __key: ::key_t, ++ pub uid: ::uid_t, ++ pub gid: ::gid_t, ++ pub cuid: ::uid_t, ++ pub cgid: ::gid_t, ++ pub mode: ::c_uint, ++ pub __seq: ::c_ushort, ++ __pad1: ::c_ushort, ++ __unused1: ::c_ulong, ++ __unused2: ::c_ulong ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, ++ pub shm_atime: ::time_t, ++ pub shm_dtime: ::time_t, ++ pub shm_ctime: ::time_t, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::shmatt_t, ++ __unused4: ::c_ulong, ++ __unused5: ::c_ulong ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ #[cfg(target_endian = "big")] ++ __glibc_reserved1: ::c_ulong, ++ pub msg_stime: ::time_t, ++ #[cfg(target_endian = "little")] ++ __glibc_reserved1: ::c_ulong, ++ #[cfg(target_endian = "big")] ++ __glibc_reserved2: ::c_ulong, ++ pub msg_rtime: ::time_t, ++ #[cfg(target_endian = "little")] ++ __glibc_reserved2: ::c_ulong, ++ #[cfg(target_endian = "big")] ++ __glibc_reserved3: ::c_ulong, ++ pub msg_ctime: ::time_t, ++ #[cfg(target_endian = "little")] ++ __glibc_reserved3: ::c_ulong, ++ __msg_cbytes: ::c_ulong, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ __glibc_reserved4: ::c_ulong, ++ __glibc_reserved5: ::c_ulong, ++ } ++ ++ pub struct statfs { ++ pub f_type: ::c_long, ++ pub f_bsize: ::c_long, ++ pub f_frsize: ::c_long, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_files: ::fsblkcnt_t, ++ pub f_ffree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_fsid: ::fsid_t, ++ ++ pub f_namelen: ::c_long, ++ f_spare: [::c_long; 6], ++ } ++ ++ pub struct msghdr { ++ pub msg_name: *mut ::c_void, ++ pub msg_namelen: ::socklen_t, ++ pub msg_iov: *mut ::iovec, ++ pub msg_iovlen: ::size_t, ++ pub msg_control: *mut ::c_void, ++ pub msg_controllen: ::size_t, ++ pub msg_flags: ::c_int, ++ } ++ ++ pub struct cmsghdr { ++ pub cmsg_len: ::size_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct termios { ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_line: ::cc_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ } ++ ++ pub struct flock { ++ pub l_type: ::c_short, ++ pub l_whence: ::c_short, ++ pub l_start: ::off_t, ++ pub l_len: ::off_t, ++ pub l_sysid: ::c_long, ++ pub l_pid: ::pid_t, ++ pad: [::c_long; 4], ++ } ++ ++ pub struct sysinfo { ++ pub uptime: ::c_long, ++ pub loads: [::c_ulong; 3], ++ pub totalram: ::c_ulong, ++ pub freeram: ::c_ulong, ++ pub sharedram: ::c_ulong, ++ pub bufferram: ::c_ulong, ++ pub totalswap: ::c_ulong, ++ pub freeswap: ::c_ulong, ++ pub procs: ::c_ushort, ++ pub pad: ::c_ushort, ++ pub totalhigh: ::c_ulong, ++ pub freehigh: ::c_ulong, ++ pub mem_unit: ::c_uint, ++ pub _f: [::c_char; 8], ++ } ++} ++ ++pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; ++pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; ++ ++pub const O_LARGEFILE: ::c_int = 0x2000; ++ ++pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; ++ ++// Valid for O32 ++pub const SYS_pivot_root: ::c_long = 4216; ++pub const SYS_gettid: ::c_long = 4222; ++pub const SYS_perf_event_open: ::c_long = 4333; ++pub const SYS_memfd_create: ::c_long = 4354; diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/mips/mips64.rs index 000000000,000000000..2de75355d new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/mips/mips64.rs @@@ -1,0 -1,0 +1,257 @@@ ++pub type blkcnt_t = i64; ++pub type blksize_t = i64; ++pub type c_char = i8; ++pub type c_long = i64; ++pub type c_ulong = u64; ++pub type ino_t = u64; ++pub type nlink_t = u64; ++pub type off_t = i64; ++pub type suseconds_t = i64; ++pub type time_t = i64; ++pub type wchar_t = i32; ++pub type clock_t = i64; ++pub type __u64 = ::c_ulong; ++ ++s! { ++ pub struct aiocb { ++ pub aio_fildes: ::c_int, ++ pub aio_lio_opcode: ::c_int, ++ pub aio_reqprio: ::c_int, ++ pub aio_buf: *mut ::c_void, ++ pub aio_nbytes: ::size_t, ++ pub aio_sigevent: ::sigevent, ++ __next_prio: *mut aiocb, ++ __abs_prio: ::c_int, ++ __policy: ::c_int, ++ __error_code: ::c_int, ++ __return_value: ::ssize_t, ++ pub aio_offset: off_t, ++ __glibc_reserved: [::c_char; 32] ++ } ++ ++ pub struct stat { ++ pub st_dev: ::c_ulong, ++ st_pad1: [::c_long; 2], ++ pub st_ino: ::ino_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::c_ulong, ++ st_pad2: [::c_ulong; 1], ++ pub st_size: ::off_t, ++ st_pad3: ::c_long, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_blksize: ::blksize_t, ++ st_pad4: ::c_long, ++ pub st_blocks: ::blkcnt_t, ++ st_pad5: [::c_long; 7], ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::c_ulong, ++ st_pad1: [::c_long; 2], ++ pub st_ino: ::ino64_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::c_ulong, ++ st_pad2: [::c_long; 2], ++ pub st_size: ::off64_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_blksize: ::blksize_t, ++ st_pad3: ::c_long, ++ pub st_blocks: ::blkcnt64_t, ++ st_pad5: [::c_long; 7], ++ } ++ ++ pub struct statfs64 { ++ pub f_type: ::c_long, ++ pub f_bsize: ::c_long, ++ pub f_frsize: ::c_long, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_bavail: u64, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::c_long, ++ pub f_flags: ::c_long, ++ pub f_spare: [::c_long; 5], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [::c_ulong; 7] ++ } ++ ++ pub struct sigaction { ++ pub sa_flags: ::c_int, ++ pub sa_sigaction: ::sighandler_t, ++ pub sa_mask: sigset_t, ++ pub sa_restorer: ::dox::Option, ++ } ++ ++ pub struct stack_t { ++ pub ss_sp: *mut ::c_void, ++ pub ss_size: ::size_t, ++ pub ss_flags: ::c_int, ++ } ++ ++ pub struct sigset_t { ++ __size: [::c_ulong; 16], ++ } ++ ++ pub struct siginfo_t { ++ pub si_signo: ::c_int, ++ pub si_code: ::c_int, ++ pub si_errno: ::c_int, ++ _pad: ::c_int, ++ _pad2: [::c_long; 14], ++ } ++ ++ pub struct ipc_perm { ++ pub __key: ::key_t, ++ pub uid: ::uid_t, ++ pub gid: ::gid_t, ++ pub cuid: ::uid_t, ++ pub cgid: ::gid_t, ++ pub mode: ::c_uint, ++ pub __seq: ::c_ushort, ++ __pad1: ::c_ushort, ++ __unused1: ::c_ulong, ++ __unused2: ::c_ulong ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, ++ pub shm_atime: ::time_t, ++ pub shm_dtime: ::time_t, ++ pub shm_ctime: ::time_t, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::shmatt_t, ++ __unused4: ::c_ulong, ++ __unused5: ::c_ulong ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ pub msg_stime: ::time_t, ++ pub msg_rtime: ::time_t, ++ pub msg_ctime: ::time_t, ++ __msg_cbytes: ::c_ulong, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ __glibc_reserved4: ::c_ulong, ++ __glibc_reserved5: ::c_ulong, ++ } ++ ++ pub struct statfs { ++ pub f_type: ::c_long, ++ pub f_bsize: ::c_long, ++ pub f_frsize: ::c_long, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_files: ::fsblkcnt_t, ++ pub f_ffree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_fsid: ::fsid_t, ++ ++ pub f_namelen: ::c_long, ++ f_spare: [::c_long; 6], ++ } ++ ++ pub struct msghdr { ++ pub msg_name: *mut ::c_void, ++ pub msg_namelen: ::socklen_t, ++ pub msg_iov: *mut ::iovec, ++ pub msg_iovlen: ::size_t, ++ pub msg_control: *mut ::c_void, ++ pub msg_controllen: ::size_t, ++ pub msg_flags: ::c_int, ++ } ++ ++ pub struct cmsghdr { ++ pub cmsg_len: ::size_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct termios { ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_line: ::cc_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ } ++ ++ pub struct flock { ++ pub l_type: ::c_short, ++ pub l_whence: ::c_short, ++ pub l_start: ::off_t, ++ pub l_len: ::off_t, ++ pub l_pid: ::pid_t, ++ } ++ ++ pub struct sysinfo { ++ pub uptime: ::c_long, ++ pub loads: [::c_ulong; 3], ++ pub totalram: ::c_ulong, ++ pub freeram: ::c_ulong, ++ pub sharedram: ::c_ulong, ++ pub bufferram: ::c_ulong, ++ pub totalswap: ::c_ulong, ++ pub freeswap: ::c_ulong, ++ pub procs: ::c_ushort, ++ pub pad: ::c_ushort, ++ pub totalhigh: ::c_ulong, ++ pub freehigh: ::c_ulong, ++ pub mem_unit: ::c_uint, ++ pub _f: [::c_char; 0], ++ } ++} ++ ++pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; ++pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; ++pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; ++ ++pub const O_LARGEFILE: ::c_int = 0; ++ ++pub const RLIM_INFINITY: ::rlim_t = 0xffff_ffff_ffff_ffff; ++ ++// Valid for n64 ++pub const SYS_pivot_root: ::c_long = 5151; ++pub const SYS_gettid: ::c_long = 5178; ++pub const SYS_memfd_create: ::c_long = 5314; diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/mips/mod.rs index 000000000,000000000..150b60786 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/mips/mod.rs @@@ -1,0 -1,0 +1,674 @@@ ++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 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, ++ } ++ ++ // 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 SFD_CLOEXEC: ::c_int = 0x080000; ++ ++pub const NCCS: usize = 32; ++ ++pub const O_TRUNC: ::c_int = 512; ++ ++pub const O_NOATIME: ::c_int = 0o1000000; ++pub const O_CLOEXEC: ::c_int = 0x80000; ++pub const O_PATH: ::c_int = 0o10000000; ++ ++pub const EBFONT: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const EDOTDOT: ::c_int = 73; ++ ++pub const SA_NODEFER: ::c_int = 0x40000000; ++pub const SA_RESETHAND: ::c_int = 0x80000000; ++pub const SA_RESTART: ::c_int = 0x10000000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000001; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x80000; ++ ++pub const BUFSIZ: ::c_uint = 8192; ++pub const TMP_MAX: ::c_uint = 238328; ++pub const FOPEN_MAX: ::c_uint = 16; ++pub const POSIX_FADV_DONTNEED: ::c_int = 4; ++pub const POSIX_FADV_NOREUSE: ::c_int = 5; ++pub const POSIX_MADV_DONTNEED: ::c_int = 4; ++pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41; ++pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45; ++pub const _SC_PII: ::c_int = 53; ++pub const _SC_PII_XTI: ::c_int = 54; ++pub const _SC_PII_SOCKET: ::c_int = 55; ++pub const _SC_PII_INTERNET: ::c_int = 56; ++pub const _SC_PII_OSI: ::c_int = 57; ++pub const _SC_POLL: ::c_int = 58; ++pub const _SC_SELECT: ::c_int = 59; ++pub const _SC_PII_INTERNET_STREAM: ::c_int = 61; ++pub const _SC_PII_INTERNET_DGRAM: ::c_int = 62; ++pub const _SC_PII_OSI_COTS: ::c_int = 63; ++pub const _SC_PII_OSI_CLTS: ::c_int = 64; ++pub const _SC_PII_OSI_M: ::c_int = 65; ++pub const _SC_T_IOV_MAX: ::c_int = 66; ++pub const _SC_2_C_VERSION: ::c_int = 96; ++pub const _SC_CHAR_BIT: ::c_int = 101; ++pub const _SC_CHAR_MAX: ::c_int = 102; ++pub const _SC_CHAR_MIN: ::c_int = 103; ++pub const _SC_INT_MAX: ::c_int = 104; ++pub const _SC_INT_MIN: ::c_int = 105; ++pub const _SC_LONG_BIT: ::c_int = 106; ++pub const _SC_WORD_BIT: ::c_int = 107; ++pub const _SC_MB_LEN_MAX: ::c_int = 108; ++pub const _SC_SSIZE_MAX: ::c_int = 110; ++pub const _SC_SCHAR_MAX: ::c_int = 111; ++pub const _SC_SCHAR_MIN: ::c_int = 112; ++pub const _SC_SHRT_MAX: ::c_int = 113; ++pub const _SC_SHRT_MIN: ::c_int = 114; ++pub const _SC_UCHAR_MAX: ::c_int = 115; ++pub const _SC_UINT_MAX: ::c_int = 116; ++pub const _SC_ULONG_MAX: ::c_int = 117; ++pub const _SC_USHRT_MAX: ::c_int = 118; ++pub const _SC_NL_ARGMAX: ::c_int = 119; ++pub const _SC_NL_LANGMAX: ::c_int = 120; ++pub const _SC_NL_MSGMAX: ::c_int = 121; ++pub const _SC_NL_NMAX: ::c_int = 122; ++pub const _SC_NL_SETMAX: ::c_int = 123; ++pub const _SC_NL_TEXTMAX: ::c_int = 124; ++pub const _SC_BASE: ::c_int = 134; ++pub const _SC_C_LANG_SUPPORT: ::c_int = 135; ++pub const _SC_C_LANG_SUPPORT_R: ::c_int = 136; ++pub const _SC_DEVICE_IO: ::c_int = 140; ++pub const _SC_DEVICE_SPECIFIC: ::c_int = 141; ++pub const _SC_DEVICE_SPECIFIC_R: ::c_int = 142; ++pub const _SC_FD_MGMT: ::c_int = 143; ++pub const _SC_FIFO: ::c_int = 144; ++pub const _SC_PIPE: ::c_int = 145; ++pub const _SC_FILE_ATTRIBUTES: ::c_int = 146; ++pub const _SC_FILE_LOCKING: ::c_int = 147; ++pub const _SC_FILE_SYSTEM: ::c_int = 148; ++pub const _SC_MULTI_PROCESS: ::c_int = 150; ++pub const _SC_SINGLE_PROCESS: ::c_int = 151; ++pub const _SC_NETWORKING: ::c_int = 152; ++pub const _SC_REGEX_VERSION: ::c_int = 156; ++pub const _SC_SIGNALS: ::c_int = 158; ++pub const _SC_SYSTEM_DATABASE: ::c_int = 162; ++pub const _SC_SYSTEM_DATABASE_R: ::c_int = 163; ++pub const _SC_USER_GROUPS: ::c_int = 166; ++pub const _SC_USER_GROUPS_R: ::c_int = 167; ++pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 185; ++pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 186; ++pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 187; ++pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 188; ++pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 189; ++pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 190; ++pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 191; ++pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 192; ++pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 193; ++pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 194; ++pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 195; ++pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 196; ++pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 197; ++pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 198; ++pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 199; ++pub const O_ACCMODE: ::c_int = 3; ++pub const O_DIRECT: ::c_int = 0x8000; ++pub const O_DIRECTORY: ::c_int = 0x10000; ++pub const O_NOFOLLOW: ::c_int = 0x20000; ++pub const ST_RELATIME: ::c_ulong = 4096; ++pub const NI_MAXHOST: ::socklen_t = 1025; ++ ++pub const RLIMIT_NOFILE: ::c_int = 5; ++pub const RLIMIT_AS: ::c_int = 6; ++pub const RLIMIT_RSS: ::c_int = 7; ++pub const RLIMIT_NPROC: ::c_int = 8; ++pub const RLIMIT_MEMLOCK: ::c_int = 9; ++pub const RLIMIT_NLIMITS: ::c_int = 16; ++ ++pub const O_APPEND: ::c_int = 8; ++pub const O_CREAT: ::c_int = 256; ++pub const O_EXCL: ::c_int = 1024; ++pub const O_NOCTTY: ::c_int = 2048; ++pub const O_NONBLOCK: ::c_int = 128; ++pub const O_SYNC: ::c_int = 0x4010; ++pub const O_RSYNC: ::c_int = 0x4010; ++pub const O_DSYNC: ::c_int = 0x10; ++pub const O_FSYNC: ::c_int = 0x4010; ++pub const O_ASYNC: ::c_int = 0x1000; ++pub const O_NDELAY: ::c_int = 0x80; ++ ++pub const SOCK_NONBLOCK: ::c_int = 128; ++ ++pub const EDEADLK: ::c_int = 45; ++pub const ENAMETOOLONG: ::c_int = 78; ++pub const ENOLCK: ::c_int = 46; ++pub const ENOSYS: ::c_int = 89; ++pub const ENOTEMPTY: ::c_int = 93; ++pub const ELOOP: ::c_int = 90; ++pub const ENOMSG: ::c_int = 35; ++pub const EIDRM: ::c_int = 36; ++pub const ECHRNG: ::c_int = 37; ++pub const EL2NSYNC: ::c_int = 38; ++pub const EL3HLT: ::c_int = 39; ++pub const EL3RST: ::c_int = 40; ++pub const ELNRNG: ::c_int = 41; ++pub const EUNATCH: ::c_int = 42; ++pub const ENOCSI: ::c_int = 43; ++pub const EL2HLT: ::c_int = 44; ++pub const EBADE: ::c_int = 50; ++pub const EBADR: ::c_int = 51; ++pub const EXFULL: ::c_int = 52; ++pub const ENOANO: ::c_int = 53; ++pub const EBADRQC: ::c_int = 54; ++pub const EBADSLT: ::c_int = 55; ++pub const EDEADLOCK: ::c_int = 56; ++pub const EMULTIHOP: ::c_int = 74; ++pub const EOVERFLOW: ::c_int = 79; ++pub const ENOTUNIQ: ::c_int = 80; ++pub const EBADFD: ::c_int = 81; ++pub const EBADMSG: ::c_int = 77; ++pub const EREMCHG: ::c_int = 82; ++pub const ELIBACC: ::c_int = 83; ++pub const ELIBBAD: ::c_int = 84; ++pub const ELIBSCN: ::c_int = 85; ++pub const ELIBMAX: ::c_int = 86; ++pub const ELIBEXEC: ::c_int = 87; ++pub const EILSEQ: ::c_int = 88; ++pub const ERESTART: ::c_int = 91; ++pub const ESTRPIPE: ::c_int = 92; ++pub const EUSERS: ::c_int = 94; ++pub const ENOTSOCK: ::c_int = 95; ++pub const EDESTADDRREQ: ::c_int = 96; ++pub const EMSGSIZE: ::c_int = 97; ++pub const EPROTOTYPE: ::c_int = 98; ++pub const ENOPROTOOPT: ::c_int = 99; ++pub const EPROTONOSUPPORT: ::c_int = 120; ++pub const ESOCKTNOSUPPORT: ::c_int = 121; ++pub const EOPNOTSUPP: ::c_int = 122; ++pub const ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EPFNOSUPPORT: ::c_int = 123; ++pub const EAFNOSUPPORT: ::c_int = 124; ++pub const EADDRINUSE: ::c_int = 125; ++pub const EADDRNOTAVAIL: ::c_int = 126; ++pub const ENETDOWN: ::c_int = 127; ++pub const ENETUNREACH: ::c_int = 128; ++pub const ENETRESET: ::c_int = 129; ++pub const ECONNABORTED: ::c_int = 130; ++pub const ECONNRESET: ::c_int = 131; ++pub const ENOBUFS: ::c_int = 132; ++pub const EISCONN: ::c_int = 133; ++pub const ENOTCONN: ::c_int = 134; ++pub const ESHUTDOWN: ::c_int = 143; ++pub const ETOOMANYREFS: ::c_int = 144; ++pub const ETIMEDOUT: ::c_int = 145; ++pub const ECONNREFUSED: ::c_int = 146; ++pub const EHOSTDOWN: ::c_int = 147; ++pub const EHOSTUNREACH: ::c_int = 148; ++pub const EALREADY: ::c_int = 149; ++pub const EINPROGRESS: ::c_int = 150; ++pub const ESTALE: ::c_int = 151; ++pub const EUCLEAN: ::c_int = 135; ++pub const ENOTNAM: ::c_int = 137; ++pub const ENAVAIL: ::c_int = 138; ++pub const EISNAM: ::c_int = 139; ++pub const EREMOTEIO: ::c_int = 140; ++pub const EDQUOT: ::c_int = 1133; ++pub const ENOMEDIUM: ::c_int = 159; ++pub const EMEDIUMTYPE: ::c_int = 160; ++pub const ECANCELED: ::c_int = 158; ++pub const ENOKEY: ::c_int = 161; ++pub const EKEYEXPIRED: ::c_int = 162; ++pub const EKEYREVOKED: ::c_int = 163; ++pub const EKEYREJECTED: ::c_int = 164; ++pub const EOWNERDEAD: ::c_int = 165; ++pub const ENOTRECOVERABLE: ::c_int = 166; ++pub const ERFKILL: ::c_int = 167; ++ ++pub const LC_PAPER: ::c_int = 7; ++pub const LC_NAME: ::c_int = 8; ++pub const LC_ADDRESS: ::c_int = 9; ++pub const LC_TELEPHONE: ::c_int = 10; ++pub const LC_MEASUREMENT: ::c_int = 11; ++pub const LC_IDENTIFICATION: ::c_int = 12; ++pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER); ++pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME); ++pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS); ++pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE); ++pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT); ++pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION); ++pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK ++ | ::LC_NUMERIC_MASK ++ | ::LC_TIME_MASK ++ | ::LC_COLLATE_MASK ++ | ::LC_MONETARY_MASK ++ | ::LC_MESSAGES_MASK ++ | LC_PAPER_MASK ++ | LC_NAME_MASK ++ | LC_ADDRESS_MASK ++ | LC_TELEPHONE_MASK ++ | LC_MEASUREMENT_MASK ++ | LC_IDENTIFICATION_MASK; ++ ++pub const MAP_NORESERVE: ::c_int = 0x400; ++pub const MAP_ANON: ::c_int = 0x800; ++pub const MAP_ANONYMOUS: ::c_int = 0x800; ++pub const MAP_GROWSDOWN: ::c_int = 0x1000; ++pub const MAP_DENYWRITE: ::c_int = 0x2000; ++pub const MAP_EXECUTABLE: ::c_int = 0x4000; ++pub const MAP_LOCKED: ::c_int = 0x8000; ++pub const MAP_POPULATE: ::c_int = 0x10000; ++pub const MAP_NONBLOCK: ::c_int = 0x20000; ++pub const MAP_STACK: ::c_int = 0x40000; ++ ++pub const SOCK_STREAM: ::c_int = 2; ++pub const SOCK_DGRAM: ::c_int = 1; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++ ++pub const SOL_SOCKET: ::c_int = 0xffff; ++ ++pub const SO_REUSEADDR: ::c_int = 0x0004; ++pub const SO_KEEPALIVE: ::c_int = 0x0008; ++pub const SO_DONTROUTE: ::c_int = 0x0010; ++pub const SO_BROADCAST: ::c_int = 0x0020; ++pub const SO_LINGER: ::c_int = 0x0080; ++pub const SO_OOBINLINE: ::c_int = 0x0100; ++pub const SO_REUSEPORT: ::c_int = 0x0200; ++pub const SO_TYPE: ::c_int = 0x1008; ++pub const SO_STYLE: ::c_int = SO_TYPE; ++pub const SO_ERROR: ::c_int = 0x1007; ++pub const SO_SNDBUF: ::c_int = 0x1001; ++pub const SO_RCVBUF: ::c_int = 0x1002; ++pub const SO_SNDLOWAT: ::c_int = 0x1003; ++pub const SO_RCVLOWAT: ::c_int = 0x1004; ++pub const SO_SNDTIMEO: ::c_int = 0x1005; ++pub const SO_RCVTIMEO: ::c_int = 0x1006; ++pub const SO_ACCEPTCONN: ::c_int = 0x1009; ++pub const SO_PROTOCOL: ::c_int = 0x1028; ++pub const SO_DOMAIN: ::c_int = 0x1029; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_PASSCRED: ::c_int = 17; ++pub const SO_PEERCRED: ::c_int = 18; ++pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; ++pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; ++pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; ++pub const SO_BINDTODEVICE: ::c_int = 25; ++pub const SO_ATTACH_FILTER: ::c_int = 26; ++pub const SO_DETACH_FILTER: ::c_int = 27; ++pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; ++pub const SO_PEERNAME: ::c_int = 28; ++pub const SO_TIMESTAMP: ::c_int = 29; ++pub const SO_PEERSEC: ::c_int = 30; ++pub const SO_SNDBUFFORCE: ::c_int = 31; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_PASSSEC: ::c_int = 34; ++pub const SO_TIMESTAMPNS: ::c_int = 35; ++pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; ++pub const SO_MARK: ::c_int = 36; ++pub const SO_TIMESTAMPING: ::c_int = 37; ++pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; ++pub const SO_RXQ_OVFL: ::c_int = 40; ++pub const SO_WIFI_STATUS: ::c_int = 41; ++pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; ++pub const SO_PEEK_OFF: ::c_int = 42; ++pub const SO_NOFCS: ::c_int = 43; ++pub const SO_LOCK_FILTER: ::c_int = 44; ++pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; ++pub const SO_BUSY_POLL: ::c_int = 46; ++pub const SO_MAX_PACING_RATE: ::c_int = 47; ++pub const SO_BPF_EXTENSIONS: ::c_int = 48; ++pub const SO_INCOMING_CPU: ::c_int = 49; ++pub const SO_ATTACH_BPF: ::c_int = 50; ++pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER; ++ ++pub const FIOCLEX: ::c_ulong = 0x6601; ++pub const FIONBIO: ::c_ulong = 0x667e; ++ ++pub const SA_ONSTACK: ::c_int = 0x08000000; ++pub const SA_SIGINFO: ::c_int = 0x00000008; ++pub const SA_NOCLDWAIT: ::c_int = 0x00010000; ++ ++pub const SIGCHLD: ::c_int = 18; ++pub const SIGBUS: ::c_int = 10; ++pub const SIGTTIN: ::c_int = 26; ++pub const SIGTTOU: ::c_int = 27; ++pub const SIGXCPU: ::c_int = 30; ++pub const SIGXFSZ: ::c_int = 31; ++pub const SIGVTALRM: ::c_int = 28; ++pub const SIGPROF: ::c_int = 29; ++pub const SIGWINCH: ::c_int = 20; ++pub const SIGUSR1: ::c_int = 16; ++pub const SIGUSR2: ::c_int = 17; ++pub const SIGCONT: ::c_int = 25; ++pub const SIGSTOP: ::c_int = 23; ++pub const SIGTSTP: ::c_int = 24; ++pub const SIGURG: ::c_int = 21; ++pub const SIGIO: ::c_int = 22; ++pub const SIGSYS: ::c_int = 12; ++pub const SIGPOLL: ::c_int = 22; ++pub const SIGPWR: ::c_int = 19; ++pub const SIG_SETMASK: ::c_int = 3; ++pub const SIG_BLOCK: ::c_int = 0x1; ++pub const SIG_UNBLOCK: ::c_int = 0x2; ++ ++pub const POLLWRNORM: ::c_short = 0x004; ++pub const POLLWRBAND: ::c_short = 0x100; ++ ++pub const PTHREAD_STACK_MIN: ::size_t = 131072; ++ ++pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; ++pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; ++pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; ++pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; ++pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; ++pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; ++pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; ++pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; ++pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; ++pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; ++pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; ++pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; ++pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; ++pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; ++pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; ++pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; ++pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; ++pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; ++pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; ++pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; ++pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; ++pub const TMPFS_MAGIC: ::c_long = 0x01021994; ++pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; ++ ++pub const VEOF: usize = 16; ++pub const VEOL: usize = 17; ++pub const VEOL2: usize = 6; ++pub const VMIN: usize = 4; ++pub const IEXTEN: ::tcflag_t = 0x00000100; ++pub const TOSTOP: ::tcflag_t = 0x00008000; ++pub const FLUSHO: ::tcflag_t = 0x00002000; ++pub const EXTPROC: ::tcflag_t = 0o200000; ++pub const TCSANOW: ::c_int = 0x540e; ++pub const TCSADRAIN: ::c_int = 0x540f; ++pub const TCSAFLUSH: ::c_int = 0x5410; ++ ++pub const CPU_SETSIZE: ::c_int = 0x400; ++ ++pub const PTRACE_TRACEME: ::c_uint = 0; ++pub const PTRACE_PEEKTEXT: ::c_uint = 1; ++pub const PTRACE_PEEKDATA: ::c_uint = 2; ++pub const PTRACE_PEEKUSER: ::c_uint = 3; ++pub const PTRACE_POKETEXT: ::c_uint = 4; ++pub const PTRACE_POKEDATA: ::c_uint = 5; ++pub const PTRACE_POKEUSER: ::c_uint = 6; ++pub const PTRACE_CONT: ::c_uint = 7; ++pub const PTRACE_KILL: ::c_uint = 8; ++pub const PTRACE_SINGLESTEP: ::c_uint = 9; ++pub const PTRACE_ATTACH: ::c_uint = 16; ++pub const PTRACE_DETACH: ::c_uint = 17; ++pub const PTRACE_SYSCALL: ::c_uint = 24; ++pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; ++pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; ++pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; ++pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; ++pub const PTRACE_GETFPREGS: ::c_uint = 14; ++pub const PTRACE_SETFPREGS: ::c_uint = 15; ++pub const PTRACE_GETFPXREGS: ::c_uint = 18; ++pub const PTRACE_SETFPXREGS: ::c_uint = 19; ++pub const PTRACE_GETREGS: ::c_uint = 12; ++pub const PTRACE_SETREGS: ::c_uint = 13; ++ ++pub const MAP_HUGETLB: ::c_int = 0x080000; ++ ++pub const EFD_NONBLOCK: ::c_int = 0x80; ++ ++pub const F_GETLK: ::c_int = 14; ++pub const F_GETOWN: ::c_int = 23; ++pub const F_SETOWN: ::c_int = 24; ++pub const F_SETLK: ::c_int = 6; ++pub const F_SETLKW: ::c_int = 7; ++ ++pub const SFD_NONBLOCK: ::c_int = 0x80; ++ ++pub const TCGETS: ::c_ulong = 0x540d; ++pub const TCSETS: ::c_ulong = 0x540e; ++pub const TCSETSW: ::c_ulong = 0x540f; ++pub const TCSETSF: ::c_ulong = 0x5410; ++pub const TCGETA: ::c_ulong = 0x5401; ++pub const TCSETA: ::c_ulong = 0x5402; ++pub const TCSETAW: ::c_ulong = 0x5403; ++pub const TCSETAF: ::c_ulong = 0x5404; ++pub const TCSBRK: ::c_ulong = 0x5405; ++pub const TCXONC: ::c_ulong = 0x5406; ++pub const TCFLSH: ::c_ulong = 0x5407; ++pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; ++pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; ++pub const TIOCINQ: ::c_ulong = 0x467f; ++pub const TIOCLINUX: ::c_ulong = 0x5483; ++pub const TIOCGSERIAL: ::c_ulong = 0x5484; ++pub const TIOCEXCL: ::c_ulong = 0x740d; ++pub const TIOCNXCL: ::c_ulong = 0x740e; ++pub const TIOCSCTTY: ::c_ulong = 0x5480; ++pub const TIOCGPGRP: ::c_ulong = 0x40047477; ++pub const TIOCSPGRP: ::c_ulong = 0x80047476; ++pub const TIOCOUTQ: ::c_ulong = 0x7472; ++pub const TIOCSTI: ::c_ulong = 0x5472; ++pub const TIOCGWINSZ: ::c_ulong = 0x40087468; ++pub const TIOCSWINSZ: ::c_ulong = 0x80087467; ++pub const TIOCMGET: ::c_ulong = 0x741d; ++pub const TIOCMBIS: ::c_ulong = 0x741b; ++pub const TIOCMBIC: ::c_ulong = 0x741c; ++pub const TIOCMSET: ::c_ulong = 0x741a; ++pub const FIONREAD: ::c_ulong = 0x467f; ++pub const TIOCCONS: ::c_ulong = 0x80047478; ++ ++pub const RTLD_DEEPBIND: ::c_int = 0x10; ++pub const RTLD_GLOBAL: ::c_int = 0x4; ++pub const RTLD_NOLOAD: ::c_int = 0x8; ++ ++pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; ++pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793; ++pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278; ++pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448; ++pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216; ++ ++pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567; ++pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123; ++pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF; ++pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000; ++pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC; ++pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4; ++pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2; ++pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const SIGSTKSZ: ::size_t = 8192; ++pub const MINSIGSTKSZ: ::size_t = 2048; ++pub const CBAUD: ::tcflag_t = 0o0010017; ++pub const TAB1: ::c_int = 0x00000800; ++pub const TAB2: ::c_int = 0x00001000; ++pub const TAB3: ::c_int = 0x00001800; ++pub const CR1: ::c_int = 0x00000200; ++pub const CR2: ::c_int = 0x00000400; ++pub const CR3: ::c_int = 0x00000600; ++pub const FF1: ::c_int = 0x00008000; ++pub const BS1: ::c_int = 0x00002000; ++pub const VT1: ::c_int = 0x00004000; ++pub const VWERASE: usize = 14; ++pub const VREPRINT: usize = 12; ++pub const VSUSP: usize = 10; ++pub const VSTART: usize = 8; ++pub const VSTOP: usize = 9; ++pub const VDISCARD: usize = 13; ++pub const VTIME: usize = 5; ++pub const IXON: ::tcflag_t = 0x00000400; ++pub const IXOFF: ::tcflag_t = 0x00001000; ++pub const ONLCR: ::tcflag_t = 0x4; ++pub const CSIZE: ::tcflag_t = 0x00000030; ++pub const CS6: ::tcflag_t = 0x00000010; ++pub const CS7: ::tcflag_t = 0x00000020; ++pub const CS8: ::tcflag_t = 0x00000030; ++pub const CSTOPB: ::tcflag_t = 0x00000040; ++pub const CREAD: ::tcflag_t = 0x00000080; ++pub const PARENB: ::tcflag_t = 0x00000100; ++pub const PARODD: ::tcflag_t = 0x00000200; ++pub const HUPCL: ::tcflag_t = 0x00000400; ++pub const CLOCAL: ::tcflag_t = 0x00000800; ++pub const ECHOKE: ::tcflag_t = 0x00000800; ++pub const ECHOE: ::tcflag_t = 0x00000010; ++pub const ECHOK: ::tcflag_t = 0x00000020; ++pub const ECHONL: ::tcflag_t = 0x00000040; ++pub const ECHOPRT: ::tcflag_t = 0x00000400; ++pub const ECHOCTL: ::tcflag_t = 0x00000200; ++pub const ISIG: ::tcflag_t = 0x00000001; ++pub const ICANON: ::tcflag_t = 0x00000002; ++pub const PENDIN: ::tcflag_t = 0x00004000; ++pub const NOFLSH: ::tcflag_t = 0x00000080; ++pub const CIBAUD: ::tcflag_t = 0o02003600000; ++pub const CBAUDEX: ::tcflag_t = 0o010000; ++pub const VSWTC: usize = 7; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const XTABS: ::tcflag_t = 0o014000; ++ ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const B57600: ::speed_t = 0o010001; ++pub const B115200: ::speed_t = 0o010002; ++pub const B230400: ::speed_t = 0o010003; ++pub const B460800: ::speed_t = 0o010004; ++pub const B500000: ::speed_t = 0o010005; ++pub const B576000: ::speed_t = 0o010006; ++pub const B921600: ::speed_t = 0o010007; ++pub const B1000000: ::speed_t = 0o010010; ++pub const B1152000: ::speed_t = 0o010011; ++pub const B1500000: ::speed_t = 0o010012; ++pub const B2000000: ::speed_t = 0o010013; ++pub const B2500000: ::speed_t = 0o010014; ++pub const B3000000: ::speed_t = 0o010015; ++pub const B3500000: ::speed_t = 0o010016; ++pub const B4000000: ::speed_t = 0o010017; ++ ++pub const TIOCM_LE: ::c_int = 0x001; ++pub const TIOCM_DTR: ::c_int = 0x002; ++pub const TIOCM_RTS: ::c_int = 0x004; ++pub const TIOCM_ST: ::c_int = 0x010; ++pub const TIOCM_SR: ::c_int = 0x020; ++pub const TIOCM_CTS: ::c_int = 0x040; ++pub const TIOCM_CAR: ::c_int = 0x100; ++pub const TIOCM_CD: ::c_int = TIOCM_CAR; ++pub const TIOCM_RNG: ::c_int = 0x200; ++pub const TIOCM_RI: ::c_int = TIOCM_RNG; ++pub const TIOCM_DSR: ::c_int = 0x400; ++ ++pub const EHWPOISON: ::c_int = 168; ++pub const SIGEV_THREAD_ID: ::c_int = 4; ++pub const EPOLLWAKEUP: ::c_int = 0x20000000; ++ ++#[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 ::c_int>, ++ pglob: *mut glob64_t) -> ::c_int; ++ pub fn globfree64(pglob: *mut glob64_t); ++ pub fn ptrace(request: ::c_uint, ...) -> ::c_long; ++ pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t, ++ cpusetsize: ::size_t, ++ cpuset: *mut ::cpu_set_t) -> ::c_int; ++ pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t, ++ cpusetsize: ::size_t, ++ cpuset: *const ::cpu_set_t) -> ::c_int; ++ pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int; ++ pub fn setpriority(which: ::__priority_which_t, who: ::id_t, ++ prio: ::c_int) -> ::c_int; ++ pub fn pthread_getaffinity_np(thread: ::pthread_t, ++ cpusetsize: ::size_t, ++ cpuset: *mut ::cpu_set_t) -> ::c_int; ++ pub fn pthread_setaffinity_np(thread: ::pthread_t, ++ cpusetsize: ::size_t, ++ cpuset: *const ::cpu_set_t) -> ::c_int; ++ pub fn sched_getcpu() -> ::c_int; ++} ++ ++cfg_if! { ++ if #[cfg(target_arch = "mips")] { ++ mod mips32; ++ pub use self::mips32::*; ++ } else if #[cfg(target_arch = "mips64")] { ++ mod mips64; ++ pub use self::mips64::*; ++ } else { ++ // Unknown target_arch ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/mod.rs index 000000000,000000000..1e0856b0b new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/mod.rs @@@ -1,0 -1,0 +1,1469 @@@ ++//! Linux-specific definitions for linux-like values ++ ++use dox::{mem, Option}; ++ ++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 type idtype_t = ::c_uint; ++pub type loff_t = ::c_longlong; ++ ++pub type __u8 = ::c_uchar; ++pub type __u16 = ::c_ushort; ++pub type __s16 = ::c_short; ++pub type __u32 = ::c_uint; ++pub type __s32 = ::c_int; ++ ++pub 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 = "arm", ++ target_arch = "powerpc"))] ++ __align: [::c_long; 0], ++ #[cfg(not(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc")))] ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_MUTEX_T], ++ } ++ ++ pub struct pthread_rwlock_t { ++ #[cfg(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc"))] ++ __align: [::c_long; 0], ++ #[cfg(not(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc")))] ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], ++ } ++ ++ pub struct pthread_mutexattr_t { ++ #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", ++ target_arch = "mips64", target_arch = "s390x", ++ target_arch = "sparc64"))] ++ __align: [::c_int; 0], ++ #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", ++ target_arch = "mips64", target_arch = "s390x", ++ target_arch = "sparc64")))] ++ __align: [::c_long; 0], ++ size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], ++ } ++ ++ pub struct pthread_rwlockattr_t { ++ #[cfg(any(target_env = "musl"))] ++ __align: [::c_int; 0], ++ #[cfg(not(any(target_env = "musl")))] ++ __align: [::c_long; 0], ++ size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_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 itimerspec { ++ pub it_interval: ::timespec, ++ pub it_value: ::timespec, ++ } ++ ++ 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 struct mmsghdr { ++ pub msg_hdr: ::msghdr, ++ pub msg_len: ::c_uint, ++ } ++ ++ pub struct sembuf { ++ pub sem_num: ::c_ushort, ++ pub sem_op: ::c_short, ++ pub sem_flg: ::c_short, ++ } ++ ++ pub struct input_event { ++ pub time: ::timeval, ++ pub type_: ::__u16, ++ pub code: ::__u16, ++ pub value: ::__s32, ++ } ++ ++ pub struct input_id { ++ pub bustype: ::__u16, ++ pub vendor: ::__u16, ++ pub product: ::__u16, ++ pub version: ::__u16, ++ } ++ ++ pub struct input_absinfo { ++ pub value: ::__s32, ++ pub minimum: ::__s32, ++ pub maximum: ::__s32, ++ pub fuzz: ::__s32, ++ pub flat: ::__s32, ++ pub resolution: ::__s32, ++ } ++ ++ pub struct input_keymap_entry { ++ pub flags: ::__u8, ++ pub len: ::__u8, ++ pub index: ::__u16, ++ pub keycode: ::__u32, ++ pub scancode: [::__u8; 32], ++ } ++ ++ pub struct input_mask { ++ pub type_: ::__u32, ++ pub codes_size: ::__u32, ++ pub codes_ptr: ::__u64, ++ } ++ ++ pub struct ff_replay { ++ pub length: ::__u16, ++ pub delay: ::__u16, ++ } ++ ++ pub struct ff_trigger { ++ pub button: ::__u16, ++ pub interval: ::__u16, ++ } ++ ++ pub struct ff_envelope { ++ pub attack_length: ::__u16, ++ pub attack_level: ::__u16, ++ pub fade_length: ::__u16, ++ pub fade_level: ::__u16, ++ } ++ ++ pub struct ff_constant_effect { ++ pub level: ::__s16, ++ pub envelope: ff_envelope, ++ } ++ ++ pub struct ff_ramp_effect { ++ pub start_level: ::__s16, ++ pub end_level: ::__s16, ++ pub envelope: ff_envelope, ++ } ++ ++ pub struct ff_condition_effect { ++ pub right_saturation: ::__u16, ++ pub left_saturation: ::__u16, ++ ++ pub right_coeff: ::__s16, ++ pub left_coeff: ::__s16, ++ ++ pub deadband: ::__u16, ++ pub center: ::__s16, ++ } ++ ++ pub struct ff_periodic_effect { ++ pub waveform: ::__u16, ++ pub period: ::__u16, ++ pub magnitude: ::__s16, ++ pub offset: ::__s16, ++ pub phase: ::__u16, ++ ++ pub envelope: ff_envelope, ++ ++ pub custom_len: ::__u32, ++ pub custom_data: *mut ::__s16, ++ } ++ ++ pub struct ff_rumble_effect { ++ pub strong_magnitude: ::__u16, ++ pub weak_magnitude: ::__u16, ++ } ++ ++ pub struct ff_effect { ++ pub type_: ::__u16, ++ pub id: ::__s16, ++ pub direction: ::__u16, ++ pub trigger: ff_trigger, ++ pub replay: ff_replay, ++ // FIXME this is actually a union ++ #[cfg(target_pointer_width = "64")] ++ pub u: [u64; 4], ++ #[cfg(target_pointer_width = "32")] ++ pub u: [u32; 7], ++ } ++} ++ ++pub const ABDAY_1: ::nl_item = 0x20000; ++pub const ABDAY_2: ::nl_item = 0x20001; ++pub const ABDAY_3: ::nl_item = 0x20002; ++pub const ABDAY_4: ::nl_item = 0x20003; ++pub const ABDAY_5: ::nl_item = 0x20004; ++pub const ABDAY_6: ::nl_item = 0x20005; ++pub const ABDAY_7: ::nl_item = 0x20006; ++ ++pub const DAY_1: ::nl_item = 0x20007; ++pub const DAY_2: ::nl_item = 0x20008; ++pub const DAY_3: ::nl_item = 0x20009; ++pub const DAY_4: ::nl_item = 0x2000A; ++pub const DAY_5: ::nl_item = 0x2000B; ++pub const DAY_6: ::nl_item = 0x2000C; ++pub const DAY_7: ::nl_item = 0x2000D; ++ ++pub const ABMON_1: ::nl_item = 0x2000E; ++pub const ABMON_2: ::nl_item = 0x2000F; ++pub const ABMON_3: ::nl_item = 0x20010; ++pub const ABMON_4: ::nl_item = 0x20011; ++pub const ABMON_5: ::nl_item = 0x20012; ++pub const ABMON_6: ::nl_item = 0x20013; ++pub const ABMON_7: ::nl_item = 0x20014; ++pub const ABMON_8: ::nl_item = 0x20015; ++pub const ABMON_9: ::nl_item = 0x20016; ++pub const ABMON_10: ::nl_item = 0x20017; ++pub const ABMON_11: ::nl_item = 0x20018; ++pub const ABMON_12: ::nl_item = 0x20019; ++ ++pub const MON_1: ::nl_item = 0x2001A; ++pub const MON_2: ::nl_item = 0x2001B; ++pub const MON_3: ::nl_item = 0x2001C; ++pub const MON_4: ::nl_item = 0x2001D; ++pub const MON_5: ::nl_item = 0x2001E; ++pub const MON_6: ::nl_item = 0x2001F; ++pub const MON_7: ::nl_item = 0x20020; ++pub const MON_8: ::nl_item = 0x20021; ++pub const MON_9: ::nl_item = 0x20022; ++pub const MON_10: ::nl_item = 0x20023; ++pub const MON_11: ::nl_item = 0x20024; ++pub const MON_12: ::nl_item = 0x20025; ++ ++pub const AM_STR: ::nl_item = 0x20026; ++pub const PM_STR: ::nl_item = 0x20027; ++ ++pub const D_T_FMT: ::nl_item = 0x20028; ++pub const D_FMT: ::nl_item = 0x20029; ++pub const T_FMT: ::nl_item = 0x2002A; ++pub const T_FMT_AMPM: ::nl_item = 0x2002B; ++ ++pub const ERA: ::nl_item = 0x2002C; ++pub const ERA_D_FMT: ::nl_item = 0x2002E; ++pub const ALT_DIGITS: ::nl_item = 0x2002F; ++pub const ERA_D_T_FMT: ::nl_item = 0x20030; ++pub const ERA_T_FMT: ::nl_item = 0x20031; ++ ++pub const CODESET: ::nl_item = 14; ++ ++pub const CRNCYSTR: ::nl_item = 0x4000F; ++ ++pub const RUSAGE_THREAD: ::c_int = 1; ++pub const RUSAGE_CHILDREN: ::c_int = -1; ++ ++pub const RADIXCHAR: ::nl_item = 0x10000; ++pub const THOUSEP: ::nl_item = 0x10001; ++ ++pub const YESEXPR: ::nl_item = 0x50000; ++pub const NOEXPR: ::nl_item = 0x50001; ++pub const YESSTR: ::nl_item = 0x50002; ++pub const NOSTR: ::nl_item = 0x50003; ++ ++pub const FILENAME_MAX: ::c_uint = 4096; ++pub const L_tmpnam: ::c_uint = 20; ++pub const _PC_LINK_MAX: ::c_int = 0; ++pub const _PC_MAX_CANON: ::c_int = 1; ++pub const _PC_MAX_INPUT: ::c_int = 2; ++pub const _PC_NAME_MAX: ::c_int = 3; ++pub const _PC_PATH_MAX: ::c_int = 4; ++pub const _PC_PIPE_BUF: ::c_int = 5; ++pub const _PC_CHOWN_RESTRICTED: ::c_int = 6; ++pub const _PC_NO_TRUNC: ::c_int = 7; ++pub const _PC_VDISABLE: ::c_int = 8; ++pub const _PC_SYNC_IO: ::c_int = 9; ++pub const _PC_ASYNC_IO: ::c_int = 10; ++pub const _PC_PRIO_IO: ::c_int = 11; ++pub const _PC_SOCK_MAXBUF: ::c_int = 12; ++pub const _PC_FILESIZEBITS: ::c_int = 13; ++pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14; ++pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15; ++pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16; ++pub const _PC_REC_XFER_ALIGN: ::c_int = 17; ++pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18; ++pub const _PC_SYMLINK_MAX: ::c_int = 19; ++pub const _PC_2_SYMLINKS: ::c_int = 20; ++ ++pub const _SC_ARG_MAX: ::c_int = 0; ++pub const _SC_CHILD_MAX: ::c_int = 1; ++pub const _SC_CLK_TCK: ::c_int = 2; ++pub const _SC_NGROUPS_MAX: ::c_int = 3; ++pub const _SC_OPEN_MAX: ::c_int = 4; ++pub const _SC_STREAM_MAX: ::c_int = 5; ++pub const _SC_TZNAME_MAX: ::c_int = 6; ++pub const _SC_JOB_CONTROL: ::c_int = 7; ++pub const _SC_SAVED_IDS: ::c_int = 8; ++pub const _SC_REALTIME_SIGNALS: ::c_int = 9; ++pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; ++pub const _SC_TIMERS: ::c_int = 11; ++pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; ++pub const _SC_PRIORITIZED_IO: ::c_int = 13; ++pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; ++pub const _SC_FSYNC: ::c_int = 15; ++pub const _SC_MAPPED_FILES: ::c_int = 16; ++pub const _SC_MEMLOCK: ::c_int = 17; ++pub const _SC_MEMLOCK_RANGE: ::c_int = 18; ++pub const _SC_MEMORY_PROTECTION: ::c_int = 19; ++pub const _SC_MESSAGE_PASSING: ::c_int = 20; ++pub const _SC_SEMAPHORES: ::c_int = 21; ++pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; ++pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; ++pub const _SC_AIO_MAX: ::c_int = 24; ++pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; ++pub const _SC_DELAYTIMER_MAX: ::c_int = 26; ++pub const _SC_MQ_OPEN_MAX: ::c_int = 27; ++pub const _SC_MQ_PRIO_MAX: ::c_int = 28; ++pub const _SC_VERSION: ::c_int = 29; ++pub const _SC_PAGESIZE: ::c_int = 30; ++pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; ++pub const _SC_RTSIG_MAX: ::c_int = 31; ++pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; ++pub const _SC_SEM_VALUE_MAX: ::c_int = 33; ++pub const _SC_SIGQUEUE_MAX: ::c_int = 34; ++pub const _SC_TIMER_MAX: ::c_int = 35; ++pub const _SC_BC_BASE_MAX: ::c_int = 36; ++pub const _SC_BC_DIM_MAX: ::c_int = 37; ++pub const _SC_BC_SCALE_MAX: ::c_int = 38; ++pub const _SC_BC_STRING_MAX: ::c_int = 39; ++pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; ++pub const _SC_EXPR_NEST_MAX: ::c_int = 42; ++pub const _SC_LINE_MAX: ::c_int = 43; ++pub const _SC_RE_DUP_MAX: ::c_int = 44; ++pub const _SC_2_VERSION: ::c_int = 46; ++pub const _SC_2_C_BIND: ::c_int = 47; ++pub const _SC_2_C_DEV: ::c_int = 48; ++pub const _SC_2_FORT_DEV: ::c_int = 49; ++pub const _SC_2_FORT_RUN: ::c_int = 50; ++pub const _SC_2_SW_DEV: ::c_int = 51; ++pub const _SC_2_LOCALEDEF: ::c_int = 52; ++pub const _SC_UIO_MAXIOV: ::c_int = 60; ++pub const _SC_IOV_MAX: ::c_int = 60; ++pub const _SC_THREADS: ::c_int = 67; ++pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; ++pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; ++pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; ++pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; ++pub const _SC_TTY_NAME_MAX: ::c_int = 72; ++pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; ++pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; ++pub const _SC_THREAD_STACK_MIN: ::c_int = 75; ++pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; ++pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; ++pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; ++pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; ++pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; ++pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; ++pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82; ++pub const _SC_NPROCESSORS_CONF: ::c_int = 83; ++pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; ++pub const _SC_PHYS_PAGES: ::c_int = 85; ++pub const _SC_AVPHYS_PAGES: ::c_int = 86; ++pub const _SC_ATEXIT_MAX: ::c_int = 87; ++pub const _SC_PASS_MAX: ::c_int = 88; ++pub const _SC_XOPEN_VERSION: ::c_int = 89; ++pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; ++pub const _SC_XOPEN_UNIX: ::c_int = 91; ++pub const _SC_XOPEN_CRYPT: ::c_int = 92; ++pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; ++pub const _SC_XOPEN_SHM: ::c_int = 94; ++pub const _SC_2_CHAR_TERM: ::c_int = 95; ++pub const _SC_2_UPE: ::c_int = 97; ++pub const _SC_XOPEN_XPG2: ::c_int = 98; ++pub const _SC_XOPEN_XPG3: ::c_int = 99; ++pub const _SC_XOPEN_XPG4: ::c_int = 100; ++pub const _SC_NZERO: ::c_int = 109; ++pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; ++pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; ++pub const _SC_XBS5_LP64_OFF64: ::c_int = 127; ++pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; ++pub const _SC_XOPEN_LEGACY: ::c_int = 129; ++pub const _SC_XOPEN_REALTIME: ::c_int = 130; ++pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; ++pub const _SC_ADVISORY_INFO: ::c_int = 132; ++pub const _SC_BARRIERS: ::c_int = 133; ++pub const _SC_CLOCK_SELECTION: ::c_int = 137; ++pub const _SC_CPUTIME: ::c_int = 138; ++pub const _SC_THREAD_CPUTIME: ::c_int = 139; ++pub const _SC_MONOTONIC_CLOCK: ::c_int = 149; ++pub const _SC_READER_WRITER_LOCKS: ::c_int = 153; ++pub const _SC_SPIN_LOCKS: ::c_int = 154; ++pub const _SC_REGEXP: ::c_int = 155; ++pub const _SC_SHELL: ::c_int = 157; ++pub const _SC_SPAWN: ::c_int = 159; ++pub const _SC_SPORADIC_SERVER: ::c_int = 160; ++pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161; ++pub const _SC_TIMEOUTS: ::c_int = 164; ++pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165; ++pub const _SC_2_PBS: ::c_int = 168; ++pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169; ++pub const _SC_2_PBS_LOCATE: ::c_int = 170; ++pub const _SC_2_PBS_MESSAGE: ::c_int = 171; ++pub const _SC_2_PBS_TRACK: ::c_int = 172; ++pub const _SC_SYMLOOP_MAX: ::c_int = 173; ++pub const _SC_STREAMS: ::c_int = 174; ++pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175; ++pub const _SC_V6_ILP32_OFF32: ::c_int = 176; ++pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177; ++pub const _SC_V6_LP64_OFF64: ::c_int = 178; ++pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179; ++pub const _SC_HOST_NAME_MAX: ::c_int = 180; ++pub const _SC_TRACE: ::c_int = 181; ++pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182; ++pub const _SC_TRACE_INHERIT: ::c_int = 183; ++pub const _SC_TRACE_LOG: ::c_int = 184; ++pub const _SC_IPV6: ::c_int = 235; ++pub const _SC_RAW_SOCKETS: ::c_int = 236; ++pub const _SC_V7_ILP32_OFF32: ::c_int = 237; ++pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238; ++pub const _SC_V7_LP64_OFF64: ::c_int = 239; ++pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240; ++pub const _SC_SS_REPL_MAX: ::c_int = 241; ++pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242; ++pub const _SC_TRACE_NAME_MAX: ::c_int = 243; ++pub const _SC_TRACE_SYS_MAX: ::c_int = 244; ++pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245; ++pub const _SC_XOPEN_STREAMS: ::c_int = 246; ++pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247; ++pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248; ++ ++pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; ++pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; ++ ++pub const GLOB_ERR: ::c_int = 1 << 0; ++pub const GLOB_MARK: ::c_int = 1 << 1; ++pub const GLOB_NOSORT: ::c_int = 1 << 2; ++pub const GLOB_DOOFFS: ::c_int = 1 << 3; ++pub const GLOB_NOCHECK: ::c_int = 1 << 4; ++pub const GLOB_APPEND: ::c_int = 1 << 5; ++pub const GLOB_NOESCAPE: ::c_int = 1 << 6; ++ ++pub const GLOB_NOSPACE: ::c_int = 1; ++pub const GLOB_ABORTED: ::c_int = 2; ++pub const GLOB_NOMATCH: ::c_int = 3; ++ ++pub const POSIX_MADV_NORMAL: ::c_int = 0; ++pub const POSIX_MADV_RANDOM: ::c_int = 1; ++pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; ++pub const POSIX_MADV_WILLNEED: ::c_int = 3; ++ ++pub const S_IEXEC: mode_t = 64; ++pub const S_IWRITE: mode_t = 128; ++pub const S_IREAD: mode_t = 256; ++ ++pub const F_LOCK: ::c_int = 1; ++pub const F_TEST: ::c_int = 3; ++pub const F_TLOCK: ::c_int = 2; ++pub const F_ULOCK: ::c_int = 0; ++ ++pub const IFF_LOWER_UP: ::c_int = 0x10000; ++pub const IFF_DORMANT: ::c_int = 0x20000; ++pub const IFF_ECHO: ::c_int = 0x40000; ++ ++pub const ST_RDONLY: ::c_ulong = 1; ++pub const ST_NOSUID: ::c_ulong = 2; ++pub const ST_NODEV: ::c_ulong = 4; ++pub const ST_NOEXEC: ::c_ulong = 8; ++pub const ST_SYNCHRONOUS: ::c_ulong = 16; ++pub const ST_MANDLOCK: ::c_ulong = 64; ++pub const ST_WRITE: ::c_ulong = 128; ++pub const ST_APPEND: ::c_ulong = 256; ++pub const ST_IMMUTABLE: ::c_ulong = 512; ++pub const ST_NOATIME: ::c_ulong = 1024; ++pub const ST_NODIRATIME: ::c_ulong = 2048; ++ ++pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void; ++pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; ++pub const RTLD_NODELETE: ::c_int = 0x1000; ++pub const RTLD_NOW: ::c_int = 0x2; ++ ++pub const TCP_MD5SIG: ::c_int = 14; ++ ++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 PTHREAD_PROCESS_PRIVATE: ::c_int = 0; ++pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; ++pub const __SIZEOF_PTHREAD_COND_T: usize = 48; ++ ++pub const SCHED_OTHER: ::c_int = 0; ++pub const SCHED_FIFO: ::c_int = 1; ++pub const SCHED_RR: ::c_int = 2; ++pub const SCHED_BATCH: ::c_int = 3; ++pub const SCHED_IDLE: ::c_int = 5; ++ ++// netinet/in.h ++// NOTE: These are in addition to the constants defined in src/unix/mod.rs ++ ++// IPPROTO_IP defined in src/unix/mod.rs ++/// Hop-by-hop option header ++pub const IPPROTO_HOPOPTS: ::c_int = 0; ++// IPPROTO_ICMP defined in src/unix/mod.rs ++/// group mgmt protocol ++pub const IPPROTO_IGMP: ::c_int = 2; ++/// for compatibility ++pub const IPPROTO_IPIP: ::c_int = 4; ++// IPPROTO_TCP defined in src/unix/mod.rs ++/// exterior gateway protocol ++pub const IPPROTO_EGP: ::c_int = 8; ++/// pup ++pub const IPPROTO_PUP: ::c_int = 12; ++// IPPROTO_UDP defined in src/unix/mod.rs ++/// xns idp ++pub const IPPROTO_IDP: ::c_int = 22; ++/// tp-4 w/ class negotiation ++pub const IPPROTO_TP: ::c_int = 29; ++/// DCCP ++pub const IPPROTO_DCCP: ::c_int = 33; ++// IPPROTO_IPV6 defined in src/unix/mod.rs ++/// IP6 routing header ++pub const IPPROTO_ROUTING: ::c_int = 43; ++/// IP6 fragmentation header ++pub const IPPROTO_FRAGMENT: ::c_int = 44; ++/// resource reservation ++pub const IPPROTO_RSVP: ::c_int = 46; ++/// General Routing Encap. ++pub const IPPROTO_GRE: ::c_int = 47; ++/// IP6 Encap Sec. Payload ++pub const IPPROTO_ESP: ::c_int = 50; ++/// IP6 Auth Header ++pub const IPPROTO_AH: ::c_int = 51; ++// IPPROTO_ICMPV6 defined in src/unix/mod.rs ++/// IP6 no next header ++pub const IPPROTO_NONE: ::c_int = 59; ++/// IP6 destination option ++pub const IPPROTO_DSTOPTS: ::c_int = 60; ++pub const IPPROTO_MTP: ::c_int = 92; ++pub const IPPROTO_BEETPH: ::c_int = 94; ++/// encapsulation header ++pub const IPPROTO_ENCAP: ::c_int = 98; ++/// Protocol indep. multicast ++pub const IPPROTO_PIM: ::c_int = 103; ++/// IP Payload Comp. Protocol ++pub const IPPROTO_COMP: ::c_int = 108; ++/// SCTP ++pub const IPPROTO_SCTP: ::c_int = 132; ++pub const IPPROTO_MH: ::c_int = 135; ++pub const IPPROTO_UDPLITE: ::c_int = 136; ++pub const IPPROTO_MPLS: ::c_int = 137; ++/// raw IP packet ++pub const IPPROTO_RAW: ::c_int = 255; ++pub const IPPROTO_MAX: ::c_int = 256; ++ ++pub const AF_IB: ::c_int = 27; ++pub const AF_MPLS: ::c_int = 28; ++pub const AF_NFC: ::c_int = 39; ++pub const AF_VSOCK: ::c_int = 40; ++#[doc(hidden)] ++pub const AF_MAX: ::c_int = 42; ++pub const PF_IB: ::c_int = AF_IB; ++pub const PF_MPLS: ::c_int = AF_MPLS; ++pub const PF_NFC: ::c_int = AF_NFC; ++pub const PF_VSOCK: ::c_int = AF_VSOCK; ++#[doc(hidden)] ++pub const PF_MAX: ::c_int = AF_MAX; ++ ++// System V IPC ++pub const IPC_PRIVATE: ::key_t = 0; ++ ++pub const IPC_CREAT: ::c_int = 0o1000; ++pub const IPC_EXCL: ::c_int = 0o2000; ++pub const IPC_NOWAIT: ::c_int = 0o4000; ++ ++pub const IPC_RMID: ::c_int = 0; ++pub const IPC_SET: ::c_int = 1; ++pub const IPC_STAT: ::c_int = 2; ++pub const IPC_INFO: ::c_int = 3; ++pub const MSG_STAT: ::c_int = 11; ++pub const MSG_INFO: ::c_int = 12; ++ ++pub const MSG_NOERROR: ::c_int = 0o10000; ++pub const MSG_EXCEPT: ::c_int = 0o20000; ++pub const MSG_COPY: ::c_int = 0o40000; ++ ++pub const SHM_R: ::c_int = 0o400; ++pub const SHM_W: ::c_int = 0o200; ++ ++pub const SHM_RDONLY: ::c_int = 0o10000; ++pub const SHM_RND: ::c_int = 0o20000; ++pub const SHM_REMAP: ::c_int = 0o40000; ++pub const SHM_EXEC: ::c_int = 0o100000; ++ ++pub const SHM_LOCK: ::c_int = 11; ++pub const SHM_UNLOCK: ::c_int = 12; ++ ++pub const SHM_HUGETLB: ::c_int = 0o4000; ++pub const SHM_NORESERVE: ::c_int = 0o10000; ++ ++pub const EPOLLRDHUP: ::c_int = 0x2000; ++pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; ++pub const EPOLLONESHOT: ::c_int = 0x40000000; ++ ++pub const QFMT_VFS_OLD: ::c_int = 1; ++pub const QFMT_VFS_V0: ::c_int = 2; ++pub const QFMT_VFS_V1: ::c_int = 4; ++ ++pub const EFD_SEMAPHORE: ::c_int = 0x1; ++ ++pub const LOG_NFACILITIES: ::c_int = 24; ++ ++pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t; ++ ++pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32; ++pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32; ++pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32; ++pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32; ++pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32; ++pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32; ++pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32; ++ ++pub const AI_PASSIVE: ::c_int = 0x0001; ++pub const AI_CANONNAME: ::c_int = 0x0002; ++pub const AI_NUMERICHOST: ::c_int = 0x0004; ++pub const AI_V4MAPPED: ::c_int = 0x0008; ++pub const AI_ALL: ::c_int = 0x0010; ++pub const AI_ADDRCONFIG: ::c_int = 0x0020; ++ ++pub const AI_NUMERICSERV: ::c_int = 0x0400; ++ ++pub const EAI_BADFLAGS: ::c_int = -1; ++pub const EAI_NONAME: ::c_int = -2; ++pub const EAI_AGAIN: ::c_int = -3; ++pub const EAI_FAIL: ::c_int = -4; ++pub const EAI_FAMILY: ::c_int = -6; ++pub const EAI_SOCKTYPE: ::c_int = -7; ++pub const EAI_SERVICE: ::c_int = -8; ++pub const EAI_MEMORY: ::c_int = -10; ++pub const EAI_OVERFLOW: ::c_int = -12; ++ ++pub const NI_NUMERICHOST: ::c_int = 1; ++pub const NI_NUMERICSERV: ::c_int = 2; ++pub const NI_NOFQDN: ::c_int = 4; ++pub const NI_NAMEREQD: ::c_int = 8; ++pub const NI_DGRAM: ::c_int = 16; ++ ++pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1; ++pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2; ++pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4; ++ ++pub const EAI_SYSTEM: ::c_int = -11; ++ ++pub const AIO_CANCELED: ::c_int = 0; ++pub const AIO_NOTCANCELED: ::c_int = 1; ++pub const AIO_ALLDONE: ::c_int = 2; ++pub const LIO_READ: ::c_int = 0; ++pub const LIO_WRITE: ::c_int = 1; ++pub const LIO_NOP: ::c_int = 2; ++pub const LIO_WAIT: ::c_int = 0; ++pub const LIO_NOWAIT: ::c_int = 1; ++ ++pub const MREMAP_MAYMOVE: ::c_int = 1; ++pub const MREMAP_FIXED: ::c_int = 2; ++ ++pub const PR_SET_PDEATHSIG: ::c_int = 1; ++pub const PR_GET_PDEATHSIG: ::c_int = 2; ++ ++pub const PR_GET_DUMPABLE: ::c_int = 3; ++pub const PR_SET_DUMPABLE: ::c_int = 4; ++ ++pub const PR_GET_UNALIGN: ::c_int = 5; ++pub const PR_SET_UNALIGN: ::c_int = 6; ++pub const PR_UNALIGN_NOPRINT: ::c_int = 1; ++pub const PR_UNALIGN_SIGBUS: ::c_int = 2; ++ ++pub const PR_GET_KEEPCAPS: ::c_int = 7; ++pub const PR_SET_KEEPCAPS: ::c_int = 8; ++ ++pub const PR_GET_FPEMU: ::c_int = 9; ++pub const PR_SET_FPEMU: ::c_int = 10; ++pub const PR_FPEMU_NOPRINT: ::c_int = 1; ++pub const PR_FPEMU_SIGFPE: ::c_int = 2; ++ ++pub const PR_GET_FPEXC: ::c_int = 11; ++pub const PR_SET_FPEXC: ::c_int = 12; ++pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80; ++pub const PR_FP_EXC_DIV: ::c_int = 0x010000; ++pub const PR_FP_EXC_OVF: ::c_int = 0x020000; ++pub const PR_FP_EXC_UND: ::c_int = 0x040000; ++pub const PR_FP_EXC_RES: ::c_int = 0x080000; ++pub const PR_FP_EXC_INV: ::c_int = 0x100000; ++pub const PR_FP_EXC_DISABLED: ::c_int = 0; ++pub const PR_FP_EXC_NONRECOV: ::c_int = 1; ++pub const PR_FP_EXC_ASYNC: ::c_int = 2; ++pub const PR_FP_EXC_PRECISE: ::c_int = 3; ++ ++pub const PR_GET_TIMING: ::c_int = 13; ++pub const PR_SET_TIMING: ::c_int = 14; ++pub const PR_TIMING_STATISTICAL: ::c_int = 0; ++pub const PR_TIMING_TIMESTAMP: ::c_int = 1; ++ ++pub const PR_SET_NAME: ::c_int = 15; ++pub const PR_GET_NAME: ::c_int = 16; ++ ++pub const PR_GET_ENDIAN: ::c_int = 19; ++pub const PR_SET_ENDIAN: ::c_int = 20; ++pub const PR_ENDIAN_BIG: ::c_int = 0; ++pub const PR_ENDIAN_LITTLE: ::c_int = 1; ++pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2; ++ ++pub const PR_GET_SECCOMP: ::c_int = 21; ++pub const PR_SET_SECCOMP: ::c_int = 22; ++ ++pub const PR_CAPBSET_READ: ::c_int = 23; ++pub const PR_CAPBSET_DROP: ::c_int = 24; ++ ++pub const PR_GET_TSC: ::c_int = 25; ++pub const PR_SET_TSC: ::c_int = 26; ++pub const PR_TSC_ENABLE: ::c_int = 1; ++pub const PR_TSC_SIGSEGV: ::c_int = 2; ++ ++pub const PR_GET_SECUREBITS: ::c_int = 27; ++pub const PR_SET_SECUREBITS: ::c_int = 28; ++ ++pub const PR_SET_TIMERSLACK: ::c_int = 29; ++pub const PR_GET_TIMERSLACK: ::c_int = 30; ++ ++pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31; ++pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32; ++ ++pub const PR_MCE_KILL: ::c_int = 33; ++pub const PR_MCE_KILL_CLEAR: ::c_int = 0; ++pub const PR_MCE_KILL_SET: ::c_int = 1; ++ ++pub const PR_MCE_KILL_LATE: ::c_int = 0; ++pub const PR_MCE_KILL_EARLY: ::c_int = 1; ++pub const PR_MCE_KILL_DEFAULT: ::c_int = 2; ++ ++pub const PR_MCE_KILL_GET: ::c_int = 34; ++ ++pub const PR_SET_MM: ::c_int = 35; ++pub const PR_SET_MM_START_CODE: ::c_int = 1; ++pub const PR_SET_MM_END_CODE: ::c_int = 2; ++pub const PR_SET_MM_START_DATA: ::c_int = 3; ++pub const PR_SET_MM_END_DATA: ::c_int = 4; ++pub const PR_SET_MM_START_STACK: ::c_int = 5; ++pub const PR_SET_MM_START_BRK: ::c_int = 6; ++pub const PR_SET_MM_BRK: ::c_int = 7; ++pub const PR_SET_MM_ARG_START: ::c_int = 8; ++pub const PR_SET_MM_ARG_END: ::c_int = 9; ++pub const PR_SET_MM_ENV_START: ::c_int = 10; ++pub const PR_SET_MM_ENV_END: ::c_int = 11; ++pub const PR_SET_MM_AUXV: ::c_int = 12; ++pub const PR_SET_MM_EXE_FILE: ::c_int = 13; ++pub const PR_SET_MM_MAP: ::c_int = 14; ++pub const PR_SET_MM_MAP_SIZE: ::c_int = 15; ++ ++pub const PR_SET_PTRACER: ::c_int = 0x59616d61; ++ ++pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36; ++pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37; ++ ++pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38; ++pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39; ++ ++pub const PR_GET_TID_ADDRESS: ::c_int = 40; ++ ++pub const PR_SET_THP_DISABLE: ::c_int = 41; ++pub const PR_GET_THP_DISABLE: ::c_int = 42; ++ ++pub const PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43; ++pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44; ++ ++pub const PR_SET_FP_MODE: ::c_int = 45; ++pub const PR_GET_FP_MODE: ::c_int = 46; ++pub const PR_FP_MODE_FR: ::c_int = 1 << 0; ++pub const PR_FP_MODE_FRE: ::c_int = 1 << 1; ++ ++pub const PR_CAP_AMBIENT: ::c_int = 47; ++pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1; ++pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2; ++pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3; ++pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4; ++ ++pub const ITIMER_REAL: ::c_int = 0; ++pub const ITIMER_VIRTUAL: ::c_int = 1; ++pub const ITIMER_PROF: ::c_int = 2; ++ ++pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC; ++pub const TFD_NONBLOCK: ::c_int = O_NONBLOCK; ++pub const TFD_TIMER_ABSTIME: ::c_int = 1; ++ ++pub const XATTR_CREATE: ::c_int = 0x1; ++pub const XATTR_REPLACE: ::c_int = 0x2; ++ ++pub const _POSIX_VDISABLE: ::cc_t = 0; ++ ++pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; ++pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; ++pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08; ++pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10; ++pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20; ++pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40; ++ ++// On Linux, libc doesn't define this constant, libattr does instead. ++// We still define it for Linux as it's defined by libc on other platforms, ++// and it's mentioned in the man pages for getxattr and setxattr. ++pub const ENOATTR: ::c_int = ::ENODATA; ++ ++pub const SO_ORIGINAL_DST: ::c_int = 80; ++pub const IUTF8: ::tcflag_t = 0x00004000; ++pub const CMSPAR: ::tcflag_t = 0o10000000000; ++pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; ++ ++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 ++ } ++ ++ pub fn major(dev: ::dev_t) -> ::c_uint { ++ let mut major = 0; ++ major |= (dev & 0x00000000000fff00) >> 8; ++ major |= (dev & 0xfffff00000000000) >> 32; ++ major as ::c_uint ++ } ++ ++ pub fn minor(dev: ::dev_t) -> ::c_uint { ++ let mut minor = 0; ++ minor |= (dev & 0x00000000000000ff) >> 0; ++ minor |= (dev & 0x00000ffffff00000) >> 12; ++ minor as ::c_uint ++ } ++ ++ pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t { ++ let major = major as ::dev_t; ++ let minor = minor as ::dev_t; ++ let mut dev = 0; ++ dev |= (major & 0x00000fff) << 8; ++ dev |= (major & 0xfffff000) << 32; ++ dev |= (minor & 0x000000ff) << 0; ++ dev |= (minor & 0xffffff00) << 12; ++ dev ++ } ++} ++ ++extern { ++ pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; ++ pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; ++ pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; ++ pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; ++ pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb, ++ nitems: ::c_int, sevp: *mut ::sigevent) -> ::c_int; ++ ++ pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; ++ ++ pub fn setpwent(); ++ pub fn endpwent(); ++ pub fn getpwent() -> *mut passwd; ++ pub fn setspent(); ++ pub fn endspent(); ++ pub fn getspent() -> *mut spwd; ++ pub fn getspnam(__name: *const ::c_char) -> *mut spwd; ++ ++ pub fn shm_open(name: *const c_char, oflag: ::c_int, ++ mode: mode_t) -> ::c_int; ++ ++ // System V IPC ++ pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; ++ pub fn shmat(shmid: ::c_int, ++ shmaddr: *const ::c_void, ++ shmflg: ::c_int) -> *mut ::c_void; ++ pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; ++ pub fn shmctl(shmid: ::c_int, ++ cmd: ::c_int, ++ buf: *mut ::shmid_ds) -> ::c_int; ++ pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t; ++ pub fn semget(key: ::key_t, nsems: ::c_int, semflag: ::c_int) -> ::c_int; ++ pub fn semop(semid: ::c_int, ++ sops: *mut ::sembuf, nsops: ::size_t) -> ::c_int; ++ pub fn semctl(semid: ::c_int, ++ semnum: ::c_int, cmd: ::c_int, ...) -> ::c_int; ++ pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int; ++ pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; ++ pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t, ++ msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t; ++ pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t, ++ msgflg: ::c_int) -> ::c_int; ++ ++ pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) ++ -> ::c_int; ++ pub fn __errno_location() -> *mut ::c_int; ++ ++ pub fn fopen64(filename: *const c_char, ++ mode: *const c_char) -> *mut ::FILE; ++ pub fn freopen64(filename: *const c_char, mode: *const c_char, ++ file: *mut ::FILE) -> *mut ::FILE; ++ pub fn tmpfile64() -> *mut ::FILE; ++ pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int; ++ pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int; ++ pub fn fseeko64(stream: *mut ::FILE, ++ offset: ::off64_t, ++ whence: ::c_int) -> ::c_int; ++ pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; ++ pub fn fallocate(fd: ::c_int, mode: ::c_int, ++ offset: ::off_t, len: ::off_t) -> ::c_int; ++ pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, ++ len: ::off_t) -> ::c_int; ++ pub fn readahead(fd: ::c_int, offset: ::off64_t, ++ count: ::size_t) -> ::ssize_t; ++ pub fn getxattr(path: *const c_char, name: *const c_char, ++ value: *mut ::c_void, size: ::size_t) -> ::ssize_t; ++ pub fn lgetxattr(path: *const c_char, name: *const c_char, ++ value: *mut ::c_void, size: ::size_t) -> ::ssize_t; ++ pub fn fgetxattr(filedes: ::c_int, name: *const c_char, ++ value: *mut ::c_void, size: ::size_t) -> ::ssize_t; ++ pub fn setxattr(path: *const c_char, name: *const c_char, ++ value: *const ::c_void, size: ::size_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn lsetxattr(path: *const c_char, name: *const c_char, ++ value: *const ::c_void, size: ::size_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn fsetxattr(filedes: ::c_int, name: *const c_char, ++ value: *const ::c_void, size: ::size_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn listxattr(path: *const c_char, list: *mut c_char, ++ size: ::size_t) -> ::ssize_t; ++ pub fn llistxattr(path: *const c_char, list: *mut c_char, ++ size: ::size_t) -> ::ssize_t; ++ pub fn flistxattr(filedes: ::c_int, list: *mut c_char, ++ size: ::size_t) -> ::ssize_t; ++ pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int; ++ pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int; ++ pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int; ++ pub fn signalfd(fd: ::c_int, ++ mask: *const ::sigset_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn timerfd_create(clockid: ::c_int, flags: ::c_int) -> ::c_int; ++ pub fn timerfd_gettime(fd: ::c_int, ++ curr_value: *mut itimerspec) -> ::c_int; ++ pub fn timerfd_settime(fd: ::c_int, ++ flags: ::c_int, ++ new_value: *const itimerspec, ++ old_value: *mut itimerspec) -> ::c_int; ++ pub fn pwritev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int, ++ offset: ::off_t) -> ::ssize_t; ++ pub fn preadv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int, ++ offset: ::off_t) -> ::ssize_t; ++ pub fn quotactl(cmd: ::c_int, ++ special: *const ::c_char, ++ id: ::c_int, ++ data: *mut ::c_char) -> ::c_int; ++ pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; ++ pub fn mq_close(mqd: ::mqd_t) -> ::c_int; ++ pub fn mq_unlink(name: *const ::c_char) -> ::c_int; ++ pub fn mq_receive(mqd: ::mqd_t, ++ msg_ptr: *mut ::c_char, ++ msg_len: ::size_t, ++ msq_prio: *mut ::c_uint) -> ::ssize_t; ++ pub fn mq_send(mqd: ::mqd_t, ++ msg_ptr: *const ::c_char, ++ msg_len: ::size_t, ++ msq_prio: ::c_uint) -> ::c_int; ++ pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; ++ pub fn mq_setattr(mqd: ::mqd_t, ++ newattr: *const ::mq_attr, ++ oldattr: *mut ::mq_attr) -> ::c_int; ++ pub fn epoll_pwait(epfd: ::c_int, ++ events: *mut ::epoll_event, ++ maxevents: ::c_int, ++ timeout: ::c_int, ++ sigmask: *const ::sigset_t) -> ::c_int; ++ pub fn dup3(oldfd: ::c_int, newfd: ::c_int, flags: ::c_int) -> ::c_int; ++ pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; ++ pub fn mkostemps(template: *mut ::c_char, ++ suffixlen: ::c_int, ++ flags: ::c_int) -> ::c_int; ++ pub fn sigtimedwait(set: *const sigset_t, ++ info: *mut siginfo_t, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn sigwaitinfo(set: *const sigset_t, ++ info: *mut siginfo_t) -> ::c_int; ++ pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; ++ pub fn getnameinfo(sa: *const ::sockaddr, ++ salen: ::socklen_t, ++ host: *mut ::c_char, ++ hostlen: ::socklen_t, ++ serv: *mut ::c_char, ++ sevlen: ::socklen_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn pthread_setschedprio(native: ::pthread_t, ++ priority: ::c_int) -> ::c_int; ++ pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit, ++ old_limit: *mut ::rlimit) -> ::c_int; ++ pub fn prlimit64(pid: ::pid_t, ++ resource: ::c_int, ++ new_limit: *const ::rlimit64, ++ old_limit: *mut ::rlimit64) -> ::c_int; ++ pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; ++ pub fn process_vm_readv(pid: ::pid_t, ++ local_iov: *const ::iovec, ++ liovcnt: ::c_ulong, ++ remote_iov: *const ::iovec, ++ riovcnt: ::c_ulong, ++ flags: ::c_ulong) -> isize; ++ pub fn process_vm_writev(pid: ::pid_t, ++ local_iov: *const ::iovec, ++ liovcnt: ::c_ulong, ++ remote_iov: *const ::iovec, ++ riovcnt: ::c_ulong, ++ flags: ::c_ulong) -> isize; ++ pub fn reboot(how_to: ::c_int) -> ::c_int; ++ pub fn setfsgid(gid: ::gid_t) -> ::c_int; ++ pub fn setfsuid(uid: ::uid_t) -> ::c_int; ++ ++ // Not available now on Android ++ pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t) -> ::c_int; ++ pub fn if_nameindex() -> *mut if_nameindex; ++ pub fn if_freenameindex(ptr: *mut if_nameindex); ++ pub fn sync_file_range(fd: ::c_int, offset: ::off64_t, ++ nbytes: ::off64_t, flags: ::c_uint) -> ::c_int; ++ pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; ++ pub fn freeifaddrs(ifa: *mut ::ifaddrs); ++ ++ pub fn mremap(addr: *mut ::c_void, ++ len: ::size_t, ++ new_len: ::size_t, ++ flags: ::c_int, ++ ...) -> *mut ::c_void; ++ ++ pub fn glob(pattern: *const c_char, ++ flags: ::c_int, ++ errfunc: Option ::c_int>, ++ pglob: *mut ::glob_t) -> ::c_int; ++ pub fn globfree(pglob: *mut ::glob_t); ++ ++ pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) ++ -> ::c_int; ++ ++ pub fn shm_unlink(name: *const ::c_char) -> ::c_int; ++ ++ pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); ++ ++ pub fn telldir(dirp: *mut ::DIR) -> ::c_long; ++ pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) ++ -> ::c_int; ++ ++ pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; ++ ++ pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, ++ flags: ::c_int, addr: *mut ::sockaddr, ++ addrlen: *mut ::socklen_t) -> ::ssize_t; ++ pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; ++ pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; ++ pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; ++ ++ pub fn bind(socket: ::c_int, address: *const ::sockaddr, ++ address_len: ::socklen_t) -> ::c_int; ++ ++ pub fn writev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ pub fn readv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ ++ pub fn sendmsg(fd: ::c_int, ++ msg: *const ::msghdr, ++ flags: ::c_int) -> ::ssize_t; ++ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) ++ -> ::ssize_t; ++ pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; ++ pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; ++ pub fn vhangup() -> ::c_int; ++ pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint, ++ flags: ::c_int) -> ::c_int; ++ pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint, ++ flags: ::c_int, timeout: *mut ::timespec) -> ::c_int; ++ pub fn sync(); ++ pub fn syscall(num: ::c_long, ...) -> ::c_long; ++ pub fn sched_getaffinity(pid: ::pid_t, ++ cpusetsize: ::size_t, ++ cpuset: *mut cpu_set_t) -> ::c_int; ++ pub fn sched_setaffinity(pid: ::pid_t, ++ cpusetsize: ::size_t, ++ cpuset: *const cpu_set_t) -> ::c_int; ++ pub fn epoll_create(size: ::c_int) -> ::c_int; ++ pub fn epoll_create1(flags: ::c_int) -> ::c_int; ++ pub fn epoll_wait(epfd: ::c_int, ++ events: *mut ::epoll_event, ++ maxevents: ::c_int, ++ timeout: ::c_int) -> ::c_int; ++ pub fn epoll_ctl(epfd: ::c_int, ++ op: ::c_int, ++ fd: ::c_int, ++ event: *mut ::epoll_event) -> ::c_int; ++ pub fn pthread_getschedparam(native: ::pthread_t, ++ policy: *mut ::c_int, ++ param: *mut ::sched_param) -> ::c_int; ++ pub fn unshare(flags: ::c_int) -> ::c_int; ++ pub fn umount(target: *const ::c_char) -> ::c_int; ++ pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; ++ pub fn tee(fd_in: ::c_int, ++ fd_out: ::c_int, ++ len: ::size_t, ++ flags: ::c_uint) -> ::ssize_t; ++ pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; ++ pub fn splice(fd_in: ::c_int, ++ off_in: *mut ::loff_t, ++ fd_out: ::c_int, ++ off_out: *mut ::loff_t, ++ len: ::size_t, ++ flags: ::c_uint) -> ::ssize_t; ++ pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; ++ pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int; ++ pub fn sem_timedwait(sem: *mut sem_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int; ++ pub fn setns(fd: ::c_int, nstype: ::c_int) -> ::c_int; ++ pub fn swapoff(puath: *const ::c_char) -> ::c_int; ++ pub fn vmsplice(fd: ::c_int, ++ iov: *const ::iovec, ++ nr_segs: ::size_t, ++ flags: ::c_uint) -> ::ssize_t; ++ pub fn mount(src: *const ::c_char, ++ target: *const ::c_char, ++ fstype: *const ::c_char, ++ flags: ::c_ulong, ++ data: *const ::c_void) -> ::c_int; ++ pub fn personality(persona: ::c_ulong) -> ::c_int; ++ pub fn prctl(option: ::c_int, ...) -> ::c_int; ++ pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int; ++ pub fn ppoll(fds: *mut ::pollfd, ++ nfds: nfds_t, ++ timeout: *const ::timespec, ++ sigmask: *const sigset_t) -> ::c_int; ++ pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int, ++ child_stack: *mut ::c_void, ++ flags: ::c_int, ++ arg: *mut ::c_void, ...) -> ::c_int; ++ pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; ++ pub fn clock_nanosleep(clk_id: ::clockid_t, ++ flags: ::c_int, ++ rqtp: *const ::timespec, ++ rmtp: *mut ::timespec) -> ::c_int; ++ pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, ++ guardsize: *mut ::size_t) -> ::c_int; ++ pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; ++ pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; ++ pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, ++ pshared: *mut ::c_int) -> ::c_int; ++ pub fn sysinfo(info: *mut ::sysinfo) -> ::c_int; ++ pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; ++ pub fn pthread_setschedparam(native: ::pthread_t, ++ policy: ::c_int, ++ param: *const ::sched_param) -> ::c_int; ++ pub fn swapon(path: *const ::c_char, swapflags: ::c_int) -> ::c_int; ++ pub fn sched_setscheduler(pid: ::pid_t, ++ policy: ::c_int, ++ param: *const ::sched_param) -> ::c_int; ++ pub fn sendfile(out_fd: ::c_int, ++ in_fd: ::c_int, ++ offset: *mut off_t, ++ count: ::size_t) -> ::ssize_t; ++ pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] ++ pub fn getgrgid_r(uid: ::uid_t, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "sigaltstack$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] ++ pub fn sigaltstack(ss: *const stack_t, ++ oss: *mut stack_t) -> ::c_int; ++ pub fn sem_close(sem: *mut sem_t) -> ::c_int; ++ pub fn getdtablesize() -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] ++ pub fn getgrnam_r(name: *const ::c_char, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_sigmask$UNIX2003")] ++ pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, ++ oldset: *mut sigset_t) -> ::c_int; ++ pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; ++ pub fn getgrnam(name: *const ::c_char) -> *mut ::group; ++ pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; ++ pub fn sem_unlink(name: *const ::c_char) -> ::c_int; ++ pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] ++ pub fn getpwnam_r(name: *const ::c_char, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] ++ pub fn getpwuid_r(uid: ::uid_t, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch ="x86"), ++ link_name = "sigwait$UNIX2003")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] ++ pub fn sigwait(set: *const sigset_t, ++ sig: *mut ::c_int) -> ::c_int; ++ pub fn pthread_atfork(prepare: Option, ++ parent: Option, ++ child: Option) -> ::c_int; ++ pub fn getgrgid(gid: ::gid_t) -> *mut ::group; ++ pub fn getgrouplist(user: *const ::c_char, ++ group: ::gid_t, ++ groups: *mut ::gid_t, ++ ngroups: *mut ::c_int) -> ::c_int; ++ pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, ++ pshared: *mut ::c_int) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "popen$UNIX2003")] ++ pub fn popen(command: *const c_char, ++ mode: *const c_char) -> *mut ::FILE; ++ pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::c_int, flags: ::c_int) -> ::c_int; ++ pub fn pthread_create(native: *mut ::pthread_t, ++ attr: *const ::pthread_attr_t, ++ f: extern fn(*mut ::c_void) -> *mut ::c_void, ++ value: *mut ::c_void) -> ::c_int; ++} ++ ++cfg_if! { ++ if #[cfg(any(target_env = "musl", target_os = "fuchsia"))] { ++ mod musl; ++ pub use self::musl::*; ++ } else if #[cfg(any(target_arch = "mips", ++ target_arch = "mips64"))] { ++ mod mips; ++ pub use self::mips::*; ++ } else if #[cfg(any(target_arch = "s390x"))] { ++ mod s390x; ++ pub use self::s390x::*; ++ } else { ++ mod other; ++ pub use self::other::*; ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b32/arm.rs index 000000000,000000000..d0b46600c new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b32/arm.rs @@@ -1,0 -1,0 +1,392 @@@ ++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 struct statfs64 { ++ pub f_type: ::c_ulong, ++ pub f_bsize: ::c_ulong, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_flags: ::c_ulong, ++ pub f_spare: [::c_ulong; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ __f_unused: ::c_int, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++} ++ ++pub const O_DIRECT: ::c_int = 0x4000; ++pub const O_DIRECTORY: ::c_int = 0x10000; ++pub const O_NOFOLLOW: ::c_int = 0x20000; ++pub const O_ASYNC: ::c_int = 0x2000; ++pub const O_LARGEFILE: ::c_int = 0o400000; ++ ++pub const FIOCLEX: ::c_int = 0x5451; ++pub const FIONBIO: ::c_int = 0x5421; ++ ++pub const RLIMIT_RSS: ::c_int = 5; ++pub const RLIMIT_NOFILE: ::c_int = 7; ++pub const RLIMIT_AS: ::c_int = 9; ++pub const RLIMIT_NPROC: ::c_int = 6; ++pub const RLIMIT_MEMLOCK: ::c_int = 8; ++ ++pub const O_APPEND: ::c_int = 1024; ++pub const O_CREAT: ::c_int = 64; ++pub const O_EXCL: ::c_int = 128; ++pub const O_NOCTTY: ::c_int = 256; ++pub const O_NONBLOCK: ::c_int = 2048; ++pub const O_SYNC: ::c_int = 1052672; ++pub const O_RSYNC: ::c_int = 1052672; ++pub const O_DSYNC: ::c_int = 4096; ++ ++pub const SOCK_NONBLOCK: ::c_int = 2048; ++ ++pub const MAP_ANON: ::c_int = 0x0020; ++pub const MAP_GROWSDOWN: ::c_int = 0x0100; ++pub const MAP_DENYWRITE: ::c_int = 0x0800; ++pub const MAP_EXECUTABLE: ::c_int = 0x01000; ++pub const MAP_LOCKED: ::c_int = 0x02000; ++pub const MAP_NORESERVE: ::c_int = 0x04000; ++pub const MAP_POPULATE: ::c_int = 0x08000; ++pub const MAP_NONBLOCK: ::c_int = 0x010000; ++pub const MAP_STACK: ::c_int = 0x020000; ++ ++pub const SOCK_STREAM: ::c_int = 1; ++pub const SOCK_DGRAM: ::c_int = 2; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++ ++pub const SOL_SOCKET: ::c_int = 1; ++ ++pub const EDEADLK: ::c_int = 35; ++pub const ENAMETOOLONG: ::c_int = 36; ++pub const ENOLCK: ::c_int = 37; ++pub const ENOSYS: ::c_int = 38; ++pub const ENOTEMPTY: ::c_int = 39; ++pub const ELOOP: ::c_int = 40; ++pub const ENOMSG: ::c_int = 42; ++pub const EIDRM: ::c_int = 43; ++pub const ECHRNG: ::c_int = 44; ++pub const EL2NSYNC: ::c_int = 45; ++pub const EL3HLT: ::c_int = 46; ++pub const EL3RST: ::c_int = 47; ++pub const ELNRNG: ::c_int = 48; ++pub const EUNATCH: ::c_int = 49; ++pub const ENOCSI: ::c_int = 50; ++pub const EL2HLT: ::c_int = 51; ++pub const EBADE: ::c_int = 52; ++pub const EBADR: ::c_int = 53; ++pub const EXFULL: ::c_int = 54; ++pub const ENOANO: ::c_int = 55; ++pub const EBADRQC: ::c_int = 56; ++pub const EBADSLT: ::c_int = 57; ++pub const EDEADLOCK: ::c_int = EDEADLK; ++pub const EMULTIHOP: ::c_int = 72; ++pub const EBADMSG: ::c_int = 74; ++pub const EOVERFLOW: ::c_int = 75; ++pub const ENOTUNIQ: ::c_int = 76; ++pub const EBADFD: ::c_int = 77; ++pub const EREMCHG: ::c_int = 78; ++pub const ELIBACC: ::c_int = 79; ++pub const ELIBBAD: ::c_int = 80; ++pub const ELIBSCN: ::c_int = 81; ++pub const ELIBMAX: ::c_int = 82; ++pub const ELIBEXEC: ::c_int = 83; ++pub const EILSEQ: ::c_int = 84; ++pub const ERESTART: ::c_int = 85; ++pub const ESTRPIPE: ::c_int = 86; ++pub const EUSERS: ::c_int = 87; ++pub const ENOTSOCK: ::c_int = 88; ++pub const EDESTADDRREQ: ::c_int = 89; ++pub const EMSGSIZE: ::c_int = 90; ++pub const EPROTOTYPE: ::c_int = 91; ++pub const ENOPROTOOPT: ::c_int = 92; ++pub const EPROTONOSUPPORT: ::c_int = 93; ++pub const ESOCKTNOSUPPORT: ::c_int = 94; ++pub const EOPNOTSUPP: ::c_int = 95; ++pub const ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const EAFNOSUPPORT: ::c_int = 97; ++pub const EADDRINUSE: ::c_int = 98; ++pub const EADDRNOTAVAIL: ::c_int = 99; ++pub const ENETDOWN: ::c_int = 100; ++pub const ENETUNREACH: ::c_int = 101; ++pub const ENETRESET: ::c_int = 102; ++pub const ECONNABORTED: ::c_int = 103; ++pub const ECONNRESET: ::c_int = 104; ++pub const ENOBUFS: ::c_int = 105; ++pub const EISCONN: ::c_int = 106; ++pub const ENOTCONN: ::c_int = 107; ++pub const ESHUTDOWN: ::c_int = 108; ++pub const ETOOMANYREFS: ::c_int = 109; ++pub const ETIMEDOUT: ::c_int = 110; ++pub const ECONNREFUSED: ::c_int = 111; ++pub const EHOSTDOWN: ::c_int = 112; ++pub const EHOSTUNREACH: ::c_int = 113; ++pub const EALREADY: ::c_int = 114; ++pub const EINPROGRESS: ::c_int = 115; ++pub const ESTALE: ::c_int = 116; ++pub const EUCLEAN: ::c_int = 117; ++pub const ENOTNAM: ::c_int = 118; ++pub const ENAVAIL: ::c_int = 119; ++pub const EISNAM: ::c_int = 120; ++pub const EREMOTEIO: ::c_int = 121; ++pub const EDQUOT: ::c_int = 122; ++pub const ENOMEDIUM: ::c_int = 123; ++pub const EMEDIUMTYPE: ::c_int = 124; ++pub const ECANCELED: ::c_int = 125; ++pub const ENOKEY: ::c_int = 126; ++pub const EKEYEXPIRED: ::c_int = 127; ++pub const EKEYREVOKED: ::c_int = 128; ++pub const EKEYREJECTED: ::c_int = 129; ++pub const EOWNERDEAD: ::c_int = 130; ++pub const ENOTRECOVERABLE: ::c_int = 131; ++pub const ERFKILL: ::c_int = 132; ++pub const EHWPOISON: ::c_int = 133; ++ ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_TYPE: ::c_int = 3; ++pub const SO_ERROR: ::c_int = 4; ++pub const SO_DONTROUTE: ::c_int = 5; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SO_SNDBUF: ::c_int = 7; ++pub const SO_RCVBUF: ::c_int = 8; ++pub const SO_KEEPALIVE: ::c_int = 9; ++pub const SO_OOBINLINE: ::c_int = 10; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_LINGER: ::c_int = 13; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_REUSEPORT: ::c_int = 15; ++pub const SO_PASSCRED: ::c_int = 16; ++pub const SO_PEERCRED: ::c_int = 17; ++pub const SO_RCVLOWAT: ::c_int = 18; ++pub const SO_SNDLOWAT: ::c_int = 19; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_SNDTIMEO: ::c_int = 21; ++pub const SO_ACCEPTCONN: ::c_int = 30; ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_PROTOCOL: ::c_int = 38; ++pub const SO_DOMAIN: ::c_int = 39; ++ ++pub const SA_ONSTACK: ::c_int = 0x08000000; ++pub const SA_SIGINFO: ::c_int = 0x00000004; ++pub const SA_NOCLDWAIT: ::c_int = 0x00000002; ++ ++pub const SIGCHLD: ::c_int = 17; ++pub const SIGBUS: ::c_int = 7; ++pub const SIGTTIN: ::c_int = 21; ++pub const SIGTTOU: ::c_int = 22; ++pub const SIGXCPU: ::c_int = 24; ++pub const SIGXFSZ: ::c_int = 25; ++pub const SIGVTALRM: ::c_int = 26; ++pub const SIGPROF: ::c_int = 27; ++pub const SIGWINCH: ::c_int = 28; ++pub const SIGUSR1: ::c_int = 10; ++pub const SIGUSR2: ::c_int = 12; ++pub const SIGCONT: ::c_int = 18; ++pub const SIGSTOP: ::c_int = 19; ++pub const SIGTSTP: ::c_int = 20; ++pub const SIGURG: ::c_int = 23; ++pub const SIGIO: ::c_int = 29; ++pub const SIGSYS: ::c_int = 31; ++pub const SIGSTKFLT: ::c_int = 16; ++pub const SIGPOLL: ::c_int = 29; ++pub const SIGPWR: ::c_int = 30; ++pub const SIG_SETMASK: ::c_int = 2; ++pub const SIG_BLOCK: ::c_int = 0x000000; ++pub const SIG_UNBLOCK: ::c_int = 0x01; ++ ++pub const EXTPROC: ::tcflag_t = 0x00010000; ++ ++pub const MAP_HUGETLB: ::c_int = 0x040000; ++ ++pub const F_GETLK: ::c_int = 12; ++pub const F_GETOWN: ::c_int = 9; ++pub const F_SETLK: ::c_int = 13; ++pub const F_SETLKW: ::c_int = 14; ++pub const F_SETOWN: ::c_int = 8; ++ ++pub const VEOF: usize = 4; ++pub const VEOL: usize = 11; ++pub const VEOL2: usize = 16; ++pub const VMIN: usize = 6; ++pub const IEXTEN: ::tcflag_t = 0x00008000; ++pub const TOSTOP: ::tcflag_t = 0x00000100; ++pub const FLUSHO: ::tcflag_t = 0x00001000; ++ ++pub const TCGETS: ::c_int = 0x5401; ++pub const TCSETS: ::c_int = 0x5402; ++pub const TCSETSW: ::c_int = 0x5403; ++pub const TCSETSF: ::c_int = 0x5404; ++pub const TCGETA: ::c_int = 0x5405; ++pub const TCSETA: ::c_int = 0x5406; ++pub const TCSETAW: ::c_int = 0x5407; ++pub const TCSETAF: ::c_int = 0x5408; ++pub const TCSBRK: ::c_int = 0x5409; ++pub const TCXONC: ::c_int = 0x540A; ++pub const TCFLSH: ::c_int = 0x540B; ++pub const TIOCGSOFTCAR: ::c_int = 0x5419; ++pub const TIOCSSOFTCAR: ::c_int = 0x541A; ++pub const TIOCLINUX: ::c_int = 0x541C; ++pub const TIOCGSERIAL: ::c_int = 0x541E; ++pub const TIOCEXCL: ::c_int = 0x540C; ++pub const TIOCNXCL: ::c_int = 0x540D; ++pub const TIOCSCTTY: ::c_int = 0x540E; ++pub const TIOCGPGRP: ::c_int = 0x540F; ++pub const TIOCSPGRP: ::c_int = 0x5410; ++pub const TIOCOUTQ: ::c_int = 0x5411; ++pub const TIOCSTI: ::c_int = 0x5412; ++pub const TIOCGWINSZ: ::c_int = 0x5413; ++pub const TIOCSWINSZ: ::c_int = 0x5414; ++pub const TIOCMGET: ::c_int = 0x5415; ++pub const TIOCMBIS: ::c_int = 0x5416; ++pub const TIOCMBIC: ::c_int = 0x5417; ++pub const TIOCMSET: ::c_int = 0x5418; ++pub const FIONREAD: ::c_int = 0x541B; ++pub const TIOCCONS: ::c_int = 0x541D; ++ ++pub const SYS_pivot_root: ::c_long = 218; ++pub const SYS_gettid: ::c_long = 224; ++pub const SYS_perf_event_open: ::c_long = 364; ++pub const SYS_memfd_create: ::c_long = 385; ++ ++pub const POLLWRNORM: ::c_short = 0x100; ++pub const POLLWRBAND: ::c_short = 0x200; ++ ++pub const TIOCM_LE: ::c_int = 0x001; ++pub const TIOCM_DTR: ::c_int = 0x002; ++pub const TIOCM_RTS: ::c_int = 0x004; ++pub const TIOCM_ST: ::c_int = 0x008; ++pub const TIOCM_SR: ::c_int = 0x010; ++pub const TIOCM_CTS: ::c_int = 0x020; ++pub const TIOCM_CAR: ::c_int = 0x040; ++pub const TIOCM_RNG: ::c_int = 0x080; ++pub const TIOCM_DSR: ::c_int = 0x100; ++pub const TIOCM_CD: ::c_int = TIOCM_CAR; ++pub const TIOCM_RI: ::c_int = TIOCM_RNG; diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b32/mips.rs index 000000000,000000000..94039773e new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b32/mips.rs @@@ -1,0 -1,0 +1,404 @@@ ++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 struct statfs64 { ++ pub f_type: ::c_ulong, ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::c_ulong, ++ pub f_flags: ::c_ulong, ++ pub f_spare: [::c_ulong; 5], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ #[cfg(target_endian = "little")] ++ pub f_fsid: ::c_ulong, ++ __f_unused: ::c_int, ++ #[cfg(target_endian = "big")] ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++} ++ ++pub const O_DIRECT: ::c_int = 0o100000; ++pub const O_DIRECTORY: ::c_int = 0o200000; ++pub const O_NOFOLLOW: ::c_int = 0o400000; ++pub const O_ASYNC: ::c_int = 0o10000; ++pub const O_LARGEFILE: ::c_int = 0x2000; ++ ++pub const FIOCLEX: ::c_int = 0x6601; ++pub const FIONBIO: ::c_int = 0x667E; ++ ++pub const RLIMIT_RSS: ::c_int = 7; ++pub const RLIMIT_NOFILE: ::c_int = 5; ++pub const RLIMIT_AS: ::c_int = 6; ++pub const RLIMIT_NPROC: ::c_int = 8; ++pub const RLIMIT_MEMLOCK: ::c_int = 9; ++ ++pub const O_APPEND: ::c_int = 0o010; ++pub const O_CREAT: ::c_int = 0o400; ++pub const O_EXCL: ::c_int = 0o2000; ++pub const O_NOCTTY: ::c_int = 0o4000; ++pub const O_NONBLOCK: ::c_int = 0o200; ++pub const O_SYNC: ::c_int = 0o40020; ++pub const O_RSYNC: ::c_int = 0o40020; ++pub const O_DSYNC: ::c_int = 0o020; ++ ++pub const SOCK_NONBLOCK: ::c_int = 0o200; ++ ++pub const MAP_ANON: ::c_int = 0x800; ++pub const MAP_GROWSDOWN: ::c_int = 0x1000; ++pub const MAP_DENYWRITE: ::c_int = 0x2000; ++pub const MAP_EXECUTABLE: ::c_int = 0x4000; ++pub const MAP_LOCKED: ::c_int = 0x8000; ++pub const MAP_NORESERVE: ::c_int = 0x0400; ++pub const MAP_POPULATE: ::c_int = 0x10000; ++pub const MAP_NONBLOCK: ::c_int = 0x20000; ++pub const MAP_STACK: ::c_int = 0x40000; ++ ++pub const EDEADLK: ::c_int = 45; ++pub const ENAMETOOLONG: ::c_int = 78; ++pub const ENOLCK: ::c_int = 46; ++pub const ENOSYS: ::c_int = 89; ++pub const ENOTEMPTY: ::c_int = 93; ++pub const ELOOP: ::c_int = 90; ++pub const ENOMSG: ::c_int = 35; ++pub const EIDRM: ::c_int = 36; ++pub const ECHRNG: ::c_int = 37; ++pub const EL2NSYNC: ::c_int = 38; ++pub const EL3HLT: ::c_int = 39; ++pub const EL3RST: ::c_int = 40; ++pub const ELNRNG: ::c_int = 41; ++pub const EUNATCH: ::c_int = 42; ++pub const ENOCSI: ::c_int = 43; ++pub const EL2HLT: ::c_int = 44; ++pub const EBADE: ::c_int = 50; ++pub const EBADR: ::c_int = 51; ++pub const EXFULL: ::c_int = 52; ++pub const ENOANO: ::c_int = 53; ++pub const EBADRQC: ::c_int = 54; ++pub const EBADSLT: ::c_int = 55; ++pub const EDEADLOCK: ::c_int = 56; ++pub const EMULTIHOP: ::c_int = 74; ++pub const EOVERFLOW: ::c_int = 79; ++pub const ENOTUNIQ: ::c_int = 80; ++pub const EBADFD: ::c_int = 81; ++pub const EBADMSG: ::c_int = 77; ++pub const EREMCHG: ::c_int = 82; ++pub const ELIBACC: ::c_int = 83; ++pub const ELIBBAD: ::c_int = 84; ++pub const ELIBSCN: ::c_int = 85; ++pub const ELIBMAX: ::c_int = 86; ++pub const ELIBEXEC: ::c_int = 87; ++pub const EILSEQ: ::c_int = 88; ++pub const ERESTART: ::c_int = 91; ++pub const ESTRPIPE: ::c_int = 92; ++pub const EUSERS: ::c_int = 94; ++pub const ENOTSOCK: ::c_int = 95; ++pub const EDESTADDRREQ: ::c_int = 96; ++pub const EMSGSIZE: ::c_int = 97; ++pub const EPROTOTYPE: ::c_int = 98; ++pub const ENOPROTOOPT: ::c_int = 99; ++pub const EPROTONOSUPPORT: ::c_int = 120; ++pub const ESOCKTNOSUPPORT: ::c_int = 121; ++pub const EOPNOTSUPP: ::c_int = 122; ++pub const ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EPFNOSUPPORT: ::c_int = 123; ++pub const EAFNOSUPPORT: ::c_int = 124; ++pub const EADDRINUSE: ::c_int = 125; ++pub const EADDRNOTAVAIL: ::c_int = 126; ++pub const ENETDOWN: ::c_int = 127; ++pub const ENETUNREACH: ::c_int = 128; ++pub const ENETRESET: ::c_int = 129; ++pub const ECONNABORTED: ::c_int = 130; ++pub const ECONNRESET: ::c_int = 131; ++pub const ENOBUFS: ::c_int = 132; ++pub const EISCONN: ::c_int = 133; ++pub const ENOTCONN: ::c_int = 134; ++pub const ESHUTDOWN: ::c_int = 143; ++pub const ETOOMANYREFS: ::c_int = 144; ++pub const ETIMEDOUT: ::c_int = 145; ++pub const ECONNREFUSED: ::c_int = 146; ++pub const EHOSTDOWN: ::c_int = 147; ++pub const EHOSTUNREACH: ::c_int = 148; ++pub const EALREADY: ::c_int = 149; ++pub const EINPROGRESS: ::c_int = 150; ++pub const ESTALE: ::c_int = 151; ++pub const EUCLEAN: ::c_int = 135; ++pub const ENOTNAM: ::c_int = 137; ++pub const ENAVAIL: ::c_int = 138; ++pub const EISNAM: ::c_int = 139; ++pub const EREMOTEIO: ::c_int = 140; ++pub const EDQUOT: ::c_int = 1133; ++pub const ENOMEDIUM: ::c_int = 159; ++pub const EMEDIUMTYPE: ::c_int = 160; ++pub const ECANCELED: ::c_int = 158; ++pub const ENOKEY: ::c_int = 161; ++pub const EKEYEXPIRED: ::c_int = 162; ++pub const EKEYREVOKED: ::c_int = 163; ++pub const EKEYREJECTED: ::c_int = 164; ++pub const EOWNERDEAD: ::c_int = 165; ++pub const ENOTRECOVERABLE: ::c_int = 166; ++pub const EHWPOISON: ::c_int = 168; ++pub const ERFKILL: ::c_int = 167; ++ ++pub const SOCK_STREAM: ::c_int = 2; ++pub const SOCK_DGRAM: ::c_int = 1; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++ ++pub const SOL_SOCKET: ::c_int = 65535; ++ ++pub const SO_REUSEADDR: ::c_int = 0x0004; ++pub const SO_KEEPALIVE: ::c_int = 0x0008; ++pub const SO_DONTROUTE: ::c_int = 0x0010; ++pub const SO_BROADCAST: ::c_int = 0x0020; ++pub const SO_LINGER: ::c_int = 0x0080; ++pub const SO_OOBINLINE: ::c_int = 0x0100; ++pub const SO_REUSEPORT: ::c_int = 0x0200; ++pub const SO_SNDBUF: ::c_int = 0x1001; ++pub const SO_RCVBUF: ::c_int = 0x1002; ++pub const SO_SNDLOWAT: ::c_int = 0x1003; ++pub const SO_RCVLOWAT: ::c_int = 0x1004; ++pub const SO_RCVTIMEO: ::c_int = 0x1006; ++pub const SO_SNDTIMEO: ::c_int = 0x1005; ++pub const SO_ERROR: ::c_int = 0x1007; ++pub const SO_TYPE: ::c_int = 0x1008; ++pub const SO_ACCEPTCONN: ::c_int = 0x1009; ++pub const SO_PROTOCOL: ::c_int = 0x1028; ++pub const SO_DOMAIN: ::c_int = 0x1029; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_PASSCRED: ::c_int = 17; ++pub const SO_PEERCRED: ::c_int = 18; ++pub const SO_SNDBUFFORCE: ::c_int = 31; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++ ++pub const SA_ONSTACK: ::c_int = 0x08000000; ++pub const SA_SIGINFO: ::c_int = 8; ++pub const SA_NOCLDWAIT: ::c_int = 0x10000; ++ ++pub const SIGCHLD: ::c_int = 18; ++pub const SIGBUS: ::c_int = 10; ++pub const SIGTTIN: ::c_int = 26; ++pub const SIGTTOU: ::c_int = 27; ++pub const SIGXCPU: ::c_int = 30; ++pub const SIGXFSZ: ::c_int = 31; ++pub const SIGVTALRM: ::c_int = 28; ++pub const SIGPROF: ::c_int = 29; ++pub const SIGWINCH: ::c_int = 20; ++pub const SIGUSR1: ::c_int = 16; ++pub const SIGUSR2: ::c_int = 17; ++pub const SIGCONT: ::c_int = 25; ++pub const SIGSTOP: ::c_int = 23; ++pub const SIGTSTP: ::c_int = 24; ++pub const SIGURG: ::c_int = 21; ++pub const SIGIO: ::c_int = 22; ++pub const SIGSYS: ::c_int = 12; ++pub const SIGSTKFLT: ::c_int = 7; ++pub const SIGPOLL: ::c_int = ::SIGIO; ++pub const SIGPWR: ::c_int = 19; ++pub const SIG_SETMASK: ::c_int = 3; ++pub const SIG_BLOCK: ::c_int = 1; ++pub const SIG_UNBLOCK: ::c_int = 2; ++ ++pub const EXTPROC: ::tcflag_t = 0o200000; ++ ++pub const MAP_HUGETLB: ::c_int = 0x80000; ++ ++pub const F_GETLK: ::c_int = 33; ++pub const F_GETOWN: ::c_int = 23; ++pub const F_SETLK: ::c_int = 34; ++pub const F_SETLKW: ::c_int = 35; ++pub const F_SETOWN: ::c_int = 24; ++ ++pub const VEOF: usize = 16; ++pub const VEOL: usize = 17; ++pub const VEOL2: usize = 6; ++pub const VMIN: usize = 4; ++pub const IEXTEN: ::tcflag_t = 0o000400; ++pub const TOSTOP: ::tcflag_t = 0o100000; ++pub const FLUSHO: ::tcflag_t = 0o020000; ++ ++pub const TCGETS: ::c_int = 0x540D; ++pub const TCSETS: ::c_int = 0x540E; ++pub const TCSETSW: ::c_int = 0x540F; ++pub const TCSETSF: ::c_int = 0x5410; ++pub const TCGETA: ::c_int = 0x5401; ++pub const TCSETA: ::c_int = 0x5402; ++pub const TCSETAW: ::c_int = 0x5403; ++pub const TCSETAF: ::c_int = 0x5404; ++pub const TCSBRK: ::c_int = 0x5405; ++pub const TCXONC: ::c_int = 0x5406; ++pub const TCFLSH: ::c_int = 0x5407; ++pub const TIOCGSOFTCAR: ::c_int = 0x5481; ++pub const TIOCSSOFTCAR: ::c_int = 0x5482; ++pub const TIOCLINUX: ::c_int = 0x5483; ++pub const TIOCGSERIAL: ::c_int = 0x5484; ++pub const TIOCEXCL: ::c_int = 0x740D; ++pub const TIOCNXCL: ::c_int = 0x740E; ++pub const TIOCSCTTY: ::c_int = 0x5480; ++pub const TIOCGPGRP: ::c_int = 0x40047477; ++pub const TIOCSPGRP: ::c_int = 0x80047476; ++pub const TIOCOUTQ: ::c_int = 0x7472; ++pub const TIOCSTI: ::c_int = 0x5472; ++pub const TIOCGWINSZ: ::c_int = 0x40087468; ++pub const TIOCSWINSZ: ::c_int = 0x80087467; ++pub const TIOCMGET: ::c_int = 0x741D; ++pub const TIOCMBIS: ::c_int = 0x741B; ++pub const TIOCMBIC: ::c_int = 0x741C; ++pub const TIOCMSET: ::c_int = 0x741A; ++pub const FIONREAD: ::c_int = 0x467F; ++pub const TIOCCONS: ::c_int = 0x80047478; ++ ++// Valid for O32 ++pub const SYS_pivot_root: ::c_long = 4216; ++pub const SYS_gettid: ::c_long = 4222; ++pub const SYS_perf_event_open: ::c_long = 4333; ++pub const SYS_memfd_create: ::c_long = 4354; ++ ++pub const POLLWRNORM: ::c_short = 0x4; ++pub const POLLWRBAND: ::c_short = 0x100; ++ ++pub const TIOCM_LE: ::c_int = 0x001; ++pub const TIOCM_DTR: ::c_int = 0x002; ++pub const TIOCM_RTS: ::c_int = 0x004; ++pub const TIOCM_ST: ::c_int = 0x010; ++pub const TIOCM_SR: ::c_int = 0x020; ++pub const TIOCM_CTS: ::c_int = 0x040; ++pub const TIOCM_CAR: ::c_int = 0x100; ++pub const TIOCM_CD: ::c_int = TIOCM_CAR; ++pub const TIOCM_RNG: ::c_int = 0x200; ++pub const TIOCM_RI: ::c_int = TIOCM_RNG; ++pub const TIOCM_DSR: ::c_int = 0x400; diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b32/mod.rs index 000000000,000000000..58c971b04 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b32/mod.rs @@@ -1,0 -1,0 +1,52 @@@ ++pub type c_long = i32; ++pub type c_ulong = u32; ++pub type nlink_t = u32; ++pub type __u64 = ::c_ulonglong; ++ ++s! { ++ pub struct pthread_attr_t { ++ __size: [u32; 9] ++ } ++ ++ pub struct sigset_t { ++ __val: [::c_ulong; 32], ++ } ++ ++ pub struct msghdr { ++ pub msg_name: *mut ::c_void, ++ pub msg_namelen: ::socklen_t, ++ pub msg_iov: *mut ::iovec, ++ pub msg_iovlen: ::c_int, ++ pub msg_control: *mut ::c_void, ++ pub msg_controllen: ::socklen_t, ++ pub msg_flags: ::c_int, ++ } ++ ++ pub struct cmsghdr { ++ pub cmsg_len: ::socklen_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct sem_t { ++ __val: [::c_int; 4], ++ } ++} ++ ++pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; ++ ++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 { ++ // Unknown target_arch ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b32/x86.rs index 000000000,000000000..812d743f2 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b32/x86.rs @@@ -1,0 -1,0 +1,800 @@@ ++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 struct statfs64 { ++ pub f_type: ::c_ulong, ++ pub f_bsize: ::c_ulong, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_flags: ::c_ulong, ++ pub f_spare: [::c_ulong; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ __f_unused: ::c_int, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++} ++ ++pub const O_DIRECT: ::c_int = 0x4000; ++pub const O_DIRECTORY: ::c_int = 0x10000; ++pub const O_NOFOLLOW: ::c_int = 0x20000; ++pub const O_ASYNC: ::c_int = 0x2000; ++pub const O_LARGEFILE: ::c_int = 0o0100000; ++ ++pub const FIOCLEX: ::c_int = 0x5451; ++pub const FIONBIO: ::c_int = 0x5421; ++ ++pub const RLIMIT_RSS: ::c_int = 5; ++pub const RLIMIT_NOFILE: ::c_int = 7; ++pub const RLIMIT_AS: ::c_int = 9; ++pub const RLIMIT_NPROC: ::c_int = 6; ++pub const RLIMIT_MEMLOCK: ::c_int = 8; ++ ++pub const O_APPEND: ::c_int = 1024; ++pub const O_CREAT: ::c_int = 64; ++pub const O_EXCL: ::c_int = 128; ++pub const O_NOCTTY: ::c_int = 256; ++pub const O_NONBLOCK: ::c_int = 2048; ++pub const O_SYNC: ::c_int = 1052672; ++pub const O_RSYNC: ::c_int = 1052672; ++pub const O_DSYNC: ::c_int = 4096; ++ ++pub const SOCK_NONBLOCK: ::c_int = 2048; ++ ++pub const MAP_ANON: ::c_int = 0x0020; ++pub const MAP_GROWSDOWN: ::c_int = 0x0100; ++pub const MAP_DENYWRITE: ::c_int = 0x0800; ++pub const MAP_EXECUTABLE: ::c_int = 0x01000; ++pub const MAP_LOCKED: ::c_int = 0x02000; ++pub const MAP_NORESERVE: ::c_int = 0x04000; ++pub const MAP_POPULATE: ::c_int = 0x08000; ++pub const MAP_NONBLOCK: ::c_int = 0x010000; ++pub const MAP_STACK: ::c_int = 0x020000; ++ ++pub const SOCK_STREAM: ::c_int = 1; ++pub const SOCK_DGRAM: ::c_int = 2; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++ ++pub const SOL_SOCKET: ::c_int = 1; ++ ++pub const EDEADLK: ::c_int = 35; ++pub const ENAMETOOLONG: ::c_int = 36; ++pub const ENOLCK: ::c_int = 37; ++pub const ENOSYS: ::c_int = 38; ++pub const ENOTEMPTY: ::c_int = 39; ++pub const ELOOP: ::c_int = 40; ++pub const ENOMSG: ::c_int = 42; ++pub const EIDRM: ::c_int = 43; ++pub const ECHRNG: ::c_int = 44; ++pub const EL2NSYNC: ::c_int = 45; ++pub const EL3HLT: ::c_int = 46; ++pub const EL3RST: ::c_int = 47; ++pub const ELNRNG: ::c_int = 48; ++pub const EUNATCH: ::c_int = 49; ++pub const ENOCSI: ::c_int = 50; ++pub const EL2HLT: ::c_int = 51; ++pub const EBADE: ::c_int = 52; ++pub const EBADR: ::c_int = 53; ++pub const EXFULL: ::c_int = 54; ++pub const ENOANO: ::c_int = 55; ++pub const EBADRQC: ::c_int = 56; ++pub const EBADSLT: ::c_int = 57; ++pub const EDEADLOCK: ::c_int = EDEADLK; ++pub const EMULTIHOP: ::c_int = 72; ++pub const EBADMSG: ::c_int = 74; ++pub const EOVERFLOW: ::c_int = 75; ++pub const ENOTUNIQ: ::c_int = 76; ++pub const EBADFD: ::c_int = 77; ++pub const EREMCHG: ::c_int = 78; ++pub const ELIBACC: ::c_int = 79; ++pub const ELIBBAD: ::c_int = 80; ++pub const ELIBSCN: ::c_int = 81; ++pub const ELIBMAX: ::c_int = 82; ++pub const ELIBEXEC: ::c_int = 83; ++pub const EILSEQ: ::c_int = 84; ++pub const ERESTART: ::c_int = 85; ++pub const ESTRPIPE: ::c_int = 86; ++pub const EUSERS: ::c_int = 87; ++pub const ENOTSOCK: ::c_int = 88; ++pub const EDESTADDRREQ: ::c_int = 89; ++pub const EMSGSIZE: ::c_int = 90; ++pub const EPROTOTYPE: ::c_int = 91; ++pub const ENOPROTOOPT: ::c_int = 92; ++pub const EPROTONOSUPPORT: ::c_int = 93; ++pub const ESOCKTNOSUPPORT: ::c_int = 94; ++pub const EOPNOTSUPP: ::c_int = 95; ++pub const ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const EAFNOSUPPORT: ::c_int = 97; ++pub const EADDRINUSE: ::c_int = 98; ++pub const EADDRNOTAVAIL: ::c_int = 99; ++pub const ENETDOWN: ::c_int = 100; ++pub const ENETUNREACH: ::c_int = 101; ++pub const ENETRESET: ::c_int = 102; ++pub const ECONNABORTED: ::c_int = 103; ++pub const ECONNRESET: ::c_int = 104; ++pub const ENOBUFS: ::c_int = 105; ++pub const EISCONN: ::c_int = 106; ++pub const ENOTCONN: ::c_int = 107; ++pub const ESHUTDOWN: ::c_int = 108; ++pub const ETOOMANYREFS: ::c_int = 109; ++pub const ETIMEDOUT: ::c_int = 110; ++pub const ECONNREFUSED: ::c_int = 111; ++pub const EHOSTDOWN: ::c_int = 112; ++pub const EHOSTUNREACH: ::c_int = 113; ++pub const EALREADY: ::c_int = 114; ++pub const EINPROGRESS: ::c_int = 115; ++pub const ESTALE: ::c_int = 116; ++pub const EUCLEAN: ::c_int = 117; ++pub const ENOTNAM: ::c_int = 118; ++pub const ENAVAIL: ::c_int = 119; ++pub const EISNAM: ::c_int = 120; ++pub const EREMOTEIO: ::c_int = 121; ++pub const EDQUOT: ::c_int = 122; ++pub const ENOMEDIUM: ::c_int = 123; ++pub const EMEDIUMTYPE: ::c_int = 124; ++pub const ECANCELED: ::c_int = 125; ++pub const ENOKEY: ::c_int = 126; ++pub const EKEYEXPIRED: ::c_int = 127; ++pub const EKEYREVOKED: ::c_int = 128; ++pub const EKEYREJECTED: ::c_int = 129; ++pub const EOWNERDEAD: ::c_int = 130; ++pub const ENOTRECOVERABLE: ::c_int = 131; ++pub const ERFKILL: ::c_int = 132; ++pub const EHWPOISON: ::c_int = 133; ++ ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_TYPE: ::c_int = 3; ++pub const SO_ERROR: ::c_int = 4; ++pub const SO_DONTROUTE: ::c_int = 5; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SO_SNDBUF: ::c_int = 7; ++pub const SO_RCVBUF: ::c_int = 8; ++pub const SO_KEEPALIVE: ::c_int = 9; ++pub const SO_OOBINLINE: ::c_int = 10; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_LINGER: ::c_int = 13; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_REUSEPORT: ::c_int = 15; ++pub const SO_PASSCRED: ::c_int = 16; ++pub const SO_PEERCRED: ::c_int = 17; ++pub const SO_RCVLOWAT: ::c_int = 18; ++pub const SO_SNDLOWAT: ::c_int = 19; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_SNDTIMEO: ::c_int = 21; ++pub const SO_ACCEPTCONN: ::c_int = 30; ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_PROTOCOL: ::c_int = 38; ++pub const SO_DOMAIN: ::c_int = 39; ++ ++pub const SA_ONSTACK: ::c_int = 0x08000000; ++pub const SA_SIGINFO: ::c_int = 0x00000004; ++pub const SA_NOCLDWAIT: ::c_int = 0x00000002; ++ ++pub const SIGCHLD: ::c_int = 17; ++pub const SIGBUS: ::c_int = 7; ++pub const SIGTTIN: ::c_int = 21; ++pub const SIGTTOU: ::c_int = 22; ++pub const SIGXCPU: ::c_int = 24; ++pub const SIGXFSZ: ::c_int = 25; ++pub const SIGVTALRM: ::c_int = 26; ++pub const SIGPROF: ::c_int = 27; ++pub const SIGWINCH: ::c_int = 28; ++pub const SIGUSR1: ::c_int = 10; ++pub const SIGUSR2: ::c_int = 12; ++pub const SIGCONT: ::c_int = 18; ++pub const SIGSTOP: ::c_int = 19; ++pub const SIGTSTP: ::c_int = 20; ++pub const SIGURG: ::c_int = 23; ++pub const SIGIO: ::c_int = 29; ++pub const SIGSYS: ::c_int = 31; ++pub const SIGSTKFLT: ::c_int = 16; ++pub const SIGPOLL: ::c_int = 29; ++pub const SIGPWR: ::c_int = 30; ++pub const SIG_SETMASK: ::c_int = 2; ++pub const SIG_BLOCK: ::c_int = 0x000000; ++pub const SIG_UNBLOCK: ::c_int = 0x01; ++ ++pub const EXTPROC: ::tcflag_t = 0x00010000; ++ ++pub const MAP_HUGETLB: ::c_int = 0x040000; ++pub const MAP_32BIT: ::c_int = 0x0040; ++ ++pub const F_GETLK: ::c_int = 12; ++pub const F_GETOWN: ::c_int = 9; ++pub const F_SETLK: ::c_int = 13; ++pub const F_SETLKW: ::c_int = 14; ++pub const F_SETOWN: ::c_int = 8; ++ ++pub const VEOF: usize = 4; ++pub const VEOL: usize = 11; ++pub const VEOL2: usize = 16; ++pub const VMIN: usize = 6; ++pub const IEXTEN: ::tcflag_t = 0x00008000; ++pub const TOSTOP: ::tcflag_t = 0x00000100; ++pub const FLUSHO: ::tcflag_t = 0x00001000; ++ ++pub const TCGETS: ::c_int = 0x5401; ++pub const TCSETS: ::c_int = 0x5402; ++pub const TCSETSW: ::c_int = 0x5403; ++pub const TCSETSF: ::c_int = 0x5404; ++pub const TCGETA: ::c_int = 0x5405; ++pub const TCSETA: ::c_int = 0x5406; ++pub const TCSETAW: ::c_int = 0x5407; ++pub const TCSETAF: ::c_int = 0x5408; ++pub const TCSBRK: ::c_int = 0x5409; ++pub const TCXONC: ::c_int = 0x540A; ++pub const TCFLSH: ::c_int = 0x540B; ++pub const TIOCGSOFTCAR: ::c_int = 0x5419; ++pub const TIOCSSOFTCAR: ::c_int = 0x541A; ++pub const TIOCLINUX: ::c_int = 0x541C; ++pub const TIOCGSERIAL: ::c_int = 0x541E; ++pub const TIOCEXCL: ::c_int = 0x540C; ++pub const TIOCNXCL: ::c_int = 0x540D; ++pub const TIOCSCTTY: ::c_int = 0x540E; ++pub const TIOCGPGRP: ::c_int = 0x540F; ++pub const TIOCSPGRP: ::c_int = 0x5410; ++pub const TIOCOUTQ: ::c_int = 0x5411; ++pub const TIOCSTI: ::c_int = 0x5412; ++pub const TIOCGWINSZ: ::c_int = 0x5413; ++pub const TIOCSWINSZ: ::c_int = 0x5414; ++pub const TIOCMGET: ::c_int = 0x5415; ++pub const TIOCMBIS: ::c_int = 0x5416; ++pub const TIOCMBIC: ::c_int = 0x5417; ++pub const TIOCMSET: ::c_int = 0x5418; ++pub const FIONREAD: ::c_int = 0x541B; ++pub const TIOCCONS: ::c_int = 0x541D; ++ ++pub const POLLWRNORM: ::c_short = 0x100; ++pub const POLLWRBAND: ::c_short = 0x200; ++ ++pub const TIOCM_LE: ::c_int = 0x001; ++pub const TIOCM_DTR: ::c_int = 0x002; ++pub const TIOCM_RTS: ::c_int = 0x004; ++pub const TIOCM_ST: ::c_int = 0x008; ++pub const TIOCM_SR: ::c_int = 0x010; ++pub const TIOCM_CTS: ::c_int = 0x020; ++pub const TIOCM_CAR: ::c_int = 0x040; ++pub const TIOCM_RNG: ::c_int = 0x080; ++pub const TIOCM_DSR: ::c_int = 0x100; ++pub const TIOCM_CD: ::c_int = TIOCM_CAR; ++pub const TIOCM_RI: ::c_int = TIOCM_RNG; ++ ++// Syscall table ++pub const SYS_restart_syscall: ::c_long = 0; ++pub const SYS_exit: ::c_long = 1; ++pub const SYS_fork: ::c_long = 2; ++pub const SYS_read: ::c_long = 3; ++pub const SYS_write: ::c_long = 4; ++pub const SYS_open: ::c_long = 5; ++pub const SYS_close: ::c_long = 6; ++pub const SYS_waitpid: ::c_long = 7; ++pub const SYS_creat: ::c_long = 8; ++pub const SYS_link: ::c_long = 9; ++pub const SYS_unlink: ::c_long = 10; ++pub const SYS_execve: ::c_long = 11; ++pub const SYS_chdir: ::c_long = 12; ++pub const SYS_time: ::c_long = 13; ++pub const SYS_mknod: ::c_long = 14; ++pub const SYS_chmod: ::c_long = 15; ++pub const SYS_lchown: ::c_long = 16; ++pub const SYS_break: ::c_long = 17; ++pub const SYS_oldstat: ::c_long = 18; ++pub const SYS_lseek: ::c_long = 19; ++pub const SYS_getpid: ::c_long = 20; ++pub const SYS_mount: ::c_long = 21; ++pub const SYS_umount: ::c_long = 22; ++pub const SYS_setuid: ::c_long = 23; ++pub const SYS_getuid: ::c_long = 24; ++pub const SYS_stime: ::c_long = 25; ++pub const SYS_ptrace: ::c_long = 26; ++pub const SYS_alarm: ::c_long = 27; ++pub const SYS_oldfstat: ::c_long = 28; ++pub const SYS_pause: ::c_long = 29; ++pub const SYS_utime: ::c_long = 30; ++pub const SYS_stty: ::c_long = 31; ++pub const SYS_gtty: ::c_long = 32; ++pub const SYS_access: ::c_long = 33; ++pub const SYS_nice: ::c_long = 34; ++pub const SYS_ftime: ::c_long = 35; ++pub const SYS_sync: ::c_long = 36; ++pub const SYS_kill: ::c_long = 37; ++pub const SYS_rename: ::c_long = 38; ++pub const SYS_mkdir: ::c_long = 39; ++pub const SYS_rmdir: ::c_long = 40; ++pub const SYS_dup: ::c_long = 41; ++pub const SYS_pipe: ::c_long = 42; ++pub const SYS_times: ::c_long = 43; ++pub const SYS_prof: ::c_long = 44; ++pub const SYS_brk: ::c_long = 45; ++pub const SYS_setgid: ::c_long = 46; ++pub const SYS_getgid: ::c_long = 47; ++pub const SYS_signal: ::c_long = 48; ++pub const SYS_geteuid: ::c_long = 49; ++pub const SYS_getegid: ::c_long = 50; ++pub const SYS_acct: ::c_long = 51; ++pub const SYS_umount2: ::c_long = 52; ++pub const SYS_lock: ::c_long = 53; ++pub const SYS_ioctl: ::c_long = 54; ++pub const SYS_fcntl: ::c_long = 55; ++pub const SYS_mpx: ::c_long = 56; ++pub const SYS_setpgid: ::c_long = 57; ++pub const SYS_ulimit: ::c_long = 58; ++pub const SYS_oldolduname: ::c_long = 59; ++pub const SYS_umask: ::c_long = 60; ++pub const SYS_chroot: ::c_long = 61; ++pub const SYS_ustat: ::c_long = 62; ++pub const SYS_dup2: ::c_long = 63; ++pub const SYS_getppid: ::c_long = 64; ++pub const SYS_getpgrp: ::c_long = 65; ++pub const SYS_setsid: ::c_long = 66; ++pub const SYS_sigaction: ::c_long = 67; ++pub const SYS_sgetmask: ::c_long = 68; ++pub const SYS_ssetmask: ::c_long = 69; ++pub const SYS_setreuid: ::c_long = 70; ++pub const SYS_setregid: ::c_long = 71; ++pub const SYS_sigsuspend: ::c_long = 72; ++pub const SYS_sigpending: ::c_long = 73; ++pub const SYS_sethostname: ::c_long = 74; ++pub const SYS_setrlimit: ::c_long = 75; ++pub const SYS_getrlimit: ::c_long = 76; ++pub const SYS_getrusage: ::c_long = 77; ++pub const SYS_gettimeofday: ::c_long = 78; ++pub const SYS_settimeofday: ::c_long = 79; ++pub const SYS_getgroups: ::c_long = 80; ++pub const SYS_setgroups: ::c_long = 81; ++pub const SYS_select: ::c_long = 82; ++pub const SYS_symlink: ::c_long = 83; ++pub const SYS_oldlstat: ::c_long = 84; ++pub const SYS_readlink: ::c_long = 85; ++pub const SYS_uselib: ::c_long = 86; ++pub const SYS_swapon: ::c_long = 87; ++pub const SYS_reboot: ::c_long = 88; ++pub const SYS_readdir: ::c_long = 89; ++pub const SYS_mmap: ::c_long = 90; ++pub const SYS_munmap: ::c_long = 91; ++pub const SYS_truncate: ::c_long = 92; ++pub const SYS_ftruncate: ::c_long = 93; ++pub const SYS_fchmod: ::c_long = 94; ++pub const SYS_fchown: ::c_long = 95; ++pub const SYS_getpriority: ::c_long = 96; ++pub const SYS_setpriority: ::c_long = 97; ++pub const SYS_profil: ::c_long = 98; ++pub const SYS_statfs: ::c_long = 99; ++pub const SYS_fstatfs: ::c_long = 100; ++pub const SYS_ioperm: ::c_long = 101; ++pub const SYS_socketcall: ::c_long = 102; ++pub const SYS_syslog: ::c_long = 103; ++pub const SYS_setitimer: ::c_long = 104; ++pub const SYS_getitimer: ::c_long = 105; ++pub const SYS_stat: ::c_long = 106; ++pub const SYS_lstat: ::c_long = 107; ++pub const SYS_fstat: ::c_long = 108; ++pub const SYS_olduname: ::c_long = 109; ++pub const SYS_iopl: ::c_long = 110; ++pub const SYS_vhangup: ::c_long = 111; ++pub const SYS_idle: ::c_long = 112; ++pub const SYS_vm86old: ::c_long = 113; ++pub const SYS_wait4: ::c_long = 114; ++pub const SYS_swapoff: ::c_long = 115; ++pub const SYS_sysinfo: ::c_long = 116; ++pub const SYS_ipc: ::c_long = 117; ++pub const SYS_fsync: ::c_long = 118; ++pub const SYS_sigreturn: ::c_long = 119; ++pub const SYS_clone: ::c_long = 120; ++pub const SYS_setdomainname: ::c_long = 121; ++pub const SYS_uname: ::c_long = 122; ++pub const SYS_modify_ldt: ::c_long = 123; ++pub const SYS_adjtimex: ::c_long = 124; ++pub const SYS_mprotect: ::c_long = 125; ++pub const SYS_sigprocmask: ::c_long = 126; ++pub const SYS_create_module: ::c_long = 127; ++pub const SYS_init_module: ::c_long = 128; ++pub const SYS_delete_module: ::c_long = 129; ++pub const SYS_get_kernel_syms: ::c_long = 130; ++pub const SYS_quotactl: ::c_long = 131; ++pub const SYS_getpgid: ::c_long = 132; ++pub const SYS_fchdir: ::c_long = 133; ++pub const SYS_bdflush: ::c_long = 134; ++pub const SYS_sysfs: ::c_long = 135; ++pub const SYS_personality: ::c_long = 136; ++pub const SYS_afs_syscall: ::c_long = 137; ++pub const SYS_setfsuid: ::c_long = 138; ++pub const SYS_setfsgid: ::c_long = 139; ++pub const SYS__llseek: ::c_long = 140; ++pub const SYS_getdents: ::c_long = 141; ++pub const SYS__newselect: ::c_long = 142; ++pub const SYS_flock: ::c_long = 143; ++pub const SYS_msync: ::c_long = 144; ++pub const SYS_readv: ::c_long = 145; ++pub const SYS_writev: ::c_long = 146; ++pub const SYS_getsid: ::c_long = 147; ++pub const SYS_fdatasync: ::c_long = 148; ++pub const SYS__sysctl: ::c_long = 149; ++pub const SYS_mlock: ::c_long = 150; ++pub const SYS_munlock: ::c_long = 151; ++pub const SYS_mlockall: ::c_long = 152; ++pub const SYS_munlockall: ::c_long = 153; ++pub const SYS_sched_setparam: ::c_long = 154; ++pub const SYS_sched_getparam: ::c_long = 155; ++pub const SYS_sched_setscheduler: ::c_long = 156; ++pub const SYS_sched_getscheduler: ::c_long = 157; ++pub const SYS_sched_yield: ::c_long = 158; ++pub const SYS_sched_get_priority_max: ::c_long = 159; ++pub const SYS_sched_get_priority_min: ::c_long = 160; ++pub const SYS_sched_rr_get_interval: ::c_long = 161; ++pub const SYS_nanosleep: ::c_long = 162; ++pub const SYS_mremap: ::c_long = 163; ++pub const SYS_setresuid: ::c_long = 164; ++pub const SYS_getresuid: ::c_long = 165; ++pub const SYS_vm86: ::c_long = 166; ++pub const SYS_query_module: ::c_long = 167; ++pub const SYS_poll: ::c_long = 168; ++pub const SYS_nfsservctl: ::c_long = 169; ++pub const SYS_setresgid: ::c_long = 170; ++pub const SYS_getresgid: ::c_long = 171; ++pub const SYS_prctl: ::c_long = 172; ++pub const SYS_rt_sigreturn: ::c_long = 173; ++pub const SYS_rt_sigaction: ::c_long = 174; ++pub const SYS_rt_sigprocmask: ::c_long = 175; ++pub const SYS_rt_sigpending: ::c_long = 176; ++pub const SYS_rt_sigtimedwait: ::c_long = 177; ++pub const SYS_rt_sigqueueinfo: ::c_long = 178; ++pub const SYS_rt_sigsuspend: ::c_long = 179; ++pub const SYS_pread64: ::c_long = 180; ++pub const SYS_pwrite64: ::c_long = 181; ++pub const SYS_chown: ::c_long = 182; ++pub const SYS_getcwd: ::c_long = 183; ++pub const SYS_capget: ::c_long = 184; ++pub const SYS_capset: ::c_long = 185; ++pub const SYS_sigaltstack: ::c_long = 186; ++pub const SYS_sendfile: ::c_long = 187; ++pub const SYS_getpmsg: ::c_long = 188; ++pub const SYS_putpmsg: ::c_long = 189; ++pub const SYS_vfork: ::c_long = 190; ++pub const SYS_ugetrlimit: ::c_long = 191; ++pub const SYS_mmap2: ::c_long = 192; ++pub const SYS_truncate64: ::c_long = 193; ++pub const SYS_ftruncate64: ::c_long = 194; ++pub const SYS_stat64: ::c_long = 195; ++pub const SYS_lstat64: ::c_long = 196; ++pub const SYS_fstat64: ::c_long = 197; ++pub const SYS_lchown32: ::c_long = 198; ++pub const SYS_getuid32: ::c_long = 199; ++pub const SYS_getgid32: ::c_long = 200; ++pub const SYS_geteuid32: ::c_long = 201; ++pub const SYS_getegid32: ::c_long = 202; ++pub const SYS_setreuid32: ::c_long = 203; ++pub const SYS_setregid32: ::c_long = 204; ++pub const SYS_getgroups32: ::c_long = 205; ++pub const SYS_setgroups32: ::c_long = 206; ++pub const SYS_fchown32: ::c_long = 207; ++pub const SYS_setresuid32: ::c_long = 208; ++pub const SYS_getresuid32: ::c_long = 209; ++pub const SYS_setresgid32: ::c_long = 210; ++pub const SYS_getresgid32: ::c_long = 211; ++pub const SYS_chown32: ::c_long = 212; ++pub const SYS_setuid32: ::c_long = 213; ++pub const SYS_setgid32: ::c_long = 214; ++pub const SYS_setfsuid32: ::c_long = 215; ++pub const SYS_setfsgid32: ::c_long = 216; ++pub const SYS_pivot_root: ::c_long = 217; ++pub const SYS_mincore: ::c_long = 218; ++pub const SYS_madvise: ::c_long = 219; ++pub const SYS_getdents64: ::c_long = 220; ++pub const SYS_fcntl64: ::c_long = 221; ++pub const SYS_gettid: ::c_long = 224; ++pub const SYS_readahead: ::c_long = 225; ++pub const SYS_setxattr: ::c_long = 226; ++pub const SYS_lsetxattr: ::c_long = 227; ++pub const SYS_fsetxattr: ::c_long = 228; ++pub const SYS_getxattr: ::c_long = 229; ++pub const SYS_lgetxattr: ::c_long = 230; ++pub const SYS_fgetxattr: ::c_long = 231; ++pub const SYS_listxattr: ::c_long = 232; ++pub const SYS_llistxattr: ::c_long = 233; ++pub const SYS_flistxattr: ::c_long = 234; ++pub const SYS_removexattr: ::c_long = 235; ++pub const SYS_lremovexattr: ::c_long = 236; ++pub const SYS_fremovexattr: ::c_long = 237; ++pub const SYS_tkill: ::c_long = 238; ++pub const SYS_sendfile64: ::c_long = 239; ++pub const SYS_futex: ::c_long = 240; ++pub const SYS_sched_setaffinity: ::c_long = 241; ++pub const SYS_sched_getaffinity: ::c_long = 242; ++pub const SYS_set_thread_area: ::c_long = 243; ++pub const SYS_get_thread_area: ::c_long = 244; ++pub const SYS_io_setup: ::c_long = 245; ++pub const SYS_io_destroy: ::c_long = 246; ++pub const SYS_io_getevents: ::c_long = 247; ++pub const SYS_io_submit: ::c_long = 248; ++pub const SYS_io_cancel: ::c_long = 249; ++pub const SYS_fadvise64: ::c_long = 250; ++pub const SYS_exit_group: ::c_long = 252; ++pub const SYS_lookup_dcookie: ::c_long = 253; ++pub const SYS_epoll_create: ::c_long = 254; ++pub const SYS_epoll_ctl: ::c_long = 255; ++pub const SYS_epoll_wait: ::c_long = 256; ++pub const SYS_remap_file_pages: ::c_long = 257; ++pub const SYS_set_tid_address: ::c_long = 258; ++pub const SYS_timer_create: ::c_long = 259; ++pub const SYS_timer_settime: ::c_long = 260; ++pub const SYS_timer_gettime: ::c_long = 261; ++pub const SYS_timer_getoverrun: ::c_long = 262; ++pub const SYS_timer_delete: ::c_long = 263; ++pub const SYS_clock_settime: ::c_long = 264; ++pub const SYS_clock_gettime: ::c_long = 265; ++pub const SYS_clock_getres: ::c_long = 266; ++pub const SYS_clock_nanosleep: ::c_long = 267; ++pub const SYS_statfs64: ::c_long = 268; ++pub const SYS_fstatfs64: ::c_long = 269; ++pub const SYS_tgkill: ::c_long = 270; ++pub const SYS_utimes: ::c_long = 271; ++pub const SYS_fadvise64_64: ::c_long = 272; ++pub const SYS_vserver: ::c_long = 273; ++pub const SYS_mbind: ::c_long = 274; ++pub const SYS_get_mempolicy: ::c_long = 275; ++pub const SYS_set_mempolicy: ::c_long = 276; ++pub const SYS_mq_open: ::c_long = 277; ++pub const SYS_mq_unlink: ::c_long = 278; ++pub const SYS_mq_timedsend: ::c_long = 279; ++pub const SYS_mq_timedreceive: ::c_long = 280; ++pub const SYS_mq_notify: ::c_long = 281; ++pub const SYS_mq_getsetattr: ::c_long = 282; ++pub const SYS_kexec_load: ::c_long = 283; ++pub const SYS_waitid: ::c_long = 284; ++pub const SYS_add_key: ::c_long = 286; ++pub const SYS_request_key: ::c_long = 287; ++pub const SYS_keyctl: ::c_long = 288; ++pub const SYS_ioprio_set: ::c_long = 289; ++pub const SYS_ioprio_get: ::c_long = 290; ++pub const SYS_inotify_init: ::c_long = 291; ++pub const SYS_inotify_add_watch: ::c_long = 292; ++pub const SYS_inotify_rm_watch: ::c_long = 293; ++pub const SYS_migrate_pages: ::c_long = 294; ++pub const SYS_openat: ::c_long = 295; ++pub const SYS_mkdirat: ::c_long = 296; ++pub const SYS_mknodat: ::c_long = 297; ++pub const SYS_fchownat: ::c_long = 298; ++pub const SYS_futimesat: ::c_long = 299; ++pub const SYS_fstatat64: ::c_long = 300; ++pub const SYS_unlinkat: ::c_long = 301; ++pub const SYS_renameat: ::c_long = 302; ++pub const SYS_linkat: ::c_long = 303; ++pub const SYS_symlinkat: ::c_long = 304; ++pub const SYS_readlinkat: ::c_long = 305; ++pub const SYS_fchmodat: ::c_long = 306; ++pub const SYS_faccessat: ::c_long = 307; ++pub const SYS_pselect6: ::c_long = 308; ++pub const SYS_ppoll: ::c_long = 309; ++pub const SYS_unshare: ::c_long = 310; ++pub const SYS_set_robust_list: ::c_long = 311; ++pub const SYS_get_robust_list: ::c_long = 312; ++pub const SYS_splice: ::c_long = 313; ++pub const SYS_sync_file_range: ::c_long = 314; ++pub const SYS_tee: ::c_long = 315; ++pub const SYS_vmsplice: ::c_long = 316; ++pub const SYS_move_pages: ::c_long = 317; ++pub const SYS_getcpu: ::c_long = 318; ++pub const SYS_epoll_pwait: ::c_long = 319; ++pub const SYS_utimensat: ::c_long = 320; ++pub const SYS_signalfd: ::c_long = 321; ++pub const SYS_timerfd_create: ::c_long = 322; ++pub const SYS_eventfd: ::c_long = 323; ++pub const SYS_fallocate: ::c_long = 324; ++pub const SYS_timerfd_settime: ::c_long = 325; ++pub const SYS_timerfd_gettime: ::c_long = 326; ++pub const SYS_signalfd4: ::c_long = 327; ++pub const SYS_eventfd2: ::c_long = 328; ++pub const SYS_epoll_create1: ::c_long = 329; ++pub const SYS_dup3: ::c_long = 330; ++pub const SYS_pipe2: ::c_long = 331; ++pub const SYS_inotify_init1: ::c_long = 332; ++pub const SYS_preadv: ::c_long = 333; ++pub const SYS_pwritev: ::c_long = 334; ++pub const SYS_rt_tgsigqueueinfo: ::c_long = 335; ++pub const SYS_perf_event_open: ::c_long = 336; ++pub const SYS_recvmmsg: ::c_long = 337; ++pub const SYS_fanotify_init: ::c_long = 338; ++pub const SYS_fanotify_mark: ::c_long = 339; ++pub const SYS_prlimit64: ::c_long = 340; ++pub const SYS_name_to_handle_at: ::c_long = 341; ++pub const SYS_open_by_handle_at: ::c_long = 342; ++pub const SYS_clock_adjtime: ::c_long = 343; ++pub const SYS_syncfs: ::c_long = 344; ++pub const SYS_sendmmsg: ::c_long = 345; ++pub const SYS_setns: ::c_long = 346; ++pub const SYS_process_vm_readv: ::c_long = 347; ++pub const SYS_process_vm_writev: ::c_long = 348; ++pub const SYS_kcmp: ::c_long = 349; ++pub const SYS_finit_module: ::c_long = 350; ++pub const SYS_sched_setattr: ::c_long = 351; ++pub const SYS_sched_getattr: ::c_long = 352; ++pub const SYS_renameat2: ::c_long = 353; ++pub const SYS_seccomp: ::c_long = 354; ++pub const SYS_getrandom: ::c_long = 355; ++pub const SYS_memfd_create: ::c_long = 356; ++pub const SYS_bpf: ::c_long = 357; ++pub const SYS_execveat: ::c_long = 358; ++pub const SYS_socket: ::c_long = 359; ++pub const SYS_socketpair: ::c_long = 360; ++pub const SYS_bind: ::c_long = 361; ++pub const SYS_connect: ::c_long = 362; ++pub const SYS_listen: ::c_long = 363; ++pub const SYS_accept4: ::c_long = 364; ++pub const SYS_getsockopt: ::c_long = 365; ++pub const SYS_setsockopt: ::c_long = 366; ++pub const SYS_getsockname: ::c_long = 367; ++pub const SYS_getpeername: ::c_long = 368; ++pub const SYS_sendto: ::c_long = 369; ++pub const SYS_sendmsg: ::c_long = 370; ++pub const SYS_recvfrom: ::c_long = 371; ++pub const SYS_recvmsg: ::c_long = 372; ++pub const SYS_shutdown: ::c_long = 373; ++pub const SYS_userfaultfd: ::c_long = 374; ++pub const SYS_membarrier: ::c_long = 375; ++pub const SYS_mlock2: ::c_long = 376; ++pub const SYS_copy_file_range: ::c_long = 377; ++pub const SYS_preadv2: ::c_long = 378; ++pub const SYS_pwritev2: ::c_long = 379; ++// FIXME syscalls 380-382 have been added in musl 1.16 ++// See discussion https://github.com/rust-lang/libc/pull/699 ++ ++// offsets in user_regs_structs, from sys/reg.h ++pub const EBX: ::c_int = 0; ++pub const ECX: ::c_int = 1; ++pub const EDX: ::c_int = 2; ++pub const ESI: ::c_int = 3; ++pub const EDI: ::c_int = 4; ++pub const EBP: ::c_int = 5; ++pub const EAX: ::c_int = 6; ++pub const DS: ::c_int = 7; ++pub const ES: ::c_int = 8; ++pub const FS: ::c_int = 9; ++pub const GS: ::c_int = 10; ++pub const ORIG_EAX: ::c_int = 11; ++pub const EIP: ::c_int = 12; ++pub const CS: ::c_int = 13; ++pub const EFL: ::c_int = 14; ++pub const UESP: ::c_int = 15; ++pub const SS: ::c_int = 16; diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b64/aarch64.rs index 000000000,000000000..fa103aaca new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b64/aarch64.rs @@@ -1,0 -1,0 +1,7 @@@ ++pub type c_char = u8; ++pub type __u64 = ::c_ulonglong; ++ ++pub const SYS_pivot_root: ::c_long = 41; ++pub const SYS_gettid: ::c_long = 178; ++pub const SYS_perf_event_open: ::c_long = 241; ++pub const SYS_memfd_create: ::c_long = 279; diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b64/mod.rs index 000000000,000000000..cdce288b3 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b64/mod.rs @@@ -1,0 -1,0 +1,430 @@@ ++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 statfs64 { ++ pub f_type: ::c_ulong, ++ pub f_bsize: ::c_ulong, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_flags: ::c_ulong, ++ pub f_spare: [::c_ulong; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct stack_t { ++ pub ss_sp: *mut ::c_void, ++ pub ss_flags: ::c_int, ++ pub ss_size: ::size_t ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [u64; 7] ++ } ++ ++ pub struct sigset_t { ++ __val: [::c_ulong; 16], ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, ++ pub shm_atime: ::time_t, ++ pub shm_dtime: ::time_t, ++ pub shm_ctime: ::time_t, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::c_ulong, ++ __pad1: ::c_ulong, ++ __pad2: ::c_ulong, ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ pub msg_stime: ::time_t, ++ pub msg_rtime: ::time_t, ++ pub msg_ctime: ::time_t, ++ __msg_cbytes: ::c_ulong, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ __pad1: ::c_ulong, ++ __pad2: ::c_ulong, ++ } ++ ++ pub struct statfs { ++ pub f_type: ::c_ulong, ++ pub f_bsize: ::c_ulong, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_flags: ::c_ulong, ++ pub f_spare: [::c_ulong; 4], ++ } ++ ++ pub struct msghdr { ++ pub msg_name: *mut ::c_void, ++ pub msg_namelen: ::socklen_t, ++ pub msg_iov: *mut ::iovec, ++ pub msg_iovlen: ::c_int, ++ __pad1: ::c_int, ++ pub msg_control: *mut ::c_void, ++ pub msg_controllen: ::socklen_t, ++ __pad2: ::socklen_t, ++ pub msg_flags: ::c_int, ++ } ++ ++ pub struct cmsghdr { ++ pub cmsg_len: ::socklen_t, ++ pub __pad1: ::c_int, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct sem_t { ++ __val: [::c_int; 8], ++ } ++ ++ pub struct siginfo_t { ++ pub si_signo: ::c_int, ++ pub si_errno: ::c_int, ++ pub si_code: ::c_int, ++ pub _pad: [::c_int; 29], ++ _align: [usize; 0], ++ } ++} ++ ++pub 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 O_LARGEFILE: ::c_int = 0; ++ ++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 ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const EAFNOSUPPORT: ::c_int = 97; ++pub const EADDRINUSE: ::c_int = 98; ++pub const EADDRNOTAVAIL: ::c_int = 99; ++pub const ENETDOWN: ::c_int = 100; ++pub const ENETUNREACH: ::c_int = 101; ++pub const ENETRESET: ::c_int = 102; ++pub const ECONNABORTED: ::c_int = 103; ++pub const ECONNRESET: ::c_int = 104; ++pub const ENOBUFS: ::c_int = 105; ++pub const EISCONN: ::c_int = 106; ++pub const ENOTCONN: ::c_int = 107; ++pub const ESHUTDOWN: ::c_int = 108; ++pub const ETOOMANYREFS: ::c_int = 109; ++pub const ETIMEDOUT: ::c_int = 110; ++pub const ECONNREFUSED: ::c_int = 111; ++pub const EHOSTDOWN: ::c_int = 112; ++pub const EHOSTUNREACH: ::c_int = 113; ++pub const EALREADY: ::c_int = 114; ++pub const EINPROGRESS: ::c_int = 115; ++pub const ESTALE: ::c_int = 116; ++pub const EUCLEAN: ::c_int = 117; ++pub const ENOTNAM: ::c_int = 118; ++pub const ENAVAIL: ::c_int = 119; ++pub const EISNAM: ::c_int = 120; ++pub const EREMOTEIO: ::c_int = 121; ++pub const EDQUOT: ::c_int = 122; ++pub const ENOMEDIUM: ::c_int = 123; ++pub const EMEDIUMTYPE: ::c_int = 124; ++pub const ECANCELED: ::c_int = 125; ++pub const ENOKEY: ::c_int = 126; ++pub const EKEYEXPIRED: ::c_int = 127; ++pub const EKEYREVOKED: ::c_int = 128; ++pub const EKEYREJECTED: ::c_int = 129; ++pub const EOWNERDEAD: ::c_int = 130; ++pub const ENOTRECOVERABLE: ::c_int = 131; ++pub const ERFKILL: ::c_int = 132; ++pub const EHWPOISON: ::c_int = 133; ++ ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_TYPE: ::c_int = 3; ++pub const SO_ERROR: ::c_int = 4; ++pub const SO_DONTROUTE: ::c_int = 5; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SO_SNDBUF: ::c_int = 7; ++pub const SO_RCVBUF: ::c_int = 8; ++pub const SO_KEEPALIVE: ::c_int = 9; ++pub const SO_OOBINLINE: ::c_int = 10; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_LINGER: ::c_int = 13; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_REUSEPORT: ::c_int = 15; ++pub const SO_PASSCRED: ::c_int = 16; ++pub const SO_PEERCRED: ::c_int = 17; ++pub const SO_RCVLOWAT: ::c_int = 18; ++pub const SO_SNDLOWAT: ::c_int = 19; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_SNDTIMEO: ::c_int = 21; ++pub const SO_ACCEPTCONN: ::c_int = 30; ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_PROTOCOL: ::c_int = 38; ++pub const SO_DOMAIN: ::c_int = 39; ++ ++pub const SA_ONSTACK: ::c_int = 0x08000000; ++pub const SA_SIGINFO: ::c_int = 0x00000004; ++pub const SA_NOCLDWAIT: ::c_int = 0x00000002; ++ ++pub const SIGCHLD: ::c_int = 17; ++pub const SIGBUS: ::c_int = 7; ++pub const SIGTTIN: ::c_int = 21; ++pub const SIGTTOU: ::c_int = 22; ++pub const SIGXCPU: ::c_int = 24; ++pub const SIGXFSZ: ::c_int = 25; ++pub const SIGVTALRM: ::c_int = 26; ++pub const SIGPROF: ::c_int = 27; ++pub const SIGWINCH: ::c_int = 28; ++pub const SIGUSR1: ::c_int = 10; ++pub const SIGUSR2: ::c_int = 12; ++pub const SIGCONT: ::c_int = 18; ++pub const SIGSTOP: ::c_int = 19; ++pub const SIGTSTP: ::c_int = 20; ++pub const SIGURG: ::c_int = 23; ++pub const SIGIO: ::c_int = 29; ++pub const SIGSYS: ::c_int = 31; ++pub const SIGSTKFLT: ::c_int = 16; ++pub const SIGPOLL: ::c_int = 29; ++pub const SIGPWR: ::c_int = 30; ++pub const SIG_SETMASK: ::c_int = 2; ++pub const SIG_BLOCK: ::c_int = 0x000000; ++pub const SIG_UNBLOCK: ::c_int = 0x01; ++ ++pub const EXTPROC: ::tcflag_t = 0x00010000; ++ ++pub const MAP_HUGETLB: ::c_int = 0x040000; ++ ++pub const F_GETLK: ::c_int = 5; ++pub const F_GETOWN: ::c_int = 9; ++pub const F_SETLK: ::c_int = 6; ++pub const F_SETLKW: ::c_int = 7; ++pub const F_SETOWN: ::c_int = 8; ++ ++pub const VEOF: usize = 4; ++pub const VEOL: usize = 11; ++pub const VEOL2: usize = 16; ++pub const VMIN: usize = 6; ++pub const IEXTEN: ::tcflag_t = 0x00008000; ++pub const TOSTOP: ::tcflag_t = 0x00000100; ++pub const FLUSHO: ::tcflag_t = 0x00001000; ++ ++pub const TCGETS: ::c_int = 0x5401; ++pub const TCSETS: ::c_int = 0x5402; ++pub const TCSETSW: ::c_int = 0x5403; ++pub const TCSETSF: ::c_int = 0x5404; ++pub const TCGETA: ::c_int = 0x5405; ++pub const TCSETA: ::c_int = 0x5406; ++pub const TCSETAW: ::c_int = 0x5407; ++pub const TCSETAF: ::c_int = 0x5408; ++pub const TCSBRK: ::c_int = 0x5409; ++pub const TCXONC: ::c_int = 0x540A; ++pub const TCFLSH: ::c_int = 0x540B; ++pub const TIOCGSOFTCAR: ::c_int = 0x5419; ++pub const TIOCSSOFTCAR: ::c_int = 0x541A; ++pub const TIOCLINUX: ::c_int = 0x541C; ++pub const TIOCGSERIAL: ::c_int = 0x541E; ++pub const TIOCEXCL: ::c_int = 0x540C; ++pub const TIOCNXCL: ::c_int = 0x540D; ++pub const TIOCSCTTY: ::c_int = 0x540E; ++pub const TIOCGPGRP: ::c_int = 0x540F; ++pub const TIOCSPGRP: ::c_int = 0x5410; ++pub const TIOCOUTQ: ::c_int = 0x5411; ++pub const TIOCSTI: ::c_int = 0x5412; ++pub const TIOCGWINSZ: ::c_int = 0x5413; ++pub const TIOCSWINSZ: ::c_int = 0x5414; ++pub const TIOCMGET: ::c_int = 0x5415; ++pub const TIOCMBIS: ::c_int = 0x5416; ++pub const TIOCMBIC: ::c_int = 0x5417; ++pub const TIOCMSET: ::c_int = 0x5418; ++pub const FIONREAD: ::c_int = 0x541B; ++pub const TIOCCONS: ::c_int = 0x541D; ++ ++pub const POLLWRNORM: ::c_short = 0x100; ++pub const POLLWRBAND: ::c_short = 0x200; ++ ++pub const TIOCM_LE: ::c_int = 0x001; ++pub const TIOCM_DTR: ::c_int = 0x002; ++pub const TIOCM_RTS: ::c_int = 0x004; ++pub const TIOCM_ST: ::c_int = 0x008; ++pub const TIOCM_SR: ::c_int = 0x010; ++pub const TIOCM_CTS: ::c_int = 0x020; ++pub const TIOCM_CAR: ::c_int = 0x040; ++pub const TIOCM_RNG: ::c_int = 0x080; ++pub const TIOCM_DSR: ::c_int = 0x100; ++pub const TIOCM_CD: ::c_int = TIOCM_CAR; ++pub const TIOCM_RI: ::c_int = TIOCM_RNG; ++ ++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 --cc vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b64/powerpc64.rs index 000000000,000000000..4e8b9adbf new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b64/powerpc64.rs @@@ -1,0 -1,0 +1,7 @@@ ++pub type c_char = u8; ++pub type __u64 = ::c_ulong; ++ ++pub const SYS_pivot_root: ::c_long = 203; ++pub const SYS_gettid: ::c_long = 207; ++pub const SYS_perf_event_open: ::c_long = 319; ++pub const SYS_memfd_create: ::c_long = 360; diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b64/x86_64.rs index 000000000,000000000..f81efdc6d new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/musl/b64/x86_64.rs @@@ -1,0 -1,0 +1,380 @@@ ++pub type c_char = i8; ++pub type __u64 = ::c_ulonglong; ++ ++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], ++ } ++} ++ ++// Syscall table ++ ++pub const SYS_read: ::c_long = 0; ++pub const SYS_write: ::c_long = 1; ++pub const SYS_open: ::c_long = 2; ++pub const SYS_close: ::c_long = 3; ++pub const SYS_stat: ::c_long = 4; ++pub const SYS_fstat: ::c_long = 5; ++pub const SYS_lstat: ::c_long = 6; ++pub const SYS_poll: ::c_long = 7; ++pub const SYS_lseek: ::c_long = 8; ++pub const SYS_mmap: ::c_long = 9; ++pub const SYS_mprotect: ::c_long = 10; ++pub const SYS_munmap: ::c_long = 11; ++pub const SYS_brk: ::c_long = 12; ++pub const SYS_rt_sigaction: ::c_long = 13; ++pub const SYS_rt_sigprocmask: ::c_long = 14; ++pub const SYS_rt_sigreturn: ::c_long = 15; ++pub const SYS_ioctl: ::c_long = 16; ++pub const SYS_pread64: ::c_long = 17; ++pub const SYS_pwrite64: ::c_long = 18; ++pub const SYS_readv: ::c_long = 19; ++pub const SYS_writev: ::c_long = 20; ++pub const SYS_access: ::c_long = 21; ++pub const SYS_pipe: ::c_long = 22; ++pub const SYS_select: ::c_long = 23; ++pub const SYS_sched_yield: ::c_long = 24; ++pub const SYS_mremap: ::c_long = 25; ++pub const SYS_msync: ::c_long = 26; ++pub const SYS_mincore: ::c_long = 27; ++pub const SYS_madvise: ::c_long = 28; ++pub const SYS_shmget: ::c_long = 29; ++pub const SYS_shmat: ::c_long = 30; ++pub const SYS_shmctl: ::c_long = 31; ++pub const SYS_dup: ::c_long = 32; ++pub const SYS_dup2: ::c_long = 33; ++pub const SYS_pause: ::c_long = 34; ++pub const SYS_nanosleep: ::c_long = 35; ++pub const SYS_getitimer: ::c_long = 36; ++pub const SYS_alarm: ::c_long = 37; ++pub const SYS_setitimer: ::c_long = 38; ++pub const SYS_getpid: ::c_long = 39; ++pub const SYS_sendfile: ::c_long = 40; ++pub const SYS_socket: ::c_long = 41; ++pub const SYS_connect: ::c_long = 42; ++pub const SYS_accept: ::c_long = 43; ++pub const SYS_sendto: ::c_long = 44; ++pub const SYS_recvfrom: ::c_long = 45; ++pub const SYS_sendmsg: ::c_long = 46; ++pub const SYS_recvmsg: ::c_long = 47; ++pub const SYS_shutdown: ::c_long = 48; ++pub const SYS_bind: ::c_long = 49; ++pub const SYS_listen: ::c_long = 50; ++pub const SYS_getsockname: ::c_long = 51; ++pub const SYS_getpeername: ::c_long = 52; ++pub const SYS_socketpair: ::c_long = 53; ++pub const SYS_setsockopt: ::c_long = 54; ++pub const SYS_getsockopt: ::c_long = 55; ++pub const SYS_clone: ::c_long = 56; ++pub const SYS_fork: ::c_long = 57; ++pub const SYS_vfork: ::c_long = 58; ++pub const SYS_execve: ::c_long = 59; ++pub const SYS_exit: ::c_long = 60; ++pub const SYS_wait4: ::c_long = 61; ++pub const SYS_kill: ::c_long = 62; ++pub const SYS_uname: ::c_long = 63; ++pub const SYS_semget: ::c_long = 64; ++pub const SYS_semop: ::c_long = 65; ++pub const SYS_semctl: ::c_long = 66; ++pub const SYS_shmdt: ::c_long = 67; ++pub const SYS_msgget: ::c_long = 68; ++pub const SYS_msgsnd: ::c_long = 69; ++pub const SYS_msgrcv: ::c_long = 70; ++pub const SYS_msgctl: ::c_long = 71; ++pub const SYS_fcntl: ::c_long = 72; ++pub const SYS_flock: ::c_long = 73; ++pub const SYS_fsync: ::c_long = 74; ++pub const SYS_fdatasync: ::c_long = 75; ++pub const SYS_truncate: ::c_long = 76; ++pub const SYS_ftruncate: ::c_long = 77; ++pub const SYS_getdents: ::c_long = 78; ++pub const SYS_getcwd: ::c_long = 79; ++pub const SYS_chdir: ::c_long = 80; ++pub const SYS_fchdir: ::c_long = 81; ++pub const SYS_rename: ::c_long = 82; ++pub const SYS_mkdir: ::c_long = 83; ++pub const SYS_rmdir: ::c_long = 84; ++pub const SYS_creat: ::c_long = 85; ++pub const SYS_link: ::c_long = 86; ++pub const SYS_unlink: ::c_long = 87; ++pub const SYS_symlink: ::c_long = 88; ++pub const SYS_readlink: ::c_long = 89; ++pub const SYS_chmod: ::c_long = 90; ++pub const SYS_fchmod: ::c_long = 91; ++pub const SYS_chown: ::c_long = 92; ++pub const SYS_fchown: ::c_long = 93; ++pub const SYS_lchown: ::c_long = 94; ++pub const SYS_umask: ::c_long = 95; ++pub const SYS_gettimeofday: ::c_long = 96; ++pub const SYS_getrlimit: ::c_long = 97; ++pub const SYS_getrusage: ::c_long = 98; ++pub const SYS_sysinfo: ::c_long = 99; ++pub const SYS_times: ::c_long = 100; ++pub const SYS_ptrace: ::c_long = 101; ++pub const SYS_getuid: ::c_long = 102; ++pub const SYS_syslog: ::c_long = 103; ++pub const SYS_getgid: ::c_long = 104; ++pub const SYS_setuid: ::c_long = 105; ++pub const SYS_setgid: ::c_long = 106; ++pub const SYS_geteuid: ::c_long = 107; ++pub const SYS_getegid: ::c_long = 108; ++pub const SYS_setpgid: ::c_long = 109; ++pub const SYS_getppid: ::c_long = 110; ++pub const SYS_getpgrp: ::c_long = 111; ++pub const SYS_setsid: ::c_long = 112; ++pub const SYS_setreuid: ::c_long = 113; ++pub const SYS_setregid: ::c_long = 114; ++pub const SYS_getgroups: ::c_long = 115; ++pub const SYS_setgroups: ::c_long = 116; ++pub const SYS_setresuid: ::c_long = 117; ++pub const SYS_getresuid: ::c_long = 118; ++pub const SYS_setresgid: ::c_long = 119; ++pub const SYS_getresgid: ::c_long = 120; ++pub const SYS_getpgid: ::c_long = 121; ++pub const SYS_setfsuid: ::c_long = 122; ++pub const SYS_setfsgid: ::c_long = 123; ++pub const SYS_getsid: ::c_long = 124; ++pub const SYS_capget: ::c_long = 125; ++pub const SYS_capset: ::c_long = 126; ++pub const SYS_rt_sigpending: ::c_long = 127; ++pub const SYS_rt_sigtimedwait: ::c_long = 128; ++pub const SYS_rt_sigqueueinfo: ::c_long = 129; ++pub const SYS_rt_sigsuspend: ::c_long = 130; ++pub const SYS_sigaltstack: ::c_long = 131; ++pub const SYS_utime: ::c_long = 132; ++pub const SYS_mknod: ::c_long = 133; ++pub const SYS_uselib: ::c_long = 134; ++pub const SYS_personality: ::c_long = 135; ++pub const SYS_ustat: ::c_long = 136; ++pub const SYS_statfs: ::c_long = 137; ++pub const SYS_fstatfs: ::c_long = 138; ++pub const SYS_sysfs: ::c_long = 139; ++pub const SYS_getpriority: ::c_long = 140; ++pub const SYS_setpriority: ::c_long = 141; ++pub const SYS_sched_setparam: ::c_long = 142; ++pub const SYS_sched_getparam: ::c_long = 143; ++pub const SYS_sched_setscheduler: ::c_long = 144; ++pub const SYS_sched_getscheduler: ::c_long = 145; ++pub const SYS_sched_get_priority_max: ::c_long = 146; ++pub const SYS_sched_get_priority_min: ::c_long = 147; ++pub const SYS_sched_rr_get_interval: ::c_long = 148; ++pub const SYS_mlock: ::c_long = 149; ++pub const SYS_munlock: ::c_long = 150; ++pub const SYS_mlockall: ::c_long = 151; ++pub const SYS_munlockall: ::c_long = 152; ++pub const SYS_vhangup: ::c_long = 153; ++pub const SYS_modify_ldt: ::c_long = 154; ++pub const SYS_pivot_root: ::c_long = 155; ++pub const SYS__sysctl: ::c_long = 156; ++pub const SYS_prctl: ::c_long = 157; ++pub const SYS_arch_prctl: ::c_long = 158; ++pub const SYS_adjtimex: ::c_long = 159; ++pub const SYS_setrlimit: ::c_long = 160; ++pub const SYS_chroot: ::c_long = 161; ++pub const SYS_sync: ::c_long = 162; ++pub const SYS_acct: ::c_long = 163; ++pub const SYS_settimeofday: ::c_long = 164; ++pub const SYS_mount: ::c_long = 165; ++pub const SYS_umount2: ::c_long = 166; ++pub const SYS_swapon: ::c_long = 167; ++pub const SYS_swapoff: ::c_long = 168; ++pub const SYS_reboot: ::c_long = 169; ++pub const SYS_sethostname: ::c_long = 170; ++pub const SYS_setdomainname: ::c_long = 171; ++pub const SYS_iopl: ::c_long = 172; ++pub const SYS_ioperm: ::c_long = 173; ++pub const SYS_create_module: ::c_long = 174; ++pub const SYS_init_module: ::c_long = 175; ++pub const SYS_delete_module: ::c_long = 176; ++pub const SYS_get_kernel_syms: ::c_long = 177; ++pub const SYS_query_module: ::c_long = 178; ++pub const SYS_quotactl: ::c_long = 179; ++pub const SYS_nfsservctl: ::c_long = 180; ++pub const SYS_getpmsg: ::c_long = 181; ++pub const SYS_putpmsg: ::c_long = 182; ++pub const SYS_afs_syscall: ::c_long = 183; ++pub const SYS_tuxcall: ::c_long = 184; ++pub const SYS_security: ::c_long = 185; ++pub const SYS_gettid: ::c_long = 186; ++pub const SYS_readahead: ::c_long = 187; ++pub const SYS_setxattr: ::c_long = 188; ++pub const SYS_lsetxattr: ::c_long = 189; ++pub const SYS_fsetxattr: ::c_long = 190; ++pub const SYS_getxattr: ::c_long = 191; ++pub const SYS_lgetxattr: ::c_long = 192; ++pub const SYS_fgetxattr: ::c_long = 193; ++pub const SYS_listxattr: ::c_long = 194; ++pub const SYS_llistxattr: ::c_long = 195; ++pub const SYS_flistxattr: ::c_long = 196; ++pub const SYS_removexattr: ::c_long = 197; ++pub const SYS_lremovexattr: ::c_long = 198; ++pub const SYS_fremovexattr: ::c_long = 199; ++pub const SYS_tkill: ::c_long = 200; ++pub const SYS_time: ::c_long = 201; ++pub const SYS_futex: ::c_long = 202; ++pub const SYS_sched_setaffinity: ::c_long = 203; ++pub const SYS_sched_getaffinity: ::c_long = 204; ++pub const SYS_set_thread_area: ::c_long = 205; ++pub const SYS_io_setup: ::c_long = 206; ++pub const SYS_io_destroy: ::c_long = 207; ++pub const SYS_io_getevents: ::c_long = 208; ++pub const SYS_io_submit: ::c_long = 209; ++pub const SYS_io_cancel: ::c_long = 210; ++pub const SYS_get_thread_area: ::c_long = 211; ++pub const SYS_lookup_dcookie: ::c_long = 212; ++pub const SYS_epoll_create: ::c_long = 213; ++pub const SYS_epoll_ctl_old: ::c_long = 214; ++pub const SYS_epoll_wait_old: ::c_long = 215; ++pub const SYS_remap_file_pages: ::c_long = 216; ++pub const SYS_getdents64: ::c_long = 217; ++pub const SYS_set_tid_address: ::c_long = 218; ++pub const SYS_restart_syscall: ::c_long = 219; ++pub const SYS_semtimedop: ::c_long = 220; ++pub const SYS_fadvise64: ::c_long = 221; ++pub const SYS_timer_create: ::c_long = 222; ++pub const SYS_timer_settime: ::c_long = 223; ++pub const SYS_timer_gettime: ::c_long = 224; ++pub const SYS_timer_getoverrun: ::c_long = 225; ++pub const SYS_timer_delete: ::c_long = 226; ++pub const SYS_clock_settime: ::c_long = 227; ++pub const SYS_clock_gettime: ::c_long = 228; ++pub const SYS_clock_getres: ::c_long = 229; ++pub const SYS_clock_nanosleep: ::c_long = 230; ++pub const SYS_exit_group: ::c_long = 231; ++pub const SYS_epoll_wait: ::c_long = 232; ++pub const SYS_epoll_ctl: ::c_long = 233; ++pub const SYS_tgkill: ::c_long = 234; ++pub const SYS_utimes: ::c_long = 235; ++pub const SYS_vserver: ::c_long = 236; ++pub const SYS_mbind: ::c_long = 237; ++pub const SYS_set_mempolicy: ::c_long = 238; ++pub const SYS_get_mempolicy: ::c_long = 239; ++pub const SYS_mq_open: ::c_long = 240; ++pub const SYS_mq_unlink: ::c_long = 241; ++pub const SYS_mq_timedsend: ::c_long = 242; ++pub const SYS_mq_timedreceive: ::c_long = 243; ++pub const SYS_mq_notify: ::c_long = 244; ++pub const SYS_mq_getsetattr: ::c_long = 245; ++pub const SYS_kexec_load: ::c_long = 246; ++pub const SYS_waitid: ::c_long = 247; ++pub const SYS_add_key: ::c_long = 248; ++pub const SYS_request_key: ::c_long = 249; ++pub const SYS_keyctl: ::c_long = 250; ++pub const SYS_ioprio_set: ::c_long = 251; ++pub const SYS_ioprio_get: ::c_long = 252; ++pub const SYS_inotify_init: ::c_long = 253; ++pub const SYS_inotify_add_watch: ::c_long = 254; ++pub const SYS_inotify_rm_watch: ::c_long = 255; ++pub const SYS_migrate_pages: ::c_long = 256; ++pub const SYS_openat: ::c_long = 257; ++pub const SYS_mkdirat: ::c_long = 258; ++pub const SYS_mknodat: ::c_long = 259; ++pub const SYS_fchownat: ::c_long = 260; ++pub const SYS_futimesat: ::c_long = 261; ++pub const SYS_newfstatat: ::c_long = 262; ++pub const SYS_unlinkat: ::c_long = 263; ++pub const SYS_renameat: ::c_long = 264; ++pub const SYS_linkat: ::c_long = 265; ++pub const SYS_symlinkat: ::c_long = 266; ++pub const SYS_readlinkat: ::c_long = 267; ++pub const SYS_fchmodat: ::c_long = 268; ++pub const SYS_faccessat: ::c_long = 269; ++pub const SYS_pselect6: ::c_long = 270; ++pub const SYS_ppoll: ::c_long = 271; ++pub const SYS_unshare: ::c_long = 272; ++pub const SYS_set_robust_list: ::c_long = 273; ++pub const SYS_get_robust_list: ::c_long = 274; ++pub const SYS_splice: ::c_long = 275; ++pub const SYS_tee: ::c_long = 276; ++pub const SYS_sync_file_range: ::c_long = 277; ++pub const SYS_vmsplice: ::c_long = 278; ++pub const SYS_move_pages: ::c_long = 279; ++pub const SYS_utimensat: ::c_long = 280; ++pub const SYS_epoll_pwait: ::c_long = 281; ++pub const SYS_signalfd: ::c_long = 282; ++pub const SYS_timerfd_create: ::c_long = 283; ++pub const SYS_eventfd: ::c_long = 284; ++pub const SYS_fallocate: ::c_long = 285; ++pub const SYS_timerfd_settime: ::c_long = 286; ++pub const SYS_timerfd_gettime: ::c_long = 287; ++pub const SYS_accept4: ::c_long = 288; ++pub const SYS_signalfd4: ::c_long = 289; ++pub const SYS_eventfd2: ::c_long = 290; ++pub const SYS_epoll_create1: ::c_long = 291; ++pub const SYS_dup3: ::c_long = 292; ++pub const SYS_pipe2: ::c_long = 293; ++pub const SYS_inotify_init1: ::c_long = 294; ++pub const SYS_preadv: ::c_long = 295; ++pub const SYS_pwritev: ::c_long = 296; ++pub const SYS_rt_tgsigqueueinfo: ::c_long = 297; ++pub const SYS_perf_event_open: ::c_long = 298; ++pub const SYS_recvmmsg: ::c_long = 299; ++pub const SYS_fanotify_init: ::c_long = 300; ++pub const SYS_fanotify_mark: ::c_long = 301; ++pub const SYS_prlimit64: ::c_long = 302; ++pub const SYS_name_to_handle_at: ::c_long = 303; ++pub const SYS_open_by_handle_at: ::c_long = 304; ++pub const SYS_clock_adjtime: ::c_long = 305; ++pub const SYS_syncfs: ::c_long = 306; ++pub const SYS_sendmmsg: ::c_long = 307; ++pub const SYS_setns: ::c_long = 308; ++pub const SYS_getcpu: ::c_long = 309; ++pub const SYS_process_vm_readv: ::c_long = 310; ++pub const SYS_process_vm_writev: ::c_long = 311; ++pub const SYS_kcmp: ::c_long = 312; ++pub const SYS_finit_module: ::c_long = 313; ++pub const SYS_sched_setattr: ::c_long = 314; ++pub const SYS_sched_getattr: ::c_long = 315; ++pub const SYS_renameat2: ::c_long = 316; ++pub const SYS_seccomp: ::c_long = 317; ++pub const SYS_getrandom: ::c_long = 318; ++pub const SYS_memfd_create: ::c_long = 319; ++pub const SYS_kexec_file_load: ::c_long = 320; ++pub const SYS_bpf: ::c_long = 321; ++pub const SYS_execveat: ::c_long = 322; ++pub const SYS_userfaultfd: ::c_long = 323; ++pub const SYS_membarrier: ::c_long = 324; ++pub const SYS_mlock2: ::c_long = 325; ++pub const SYS_copy_file_range: ::c_long = 326; ++pub const SYS_preadv2: ::c_long = 327; ++pub const SYS_pwritev2: ::c_long = 328; ++// FIXME syscalls 329-331 have been added in musl 1.16 ++// See discussion https://github.com/rust-lang/libc/pull/699 ++ ++// offsets in user_regs_structs, from sys/reg.h ++pub const R15: ::c_int = 0; ++pub const R14: ::c_int = 1; ++pub const R13: ::c_int = 2; ++pub const R12: ::c_int = 3; ++pub const RBP: ::c_int = 4; ++pub const RBX: ::c_int = 5; ++pub const R11: ::c_int = 6; ++pub const R10: ::c_int = 7; ++pub const R9: ::c_int = 8; ++pub const R8: ::c_int = 9; ++pub const RAX: ::c_int = 10; ++pub const RCX: ::c_int = 11; ++pub const RDX: ::c_int = 12; ++pub const RSI: ::c_int = 13; ++pub const RDI: ::c_int = 14; ++pub const ORIG_RAX: ::c_int = 15; ++pub const RIP: ::c_int = 16; ++pub const CS: ::c_int = 17; ++pub const EFLAGS: ::c_int = 18; ++pub const RSP: ::c_int = 19; ++pub const SS: ::c_int = 20; ++pub const FS_BASE: ::c_int = 21; ++pub const GS_BASE: ::c_int = 22; ++pub const DS: ::c_int = 23; ++pub const ES: ::c_int = 24; ++pub const FS: ::c_int = 25; ++pub const GS: ::c_int = 26; diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/musl/mod.rs index 000000000,000000000..5156d2f24 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/musl/mod.rs @@@ -1,0 -1,0 +1,327 @@@ ++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 aiocb { ++ pub aio_fildes: ::c_int, ++ pub aio_lio_opcode: ::c_int, ++ pub aio_reqprio: ::c_int, ++ pub aio_buf: *mut ::c_void, ++ pub aio_nbytes: ::size_t, ++ pub aio_sigevent: ::sigevent, ++ __td: *mut ::c_void, ++ __lock: [::c_int; 2], ++ __err: ::c_int, ++ __ret: ::ssize_t, ++ pub aio_offset: off_t, ++ __next: *mut ::c_void, ++ __prev: *mut ::c_void, ++ #[cfg(target_pointer_width = "32")] ++ __dummy4: [::c_char; 24], ++ #[cfg(target_pointer_width = "64")] ++ __dummy4: [::c_char; 16], ++ } ++ ++ pub struct sigaction { ++ pub sa_sigaction: ::sighandler_t, ++ pub sa_mask: ::sigset_t, ++ pub sa_flags: ::c_int, ++ pub sa_restorer: ::dox::Option, ++ } ++ ++ 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 SFD_CLOEXEC: ::c_int = 0x080000; ++ ++pub const NCCS: usize = 32; ++ ++pub const O_TRUNC: ::c_int = 512; ++pub const O_NOATIME: ::c_int = 0o1000000; ++pub const O_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EBFONT: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const EDOTDOT: ::c_int = 73; ++ ++pub const SA_NODEFER: ::c_int = 0x40000000; ++pub const SA_RESETHAND: ::c_int = 0x80000000; ++pub const SA_RESTART: ::c_int = 0x10000000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000001; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x80000; ++ ++pub const BUFSIZ: ::c_uint = 1024; ++pub const TMP_MAX: ::c_uint = 10000; ++pub const FOPEN_MAX: ::c_uint = 1000; ++pub const O_PATH: ::c_int = 0o10000000; ++pub const O_EXEC: ::c_int = 0o10000000; ++pub const O_SEARCH: ::c_int = 0o10000000; ++pub const O_ACCMODE: ::c_int = 0o10000003; ++pub const O_NDELAY: ::c_int = O_NONBLOCK; ++pub const NI_MAXHOST: ::socklen_t = 255; ++pub const PTHREAD_STACK_MIN: ::size_t = 2048; ++pub const POSIX_FADV_DONTNEED: ::c_int = 4; ++pub const POSIX_FADV_NOREUSE: ::c_int = 5; ++ ++pub const POSIX_MADV_DONTNEED: ::c_int = 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 __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; ++ ++pub const CPU_SETSIZE: ::c_int = 128; ++ ++pub const PTRACE_TRACEME: ::c_int = 0; ++pub const PTRACE_PEEKTEXT: ::c_int = 1; ++pub const PTRACE_PEEKDATA: ::c_int = 2; ++pub const PTRACE_PEEKUSER: ::c_int = 3; ++pub const PTRACE_POKETEXT: ::c_int = 4; ++pub const PTRACE_POKEDATA: ::c_int = 5; ++pub const PTRACE_POKEUSER: ::c_int = 6; ++pub const PTRACE_CONT: ::c_int = 7; ++pub const PTRACE_KILL: ::c_int = 8; ++pub const PTRACE_SINGLESTEP: ::c_int = 9; ++pub const PTRACE_GETREGS: ::c_int = 12; ++pub const PTRACE_SETREGS: ::c_int = 13; ++pub const PTRACE_GETFPREGS: ::c_int = 14; ++pub const PTRACE_SETFPREGS: ::c_int = 15; ++pub const PTRACE_ATTACH: ::c_int = 16; ++pub const PTRACE_DETACH: ::c_int = 17; ++pub const PTRACE_GETFPXREGS: ::c_int = 18; ++pub const PTRACE_SETFPXREGS: ::c_int = 19; ++pub const PTRACE_SYSCALL: ::c_int = 24; ++pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; ++pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; ++pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; ++pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; ++pub const PTRACE_GETREGSET: ::c_int = 0x4204; ++pub const PTRACE_SETREGSET: ::c_int = 0x4205; ++pub const PTRACE_SEIZE: ::c_int = 0x4206; ++pub const PTRACE_INTERRUPT: ::c_int = 0x4207; ++pub const PTRACE_LISTEN: ::c_int = 0x4208; ++pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; ++ ++pub const EPOLLWAKEUP: ::c_int = 0x20000000; ++ ++pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK; ++ ++pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK; ++ ++pub const TCSANOW: ::c_int = 0; ++pub const TCSADRAIN: ::c_int = 1; ++pub const TCSAFLUSH: ::c_int = 2; ++ ++pub const TIOCINQ: ::c_int = ::FIONREAD; ++ ++pub const RTLD_GLOBAL: ::c_int = 0x100; ++pub const RTLD_NOLOAD: ::c_int = 0x4; ++ ++// TODO(#247) Temporarily musl-specific (available since musl 0.9.12 / Linux ++// kernel 3.10). See also notbsd/mod.rs ++pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; ++pub const CLOCK_TAI: ::clockid_t = 11; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const SIGSTKSZ: ::size_t = 8192; ++pub const MINSIGSTKSZ: ::size_t = 2048; ++pub const CBAUD: ::tcflag_t = 0o0010017; ++pub const TAB1: ::c_int = 0x00000800; ++pub const TAB2: ::c_int = 0x00001000; ++pub const TAB3: ::c_int = 0x00001800; ++pub const CR1: ::c_int = 0x00000200; ++pub const CR2: ::c_int = 0x00000400; ++pub const CR3: ::c_int = 0x00000600; ++pub const FF1: ::c_int = 0x00008000; ++pub const BS1: ::c_int = 0x00002000; ++pub const VT1: ::c_int = 0x00004000; ++pub const VWERASE: usize = 14; ++pub const VREPRINT: usize = 12; ++pub const VSUSP: usize = 10; ++pub const VSTART: usize = 8; ++pub const VSTOP: usize = 9; ++pub const VDISCARD: usize = 13; ++pub const VTIME: usize = 5; ++pub const IXON: ::tcflag_t = 0x00000400; ++pub const IXOFF: ::tcflag_t = 0x00001000; ++pub const ONLCR: ::tcflag_t = 0x4; ++pub const CSIZE: ::tcflag_t = 0x00000030; ++pub const CS6: ::tcflag_t = 0x00000010; ++pub const CS7: ::tcflag_t = 0x00000020; ++pub const CS8: ::tcflag_t = 0x00000030; ++pub const CSTOPB: ::tcflag_t = 0x00000040; ++pub const CREAD: ::tcflag_t = 0x00000080; ++pub const PARENB: ::tcflag_t = 0x00000100; ++pub const PARODD: ::tcflag_t = 0x00000200; ++pub const HUPCL: ::tcflag_t = 0x00000400; ++pub const CLOCAL: ::tcflag_t = 0x00000800; ++pub const ECHOKE: ::tcflag_t = 0x00000800; ++pub const ECHOE: ::tcflag_t = 0x00000010; ++pub const ECHOK: ::tcflag_t = 0x00000020; ++pub const ECHONL: ::tcflag_t = 0x00000040; ++pub const ECHOPRT: ::tcflag_t = 0x00000400; ++pub const ECHOCTL: ::tcflag_t = 0x00000200; ++pub const ISIG: ::tcflag_t = 0x00000001; ++pub const ICANON: ::tcflag_t = 0x00000002; ++pub const PENDIN: ::tcflag_t = 0x00004000; ++pub const NOFLSH: ::tcflag_t = 0x00000080; ++pub const CIBAUD: ::tcflag_t = 0o02003600000; ++pub const CBAUDEX: ::tcflag_t = 0o010000; ++pub const VSWTC: usize = 7; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const XTABS: ::tcflag_t = 0o014000; ++ ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const B57600: ::speed_t = 0o010001; ++pub const B115200: ::speed_t = 0o010002; ++pub const B230400: ::speed_t = 0o010003; ++pub const B460800: ::speed_t = 0o010004; ++pub const B500000: ::speed_t = 0o010005; ++pub const B576000: ::speed_t = 0o010006; ++pub const B921600: ::speed_t = 0o010007; ++pub const B1000000: ::speed_t = 0o010010; ++pub const B1152000: ::speed_t = 0o010011; ++pub const B1500000: ::speed_t = 0o010012; ++pub const B2000000: ::speed_t = 0o010013; ++pub const B2500000: ::speed_t = 0o010014; ++pub const B3000000: ::speed_t = 0o010015; ++pub const B3500000: ::speed_t = 0o010016; ++pub const B4000000: ::speed_t = 0o010017; ++ ++pub const SO_BINDTODEVICE: ::c_int = 25; ++pub const SO_TIMESTAMP: ::c_int = 29; ++pub const SO_MARK: ::c_int = 36; ++pub const SO_RXQ_OVFL: ::c_int = 40; ++pub const SO_PEEK_OFF: ::c_int = 42; ++pub const SO_BUSY_POLL: ::c_int = 46; ++ ++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", target_arch = "aarch64"))] { ++ mod b64; ++ pub use self::b64::*; ++ } else if #[cfg(any(target_arch = "x86", ++ target_arch = "mips", ++ target_arch = "arm"))] { ++ mod b32; ++ pub use self::b32::*; ++ } else { } ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/other/b32/arm.rs index 000000000,000000000..4de1f32ba new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/other/b32/arm.rs @@@ -1,0 -1,0 +1,251 @@@ ++pub type c_char = u8; ++pub type wchar_t = u32; ++ ++s! { ++ pub struct ipc_perm { ++ pub __key: ::key_t, ++ pub uid: ::uid_t, ++ pub gid: ::gid_t, ++ pub cuid: ::uid_t, ++ pub cgid: ::gid_t, ++ pub mode: ::c_ushort, ++ __pad1: ::c_ushort, ++ pub __seq: ::c_ushort, ++ __pad2: ::c_ushort, ++ __unused1: ::c_ulong, ++ __unused2: ::c_ulong ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::dev_t, ++ __pad1: ::c_uint, ++ __st_ino: ::ino_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ __pad2: ::c_uint, ++ pub st_size: ::off64_t, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt64_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_ino: ::ino64_t, ++ } ++ ++ pub struct statfs64 { ++ pub f_type: ::__fsword_t, ++ pub f_bsize: ::__fsword_t, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::__fsword_t, ++ pub f_frsize: ::__fsword_t, ++ pub f_flags: ::__fsword_t, ++ pub f_spare: [::__fsword_t; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ __f_unused: ::c_int, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, ++ pub shm_atime: ::time_t, ++ __unused1: ::c_ulong, ++ pub shm_dtime: ::time_t, ++ __unused2: ::c_ulong, ++ pub shm_ctime: ::time_t, ++ __unused3: ::c_ulong, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::shmatt_t, ++ __unused4: ::c_ulong, ++ __unused5: ::c_ulong ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ pub msg_stime: ::time_t, ++ __glibc_reserved1: ::c_ulong, ++ pub msg_rtime: ::time_t, ++ __glibc_reserved2: ::c_ulong, ++ pub msg_ctime: ::time_t, ++ __glibc_reserved3: ::c_ulong, ++ __msg_cbytes: ::c_ulong, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ __glibc_reserved4: ::c_ulong, ++ __glibc_reserved5: ::c_ulong, ++ } ++} ++ ++pub const O_DIRECT: ::c_int = 0x10000; ++pub const O_DIRECTORY: ::c_int = 0x4000; ++pub const O_NOFOLLOW: ::c_int = 0x8000; ++pub const O_LARGEFILE: ::c_int = 0o400000; ++ ++pub const MAP_LOCKED: ::c_int = 0x02000; ++pub const MAP_NORESERVE: ::c_int = 0x04000; ++ ++pub const EDEADLOCK: ::c_int = 35; ++ ++pub const SO_PASSCRED: ::c_int = 16; ++pub const SO_PEERCRED: ::c_int = 17; ++pub const SO_RCVLOWAT: ::c_int = 18; ++pub const SO_SNDLOWAT: ::c_int = 19; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_SNDTIMEO: ::c_int = 21; ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++ ++pub const FIOCLEX: ::c_ulong = 0x5451; ++pub const FIONBIO: ::c_ulong = 0x5421; ++ ++pub const SYS_pivot_root: ::c_long = 218; ++pub const SYS_gettid: ::c_long = 224; ++pub const SYS_perf_event_open: ::c_long = 364; ++pub const SYS_memfd_create: ::c_long = 385; ++ ++pub const PTRACE_GETFPXREGS: ::c_uint = 18; ++pub const PTRACE_SETFPXREGS: ::c_uint = 19; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const SIGSTKSZ: ::size_t = 8192; ++pub const MINSIGSTKSZ: ::size_t = 2048; ++pub const CBAUD: ::tcflag_t = 0o0010017; ++pub const TAB1: ::c_int = 0x00000800; ++pub const TAB2: ::c_int = 0x00001000; ++pub const TAB3: ::c_int = 0x00001800; ++pub const CR1: ::c_int = 0x00000200; ++pub const CR2: ::c_int = 0x00000400; ++pub const CR3: ::c_int = 0x00000600; ++pub const FF1: ::c_int = 0x00008000; ++pub const BS1: ::c_int = 0x00002000; ++pub const VT1: ::c_int = 0x00004000; ++pub const VWERASE: usize = 14; ++pub const VREPRINT: usize = 12; ++pub const VSUSP: usize = 10; ++pub const VSTART: usize = 8; ++pub const VSTOP: usize = 9; ++pub const VDISCARD: usize = 13; ++pub const VTIME: usize = 5; ++pub const IXON: ::tcflag_t = 0x00000400; ++pub const IXOFF: ::tcflag_t = 0x00001000; ++pub const ONLCR: ::tcflag_t = 0x4; ++pub const CSIZE: ::tcflag_t = 0x00000030; ++pub const CS6: ::tcflag_t = 0x00000010; ++pub const CS7: ::tcflag_t = 0x00000020; ++pub const CS8: ::tcflag_t = 0x00000030; ++pub const CSTOPB: ::tcflag_t = 0x00000040; ++pub const CREAD: ::tcflag_t = 0x00000080; ++pub const PARENB: ::tcflag_t = 0x00000100; ++pub const PARODD: ::tcflag_t = 0x00000200; ++pub const HUPCL: ::tcflag_t = 0x00000400; ++pub const CLOCAL: ::tcflag_t = 0x00000800; ++pub const ECHOKE: ::tcflag_t = 0x00000800; ++pub const ECHOE: ::tcflag_t = 0x00000010; ++pub const ECHOK: ::tcflag_t = 0x00000020; ++pub const ECHONL: ::tcflag_t = 0x00000040; ++pub const ECHOPRT: ::tcflag_t = 0x00000400; ++pub const ECHOCTL: ::tcflag_t = 0x00000200; ++pub const ISIG: ::tcflag_t = 0x00000001; ++pub const ICANON: ::tcflag_t = 0x00000002; ++pub const PENDIN: ::tcflag_t = 0x00004000; ++pub const NOFLSH: ::tcflag_t = 0x00000080; ++pub const CIBAUD: ::tcflag_t = 0o02003600000; ++pub const CBAUDEX: ::tcflag_t = 0o010000; ++pub const VSWTC: usize = 7; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const XTABS: ::tcflag_t = 0o014000; ++ ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const B57600: ::speed_t = 0o010001; ++pub const B115200: ::speed_t = 0o010002; ++pub const B230400: ::speed_t = 0o010003; ++pub const B460800: ::speed_t = 0o010004; ++pub const B500000: ::speed_t = 0o010005; ++pub const B576000: ::speed_t = 0o010006; ++pub const B921600: ::speed_t = 0o010007; ++pub const B1000000: ::speed_t = 0o010010; ++pub const B1152000: ::speed_t = 0o010011; ++pub const B1500000: ::speed_t = 0o010012; ++pub const B2000000: ::speed_t = 0o010013; ++pub const B2500000: ::speed_t = 0o010014; ++pub const B3000000: ::speed_t = 0o010015; ++pub const B3500000: ::speed_t = 0o010016; ++pub const B4000000: ::speed_t = 0o010017; ++ ++pub const 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 --cc vendor/libc-0.2.31/src/unix/notbsd/linux/other/b32/mod.rs index 000000000,000000000..247f01bb3 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/other/b32/mod.rs @@@ -1,0 -1,0 +1,297 @@@ ++//! 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; ++pub type __u64 = ::c_ulonglong; ++ ++s! { ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ __pad1: ::c_short, ++ pub st_ino: ::ino_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ __pad2: ::c_short, ++ pub st_size: ::off_t, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ __unused4: ::c_long, ++ __unused5: ::c_long, ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [u32; 9] ++ } ++ ++ pub struct sigset_t { ++ __val: [::c_ulong; 32], ++ } ++ ++ pub struct sysinfo { ++ pub uptime: ::c_long, ++ pub loads: [::c_ulong; 3], ++ pub totalram: ::c_ulong, ++ pub freeram: ::c_ulong, ++ pub sharedram: ::c_ulong, ++ pub bufferram: ::c_ulong, ++ pub totalswap: ::c_ulong, ++ pub freeswap: ::c_ulong, ++ pub procs: ::c_ushort, ++ pub pad: ::c_ushort, ++ pub totalhigh: ::c_ulong, ++ pub freehigh: ::c_ulong, ++ pub mem_unit: ::c_uint, ++ pub _f: [::c_char; 8], ++ } ++} ++ ++pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; ++pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; ++ ++pub const RLIMIT_NOFILE: ::c_int = 7; ++pub const RLIMIT_NPROC: ::c_int = 6; ++ ++pub const O_APPEND: ::c_int = 1024; ++pub const O_CREAT: ::c_int = 64; ++pub const O_EXCL: ::c_int = 128; ++pub const O_NOCTTY: ::c_int = 256; ++pub const O_NONBLOCK: ::c_int = 2048; ++pub const O_SYNC: ::c_int = 1052672; ++pub const O_RSYNC: ::c_int = 1052672; ++pub const O_DSYNC: ::c_int = 4096; ++pub const O_FSYNC: ::c_int = 0x101000; ++pub const O_NOATIME: ::c_int = 0o1000000; ++pub const O_PATH: ::c_int = 0o10000000; ++ ++pub const MAP_GROWSDOWN: ::c_int = 0x0100; ++ ++pub const EDEADLK: ::c_int = 35; ++pub const ENAMETOOLONG: ::c_int = 36; ++pub const ENOLCK: ::c_int = 37; ++pub const ENOSYS: ::c_int = 38; ++pub const ENOTEMPTY: ::c_int = 39; ++pub const ELOOP: ::c_int = 40; ++pub const ENOMSG: ::c_int = 42; ++pub const EIDRM: ::c_int = 43; ++pub const ECHRNG: ::c_int = 44; ++pub const EL2NSYNC: ::c_int = 45; ++pub const EL3HLT: ::c_int = 46; ++pub const EL3RST: ::c_int = 47; ++pub const ELNRNG: ::c_int = 48; ++pub const EUNATCH: ::c_int = 49; ++pub const ENOCSI: ::c_int = 50; ++pub const EL2HLT: ::c_int = 51; ++pub const EBADE: ::c_int = 52; ++pub const EBADR: ::c_int = 53; ++pub const EXFULL: ::c_int = 54; ++pub const ENOANO: ::c_int = 55; ++pub const EBADRQC: ::c_int = 56; ++pub const EBADSLT: ::c_int = 57; ++pub const EMULTIHOP: ::c_int = 72; ++pub const EOVERFLOW: ::c_int = 75; ++pub const ENOTUNIQ: ::c_int = 76; ++pub const EBADFD: ::c_int = 77; ++pub const EBADMSG: ::c_int = 74; ++pub const EREMCHG: ::c_int = 78; ++pub const ELIBACC: ::c_int = 79; ++pub const ELIBBAD: ::c_int = 80; ++pub const ELIBSCN: ::c_int = 81; ++pub const ELIBMAX: ::c_int = 82; ++pub const ELIBEXEC: ::c_int = 83; ++pub const EILSEQ: ::c_int = 84; ++pub const ERESTART: ::c_int = 85; ++pub const ESTRPIPE: ::c_int = 86; ++pub const EUSERS: ::c_int = 87; ++pub const ENOTSOCK: ::c_int = 88; ++pub const EDESTADDRREQ: ::c_int = 89; ++pub const EMSGSIZE: ::c_int = 90; ++pub const EPROTOTYPE: ::c_int = 91; ++pub const ENOPROTOOPT: ::c_int = 92; ++pub const EPROTONOSUPPORT: ::c_int = 93; ++pub const ESOCKTNOSUPPORT: ::c_int = 94; ++pub const EOPNOTSUPP: ::c_int = 95; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const EAFNOSUPPORT: ::c_int = 97; ++pub const EADDRINUSE: ::c_int = 98; ++pub const EADDRNOTAVAIL: ::c_int = 99; ++pub const ENETDOWN: ::c_int = 100; ++pub const ENETUNREACH: ::c_int = 101; ++pub const ENETRESET: ::c_int = 102; ++pub const ECONNABORTED: ::c_int = 103; ++pub const ECONNRESET: ::c_int = 104; ++pub const ENOBUFS: ::c_int = 105; ++pub const EISCONN: ::c_int = 106; ++pub const ENOTCONN: ::c_int = 107; ++pub const ESHUTDOWN: ::c_int = 108; ++pub const ETOOMANYREFS: ::c_int = 109; ++pub const ETIMEDOUT: ::c_int = 110; ++pub const ECONNREFUSED: ::c_int = 111; ++pub const EHOSTDOWN: ::c_int = 112; ++pub const EHOSTUNREACH: ::c_int = 113; ++pub const EALREADY: ::c_int = 114; ++pub const EINPROGRESS: ::c_int = 115; ++pub const ESTALE: ::c_int = 116; ++pub const EDQUOT: ::c_int = 122; ++pub const ENOMEDIUM: ::c_int = 123; ++pub const EMEDIUMTYPE: ::c_int = 124; ++pub const ECANCELED: ::c_int = 125; ++pub const ENOKEY: ::c_int = 126; ++pub const EKEYEXPIRED: ::c_int = 127; ++pub const EKEYREVOKED: ::c_int = 128; ++pub const EKEYREJECTED: ::c_int = 129; ++pub const EOWNERDEAD: ::c_int = 130; ++pub const ENOTRECOVERABLE: ::c_int = 131; ++pub const EHWPOISON: ::c_int = 133; ++pub const ERFKILL: ::c_int = 132; ++ ++pub const SOL_SOCKET: ::c_int = 1; ++ ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_TYPE: ::c_int = 3; ++pub const SO_ERROR: ::c_int = 4; ++pub const SO_DONTROUTE: ::c_int = 5; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SO_SNDBUF: ::c_int = 7; ++pub const SO_RCVBUF: ::c_int = 8; ++pub const SO_KEEPALIVE: ::c_int = 9; ++pub const SO_OOBINLINE: ::c_int = 10; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_LINGER: ::c_int = 13; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_REUSEPORT: ::c_int = 15; ++pub const SO_BINDTODEVICE: ::c_int = 25; ++pub const SO_TIMESTAMP: ::c_int = 29; ++pub const SO_ACCEPTCONN: ::c_int = 30; ++pub const SO_MARK: ::c_int = 36; ++pub const SO_PROTOCOL: ::c_int = 38; ++pub const SO_DOMAIN: ::c_int = 39; ++pub const SO_RXQ_OVFL: ::c_int = 40; ++pub const SO_PEEK_OFF: ::c_int = 42; ++pub const SO_BUSY_POLL: ::c_int = 46; ++ ++pub const SA_ONSTACK: ::c_int = 0x08000000; ++pub const SA_SIGINFO: ::c_int = 0x00000004; ++pub const SA_NOCLDWAIT: ::c_int = 0x00000002; ++ ++pub const SIGCHLD: ::c_int = 17; ++pub const SIGBUS: ::c_int = 7; ++pub const SIGUSR1: ::c_int = 10; ++pub const SIGUSR2: ::c_int = 12; ++pub const SIGCONT: ::c_int = 18; ++pub const SIGSTOP: ::c_int = 19; ++pub const SIGTSTP: ::c_int = 20; ++pub const SIGURG: ::c_int = 23; ++pub const SIGIO: ::c_int = 29; ++pub const SIGSYS: ::c_int = 31; ++pub const SIGSTKFLT: ::c_int = 16; ++pub const SIGUNUSED: ::c_int = 31; ++pub const SIGPOLL: ::c_int = 29; ++pub const SIGPWR: ::c_int = 30; ++pub const SIG_SETMASK: ::c_int = 2; ++pub const SIG_BLOCK: ::c_int = 0x000000; ++pub const SIG_UNBLOCK: ::c_int = 0x01; ++ ++pub const POLLWRNORM: ::c_short = 0x100; ++pub const POLLWRBAND: ::c_short = 0x200; ++ ++pub const O_ASYNC: ::c_int = 0x2000; ++pub const O_NDELAY: ::c_int = 0x800; ++ ++pub const PTRACE_DETACH: ::c_uint = 17; ++ ++pub const EFD_NONBLOCK: ::c_int = 0x800; ++ ++pub const F_GETLK: ::c_int = 5; ++pub const F_GETOWN: ::c_int = 9; ++pub const F_SETOWN: ::c_int = 8; ++pub const F_SETLK: ::c_int = 6; ++pub const F_SETLKW: ::c_int = 7; ++ ++pub const SFD_NONBLOCK: ::c_int = 0x0800; ++ ++pub const TIOCEXCL: ::c_ulong = 0x540C; ++pub const TIOCNXCL: ::c_ulong = 0x540D; ++pub const TIOCSCTTY: ::c_ulong = 0x540E; ++pub const TIOCSTI: ::c_ulong = 0x5412; ++pub const TIOCMGET: ::c_ulong = 0x5415; ++pub const TIOCMBIS: ::c_ulong = 0x5416; ++pub const TIOCMBIC: ::c_ulong = 0x5417; ++pub const TIOCMSET: ::c_ulong = 0x5418; ++pub const TIOCCONS: ::c_ulong = 0x541D; ++ ++pub const SFD_CLOEXEC: ::c_int = 0x080000; ++ ++pub const NCCS: usize = 32; ++ ++pub const O_TRUNC: ::c_int = 512; ++ ++pub const O_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EBFONT: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const EDOTDOT: ::c_int = 73; ++ ++pub const SA_NODEFER: ::c_int = 0x40000000; ++pub const SA_RESETHAND: ::c_int = 0x80000000; ++pub const SA_RESTART: ::c_int = 0x10000000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000001; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x80000; ++ ++pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; ++pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; ++ ++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 --cc vendor/libc-0.2.31/src/unix/notbsd/linux/other/b32/powerpc.rs index 000000000,000000000..13646b7f0 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/other/b32/powerpc.rs @@@ -1,0 -1,0 +1,248 @@@ ++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 statfs64 { ++ pub f_type: ::__fsword_t, ++ pub f_bsize: ::__fsword_t, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::__fsword_t, ++ pub f_frsize: ::__fsword_t, ++ pub f_flags: ::__fsword_t, ++ pub f_spare: [::__fsword_t; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ __f_unused: ::c_int, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ __glibc_reserved1: ::c_uint, ++ pub shm_atime: ::time_t, ++ __glibc_reserved2: ::c_uint, ++ pub shm_dtime: ::time_t, ++ __glibc_reserved3: ::c_uint, ++ pub shm_ctime: ::time_t, ++ __glibc_reserved4: ::c_uint, ++ pub shm_segsz: ::size_t, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::shmatt_t, ++ __glibc_reserved5: ::c_ulong, ++ __glibc_reserved6: ::c_ulong, ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ __glibc_reserved1: ::c_uint, ++ pub msg_stime: ::time_t, ++ __glibc_reserved2: ::c_uint, ++ pub msg_rtime: ::time_t, ++ __glibc_reserved3: ::c_uint, ++ pub msg_ctime: ::time_t, ++ __msg_cbytes: ::c_ulong, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ __glibc_reserved4: ::c_ulong, ++ __glibc_reserved5: ::c_ulong, ++ } ++} ++ ++pub const O_DIRECT: ::c_int = 0x20000; ++pub const O_DIRECTORY: ::c_int = 0x4000; ++pub const O_NOFOLLOW: ::c_int = 0x8000; ++pub const O_LARGEFILE: ::c_int = 0o200000; ++ ++pub const MAP_LOCKED: ::c_int = 0x00080; ++pub const MAP_NORESERVE: ::c_int = 0x00040; ++ ++pub const EDEADLOCK: ::c_int = 58; ++ ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_RCVLOWAT: ::c_int = 16; ++pub const SO_SNDLOWAT: ::c_int = 17; ++pub const SO_RCVTIMEO: ::c_int = 18; ++pub const SO_SNDTIMEO: ::c_int = 19; ++pub const SO_PASSCRED: ::c_int = 20; ++pub const SO_PEERCRED: ::c_int = 21; ++ ++pub const FIOCLEX: ::c_ulong = 0x20006601; ++pub const FIONBIO: ::c_ulong = 0x8004667e; ++ ++pub const SYS_pivot_root: ::c_long = 203; ++pub const SYS_gettid: ::c_long = 207; ++pub const SYS_perf_event_open: ::c_long = 319; ++pub const SYS_memfd_create: ::c_long = 360; ++ ++pub const MCL_CURRENT: ::c_int = 0x2000; ++pub const MCL_FUTURE: ::c_int = 0x4000; ++ ++pub const SIGSTKSZ: ::size_t = 0x4000; ++pub const MINSIGSTKSZ: ::size_t = 4096; ++pub const CBAUD: ::tcflag_t = 0xff; ++pub const TAB1: ::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 VSWTC: usize = 9; ++pub const OLCUC: ::tcflag_t = 0o000004; ++pub const NLDLY: ::tcflag_t = 0o001400; ++pub const CRDLY: ::tcflag_t = 0o030000; ++pub const TABDLY: ::tcflag_t = 0o006000; ++pub const BSDLY: ::tcflag_t = 0o100000; ++pub const FFDLY: ::tcflag_t = 0o040000; ++pub const VTDLY: ::tcflag_t = 0o200000; ++pub const XTABS: ::tcflag_t = 0o006000; ++ ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const CBAUDEX: ::speed_t = 0o000020; ++pub const B57600: ::speed_t = 0o0020; ++pub const B115200: ::speed_t = 0o0021; ++pub const B230400: ::speed_t = 0o0022; ++pub const B460800: ::speed_t = 0o0023; ++pub const B500000: ::speed_t = 0o0024; ++pub const B576000: ::speed_t = 0o0025; ++pub const B921600: ::speed_t = 0o0026; ++pub const B1000000: ::speed_t = 0o0027; ++pub const B1152000: ::speed_t = 0o0030; ++pub const B1500000: ::speed_t = 0o0031; ++pub const B2000000: ::speed_t = 0o0032; ++pub const B2500000: ::speed_t = 0o0033; ++pub const B3000000: ::speed_t = 0o0034; ++pub const B3500000: ::speed_t = 0o0035; ++pub const B4000000: ::speed_t = 0o0036; ++ ++pub const 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 --cc vendor/libc-0.2.31/src/unix/notbsd/linux/other/b32/x86.rs index 000000000,000000000..141339694 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/other/b32/x86.rs @@@ -1,0 -1,0 +1,757 @@@ ++pub type c_char = i8; ++pub type wchar_t = i32; ++pub type greg_t = i32; ++ ++s! { ++ pub struct _libc_fpreg { ++ pub significand: [u16; 4], ++ pub exponent: u16, ++ } ++ ++ pub struct _libc_fpstate { ++ pub cw: ::c_ulong, ++ pub sw: ::c_ulong, ++ pub tag: ::c_ulong, ++ pub ipoff: ::c_ulong, ++ pub cssel: ::c_ulong, ++ pub dataoff: ::c_ulong, ++ pub datasel: ::c_ulong, ++ pub _st: [_libc_fpreg; 8], ++ pub status: ::c_ulong, ++ } ++ ++ pub struct user_fpregs_struct { ++ pub cwd: ::c_long, ++ pub swd: ::c_long, ++ pub twd: ::c_long, ++ pub fip: ::c_long, ++ pub fcs: ::c_long, ++ pub foo: ::c_long, ++ pub fos: ::c_long, ++ pub st_space: [::c_long; 20], ++ } ++ ++ pub struct user_fpxregs_struct { ++ pub cwd: ::c_ushort, ++ pub swd: ::c_ushort, ++ pub twd: ::c_ushort, ++ pub fop: ::c_ushort, ++ pub fip: ::c_long, ++ pub fcs: ::c_long, ++ pub foo: ::c_long, ++ pub fos: ::c_long, ++ pub mxcsr: ::c_long, ++ __reserved: ::c_long, ++ pub st_space: [::c_long; 32], ++ pub xmm_space: [::c_long; 32], ++ padding: [::c_long; 56], ++ } ++ ++ pub struct user_regs_struct { ++ pub ebx: ::c_long, ++ pub ecx: ::c_long, ++ pub edx: ::c_long, ++ pub esi: ::c_long, ++ pub edi: ::c_long, ++ pub ebp: ::c_long, ++ pub eax: ::c_long, ++ pub xds: ::c_long, ++ pub xes: ::c_long, ++ pub xfs: ::c_long, ++ pub xgs: ::c_long, ++ pub orig_eax: ::c_long, ++ pub eip: ::c_long, ++ pub xcs: ::c_long, ++ pub eflags: ::c_long, ++ pub esp: ::c_long, ++ pub xss: ::c_long, ++ } ++ ++ pub struct user { ++ pub regs: user_regs_struct, ++ pub u_fpvalid: ::c_int, ++ pub i387: user_fpregs_struct, ++ pub u_tsize: ::c_ulong, ++ pub u_dsize: ::c_ulong, ++ pub u_ssize: ::c_ulong, ++ pub start_code: ::c_ulong, ++ pub start_stack: ::c_ulong, ++ pub signal: ::c_long, ++ __reserved: ::c_int, ++ pub u_ar0: *mut user_regs_struct, ++ pub u_fpstate: *mut user_fpregs_struct, ++ pub magic: ::c_ulong, ++ pub u_comm: [c_char; 32], ++ pub u_debugreg: [::c_int; 8], ++ } ++ ++ pub struct mcontext_t { ++ pub gregs: [greg_t; 19], ++ pub fpregs: *mut _libc_fpstate, ++ pub oldmask: ::c_ulong, ++ pub cr2: ::c_ulong, ++ } ++ ++ pub struct 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 statfs64 { ++ pub f_type: ::__fsword_t, ++ pub f_bsize: ::__fsword_t, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::__fsword_t, ++ pub f_frsize: ::__fsword_t, ++ pub f_flags: ::__fsword_t, ++ pub f_spare: [::__fsword_t; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ __f_unused: ::c_int, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, ++ pub shm_atime: ::time_t, ++ __unused1: ::c_ulong, ++ pub shm_dtime: ::time_t, ++ __unused2: ::c_ulong, ++ pub shm_ctime: ::time_t, ++ __unused3: ::c_ulong, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::shmatt_t, ++ __unused4: ::c_ulong, ++ __unused5: ::c_ulong ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ pub msg_stime: ::time_t, ++ __glibc_reserved1: ::c_ulong, ++ pub msg_rtime: ::time_t, ++ __glibc_reserved2: ::c_ulong, ++ pub msg_ctime: ::time_t, ++ __glibc_reserved3: ::c_ulong, ++ __msg_cbytes: ::c_ulong, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ __glibc_reserved4: ::c_ulong, ++ __glibc_reserved5: ::c_ulong, ++ } ++} ++ ++pub const O_DIRECT: ::c_int = 0x4000; ++pub const O_DIRECTORY: ::c_int = 0x10000; ++pub const O_NOFOLLOW: ::c_int = 0x20000; ++pub const O_LARGEFILE: ::c_int = 0o0100000; ++ ++pub const MAP_LOCKED: ::c_int = 0x02000; ++pub const MAP_NORESERVE: ::c_int = 0x04000; ++pub const MAP_32BIT: ::c_int = 0x0040; ++ ++pub const EDEADLOCK: ::c_int = 35; ++ ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_PASSCRED: ::c_int = 16; ++pub const SO_PEERCRED: ::c_int = 17; ++pub const SO_RCVLOWAT: ::c_int = 18; ++pub const SO_SNDLOWAT: ::c_int = 19; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_SNDTIMEO: ::c_int = 21; ++ ++pub const FIOCLEX: ::c_ulong = 0x5451; ++pub const FIONBIO: ::c_ulong = 0x5421; ++ ++pub const PTRACE_GETFPXREGS: ::c_uint = 18; ++pub const PTRACE_SETFPXREGS: ::c_uint = 19; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const SIGSTKSZ: ::size_t = 8192; ++pub const MINSIGSTKSZ: ::size_t = 2048; ++pub const CBAUD: ::tcflag_t = 0o0010017; ++pub const TAB1: ::c_int = 0x00000800; ++pub const TAB2: ::c_int = 0x00001000; ++pub const TAB3: ::c_int = 0x00001800; ++pub const CR1: ::c_int = 0x00000200; ++pub const CR2: ::c_int = 0x00000400; ++pub const CR3: ::c_int = 0x00000600; ++pub const FF1: ::c_int = 0x00008000; ++pub const BS1: ::c_int = 0x00002000; ++pub const VT1: ::c_int = 0x00004000; ++pub const VWERASE: usize = 14; ++pub const VREPRINT: usize = 12; ++pub const VSUSP: usize = 10; ++pub const VSTART: usize = 8; ++pub const VSTOP: usize = 9; ++pub const VDISCARD: usize = 13; ++pub const VTIME: usize = 5; ++pub const IXON: ::tcflag_t = 0x00000400; ++pub const IXOFF: ::tcflag_t = 0x00001000; ++pub const ONLCR: ::tcflag_t = 0x4; ++pub const CSIZE: ::tcflag_t = 0x00000030; ++pub const CS6: ::tcflag_t = 0x00000010; ++pub const CS7: ::tcflag_t = 0x00000020; ++pub const CS8: ::tcflag_t = 0x00000030; ++pub const CSTOPB: ::tcflag_t = 0x00000040; ++pub const CREAD: ::tcflag_t = 0x00000080; ++pub const PARENB: ::tcflag_t = 0x00000100; ++pub const PARODD: ::tcflag_t = 0x00000200; ++pub const HUPCL: ::tcflag_t = 0x00000400; ++pub const CLOCAL: ::tcflag_t = 0x00000800; ++pub const ECHOKE: ::tcflag_t = 0x00000800; ++pub const ECHOE: ::tcflag_t = 0x00000010; ++pub const ECHOK: ::tcflag_t = 0x00000020; ++pub const ECHONL: ::tcflag_t = 0x00000040; ++pub const ECHOPRT: ::tcflag_t = 0x00000400; ++pub const ECHOCTL: ::tcflag_t = 0x00000200; ++pub const ISIG: ::tcflag_t = 0x00000001; ++pub const ICANON: ::tcflag_t = 0x00000002; ++pub const PENDIN: ::tcflag_t = 0x00004000; ++pub const NOFLSH: ::tcflag_t = 0x00000080; ++pub const CIBAUD: ::tcflag_t = 0o02003600000; ++pub const CBAUDEX: ::tcflag_t = 0o010000; ++pub const VSWTC: usize = 7; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const XTABS: ::tcflag_t = 0o014000; ++ ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const B57600: ::speed_t = 0o010001; ++pub const B115200: ::speed_t = 0o010002; ++pub const B230400: ::speed_t = 0o010003; ++pub const B460800: ::speed_t = 0o010004; ++pub const B500000: ::speed_t = 0o010005; ++pub const B576000: ::speed_t = 0o010006; ++pub const B921600: ::speed_t = 0o010007; ++pub const B1000000: ::speed_t = 0o010010; ++pub const B1152000: ::speed_t = 0o010011; ++pub const B1500000: ::speed_t = 0o010012; ++pub const B2000000: ::speed_t = 0o010013; ++pub const B2500000: ::speed_t = 0o010014; ++pub const B3000000: ::speed_t = 0o010015; ++pub const B3500000: ::speed_t = 0o010016; ++pub const B4000000: ::speed_t = 0o010017; ++ ++pub const VEOL: usize = 11; ++pub const VEOL2: usize = 16; ++pub const VMIN: usize = 6; ++pub const IEXTEN: ::tcflag_t = 0x00008000; ++pub const TOSTOP: ::tcflag_t = 0x00000100; ++pub const FLUSHO: ::tcflag_t = 0x00001000; ++pub const EXTPROC: ::tcflag_t = 0x00010000; ++pub const TCGETS: ::c_ulong = 0x5401; ++pub const TCSETS: ::c_ulong = 0x5402; ++pub const TCSETSW: ::c_ulong = 0x5403; ++pub const TCSETSF: ::c_ulong = 0x5404; ++pub const TCGETA: ::c_ulong = 0x5405; ++pub const TCSETA: ::c_ulong = 0x5406; ++pub const TCSETAW: ::c_ulong = 0x5407; ++pub const TCSETAF: ::c_ulong = 0x5408; ++pub const TCSBRK: ::c_ulong = 0x5409; ++pub const TCXONC: ::c_ulong = 0x540A; ++pub const TCFLSH: ::c_ulong = 0x540B; ++pub const TIOCINQ: ::c_ulong = 0x541B; ++pub const TIOCGPGRP: ::c_ulong = 0x540F; ++pub const TIOCSPGRP: ::c_ulong = 0x5410; ++pub const TIOCOUTQ: ::c_ulong = 0x5411; ++pub const TIOCGWINSZ: ::c_ulong = 0x5413; ++pub const TIOCSWINSZ: ::c_ulong = 0x5414; ++pub const FIONREAD: ::c_ulong = 0x541B; ++ ++// Syscall table ++pub const SYS_restart_syscall: ::c_long = 0; ++pub const SYS_exit: ::c_long = 1; ++pub const SYS_fork: ::c_long = 2; ++pub const SYS_read: ::c_long = 3; ++pub const SYS_write: ::c_long = 4; ++pub const SYS_open: ::c_long = 5; ++pub const SYS_close: ::c_long = 6; ++pub const SYS_waitpid: ::c_long = 7; ++pub const SYS_creat: ::c_long = 8; ++pub const SYS_link: ::c_long = 9; ++pub const SYS_unlink: ::c_long = 10; ++pub const SYS_execve: ::c_long = 11; ++pub const SYS_chdir: ::c_long = 12; ++pub const SYS_time: ::c_long = 13; ++pub const SYS_mknod: ::c_long = 14; ++pub const SYS_chmod: ::c_long = 15; ++pub const SYS_lchown: ::c_long = 16; ++pub const SYS_break: ::c_long = 17; ++pub const SYS_oldstat: ::c_long = 18; ++pub const SYS_lseek: ::c_long = 19; ++pub const SYS_getpid: ::c_long = 20; ++pub const SYS_mount: ::c_long = 21; ++pub const SYS_umount: ::c_long = 22; ++pub const SYS_setuid: ::c_long = 23; ++pub const SYS_getuid: ::c_long = 24; ++pub const SYS_stime: ::c_long = 25; ++pub const SYS_ptrace: ::c_long = 26; ++pub const SYS_alarm: ::c_long = 27; ++pub const SYS_oldfstat: ::c_long = 28; ++pub const SYS_pause: ::c_long = 29; ++pub const SYS_utime: ::c_long = 30; ++pub const SYS_stty: ::c_long = 31; ++pub const SYS_gtty: ::c_long = 32; ++pub const SYS_access: ::c_long = 33; ++pub const SYS_nice: ::c_long = 34; ++pub const SYS_ftime: ::c_long = 35; ++pub const SYS_sync: ::c_long = 36; ++pub const SYS_kill: ::c_long = 37; ++pub const SYS_rename: ::c_long = 38; ++pub const SYS_mkdir: ::c_long = 39; ++pub const SYS_rmdir: ::c_long = 40; ++pub const SYS_dup: ::c_long = 41; ++pub const SYS_pipe: ::c_long = 42; ++pub const SYS_times: ::c_long = 43; ++pub const SYS_prof: ::c_long = 44; ++pub const SYS_brk: ::c_long = 45; ++pub const SYS_setgid: ::c_long = 46; ++pub const SYS_getgid: ::c_long = 47; ++pub const SYS_signal: ::c_long = 48; ++pub const SYS_geteuid: ::c_long = 49; ++pub const SYS_getegid: ::c_long = 50; ++pub const SYS_acct: ::c_long = 51; ++pub const SYS_umount2: ::c_long = 52; ++pub const SYS_lock: ::c_long = 53; ++pub const SYS_ioctl: ::c_long = 54; ++pub const SYS_fcntl: ::c_long = 55; ++pub const SYS_mpx: ::c_long = 56; ++pub const SYS_setpgid: ::c_long = 57; ++pub const SYS_ulimit: ::c_long = 58; ++pub const SYS_oldolduname: ::c_long = 59; ++pub const SYS_umask: ::c_long = 60; ++pub const SYS_chroot: ::c_long = 61; ++pub const SYS_ustat: ::c_long = 62; ++pub const SYS_dup2: ::c_long = 63; ++pub const SYS_getppid: ::c_long = 64; ++pub const SYS_getpgrp: ::c_long = 65; ++pub const SYS_setsid: ::c_long = 66; ++pub const SYS_sigaction: ::c_long = 67; ++pub const SYS_sgetmask: ::c_long = 68; ++pub const SYS_ssetmask: ::c_long = 69; ++pub const SYS_setreuid: ::c_long = 70; ++pub const SYS_setregid: ::c_long = 71; ++pub const SYS_sigsuspend: ::c_long = 72; ++pub const SYS_sigpending: ::c_long = 73; ++pub const SYS_sethostname: ::c_long = 74; ++pub const SYS_setrlimit: ::c_long = 75; ++pub const SYS_getrlimit: ::c_long = 76; ++pub const SYS_getrusage: ::c_long = 77; ++pub const SYS_gettimeofday: ::c_long = 78; ++pub const SYS_settimeofday: ::c_long = 79; ++pub const SYS_getgroups: ::c_long = 80; ++pub const SYS_setgroups: ::c_long = 81; ++pub const SYS_select: ::c_long = 82; ++pub const SYS_symlink: ::c_long = 83; ++pub const SYS_oldlstat: ::c_long = 84; ++pub const SYS_readlink: ::c_long = 85; ++pub const SYS_uselib: ::c_long = 86; ++pub const SYS_swapon: ::c_long = 87; ++pub const SYS_reboot: ::c_long = 88; ++pub const SYS_readdir: ::c_long = 89; ++pub const SYS_mmap: ::c_long = 90; ++pub const SYS_munmap: ::c_long = 91; ++pub const SYS_truncate: ::c_long = 92; ++pub const SYS_ftruncate: ::c_long = 93; ++pub const SYS_fchmod: ::c_long = 94; ++pub const SYS_fchown: ::c_long = 95; ++pub const SYS_getpriority: ::c_long = 96; ++pub const SYS_setpriority: ::c_long = 97; ++pub const SYS_profil: ::c_long = 98; ++pub const SYS_statfs: ::c_long = 99; ++pub const SYS_fstatfs: ::c_long = 100; ++pub const SYS_ioperm: ::c_long = 101; ++pub const SYS_socketcall: ::c_long = 102; ++pub const SYS_syslog: ::c_long = 103; ++pub const SYS_setitimer: ::c_long = 104; ++pub const SYS_getitimer: ::c_long = 105; ++pub const SYS_stat: ::c_long = 106; ++pub const SYS_lstat: ::c_long = 107; ++pub const SYS_fstat: ::c_long = 108; ++pub const SYS_olduname: ::c_long = 109; ++pub const SYS_iopl: ::c_long = 110; ++pub const SYS_vhangup: ::c_long = 111; ++pub const SYS_idle: ::c_long = 112; ++pub const SYS_vm86old: ::c_long = 113; ++pub const SYS_wait4: ::c_long = 114; ++pub const SYS_swapoff: ::c_long = 115; ++pub const SYS_sysinfo: ::c_long = 116; ++pub const SYS_ipc: ::c_long = 117; ++pub const SYS_fsync: ::c_long = 118; ++pub const SYS_sigreturn: ::c_long = 119; ++pub const SYS_clone: ::c_long = 120; ++pub const SYS_setdomainname: ::c_long = 121; ++pub const SYS_uname: ::c_long = 122; ++pub const SYS_modify_ldt: ::c_long = 123; ++pub const SYS_adjtimex: ::c_long = 124; ++pub const SYS_mprotect: ::c_long = 125; ++pub const SYS_sigprocmask: ::c_long = 126; ++pub const SYS_create_module: ::c_long = 127; ++pub const SYS_init_module: ::c_long = 128; ++pub const SYS_delete_module: ::c_long = 129; ++pub const SYS_get_kernel_syms: ::c_long = 130; ++pub const SYS_quotactl: ::c_long = 131; ++pub const SYS_getpgid: ::c_long = 132; ++pub const SYS_fchdir: ::c_long = 133; ++pub const SYS_bdflush: ::c_long = 134; ++pub const SYS_sysfs: ::c_long = 135; ++pub const SYS_personality: ::c_long = 136; ++pub const SYS_afs_syscall: ::c_long = 137; ++pub const SYS_setfsuid: ::c_long = 138; ++pub const SYS_setfsgid: ::c_long = 139; ++pub const SYS__llseek: ::c_long = 140; ++pub const SYS_getdents: ::c_long = 141; ++pub const SYS__newselect: ::c_long = 142; ++pub const SYS_flock: ::c_long = 143; ++pub const SYS_msync: ::c_long = 144; ++pub const SYS_readv: ::c_long = 145; ++pub const SYS_writev: ::c_long = 146; ++pub const SYS_getsid: ::c_long = 147; ++pub const SYS_fdatasync: ::c_long = 148; ++pub const SYS__sysctl: ::c_long = 149; ++pub const SYS_mlock: ::c_long = 150; ++pub const SYS_munlock: ::c_long = 151; ++pub const SYS_mlockall: ::c_long = 152; ++pub const SYS_munlockall: ::c_long = 153; ++pub const SYS_sched_setparam: ::c_long = 154; ++pub const SYS_sched_getparam: ::c_long = 155; ++pub const SYS_sched_setscheduler: ::c_long = 156; ++pub const SYS_sched_getscheduler: ::c_long = 157; ++pub const SYS_sched_yield: ::c_long = 158; ++pub const SYS_sched_get_priority_max: ::c_long = 159; ++pub const SYS_sched_get_priority_min: ::c_long = 160; ++pub const SYS_sched_rr_get_interval: ::c_long = 161; ++pub const SYS_nanosleep: ::c_long = 162; ++pub const SYS_mremap: ::c_long = 163; ++pub const SYS_setresuid: ::c_long = 164; ++pub const SYS_getresuid: ::c_long = 165; ++pub const SYS_vm86: ::c_long = 166; ++pub const SYS_query_module: ::c_long = 167; ++pub const SYS_poll: ::c_long = 168; ++pub const SYS_nfsservctl: ::c_long = 169; ++pub const SYS_setresgid: ::c_long = 170; ++pub const SYS_getresgid: ::c_long = 171; ++pub const SYS_prctl: ::c_long = 172; ++pub const SYS_rt_sigreturn: ::c_long = 173; ++pub const SYS_rt_sigaction: ::c_long = 174; ++pub const SYS_rt_sigprocmask: ::c_long = 175; ++pub const SYS_rt_sigpending: ::c_long = 176; ++pub const SYS_rt_sigtimedwait: ::c_long = 177; ++pub const SYS_rt_sigqueueinfo: ::c_long = 178; ++pub const SYS_rt_sigsuspend: ::c_long = 179; ++pub const SYS_pread64: ::c_long = 180; ++pub const SYS_pwrite64: ::c_long = 181; ++pub const SYS_chown: ::c_long = 182; ++pub const SYS_getcwd: ::c_long = 183; ++pub const SYS_capget: ::c_long = 184; ++pub const SYS_capset: ::c_long = 185; ++pub const SYS_sigaltstack: ::c_long = 186; ++pub const SYS_sendfile: ::c_long = 187; ++pub const SYS_getpmsg: ::c_long = 188; ++pub const SYS_putpmsg: ::c_long = 189; ++pub const SYS_vfork: ::c_long = 190; ++pub const SYS_ugetrlimit: ::c_long = 191; ++pub const SYS_mmap2: ::c_long = 192; ++pub const SYS_truncate64: ::c_long = 193; ++pub const SYS_ftruncate64: ::c_long = 194; ++pub const SYS_stat64: ::c_long = 195; ++pub const SYS_lstat64: ::c_long = 196; ++pub const SYS_fstat64: ::c_long = 197; ++pub const SYS_lchown32: ::c_long = 198; ++pub const SYS_getuid32: ::c_long = 199; ++pub const SYS_getgid32: ::c_long = 200; ++pub const SYS_geteuid32: ::c_long = 201; ++pub const SYS_getegid32: ::c_long = 202; ++pub const SYS_setreuid32: ::c_long = 203; ++pub const SYS_setregid32: ::c_long = 204; ++pub const SYS_getgroups32: ::c_long = 205; ++pub const SYS_setgroups32: ::c_long = 206; ++pub const SYS_fchown32: ::c_long = 207; ++pub const SYS_setresuid32: ::c_long = 208; ++pub const SYS_getresuid32: ::c_long = 209; ++pub const SYS_setresgid32: ::c_long = 210; ++pub const SYS_getresgid32: ::c_long = 211; ++pub const SYS_chown32: ::c_long = 212; ++pub const SYS_setuid32: ::c_long = 213; ++pub const SYS_setgid32: ::c_long = 214; ++pub const SYS_setfsuid32: ::c_long = 215; ++pub const SYS_setfsgid32: ::c_long = 216; ++pub const SYS_pivot_root: ::c_long = 217; ++pub const SYS_mincore: ::c_long = 218; ++pub const SYS_madvise: ::c_long = 219; ++pub const SYS_getdents64: ::c_long = 220; ++pub const SYS_fcntl64: ::c_long = 221; ++pub const SYS_gettid: ::c_long = 224; ++pub const SYS_readahead: ::c_long = 225; ++pub const SYS_setxattr: ::c_long = 226; ++pub const SYS_lsetxattr: ::c_long = 227; ++pub const SYS_fsetxattr: ::c_long = 228; ++pub const SYS_getxattr: ::c_long = 229; ++pub const SYS_lgetxattr: ::c_long = 230; ++pub const SYS_fgetxattr: ::c_long = 231; ++pub const SYS_listxattr: ::c_long = 232; ++pub const SYS_llistxattr: ::c_long = 233; ++pub const SYS_flistxattr: ::c_long = 234; ++pub const SYS_removexattr: ::c_long = 235; ++pub const SYS_lremovexattr: ::c_long = 236; ++pub const SYS_fremovexattr: ::c_long = 237; ++pub const SYS_tkill: ::c_long = 238; ++pub const SYS_sendfile64: ::c_long = 239; ++pub const SYS_futex: ::c_long = 240; ++pub const SYS_sched_setaffinity: ::c_long = 241; ++pub const SYS_sched_getaffinity: ::c_long = 242; ++pub const SYS_set_thread_area: ::c_long = 243; ++pub const SYS_get_thread_area: ::c_long = 244; ++pub const SYS_io_setup: ::c_long = 245; ++pub const SYS_io_destroy: ::c_long = 246; ++pub const SYS_io_getevents: ::c_long = 247; ++pub const SYS_io_submit: ::c_long = 248; ++pub const SYS_io_cancel: ::c_long = 249; ++pub const SYS_fadvise64: ::c_long = 250; ++pub const SYS_exit_group: ::c_long = 252; ++pub const SYS_lookup_dcookie: ::c_long = 253; ++pub const SYS_epoll_create: ::c_long = 254; ++pub const SYS_epoll_ctl: ::c_long = 255; ++pub const SYS_epoll_wait: ::c_long = 256; ++pub const SYS_remap_file_pages: ::c_long = 257; ++pub const SYS_set_tid_address: ::c_long = 258; ++pub const SYS_timer_create: ::c_long = 259; ++pub const SYS_timer_settime: ::c_long = 260; ++pub const SYS_timer_gettime: ::c_long = 261; ++pub const SYS_timer_getoverrun: ::c_long = 262; ++pub const SYS_timer_delete: ::c_long = 263; ++pub const SYS_clock_settime: ::c_long = 264; ++pub const SYS_clock_gettime: ::c_long = 265; ++pub const SYS_clock_getres: ::c_long = 266; ++pub const SYS_clock_nanosleep: ::c_long = 267; ++pub const SYS_statfs64: ::c_long = 268; ++pub const SYS_fstatfs64: ::c_long = 269; ++pub const SYS_tgkill: ::c_long = 270; ++pub const SYS_utimes: ::c_long = 271; ++pub const SYS_fadvise64_64: ::c_long = 272; ++pub const SYS_vserver: ::c_long = 273; ++pub const SYS_mbind: ::c_long = 274; ++pub const SYS_get_mempolicy: ::c_long = 275; ++pub const SYS_set_mempolicy: ::c_long = 276; ++pub const SYS_mq_open: ::c_long = 277; ++pub const SYS_mq_unlink: ::c_long = 278; ++pub const SYS_mq_timedsend: ::c_long = 279; ++pub const SYS_mq_timedreceive: ::c_long = 280; ++pub const SYS_mq_notify: ::c_long = 281; ++pub const SYS_mq_getsetattr: ::c_long = 282; ++pub const SYS_kexec_load: ::c_long = 283; ++pub const SYS_waitid: ::c_long = 284; ++pub const SYS_add_key: ::c_long = 286; ++pub const SYS_request_key: ::c_long = 287; ++pub const SYS_keyctl: ::c_long = 288; ++pub const SYS_ioprio_set: ::c_long = 289; ++pub const SYS_ioprio_get: ::c_long = 290; ++pub const SYS_inotify_init: ::c_long = 291; ++pub const SYS_inotify_add_watch: ::c_long = 292; ++pub const SYS_inotify_rm_watch: ::c_long = 293; ++pub const SYS_migrate_pages: ::c_long = 294; ++pub const SYS_openat: ::c_long = 295; ++pub const SYS_mkdirat: ::c_long = 296; ++pub const SYS_mknodat: ::c_long = 297; ++pub const SYS_fchownat: ::c_long = 298; ++pub const SYS_futimesat: ::c_long = 299; ++pub const SYS_fstatat64: ::c_long = 300; ++pub const SYS_unlinkat: ::c_long = 301; ++pub const SYS_renameat: ::c_long = 302; ++pub const SYS_linkat: ::c_long = 303; ++pub const SYS_symlinkat: ::c_long = 304; ++pub const SYS_readlinkat: ::c_long = 305; ++pub const SYS_fchmodat: ::c_long = 306; ++pub const SYS_faccessat: ::c_long = 307; ++pub const SYS_pselect6: ::c_long = 308; ++pub const SYS_ppoll: ::c_long = 309; ++pub const SYS_unshare: ::c_long = 310; ++pub const SYS_set_robust_list: ::c_long = 311; ++pub const SYS_get_robust_list: ::c_long = 312; ++pub const SYS_splice: ::c_long = 313; ++pub const SYS_sync_file_range: ::c_long = 314; ++pub const SYS_tee: ::c_long = 315; ++pub const SYS_vmsplice: ::c_long = 316; ++pub const SYS_move_pages: ::c_long = 317; ++pub const SYS_getcpu: ::c_long = 318; ++pub const SYS_epoll_pwait: ::c_long = 319; ++pub const SYS_utimensat: ::c_long = 320; ++pub const SYS_signalfd: ::c_long = 321; ++pub const SYS_timerfd_create: ::c_long = 322; ++pub const SYS_eventfd: ::c_long = 323; ++pub const SYS_fallocate: ::c_long = 324; ++pub const SYS_timerfd_settime: ::c_long = 325; ++pub const SYS_timerfd_gettime: ::c_long = 326; ++pub const SYS_signalfd4: ::c_long = 327; ++pub const SYS_eventfd2: ::c_long = 328; ++pub const SYS_epoll_create1: ::c_long = 329; ++pub const SYS_dup3: ::c_long = 330; ++pub const SYS_pipe2: ::c_long = 331; ++pub const SYS_inotify_init1: ::c_long = 332; ++pub const SYS_preadv: ::c_long = 333; ++pub const SYS_pwritev: ::c_long = 334; ++pub const SYS_rt_tgsigqueueinfo: ::c_long = 335; ++pub const SYS_perf_event_open: ::c_long = 336; ++pub const SYS_recvmmsg: ::c_long = 337; ++pub const SYS_fanotify_init: ::c_long = 338; ++pub const SYS_fanotify_mark: ::c_long = 339; ++pub const SYS_prlimit64: ::c_long = 340; ++pub const SYS_name_to_handle_at: ::c_long = 341; ++pub const SYS_open_by_handle_at: ::c_long = 342; ++pub const SYS_clock_adjtime: ::c_long = 343; ++pub const SYS_syncfs: ::c_long = 344; ++pub const SYS_sendmmsg: ::c_long = 345; ++pub const SYS_setns: ::c_long = 346; ++pub const SYS_process_vm_readv: ::c_long = 347; ++pub const SYS_process_vm_writev: ::c_long = 348; ++pub const SYS_kcmp: ::c_long = 349; ++pub const SYS_finit_module: ::c_long = 350; ++pub const SYS_sched_setattr: ::c_long = 351; ++pub const SYS_sched_getattr: ::c_long = 352; ++pub const SYS_renameat2: ::c_long = 353; ++pub const SYS_seccomp: ::c_long = 354; ++pub const SYS_getrandom: ::c_long = 355; ++pub const SYS_memfd_create: ::c_long = 356; ++pub const SYS_bpf: ::c_long = 357; ++pub const SYS_execveat: ::c_long = 358; ++pub const SYS_socket: ::c_long = 359; ++pub const SYS_socketpair: ::c_long = 360; ++pub const SYS_bind: ::c_long = 361; ++pub const SYS_connect: ::c_long = 362; ++pub const SYS_listen: ::c_long = 363; ++pub const SYS_accept4: ::c_long = 364; ++pub const SYS_getsockopt: ::c_long = 365; ++pub const SYS_setsockopt: ::c_long = 366; ++pub const SYS_getsockname: ::c_long = 367; ++pub const SYS_getpeername: ::c_long = 368; ++pub const SYS_sendto: ::c_long = 369; ++pub const SYS_sendmsg: ::c_long = 370; ++pub const SYS_recvfrom: ::c_long = 371; ++pub const SYS_recvmsg: ::c_long = 372; ++pub const SYS_shutdown: ::c_long = 373; ++pub const SYS_userfaultfd: ::c_long = 374; ++pub const SYS_membarrier: ::c_long = 375; ++pub const SYS_mlock2: ::c_long = 376; ++pub const SYS_copy_file_range: ::c_long = 377; ++pub const SYS_preadv2: ::c_long = 378; ++pub const SYS_pwritev2: ::c_long = 379; ++pub const SYS_pkey_mprotect: ::c_long = 380; ++pub const SYS_pkey_alloc: ::c_long = 381; ++pub const SYS_pkey_free: ::c_long = 382; ++ ++// offsets in user_regs_structs, from sys/reg.h ++pub const EBX: ::c_int = 0; ++pub const ECX: ::c_int = 1; ++pub const EDX: ::c_int = 2; ++pub const ESI: ::c_int = 3; ++pub const EDI: ::c_int = 4; ++pub const EBP: ::c_int = 5; ++pub const EAX: ::c_int = 6; ++pub const DS: ::c_int = 7; ++pub const ES: ::c_int = 8; ++pub const FS: ::c_int = 9; ++pub const GS: ::c_int = 10; ++pub const ORIG_EAX: ::c_int = 11; ++pub const EIP: ::c_int = 12; ++pub const CS: ::c_int = 13; ++pub const EFL: ::c_int = 14; ++pub const UESP: ::c_int = 15; ++pub const SS: ::c_int = 16; ++ ++extern { ++ 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 --cc vendor/libc-0.2.31/src/unix/notbsd/linux/other/b64/aarch64.rs index 000000000,000000000..f4583d589 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/other/b64/aarch64.rs @@@ -1,0 -1,0 +1,490 @@@ ++//! 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; ++pub type suseconds_t = i64; ++pub type __u64 = ::c_ulonglong; ++ ++s! { ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ __pad1: ::dev_t, ++ pub st_size: ::off_t, ++ pub st_blksize: ::blksize_t, ++ __pad2: ::c_int, ++ pub st_blocks: ::blkcnt_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ __unused: [::c_int; 2], ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ __pad1: ::dev_t, ++ pub st_size: ::off64_t, ++ pub st_blksize: ::blksize_t, ++ __pad2: ::c_int, ++ pub st_blocks: ::blkcnt64_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ __unused: [::c_int; 2], ++ } ++ ++ pub struct statfs64 { ++ pub f_type: ::__fsword_t, ++ pub f_bsize: ::__fsword_t, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::__fsword_t, ++ pub f_frsize: ::__fsword_t, ++ pub f_flags: ::__fsword_t, ++ pub f_spare: [::__fsword_t; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [u64; 8] ++ } ++ ++ pub struct ipc_perm { ++ pub __key: ::key_t, ++ pub uid: ::uid_t, ++ pub gid: ::gid_t, ++ pub cuid: ::uid_t, ++ pub cgid: ::gid_t, ++ pub mode: ::c_uint, ++ pub __seq: ::c_ushort, ++ __pad1: ::c_ushort, ++ __unused1: ::c_ulong, ++ __unused2: ::c_ulong ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, ++ pub shm_atime: ::time_t, ++ pub shm_dtime: ::time_t, ++ pub shm_ctime: ::time_t, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::shmatt_t, ++ __unused4: ::c_ulong, ++ __unused5: ::c_ulong ++ } ++} ++ ++pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; ++pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; ++ ++pub const RLIMIT_NOFILE: ::c_int = 7; ++pub const RLIMIT_NPROC: ::c_int = 6; ++ ++pub const O_APPEND: ::c_int = 1024; ++pub const O_CREAT: ::c_int = 64; ++pub const O_EXCL: ::c_int = 128; ++pub const O_NOCTTY: ::c_int = 256; ++pub const O_NONBLOCK: ::c_int = 2048; ++pub const O_SYNC: ::c_int = 1052672; ++pub const O_RSYNC: ::c_int = 1052672; ++pub const O_DSYNC: ::c_int = 4096; ++pub const O_FSYNC: ::c_int = 0x101000; ++pub const O_NOATIME: ::c_int = 0o1000000; ++pub const O_PATH: ::c_int = 0o10000000; ++ ++pub const MAP_GROWSDOWN: ::c_int = 0x0100; ++ ++pub const EDEADLK: ::c_int = 35; ++pub const ENAMETOOLONG: ::c_int = 36; ++pub const ENOLCK: ::c_int = 37; ++pub const ENOSYS: ::c_int = 38; ++pub const ENOTEMPTY: ::c_int = 39; ++pub const ELOOP: ::c_int = 40; ++pub const ENOMSG: ::c_int = 42; ++pub const EIDRM: ::c_int = 43; ++pub const ECHRNG: ::c_int = 44; ++pub const EL2NSYNC: ::c_int = 45; ++pub const EL3HLT: ::c_int = 46; ++pub const EL3RST: ::c_int = 47; ++pub const ELNRNG: ::c_int = 48; ++pub const EUNATCH: ::c_int = 49; ++pub const ENOCSI: ::c_int = 50; ++pub const EL2HLT: ::c_int = 51; ++pub const EBADE: ::c_int = 52; ++pub const EBADR: ::c_int = 53; ++pub const EXFULL: ::c_int = 54; ++pub const ENOANO: ::c_int = 55; ++pub const EBADRQC: ::c_int = 56; ++pub const EBADSLT: ::c_int = 57; ++pub const EMULTIHOP: ::c_int = 72; ++pub const EOVERFLOW: ::c_int = 75; ++pub const ENOTUNIQ: ::c_int = 76; ++pub const EBADFD: ::c_int = 77; ++pub const EBADMSG: ::c_int = 74; ++pub const EREMCHG: ::c_int = 78; ++pub const ELIBACC: ::c_int = 79; ++pub const ELIBBAD: ::c_int = 80; ++pub const ELIBSCN: ::c_int = 81; ++pub const ELIBMAX: ::c_int = 82; ++pub const ELIBEXEC: ::c_int = 83; ++pub const EILSEQ: ::c_int = 84; ++pub const ERESTART: ::c_int = 85; ++pub const ESTRPIPE: ::c_int = 86; ++pub const EUSERS: ::c_int = 87; ++pub const ENOTSOCK: ::c_int = 88; ++pub const EDESTADDRREQ: ::c_int = 89; ++pub const EMSGSIZE: ::c_int = 90; ++pub const EPROTOTYPE: ::c_int = 91; ++pub const ENOPROTOOPT: ::c_int = 92; ++pub const EPROTONOSUPPORT: ::c_int = 93; ++pub const ESOCKTNOSUPPORT: ::c_int = 94; ++pub const EOPNOTSUPP: ::c_int = 95; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const EAFNOSUPPORT: ::c_int = 97; ++pub const EADDRINUSE: ::c_int = 98; ++pub const EADDRNOTAVAIL: ::c_int = 99; ++pub const ENETDOWN: ::c_int = 100; ++pub const ENETUNREACH: ::c_int = 101; ++pub const ENETRESET: ::c_int = 102; ++pub const ECONNABORTED: ::c_int = 103; ++pub const ECONNRESET: ::c_int = 104; ++pub const ENOBUFS: ::c_int = 105; ++pub const EISCONN: ::c_int = 106; ++pub const ENOTCONN: ::c_int = 107; ++pub const ESHUTDOWN: ::c_int = 108; ++pub const ETOOMANYREFS: ::c_int = 109; ++pub const ETIMEDOUT: ::c_int = 110; ++pub const ECONNREFUSED: ::c_int = 111; ++pub const EHOSTDOWN: ::c_int = 112; ++pub const EHOSTUNREACH: ::c_int = 113; ++pub const EALREADY: ::c_int = 114; ++pub const EINPROGRESS: ::c_int = 115; ++pub const ESTALE: ::c_int = 116; ++pub const EDQUOT: ::c_int = 122; ++pub const ENOMEDIUM: ::c_int = 123; ++pub const EMEDIUMTYPE: ::c_int = 124; ++pub const ECANCELED: ::c_int = 125; ++pub const ENOKEY: ::c_int = 126; ++pub const EKEYEXPIRED: ::c_int = 127; ++pub const EKEYREVOKED: ::c_int = 128; ++pub const EKEYREJECTED: ::c_int = 129; ++pub const EOWNERDEAD: ::c_int = 130; ++pub const ENOTRECOVERABLE: ::c_int = 131; ++pub const EHWPOISON: ::c_int = 133; ++pub const ERFKILL: ::c_int = 132; ++ ++pub const SOL_SOCKET: ::c_int = 1; ++ ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_TYPE: ::c_int = 3; ++pub const SO_ERROR: ::c_int = 4; ++pub const SO_DONTROUTE: ::c_int = 5; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SO_SNDBUF: ::c_int = 7; ++pub const SO_RCVBUF: ::c_int = 8; ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_KEEPALIVE: ::c_int = 9; ++pub const SO_OOBINLINE: ::c_int = 10; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_LINGER: ::c_int = 13; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_REUSEPORT: ::c_int = 15; ++pub const SO_PASSCRED: ::c_int = 16; ++pub const SO_PEERCRED: ::c_int = 17; ++pub const SO_RCVLOWAT: ::c_int = 18; ++pub const SO_SNDLOWAT: ::c_int = 19; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_SNDTIMEO: ::c_int = 21; ++pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; ++pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; ++pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; ++pub const SO_BINDTODEVICE: ::c_int = 25; ++pub const SO_ATTACH_FILTER: ::c_int = 26; ++pub const SO_DETACH_FILTER: ::c_int = 27; ++pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; ++pub const SO_PEERNAME: ::c_int = 28; ++pub const SO_TIMESTAMP: ::c_int = 29; ++pub const SO_ACCEPTCONN: ::c_int = 30; ++pub const SO_PEERSEC: ::c_int = 31; ++pub const SO_PASSSEC: ::c_int = 34; ++pub const SO_TIMESTAMPNS: ::c_int = 35; ++pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; ++pub const SO_MARK: ::c_int = 36; ++pub const SO_TIMESTAMPING: ::c_int = 37; ++pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; ++pub const SO_PROTOCOL: ::c_int = 38; ++pub const SO_DOMAIN: ::c_int = 39; ++pub const SO_RXQ_OVFL: ::c_int = 40; ++pub const SO_WIFI_STATUS: ::c_int = 41; ++pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; ++pub const SO_PEEK_OFF: ::c_int = 42; ++pub const SO_NOFCS: ::c_int = 43; ++pub const SO_LOCK_FILTER: ::c_int = 44; ++pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; ++pub const SO_BUSY_POLL: ::c_int = 46; ++pub const SO_MAX_PACING_RATE: ::c_int = 47; ++pub const SO_BPF_EXTENSIONS: ::c_int = 48; ++pub const SO_INCOMING_CPU: ::c_int = 49; ++pub const SO_ATTACH_BPF: ::c_int = 50; ++pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER; ++ ++pub const SA_ONSTACK: ::c_int = 0x08000000; ++pub const SA_SIGINFO: ::c_int = 0x00000004; ++pub const SA_NOCLDWAIT: ::c_int = 0x00000002; ++ ++pub const SIGCHLD: ::c_int = 17; ++pub const SIGBUS: ::c_int = 7; ++pub const SIGUSR1: ::c_int = 10; ++pub const SIGUSR2: ::c_int = 12; ++pub const SIGCONT: ::c_int = 18; ++pub const SIGSTOP: ::c_int = 19; ++pub const SIGTSTP: ::c_int = 20; ++pub const SIGURG: ::c_int = 23; ++pub const SIGIO: ::c_int = 29; ++pub const SIGSYS: ::c_int = 31; ++pub const SIGSTKFLT: ::c_int = 16; ++pub const SIGUNUSED: ::c_int = 31; ++pub const SIGPOLL: ::c_int = 29; ++pub const SIGPWR: ::c_int = 30; ++pub const SIG_SETMASK: ::c_int = 2; ++pub const SIG_BLOCK: ::c_int = 0x000000; ++pub const SIG_UNBLOCK: ::c_int = 0x01; ++ ++pub const POLLWRNORM: ::c_short = 0x100; ++pub const POLLWRBAND: ::c_short = 0x200; ++ ++pub const O_ASYNC: ::c_int = 0x2000; ++pub const O_NDELAY: ::c_int = 0x800; ++ ++pub const PTRACE_DETACH: ::c_uint = 17; ++ ++pub const EFD_NONBLOCK: ::c_int = 0x800; ++ ++pub const F_GETLK: ::c_int = 5; ++pub const F_GETOWN: ::c_int = 9; ++pub const F_SETOWN: ::c_int = 8; ++pub const F_SETLK: ::c_int = 6; ++pub const F_SETLKW: ::c_int = 7; ++ ++pub const SFD_NONBLOCK: ::c_int = 0x0800; ++ ++pub const TIOCEXCL: ::c_ulong = 0x540C; ++pub const TIOCNXCL: ::c_ulong = 0x540D; ++pub const TIOCSCTTY: ::c_ulong = 0x540E; ++pub const TIOCSTI: ::c_ulong = 0x5412; ++pub const TIOCMGET: ::c_ulong = 0x5415; ++pub const TIOCMBIS: ::c_ulong = 0x5416; ++pub const TIOCMBIC: ::c_ulong = 0x5417; ++pub const TIOCMSET: ::c_ulong = 0x5418; ++pub const TIOCCONS: ::c_ulong = 0x541D; ++ ++pub const SFD_CLOEXEC: ::c_int = 0x080000; ++ ++pub const NCCS: usize = 32; ++ ++pub const O_TRUNC: ::c_int = 512; ++ ++pub const O_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EBFONT: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const EDOTDOT: ::c_int = 73; ++ ++pub const SA_NODEFER: ::c_int = 0x40000000; ++pub const SA_RESETHAND: ::c_int = 0x80000000; ++pub const SA_RESTART: ::c_int = 0x10000000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000001; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x80000; ++ ++pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; ++ ++pub const O_DIRECT: ::c_int = 0x10000; ++pub const O_DIRECTORY: ::c_int = 0x4000; ++pub const O_NOFOLLOW: ::c_int = 0x8000; ++ ++pub const MAP_LOCKED: ::c_int = 0x02000; ++pub const MAP_NORESERVE: ::c_int = 0x04000; ++ ++pub const EDEADLOCK: ::c_int = 35; ++ ++pub const FIOCLEX: ::c_ulong = 0x5451; ++pub const FIONBIO: ::c_ulong = 0x5421; ++ ++pub const SYS_pivot_root: ::c_long = 41; ++pub const SYS_gettid: ::c_long = 178; ++pub const SYS_perf_event_open: ::c_long = 241; ++pub const SYS_memfd_create: ::c_long = 279; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const SIGSTKSZ: ::size_t = 16384; ++pub const MINSIGSTKSZ: ::size_t = 5120; ++pub const CBAUD: ::tcflag_t = 0o0010017; ++pub const TAB1: ::c_int = 0x00000800; ++pub const TAB2: ::c_int = 0x00001000; ++pub const TAB3: ::c_int = 0x00001800; ++pub const CR1: ::c_int = 0x00000200; ++pub const CR2: ::c_int = 0x00000400; ++pub const CR3: ::c_int = 0x00000600; ++pub const FF1: ::c_int = 0x00008000; ++pub const BS1: ::c_int = 0x00002000; ++pub const VT1: ::c_int = 0x00004000; ++pub const VWERASE: usize = 14; ++pub const VREPRINT: usize = 12; ++pub const VSUSP: usize = 10; ++pub const VSTART: usize = 8; ++pub const VSTOP: usize = 9; ++pub const VDISCARD: usize = 13; ++pub const VTIME: usize = 5; ++pub const IXON: ::tcflag_t = 0x00000400; ++pub const IXOFF: ::tcflag_t = 0x00001000; ++pub const ONLCR: ::tcflag_t = 0x4; ++pub const CSIZE: ::tcflag_t = 0x00000030; ++pub const CS6: ::tcflag_t = 0x00000010; ++pub const CS7: ::tcflag_t = 0x00000020; ++pub const CS8: ::tcflag_t = 0x00000030; ++pub const CSTOPB: ::tcflag_t = 0x00000040; ++pub const CREAD: ::tcflag_t = 0x00000080; ++pub const PARENB: ::tcflag_t = 0x00000100; ++pub const PARODD: ::tcflag_t = 0x00000200; ++pub const HUPCL: ::tcflag_t = 0x00000400; ++pub const CLOCAL: ::tcflag_t = 0x00000800; ++pub const ECHOKE: ::tcflag_t = 0x00000800; ++pub const ECHOE: ::tcflag_t = 0x00000010; ++pub const ECHOK: ::tcflag_t = 0x00000020; ++pub const ECHONL: ::tcflag_t = 0x00000040; ++pub const ECHOPRT: ::tcflag_t = 0x00000400; ++pub const ECHOCTL: ::tcflag_t = 0x00000200; ++pub const ISIG: ::tcflag_t = 0x00000001; ++pub const ICANON: ::tcflag_t = 0x00000002; ++pub const PENDIN: ::tcflag_t = 0x00004000; ++pub const NOFLSH: ::tcflag_t = 0x00000080; ++pub const CIBAUD: ::tcflag_t = 0o02003600000; ++pub const CBAUDEX: ::tcflag_t = 0o010000; ++pub const VSWTC: usize = 7; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const XTABS: ::tcflag_t = 0o014000; ++ ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const B57600: ::speed_t = 0o010001; ++pub const B115200: ::speed_t = 0o010002; ++pub const B230400: ::speed_t = 0o010003; ++pub const B460800: ::speed_t = 0o010004; ++pub const B500000: ::speed_t = 0o010005; ++pub const B576000: ::speed_t = 0o010006; ++pub const B921600: ::speed_t = 0o010007; ++pub const B1000000: ::speed_t = 0o010010; ++pub const B1152000: ::speed_t = 0o010011; ++pub const B1500000: ::speed_t = 0o010012; ++pub const B2000000: ::speed_t = 0o010013; ++pub const B2500000: ::speed_t = 0o010014; ++pub const B3000000: ::speed_t = 0o010015; ++pub const B3500000: ::speed_t = 0o010016; ++pub const B4000000: ::speed_t = 0o010017; ++ ++pub const 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 --cc vendor/libc-0.2.31/src/unix/notbsd/linux/other/b64/mod.rs index 000000000,000000000..aa0e09108 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/other/b64/mod.rs @@@ -1,0 -1,0 +1,70 @@@ ++//! 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 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; ++pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; ++ ++pub const O_LARGEFILE: ::c_int = 0; ++ ++cfg_if! { ++ if #[cfg(target_arch = "aarch64")] { ++ mod aarch64; ++ pub use self::aarch64::*; ++ } else if #[cfg(any(target_arch = "powerpc64"))] { ++ mod powerpc64; ++ pub use self::powerpc64::*; ++ } else if #[cfg(any(target_arch = "sparc64"))] { ++ mod sparc64; ++ pub use self::sparc64::*; ++ } else if #[cfg(any(target_arch = "x86_64"))] { ++ mod x86_64; ++ pub use self::x86_64::*; ++ } else { ++ // Unknown target_arch ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/other/b64/powerpc64.rs index 000000000,000000000..56a78b062 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/other/b64/powerpc64.rs @@@ -1,0 -1,0 +1,487 @@@ ++//! 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; ++pub type suseconds_t = i64; ++pub type __u64 = ::c_ulong; ++ ++s! { ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino_t, ++ pub st_nlink: ::nlink_t, ++ pub st_mode: ::mode_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ __pad0: ::c_int, ++ pub st_rdev: ::dev_t, ++ pub st_size: ::off_t, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ __unused: [::c_long; 3], ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino64_t, ++ pub st_nlink: ::nlink_t, ++ pub st_mode: ::mode_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ __pad0: ::c_int, ++ pub st_rdev: ::dev_t, ++ pub st_size: ::off64_t, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt64_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ __reserved: [::c_long; 3], ++ } ++ ++ pub struct statfs64 { ++ pub f_type: ::__fsword_t, ++ pub f_bsize: ::__fsword_t, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::__fsword_t, ++ pub f_frsize: ::__fsword_t, ++ pub f_flags: ::__fsword_t, ++ pub f_spare: [::__fsword_t; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [u64; 7] ++ } ++ ++ pub struct ipc_perm { ++ pub __key: ::key_t, ++ pub uid: ::uid_t, ++ pub gid: ::gid_t, ++ pub cuid: ::uid_t, ++ pub cgid: ::gid_t, ++ pub mode: ::mode_t, ++ pub __seq: ::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 TIOCGSOFTCAR: ::c_ulong = 0x5419; ++pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; ++ ++pub const RLIMIT_NOFILE: ::c_int = 7; ++pub const RLIMIT_NPROC: ::c_int = 6; ++ ++pub const O_APPEND: ::c_int = 1024; ++pub const O_CREAT: ::c_int = 64; ++pub const O_EXCL: ::c_int = 128; ++pub const O_NOCTTY: ::c_int = 256; ++pub const O_NONBLOCK: ::c_int = 2048; ++pub const O_SYNC: ::c_int = 1052672; ++pub const O_RSYNC: ::c_int = 1052672; ++pub const O_DSYNC: ::c_int = 4096; ++pub const O_FSYNC: ::c_int = 0x101000; ++pub const O_NOATIME: ::c_int = 0o1000000; ++pub const O_PATH: ::c_int = 0o10000000; ++ ++pub const MAP_GROWSDOWN: ::c_int = 0x0100; ++ ++pub const EDEADLK: ::c_int = 35; ++pub const ENAMETOOLONG: ::c_int = 36; ++pub const ENOLCK: ::c_int = 37; ++pub const ENOSYS: ::c_int = 38; ++pub const ENOTEMPTY: ::c_int = 39; ++pub const ELOOP: ::c_int = 40; ++pub const ENOMSG: ::c_int = 42; ++pub const EIDRM: ::c_int = 43; ++pub const ECHRNG: ::c_int = 44; ++pub const EL2NSYNC: ::c_int = 45; ++pub const EL3HLT: ::c_int = 46; ++pub const EL3RST: ::c_int = 47; ++pub const ELNRNG: ::c_int = 48; ++pub const EUNATCH: ::c_int = 49; ++pub const ENOCSI: ::c_int = 50; ++pub const EL2HLT: ::c_int = 51; ++pub const EBADE: ::c_int = 52; ++pub const EBADR: ::c_int = 53; ++pub const EXFULL: ::c_int = 54; ++pub const ENOANO: ::c_int = 55; ++pub const EBADRQC: ::c_int = 56; ++pub const EBADSLT: ::c_int = 57; ++pub const EMULTIHOP: ::c_int = 72; ++pub const EOVERFLOW: ::c_int = 75; ++pub const ENOTUNIQ: ::c_int = 76; ++pub const EBADFD: ::c_int = 77; ++pub const EBADMSG: ::c_int = 74; ++pub const EREMCHG: ::c_int = 78; ++pub const ELIBACC: ::c_int = 79; ++pub const ELIBBAD: ::c_int = 80; ++pub const ELIBSCN: ::c_int = 81; ++pub const ELIBMAX: ::c_int = 82; ++pub const ELIBEXEC: ::c_int = 83; ++pub const EILSEQ: ::c_int = 84; ++pub const ERESTART: ::c_int = 85; ++pub const ESTRPIPE: ::c_int = 86; ++pub const EUSERS: ::c_int = 87; ++pub const ENOTSOCK: ::c_int = 88; ++pub const EDESTADDRREQ: ::c_int = 89; ++pub const EMSGSIZE: ::c_int = 90; ++pub const EPROTOTYPE: ::c_int = 91; ++pub const ENOPROTOOPT: ::c_int = 92; ++pub const EPROTONOSUPPORT: ::c_int = 93; ++pub const ESOCKTNOSUPPORT: ::c_int = 94; ++pub const EOPNOTSUPP: ::c_int = 95; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const EAFNOSUPPORT: ::c_int = 97; ++pub const EADDRINUSE: ::c_int = 98; ++pub const EADDRNOTAVAIL: ::c_int = 99; ++pub const ENETDOWN: ::c_int = 100; ++pub const ENETUNREACH: ::c_int = 101; ++pub const ENETRESET: ::c_int = 102; ++pub const ECONNABORTED: ::c_int = 103; ++pub const ECONNRESET: ::c_int = 104; ++pub const ENOBUFS: ::c_int = 105; ++pub const EISCONN: ::c_int = 106; ++pub const ENOTCONN: ::c_int = 107; ++pub const ESHUTDOWN: ::c_int = 108; ++pub const ETOOMANYREFS: ::c_int = 109; ++pub const ETIMEDOUT: ::c_int = 110; ++pub const ECONNREFUSED: ::c_int = 111; ++pub const EHOSTDOWN: ::c_int = 112; ++pub const EHOSTUNREACH: ::c_int = 113; ++pub const EALREADY: ::c_int = 114; ++pub const EINPROGRESS: ::c_int = 115; ++pub const ESTALE: ::c_int = 116; ++pub const EDQUOT: ::c_int = 122; ++pub const ENOMEDIUM: ::c_int = 123; ++pub const EMEDIUMTYPE: ::c_int = 124; ++pub const ECANCELED: ::c_int = 125; ++pub const ENOKEY: ::c_int = 126; ++pub const EKEYEXPIRED: ::c_int = 127; ++pub const EKEYREVOKED: ::c_int = 128; ++pub const EKEYREJECTED: ::c_int = 129; ++pub const EOWNERDEAD: ::c_int = 130; ++pub const ENOTRECOVERABLE: ::c_int = 131; ++pub const EHWPOISON: ::c_int = 133; ++pub const ERFKILL: ::c_int = 132; ++ ++pub const SOL_SOCKET: ::c_int = 1; ++ ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_TYPE: ::c_int = 3; ++pub const SO_ERROR: ::c_int = 4; ++pub const SO_DONTROUTE: ::c_int = 5; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SO_SNDBUF: ::c_int = 7; ++pub const SO_RCVBUF: ::c_int = 8; ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_KEEPALIVE: ::c_int = 9; ++pub const SO_OOBINLINE: ::c_int = 10; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_LINGER: ::c_int = 13; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_REUSEPORT: ::c_int = 15; ++pub const SO_PASSCRED: ::c_int = 20; ++pub const SO_PEERCRED: ::c_int = 21; ++pub const SO_RCVLOWAT: ::c_int = 16; ++pub const SO_SNDLOWAT: ::c_int = 17; ++pub const SO_RCVTIMEO: ::c_int = 18; ++pub const SO_SNDTIMEO: ::c_int = 19; ++pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; ++pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; ++pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; ++pub const SO_BINDTODEVICE: ::c_int = 25; ++pub const SO_ATTACH_FILTER: ::c_int = 26; ++pub const SO_DETACH_FILTER: ::c_int = 27; ++pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; ++pub const SO_PEERNAME: ::c_int = 28; ++pub const SO_TIMESTAMP: ::c_int = 29; ++pub const SO_ACCEPTCONN: ::c_int = 30; ++pub const SO_PEERSEC: ::c_int = 31; ++pub const SO_PASSSEC: ::c_int = 34; ++pub const SO_TIMESTAMPNS: ::c_int = 35; ++pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; ++pub const SO_MARK: ::c_int = 36; ++pub const SO_TIMESTAMPING: ::c_int = 37; ++pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; ++pub const SO_PROTOCOL: ::c_int = 38; ++pub const SO_DOMAIN: ::c_int = 39; ++pub const SO_RXQ_OVFL: ::c_int = 40; ++pub const SO_WIFI_STATUS: ::c_int = 41; ++pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; ++pub const SO_PEEK_OFF: ::c_int = 42; ++pub const SO_NOFCS: ::c_int = 43; ++pub const SO_LOCK_FILTER: ::c_int = 44; ++pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; ++pub const SO_BUSY_POLL: ::c_int = 46; ++pub const SO_MAX_PACING_RATE: ::c_int = 47; ++pub const SO_BPF_EXTENSIONS: ::c_int = 48; ++pub const SO_INCOMING_CPU: ::c_int = 49; ++pub const SO_ATTACH_BPF: ::c_int = 50; ++pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER; ++ ++pub const SA_ONSTACK: ::c_int = 0x08000000; ++pub const SA_SIGINFO: ::c_int = 0x00000004; ++pub const SA_NOCLDWAIT: ::c_int = 0x00000002; ++ ++pub const SIGCHLD: ::c_int = 17; ++pub const SIGBUS: ::c_int = 7; ++pub const SIGUSR1: ::c_int = 10; ++pub const SIGUSR2: ::c_int = 12; ++pub const SIGCONT: ::c_int = 18; ++pub const SIGSTOP: ::c_int = 19; ++pub const SIGTSTP: ::c_int = 20; ++pub const SIGURG: ::c_int = 23; ++pub const SIGIO: ::c_int = 29; ++pub const SIGSYS: ::c_int = 31; ++pub const SIGSTKFLT: ::c_int = 16; ++pub const SIGUNUSED: ::c_int = 31; ++pub const SIGPOLL: ::c_int = 29; ++pub const SIGPWR: ::c_int = 30; ++pub const SIG_SETMASK: ::c_int = 2; ++pub const SIG_BLOCK: ::c_int = 0x000000; ++pub const SIG_UNBLOCK: ::c_int = 0x01; ++ ++pub const POLLWRNORM: ::c_short = 0x100; ++pub const POLLWRBAND: ::c_short = 0x200; ++ ++pub const O_ASYNC: ::c_int = 0x2000; ++pub const O_NDELAY: ::c_int = 0x800; ++ ++pub const PTRACE_DETACH: ::c_uint = 17; ++ ++pub const EFD_NONBLOCK: ::c_int = 0x800; ++ ++pub const F_GETLK: ::c_int = 5; ++pub const F_GETOWN: ::c_int = 9; ++pub const F_SETOWN: ::c_int = 8; ++pub const F_SETLK: ::c_int = 6; ++pub const F_SETLKW: ::c_int = 7; ++ ++pub const SFD_NONBLOCK: ::c_int = 0x0800; ++ ++pub const TIOCEXCL: ::c_ulong = 0x540C; ++pub const TIOCNXCL: ::c_ulong = 0x540D; ++pub const TIOCSCTTY: ::c_ulong = 0x540E; ++pub const TIOCSTI: ::c_ulong = 0x5412; ++pub const TIOCMGET: ::c_ulong = 0x5415; ++pub const TIOCMBIS: ::c_ulong = 0x5416; ++pub const TIOCMBIC: ::c_ulong = 0x5417; ++pub const TIOCMSET: ::c_ulong = 0x5418; ++pub const TIOCCONS: ::c_ulong = 0x541D; ++ ++pub const SFD_CLOEXEC: ::c_int = 0x080000; ++ ++pub const NCCS: usize = 32; ++ ++pub const O_TRUNC: ::c_int = 512; ++ ++pub const O_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EBFONT: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const EDOTDOT: ::c_int = 73; ++ ++pub const SA_NODEFER: ::c_int = 0x40000000; ++pub const SA_RESETHAND: ::c_int = 0x80000000; ++pub const SA_RESTART: ::c_int = 0x10000000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000001; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x80000; ++ ++pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 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 FIOCLEX: ::c_ulong = 0x20006601; ++pub const FIONBIO: ::c_ulong = 0x8004667e; ++ ++pub const SYS_pivot_root: ::c_long = 203; ++pub const SYS_gettid: ::c_long = 207; ++pub const SYS_perf_event_open: ::c_long = 319; ++pub const SYS_memfd_create: ::c_long = 360; ++ ++pub const MCL_CURRENT: ::c_int = 0x2000; ++pub const MCL_FUTURE: ::c_int = 0x4000; ++ ++pub const SIGSTKSZ: ::size_t = 0x4000; ++pub const MINSIGSTKSZ: ::size_t = 4096; ++pub const CBAUD: ::tcflag_t = 0xff; ++pub const TAB1: ::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 VSWTC: usize = 9; ++pub const OLCUC: ::tcflag_t = 0o000004; ++pub const NLDLY: ::tcflag_t = 0o001400; ++pub const CRDLY: ::tcflag_t = 0o030000; ++pub const TABDLY: ::tcflag_t = 0o006000; ++pub const BSDLY: ::tcflag_t = 0o100000; ++pub const FFDLY: ::tcflag_t = 0o040000; ++pub const VTDLY: ::tcflag_t = 0o200000; ++pub const XTABS: ::tcflag_t = 0o006000; ++ ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const CBAUDEX: ::speed_t = 0o000020; ++pub const B57600: ::speed_t = 0o0020; ++pub const B115200: ::speed_t = 0o0021; ++pub const B230400: ::speed_t = 0o0022; ++pub const B460800: ::speed_t = 0o0023; ++pub const B500000: ::speed_t = 0o0024; ++pub const B576000: ::speed_t = 0o0025; ++pub const B921600: ::speed_t = 0o0026; ++pub const B1000000: ::speed_t = 0o0027; ++pub const B1152000: ::speed_t = 0o0030; ++pub const B1500000: ::speed_t = 0o0031; ++pub const B2000000: ::speed_t = 0o0032; ++pub const B2500000: ::speed_t = 0o0033; ++pub const B3000000: ::speed_t = 0o0034; ++pub const B3500000: ::speed_t = 0o0035; ++pub const B4000000: ::speed_t = 0o0036; ++ ++pub const 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 --cc vendor/libc-0.2.31/src/unix/notbsd/linux/other/b64/sparc64.rs index 000000000,000000000..d9985301e new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/other/b64/sparc64.rs @@@ -1,0 -1,0 +1,421 @@@ ++//! SPARC64-specific definitions for 64-bit linux-like values ++ ++pub type c_char = i8; ++pub type wchar_t = i32; ++pub type nlink_t = u32; ++pub type blksize_t = i64; ++pub type suseconds_t = i32; ++pub type __u64 = ::c_ulonglong; ++ ++s! { ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ __pad0: u64, ++ pub st_ino: ::ino_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ __pad1: u64, ++ pub st_size: ::off_t, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ __unused: [::c_long; 2], ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::dev_t, ++ __pad0: u64, ++ pub st_ino: ::ino64_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ __pad2: ::c_int, ++ pub st_size: ::off64_t, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt64_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ __reserved: [::c_long; 2], ++ } ++ ++ pub struct statfs64 { ++ pub f_type: ::__fsword_t, ++ pub f_bsize: ::__fsword_t, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::__fsword_t, ++ pub f_frsize: ::__fsword_t, ++ pub f_flags: ::__fsword_t, ++ pub f_spare: [::__fsword_t; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [u64; 7] ++ } ++ ++ pub struct ipc_perm { ++ pub __key: ::key_t, ++ pub uid: ::uid_t, ++ pub gid: ::gid_t, ++ pub cuid: ::uid_t, ++ pub cgid: ::gid_t, ++ pub mode: ::mode_t, ++ __pad0: u16, ++ pub __seq: ::c_ushort, ++ __unused1: ::c_ulonglong, ++ __unused2: ::c_ulonglong, ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_atime: ::time_t, ++ pub shm_dtime: ::time_t, ++ pub shm_ctime: ::time_t, ++ pub shm_segsz: ::size_t, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::shmatt_t, ++ __reserved1: ::c_ulong, ++ __reserved2: ::c_ulong ++ } ++} ++ ++pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464; ++pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465; ++ ++pub const RLIMIT_NOFILE: ::c_int = 6; ++pub const RLIMIT_NPROC: ::c_int = 7; ++ ++pub const O_APPEND: ::c_int = 0x8; ++pub const O_CREAT: ::c_int = 0x200; ++pub const O_EXCL: ::c_int = 0x800; ++pub const O_NOCTTY: ::c_int = 0x8000; ++pub const O_NONBLOCK: ::c_int = 0x4000; ++pub const O_SYNC: ::c_int = 0x802000; ++pub const O_RSYNC: ::c_int = 0x802000; ++pub const O_DSYNC: ::c_int = 0x2000; ++pub const O_FSYNC: ::c_int = 0x802000; ++pub const O_NOATIME: ::c_int = 0x200000; ++pub const O_PATH: ::c_int = 0x1000000; ++ ++pub const MAP_GROWSDOWN: ::c_int = 0x0200; ++ ++pub const EDEADLK: ::c_int = 78; ++pub const ENAMETOOLONG: ::c_int = 63; ++pub const ENOLCK: ::c_int = 79; ++pub const ENOSYS: ::c_int = 90; ++pub const ENOTEMPTY: ::c_int = 66; ++pub const ELOOP: ::c_int = 62; ++pub const ENOMSG: ::c_int = 75; ++pub const EIDRM: ::c_int = 77; ++pub const ECHRNG: ::c_int = 94; ++pub const EL2NSYNC: ::c_int = 95; ++pub const EL3HLT: ::c_int = 96; ++pub const EL3RST: ::c_int = 97; ++pub const ELNRNG: ::c_int = 98; ++pub const EUNATCH: ::c_int = 99; ++pub const ENOCSI: ::c_int = 100; ++pub const EL2HLT: ::c_int = 101; ++pub const EBADE: ::c_int = 102; ++pub const EBADR: ::c_int = 103; ++pub const EXFULL: ::c_int = 104; ++pub const ENOANO: ::c_int = 105; ++pub const EBADRQC: ::c_int = 106; ++pub const EBADSLT: ::c_int = 107; ++pub const EMULTIHOP: ::c_int = 87; ++pub const EOVERFLOW: ::c_int = 92; ++pub const ENOTUNIQ: ::c_int = 115; ++pub const EBADFD: ::c_int = 93; ++pub const EBADMSG: ::c_int = 76; ++pub const EREMCHG: ::c_int = 89; ++pub const ELIBACC: ::c_int = 114; ++pub const ELIBBAD: ::c_int = 112; ++pub const ELIBSCN: ::c_int = 124; ++pub const ELIBMAX: ::c_int = 123; ++pub const ELIBEXEC: ::c_int = 110; ++pub const EILSEQ: ::c_int = 122; ++pub const ERESTART: ::c_int = 116; ++pub const ESTRPIPE: ::c_int = 91; ++pub const EUSERS: ::c_int = 68; ++pub const ENOTSOCK: ::c_int = 38; ++pub const EDESTADDRREQ: ::c_int = 39; ++pub const EMSGSIZE: ::c_int = 40; ++pub const EPROTOTYPE: ::c_int = 41; ++pub const ENOPROTOOPT: ::c_int = 42; ++pub const EPROTONOSUPPORT: ::c_int = 43; ++pub const ESOCKTNOSUPPORT: ::c_int = 44; ++pub const EOPNOTSUPP: ::c_int = 45; ++pub const EPFNOSUPPORT: ::c_int = 46; ++pub const EAFNOSUPPORT: ::c_int = 47; ++pub const EADDRINUSE: ::c_int = 48; ++pub const EADDRNOTAVAIL: ::c_int = 49; ++pub const ENETDOWN: ::c_int = 50; ++pub const ENETUNREACH: ::c_int = 51; ++pub const ENETRESET: ::c_int = 52; ++pub const ECONNABORTED: ::c_int = 53; ++pub const ECONNRESET: ::c_int = 54; ++pub const ENOBUFS: ::c_int = 55; ++pub const EISCONN: ::c_int = 56; ++pub const ENOTCONN: ::c_int = 57; ++pub const ESHUTDOWN: ::c_int = 58; ++pub const ETOOMANYREFS: ::c_int = 59; ++pub const ETIMEDOUT: ::c_int = 60; ++pub const ECONNREFUSED: ::c_int = 61; ++pub const EHOSTDOWN: ::c_int = 64; ++pub const EHOSTUNREACH: ::c_int = 65; ++pub const EALREADY: ::c_int = 37; ++pub const EINPROGRESS: ::c_int = 36; ++pub const ESTALE: ::c_int = 70; ++pub const EDQUOT: ::c_int = 69; ++pub const ENOMEDIUM: ::c_int = 125; ++pub const EMEDIUMTYPE: ::c_int = 126; ++pub const ECANCELED: ::c_int = 127; ++pub const ENOKEY: ::c_int = 128; ++pub const EKEYEXPIRED: ::c_int = 129; ++pub const EKEYREVOKED: ::c_int = 130; ++pub const EKEYREJECTED: ::c_int = 131; ++pub const EOWNERDEAD: ::c_int = 132; ++pub const ENOTRECOVERABLE: ::c_int = 133; ++pub const EHWPOISON: ::c_int = 135; ++pub const ERFKILL: ::c_int = 134; ++ ++pub const SOL_SOCKET: ::c_int = 0xffff; ++ ++pub const SO_REUSEADDR: ::c_int = 4; ++pub const SO_BINDTODEVICE: ::c_int = 0x000d; ++pub const SO_TIMESTAMP: ::c_int = 0x001d; ++pub const SO_MARK: ::c_int = 0x0022; ++pub const SO_RXQ_OVFL: ::c_int = 0x0024; ++pub const SO_PEEK_OFF: ::c_int = 0x0026; ++pub const SO_BUSY_POLL: ::c_int = 0x0030; ++pub const SO_TYPE: ::c_int = 0x1008; ++pub const SO_ERROR: ::c_int = 0x1007; ++pub const SO_DONTROUTE: ::c_int = 16; ++pub const SO_BROADCAST: ::c_int = 32; ++pub const SO_SNDBUF: ::c_int = 0x1001; ++pub const SO_RCVBUF: ::c_int = 0x1002; ++pub const SO_DOMAIN: ::c_int = 0x1029; ++pub const SO_KEEPALIVE: ::c_int = 8; ++pub const SO_OOBINLINE: ::c_int = 0x100; ++pub const SO_LINGER: ::c_int = 128; ++pub const SO_REUSEPORT: ::c_int = 0x200; ++pub const SO_ACCEPTCONN: ::c_int = 0x8000; ++ ++pub const SA_ONSTACK: ::c_int = 1; ++pub const SA_SIGINFO: ::c_int = 0x200; ++pub const SA_NOCLDWAIT: ::c_int = 0x100; ++ ++pub const SIGCHLD: ::c_int = 20; ++pub const SIGBUS: ::c_int = 10; ++pub const SIGUSR1: ::c_int = 30; ++pub const SIGUSR2: ::c_int = 31; ++pub const SIGCONT: ::c_int = 19; ++pub const SIGSTOP: ::c_int = 17; ++pub const SIGTSTP: ::c_int = 18; ++pub const SIGURG: ::c_int = 16; ++pub const SIGIO: ::c_int = 23; ++pub const SIGSYS: ::c_int = 12; ++pub const SIGPOLL: ::c_int = 23; ++pub const SIGPWR: ::c_int = 29; ++pub const SIG_SETMASK: ::c_int = 4; ++pub const SIG_BLOCK: ::c_int = 1; ++pub const SIG_UNBLOCK: ::c_int = 2; ++ ++pub const POLLWRNORM: ::c_short = 4; ++pub const POLLWRBAND: ::c_short = 0x100; ++ ++pub const O_ASYNC: ::c_int = 0x40; ++pub const O_NDELAY: ::c_int = 0x4004; ++ ++pub const PTRACE_DETACH: ::c_uint = 11; ++ ++pub const EFD_NONBLOCK: ::c_int = 0x4000; ++ ++pub const F_GETLK: ::c_int = 7; ++pub const F_GETOWN: ::c_int = 5; ++pub const F_SETOWN: ::c_int = 6; ++pub const F_SETLK: ::c_int = 8; ++pub const F_SETLKW: ::c_int = 9; ++ ++pub const SFD_NONBLOCK: ::c_int = 0x4000; ++ ++pub const TIOCEXCL: ::c_ulong = 0x2000740d; ++pub const TIOCNXCL: ::c_ulong = 0x2000740e; ++pub const TIOCSCTTY: ::c_ulong = 0x20007484; ++pub const TIOCSTI: ::c_ulong = 0x80017472; ++pub const TIOCMGET: ::c_ulong = 0x4004746a; ++pub const TIOCMBIS: ::c_ulong = 0x8004746c; ++pub const TIOCMBIC: ::c_ulong = 0x8004746b; ++pub const TIOCMSET: ::c_ulong = 0x8004746d; ++pub const TIOCCONS: ::c_ulong = 0x20007424; ++ ++pub const SFD_CLOEXEC: ::c_int = 0x400000; ++ ++pub const NCCS: usize = 17; ++pub const O_TRUNC: ::c_int = 0x400; ++ ++pub const O_CLOEXEC: ::c_int = 0x400000; ++ ++pub const EBFONT: ::c_int = 109; ++pub const ENOSTR: ::c_int = 72; ++pub const ENODATA: ::c_int = 111; ++pub const ETIME: ::c_int = 73; ++pub const ENOSR: ::c_int = 74; ++pub const ENONET: ::c_int = 80; ++pub const ENOPKG: ::c_int = 113; ++pub const EREMOTE: ::c_int = 71; ++pub const ENOLINK: ::c_int = 82; ++pub const EADV: ::c_int = 83; ++pub const ESRMNT: ::c_int = 84; ++pub const ECOMM: ::c_int = 85; ++pub const EPROTO: ::c_int = 86; ++pub const EDOTDOT: ::c_int = 88; ++ ++pub const SA_NODEFER: ::c_int = 0x20; ++pub const SA_RESETHAND: ::c_int = 0x4; ++pub const SA_RESTART: ::c_int = 0x2; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000008; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x400000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x400000; ++pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; ++ ++pub const O_DIRECTORY: ::c_int = 0o200000; ++pub const O_NOFOLLOW: ::c_int = 0o400000; ++pub const O_DIRECT: ::c_int = 0x100000; ++ ++pub const MAP_LOCKED: ::c_int = 0x0100; ++pub const MAP_NORESERVE: ::c_int = 0x00040; ++ ++pub const EDEADLOCK: ::c_int = 108; ++ ++pub const SO_PEERCRED: ::c_int = 0x40; ++pub const SO_RCVLOWAT: ::c_int = 0x800; ++pub const SO_SNDLOWAT: ::c_int = 0x1000; ++pub const SO_RCVTIMEO: ::c_int = 0x2000; ++pub const SO_SNDTIMEO: ::c_int = 0x4000; ++ ++pub const FIOCLEX: ::c_ulong = 0x20006601; ++pub const FIONBIO: ::c_ulong = 0x8004667e; ++ ++pub const SYS_gettid: ::c_long = 143; ++pub const SYS_perf_event_open: ::c_long = 327; ++ ++pub const MCL_CURRENT: ::c_int = 0x2000; ++pub const MCL_FUTURE: ::c_int = 0x4000; ++ ++pub const SIGSTKSZ: ::size_t = 16384; ++pub const MINSIGSTKSZ: ::size_t = 4096; ++pub const CBAUD: ::tcflag_t = 0x0000100f; ++pub const TAB1: ::c_int = 0x800; ++pub const TAB2: ::c_int = 0x1000; ++pub const TAB3: ::c_int = 0x1800; ++pub const CR1: ::c_int = 0x200; ++pub const CR2: ::c_int = 0x400; ++pub const CR3: ::c_int = 0x600; ++pub const FF1: ::c_int = 0x8000; ++pub const BS1: ::c_int = 0x2000; ++pub const VT1: ::c_int = 0x4000; ++pub const VWERASE: usize = 0xe; ++pub const VREPRINT: usize = 0xc; ++pub const VSUSP: usize = 0xa; ++pub const VSTART: usize = 0x8; ++pub const VSTOP: usize = 0x9; ++pub const VDISCARD: usize = 0xd; ++pub const VTIME: usize = 0x5; ++pub const IXON: ::tcflag_t = 0x400; ++pub const IXOFF: ::tcflag_t = 0x1000; ++pub const ONLCR: ::tcflag_t = 0x4; ++pub const CSIZE: ::tcflag_t = 0x30; ++pub const CS6: ::tcflag_t = 0x10; ++pub const CS7: ::tcflag_t = 0x20; ++pub const CS8: ::tcflag_t = 0x30; ++pub const CSTOPB: ::tcflag_t = 0x40; ++pub const CREAD: ::tcflag_t = 0x80; ++pub const PARENB: ::tcflag_t = 0x100; ++pub const PARODD: ::tcflag_t = 0x200; ++pub const HUPCL: ::tcflag_t = 0x400; ++pub const CLOCAL: ::tcflag_t = 0x800; ++pub const ECHOKE: ::tcflag_t = 0x800; ++pub const ECHOE: ::tcflag_t = 0x10; ++pub const ECHOK: ::tcflag_t = 0x20; ++pub const ECHONL: ::tcflag_t = 0x40; ++pub const ECHOPRT: ::tcflag_t = 0x400; ++pub const ECHOCTL: ::tcflag_t = 0x200; ++pub const ISIG: ::tcflag_t = 0x1; ++pub const ICANON: ::tcflag_t = 0x2; ++pub const PENDIN: ::tcflag_t = 0x4000; ++pub const NOFLSH: ::tcflag_t = 0x80; ++pub const CIBAUD: ::tcflag_t = 0o02003600000; ++pub const CBAUDEX: ::tcflag_t = 0x00001000; ++pub const VSWTC: usize = 7; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const XTABS: ::tcflag_t = 0o014000; ++ ++pub const VEOL: usize = 5; ++pub const VEOL2: usize = 6; ++pub const VMIN: usize = 4; ++pub const IEXTEN: ::tcflag_t = 0x8000; ++pub const TOSTOP: ::tcflag_t = 0x100; ++pub const FLUSHO: ::tcflag_t = 0x2000; ++pub const EXTPROC: ::tcflag_t = 0x10000; ++pub const TCGETS: ::c_ulong = 0x40245408; ++pub const TCSETS: ::c_ulong = 0x80245409; ++pub const TCSETSW: ::c_ulong = 0x8024540a; ++pub const TCSETSF: ::c_ulong = 0x8024540b; ++pub const TCGETA: ::c_ulong = 0x40125401; ++pub const TCSETA: ::c_ulong = 0x80125402; ++pub const TCSETAW: ::c_ulong = 0x80125403; ++pub const TCSETAF: ::c_ulong = 0x80125404; ++pub const TCSBRK: ::c_ulong = 0x20005405; ++pub const TCXONC: ::c_ulong = 0x20005406; ++pub const TCFLSH: ::c_ulong = 0x20005407; ++pub const TIOCINQ: ::c_ulong = 0x4004667f; ++pub const TIOCGPGRP: ::c_ulong = 0x40047483; ++pub const TIOCSPGRP: ::c_ulong = 0x80047482; ++pub const TIOCOUTQ: ::c_ulong = 0x40047473; ++pub const TIOCGWINSZ: ::c_ulong = 0x40087468; ++pub const TIOCSWINSZ: ::c_ulong = 0x80087467; ++pub const FIONREAD: ::c_ulong = 0x4004667f; diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/other/b64/x86_64.rs index 000000000,000000000..81b2384a5 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/other/b64/x86_64.rs @@@ -1,0 -1,0 +1,972 @@@ ++//! x86_64-specific definitions for 64-bit linux-like values ++ ++pub type c_char = i8; ++pub type wchar_t = i32; ++pub type nlink_t = u64; ++pub type blksize_t = i64; ++pub type greg_t = i64; ++pub type suseconds_t = i64; ++pub type __u64 = ::c_ulonglong; ++ ++s! { ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino_t, ++ pub st_nlink: ::nlink_t, ++ pub st_mode: ::mode_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ __pad0: ::c_int, ++ pub st_rdev: ::dev_t, ++ pub st_size: ::off_t, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::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 statfs64 { ++ pub f_type: ::__fsword_t, ++ pub f_bsize: ::__fsword_t, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::__fsword_t, ++ pub f_frsize: ::__fsword_t, ++ pub f_flags: ::__fsword_t, ++ pub f_spare: [::__fsword_t; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [u64; 7] ++ } ++ ++ pub struct _libc_fpxreg { ++ pub significand: [u16; 4], ++ pub exponent: u16, ++ __private: [u16; 3], ++ } ++ ++ pub struct _libc_xmmreg { ++ pub element: [u32; 4], ++ } ++ ++ pub struct _libc_fpstate { ++ pub cwd: u16, ++ pub swd: u16, ++ pub ftw: u16, ++ pub fop: u16, ++ pub rip: u64, ++ pub rdp: u64, ++ pub mxcsr: u32, ++ pub mxcr_mask: u32, ++ pub _st: [_libc_fpxreg; 8], ++ pub _xmm: [_libc_xmmreg; 16], ++ __private: [u64; 12], ++ } ++ ++ pub struct user_fpregs_struct { ++ pub cwd: ::c_ushort, ++ pub swd: ::c_ushort, ++ pub ftw: ::c_ushort, ++ pub fop: ::c_ushort, ++ pub rip: ::c_ulonglong, ++ pub rdp: ::c_ulonglong, ++ pub mxcsr: ::c_uint, ++ pub mxcr_mask: ::c_uint, ++ pub st_space: [::c_uint; 32], ++ pub xmm_space: [::c_uint; 64], ++ padding: [::c_uint; 24], ++ } ++ ++ pub struct user_regs_struct { ++ pub r15: ::c_ulonglong, ++ pub r14: ::c_ulonglong, ++ pub r13: ::c_ulonglong, ++ pub r12: ::c_ulonglong, ++ pub rbp: ::c_ulonglong, ++ pub rbx: ::c_ulonglong, ++ pub r11: ::c_ulonglong, ++ pub r10: ::c_ulonglong, ++ pub r9: ::c_ulonglong, ++ pub r8: ::c_ulonglong, ++ pub rax: ::c_ulonglong, ++ pub rcx: ::c_ulonglong, ++ pub rdx: ::c_ulonglong, ++ pub rsi: ::c_ulonglong, ++ pub rdi: ::c_ulonglong, ++ pub orig_rax: ::c_ulonglong, ++ pub rip: ::c_ulonglong, ++ pub cs: ::c_ulonglong, ++ pub eflags: ::c_ulonglong, ++ pub rsp: ::c_ulonglong, ++ pub ss: ::c_ulonglong, ++ pub fs_base: ::c_ulonglong, ++ pub gs_base: ::c_ulonglong, ++ pub ds: ::c_ulonglong, ++ pub es: ::c_ulonglong, ++ pub fs: ::c_ulonglong, ++ pub gs: ::c_ulonglong, ++ } ++ ++ pub struct user { ++ pub regs: user_regs_struct, ++ pub u_fpvalid: ::c_int, ++ pub i387: user_fpregs_struct, ++ pub u_tsize: ::c_ulonglong, ++ pub u_dsize: ::c_ulonglong, ++ pub u_ssize: ::c_ulonglong, ++ pub start_code: ::c_ulonglong, ++ pub start_stack: ::c_ulonglong, ++ pub signal: ::c_longlong, ++ __reserved: ::c_int, ++ pub u_ar0: *mut user_regs_struct, ++ pub u_fpstate: *mut user_fpregs_struct, ++ pub magic: ::c_ulonglong, ++ pub u_comm: [::c_char; 32], ++ pub u_debugreg: [::c_ulonglong; 8], ++ } ++ ++ pub struct mcontext_t { ++ pub gregs: [greg_t; 23], ++ pub fpregs: *mut _libc_fpstate, ++ __private: [u64; 8], ++ } ++ ++ pub struct 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 TIOCGSOFTCAR: ::c_ulong = 0x5419; ++pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; ++ ++pub const RLIMIT_NOFILE: ::c_int = 7; ++pub const RLIMIT_NPROC: ::c_int = 6; ++ ++pub const O_APPEND: ::c_int = 1024; ++pub const O_CREAT: ::c_int = 64; ++pub const O_EXCL: ::c_int = 128; ++pub const O_NOCTTY: ::c_int = 256; ++pub const O_NONBLOCK: ::c_int = 2048; ++pub const O_SYNC: ::c_int = 1052672; ++pub const O_RSYNC: ::c_int = 1052672; ++pub const O_DSYNC: ::c_int = 4096; ++pub const O_FSYNC: ::c_int = 0x101000; ++pub const O_NOATIME: ::c_int = 0o1000000; ++pub const O_PATH: ::c_int = 0o10000000; ++ ++pub const MAP_GROWSDOWN: ::c_int = 0x0100; ++ ++pub const EDEADLK: ::c_int = 35; ++pub const ENAMETOOLONG: ::c_int = 36; ++pub const ENOLCK: ::c_int = 37; ++pub const ENOSYS: ::c_int = 38; ++pub const ENOTEMPTY: ::c_int = 39; ++pub const ELOOP: ::c_int = 40; ++pub const ENOMSG: ::c_int = 42; ++pub const EIDRM: ::c_int = 43; ++pub const ECHRNG: ::c_int = 44; ++pub const EL2NSYNC: ::c_int = 45; ++pub const EL3HLT: ::c_int = 46; ++pub const EL3RST: ::c_int = 47; ++pub const ELNRNG: ::c_int = 48; ++pub const EUNATCH: ::c_int = 49; ++pub const ENOCSI: ::c_int = 50; ++pub const EL2HLT: ::c_int = 51; ++pub const EBADE: ::c_int = 52; ++pub const EBADR: ::c_int = 53; ++pub const EXFULL: ::c_int = 54; ++pub const ENOANO: ::c_int = 55; ++pub const EBADRQC: ::c_int = 56; ++pub const EBADSLT: ::c_int = 57; ++pub const EMULTIHOP: ::c_int = 72; ++pub const EOVERFLOW: ::c_int = 75; ++pub const ENOTUNIQ: ::c_int = 76; ++pub const EBADFD: ::c_int = 77; ++pub const EBADMSG: ::c_int = 74; ++pub const EREMCHG: ::c_int = 78; ++pub const ELIBACC: ::c_int = 79; ++pub const ELIBBAD: ::c_int = 80; ++pub const ELIBSCN: ::c_int = 81; ++pub const ELIBMAX: ::c_int = 82; ++pub const ELIBEXEC: ::c_int = 83; ++pub const EILSEQ: ::c_int = 84; ++pub const ERESTART: ::c_int = 85; ++pub const ESTRPIPE: ::c_int = 86; ++pub const EUSERS: ::c_int = 87; ++pub const ENOTSOCK: ::c_int = 88; ++pub const EDESTADDRREQ: ::c_int = 89; ++pub const EMSGSIZE: ::c_int = 90; ++pub const EPROTOTYPE: ::c_int = 91; ++pub const ENOPROTOOPT: ::c_int = 92; ++pub const EPROTONOSUPPORT: ::c_int = 93; ++pub const ESOCKTNOSUPPORT: ::c_int = 94; ++pub const EOPNOTSUPP: ::c_int = 95; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const EAFNOSUPPORT: ::c_int = 97; ++pub const EADDRINUSE: ::c_int = 98; ++pub const EADDRNOTAVAIL: ::c_int = 99; ++pub const ENETDOWN: ::c_int = 100; ++pub const ENETUNREACH: ::c_int = 101; ++pub const ENETRESET: ::c_int = 102; ++pub const ECONNABORTED: ::c_int = 103; ++pub const ECONNRESET: ::c_int = 104; ++pub const ENOBUFS: ::c_int = 105; ++pub const EISCONN: ::c_int = 106; ++pub const ENOTCONN: ::c_int = 107; ++pub const ESHUTDOWN: ::c_int = 108; ++pub const ETOOMANYREFS: ::c_int = 109; ++pub const ETIMEDOUT: ::c_int = 110; ++pub const ECONNREFUSED: ::c_int = 111; ++pub const EHOSTDOWN: ::c_int = 112; ++pub const EHOSTUNREACH: ::c_int = 113; ++pub const EALREADY: ::c_int = 114; ++pub const EINPROGRESS: ::c_int = 115; ++pub const ESTALE: ::c_int = 116; ++pub const EDQUOT: ::c_int = 122; ++pub const ENOMEDIUM: ::c_int = 123; ++pub const EMEDIUMTYPE: ::c_int = 124; ++pub const ECANCELED: ::c_int = 125; ++pub const ENOKEY: ::c_int = 126; ++pub const EKEYEXPIRED: ::c_int = 127; ++pub const EKEYREVOKED: ::c_int = 128; ++pub const EKEYREJECTED: ::c_int = 129; ++pub const EOWNERDEAD: ::c_int = 130; ++pub const ENOTRECOVERABLE: ::c_int = 131; ++pub const EHWPOISON: ::c_int = 133; ++pub const ERFKILL: ::c_int = 132; ++ ++pub const SOL_SOCKET: ::c_int = 1; ++ ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_TYPE: ::c_int = 3; ++pub const SO_ERROR: ::c_int = 4; ++pub const SO_DONTROUTE: ::c_int = 5; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SO_SNDBUF: ::c_int = 7; ++pub const SO_RCVBUF: ::c_int = 8; ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_KEEPALIVE: ::c_int = 9; ++pub const SO_OOBINLINE: ::c_int = 10; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_LINGER: ::c_int = 13; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_REUSEPORT: ::c_int = 15; ++pub const SO_PASSCRED: ::c_int = 16; ++pub const SO_PEERCRED: ::c_int = 17; ++pub const SO_RCVLOWAT: ::c_int = 18; ++pub const SO_SNDLOWAT: ::c_int = 19; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_SNDTIMEO: ::c_int = 21; ++pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; ++pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; ++pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; ++pub const SO_BINDTODEVICE: ::c_int = 25; ++pub const SO_ATTACH_FILTER: ::c_int = 26; ++pub const SO_DETACH_FILTER: ::c_int = 27; ++pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; ++pub const SO_PEERNAME: ::c_int = 28; ++pub const SO_TIMESTAMP: ::c_int = 29; ++pub const SO_ACCEPTCONN: ::c_int = 30; ++pub const SO_PEERSEC: ::c_int = 31; ++pub const SO_PASSSEC: ::c_int = 34; ++pub const SO_TIMESTAMPNS: ::c_int = 35; ++pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; ++pub const SO_MARK: ::c_int = 36; ++pub const SO_TIMESTAMPING: ::c_int = 37; ++pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; ++pub const SO_PROTOCOL: ::c_int = 38; ++pub const SO_DOMAIN: ::c_int = 39; ++pub const SO_RXQ_OVFL: ::c_int = 40; ++pub const SO_WIFI_STATUS: ::c_int = 41; ++pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; ++pub const SO_PEEK_OFF: ::c_int = 42; ++pub const SO_NOFCS: ::c_int = 43; ++pub const SO_LOCK_FILTER: ::c_int = 44; ++pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; ++pub const SO_BUSY_POLL: ::c_int = 46; ++pub const SO_MAX_PACING_RATE: ::c_int = 47; ++pub const SO_BPF_EXTENSIONS: ::c_int = 48; ++pub const SO_INCOMING_CPU: ::c_int = 49; ++pub const SO_ATTACH_BPF: ::c_int = 50; ++pub const SO_DETACH_BPF: ::c_int = SO_DETACH_FILTER; ++ ++pub const SA_ONSTACK: ::c_int = 0x08000000; ++pub const SA_SIGINFO: ::c_int = 0x00000004; ++pub const SA_NOCLDWAIT: ::c_int = 0x00000002; ++ ++pub const SIGCHLD: ::c_int = 17; ++pub const SIGBUS: ::c_int = 7; ++pub const SIGUSR1: ::c_int = 10; ++pub const SIGUSR2: ::c_int = 12; ++pub const SIGCONT: ::c_int = 18; ++pub const SIGSTOP: ::c_int = 19; ++pub const SIGTSTP: ::c_int = 20; ++pub const SIGURG: ::c_int = 23; ++pub const SIGIO: ::c_int = 29; ++pub const SIGSYS: ::c_int = 31; ++pub const SIGSTKFLT: ::c_int = 16; ++pub const SIGUNUSED: ::c_int = 31; ++pub const SIGPOLL: ::c_int = 29; ++pub const SIGPWR: ::c_int = 30; ++pub const SIG_SETMASK: ::c_int = 2; ++pub const SIG_BLOCK: ::c_int = 0x000000; ++pub const SIG_UNBLOCK: ::c_int = 0x01; ++ ++pub const POLLWRNORM: ::c_short = 0x100; ++pub const POLLWRBAND: ::c_short = 0x200; ++ ++pub const O_ASYNC: ::c_int = 0x2000; ++pub const O_NDELAY: ::c_int = 0x800; ++ ++pub const PTRACE_DETACH: ::c_uint = 17; ++ ++pub const EFD_NONBLOCK: ::c_int = 0x800; ++ ++pub const F_GETLK: ::c_int = 5; ++pub const F_GETOWN: ::c_int = 9; ++pub const F_SETOWN: ::c_int = 8; ++pub const F_SETLK: ::c_int = 6; ++pub const F_SETLKW: ::c_int = 7; ++ ++pub const SFD_NONBLOCK: ::c_int = 0x0800; ++ ++pub const TIOCEXCL: ::c_ulong = 0x540C; ++pub const TIOCNXCL: ::c_ulong = 0x540D; ++pub const TIOCSCTTY: ::c_ulong = 0x540E; ++pub const TIOCSTI: ::c_ulong = 0x5412; ++pub const TIOCMGET: ::c_ulong = 0x5415; ++pub const TIOCMBIS: ::c_ulong = 0x5416; ++pub const TIOCMBIC: ::c_ulong = 0x5417; ++pub const TIOCMSET: ::c_ulong = 0x5418; ++pub const TIOCCONS: ::c_ulong = 0x541D; ++ ++pub const SFD_CLOEXEC: ::c_int = 0x080000; ++ ++pub const NCCS: usize = 32; ++ ++pub const O_TRUNC: ::c_int = 512; ++ ++pub const O_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EBFONT: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const EDOTDOT: ::c_int = 73; ++ ++pub const SA_NODEFER: ::c_int = 0x40000000; ++pub const SA_RESETHAND: ::c_int = 0x80000000; ++pub const SA_RESTART: ::c_int = 0x10000000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000001; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x80000; ++ ++pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 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 FIOCLEX: ::c_ulong = 0x5451; ++pub const FIONBIO: ::c_ulong = 0x5421; ++ ++pub const PTRACE_GETFPREGS: ::c_uint = 14; ++pub const PTRACE_SETFPREGS: ::c_uint = 15; ++pub const PTRACE_GETFPXREGS: ::c_uint = 18; ++pub const PTRACE_SETFPXREGS: ::c_uint = 19; ++pub const PTRACE_GETREGS: ::c_uint = 12; ++pub const PTRACE_SETREGS: ::c_uint = 13; ++pub const PTRACE_PEEKSIGINFO_SHARED: ::c_uint = 1; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const SIGSTKSZ: ::size_t = 8192; ++pub const MINSIGSTKSZ: ::size_t = 2048; ++pub const CBAUD: ::tcflag_t = 0o0010017; ++pub const TAB1: ::c_int = 0x00000800; ++pub const TAB2: ::c_int = 0x00001000; ++pub const TAB3: ::c_int = 0x00001800; ++pub const CR1: ::c_int = 0x00000200; ++pub const CR2: ::c_int = 0x00000400; ++pub const CR3: ::c_int = 0x00000600; ++pub const FF1: ::c_int = 0x00008000; ++pub const BS1: ::c_int = 0x00002000; ++pub const VT1: ::c_int = 0x00004000; ++pub const VWERASE: usize = 14; ++pub const VREPRINT: usize = 12; ++pub const VSUSP: usize = 10; ++pub const VSTART: usize = 8; ++pub const VSTOP: usize = 9; ++pub const VDISCARD: usize = 13; ++pub const VTIME: usize = 5; ++pub const IXON: ::tcflag_t = 0x00000400; ++pub const IXOFF: ::tcflag_t = 0x00001000; ++pub const ONLCR: ::tcflag_t = 0x4; ++pub const CSIZE: ::tcflag_t = 0x00000030; ++pub const CS6: ::tcflag_t = 0x00000010; ++pub const CS7: ::tcflag_t = 0x00000020; ++pub const CS8: ::tcflag_t = 0x00000030; ++pub const CSTOPB: ::tcflag_t = 0x00000040; ++pub const CREAD: ::tcflag_t = 0x00000080; ++pub const PARENB: ::tcflag_t = 0x00000100; ++pub const PARODD: ::tcflag_t = 0x00000200; ++pub const HUPCL: ::tcflag_t = 0x00000400; ++pub const CLOCAL: ::tcflag_t = 0x00000800; ++pub const ECHOKE: ::tcflag_t = 0x00000800; ++pub const ECHOE: ::tcflag_t = 0x00000010; ++pub const ECHOK: ::tcflag_t = 0x00000020; ++pub const ECHONL: ::tcflag_t = 0x00000040; ++pub const ECHOPRT: ::tcflag_t = 0x00000400; ++pub const ECHOCTL: ::tcflag_t = 0x00000200; ++pub const ISIG: ::tcflag_t = 0x00000001; ++pub const ICANON: ::tcflag_t = 0x00000002; ++pub const PENDIN: ::tcflag_t = 0x00004000; ++pub const NOFLSH: ::tcflag_t = 0x00000080; ++pub const CIBAUD: ::tcflag_t = 0o02003600000; ++pub const CBAUDEX: ::tcflag_t = 0o010000; ++pub const VSWTC: usize = 7; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const XTABS: ::tcflag_t = 0o014000; ++ ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const B57600: ::speed_t = 0o010001; ++pub const B115200: ::speed_t = 0o010002; ++pub const B230400: ::speed_t = 0o010003; ++pub const B460800: ::speed_t = 0o010004; ++pub const B500000: ::speed_t = 0o010005; ++pub const B576000: ::speed_t = 0o010006; ++pub const B921600: ::speed_t = 0o010007; ++pub const B1000000: ::speed_t = 0o010010; ++pub const B1152000: ::speed_t = 0o010011; ++pub const B1500000: ::speed_t = 0o010012; ++pub const B2000000: ::speed_t = 0o010013; ++pub const B2500000: ::speed_t = 0o010014; ++pub const B3000000: ::speed_t = 0o010015; ++pub const B3500000: ::speed_t = 0o010016; ++pub const B4000000: ::speed_t = 0o010017; ++ ++pub const VEOL: usize = 11; ++pub const VEOL2: usize = 16; ++pub const VMIN: usize = 6; ++pub const IEXTEN: ::tcflag_t = 0x00008000; ++pub const TOSTOP: ::tcflag_t = 0x00000100; ++pub const FLUSHO: ::tcflag_t = 0x00001000; ++pub const EXTPROC: ::tcflag_t = 0x00010000; ++pub const TCGETS: ::c_ulong = 0x5401; ++pub const TCSETS: ::c_ulong = 0x5402; ++pub const TCSETSW: ::c_ulong = 0x5403; ++pub const TCSETSF: ::c_ulong = 0x5404; ++pub const TCGETA: ::c_ulong = 0x5405; ++pub const TCSETA: ::c_ulong = 0x5406; ++pub const TCSETAW: ::c_ulong = 0x5407; ++pub const TCSETAF: ::c_ulong = 0x5408; ++pub const TCSBRK: ::c_ulong = 0x5409; ++pub const TCXONC: ::c_ulong = 0x540A; ++pub const TCFLSH: ::c_ulong = 0x540B; ++pub const TIOCINQ: ::c_ulong = 0x541B; ++pub const TIOCGPGRP: ::c_ulong = 0x540F; ++pub const TIOCSPGRP: ::c_ulong = 0x5410; ++pub const TIOCOUTQ: ::c_ulong = 0x5411; ++pub const TIOCGWINSZ: ::c_ulong = 0x5413; ++pub const TIOCSWINSZ: ::c_ulong = 0x5414; ++pub const FIONREAD: ::c_ulong = 0x541B; ++ ++// Syscall table ++ ++pub const SYS_read: ::c_long = 0; ++pub const SYS_write: ::c_long = 1; ++pub const SYS_open: ::c_long = 2; ++pub const SYS_close: ::c_long = 3; ++pub const SYS_stat: ::c_long = 4; ++pub const SYS_fstat: ::c_long = 5; ++pub const SYS_lstat: ::c_long = 6; ++pub const SYS_poll: ::c_long = 7; ++pub const SYS_lseek: ::c_long = 8; ++pub const SYS_mmap: ::c_long = 9; ++pub const SYS_mprotect: ::c_long = 10; ++pub const SYS_munmap: ::c_long = 11; ++pub const SYS_brk: ::c_long = 12; ++pub const SYS_rt_sigaction: ::c_long = 13; ++pub const SYS_rt_sigprocmask: ::c_long = 14; ++pub const SYS_rt_sigreturn: ::c_long = 15; ++pub const SYS_ioctl: ::c_long = 16; ++pub const SYS_pread64: ::c_long = 17; ++pub const SYS_pwrite64: ::c_long = 18; ++pub const SYS_readv: ::c_long = 19; ++pub const SYS_writev: ::c_long = 20; ++pub const SYS_access: ::c_long = 21; ++pub const SYS_pipe: ::c_long = 22; ++pub const SYS_select: ::c_long = 23; ++pub const SYS_sched_yield: ::c_long = 24; ++pub const SYS_mremap: ::c_long = 25; ++pub const SYS_msync: ::c_long = 26; ++pub const SYS_mincore: ::c_long = 27; ++pub const SYS_madvise: ::c_long = 28; ++pub const SYS_shmget: ::c_long = 29; ++pub const SYS_shmat: ::c_long = 30; ++pub const SYS_shmctl: ::c_long = 31; ++pub const SYS_dup: ::c_long = 32; ++pub const SYS_dup2: ::c_long = 33; ++pub const SYS_pause: ::c_long = 34; ++pub const SYS_nanosleep: ::c_long = 35; ++pub const SYS_getitimer: ::c_long = 36; ++pub const SYS_alarm: ::c_long = 37; ++pub const SYS_setitimer: ::c_long = 38; ++pub const SYS_getpid: ::c_long = 39; ++pub const SYS_sendfile: ::c_long = 40; ++pub const SYS_socket: ::c_long = 41; ++pub const SYS_connect: ::c_long = 42; ++pub const SYS_accept: ::c_long = 43; ++pub const SYS_sendto: ::c_long = 44; ++pub const SYS_recvfrom: ::c_long = 45; ++pub const SYS_sendmsg: ::c_long = 46; ++pub const SYS_recvmsg: ::c_long = 47; ++pub const SYS_shutdown: ::c_long = 48; ++pub const SYS_bind: ::c_long = 49; ++pub const SYS_listen: ::c_long = 50; ++pub const SYS_getsockname: ::c_long = 51; ++pub const SYS_getpeername: ::c_long = 52; ++pub const SYS_socketpair: ::c_long = 53; ++pub const SYS_setsockopt: ::c_long = 54; ++pub const SYS_getsockopt: ::c_long = 55; ++pub const SYS_clone: ::c_long = 56; ++pub const SYS_fork: ::c_long = 57; ++pub const SYS_vfork: ::c_long = 58; ++pub const SYS_execve: ::c_long = 59; ++pub const SYS_exit: ::c_long = 60; ++pub const SYS_wait4: ::c_long = 61; ++pub const SYS_kill: ::c_long = 62; ++pub const SYS_uname: ::c_long = 63; ++pub const SYS_semget: ::c_long = 64; ++pub const SYS_semop: ::c_long = 65; ++pub const SYS_semctl: ::c_long = 66; ++pub const SYS_shmdt: ::c_long = 67; ++pub const SYS_msgget: ::c_long = 68; ++pub const SYS_msgsnd: ::c_long = 69; ++pub const SYS_msgrcv: ::c_long = 70; ++pub const SYS_msgctl: ::c_long = 71; ++pub const SYS_fcntl: ::c_long = 72; ++pub const SYS_flock: ::c_long = 73; ++pub const SYS_fsync: ::c_long = 74; ++pub const SYS_fdatasync: ::c_long = 75; ++pub const SYS_truncate: ::c_long = 76; ++pub const SYS_ftruncate: ::c_long = 77; ++pub const SYS_getdents: ::c_long = 78; ++pub const SYS_getcwd: ::c_long = 79; ++pub const SYS_chdir: ::c_long = 80; ++pub const SYS_fchdir: ::c_long = 81; ++pub const SYS_rename: ::c_long = 82; ++pub const SYS_mkdir: ::c_long = 83; ++pub const SYS_rmdir: ::c_long = 84; ++pub const SYS_creat: ::c_long = 85; ++pub const SYS_link: ::c_long = 86; ++pub const SYS_unlink: ::c_long = 87; ++pub const SYS_symlink: ::c_long = 88; ++pub const SYS_readlink: ::c_long = 89; ++pub const SYS_chmod: ::c_long = 90; ++pub const SYS_fchmod: ::c_long = 91; ++pub const SYS_chown: ::c_long = 92; ++pub const SYS_fchown: ::c_long = 93; ++pub const SYS_lchown: ::c_long = 94; ++pub const SYS_umask: ::c_long = 95; ++pub const SYS_gettimeofday: ::c_long = 96; ++pub const SYS_getrlimit: ::c_long = 97; ++pub const SYS_getrusage: ::c_long = 98; ++pub const SYS_sysinfo: ::c_long = 99; ++pub const SYS_times: ::c_long = 100; ++pub const SYS_ptrace: ::c_long = 101; ++pub const SYS_getuid: ::c_long = 102; ++pub const SYS_syslog: ::c_long = 103; ++pub const SYS_getgid: ::c_long = 104; ++pub const SYS_setuid: ::c_long = 105; ++pub const SYS_setgid: ::c_long = 106; ++pub const SYS_geteuid: ::c_long = 107; ++pub const SYS_getegid: ::c_long = 108; ++pub const SYS_setpgid: ::c_long = 109; ++pub const SYS_getppid: ::c_long = 110; ++pub const SYS_getpgrp: ::c_long = 111; ++pub const SYS_setsid: ::c_long = 112; ++pub const SYS_setreuid: ::c_long = 113; ++pub const SYS_setregid: ::c_long = 114; ++pub const SYS_getgroups: ::c_long = 115; ++pub const SYS_setgroups: ::c_long = 116; ++pub const SYS_setresuid: ::c_long = 117; ++pub const SYS_getresuid: ::c_long = 118; ++pub const SYS_setresgid: ::c_long = 119; ++pub const SYS_getresgid: ::c_long = 120; ++pub const SYS_getpgid: ::c_long = 121; ++pub const SYS_setfsuid: ::c_long = 122; ++pub const SYS_setfsgid: ::c_long = 123; ++pub const SYS_getsid: ::c_long = 124; ++pub const SYS_capget: ::c_long = 125; ++pub const SYS_capset: ::c_long = 126; ++pub const SYS_rt_sigpending: ::c_long = 127; ++pub const SYS_rt_sigtimedwait: ::c_long = 128; ++pub const SYS_rt_sigqueueinfo: ::c_long = 129; ++pub const SYS_rt_sigsuspend: ::c_long = 130; ++pub const SYS_sigaltstack: ::c_long = 131; ++pub const SYS_utime: ::c_long = 132; ++pub const SYS_mknod: ::c_long = 133; ++pub const SYS_uselib: ::c_long = 134; ++pub const SYS_personality: ::c_long = 135; ++pub const SYS_ustat: ::c_long = 136; ++pub const SYS_statfs: ::c_long = 137; ++pub const SYS_fstatfs: ::c_long = 138; ++pub const SYS_sysfs: ::c_long = 139; ++pub const SYS_getpriority: ::c_long = 140; ++pub const SYS_setpriority: ::c_long = 141; ++pub const SYS_sched_setparam: ::c_long = 142; ++pub const SYS_sched_getparam: ::c_long = 143; ++pub const SYS_sched_setscheduler: ::c_long = 144; ++pub const SYS_sched_getscheduler: ::c_long = 145; ++pub const SYS_sched_get_priority_max: ::c_long = 146; ++pub const SYS_sched_get_priority_min: ::c_long = 147; ++pub const SYS_sched_rr_get_interval: ::c_long = 148; ++pub const SYS_mlock: ::c_long = 149; ++pub const SYS_munlock: ::c_long = 150; ++pub const SYS_mlockall: ::c_long = 151; ++pub const SYS_munlockall: ::c_long = 152; ++pub const SYS_vhangup: ::c_long = 153; ++pub const SYS_modify_ldt: ::c_long = 154; ++pub const SYS_pivot_root: ::c_long = 155; ++pub const SYS__sysctl: ::c_long = 156; ++pub const SYS_prctl: ::c_long = 157; ++pub const SYS_arch_prctl: ::c_long = 158; ++pub const SYS_adjtimex: ::c_long = 159; ++pub const SYS_setrlimit: ::c_long = 160; ++pub const SYS_chroot: ::c_long = 161; ++pub const SYS_sync: ::c_long = 162; ++pub const SYS_acct: ::c_long = 163; ++pub const SYS_settimeofday: ::c_long = 164; ++pub const SYS_mount: ::c_long = 165; ++pub const SYS_umount2: ::c_long = 166; ++pub const SYS_swapon: ::c_long = 167; ++pub const SYS_swapoff: ::c_long = 168; ++pub const SYS_reboot: ::c_long = 169; ++pub const SYS_sethostname: ::c_long = 170; ++pub const SYS_setdomainname: ::c_long = 171; ++pub const SYS_iopl: ::c_long = 172; ++pub const SYS_ioperm: ::c_long = 173; ++pub const SYS_create_module: ::c_long = 174; ++pub const SYS_init_module: ::c_long = 175; ++pub const SYS_delete_module: ::c_long = 176; ++pub const SYS_get_kernel_syms: ::c_long = 177; ++pub const SYS_query_module: ::c_long = 178; ++pub const SYS_quotactl: ::c_long = 179; ++pub const SYS_nfsservctl: ::c_long = 180; ++pub const SYS_getpmsg: ::c_long = 181; ++pub const SYS_putpmsg: ::c_long = 182; ++pub const SYS_afs_syscall: ::c_long = 183; ++pub const SYS_tuxcall: ::c_long = 184; ++pub const SYS_security: ::c_long = 185; ++pub const SYS_gettid: ::c_long = 186; ++pub const SYS_readahead: ::c_long = 187; ++pub const SYS_setxattr: ::c_long = 188; ++pub const SYS_lsetxattr: ::c_long = 189; ++pub const SYS_fsetxattr: ::c_long = 190; ++pub const SYS_getxattr: ::c_long = 191; ++pub const SYS_lgetxattr: ::c_long = 192; ++pub const SYS_fgetxattr: ::c_long = 193; ++pub const SYS_listxattr: ::c_long = 194; ++pub const SYS_llistxattr: ::c_long = 195; ++pub const SYS_flistxattr: ::c_long = 196; ++pub const SYS_removexattr: ::c_long = 197; ++pub const SYS_lremovexattr: ::c_long = 198; ++pub const SYS_fremovexattr: ::c_long = 199; ++pub const SYS_tkill: ::c_long = 200; ++pub const SYS_time: ::c_long = 201; ++pub const SYS_futex: ::c_long = 202; ++pub const SYS_sched_setaffinity: ::c_long = 203; ++pub const SYS_sched_getaffinity: ::c_long = 204; ++pub const SYS_set_thread_area: ::c_long = 205; ++pub const SYS_io_setup: ::c_long = 206; ++pub const SYS_io_destroy: ::c_long = 207; ++pub const SYS_io_getevents: ::c_long = 208; ++pub const SYS_io_submit: ::c_long = 209; ++pub const SYS_io_cancel: ::c_long = 210; ++pub const SYS_get_thread_area: ::c_long = 211; ++pub const SYS_lookup_dcookie: ::c_long = 212; ++pub const SYS_epoll_create: ::c_long = 213; ++pub const SYS_epoll_ctl_old: ::c_long = 214; ++pub const SYS_epoll_wait_old: ::c_long = 215; ++pub const SYS_remap_file_pages: ::c_long = 216; ++pub const SYS_getdents64: ::c_long = 217; ++pub const SYS_set_tid_address: ::c_long = 218; ++pub const SYS_restart_syscall: ::c_long = 219; ++pub const SYS_semtimedop: ::c_long = 220; ++pub const SYS_fadvise64: ::c_long = 221; ++pub const SYS_timer_create: ::c_long = 222; ++pub const SYS_timer_settime: ::c_long = 223; ++pub const SYS_timer_gettime: ::c_long = 224; ++pub const SYS_timer_getoverrun: ::c_long = 225; ++pub const SYS_timer_delete: ::c_long = 226; ++pub const SYS_clock_settime: ::c_long = 227; ++pub const SYS_clock_gettime: ::c_long = 228; ++pub const SYS_clock_getres: ::c_long = 229; ++pub const SYS_clock_nanosleep: ::c_long = 230; ++pub const SYS_exit_group: ::c_long = 231; ++pub const SYS_epoll_wait: ::c_long = 232; ++pub const SYS_epoll_ctl: ::c_long = 233; ++pub const SYS_tgkill: ::c_long = 234; ++pub const SYS_utimes: ::c_long = 235; ++pub const SYS_vserver: ::c_long = 236; ++pub const SYS_mbind: ::c_long = 237; ++pub const SYS_set_mempolicy: ::c_long = 238; ++pub const SYS_get_mempolicy: ::c_long = 239; ++pub const SYS_mq_open: ::c_long = 240; ++pub const SYS_mq_unlink: ::c_long = 241; ++pub const SYS_mq_timedsend: ::c_long = 242; ++pub const SYS_mq_timedreceive: ::c_long = 243; ++pub const SYS_mq_notify: ::c_long = 244; ++pub const SYS_mq_getsetattr: ::c_long = 245; ++pub const SYS_kexec_load: ::c_long = 246; ++pub const SYS_waitid: ::c_long = 247; ++pub const SYS_add_key: ::c_long = 248; ++pub const SYS_request_key: ::c_long = 249; ++pub const SYS_keyctl: ::c_long = 250; ++pub const SYS_ioprio_set: ::c_long = 251; ++pub const SYS_ioprio_get: ::c_long = 252; ++pub const SYS_inotify_init: ::c_long = 253; ++pub const SYS_inotify_add_watch: ::c_long = 254; ++pub const SYS_inotify_rm_watch: ::c_long = 255; ++pub const SYS_migrate_pages: ::c_long = 256; ++pub const SYS_openat: ::c_long = 257; ++pub const SYS_mkdirat: ::c_long = 258; ++pub const SYS_mknodat: ::c_long = 259; ++pub const SYS_fchownat: ::c_long = 260; ++pub const SYS_futimesat: ::c_long = 261; ++pub const SYS_newfstatat: ::c_long = 262; ++pub const SYS_unlinkat: ::c_long = 263; ++pub const SYS_renameat: ::c_long = 264; ++pub const SYS_linkat: ::c_long = 265; ++pub const SYS_symlinkat: ::c_long = 266; ++pub const SYS_readlinkat: ::c_long = 267; ++pub const SYS_fchmodat: ::c_long = 268; ++pub const SYS_faccessat: ::c_long = 269; ++pub const SYS_pselect6: ::c_long = 270; ++pub const SYS_ppoll: ::c_long = 271; ++pub const SYS_unshare: ::c_long = 272; ++pub const SYS_set_robust_list: ::c_long = 273; ++pub const SYS_get_robust_list: ::c_long = 274; ++pub const SYS_splice: ::c_long = 275; ++pub const SYS_tee: ::c_long = 276; ++pub const SYS_sync_file_range: ::c_long = 277; ++pub const SYS_vmsplice: ::c_long = 278; ++pub const SYS_move_pages: ::c_long = 279; ++pub const SYS_utimensat: ::c_long = 280; ++pub const SYS_epoll_pwait: ::c_long = 281; ++pub const SYS_signalfd: ::c_long = 282; ++pub const SYS_timerfd_create: ::c_long = 283; ++pub const SYS_eventfd: ::c_long = 284; ++pub const SYS_fallocate: ::c_long = 285; ++pub const SYS_timerfd_settime: ::c_long = 286; ++pub const SYS_timerfd_gettime: ::c_long = 287; ++pub const SYS_accept4: ::c_long = 288; ++pub const SYS_signalfd4: ::c_long = 289; ++pub const SYS_eventfd2: ::c_long = 290; ++pub const SYS_epoll_create1: ::c_long = 291; ++pub const SYS_dup3: ::c_long = 292; ++pub const SYS_pipe2: ::c_long = 293; ++pub const SYS_inotify_init1: ::c_long = 294; ++pub const SYS_preadv: ::c_long = 295; ++pub const SYS_pwritev: ::c_long = 296; ++pub const SYS_rt_tgsigqueueinfo: ::c_long = 297; ++pub const SYS_perf_event_open: ::c_long = 298; ++pub const SYS_recvmmsg: ::c_long = 299; ++pub const SYS_fanotify_init: ::c_long = 300; ++pub const SYS_fanotify_mark: ::c_long = 301; ++pub const SYS_prlimit64: ::c_long = 302; ++pub const SYS_name_to_handle_at: ::c_long = 303; ++pub const SYS_open_by_handle_at: ::c_long = 304; ++pub const SYS_clock_adjtime: ::c_long = 305; ++pub const SYS_syncfs: ::c_long = 306; ++pub const SYS_sendmmsg: ::c_long = 307; ++pub const SYS_setns: ::c_long = 308; ++pub const SYS_getcpu: ::c_long = 309; ++pub const SYS_process_vm_readv: ::c_long = 310; ++pub const SYS_process_vm_writev: ::c_long = 311; ++pub const SYS_kcmp: ::c_long = 312; ++pub const SYS_finit_module: ::c_long = 313; ++pub const SYS_sched_setattr: ::c_long = 314; ++pub const SYS_sched_getattr: ::c_long = 315; ++pub const SYS_renameat2: ::c_long = 316; ++pub const SYS_seccomp: ::c_long = 317; ++pub const SYS_getrandom: ::c_long = 318; ++pub const SYS_memfd_create: ::c_long = 319; ++pub const SYS_kexec_file_load: ::c_long = 320; ++pub const SYS_bpf: ::c_long = 321; ++pub const SYS_execveat: ::c_long = 322; ++pub const SYS_userfaultfd: ::c_long = 323; ++pub const SYS_membarrier: ::c_long = 324; ++pub const SYS_mlock2: ::c_long = 325; ++pub const SYS_copy_file_range: ::c_long = 326; ++pub const SYS_preadv2: ::c_long = 327; ++pub const SYS_pwritev2: ::c_long = 328; ++pub const SYS_pkey_mprotect: ::c_long = 329; ++pub const SYS_pkey_alloc: ::c_long = 330; ++pub const SYS_pkey_free: ::c_long = 331; ++ ++// offsets in user_regs_structs, from sys/reg.h ++pub const R15: ::c_int = 0; ++pub const R14: ::c_int = 1; ++pub const R13: ::c_int = 2; ++pub const R12: ::c_int = 3; ++pub const RBP: ::c_int = 4; ++pub const RBX: ::c_int = 5; ++pub const R11: ::c_int = 6; ++pub const R10: ::c_int = 7; ++pub const R9: ::c_int = 8; ++pub const R8: ::c_int = 9; ++pub const RAX: ::c_int = 10; ++pub const RCX: ::c_int = 11; ++pub const RDX: ::c_int = 12; ++pub const RSI: ::c_int = 13; ++pub const RDI: ::c_int = 14; ++pub const ORIG_RAX: ::c_int = 15; ++pub const RIP: ::c_int = 16; ++pub const CS: ::c_int = 17; ++pub const EFLAGS: ::c_int = 18; ++pub const RSP: ::c_int = 19; ++pub const SS: ::c_int = 20; ++pub const FS_BASE: ::c_int = 21; ++pub const GS_BASE: ::c_int = 22; ++pub const DS: ::c_int = 23; ++pub const ES: ::c_int = 24; ++pub const FS: ::c_int = 25; ++pub const GS: ::c_int = 26; ++ ++extern { ++ pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; ++ pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; ++ pub fn makecontext(ucp: *mut ucontext_t, ++ func: extern fn (), ++ argc: ::c_int, ...); ++ pub fn swapcontext(uocp: *mut ucontext_t, ++ ucp: *const ucontext_t) -> ::c_int; ++ pub fn iopl(level: ::c_int) -> ::c_int; ++ pub fn ioperm(from: ::c_ulong, num: ::c_ulong, ++ turn_on: ::c_int) -> ::c_int; ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/other/mod.rs index 000000000,000000000..7363ca61c new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/other/mod.rs @@@ -1,0 -1,0 +1,598 @@@ ++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 aiocb { ++ pub aio_fildes: ::c_int, ++ pub aio_lio_opcode: ::c_int, ++ pub aio_reqprio: ::c_int, ++ pub aio_buf: *mut ::c_void, ++ pub aio_nbytes: ::size_t, ++ pub aio_sigevent: ::sigevent, ++ __next_prio: *mut aiocb, ++ __abs_prio: ::c_int, ++ __policy: ::c_int, ++ __error_code: ::c_int, ++ __return_value: ::ssize_t, ++ pub aio_offset: off_t, ++ #[cfg(target_pointer_width = "32")] ++ __unused1: [::c_char; 4], ++ __glibc_reserved: [::c_char; 32] ++ } ++ ++ pub struct __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_arch = "sparc64", ++ target_pointer_width = "32"))] ++ pub ut_session: ::c_long, ++ #[cfg(any(target_arch = "aarch64", ++ target_arch = "sparc64", ++ target_pointer_width = "32"))] ++ pub ut_tv: ::timeval, ++ ++ #[cfg(not(any(target_arch = "aarch64", ++ target_arch = "sparc64", ++ target_pointer_width = "32")))] ++ pub ut_session: ::int32_t, ++ #[cfg(not(any(target_arch = "aarch64", ++ target_arch = "sparc64", ++ 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, ++ #[cfg(target_arch = "sparc64")] ++ __reserved0: ::c_int, ++ pub sa_flags: ::c_int, ++ pub sa_restorer: ::dox::Option, ++ } ++ ++ 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 cmsghdr { ++ pub cmsg_len: ::size_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct termios { ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_line: ::cc_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ #[cfg(not(target_arch = "sparc64"))] ++ pub c_ispeed: ::speed_t, ++ #[cfg(not(target_arch = "sparc64"))] ++ pub c_ospeed: ::speed_t, ++ } ++ ++ pub struct flock { ++ pub l_type: ::c_short, ++ pub l_whence: ::c_short, ++ pub l_start: ::off_t, ++ pub l_len: ::off_t, ++ pub l_pid: ::pid_t, ++ } ++ ++ // 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_AS: ::c_int = 9; ++pub const RLIMIT_MEMLOCK: ::c_int = 8; ++pub const RLIM_INFINITY: ::rlim_t = !0; ++pub const RLIMIT_RTTIME: ::c_int = 15; ++pub const RLIMIT_NLIMITS: ::c_int = 16; ++ ++pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; ++ ++pub const SOL_RXRPC: ::c_int = 272; ++pub const SOL_PPPOL2TP: ::c_int = 273; ++pub const SOL_BLUETOOTH: ::c_int = 274; ++pub const SOL_PNPIPE: ::c_int = 275; ++pub const SOL_RDS: ::c_int = 276; ++pub const SOL_IUCV: ::c_int = 277; ++pub const SOL_CAIF: ::c_int = 278; ++pub const SOL_ALG: ::c_int = 279; ++pub const SOL_NFC: ::c_int = 280; ++ ++pub const MSG_TRYHARD: ::c_int = 4; ++ ++pub const LC_PAPER: ::c_int = 7; ++pub const LC_NAME: ::c_int = 8; ++pub const LC_ADDRESS: ::c_int = 9; ++pub const LC_TELEPHONE: ::c_int = 10; ++pub const LC_MEASUREMENT: ::c_int = 11; ++pub const LC_IDENTIFICATION: ::c_int = 12; ++pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER); ++pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME); ++pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS); ++pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE); ++pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT); ++pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION); ++pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK ++ | ::LC_NUMERIC_MASK ++ | ::LC_TIME_MASK ++ | ::LC_COLLATE_MASK ++ | ::LC_MONETARY_MASK ++ | ::LC_MESSAGES_MASK ++ | LC_PAPER_MASK ++ | LC_NAME_MASK ++ | LC_ADDRESS_MASK ++ | LC_TELEPHONE_MASK ++ | LC_MEASUREMENT_MASK ++ | LC_IDENTIFICATION_MASK; ++ ++pub const MAP_ANON: ::c_int = 0x0020; ++pub const MAP_ANONYMOUS: ::c_int = 0x0020; ++pub const MAP_DENYWRITE: ::c_int = 0x0800; ++pub const MAP_EXECUTABLE: ::c_int = 0x01000; ++pub const MAP_POPULATE: ::c_int = 0x08000; ++pub const MAP_NONBLOCK: ::c_int = 0x010000; ++pub const MAP_STACK: ::c_int = 0x020000; ++ ++pub const ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EUCLEAN: ::c_int = 117; ++pub const ENOTNAM: ::c_int = 118; ++pub const ENAVAIL: ::c_int = 119; ++pub const EISNAM: ::c_int = 120; ++pub const EREMOTEIO: ::c_int = 121; ++ ++pub const SOCK_STREAM: ::c_int = 1; ++pub const SOCK_DGRAM: ::c_int = 2; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++ ++pub const 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 SIGTTIN: ::c_int = 21; ++pub const SIGTTOU: ::c_int = 22; ++pub const SIGXCPU: ::c_int = 24; ++pub const SIGXFSZ: ::c_int = 25; ++pub const SIGVTALRM: ::c_int = 26; ++pub const SIGPROF: ::c_int = 27; ++pub const SIGWINCH: ::c_int = 28; ++ ++pub const SIGEV_THREAD_ID: ::c_int = 4; ++ ++pub const BUFSIZ: ::c_uint = 8192; ++pub const TMP_MAX: ::c_uint = 238328; ++pub const FOPEN_MAX: ::c_uint = 16; ++pub const POSIX_FADV_DONTNEED: ::c_int = 4; ++pub const POSIX_FADV_NOREUSE: ::c_int = 5; ++pub const POSIX_MADV_DONTNEED: ::c_int = 4; ++pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41; ++pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45; ++pub const _SC_PII: ::c_int = 53; ++pub const _SC_PII_XTI: ::c_int = 54; ++pub const _SC_PII_SOCKET: ::c_int = 55; ++pub const _SC_PII_INTERNET: ::c_int = 56; ++pub const _SC_PII_OSI: ::c_int = 57; ++pub const _SC_POLL: ::c_int = 58; ++pub const _SC_SELECT: ::c_int = 59; ++pub const _SC_PII_INTERNET_STREAM: ::c_int = 61; ++pub const _SC_PII_INTERNET_DGRAM: ::c_int = 62; ++pub const _SC_PII_OSI_COTS: ::c_int = 63; ++pub const _SC_PII_OSI_CLTS: ::c_int = 64; ++pub const _SC_PII_OSI_M: ::c_int = 65; ++pub const _SC_T_IOV_MAX: ::c_int = 66; ++pub const _SC_2_C_VERSION: ::c_int = 96; ++pub const _SC_CHAR_BIT: ::c_int = 101; ++pub const _SC_CHAR_MAX: ::c_int = 102; ++pub const _SC_CHAR_MIN: ::c_int = 103; ++pub const _SC_INT_MAX: ::c_int = 104; ++pub const _SC_INT_MIN: ::c_int = 105; ++pub const _SC_LONG_BIT: ::c_int = 106; ++pub const _SC_WORD_BIT: ::c_int = 107; ++pub const _SC_MB_LEN_MAX: ::c_int = 108; ++pub const _SC_SSIZE_MAX: ::c_int = 110; ++pub const _SC_SCHAR_MAX: ::c_int = 111; ++pub const _SC_SCHAR_MIN: ::c_int = 112; ++pub const _SC_SHRT_MAX: ::c_int = 113; ++pub const _SC_SHRT_MIN: ::c_int = 114; ++pub const _SC_UCHAR_MAX: ::c_int = 115; ++pub const _SC_UINT_MAX: ::c_int = 116; ++pub const _SC_ULONG_MAX: ::c_int = 117; ++pub const _SC_USHRT_MAX: ::c_int = 118; ++pub const _SC_NL_ARGMAX: ::c_int = 119; ++pub const _SC_NL_LANGMAX: ::c_int = 120; ++pub const _SC_NL_MSGMAX: ::c_int = 121; ++pub const _SC_NL_NMAX: ::c_int = 122; ++pub const _SC_NL_SETMAX: ::c_int = 123; ++pub const _SC_NL_TEXTMAX: ::c_int = 124; ++pub const _SC_BASE: ::c_int = 134; ++pub const _SC_C_LANG_SUPPORT: ::c_int = 135; ++pub const _SC_C_LANG_SUPPORT_R: ::c_int = 136; ++pub const _SC_DEVICE_IO: ::c_int = 140; ++pub const _SC_DEVICE_SPECIFIC: ::c_int = 141; ++pub const _SC_DEVICE_SPECIFIC_R: ::c_int = 142; ++pub const _SC_FD_MGMT: ::c_int = 143; ++pub const _SC_FIFO: ::c_int = 144; ++pub const _SC_PIPE: ::c_int = 145; ++pub const _SC_FILE_ATTRIBUTES: ::c_int = 146; ++pub const _SC_FILE_LOCKING: ::c_int = 147; ++pub const _SC_FILE_SYSTEM: ::c_int = 148; ++pub const _SC_MULTI_PROCESS: ::c_int = 150; ++pub const _SC_SINGLE_PROCESS: ::c_int = 151; ++pub const _SC_NETWORKING: ::c_int = 152; ++pub const _SC_REGEX_VERSION: ::c_int = 156; ++pub const _SC_SIGNALS: ::c_int = 158; ++pub const _SC_SYSTEM_DATABASE: ::c_int = 162; ++pub const _SC_SYSTEM_DATABASE_R: ::c_int = 163; ++pub const _SC_USER_GROUPS: ::c_int = 166; ++pub const _SC_USER_GROUPS_R: ::c_int = 167; ++pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 185; ++pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 186; ++pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 187; ++pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 188; ++pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 189; ++pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 190; ++pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 191; ++pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 192; ++pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 193; ++pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 194; ++pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 195; ++pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 196; ++pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 197; ++pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 198; ++pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 199; ++pub const O_ACCMODE: ::c_int = 3; ++pub const ST_RELATIME: ::c_ulong = 4096; ++pub const NI_MAXHOST: ::socklen_t = 1025; ++ ++pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; ++pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; ++pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; ++pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; ++pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; ++pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; ++pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; ++pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; ++pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; ++pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; ++pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; ++pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; ++pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; ++pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; ++pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; ++pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; ++pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; ++pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; ++pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; ++pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; ++pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; ++pub const TMPFS_MAGIC: ::c_long = 0x01021994; ++pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; ++ ++pub const VEOF: usize = 4; ++ ++pub const CPU_SETSIZE: ::c_int = 0x400; ++ ++pub const PTRACE_TRACEME: ::c_uint = 0; ++pub const PTRACE_PEEKTEXT: ::c_uint = 1; ++pub const PTRACE_PEEKDATA: ::c_uint = 2; ++pub const PTRACE_PEEKUSER: ::c_uint = 3; ++pub const PTRACE_POKETEXT: ::c_uint = 4; ++pub const PTRACE_POKEDATA: ::c_uint = 5; ++pub const PTRACE_POKEUSER: ::c_uint = 6; ++pub const PTRACE_CONT: ::c_uint = 7; ++pub const PTRACE_KILL: ::c_uint = 8; ++pub const PTRACE_SINGLESTEP: ::c_uint = 9; ++pub const PTRACE_ATTACH: ::c_uint = 16; ++pub const PTRACE_SYSCALL: ::c_uint = 24; ++pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; ++pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; ++pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; ++pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; ++pub const PTRACE_GETREGSET: ::c_uint = 0x4204; ++pub const PTRACE_SETREGSET: ::c_uint = 0x4205; ++pub const PTRACE_SEIZE: ::c_uint = 0x4206; ++pub const PTRACE_INTERRUPT: ::c_uint = 0x4207; ++pub const PTRACE_LISTEN: ::c_uint = 0x4208; ++pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209; ++ ++pub const EPOLLWAKEUP: ::c_int = 0x20000000; ++ ++pub const MAP_HUGETLB: ::c_int = 0x040000; ++ ++pub const SEEK_DATA: ::c_int = 3; ++pub const SEEK_HOLE: ::c_int = 4; ++ ++pub const TCSANOW: ::c_int = 0; ++pub const TCSADRAIN: ::c_int = 1; ++pub const TCSAFLUSH: ::c_int = 2; ++ ++pub const TIOCLINUX: ::c_ulong = 0x541C; ++pub const TIOCGSERIAL: ::c_ulong = 0x541E; ++ ++pub const RTLD_DEEPBIND: ::c_int = 0x8; ++pub const RTLD_GLOBAL: ::c_int = 0x100; ++pub const RTLD_NOLOAD: ::c_int = 0x4; ++ ++pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; ++pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793; ++pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278; ++pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448; ++pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216; ++ ++pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567; ++pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123; ++pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF; ++pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000; ++pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC; ++pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4; ++pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2; ++pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543; ++ ++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); ++ ++pub const TIOCM_LE: ::c_int = 0x001; ++pub const TIOCM_DTR: ::c_int = 0x002; ++pub const TIOCM_RTS: ::c_int = 0x004; ++pub const TIOCM_ST: ::c_int = 0x008; ++pub const TIOCM_SR: ::c_int = 0x010; ++pub const TIOCM_CTS: ::c_int = 0x020; ++pub const TIOCM_CAR: ::c_int = 0x040; ++pub const TIOCM_RNG: ::c_int = 0x080; ++pub const TIOCM_DSR: ::c_int = 0x100; ++pub const TIOCM_CD: ::c_int = TIOCM_CAR; ++pub const TIOCM_RI: ::c_int = TIOCM_RNG; ++ ++cfg_if! { ++ if #[cfg(any(target_arch = "arm", target_arch = "x86", ++ target_arch = "x86_64"))] { ++ pub const PTHREAD_STACK_MIN: ::size_t = 16384; ++ } else if #[cfg(target_arch = "sparc64")] { ++ pub const PTHREAD_STACK_MIN: ::size_t = 0x6000; ++ } else { ++ pub const PTHREAD_STACK_MIN: ::size_t = 131072; ++ } ++} ++ ++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(); ++ pub fn getpt() -> ::c_int; ++} ++ ++#[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 ::c_int>, ++ pglob: *mut glob64_t) -> ::c_int; ++ pub fn globfree64(pglob: *mut glob64_t); ++ pub fn ptrace(request: ::c_uint, ...) -> ::c_long; ++ pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t, ++ cpusetsize: ::size_t, ++ cpuset: *mut ::cpu_set_t) -> ::c_int; ++ pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t, ++ cpusetsize: ::size_t, ++ cpuset: *const ::cpu_set_t) -> ::c_int; ++ pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int; ++ pub fn setpriority(which: ::__priority_which_t, who: ::id_t, ++ prio: ::c_int) -> ::c_int; ++ pub fn pthread_getaffinity_np(thread: ::pthread_t, ++ cpusetsize: ::size_t, ++ cpuset: *mut ::cpu_set_t) -> ::c_int; ++ pub fn pthread_setaffinity_np(thread: ::pthread_t, ++ cpusetsize: ::size_t, ++ cpuset: *const ::cpu_set_t) -> ::c_int; ++ pub fn pthread_rwlockattr_getkind_np(attr: *const ::pthread_rwlockattr_t, ++ val: *mut ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_setkind_np(attr: *mut ::pthread_rwlockattr_t, ++ val: ::c_int) -> ::c_int; ++ pub fn sched_getcpu() -> ::c_int; ++} ++ ++cfg_if! { ++ if #[cfg(any(target_arch = "x86", ++ target_arch = "arm", ++ target_arch = "powerpc"))] { ++ mod b32; ++ pub use self::b32::*; ++ } else if #[cfg(any(target_arch = "x86_64", ++ target_arch = "aarch64", ++ target_arch = "powerpc64", ++ target_arch = "sparc64"))] { ++ mod b64; ++ pub use self::b64::*; ++ } else { ++ // Unknown target_arch ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/notbsd/linux/s390x.rs index 000000000,000000000..fa550730d new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/linux/s390x.rs @@@ -1,0 -1,0 +1,955 @@@ ++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; ++pub type __u64 = u64; ++ ++s! { ++ pub struct aiocb { ++ pub aio_fildes: ::c_int, ++ pub aio_lio_opcode: ::c_int, ++ pub aio_reqprio: ::c_int, ++ pub aio_buf: *mut ::c_void, ++ pub aio_nbytes: ::size_t, ++ pub aio_sigevent: ::sigevent, ++ __next_prio: *mut aiocb, ++ __abs_prio: ::c_int, ++ __policy: ::c_int, ++ __error_code: ::c_int, ++ __return_value: ::ssize_t, ++ pub aio_offset: off_t, ++ #[cfg(target_pointer_width = "32")] ++ __unused1: [::c_char; 4], ++ __glibc_reserved: [::c_char; 32] ++ } ++ ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino_t, ++ pub st_nlink: ::nlink_t, ++ pub st_mode: ::mode_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ st_pad0: ::c_int, ++ pub st_rdev: ::dev_t, ++ pub st_size: ::off_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt_t, ++ __glibc_reserved: [::c_long; 3], ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::dev_t, ++ pub st_ino: ::ino64_t, ++ pub st_nlink: ::nlink_t, ++ pub st_mode: ::mode_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ st_pad0: ::c_int, ++ pub st_rdev: ::dev_t, ++ pub st_size: ::off_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt64_t, ++ __glibc_reserved: [::c_long; 3], ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [::c_ulong; 7] ++ } ++ ++ pub struct sigaction { ++ pub sa_sigaction: ::sighandler_t, ++ __glibc_reserved0: ::c_int, ++ pub sa_flags: ::c_int, ++ pub sa_restorer: ::dox::Option, ++ 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 cmsghdr { ++ pub cmsg_len: ::size_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct termios { ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_line: ::cc_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ pub c_ispeed: ::speed_t, ++ pub c_ospeed: ::speed_t, ++ } ++ ++ pub struct 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 struct statfs64 { ++ pub f_type: ::c_uint, ++ pub f_bsize: ::c_uint, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: ::c_uint, ++ pub f_frsize: ::c_uint, ++ pub f_flags: ::c_uint, ++ pub f_spare: [::c_uint; 4], ++ } ++ ++ pub struct statvfs64 { ++ pub f_bsize: ::c_ulong, ++ pub f_frsize: ::c_ulong, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++ pub f_files: u64, ++ pub f_ffree: u64, ++ pub f_favail: u64, ++ pub f_fsid: ::c_ulong, ++ pub f_flag: ::c_ulong, ++ pub f_namemax: ::c_ulong, ++ __f_spare: [::c_int; 6], ++ } ++} ++ ++pub const SFD_CLOEXEC: ::c_int = 0x080000; ++ ++pub const NCCS: usize = 32; ++ ++pub const O_TRUNC: ::c_int = 512; ++pub const O_LARGEFILE: ::c_int = 0o0100000; ++pub const O_NOATIME: ::c_int = 0o1000000; ++pub const O_CLOEXEC: ::c_int = 0x80000; ++pub const O_PATH: ::c_int = 0o10000000; ++ ++pub const EBFONT: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const EDOTDOT: ::c_int = 73; ++ ++pub const SA_NODEFER: ::c_int = 0x40000000; ++pub const SA_RESETHAND: ::c_int = 0x80000000; ++pub const SA_RESTART: ::c_int = 0x10000000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000001; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x80000; ++ ++pub const POSIX_FADV_DONTNEED: ::c_int = 6; ++pub const POSIX_FADV_NOREUSE: ::c_int = 7; ++ ++pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; ++pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; ++pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; ++ ++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 MINSIGSTKSZ: ::size_t = 2048; ++pub const SIG_SETMASK: ::c_int = 2; ++pub const SOCK_DGRAM: ::c_int = 2; ++pub const SOCK_STREAM: ::c_int = 1; ++pub const SOL_SOCKET: ::c_int = 1; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SO_ERROR: ::c_int = 4; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_SNDTIMEO: ::c_int = 21; ++pub const SO_BINDTODEVICE: ::c_int = 25; ++pub const SO_TIMESTAMP: ::c_int = 29; ++pub const SO_MARK: ::c_int = 36; ++pub const SO_PROTOCOL: ::c_int = 38; ++pub const SO_DOMAIN: ::c_int = 39; ++pub const SO_RXQ_OVFL: ::c_int = 40; ++pub const SO_PEEK_OFF: ::c_int = 42; ++pub const SO_BUSY_POLL: ::c_int = 46; ++ ++pub const RLIMIT_RSS: ::c_int = 5; ++pub const RLIMIT_NOFILE: ::c_int = 7; ++pub const RLIMIT_AS: ::c_int = 9; ++pub const RLIMIT_NPROC: ::c_int = 6; ++pub const RLIMIT_MEMLOCK: ::c_int = 8; ++pub const RLIMIT_RTTIME: ::c_int = 15; ++pub const RLIMIT_NLIMITS: ::c_int = 16; ++ ++pub const O_NOCTTY: ::c_int = 256; ++pub const O_SYNC: ::c_int = 1052672; ++pub const O_RSYNC: ::c_int = 1052672; ++pub const O_DSYNC: ::c_int = 4096; ++pub const O_FSYNC: ::c_int = 0x101000; ++pub const O_DIRECT: ::c_int = 0x4000; ++pub const O_DIRECTORY: ::c_int = 0x10000; ++pub const O_NOFOLLOW: ::c_int = 0x20000; ++ ++pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; ++ ++pub const LC_PAPER: ::c_int = 7; ++pub const LC_NAME: ::c_int = 8; ++pub const LC_ADDRESS: ::c_int = 9; ++pub const LC_TELEPHONE: ::c_int = 10; ++pub const LC_MEASUREMENT: ::c_int = 11; ++pub const LC_IDENTIFICATION: ::c_int = 12; ++pub const LC_PAPER_MASK: ::c_int = (1 << LC_PAPER); ++pub const LC_NAME_MASK: ::c_int = (1 << LC_NAME); ++pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS); ++pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE); ++pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT); ++pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION); ++pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK ++ | ::LC_NUMERIC_MASK ++ | ::LC_TIME_MASK ++ | ::LC_COLLATE_MASK ++ | ::LC_MONETARY_MASK ++ | ::LC_MESSAGES_MASK ++ | LC_PAPER_MASK ++ | LC_NAME_MASK ++ | LC_ADDRESS_MASK ++ | LC_TELEPHONE_MASK ++ | LC_MEASUREMENT_MASK ++ | LC_IDENTIFICATION_MASK; ++ ++pub const MAP_ANONYMOUS: ::c_int = 0x0020; ++pub const MAP_GROWSDOWN: ::c_int = 0x0100; ++pub const MAP_DENYWRITE: ::c_int = 0x0800; ++pub const MAP_EXECUTABLE: ::c_int = 0x01000; ++pub const MAP_LOCKED: ::c_int = 0x02000; ++pub const MAP_NORESERVE: ::c_int = 0x04000; ++pub const MAP_POPULATE: ::c_int = 0x08000; ++pub const MAP_NONBLOCK: ::c_int = 0x010000; ++pub const MAP_STACK: ::c_int = 0x020000; ++ ++pub const EDEADLOCK: ::c_int = 35; ++pub const ENAMETOOLONG: ::c_int = 36; ++pub const ENOLCK: ::c_int = 37; ++pub const ENOTEMPTY: ::c_int = 39; ++pub const ELOOP: ::c_int = 40; ++pub const ENOMSG: ::c_int = 42; ++pub const EIDRM: ::c_int = 43; ++pub const ECHRNG: ::c_int = 44; ++pub const EL2NSYNC: ::c_int = 45; ++pub const EL3HLT: ::c_int = 46; ++pub const EL3RST: ::c_int = 47; ++pub const ELNRNG: ::c_int = 48; ++pub const EUNATCH: ::c_int = 49; ++pub const ENOCSI: ::c_int = 50; ++pub const EL2HLT: ::c_int = 51; ++pub const EBADE: ::c_int = 52; ++pub const EBADR: ::c_int = 53; ++pub const EXFULL: ::c_int = 54; ++pub const ENOANO: ::c_int = 55; ++pub const EBADRQC: ::c_int = 56; ++pub const EBADSLT: ::c_int = 57; ++pub const EMULTIHOP: ::c_int = 72; ++pub const EOVERFLOW: ::c_int = 75; ++pub const ENOTUNIQ: ::c_int = 76; ++pub const EBADFD: ::c_int = 77; ++pub const EBADMSG: ::c_int = 74; ++pub const EREMCHG: ::c_int = 78; ++pub const ELIBACC: ::c_int = 79; ++pub const ELIBBAD: ::c_int = 80; ++pub const ELIBSCN: ::c_int = 81; ++pub const ELIBMAX: ::c_int = 82; ++pub const ELIBEXEC: ::c_int = 83; ++pub const EILSEQ: ::c_int = 84; ++pub const ERESTART: ::c_int = 85; ++pub const ESTRPIPE: ::c_int = 86; ++pub const EUSERS: ::c_int = 87; ++pub const ENOTSOCK: ::c_int = 88; ++pub const EDESTADDRREQ: ::c_int = 89; ++pub const EMSGSIZE: ::c_int = 90; ++pub const EPROTOTYPE: ::c_int = 91; ++pub const ENOPROTOOPT: ::c_int = 92; ++pub const EPROTONOSUPPORT: ::c_int = 93; ++pub const ESOCKTNOSUPPORT: ::c_int = 94; ++pub const EOPNOTSUPP: ::c_int = 95; ++pub const ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EPFNOSUPPORT: ::c_int = 96; ++pub const EAFNOSUPPORT: ::c_int = 97; ++pub const ENETDOWN: ::c_int = 100; ++pub const ENETUNREACH: ::c_int = 101; ++pub const ENETRESET: ::c_int = 102; ++pub const ENOBUFS: ::c_int = 105; ++pub const EISCONN: ::c_int = 106; ++pub const ESHUTDOWN: ::c_int = 108; ++pub const ETOOMANYREFS: ::c_int = 109; ++pub const EHOSTDOWN: ::c_int = 112; ++pub const EHOSTUNREACH: ::c_int = 113; ++pub const EALREADY: ::c_int = 114; ++pub const EINPROGRESS: ::c_int = 115; ++pub const ESTALE: ::c_int = 116; ++pub const EUCLEAN: ::c_int = 117; ++pub const ENOTNAM: ::c_int = 118; ++pub const ENAVAIL: ::c_int = 119; ++pub const EISNAM: ::c_int = 120; ++pub const EREMOTEIO: ::c_int = 121; ++pub const EDQUOT: ::c_int = 122; ++pub const ENOMEDIUM: ::c_int = 123; ++pub const EMEDIUMTYPE: ::c_int = 124; ++pub const ECANCELED: ::c_int = 125; ++pub const ENOKEY: ::c_int = 126; ++pub const EKEYEXPIRED: ::c_int = 127; ++pub const EKEYREVOKED: ::c_int = 128; ++pub const EKEYREJECTED: ::c_int = 129; ++pub const EOWNERDEAD: ::c_int = 130; ++pub const ENOTRECOVERABLE: ::c_int = 131; ++pub const EHWPOISON: ::c_int = 133; ++pub const ERFKILL: ::c_int = 132; ++ ++pub const SOCK_SEQPACKET: ::c_int = 5; ++ ++pub const SO_TYPE: ::c_int = 3; ++pub const SO_DONTROUTE: ::c_int = 5; ++pub const SO_SNDBUF: ::c_int = 7; ++pub const SO_RCVBUF: ::c_int = 8; ++pub const SO_KEEPALIVE: ::c_int = 9; ++pub const SO_OOBINLINE: ::c_int = 10; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_LINGER: ::c_int = 13; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_REUSEPORT: ::c_int = 15; ++pub const SO_PASSCRED: ::c_int = 16; ++pub const SO_PEERCRED: ::c_int = 17; ++pub const SO_RCVLOWAT: ::c_int = 18; ++pub const SO_SNDLOWAT: ::c_int = 19; ++pub const SO_ACCEPTCONN: ::c_int = 30; ++pub const SO_SNDBUFFORCE: ::c_int = 32; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++ ++pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; ++pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; ++pub const TCP_THIN_DUPACK: ::c_int = 17; ++pub const TCP_USER_TIMEOUT: ::c_int = 18; ++pub const TCP_REPAIR: ::c_int = 19; ++pub const TCP_REPAIR_QUEUE: ::c_int = 20; ++pub const TCP_QUEUE_SEQ: ::c_int = 21; ++pub const TCP_REPAIR_OPTIONS: ::c_int = 22; ++pub const TCP_FASTOPEN: ::c_int = 23; ++pub const TCP_TIMESTAMP: ::c_int = 24; ++ ++pub const SIGCHLD: ::c_int = 17; ++pub const SIGUSR1: ::c_int = 10; ++pub const SIGUSR2: ::c_int = 12; ++pub const SIGCONT: ::c_int = 18; ++pub const SIGSTOP: ::c_int = 19; ++pub const SIGTSTP: ::c_int = 20; ++pub const SIGURG: ::c_int = 23; ++pub const SIGIO: ::c_int = 29; ++pub const SIGSYS: ::c_int = 31; ++pub const SIGSTKFLT: ::c_int = 16; ++pub const SIGUNUSED: ::c_int = 31; ++pub const SIGTTIN: ::c_int = 21; ++pub const SIGTTOU: ::c_int = 22; ++pub const SIGXCPU: ::c_int = 24; ++pub const SIGXFSZ: ::c_int = 25; ++pub const SIGVTALRM: ::c_int = 26; ++pub const SIGPROF: ::c_int = 27; ++pub const SIGWINCH: ::c_int = 28; ++pub const SIGPOLL: ::c_int = 29; ++pub const SIGPWR: ::c_int = 30; ++pub const SIG_BLOCK: ::c_int = 0x000000; ++pub const SIG_UNBLOCK: ::c_int = 0x01; ++ ++pub const BUFSIZ: ::c_uint = 8192; ++pub const TMP_MAX: ::c_uint = 238328; ++pub const FOPEN_MAX: ::c_uint = 16; ++pub const POSIX_MADV_DONTNEED: ::c_int = 4; ++pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41; ++pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45; ++pub const _SC_PII: ::c_int = 53; ++pub const _SC_PII_XTI: ::c_int = 54; ++pub const _SC_PII_SOCKET: ::c_int = 55; ++pub const _SC_PII_INTERNET: ::c_int = 56; ++pub const _SC_PII_OSI: ::c_int = 57; ++pub const _SC_POLL: ::c_int = 58; ++pub const _SC_SELECT: ::c_int = 59; ++pub const _SC_PII_INTERNET_STREAM: ::c_int = 61; ++pub const _SC_PII_INTERNET_DGRAM: ::c_int = 62; ++pub const _SC_PII_OSI_COTS: ::c_int = 63; ++pub const _SC_PII_OSI_CLTS: ::c_int = 64; ++pub const _SC_PII_OSI_M: ::c_int = 65; ++pub const _SC_T_IOV_MAX: ::c_int = 66; ++pub const _SC_2_C_VERSION: ::c_int = 96; ++pub const _SC_CHAR_BIT: ::c_int = 101; ++pub const _SC_CHAR_MAX: ::c_int = 102; ++pub const _SC_CHAR_MIN: ::c_int = 103; ++pub const _SC_INT_MAX: ::c_int = 104; ++pub const _SC_INT_MIN: ::c_int = 105; ++pub const _SC_LONG_BIT: ::c_int = 106; ++pub const _SC_WORD_BIT: ::c_int = 107; ++pub const _SC_MB_LEN_MAX: ::c_int = 108; ++pub const _SC_SSIZE_MAX: ::c_int = 110; ++pub const _SC_SCHAR_MAX: ::c_int = 111; ++pub const _SC_SCHAR_MIN: ::c_int = 112; ++pub const _SC_SHRT_MAX: ::c_int = 113; ++pub const _SC_SHRT_MIN: ::c_int = 114; ++pub const _SC_UCHAR_MAX: ::c_int = 115; ++pub const _SC_UINT_MAX: ::c_int = 116; ++pub const _SC_ULONG_MAX: ::c_int = 117; ++pub const _SC_USHRT_MAX: ::c_int = 118; ++pub const _SC_NL_ARGMAX: ::c_int = 119; ++pub const _SC_NL_LANGMAX: ::c_int = 120; ++pub const _SC_NL_MSGMAX: ::c_int = 121; ++pub const _SC_NL_NMAX: ::c_int = 122; ++pub const _SC_NL_SETMAX: ::c_int = 123; ++pub const _SC_NL_TEXTMAX: ::c_int = 124; ++pub const _SC_BASE: ::c_int = 134; ++pub const _SC_C_LANG_SUPPORT: ::c_int = 135; ++pub const _SC_C_LANG_SUPPORT_R: ::c_int = 136; ++pub const _SC_DEVICE_IO: ::c_int = 140; ++pub const _SC_DEVICE_SPECIFIC: ::c_int = 141; ++pub const _SC_DEVICE_SPECIFIC_R: ::c_int = 142; ++pub const _SC_FD_MGMT: ::c_int = 143; ++pub const _SC_FIFO: ::c_int = 144; ++pub const _SC_PIPE: ::c_int = 145; ++pub const _SC_FILE_ATTRIBUTES: ::c_int = 146; ++pub const _SC_FILE_LOCKING: ::c_int = 147; ++pub const _SC_FILE_SYSTEM: ::c_int = 148; ++pub const _SC_MULTI_PROCESS: ::c_int = 150; ++pub const _SC_SINGLE_PROCESS: ::c_int = 151; ++pub const _SC_NETWORKING: ::c_int = 152; ++pub const _SC_REGEX_VERSION: ::c_int = 156; ++pub const _SC_SIGNALS: ::c_int = 158; ++pub const _SC_SYSTEM_DATABASE: ::c_int = 162; ++pub const _SC_SYSTEM_DATABASE_R: ::c_int = 163; ++pub const _SC_USER_GROUPS: ::c_int = 166; ++pub const _SC_USER_GROUPS_R: ::c_int = 167; ++pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 185; ++pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 186; ++pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 187; ++pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 188; ++pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 189; ++pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 190; ++pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 191; ++pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 192; ++pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 193; ++pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 194; ++pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 195; ++pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 196; ++pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 197; ++pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 198; ++pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 199; ++pub const O_ASYNC: ::c_int = 0x2000; ++pub const O_NDELAY: ::c_int = 0x800; ++pub const ST_RELATIME: ::c_ulong = 4096; ++pub const NI_MAXHOST: ::socklen_t = 1025; ++ ++pub const ADFS_SUPER_MAGIC: ::c_int = 0x0000adf5; ++pub const AFFS_SUPER_MAGIC: ::c_int = 0x0000adff; ++pub const CODA_SUPER_MAGIC: ::c_int = 0x73757245; ++pub const CRAMFS_MAGIC: ::c_int = 0x28cd3d45; ++pub const EFS_SUPER_MAGIC: ::c_int = 0x00414a53; ++pub const EXT2_SUPER_MAGIC: ::c_int = 0x0000ef53; ++pub const EXT3_SUPER_MAGIC: ::c_int = 0x0000ef53; ++pub const EXT4_SUPER_MAGIC: ::c_int = 0x0000ef53; ++pub const HPFS_SUPER_MAGIC: ::c_int = 0xf995e849; ++pub const HUGETLBFS_MAGIC: ::c_int = 0x958458f6; ++pub const ISOFS_SUPER_MAGIC: ::c_int = 0x00009660; ++pub const JFFS2_SUPER_MAGIC: ::c_int = 0x000072b6; ++pub const MINIX_SUPER_MAGIC: ::c_int = 0x0000137f; ++pub const MINIX_SUPER_MAGIC2: ::c_int = 0x0000138f; ++pub const MINIX2_SUPER_MAGIC: ::c_int = 0x00002468; ++pub const MINIX2_SUPER_MAGIC2: ::c_int = 0x00002478; ++pub const MSDOS_SUPER_MAGIC: ::c_int = 0x00004d44; ++pub const NCP_SUPER_MAGIC: ::c_int = 0x0000564c; ++pub const NFS_SUPER_MAGIC: ::c_int = 0x00006969; ++pub const OPENPROM_SUPER_MAGIC: ::c_int = 0x00009fa1; ++pub const PROC_SUPER_MAGIC: ::c_int = 0x00009fa0; ++pub const QNX4_SUPER_MAGIC: ::c_int = 0x0000002f; ++pub const REISERFS_SUPER_MAGIC: ::c_int = 0x52654973; ++pub const SMB_SUPER_MAGIC: ::c_int = 0x0000517b; ++pub const TMPFS_MAGIC: ::c_int = 0x01021994; ++pub const USBDEVICE_SUPER_MAGIC: ::c_int = 0x00009fa2; ++ ++pub const VEOF: usize = 4; ++pub const VEOL: usize = 11; ++pub const VEOL2: usize = 16; ++pub const VMIN: usize = 6; ++pub const IEXTEN: ::tcflag_t = 0x00008000; ++pub const TOSTOP: ::tcflag_t = 0x00000100; ++pub const FLUSHO: ::tcflag_t = 0x00001000; ++ ++pub const CPU_SETSIZE: ::c_int = 0x400; ++ ++pub const EXTPROC: ::tcflag_t = 0x00010000; ++ ++pub const PTRACE_TRACEME: ::c_uint = 0; ++pub const PTRACE_PEEKTEXT: ::c_uint = 1; ++pub const PTRACE_PEEKDATA: ::c_uint = 2; ++pub const PTRACE_PEEKUSER: ::c_uint = 3; ++pub const PTRACE_POKETEXT: ::c_uint = 4; ++pub const PTRACE_POKEDATA: ::c_uint = 5; ++pub const PTRACE_POKEUSER: ::c_uint = 6; ++pub const PTRACE_CONT: ::c_uint = 7; ++pub const PTRACE_KILL: ::c_uint = 8; ++pub const PTRACE_SINGLESTEP: ::c_uint = 9; ++pub const PTRACE_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 EPOLLWAKEUP: ::c_int = 0x20000000; ++ ++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_pivot_root: ::c_long = 217; ++pub const SYS_gettid: ::c_long = 236; ++pub const SYS_perf_event_open: ::c_long = 331; ++pub const SYS_memfd_create: ::c_long = 350; ++ ++pub const VTIME: usize = 5; ++pub const VSWTC: usize = 7; ++pub const VSTART: usize = 8; ++pub const VSTOP: usize = 9; ++pub const VSUSP: usize = 10; ++pub const VREPRINT: usize = 12; ++pub const VDISCARD: usize = 13; ++pub const VWERASE: usize = 14; ++pub const OLCUC: ::tcflag_t = 0o000002; ++pub const ONLCR: ::tcflag_t = 0o000004; ++pub const NLDLY: ::tcflag_t = 0o000400; ++pub const CRDLY: ::tcflag_t = 0o003000; ++pub const CR1: ::tcflag_t = 0x00000200; ++pub const CR2: ::tcflag_t = 0x00000400; ++pub const CR3: ::tcflag_t = 0x00000600; ++pub const TABDLY: ::tcflag_t = 0o014000; ++pub const TAB1: ::tcflag_t = 0x00000800; ++pub const TAB2: ::tcflag_t = 0x00001000; ++pub const TAB3: ::tcflag_t = 0x00001800; ++pub const BSDLY: ::tcflag_t = 0o020000; ++pub const BS1: ::tcflag_t = 0x00002000; ++pub const FFDLY: ::tcflag_t = 0o100000; ++pub const FF1: ::tcflag_t = 0x00008000; ++pub const VTDLY: ::tcflag_t = 0o040000; ++pub const VT1: ::tcflag_t = 0x00004000; ++pub const XTABS: ::tcflag_t = 0o014000; ++ ++pub const TIOCM_LE: ::c_int = 0x001; ++pub const TIOCM_DTR: ::c_int = 0x002; ++pub const TIOCM_RTS: ::c_int = 0x004; ++pub const TIOCM_ST: ::c_int = 0x008; ++pub const TIOCM_SR: ::c_int = 0x010; ++pub const TIOCM_CTS: ::c_int = 0x020; ++pub const TIOCM_CAR: ::c_int = 0x040; ++pub const TIOCM_RNG: ::c_int = 0x080; ++pub const TIOCM_DSR: ::c_int = 0x100; ++pub const TIOCM_CD: ::c_int = TIOCM_CAR; ++pub const TIOCM_RI: ::c_int = TIOCM_RNG; ++ ++pub const SIGEV_THREAD_ID: ::c_int = 4; ++ ++pub const CBAUD: ::speed_t = 0o010017; ++pub const B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const CSIZE: ::tcflag_t = 0o000060; ++pub const CS6: ::tcflag_t = 0o000020; ++pub const CS7: ::tcflag_t = 0o000040; ++pub const CS8: ::tcflag_t = 0o000060; ++pub const CSTOPB: ::tcflag_t = 0o000100; ++pub const CREAD: ::tcflag_t = 0o000200; ++pub const PARENB: ::tcflag_t = 0o000400; ++pub const PARODD: ::tcflag_t = 0o001000; ++pub const HUPCL: ::tcflag_t = 0o002000; ++pub const CLOCAL: ::tcflag_t = 0o004000; ++pub const CBAUDEX: ::tcflag_t = 0o010000; ++pub const B57600: ::speed_t = 0o010001; ++pub const B115200: ::speed_t = 0o010002; ++pub const B230400: ::speed_t = 0o010003; ++pub const B460800: ::speed_t = 0o010004; ++pub const B500000: ::speed_t = 0o010005; ++pub const B576000: ::speed_t = 0o010006; ++pub const B921600: ::speed_t = 0o010007; ++pub const B1000000: ::speed_t = 0o010010; ++pub const B1152000: ::speed_t = 0o010011; ++pub const B1500000: ::speed_t = 0o010012; ++pub const B2000000: ::speed_t = 0o010013; ++pub const B2500000: ::speed_t = 0o010014; ++pub const B3000000: ::speed_t = 0o010015; ++pub const B3500000: ::speed_t = 0o010016; ++pub const B4000000: ::speed_t = 0o010017; ++pub const CIBAUD: ::tcflag_t = 0o02003600000; ++ ++pub const ISIG: ::tcflag_t = 0o000001; ++pub const ICANON: ::tcflag_t = 0o000002; ++pub const XCASE: ::tcflag_t = 0o000004; ++pub const ECHOE: ::tcflag_t = 0o000020; ++pub const ECHOK: ::tcflag_t = 0o000040; ++pub const ECHONL: ::tcflag_t = 0o000100; ++pub const NOFLSH: ::tcflag_t = 0o000200; ++pub const ECHOCTL: ::tcflag_t = 0o001000; ++pub const ECHOPRT: ::tcflag_t = 0o002000; ++pub const ECHOKE: ::tcflag_t = 0o004000; ++pub const PENDIN: ::tcflag_t = 0o040000; ++ ++pub const POLLWRNORM: ::c_short = 0x004; ++pub const POLLWRBAND: ::c_short = 0x100; ++ ++pub const IXON: ::tcflag_t = 0o002000; ++pub const IXOFF: ::tcflag_t = 0o010000; ++ ++#[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 ::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 --cc vendor/libc-0.2.31/src/unix/notbsd/mod.rs index 000000000,000000000..859312e0a new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/notbsd/mod.rs @@@ -1,0 -1,0 +1,997 @@@ ++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 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", ++ target_os = "fuchsia"))] ++ 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", target_os = "emscripten"))] ++ pub sched_ss_low_priority: ::c_int, ++ #[cfg(any(target_env = "musl", target_os = "emscripten"))] ++ pub sched_ss_repl_period: ::timespec, ++ #[cfg(any(target_env = "musl", target_os = "emscripten"))] ++ pub sched_ss_init_budget: ::timespec, ++ #[cfg(any(target_env = "musl", target_os = "emscripten"))] ++ pub sched_ss_max_repl: ::c_int, ++ } ++ ++ pub struct Dl_info { ++ pub dli_fname: *const ::c_char, ++ pub dli_fbase: *mut ::c_void, ++ pub dli_sname: *const ::c_char, ++ pub dli_saddr: *mut ::c_void, ++ } ++ ++ #[cfg_attr(any(all(target_arch = "x86", ++ not(target_env = "musl"), ++ not(target_os = "android")), ++ target_arch = "x86_64"), ++ repr(packed))] ++ pub struct epoll_event { ++ pub events: ::uint32_t, ++ pub u64: ::uint64_t, ++ } ++ ++ 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, ++ } ++ ++ pub struct sigevent { ++ pub sigev_value: ::sigval, ++ pub sigev_signo: ::c_int, ++ pub sigev_notify: ::c_int, ++ // Actually a union. We only expose sigev_notify_thread_id because it's ++ // the most useful member ++ pub sigev_notify_thread_id: ::c_int, ++ #[cfg(target_pointer_width = "64")] ++ __unused1: [::c_int; 11], ++ #[cfg(target_pointer_width = "32")] ++ __unused1: [::c_int; 12] ++ } ++} ++ ++// intentionally not public, only used for fd_set ++cfg_if! { ++ if #[cfg(target_pointer_width = "32")] { ++ const ULONG_SIZE: usize = 32; ++ } else if #[cfg(target_pointer_width = "64")] { ++ const ULONG_SIZE: usize = 64; ++ } else { ++ // Unknown target_pointer_width ++ } ++} ++ ++pub const EXIT_FAILURE: ::c_int = 1; ++pub const EXIT_SUCCESS: ::c_int = 0; ++pub const RAND_MAX: ::c_int = 2147483647; ++pub const EOF: ::c_int = -1; ++pub const SEEK_SET: ::c_int = 0; ++pub const SEEK_CUR: ::c_int = 1; ++pub const SEEK_END: ::c_int = 2; ++pub const _IOFBF: ::c_int = 0; ++pub const _IONBF: ::c_int = 2; ++pub const _IOLBF: ::c_int = 1; ++ ++pub const F_DUPFD: ::c_int = 0; ++pub const F_GETFD: ::c_int = 1; ++pub const F_SETFD: ::c_int = 2; ++pub const F_GETFL: ::c_int = 3; ++pub const F_SETFL: ::c_int = 4; ++ ++// Linux-specific fcntls ++pub const F_SETLEASE: ::c_int = 1024; ++pub const F_GETLEASE: ::c_int = 1025; ++pub const F_NOTIFY: ::c_int = 1026; ++pub const F_CANCELLK: ::c_int = 1029; ++pub const F_DUPFD_CLOEXEC: ::c_int = 1030; ++pub const F_SETPIPE_SZ: ::c_int = 1031; ++pub const F_GETPIPE_SZ: ::c_int = 1032; ++pub const F_ADD_SEALS: ::c_int = 1033; ++pub const F_GET_SEALS: ::c_int = 1034; ++ ++pub const F_SEAL_SEAL: ::c_int = 0x0001; ++pub const F_SEAL_SHRINK: ::c_int = 0x0002; ++pub const F_SEAL_GROW: ::c_int = 0x0004; ++pub const F_SEAL_WRITE: ::c_int = 0x0008; ++ ++// TODO(#235): Include file sealing fcntls once we have a way to verify them. ++ ++pub const SIGTRAP: ::c_int = 5; ++ ++pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; ++pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; ++ ++pub const CLOCK_REALTIME: ::clockid_t = 0; ++pub const CLOCK_MONOTONIC: ::clockid_t = 1; ++pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2; ++pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3; ++pub const CLOCK_MONOTONIC_RAW: ::clockid_t = 4; ++pub const CLOCK_REALTIME_COARSE: ::clockid_t = 5; ++pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = 6; ++pub const CLOCK_BOOTTIME: ::clockid_t = 7; ++pub const CLOCK_REALTIME_ALARM: ::clockid_t = 8; ++pub const CLOCK_BOOTTIME_ALARM: ::clockid_t = 9; ++// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep ++// 2014.) See also musl/mod.rs ++// pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; ++// pub const CLOCK_TAI: ::clockid_t = 11; ++pub const TIMER_ABSTIME: ::c_int = 1; ++ ++pub const RLIMIT_CPU: ::c_int = 0; ++pub const RLIMIT_FSIZE: ::c_int = 1; ++pub const RLIMIT_DATA: ::c_int = 2; ++pub const RLIMIT_STACK: ::c_int = 3; ++pub const RLIMIT_CORE: ::c_int = 4; ++pub const RLIMIT_LOCKS: ::c_int = 10; ++pub const RLIMIT_SIGPENDING: ::c_int = 11; ++pub const RLIMIT_MSGQUEUE: ::c_int = 12; ++pub const RLIMIT_NICE: ::c_int = 13; ++pub const RLIMIT_RTPRIO: ::c_int = 14; ++ ++pub const RUSAGE_SELF: ::c_int = 0; ++ ++pub const O_RDONLY: ::c_int = 0; ++pub const O_WRONLY: ::c_int = 1; ++pub const O_RDWR: ::c_int = 2; ++ ++pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; ++ ++pub const S_IFIFO: ::mode_t = 4096; ++pub const S_IFCHR: ::mode_t = 8192; ++pub const S_IFBLK: ::mode_t = 24576; ++pub const S_IFDIR: ::mode_t = 16384; ++pub const S_IFREG: ::mode_t = 32768; ++pub const S_IFLNK: ::mode_t = 40960; ++pub const S_IFSOCK: ::mode_t = 49152; ++pub const S_IFMT: ::mode_t = 61440; ++pub const S_IRWXU: ::mode_t = 448; ++pub const S_IXUSR: ::mode_t = 64; ++pub const S_IWUSR: ::mode_t = 128; ++pub const S_IRUSR: ::mode_t = 256; ++pub const S_IRWXG: ::mode_t = 56; ++pub const S_IXGRP: ::mode_t = 8; ++pub const S_IWGRP: ::mode_t = 16; ++pub const S_IRGRP: ::mode_t = 32; ++pub const S_IRWXO: ::mode_t = 7; ++pub const S_IXOTH: ::mode_t = 1; ++pub const S_IWOTH: ::mode_t = 2; ++pub const S_IROTH: ::mode_t = 4; ++pub const F_OK: ::c_int = 0; ++pub const R_OK: ::c_int = 4; ++pub const W_OK: ::c_int = 2; ++pub const X_OK: ::c_int = 1; ++pub const STDIN_FILENO: ::c_int = 0; ++pub const STDOUT_FILENO: ::c_int = 1; ++pub const STDERR_FILENO: ::c_int = 2; ++pub const SIGHUP: ::c_int = 1; ++pub const SIGINT: ::c_int = 2; ++pub const SIGQUIT: ::c_int = 3; ++pub const SIGILL: ::c_int = 4; ++pub const SIGABRT: ::c_int = 6; ++pub const SIGFPE: ::c_int = 8; ++pub const SIGKILL: ::c_int = 9; ++pub const SIGSEGV: ::c_int = 11; ++pub const SIGPIPE: ::c_int = 13; ++pub const SIGALRM: ::c_int = 14; ++pub const SIGTERM: ::c_int = 15; ++ ++pub const PROT_NONE: ::c_int = 0; ++pub const PROT_READ: ::c_int = 1; ++pub const PROT_WRITE: ::c_int = 2; ++pub const PROT_EXEC: ::c_int = 4; ++ ++pub const LC_CTYPE: ::c_int = 0; ++pub const LC_NUMERIC: ::c_int = 1; ++pub const LC_TIME: ::c_int = 2; ++pub const LC_COLLATE: ::c_int = 3; ++pub const LC_MONETARY: ::c_int = 4; ++pub const LC_MESSAGES: ::c_int = 5; ++pub const LC_ALL: ::c_int = 6; ++pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE); ++pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC); ++pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME); ++pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE); ++pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY); ++pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES); ++// LC_ALL_MASK defined per platform ++ ++pub const MAP_FILE: ::c_int = 0x0000; ++pub const MAP_SHARED: ::c_int = 0x0001; ++pub const MAP_PRIVATE: ::c_int = 0x0002; ++pub const MAP_FIXED: ::c_int = 0x0010; ++ ++pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; ++ ++// MS_ flags for msync(2) ++pub const MS_ASYNC: ::c_int = 0x0001; ++pub const MS_INVALIDATE: ::c_int = 0x0002; ++pub const MS_SYNC: ::c_int = 0x0004; ++ ++// MS_ flags for mount(2) ++pub const MS_RDONLY: ::c_ulong = 0x01; ++pub const MS_NOSUID: ::c_ulong = 0x02; ++pub const MS_NODEV: ::c_ulong = 0x04; ++pub const MS_NOEXEC: ::c_ulong = 0x08; ++pub const MS_SYNCHRONOUS: ::c_ulong = 0x10; ++pub const MS_REMOUNT: ::c_ulong = 0x20; ++pub const MS_MANDLOCK: ::c_ulong = 0x40; ++pub const MS_DIRSYNC: ::c_ulong = 0x80; ++pub const MS_NOATIME: ::c_ulong = 0x0400; ++pub const MS_NODIRATIME: ::c_ulong = 0x0800; ++pub const MS_BIND: ::c_ulong = 0x1000; ++pub const MS_MOVE: ::c_ulong = 0x2000; ++pub const MS_REC: ::c_ulong = 0x4000; ++pub const MS_SILENT: ::c_ulong = 0x8000; ++pub const MS_POSIXACL: ::c_ulong = 0x010000; ++pub const MS_UNBINDABLE: ::c_ulong = 0x020000; ++pub const MS_PRIVATE: ::c_ulong = 0x040000; ++pub const MS_SLAVE: ::c_ulong = 0x080000; ++pub const MS_SHARED: ::c_ulong = 0x100000; ++pub const MS_RELATIME: ::c_ulong = 0x200000; ++pub const MS_KERNMOUNT: ::c_ulong = 0x400000; ++pub const MS_I_VERSION: ::c_ulong = 0x800000; ++pub const MS_STRICTATIME: ::c_ulong = 0x1000000; ++pub const MS_ACTIVE: ::c_ulong = 0x40000000; ++pub const MS_NOUSER: ::c_ulong = 0x80000000; ++pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000; ++pub const MS_MGC_MSK: ::c_ulong = 0xffff0000; ++pub const MS_RMT_MASK: ::c_ulong = 0x800051; ++ ++pub const EPERM: ::c_int = 1; ++pub const ENOENT: ::c_int = 2; ++pub const ESRCH: ::c_int = 3; ++pub const EINTR: ::c_int = 4; ++pub const EIO: ::c_int = 5; ++pub const ENXIO: ::c_int = 6; ++pub const E2BIG: ::c_int = 7; ++pub const ENOEXEC: ::c_int = 8; ++pub const EBADF: ::c_int = 9; ++pub const ECHILD: ::c_int = 10; ++pub const EAGAIN: ::c_int = 11; ++pub const ENOMEM: ::c_int = 12; ++pub const EACCES: ::c_int = 13; ++pub const EFAULT: ::c_int = 14; ++pub const ENOTBLK: ::c_int = 15; ++pub const EBUSY: ::c_int = 16; ++pub const EEXIST: ::c_int = 17; ++pub const EXDEV: ::c_int = 18; ++pub const ENODEV: ::c_int = 19; ++pub const ENOTDIR: ::c_int = 20; ++pub const EISDIR: ::c_int = 21; ++pub const EINVAL: ::c_int = 22; ++pub const ENFILE: ::c_int = 23; ++pub const EMFILE: ::c_int = 24; ++pub const ENOTTY: ::c_int = 25; ++pub const ETXTBSY: ::c_int = 26; ++pub const EFBIG: ::c_int = 27; ++pub const ENOSPC: ::c_int = 28; ++pub const ESPIPE: ::c_int = 29; ++pub const EROFS: ::c_int = 30; ++pub const EMLINK: ::c_int = 31; ++pub const EPIPE: ::c_int = 32; ++pub const EDOM: ::c_int = 33; ++pub const ERANGE: ::c_int = 34; ++pub const EWOULDBLOCK: ::c_int = EAGAIN; ++ ++pub const SCM_RIGHTS: ::c_int = 0x01; ++pub const SCM_CREDENTIALS: ::c_int = 0x02; ++ ++pub const PROT_GROWSDOWN: ::c_int = 0x1000000; ++pub const PROT_GROWSUP: ::c_int = 0x2000000; ++ ++pub const MAP_TYPE: ::c_int = 0x000f; ++ ++pub const MADV_NORMAL: ::c_int = 0; ++pub const MADV_RANDOM: ::c_int = 1; ++pub const MADV_SEQUENTIAL: ::c_int = 2; ++pub const MADV_WILLNEED: ::c_int = 3; ++pub const MADV_DONTNEED: ::c_int = 4; ++pub const MADV_FREE: ::c_int = 8; ++pub const MADV_REMOVE: ::c_int = 9; ++pub const MADV_DONTFORK: ::c_int = 10; ++pub const MADV_DOFORK: ::c_int = 11; ++pub const MADV_MERGEABLE: ::c_int = 12; ++pub const MADV_UNMERGEABLE: ::c_int = 13; ++pub const MADV_HUGEPAGE: ::c_int = 14; ++pub const MADV_NOHUGEPAGE: ::c_int = 15; ++pub const MADV_DONTDUMP: ::c_int = 16; ++pub const MADV_DODUMP: ::c_int = 17; ++pub const MADV_HWPOISON: ::c_int = 100; ++pub const MADV_SOFT_OFFLINE: ::c_int = 101; ++ ++pub const IFF_UP: ::c_int = 0x1; ++pub const IFF_BROADCAST: ::c_int = 0x2; ++pub const IFF_DEBUG: ::c_int = 0x4; ++pub const IFF_LOOPBACK: ::c_int = 0x8; ++pub const IFF_POINTOPOINT: ::c_int = 0x10; ++pub const IFF_NOTRAILERS: ::c_int = 0x20; ++pub const IFF_RUNNING: ::c_int = 0x40; ++pub const IFF_NOARP: ::c_int = 0x80; ++pub const IFF_PROMISC: ::c_int = 0x100; ++pub const IFF_ALLMULTI: ::c_int = 0x200; ++pub const IFF_MASTER: ::c_int = 0x400; ++pub const IFF_SLAVE: ::c_int = 0x800; ++pub const IFF_MULTICAST: ::c_int = 0x1000; ++pub const IFF_PORTSEL: ::c_int = 0x2000; ++pub const IFF_AUTOMEDIA: ::c_int = 0x4000; ++pub const IFF_DYNAMIC: ::c_int = 0x8000; ++ ++pub const SOL_IP: ::c_int = 0; ++pub const SOL_TCP: ::c_int = 6; ++pub const SOL_UDP: ::c_int = 17; ++pub const SOL_IPV6: ::c_int = 41; ++pub const SOL_ICMPV6: ::c_int = 58; ++pub const SOL_RAW: ::c_int = 255; ++pub const SOL_DECNET: ::c_int = 261; ++pub const SOL_X25: ::c_int = 262; ++pub const SOL_PACKET: ::c_int = 263; ++pub const SOL_ATM: ::c_int = 264; ++pub const SOL_AAL: ::c_int = 265; ++pub const SOL_IRDA: ::c_int = 266; ++pub const SOL_NETBEUI: ::c_int = 267; ++pub const SOL_LLC: ::c_int = 268; ++pub const SOL_DCCP: ::c_int = 269; ++pub const SOL_NETLINK: ::c_int = 270; ++pub const SOL_TIPC: ::c_int = 271; ++ ++pub const AF_UNSPEC: ::c_int = 0; ++pub const AF_UNIX: ::c_int = 1; ++pub const AF_LOCAL: ::c_int = 1; ++pub const AF_INET: ::c_int = 2; ++pub const AF_AX25: ::c_int = 3; ++pub const AF_IPX: ::c_int = 4; ++pub const AF_APPLETALK: ::c_int = 5; ++pub const AF_NETROM: ::c_int = 6; ++pub const AF_BRIDGE: ::c_int = 7; ++pub const AF_ATMPVC: ::c_int = 8; ++pub const AF_X25: ::c_int = 9; ++pub const AF_INET6: ::c_int = 10; ++pub const AF_ROSE: ::c_int = 11; ++pub const AF_DECnet: ::c_int = 12; ++pub const AF_NETBEUI: ::c_int = 13; ++pub const AF_SECURITY: ::c_int = 14; ++pub const AF_KEY: ::c_int = 15; ++pub const AF_NETLINK: ::c_int = 16; ++pub const AF_ROUTE: ::c_int = AF_NETLINK; ++pub const AF_PACKET: ::c_int = 17; ++pub const AF_ASH: ::c_int = 18; ++pub const AF_ECONET: ::c_int = 19; ++pub const AF_ATMSVC: ::c_int = 20; ++pub const AF_RDS: ::c_int = 21; ++pub const AF_SNA: ::c_int = 22; ++pub const AF_IRDA: ::c_int = 23; ++pub const AF_PPPOX: ::c_int = 24; ++pub const AF_WANPIPE: ::c_int = 25; ++pub const AF_LLC: ::c_int = 26; ++pub const AF_CAN: ::c_int = 29; ++pub const AF_TIPC: ::c_int = 30; ++pub const AF_BLUETOOTH: ::c_int = 31; ++pub const AF_IUCV: ::c_int = 32; ++pub const AF_RXRPC: ::c_int = 33; ++pub const AF_ISDN: ::c_int = 34; ++pub const AF_PHONET: ::c_int = 35; ++pub const AF_IEEE802154: ::c_int = 36; ++pub const AF_CAIF: ::c_int = 37; ++pub const AF_ALG: ::c_int = 38; ++ ++pub const PF_UNSPEC: ::c_int = AF_UNSPEC; ++pub const PF_UNIX: ::c_int = AF_UNIX; ++pub const PF_LOCAL: ::c_int = AF_LOCAL; ++pub const PF_INET: ::c_int = AF_INET; ++pub const PF_AX25: ::c_int = AF_AX25; ++pub const PF_IPX: ::c_int = AF_IPX; ++pub const PF_APPLETALK: ::c_int = AF_APPLETALK; ++pub const PF_NETROM: ::c_int = AF_NETROM; ++pub const PF_BRIDGE: ::c_int = AF_BRIDGE; ++pub const PF_ATMPVC: ::c_int = AF_ATMPVC; ++pub const PF_X25: ::c_int = AF_X25; ++pub const PF_INET6: ::c_int = AF_INET6; ++pub const PF_ROSE: ::c_int = AF_ROSE; ++pub const PF_DECnet: ::c_int = AF_DECnet; ++pub const PF_NETBEUI: ::c_int = AF_NETBEUI; ++pub const PF_SECURITY: ::c_int = AF_SECURITY; ++pub const PF_KEY: ::c_int = AF_KEY; ++pub const PF_NETLINK: ::c_int = AF_NETLINK; ++pub const PF_ROUTE: ::c_int = AF_ROUTE; ++pub const PF_PACKET: ::c_int = AF_PACKET; ++pub const PF_ASH: ::c_int = AF_ASH; ++pub const PF_ECONET: ::c_int = AF_ECONET; ++pub const PF_ATMSVC: ::c_int = AF_ATMSVC; ++pub const PF_RDS: ::c_int = AF_RDS; ++pub const PF_SNA: ::c_int = AF_SNA; ++pub const PF_IRDA: ::c_int = AF_IRDA; ++pub const PF_PPPOX: ::c_int = AF_PPPOX; ++pub const PF_WANPIPE: ::c_int = AF_WANPIPE; ++pub const PF_LLC: ::c_int = AF_LLC; ++pub const PF_CAN: ::c_int = AF_CAN; ++pub const PF_TIPC: ::c_int = AF_TIPC; ++pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; ++pub const PF_IUCV: ::c_int = AF_IUCV; ++pub const PF_RXRPC: ::c_int = AF_RXRPC; ++pub const PF_ISDN: ::c_int = AF_ISDN; ++pub const PF_PHONET: ::c_int = AF_PHONET; ++pub const PF_IEEE802154: ::c_int = AF_IEEE802154; ++pub const PF_CAIF: ::c_int = AF_CAIF; ++pub const PF_ALG: ::c_int = AF_ALG; ++ ++pub const SOMAXCONN: ::c_int = 128; ++ ++pub const MSG_OOB: ::c_int = 1; ++pub const MSG_PEEK: ::c_int = 2; ++pub const MSG_DONTROUTE: ::c_int = 4; ++pub const MSG_CTRUNC: ::c_int = 8; ++pub const MSG_TRUNC: ::c_int = 0x20; ++pub const MSG_DONTWAIT: ::c_int = 0x40; ++pub const MSG_EOR: ::c_int = 0x80; ++pub const MSG_WAITALL: ::c_int = 0x100; ++pub const MSG_FIN: ::c_int = 0x200; ++pub const MSG_SYN: ::c_int = 0x400; ++pub const MSG_CONFIRM: ::c_int = 0x800; ++pub const MSG_RST: ::c_int = 0x1000; ++pub const MSG_ERRQUEUE: ::c_int = 0x2000; ++pub const MSG_NOSIGNAL: ::c_int = 0x4000; ++pub const MSG_MORE: ::c_int = 0x8000; ++pub const MSG_WAITFORONE: ::c_int = 0x10000; ++pub const MSG_FASTOPEN: ::c_int = 0x20000000; ++pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000; ++ ++pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; ++ ++pub const SOCK_RAW: ::c_int = 3; ++pub const SOCK_RDM: ::c_int = 4; ++pub const IP_MULTICAST_IF: ::c_int = 32; ++pub const IP_MULTICAST_TTL: ::c_int = 33; ++pub const IP_MULTICAST_LOOP: ::c_int = 34; ++pub const IP_TTL: ::c_int = 2; ++pub const IP_HDRINCL: ::c_int = 3; ++pub const IP_ADD_MEMBERSHIP: ::c_int = 35; ++pub const IP_DROP_MEMBERSHIP: ::c_int = 36; ++pub const IP_TRANSPARENT: ::c_int = 19; ++pub const IPV6_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 SHUT_RD: ::c_int = 0; ++pub const SHUT_WR: ::c_int = 1; ++pub const SHUT_RDWR: ::c_int = 2; ++ ++pub const LOCK_SH: ::c_int = 1; ++pub const LOCK_EX: ::c_int = 2; ++pub const LOCK_NB: ::c_int = 4; ++pub const LOCK_UN: ::c_int = 8; ++ ++pub const SS_ONSTACK: ::c_int = 1; ++pub const SS_DISABLE: ::c_int = 2; ++ ++pub const PATH_MAX: ::c_int = 4096; ++ ++pub const FD_SETSIZE: usize = 1024; ++ ++pub const EPOLLIN: ::c_int = 0x1; ++pub const EPOLLPRI: ::c_int = 0x2; ++pub const EPOLLOUT: ::c_int = 0x4; ++pub const EPOLLRDNORM: ::c_int = 0x40; ++pub const EPOLLRDBAND: ::c_int = 0x80; ++pub const EPOLLWRNORM: ::c_int = 0x100; ++pub const EPOLLWRBAND: ::c_int = 0x200; ++pub const EPOLLMSG: ::c_int = 0x400; ++pub const EPOLLERR: ::c_int = 0x8; ++pub const EPOLLHUP: ::c_int = 0x10; ++pub const EPOLLET: ::c_int = 0x80000000; ++ ++pub const EPOLL_CTL_ADD: ::c_int = 1; ++pub const EPOLL_CTL_MOD: ::c_int = 3; ++pub const EPOLL_CTL_DEL: ::c_int = 2; ++ ++pub const MNT_DETACH: ::c_int = 0x2; ++pub const MNT_EXPIRE: ::c_int = 0x4; ++ ++pub const Q_GETFMT: ::c_int = 0x800004; ++pub const Q_GETINFO: ::c_int = 0x800005; ++pub const Q_SETINFO: ::c_int = 0x800006; ++pub const QIF_BLIMITS: ::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 MNT_FORCE: ::c_int = 0x1; ++ ++pub const Q_SYNC: ::c_int = 0x800001; ++pub const Q_QUOTAON: ::c_int = 0x800002; ++pub const Q_QUOTAOFF: ::c_int = 0x800003; ++pub const Q_GETQUOTA: ::c_int = 0x800007; ++pub const Q_SETQUOTA: ::c_int = 0x800008; ++ ++pub const TCIOFF: ::c_int = 2; ++pub const TCION: ::c_int = 3; ++pub const TCOOFF: ::c_int = 0; ++pub const TCOON: ::c_int = 1; ++pub const TCIFLUSH: ::c_int = 0; ++pub const TCOFLUSH: ::c_int = 1; ++pub const TCIOFLUSH: ::c_int = 2; ++pub const NL0: ::c_int = 0x00000000; ++pub const NL1: ::c_int = 0x00000100; ++pub const TAB0: ::c_int = 0x00000000; ++pub const CR0: ::c_int = 0x00000000; ++pub const FF0: ::c_int = 0x00000000; ++pub const BS0: ::c_int = 0x00000000; ++pub const VT0: ::c_int = 0x00000000; ++pub const VERASE: usize = 2; ++pub const VKILL: usize = 3; ++pub const VINTR: usize = 0; ++pub const VQUIT: usize = 1; ++pub const VLNEXT: usize = 15; ++pub const IGNBRK: ::tcflag_t = 0x00000001; ++pub const BRKINT: ::tcflag_t = 0x00000002; ++pub const IGNPAR: ::tcflag_t = 0x00000004; ++pub const PARMRK: ::tcflag_t = 0x00000008; ++pub const INPCK: ::tcflag_t = 0x00000010; ++pub const ISTRIP: ::tcflag_t = 0x00000020; ++pub const INLCR: ::tcflag_t = 0x00000040; ++pub const IGNCR: ::tcflag_t = 0x00000080; ++pub const ICRNL: ::tcflag_t = 0x00000100; ++pub const IXANY: ::tcflag_t = 0x00000800; ++pub const IMAXBEL: ::tcflag_t = 0x00002000; ++pub const OPOST: ::tcflag_t = 0x1; ++pub const CS5: ::tcflag_t = 0x00000000; ++pub const CRTSCTS: ::tcflag_t = 0x80000000; ++pub const ECHO: ::tcflag_t = 0x00000008; ++pub const OCRNL: ::tcflag_t = 0o000010; ++pub const ONOCR: ::tcflag_t = 0o000020; ++pub const ONLRET: ::tcflag_t = 0o000040; ++pub const OFILL: ::tcflag_t = 0o000100; ++pub const OFDEL: ::tcflag_t = 0o000200; ++ ++pub const CLONE_VM: ::c_int = 0x100; ++pub const CLONE_FS: ::c_int = 0x200; ++pub const CLONE_FILES: ::c_int = 0x400; ++pub const CLONE_SIGHAND: ::c_int = 0x800; ++pub const CLONE_PTRACE: ::c_int = 0x2000; ++pub const CLONE_VFORK: ::c_int = 0x4000; ++pub const CLONE_PARENT: ::c_int = 0x8000; ++pub const CLONE_THREAD: ::c_int = 0x10000; ++pub const CLONE_NEWNS: ::c_int = 0x20000; ++pub const CLONE_SYSVSEM: ::c_int = 0x40000; ++pub const CLONE_SETTLS: ::c_int = 0x80000; ++pub const CLONE_PARENT_SETTID: ::c_int = 0x100000; ++pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000; ++pub const CLONE_DETACHED: ::c_int = 0x400000; ++pub const CLONE_UNTRACED: ::c_int = 0x800000; ++pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000; ++pub const CLONE_NEWUTS: ::c_int = 0x04000000; ++pub const CLONE_NEWIPC: ::c_int = 0x08000000; ++pub const CLONE_NEWUSER: ::c_int = 0x10000000; ++pub const CLONE_NEWPID: ::c_int = 0x20000000; ++pub const CLONE_NEWNET: ::c_int = 0x40000000; ++pub const CLONE_IO: ::c_int = 0x80000000; ++pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; ++ ++pub const WNOHANG: ::c_int = 0x00000001; ++pub const WUNTRACED: ::c_int = 0x00000002; ++pub const WSTOPPED: ::c_int = WUNTRACED; ++pub const WEXITED: ::c_int = 0x00000004; ++pub const WCONTINUED: ::c_int = 0x00000008; ++pub const WNOWAIT: ::c_int = 0x01000000; ++ ++// Options set using PTRACE_SETOPTIONS. ++pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001; ++pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002; ++pub const PTRACE_O_TRACEVFORK: ::c_int = 0x00000004; ++pub const PTRACE_O_TRACECLONE: ::c_int = 0x00000008; ++pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010; ++pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020; ++pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040; ++pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080; ++pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000; ++pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000; ++pub const PTRACE_O_MASK: ::c_int = 0x003000ff; ++ ++// Wait extended result codes for the above trace options. ++pub const PTRACE_EVENT_FORK: ::c_int = 1; ++pub const PTRACE_EVENT_VFORK: ::c_int = 2; ++pub const PTRACE_EVENT_CLONE: ::c_int = 3; ++pub const PTRACE_EVENT_EXEC: ::c_int = 4; ++pub const PTRACE_EVENT_VFORK_DONE: ::c_int = 5; ++pub const PTRACE_EVENT_EXIT: ::c_int = 6; ++pub const PTRACE_EVENT_SECCOMP: ::c_int = 7; ++// PTRACE_EVENT_STOP was added to glibc in 2.26 ++// pub const PTRACE_EVENT_STOP: ::c_int = 128; ++ ++pub const __WNOTHREAD: ::c_int = 0x20000000; ++pub const __WALL: ::c_int = 0x40000000; ++pub const __WCLONE: ::c_int = 0x80000000; ++ ++pub const SPLICE_F_MOVE: ::c_uint = 0x01; ++pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02; ++pub const SPLICE_F_MORE: ::c_uint = 0x04; ++pub const SPLICE_F_GIFT: ::c_uint = 0x08; ++ ++pub const RTLD_LOCAL: ::c_int = 0; ++ ++pub const POSIX_FADV_NORMAL: ::c_int = 0; ++pub const POSIX_FADV_RANDOM: ::c_int = 1; ++pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; ++pub const POSIX_FADV_WILLNEED: ::c_int = 3; ++ ++pub const AT_FDCWD: ::c_int = -100; ++pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100; ++pub const AT_REMOVEDIR: ::c_int = 0x200; ++pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; ++pub const AT_NO_AUTOMOUNT: ::c_int = 0x800; ++pub const AT_EMPTY_PATH: ::c_int = 0x1000; ++ ++pub const LOG_CRON: ::c_int = 9 << 3; ++pub const LOG_AUTHPRIV: ::c_int = 10 << 3; ++pub const LOG_FTP: ::c_int = 11 << 3; ++pub const LOG_PERROR: ::c_int = 0x20; ++ ++pub const PIPE_BUF: usize = 4096; ++ ++pub const SI_LOAD_SHIFT: ::c_uint = 16; ++ ++pub const SIGEV_SIGNAL: ::c_int = 0; ++pub const SIGEV_NONE: ::c_int = 1; ++pub const SIGEV_THREAD: ::c_int = 2; ++ ++pub const P_ALL: idtype_t = 0; ++pub const P_PID: idtype_t = 1; ++pub const P_PGID: idtype_t = 2; ++ ++pub const UTIME_OMIT: c_long = 1073741822; ++pub const UTIME_NOW: c_long = 1073741823; ++ ++pub const POLLRDNORM: ::c_short = 0x040; ++pub const POLLRDBAND: ::c_short = 0x080; ++ ++f! { ++ pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { ++ let fd = fd as usize; ++ let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ (*set).fds_bits[fd / size] &= !(1 << (fd % size)); ++ return ++ } ++ ++ pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { ++ let fd = fd as usize; ++ let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 ++ } ++ ++ pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { ++ let fd = fd as usize; ++ let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ (*set).fds_bits[fd / size] |= 1 << (fd % size); ++ return ++ } ++ ++ pub fn FD_ZERO(set: *mut fd_set) -> () { ++ for slot in (*set).fds_bits.iter_mut() { ++ *slot = 0; ++ } ++ } ++ ++ pub fn WIFSTOPPED(status: ::c_int) -> bool { ++ (status & 0xff) == 0x7f ++ } ++ ++ pub fn WSTOPSIG(status: ::c_int) -> ::c_int { ++ (status >> 8) & 0xff ++ } ++ ++ pub fn WIFCONTINUED(status: ::c_int) -> bool { ++ status == 0xffff ++ } ++ ++ pub fn WIFSIGNALED(status: ::c_int) -> bool { ++ ((status & 0x7f) + 1) as i8 >= 2 ++ } ++ ++ pub fn WTERMSIG(status: ::c_int) -> ::c_int { ++ status & 0x7f ++ } ++ ++ pub fn WIFEXITED(status: ::c_int) -> bool { ++ (status & 0x7f) == 0 ++ } ++ ++ pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { ++ (status >> 8) & 0xff ++ } ++ ++ pub fn WCOREDUMP(status: ::c_int) -> bool { ++ (status & 0x80) != 0 ++ } ++ ++ pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { ++ (cmd << 8) | (type_ & 0x00ff) ++ } ++} ++ ++extern { ++ pub fn fdatasync(fd: ::c_int) -> ::c_int; ++ pub fn mincore(addr: *mut ::c_void, len: ::size_t, ++ vec: *mut ::c_uchar) -> ::c_int; ++ pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; ++ pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; ++ pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; ++ pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; ++ ++ pub fn pthread_getattr_np(native: ::pthread_t, ++ attr: *mut ::pthread_attr_t) -> ::c_int; ++ pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, ++ stackaddr: *mut *mut ::c_void, ++ stacksize: *mut ::size_t) -> ::c_int; ++ pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; ++ pub fn setgroups(ngroups: ::size_t, ++ ptr: *const ::gid_t) -> ::c_int; ++ pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; ++ pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; ++ pub fn statfs64(path: *const ::c_char, buf: *mut statfs64) -> ::c_int; ++ pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; ++ pub fn fstatfs64(fd: ::c_int, buf: *mut statfs64) -> ::c_int; ++ pub fn statvfs64(path: *const ::c_char, buf: *mut statvfs64) -> ::c_int; ++ pub fn fstatvfs64(fd: ::c_int, buf: *mut statvfs64) -> ::c_int; ++ pub fn memrchr(cx: *const ::c_void, ++ c: ::c_int, ++ n: ::size_t) -> *mut ::c_void; ++ ++ pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, ++ advise: ::c_int) -> ::c_int; ++ pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; ++ pub fn utimensat(dirfd: ::c_int, path: *const ::c_char, ++ times: *const ::timespec, flag: ::c_int) -> ::c_int; ++ pub fn duplocale(base: ::locale_t) -> ::locale_t; ++ pub fn freelocale(loc: ::locale_t); ++ pub fn newlocale(mask: ::c_int, ++ locale: *const ::c_char, ++ base: ::locale_t) -> ::locale_t; ++ pub fn uselocale(loc: ::locale_t) -> ::locale_t; ++ pub fn creat64(path: *const c_char, mode: mode_t) -> ::c_int; ++ pub fn fstat64(fildes: ::c_int, buf: *mut stat64) -> ::c_int; ++ pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int; ++ pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int; ++ pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t; ++ pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int; ++ pub fn mmap64(addr: *mut ::c_void, ++ len: ::size_t, ++ prot: ::c_int, ++ flags: ::c_int, ++ fd: ::c_int, ++ offset: off64_t) ++ -> *mut ::c_void; ++ pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; ++ pub fn openat64(fd: ::c_int, ++ path: *const c_char, ++ oflag: ::c_int, ...) -> ::c_int; ++ pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, ++ offset: off64_t) -> ::ssize_t; ++ pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t, ++ offset: off64_t) -> ::ssize_t; ++ pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64; ++ pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64, ++ result: *mut *mut ::dirent64) -> ::c_int; ++ pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; ++ pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; ++ pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; ++ ++ pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; ++ ++ pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t, dev: dev_t) -> ::c_int; ++ pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, ++ clock_id: *mut clockid_t) -> ::c_int; ++ pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, ++ clock_id: ::clockid_t) -> ::c_int; ++ pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, ++ pshared: ::c_int) -> ::c_int; ++ pub fn accept4(fd: ::c_int, addr: *mut ::sockaddr, len: *mut ::socklen_t, ++ flg: ::c_int) -> ::c_int; ++ pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, ++ pshared: ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t, ++ val: *mut ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, ++ val: ::c_int) -> ::c_int; ++ pub fn ptsname_r(fd: ::c_int, ++ buf: *mut ::c_char, ++ buflen: ::size_t) -> ::c_int; ++ pub fn clearenv() -> ::c_int; ++ pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, ++ options: ::c_int) -> ::c_int; ++ pub fn setreuid(ruid: ::uid_t, euid: ::uid_t) -> ::c_int; ++ pub fn setregid(rgid: ::gid_t, egid: ::gid_t) -> ::c_int; ++ pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, ++ suid: *mut ::uid_t) -> ::c_int; ++ pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, ++ sgid: *mut ::gid_t) -> ::c_int; ++ pub fn acct(filename: *const ::c_char) -> ::c_int; ++ pub fn brk(addr: *mut ::c_void) -> ::c_int; ++ pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void; ++ pub fn vfork() -> ::pid_t; ++ pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; ++ pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; ++ pub fn wait4(pid: ::pid_t, status: *mut ::c_int, options: ::c_int, ++ rusage: *mut ::rusage) -> ::pid_t; ++ pub fn openpty(amaster: *mut ::c_int, ++ aslave: *mut ::c_int, ++ name: *mut ::c_char, ++ termp: *const termios, ++ winp: *const ::winsize) -> ::c_int; ++ pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char, ++ envp: *const *const ::c_char) -> ::c_int; ++ pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, ++ envp: *const *const ::c_char) ++ -> ::c_int; ++} ++ ++cfg_if! { ++ if #[cfg(target_os = "emscripten")] { ++ mod emscripten; ++ pub use self::emscripten::*; ++ } else if #[cfg(any(target_os = "linux", target_os = "fuchsia"))] { ++ mod linux; ++ pub use self::linux::*; ++ } else if #[cfg(target_os = "android")] { ++ mod android; ++ pub use self::android::*; ++ } else { ++ // Unknown target_os ++ } ++} ++ // pub fn forkpty(amaster: *mut ::c_int, ++ // name: *mut ::c_char, ++ // termp: *const termios, ++ // winp: *const ::winsize) -> ::pid_t; diff --cc vendor/libc-0.2.31/src/unix/solaris/mod.rs index 000000000,000000000..5edf4178e new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/solaris/mod.rs @@@ -1,0 -1,0 +1,1345 @@@ ++use dox::{mem, Option}; ++ ++pub type c_char = i8; ++pub type c_long = i64; ++pub type c_ulong = u64; ++ ++pub type clockid_t = ::c_int; ++pub type blkcnt_t = ::c_long; ++pub type clock_t = ::c_long; ++pub type daddr_t = ::c_long; ++pub type dev_t = ::c_ulong; ++pub type fsblkcnt_t = ::c_ulong; ++pub type fsfilcnt_t = ::c_ulong; ++pub type ino_t = ::c_ulong; ++pub type key_t = ::c_int; ++pub type major_t = ::c_uint; ++pub type minor_t = ::c_uint; ++pub type mode_t = ::c_uint; ++pub type nlink_t = ::c_uint; ++pub type rlim_t = ::c_ulong; ++pub type speed_t = ::c_uint; ++pub type tcflag_t = ::c_uint; ++pub type time_t = ::c_long; ++pub type wchar_t = ::c_int; ++pub type nfds_t = ::c_ulong; ++ ++pub type suseconds_t = ::c_long; ++pub type off_t = ::c_long; ++pub type useconds_t = ::c_uint; ++pub type socklen_t = ::c_uint; ++pub type sa_family_t = u16; ++pub type pthread_t = ::c_uint; ++pub type pthread_key_t = ::c_uint; ++pub type blksize_t = ::c_int; ++pub type fflags_t = ::c_int; ++pub type nl_item = ::c_int; ++pub type id_t = ::c_int; ++pub type idtype_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: [::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 cmsghdr { ++ pub cmsg_len: ::size_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct fd_set { ++ #[cfg(target_pointer_width = "64")] ++ fds_bits: [i64; FD_SETSIZE / 64], ++ #[cfg(target_pointer_width = "32")] ++ fds_bits: [i32; FD_SETSIZE / 32], ++ } ++ ++ pub struct pthread_attr_t { ++ __pthread_attrp: *mut ::c_void ++ } ++ ++ pub struct pthread_mutex_t { ++ __pthread_mutex_flag1: u16, ++ __pthread_mutex_flag2: u8, ++ __pthread_mutex_ceiling: u8, ++ __pthread_mutex_type: u16, ++ __pthread_mutex_magic: u16, ++ __pthread_mutex_lock: u64, ++ __pthread_mutex_data: u64 ++ } ++ ++ pub struct pthread_mutexattr_t { ++ __pthread_mutexattrp: *mut ::c_void ++ } ++ ++ pub struct pthread_cond_t { ++ __pthread_cond_flag: [u8; 4], ++ __pthread_cond_type: u16, ++ __pthread_cond_magic: u16, ++ __pthread_cond_data: u64 ++ } ++ ++ pub struct pthread_condattr_t { ++ __pthread_condattrp: *mut ::c_void, ++ } ++ ++ pub struct pthread_rwlock_t { ++ __pthread_rwlock_readers: i32, ++ __pthread_rwlock_type: u16, ++ __pthread_rwlock_magic: u16, ++ __pthread_rwlock_mutex: ::pthread_mutex_t, ++ __pthread_rwlock_readercv: ::pthread_cond_t, ++ __pthread_rwlock_writercv: ::pthread_cond_t ++ } ++ ++ pub struct pthread_rwlockattr_t { ++ __pthread_rwlockattrp: *mut ::c_void, ++ } ++ ++ pub struct dirent { ++ pub d_ino: ::ino_t, ++ pub d_off: ::off_t, ++ pub d_reclen: u16, ++ pub d_name: [::c_char; 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, ++ #[cfg(target_arch = "sparc64")] ++ __sparcv9_pad: ::c_int, ++ pub ai_addrlen: ::socklen_t, ++ pub ai_canonname: *mut ::c_char, ++ pub ai_addr: *mut ::sockaddr, ++ pub ai_next: *mut addrinfo, ++ } ++ ++ pub struct sigset_t { ++ bits: [u32; 4], ++ } ++ ++ pub struct 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 struct port_event { ++ pub portev_events: ::c_int, ++ pub portev_source: ::c_ushort, ++ pub portev_pad: ::c_ushort, ++ pub portev_object: ::uintptr_t, ++ pub portev_user: ::uintptr_t, ++ } ++} ++ ++pub const LC_CTYPE: ::c_int = 0; ++pub const LC_NUMERIC: ::c_int = 1; ++pub const LC_TIME: ::c_int = 2; ++pub const LC_COLLATE: ::c_int = 3; ++pub const LC_MONETARY: ::c_int = 4; ++pub const LC_MESSAGES: ::c_int = 5; ++pub const LC_ALL: ::c_int = 6; ++pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE); ++pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC); ++pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME); ++pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE); ++pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY); ++pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES); ++pub const LC_ALL_MASK: ::c_int = LC_CTYPE_MASK ++ | LC_NUMERIC_MASK ++ | LC_TIME_MASK ++ | LC_COLLATE_MASK ++ | LC_MONETARY_MASK ++ | LC_MESSAGES_MASK; ++ ++pub const DAY_1: ::nl_item = 1; ++pub const DAY_2: ::nl_item = 2; ++pub const DAY_3: ::nl_item = 3; ++pub const DAY_4: ::nl_item = 4; ++pub const DAY_5: ::nl_item = 5; ++pub const DAY_6: ::nl_item = 6; ++pub const DAY_7: ::nl_item = 7; ++ ++pub const ABDAY_1: ::nl_item = 8; ++pub const ABDAY_2: ::nl_item = 9; ++pub const ABDAY_3: ::nl_item = 10; ++pub const ABDAY_4: ::nl_item = 11; ++pub const ABDAY_5: ::nl_item = 12; ++pub const ABDAY_6: ::nl_item = 13; ++pub const ABDAY_7: ::nl_item = 14; ++ ++pub const MON_1: ::nl_item = 15; ++pub const MON_2: ::nl_item = 16; ++pub const MON_3: ::nl_item = 17; ++pub const MON_4: ::nl_item = 18; ++pub const MON_5: ::nl_item = 19; ++pub const MON_6: ::nl_item = 20; ++pub const MON_7: ::nl_item = 21; ++pub const MON_8: ::nl_item = 22; ++pub const MON_9: ::nl_item = 23; ++pub const MON_10: ::nl_item = 24; ++pub const MON_11: ::nl_item = 25; ++pub const MON_12: ::nl_item = 26; ++ ++pub const ABMON_1: ::nl_item = 27; ++pub const ABMON_2: ::nl_item = 28; ++pub const ABMON_3: ::nl_item = 29; ++pub const ABMON_4: ::nl_item = 30; ++pub const ABMON_5: ::nl_item = 31; ++pub const ABMON_6: ::nl_item = 32; ++pub const ABMON_7: ::nl_item = 33; ++pub const ABMON_8: ::nl_item = 34; ++pub const ABMON_9: ::nl_item = 35; ++pub const ABMON_10: ::nl_item = 36; ++pub const ABMON_11: ::nl_item = 37; ++pub const ABMON_12: ::nl_item = 38; ++ ++pub const RADIXCHAR: ::nl_item = 39; ++pub const THOUSEP: ::nl_item = 40; ++pub const YESSTR: ::nl_item = 41; ++pub const NOSTR: ::nl_item = 42; ++pub const CRNCYSTR: ::nl_item = 43; ++ ++pub const D_T_FMT: ::nl_item = 44; ++pub const D_FMT: ::nl_item = 45; ++pub const T_FMT: ::nl_item = 46; ++pub const AM_STR: ::nl_item = 47; ++pub const PM_STR: ::nl_item = 48; ++ ++pub const CODESET: ::nl_item = 49; ++pub const T_FMT_AMPM: ::nl_item = 50; ++pub const ERA: ::nl_item = 51; ++pub const ERA_D_FMT: ::nl_item = 52; ++pub const ERA_D_T_FMT: ::nl_item = 53; ++pub const ERA_T_FMT: ::nl_item = 54; ++pub const ALT_DIGITS: ::nl_item = 55; ++pub const YESEXPR: ::nl_item = 56; ++pub const NOEXPR: ::nl_item = 57; ++pub const _DATE_FMT: ::nl_item = 58; ++pub const MAXSTRMSG: ::nl_item = 58; ++ ++pub const PATH_MAX: ::c_int = 1024; ++ ++pub const SA_ONSTACK: ::c_int = 0x00000001; ++pub const SA_RESETHAND: ::c_int = 0x00000002; ++pub const SA_RESTART: ::c_int = 0x00000004; ++pub const SA_SIGINFO: ::c_int = 0x00000008; ++pub const SA_NODEFER: ::c_int = 0x00000010; ++pub const SA_NOCLDWAIT: ::c_int = 0x00010000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00020000; ++ ++pub const SS_ONSTACK: ::c_int = 1; ++pub const SS_DISABLE: ::c_int = 2; ++ ++pub const FIOCLEX: ::c_int = 0x20006601; ++pub const FIONCLEX: ::c_int = 0x20006602; ++pub const FIONREAD: ::c_int = 0x4004667f; ++pub const FIONBIO: ::c_int = 0x8004667e; ++pub const FIOASYNC: ::c_int = 0x8004667d; ++pub const FIOSETOWN: ::c_int = 0x8004667c; ++pub const FIOGETOWN: ::c_int = 0x4004667b; ++ ++pub const SIGCHLD: ::c_int = 18; ++pub const SIGBUS: ::c_int = 10; ++pub const SIGINFO: ::c_int = 41; ++pub const SIG_BLOCK: ::c_int = 1; ++pub const SIG_UNBLOCK: ::c_int = 2; ++pub const SIG_SETMASK: ::c_int = 3; ++ ++pub const IPV6_MULTICAST_LOOP: ::c_int = 0x8; ++pub const IPV6_V6ONLY: ::c_int = 0x27; ++ ++cfg_if! { ++ if #[cfg(target_pointer_width = "64")] { ++ pub const FD_SETSIZE: usize = 65536; ++ } else { ++ pub const FD_SETSIZE: usize = 1024; ++ } ++} ++ ++pub const ST_RDONLY: ::c_ulong = 1; ++pub const ST_NOSUID: ::c_ulong = 2; ++ ++pub const NI_MAXHOST: ::socklen_t = 1025; ++ ++pub const EXIT_FAILURE: ::c_int = 1; ++pub const EXIT_SUCCESS: ::c_int = 0; ++pub const RAND_MAX: ::c_int = 32767; ++pub const EOF: ::c_int = -1; ++pub const SEEK_SET: ::c_int = 0; ++pub const SEEK_CUR: ::c_int = 1; ++pub const SEEK_END: ::c_int = 2; ++pub const _IOFBF: ::c_int = 0; ++pub const _IONBF: ::c_int = 4; ++pub const _IOLBF: ::c_int = 64; ++pub const BUFSIZ: ::c_uint = 1024; ++pub const FOPEN_MAX: ::c_uint = 20; ++pub const FILENAME_MAX: ::c_uint = 1024; ++pub const L_tmpnam: ::c_uint = 25; ++pub const TMP_MAX: ::c_uint = 17576; ++ ++pub const O_RDONLY: ::c_int = 0; ++pub const O_WRONLY: ::c_int = 1; ++pub const O_RDWR: ::c_int = 2; ++pub const O_SEARCH: ::c_int = 0x200000; ++pub const O_EXEC: ::c_int = 0x400000; ++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 WEXITED: ::c_int = 0x01; ++pub const WTRAPPED: ::c_int = 0x02; ++pub const WSTOPPED: ::c_int = WUNTRACED; ++pub const WCONTINUED: ::c_int = 0x08; ++pub const WNOWAIT: ::c_int = 0x80; ++ ++// Solaris defines a great many more of these; we only expose the ++// standardized ones. ++pub const P_PID: idtype_t = 0; ++pub const P_PGID: idtype_t = 2; ++pub const P_ALL: idtype_t = 7; ++ ++pub const 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 EAGAIN: ::c_int = 11; ++pub const ENOMEM: ::c_int = 12; ++pub const EACCES: ::c_int = 13; ++pub const EFAULT: ::c_int = 14; ++pub const ENOTBLK: ::c_int = 15; ++pub const EBUSY: ::c_int = 16; ++pub const EEXIST: ::c_int = 17; ++pub const EXDEV: ::c_int = 18; ++pub const ENODEV: ::c_int = 19; ++pub const ENOTDIR: ::c_int = 20; ++pub const EISDIR: ::c_int = 21; ++pub const EINVAL: ::c_int = 22; ++pub const ENFILE: ::c_int = 23; ++pub const EMFILE: ::c_int = 24; ++pub const ENOTTY: ::c_int = 25; ++pub const ETXTBSY: ::c_int = 26; ++pub const EFBIG: ::c_int = 27; ++pub const ENOSPC: ::c_int = 28; ++pub const ESPIPE: ::c_int = 29; ++pub const EROFS: ::c_int = 30; ++pub const EMLINK: ::c_int = 31; ++pub const EPIPE: ::c_int = 32; ++pub const EDOM: ::c_int = 33; ++pub const ERANGE: ::c_int = 34; ++pub const ENOMSG: ::c_int = 35; ++pub const EIDRM: ::c_int = 36; ++pub const ECHRNG: ::c_int = 37; ++pub const EL2NSYNC: ::c_int = 38; ++pub const EL3HLT: ::c_int = 39; ++pub const EL3RST: ::c_int = 40; ++pub const ELNRNG: ::c_int = 41; ++pub const EUNATCH: ::c_int = 42; ++pub const ENOCSI: ::c_int = 43; ++pub const EL2HLT: ::c_int = 44; ++pub const EDEADLK: ::c_int = 45; ++pub const ENOLCK: ::c_int = 46; ++pub const ECANCELED: ::c_int = 47; ++pub const ENOTSUP: ::c_int = 48; ++pub const EDQUOT: ::c_int = 49; ++pub const EBADE: ::c_int = 50; ++pub const EBADR: ::c_int = 51; ++pub const EXFULL: ::c_int = 52; ++pub const ENOANO: ::c_int = 53; ++pub const EBADRQC: ::c_int = 54; ++pub const EBADSLT: ::c_int = 55; ++pub const EDEADLOCK: ::c_int = 56; ++pub const EBFONT: ::c_int = 57; ++pub const EOWNERDEAD: ::c_int = 58; ++pub const ENOTRECOVERABLE: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const ELOCKUNMAPPED: ::c_int = 72; ++pub const ENOTACTIVE: ::c_int = 73; ++pub const EMULTIHOP: ::c_int = 74; ++pub const EADI: ::c_int = 75; ++pub const EBADMSG: ::c_int = 77; ++pub const ENAMETOOLONG: ::c_int = 78; ++pub const EOVERFLOW: ::c_int = 79; ++pub const ENOTUNIQ: ::c_int = 80; ++pub const EBADFD: ::c_int = 81; ++pub const EREMCHG: ::c_int = 82; ++pub const ELIBACC: ::c_int = 83; ++pub const ELIBBAD: ::c_int = 84; ++pub const ELIBSCN: ::c_int = 85; ++pub const ELIBMAX: ::c_int = 86; ++pub const ELIBEXEC: ::c_int = 87; ++pub const EILSEQ: ::c_int = 88; ++pub const ENOSYS: ::c_int = 89; ++pub const ELOOP: ::c_int = 90; ++pub const ERESTART: ::c_int = 91; ++pub const ESTRPIPE: ::c_int = 92; ++pub const ENOTEMPTY: ::c_int = 93; ++pub const EUSERS: ::c_int = 94; ++pub const ENOTSOCK: ::c_int = 95; ++pub const EDESTADDRREQ: ::c_int = 96; ++pub const EMSGSIZE: ::c_int = 97; ++pub const EPROTOTYPE: ::c_int = 98; ++pub const ENOPROTOOPT: ::c_int = 99; ++pub const EPROTONOSUPPORT: ::c_int = 120; ++pub const ESOCKTNOSUPPORT: ::c_int = 121; ++pub const EOPNOTSUPP: ::c_int = 122; ++pub const EPFNOSUPPORT: ::c_int = 123; ++pub const EAFNOSUPPORT: ::c_int = 124; ++pub const EADDRINUSE: ::c_int = 125; ++pub const EADDRNOTAVAIL: ::c_int = 126; ++pub const ENETDOWN: ::c_int = 127; ++pub const ENETUNREACH: ::c_int = 128; ++pub const ENETRESET: ::c_int = 129; ++pub const ECONNABORTED: ::c_int = 130; ++pub const ECONNRESET: ::c_int = 131; ++pub const ENOBUFS: ::c_int = 132; ++pub const EISCONN: ::c_int = 133; ++pub const ENOTCONN: ::c_int = 134; ++pub const ESHUTDOWN: ::c_int = 143; ++pub const ETOOMANYREFS: ::c_int = 144; ++pub const ETIMEDOUT: ::c_int = 145; ++pub const ECONNREFUSED: ::c_int = 146; ++pub const EHOSTDOWN: ::c_int = 147; ++pub const EHOSTUNREACH: ::c_int = 148; ++pub const EWOULDBLOCK: ::c_int = EAGAIN; ++pub const EALREADY: ::c_int = 149; ++pub const EINPROGRESS: ::c_int = 150; ++ ++pub const 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 PTHREAD_CREATE_JOINABLE: ::c_int = 0; ++pub const PTHREAD_CREATE_DETACHED: ::c_int = 0x40; ++pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; ++pub const PTHREAD_PROCESS_PRIVATE: ::c_ushort = 0; ++pub const PTHREAD_STACK_MIN: ::size_t = 4096; ++ ++pub const SIGSTKSZ: ::size_t = 8192; ++ ++// https://illumos.org/man/3c/clock_gettime ++// https://github.com/illumos/illumos-gate/ ++// blob/HEAD/usr/src/lib/libc/amd64/sys/__clock_gettime.s ++// clock_gettime(3c) doesn't seem to accept anything other than CLOCK_REALTIME ++// or __CLOCK_REALTIME0 ++// ++// https://github.com/illumos/illumos-gate/ ++// blob/HEAD/usr/src/uts/common/sys/time_impl.h ++// Confusing! CLOCK_HIGHRES==CLOCK_MONOTONIC==4 ++// __CLOCK_REALTIME0==0 is an obsoleted version of CLOCK_REALTIME==3 ++pub const CLOCK_REALTIME: ::clockid_t = 3; ++pub const CLOCK_MONOTONIC: ::clockid_t = 4; ++pub const TIMER_RELTIME: ::c_int = 0; ++pub const TIMER_ABSTIME: ::c_int = 1; ++ ++pub const RLIMIT_CPU: ::c_int = 0; ++pub const RLIMIT_FSIZE: ::c_int = 1; ++pub const RLIMIT_DATA: ::c_int = 2; ++pub const RLIMIT_STACK: ::c_int = 3; ++pub const RLIMIT_CORE: ::c_int = 4; ++pub const RLIMIT_NOFILE: ::c_int = 5; ++pub const RLIMIT_VMEM: ::c_int = 6; ++pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM; ++ ++pub const RLIM_NLIMITS: rlim_t = 7; ++pub const RLIM_INFINITY: rlim_t = 0x7fffffff; ++ ++pub const RUSAGE_SELF: ::c_int = 0; ++pub const RUSAGE_CHILDREN: ::c_int = -1; ++ ++pub const MADV_NORMAL: ::c_int = 0; ++pub const MADV_RANDOM: ::c_int = 1; ++pub const MADV_SEQUENTIAL: ::c_int = 2; ++pub const MADV_WILLNEED: ::c_int = 3; ++pub const MADV_DONTNEED: ::c_int = 4; ++pub const MADV_FREE: ::c_int = 5; ++ ++pub const AF_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 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 MSG_PEEK: ::c_int = 0x2; ++ ++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 F_RDLCK: ::c_short = 1; ++pub const F_WRLCK: ::c_short = 2; ++pub const F_UNLCK: ::c_short = 3; ++ ++pub const O_SYNC: ::c_int = 16; ++pub const O_NONBLOCK: ::c_int = 128; ++ ++pub const IPPROTO_RAW: ::c_int = 255; ++ ++pub const _PC_LINK_MAX: ::c_int = 1; ++pub const _PC_MAX_CANON: ::c_int = 2; ++pub const _PC_MAX_INPUT: ::c_int = 3; ++pub const _PC_NAME_MAX: ::c_int = 4; ++pub const _PC_PATH_MAX: ::c_int = 5; ++pub const _PC_PIPE_BUF: ::c_int = 6; ++pub const _PC_NO_TRUNC: ::c_int = 7; ++pub const _PC_VDISABLE: ::c_int = 8; ++pub const _PC_CHOWN_RESTRICTED: ::c_int = 9; ++pub const _PC_ASYNC_IO: ::c_int = 10; ++pub const _PC_PRIO_IO: ::c_int = 11; ++pub const _PC_SYNC_IO: ::c_int = 12; ++pub const _PC_ALLOC_SIZE_MIN: ::c_int = 13; ++pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14; ++pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15; ++pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16; ++pub const _PC_REC_XFER_ALIGN: ::c_int = 17; ++pub const _PC_SYMLINK_MAX: ::c_int = 18; ++pub const _PC_2_SYMLINKS: ::c_int = 19; ++pub const _PC_ACL_ENABLED: ::c_int = 20; ++pub const _PC_MIN_HOLE_SIZE: ::c_int = 21; ++pub const _PC_CASE_BEHAVIOR: ::c_int = 22; ++pub const _PC_SATTR_ENABLED: ::c_int = 23; ++pub const _PC_SATTR_EXISTS: ::c_int = 24; ++pub const _PC_ACCESS_FILTERING: ::c_int = 25; ++pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 26; ++pub const _PC_FILESIZEBITS: ::c_int = 67; ++pub const _PC_XATTR_ENABLED: ::c_int = 100; ++pub const _PC_LAST: ::c_int = 101; ++pub const _PC_XATTR_EXISTS: ::c_int = 101; ++ ++pub const _SC_ARG_MAX: ::c_int = 1; ++pub const _SC_CHILD_MAX: ::c_int = 2; ++pub const _SC_CLK_TCK: ::c_int = 3; ++pub const _SC_NGROUPS_MAX: ::c_int = 4; ++pub const _SC_OPEN_MAX: ::c_int = 5; ++pub const _SC_JOB_CONTROL: ::c_int = 6; ++pub const _SC_SAVED_IDS: ::c_int = 7; ++pub const _SC_VERSION: ::c_int = 8; ++pub const _SC_PASS_MAX: ::c_int = 9; ++pub const _SC_LOGNAME_MAX: ::c_int = 10; ++pub const _SC_PAGESIZE: ::c_int = 11; ++pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; ++pub const _SC_XOPEN_VERSION: ::c_int = 12; ++pub const _SC_NPROCESSORS_CONF: ::c_int = 14; ++pub const _SC_NPROCESSORS_ONLN: ::c_int = 15; ++pub const _SC_STREAM_MAX: ::c_int = 16; ++pub const _SC_TZNAME_MAX: ::c_int = 17; ++pub const _SC_AIO_LISTIO_MAX: ::c_int = 18; ++pub const _SC_AIO_MAX: ::c_int = 19; ++pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 20; ++pub const _SC_ASYNCHRONOUS_IO: ::c_int = 21; ++pub const _SC_DELAYTIMER_MAX: ::c_int = 22; ++pub const _SC_FSYNC: ::c_int = 23; ++pub const _SC_MAPPED_FILES: ::c_int = 24; ++pub const _SC_MEMLOCK: ::c_int = 25; ++pub const _SC_MEMLOCK_RANGE: ::c_int = 26; ++pub const _SC_MEMORY_PROTECTION: ::c_int = 27; ++pub const _SC_MESSAGE_PASSING: ::c_int = 28; ++pub const _SC_MQ_OPEN_MAX: ::c_int = 29; ++pub const _SC_MQ_PRIO_MAX: ::c_int = 30; ++pub const _SC_PRIORITIZED_IO: ::c_int = 31; ++pub const _SC_PRIORITY_SCHEDULING: ::c_int = 32; ++pub const _SC_REALTIME_SIGNALS: ::c_int = 33; ++pub const _SC_RTSIG_MAX: ::c_int = 34; ++pub const _SC_SEMAPHORES: ::c_int = 35; ++pub const _SC_SEM_NSEMS_MAX: ::c_int = 36; ++pub const _SC_SEM_VALUE_MAX: ::c_int = 37; ++pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 38; ++pub const _SC_SIGQUEUE_MAX: ::c_int = 39; ++pub const _SC_SIGRT_MIN: ::c_int = 40; ++pub const _SC_SIGRT_MAX: ::c_int = 41; ++pub const _SC_SYNCHRONIZED_IO: ::c_int = 42; ++pub const _SC_TIMERS: ::c_int = 43; ++pub const _SC_TIMER_MAX: ::c_int = 44; ++pub const _SC_2_C_BIND: ::c_int = 45; ++pub const _SC_2_C_DEV: ::c_int = 46; ++pub const _SC_2_C_VERSION: ::c_int = 47; ++pub const _SC_2_FORT_DEV: ::c_int = 48; ++pub const _SC_2_FORT_RUN: ::c_int = 49; ++pub const _SC_2_LOCALEDEF: ::c_int = 50; ++pub const _SC_2_SW_DEV: ::c_int = 51; ++pub const _SC_2_UPE: ::c_int = 52; ++pub const _SC_2_VERSION: ::c_int = 53; ++pub const _SC_BC_BASE_MAX: ::c_int = 54; ++pub const _SC_BC_DIM_MAX: ::c_int = 55; ++pub const _SC_BC_SCALE_MAX: ::c_int = 56; ++pub const _SC_BC_STRING_MAX: ::c_int = 57; ++pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 58; ++pub const _SC_EXPR_NEST_MAX: ::c_int = 59; ++pub const _SC_LINE_MAX: ::c_int = 60; ++pub const _SC_RE_DUP_MAX: ::c_int = 61; ++pub const _SC_XOPEN_CRYPT: ::c_int = 62; ++pub const _SC_XOPEN_ENH_I18N: ::c_int = 63; ++pub const _SC_XOPEN_SHM: ::c_int = 64; ++pub const _SC_2_CHAR_TERM: ::c_int = 66; ++pub const _SC_XOPEN_XCU_VERSION: ::c_int = 67; ++pub const _SC_ATEXIT_MAX: ::c_int = 76; ++pub const _SC_IOV_MAX: ::c_int = 77; ++pub const _SC_XOPEN_UNIX: ::c_int = 78; ++pub const _SC_T_IOV_MAX: ::c_int = 79; ++pub const _SC_PHYS_PAGES: ::c_int = 500; ++pub const _SC_AVPHYS_PAGES: ::c_int = 501; ++pub const _SC_COHER_BLKSZ: ::c_int = 503; ++pub const _SC_SPLIT_CACHE: ::c_int = 504; ++pub const _SC_ICACHE_SZ: ::c_int = 505; ++pub const _SC_DCACHE_SZ: ::c_int = 506; ++pub const _SC_ICACHE_LINESZ: ::c_int = 507; ++pub const _SC_DCACHE_LINESZ: ::c_int = 508; ++pub const _SC_ICACHE_BLKSZ: ::c_int = 509; ++pub const _SC_DCACHE_BLKSZ: ::c_int = 510; ++pub const _SC_DCACHE_TBLKSZ: ::c_int = 511; ++pub const _SC_ICACHE_ASSOC: ::c_int = 512; ++pub const _SC_DCACHE_ASSOC: ::c_int = 513; ++pub const _SC_MAXPID: ::c_int = 514; ++pub const _SC_STACK_PROT: ::c_int = 515; ++pub const _SC_NPROCESSORS_MAX: ::c_int = 516; ++pub const _SC_CPUID_MAX: ::c_int = 517; ++pub const _SC_EPHID_MAX: ::c_int = 518; ++pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 568; ++pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 569; ++pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 570; ++pub const _SC_LOGIN_NAME_MAX: ::c_int = 571; ++pub const _SC_THREAD_KEYS_MAX: ::c_int = 572; ++pub const _SC_THREAD_STACK_MIN: ::c_int = 573; ++pub const _SC_THREAD_THREADS_MAX: ::c_int = 574; ++pub const _SC_TTY_NAME_MAX: ::c_int = 575; ++pub const _SC_THREADS: ::c_int = 576; ++pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 577; ++pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 578; ++pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 579; ++pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 580; ++pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 581; ++pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 582; ++pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 583; ++pub const _SC_XOPEN_LEGACY: ::c_int = 717; ++pub const _SC_XOPEN_REALTIME: ::c_int = 718; ++pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 719; ++pub const _SC_XBS5_ILP32_OFF32: ::c_int = 720; ++pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 721; ++pub const _SC_XBS5_LP64_OFF64: ::c_int = 722; ++pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 723; ++pub const _SC_2_PBS: ::c_int = 724; ++pub const _SC_2_PBS_ACCOUNTING: ::c_int = 725; ++pub const _SC_2_PBS_CHECKPOINT: ::c_int = 726; ++pub const _SC_2_PBS_LOCATE: ::c_int = 728; ++pub const _SC_2_PBS_MESSAGE: ::c_int = 729; ++pub const _SC_2_PBS_TRACK: ::c_int = 730; ++pub const _SC_ADVISORY_INFO: ::c_int = 731; ++pub const _SC_BARRIERS: ::c_int = 732; ++pub const _SC_CLOCK_SELECTION: ::c_int = 733; ++pub const _SC_CPUTIME: ::c_int = 734; ++pub const _SC_HOST_NAME_MAX: ::c_int = 735; ++pub const _SC_MONOTONIC_CLOCK: ::c_int = 736; ++pub const _SC_READER_WRITER_LOCKS: ::c_int = 737; ++pub const _SC_REGEXP: ::c_int = 738; ++pub const _SC_SHELL: ::c_int = 739; ++pub const _SC_SPAWN: ::c_int = 740; ++pub const _SC_SPIN_LOCKS: ::c_int = 741; ++pub const _SC_SPORADIC_SERVER: ::c_int = 742; ++pub const _SC_SS_REPL_MAX: ::c_int = 743; ++pub const _SC_SYMLOOP_MAX: ::c_int = 744; ++pub const _SC_THREAD_CPUTIME: ::c_int = 745; ++pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 746; ++pub const _SC_TIMEOUTS: ::c_int = 747; ++pub const _SC_TRACE: ::c_int = 748; ++pub const _SC_TRACE_EVENT_FILTER: ::c_int = 749; ++pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 750; ++pub const _SC_TRACE_INHERIT: ::c_int = 751; ++pub const _SC_TRACE_LOG: ::c_int = 752; ++pub const _SC_TRACE_NAME_MAX: ::c_int = 753; ++pub const _SC_TRACE_SYS_MAX: ::c_int = 754; ++pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 755; ++pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 756; ++pub const _SC_V6_ILP32_OFF32: ::c_int = 757; ++pub const _SC_V6_ILP32_OFFBIG: ::c_int = 758; ++pub const _SC_V6_LP64_OFF64: ::c_int = 759; ++pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 760; ++pub const _SC_XOPEN_STREAMS: ::c_int = 761; ++pub const _SC_IPV6: ::c_int = 762; ++pub const _SC_RAW_SOCKETS: ::c_int = 763; ++ ++pub const _MUTEX_MAGIC: u16 = 0x4d58; // MX ++pub const _COND_MAGIC: u16 = 0x4356; // CV ++pub const _RWL_MAGIC: u16 = 0x5257; // RW ++ ++pub const NCCS: usize = 19; ++ ++pub const LOG_CRON: ::c_int = 15 << 3; ++ ++pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ++ __pthread_mutex_flag1: 0, ++ __pthread_mutex_flag2: 0, ++ __pthread_mutex_ceiling: 0, ++ __pthread_mutex_type: PTHREAD_PROCESS_PRIVATE, ++ __pthread_mutex_magic: _MUTEX_MAGIC, ++ __pthread_mutex_lock: 0, ++ __pthread_mutex_data: 0 ++}; ++pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { ++ __pthread_cond_flag: [0; 4], ++ __pthread_cond_type: PTHREAD_PROCESS_PRIVATE, ++ __pthread_cond_magic: _COND_MAGIC, ++ __pthread_cond_data: 0 ++}; ++pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { ++ __pthread_rwlock_readers: 0, ++ __pthread_rwlock_type: PTHREAD_PROCESS_PRIVATE, ++ __pthread_rwlock_magic: _RWL_MAGIC, ++ __pthread_rwlock_mutex: PTHREAD_MUTEX_INITIALIZER, ++ __pthread_rwlock_readercv: PTHREAD_COND_INITIALIZER, ++ __pthread_rwlock_writercv: PTHREAD_COND_INITIALIZER ++}; ++pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; ++pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; ++pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 4; ++pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; ++ ++pub const RTLD_NEXT: *mut ::c_void = -1isize as *mut ::c_void; ++pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void; ++pub const RTLD_SELF: *mut ::c_void = -3isize as *mut ::c_void; ++pub const RTLD_PROBE: *mut ::c_void = -4isize as *mut ::c_void; ++ ++pub const RTLD_NOW: ::c_int = 0x2; ++pub const RTLD_NOLOAD: ::c_int = 0x4; ++pub const RTLD_GLOBAL: ::c_int = 0x100; ++pub const RTLD_LOCAL: ::c_int = 0x0; ++pub const RTLD_PARENT: ::c_int = 0x200; ++pub const RTLD_GROUP: ::c_int = 0x400; ++pub const RTLD_WORLD: ::c_int = 0x800; ++pub const RTLD_NODELETE: ::c_int = 0x1000; ++pub const RTLD_FIRST: ::c_int = 0x2000; ++pub const RTLD_CONFGEN: ::c_int = 0x10000; ++ ++pub const PORT_SOURCE_AIO: ::c_int = 1; ++pub const PORT_SOURCE_TIMER: ::c_int = 2; ++pub const PORT_SOURCE_USER: ::c_int = 3; ++pub const PORT_SOURCE_FD: ::c_int = 4; ++pub const PORT_SOURCE_ALERT: ::c_int = 5; ++pub const PORT_SOURCE_MQ: ::c_int = 6; ++pub const PORT_SOURCE_FILE: ::c_int = 7; ++pub const PORT_SOURCE_POSTWAIT: ::c_int = 8; ++pub const PORT_SOURCE_SIGNAL: ::c_int = 9; ++ ++f! { ++ pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { ++ let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ let fd = fd as usize; ++ (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); ++ return ++ } ++ ++ pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { ++ let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ let fd = fd as usize; ++ return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0 ++ } ++ ++ pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { ++ let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ let fd = fd as usize; ++ (*set).fds_bits[fd / bits] |= 1 << (fd % bits); ++ return ++ } ++ ++ pub fn FD_ZERO(set: *mut fd_set) -> () { ++ for slot in (*set).fds_bits.iter_mut() { ++ *slot = 0; ++ } ++ } ++ ++ pub fn WIFEXITED(status: ::c_int) -> bool { ++ (status & 0xFF) == 0 ++ } ++ ++ pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { ++ (status >> 8) & 0xFF ++ } ++ ++ pub fn WTERMSIG(status: ::c_int) -> ::c_int { ++ status & 0x7F ++ } ++} ++ ++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 clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; ++ pub fn getnameinfo(sa: *const ::sockaddr, ++ salen: ::socklen_t, ++ host: *mut ::c_char, ++ hostlen: ::socklen_t, ++ serv: *mut ::c_char, ++ sevlen: ::socklen_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn setpwent(); ++ pub fn endpwent(); ++ pub fn getpwent() -> *mut passwd; ++ pub fn fdatasync(fd: ::c_int) -> ::c_int; ++ pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; ++ pub fn duplocale(base: ::locale_t) -> ::locale_t; ++ pub fn freelocale(loc: ::locale_t); ++ pub fn newlocale(mask: ::c_int, ++ locale: *const ::c_char, ++ base: ::locale_t) -> ::locale_t; ++ pub fn uselocale(loc: ::locale_t) -> ::locale_t; ++ pub fn getprogname() -> *const ::c_char; ++ pub fn setprogname(name: *const ::c_char); ++ pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; ++ pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; ++ pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int; ++ ++ pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; ++ ++ pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t, dev: dev_t) -> ::c_int; ++ pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t) -> ::c_int; ++ pub fn 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_create(native: *mut ::pthread_t, ++ attr: *const ::pthread_attr_t, ++ f: extern fn(*mut ::c_void) -> *mut ::c_void, ++ value: *mut ::c_void) -> ::c_int; ++ pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, ++ clock_id: *mut clockid_t) -> ::c_int; ++ pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, ++ clock_id: ::clockid_t) -> ::c_int; ++ pub fn sem_timedwait(sem: *mut sem_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, ++ options: ::c_int) -> ::c_int; ++ ++ pub fn glob(pattern: *const ::c_char, ++ flags: ::c_int, ++ errfunc: Option ::c_int>, ++ pglob: *mut ::glob_t) -> ::c_int; ++ ++ pub fn globfree(pglob: *mut ::glob_t); ++ ++ pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) ++ -> ::c_int; ++ ++ pub fn shm_unlink(name: *const ::c_char) -> ::c_int; ++ ++ pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); ++ ++ pub fn telldir(dirp: *mut ::DIR) -> ::c_long; ++ pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) ++ -> ::c_int; ++ ++ pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; ++ ++ pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; ++ ++ pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, ++ flags: ::c_int, addr: *mut ::sockaddr, ++ addrlen: *mut ::socklen_t) -> ::ssize_t; ++ pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int; ++ pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int; ++ pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; ++ ++ pub fn bind(socket: ::c_int, address: *const ::sockaddr, ++ address_len: ::socklen_t) -> ::c_int; ++ ++ pub fn writev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ pub fn readv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ ++ pub fn sendmsg(fd: ::c_int, ++ msg: *const ::msghdr, ++ flags: ::c_int) -> ::ssize_t; ++ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) ++ -> ::ssize_t; ++ ++ pub fn port_create() -> ::c_int; ++ pub fn port_associate(port: ::c_int, source: ::c_int, object: ::uintptr_t, ++ events: ::c_int, user: ::uintptr_t) -> ::c_int; ++ pub fn port_dissociate(port: ::c_int, source: ::c_int, object: ::uintptr_t) ++ -> ::c_int; ++ pub fn port_get(port: ::c_int, pe: *mut port_event, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn port_getn(port: ::c_int, pe_list: *mut port_event, max: ::c_uint, ++ nget: *mut ::c_uint, timeout: *const ::timespec) ++ -> ::c_int; ++ pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, ++ envp: *const *const ::c_char) ++ -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] ++ pub fn getgrgid_r(uid: ::uid_t, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "sigaltstack$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] ++ pub fn sigaltstack(ss: *const stack_t, ++ oss: *mut stack_t) -> ::c_int; ++ pub fn sem_close(sem: *mut sem_t) -> ::c_int; ++ pub fn getdtablesize() -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] ++ pub fn getgrnam_r(name: *const ::c_char, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_sigmask$UNIX2003")] ++ pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, ++ oldset: *mut sigset_t) -> ::c_int; ++ pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; ++ pub fn getgrnam(name: *const ::c_char) -> *mut ::group; ++ pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; ++ pub fn sem_unlink(name: *const ::c_char) -> ::c_int; ++ pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] ++ pub fn getpwnam_r(name: *const ::c_char, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] ++ pub fn getpwuid_r(uid: ::uid_t, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch ="x86"), ++ link_name = "sigwait$UNIX2003")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] ++ pub fn sigwait(set: *const sigset_t, ++ sig: *mut ::c_int) -> ::c_int; ++ pub fn pthread_atfork(prepare: Option, ++ parent: Option, ++ child: Option) -> ::c_int; ++ pub fn getgrgid(gid: ::gid_t) -> *mut ::group; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "popen$UNIX2003")] ++ pub fn popen(command: *const c_char, ++ mode: *const c_char) -> *mut ::FILE; ++} diff --cc vendor/libc-0.2.31/src/unix/uclibc/mips/mips32.rs index 000000000,000000000..a81e884e0 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/uclibc/mips/mips32.rs @@@ -1,0 -1,0 +1,269 @@@ ++pub type c_char = i8; ++pub type c_long = i32; ++pub type c_ulong = u32; ++pub type clock_t = i32; ++pub type time_t = i32; ++pub type suseconds_t = i32; ++pub type wchar_t = i32; ++pub type off_t = i32; ++pub type ino_t = u32; ++pub type blkcnt_t = i32; ++pub type blksize_t = i32; ++pub type nlink_t = u32; ++pub type fsblkcnt_t = ::c_ulong; ++pub type fsfilcnt_t = ::c_ulong; ++pub type rlim_t = c_ulong; ++ ++s! { ++ pub struct stat { ++ pub st_dev: ::dev_t, ++ st_pad1: [::c_long; 2], ++ pub st_ino: ::ino_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ pub st_pad2: [::c_long; 1], ++ pub st_size: ::off_t, ++ st_pad3: ::c_long, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt_t, ++ st_pad5: [::c_long; 14], ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::dev_t, ++ st_pad1: [::c_long; 2], ++ pub st_ino: ::ino64_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::dev_t, ++ st_pad2: [::c_long; 2], ++ pub st_size: ::off64_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_blksize: ::blksize_t, ++ st_pad3: ::c_long, ++ pub st_blocks: ::blkcnt64_t, ++ st_pad5: [::c_long; 14], ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [u32; 9] ++ } ++ ++ pub struct sigaction { ++ pub sa_flags: ::c_uint, ++ pub sa_sigaction: ::sighandler_t, ++ pub sa_mask: sigset_t, ++ _restorer: *mut ::c_void, ++ } ++ ++ pub struct stack_t { ++ pub ss_sp: *mut ::c_void, ++ pub ss_size: ::size_t, ++ pub ss_flags: ::c_int, ++ } ++ ++ pub struct sigset_t { ++ __val: [::c_ulong; 4], ++ } ++ ++ pub struct siginfo_t { ++ pub si_signo: ::c_int, ++ pub si_code: ::c_int, ++ pub si_errno: ::c_int, ++ pub _pad: [::c_int; 29], ++ } ++ ++ pub struct glob64_t { ++ pub gl_pathc: ::size_t, ++ pub gl_pathv: *mut *mut ::c_char, ++ pub gl_offs: ::size_t, ++ pub gl_flags: ::c_int, ++ ++ __unused1: *mut ::c_void, ++ __unused2: *mut ::c_void, ++ __unused3: *mut ::c_void, ++ __unused4: *mut ::c_void, ++ __unused5: *mut ::c_void, ++ } ++ ++ pub struct ipc_perm { ++ pub __key: ::key_t, ++ pub uid: ::uid_t, ++ pub gid: ::gid_t, ++ pub cuid: ::uid_t, ++ pub cgid: ::gid_t, ++ pub mode: ::c_uint, ++ pub __seq: ::c_ushort, ++ __pad1: ::c_ushort, ++ __unused1: ::c_ulong, ++ __unused2: ::c_ulong ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, ++ pub shm_atime: ::time_t, ++ pub shm_dtime: ::time_t, ++ pub shm_ctime: ::time_t, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::shmatt_t, ++ __unused4: ::c_ulong, ++ __unused5: ::c_ulong ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ #[cfg(target_endian = "big")] ++ __glibc_reserved1: ::c_ulong, ++ pub msg_stime: ::time_t, ++ #[cfg(target_endian = "little")] ++ __glibc_reserved1: ::c_ulong, ++ #[cfg(target_endian = "big")] ++ __glibc_reserved2: ::c_ulong, ++ pub msg_rtime: ::time_t, ++ #[cfg(target_endian = "little")] ++ __glibc_reserved2: ::c_ulong, ++ #[cfg(target_endian = "big")] ++ __glibc_reserved3: ::c_ulong, ++ pub msg_ctime: ::time_t, ++ #[cfg(target_endian = "little")] ++ __glibc_reserved3: ::c_ulong, ++ __msg_cbytes: ::c_ulong, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ __glibc_reserved4: ::c_ulong, ++ __glibc_reserved5: ::c_ulong, ++ } ++ ++ pub struct statfs { ++ pub f_type: ::c_long, ++ pub f_bsize: ::c_long, ++ pub f_frsize: ::c_long, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_files: ::fsblkcnt_t, ++ pub f_ffree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_fsid: ::fsid_t, ++ ++ pub f_namelen: ::c_long, ++ f_spare: [::c_long; 6], ++ } ++ ++ pub struct msghdr { ++ pub msg_name: *mut ::c_void, ++ pub msg_namelen: ::socklen_t, ++ pub msg_iov: *mut ::iovec, ++ pub msg_iovlen: ::c_int, ++ pub msg_control: *mut ::c_void, ++ pub msg_controllen: ::size_t, ++ pub msg_flags: ::c_int, ++ } ++ ++ pub struct cmsghdr { ++ pub cmsg_len: ::size_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct termios { ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_line: ::cc_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ } ++ ++ pub struct flock { ++ pub l_type: ::c_short, ++ pub l_whence: ::c_short, ++ pub l_start: ::off_t, ++ pub l_len: ::off_t, ++ pub l_sysid: ::c_long, ++ pub l_pid: ::pid_t, ++ pad: [::c_long; 4], ++ } ++ ++ pub struct sysinfo { ++ pub uptime: ::c_long, ++ pub loads: [::c_ulong; 3], ++ pub totalram: ::c_ulong, ++ pub freeram: ::c_ulong, ++ pub sharedram: ::c_ulong, ++ pub bufferram: ::c_ulong, ++ pub totalswap: ::c_ulong, ++ pub freeswap: ::c_ulong, ++ pub procs: ::c_ushort, ++ pub pad: ::c_ushort, ++ pub totalhigh: ::c_ulong, ++ pub freehigh: ::c_ulong, ++ pub mem_unit: ::c_uint, ++ pub _f: [::c_char; 8], ++ } ++ ++ // 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 __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; ++pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; ++ ++pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; ++ ++pub const SYS_gettid: ::c_long = 4222; // Valid for O32 ++ ++#[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 ::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 --cc vendor/libc-0.2.31/src/unix/uclibc/mips/mips64.rs index 000000000,000000000..79bac1fa8 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/uclibc/mips/mips64.rs @@@ -1,0 -1,0 +1,209 @@@ ++pub type blkcnt_t = i64; ++pub type blksize_t = i64; ++pub type c_char = i8; ++pub type c_long = i64; ++pub type c_ulong = u64; ++pub type fsblkcnt_t = ::c_ulong; ++pub type fsfilcnt_t = ::c_ulong; ++pub type ino_t = u64; ++pub type nlink_t = u64; ++pub type off_t = i64; ++pub type rlim_t = ::c_ulong; ++pub type suseconds_t = i64; ++pub type time_t = i64; ++pub type wchar_t = i32; ++ ++s! { ++ pub struct stat { ++ pub st_dev: ::c_ulong, ++ st_pad1: [::c_long; 2], ++ pub st_ino: ::ino_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::c_ulong, ++ st_pad2: [::c_ulong; 1], ++ pub st_size: ::off_t, ++ st_pad3: ::c_long, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_blksize: ::blksize_t, ++ st_pad4: ::c_long, ++ pub st_blocks: ::blkcnt_t, ++ st_pad5: [::c_long; 7], ++ } ++ ++ pub struct stat64 { ++ pub st_dev: ::c_ulong, ++ st_pad1: [::c_long; 2], ++ pub st_ino: ::ino64_t, ++ pub st_mode: ::mode_t, ++ pub st_nlink: ::nlink_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::c_ulong, ++ st_pad2: [::c_long; 2], ++ pub st_size: ::off64_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_long, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_long, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_long, ++ pub st_blksize: ::blksize_t, ++ st_pad3: ::c_long, ++ pub st_blocks: ::blkcnt64_t, ++ st_pad5: [::c_long; 7], ++ } ++ ++ pub struct pthread_attr_t { ++ __size: [::c_ulong; 7] ++ } ++ ++ pub struct sigaction { ++ pub sa_flags: ::c_int, ++ pub sa_sigaction: ::sighandler_t, ++ pub sa_mask: sigset_t, ++ _restorer: *mut ::c_void, ++ } ++ ++ pub struct stack_t { ++ pub ss_sp: *mut ::c_void, ++ pub ss_size: ::size_t, ++ pub ss_flags: ::c_int, ++ } ++ ++ pub struct sigset_t { ++ __size: [::c_ulong; 16], ++ } ++ ++ pub struct siginfo_t { ++ pub si_signo: ::c_int, ++ pub si_code: ::c_int, ++ pub si_errno: ::c_int, ++ _pad: ::c_int, ++ _pad2: [::c_long; 14], ++ } ++ ++ pub struct ipc_perm { ++ pub __key: ::key_t, ++ pub uid: ::uid_t, ++ pub gid: ::gid_t, ++ pub cuid: ::uid_t, ++ pub cgid: ::gid_t, ++ pub mode: ::c_uint, ++ pub __seq: ::c_ushort, ++ __pad1: ::c_ushort, ++ __unused1: ::c_ulong, ++ __unused2: ::c_ulong ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, ++ pub shm_atime: ::time_t, ++ pub shm_dtime: ::time_t, ++ pub shm_ctime: ::time_t, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::shmatt_t, ++ __unused4: ::c_ulong, ++ __unused5: ::c_ulong ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ pub msg_stime: ::time_t, ++ pub msg_rtime: ::time_t, ++ pub msg_ctime: ::time_t, ++ __msg_cbytes: ::c_ulong, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ __glibc_reserved4: ::c_ulong, ++ __glibc_reserved5: ::c_ulong, ++ } ++ ++ pub struct statfs { ++ pub f_type: ::c_long, ++ pub f_bsize: ::c_long, ++ pub f_frsize: ::c_long, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_files: ::fsblkcnt_t, ++ pub f_ffree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_fsid: ::fsid_t, ++ ++ pub f_namelen: ::c_long, ++ f_spare: [::c_long; 6], ++ } ++ ++ pub struct msghdr { ++ pub msg_name: *mut ::c_void, ++ pub msg_namelen: ::socklen_t, ++ pub msg_iov: *mut ::iovec, ++ pub msg_iovlen: ::size_t, ++ pub msg_control: *mut ::c_void, ++ pub msg_controllen: ::size_t, ++ pub msg_flags: ::c_int, ++ } ++ ++ pub struct cmsghdr { ++ pub cmsg_len: ::size_t, ++ pub cmsg_level: ::c_int, ++ pub cmsg_type: ::c_int, ++ } ++ ++ pub struct termios { ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_line: ::cc_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ } ++ ++ pub struct sysinfo { ++ pub uptime: ::c_long, ++ pub loads: [::c_ulong; 3], ++ pub totalram: ::c_ulong, ++ pub freeram: ::c_ulong, ++ pub sharedram: ::c_ulong, ++ pub bufferram: ::c_ulong, ++ pub totalswap: ::c_ulong, ++ pub freeswap: ::c_ulong, ++ pub procs: ::c_ushort, ++ pub pad: ::c_ushort, ++ pub totalhigh: ::c_ulong, ++ pub freehigh: ::c_ulong, ++ pub mem_unit: ::c_uint, ++ pub _f: [::c_char; 0], ++ } ++ ++ // 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 RLIM_INFINITY: ::rlim_t = 0xffff_ffff_ffff_ffff; ++ ++pub const SYS_gettid: ::c_long = 5178; // Valid for n64 ++ ++#[link(name = "util")] ++extern { ++ pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; ++} diff --cc vendor/libc-0.2.31/src/unix/uclibc/mips/mod.rs index 000000000,000000000..cc3ddf254 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/uclibc/mips/mod.rs @@@ -1,0 -1,0 +1,476 @@@ ++pub const SFD_CLOEXEC: ::c_int = 0x080000; ++ ++pub const NCCS: usize = 32; ++ ++pub const O_TRUNC: ::c_int = 512; ++ ++pub const O_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EBFONT: ::c_int = 59; ++pub const ENOSTR: ::c_int = 60; ++pub const ENODATA: ::c_int = 61; ++pub const ETIME: ::c_int = 62; ++pub const ENOSR: ::c_int = 63; ++pub const ENONET: ::c_int = 64; ++pub const ENOPKG: ::c_int = 65; ++pub const EREMOTE: ::c_int = 66; ++pub const ENOLINK: ::c_int = 67; ++pub const EADV: ::c_int = 68; ++pub const ESRMNT: ::c_int = 69; ++pub const ECOMM: ::c_int = 70; ++pub const EPROTO: ::c_int = 71; ++pub const EDOTDOT: ::c_int = 73; ++ ++pub const SA_NODEFER: ::c_int = 0x40000000; ++pub const SA_RESETHAND: ::c_int = 0x80000000; ++pub const SA_RESTART: ::c_int = 0x10000000; ++pub const SA_NOCLDSTOP: ::c_int = 0x00000001; ++ ++pub const EPOLL_CLOEXEC: ::c_int = 0x80000; ++ ++pub const EFD_CLOEXEC: ::c_int = 0x80000; ++ ++pub const BUFSIZ: ::c_uint = 4096; ++pub const TMP_MAX: ::c_uint = 238328; ++pub const FOPEN_MAX: ::c_uint = 16; ++pub const POSIX_FADV_DONTNEED: ::c_int = 4; ++pub const POSIX_FADV_NOREUSE: ::c_int = 5; ++pub const POSIX_MADV_DONTNEED: ::c_int = 4; ++pub const _SC_2_C_VERSION: ::c_int = 96; ++pub const O_ACCMODE: ::c_int = 3; ++pub const O_DIRECT: ::c_int = 0x8000; ++pub const O_DIRECTORY: ::c_int = 0x10000; ++pub const O_NOFOLLOW: ::c_int = 0x20000; ++pub const ST_RELATIME: ::c_ulong = 4096; ++pub const NI_MAXHOST: ::socklen_t = 1025; ++ ++pub const RLIMIT_NOFILE: ::c_int = 5; ++pub const RLIMIT_AS: ::c_int = 6; ++pub const RLIMIT_RSS: ::c_int = 7; ++pub const RLIMIT_NPROC: ::c_int = 8; ++pub const RLIMIT_MEMLOCK: ::c_int = 9; ++pub const RLIMIT_NLIMITS: ::c_int = 15; ++ ++pub const O_APPEND: ::c_int = 8; ++pub const O_CREAT: ::c_int = 256; ++pub const O_EXCL: ::c_int = 1024; ++pub const O_NOCTTY: ::c_int = 2048; ++pub const O_NONBLOCK: ::c_int = 128; ++pub const O_SYNC: ::c_int = 0x10; ++pub const O_RSYNC: ::c_int = 0x10; ++pub const O_DSYNC: ::c_int = 0x10; ++pub const O_FSYNC: ::c_int = 0x10; ++pub const O_ASYNC: ::c_int = 0x1000; ++pub const O_NDELAY: ::c_int = 0x80; ++ ++pub const SOCK_NONBLOCK: ::c_int = 128; ++ ++pub const EDEADLK: ::c_int = 45; ++pub const ENAMETOOLONG: ::c_int = 78; ++pub const ENOLCK: ::c_int = 46; ++pub const ENOSYS: ::c_int = 89; ++pub const ENOTEMPTY: ::c_int = 93; ++pub const ELOOP: ::c_int = 90; ++pub const ENOMSG: ::c_int = 35; ++pub const EIDRM: ::c_int = 36; ++pub const ECHRNG: ::c_int = 37; ++pub const EL2NSYNC: ::c_int = 38; ++pub const EL3HLT: ::c_int = 39; ++pub const EL3RST: ::c_int = 40; ++pub const ELNRNG: ::c_int = 41; ++pub const EUNATCH: ::c_int = 42; ++pub const ENOCSI: ::c_int = 43; ++pub const EL2HLT: ::c_int = 44; ++pub const EBADE: ::c_int = 50; ++pub const EBADR: ::c_int = 51; ++pub const EXFULL: ::c_int = 52; ++pub const ENOANO: ::c_int = 53; ++pub const EBADRQC: ::c_int = 54; ++pub const EBADSLT: ::c_int = 55; ++pub const EDEADLOCK: ::c_int = 56; ++pub const EMULTIHOP: ::c_int = 74; ++pub const EOVERFLOW: ::c_int = 79; ++pub const ENOTUNIQ: ::c_int = 80; ++pub const EBADFD: ::c_int = 81; ++pub const EBADMSG: ::c_int = 77; ++pub const EREMCHG: ::c_int = 82; ++pub const ELIBACC: ::c_int = 83; ++pub const ELIBBAD: ::c_int = 84; ++pub const ELIBSCN: ::c_int = 85; ++pub const ELIBMAX: ::c_int = 86; ++pub const ELIBEXEC: ::c_int = 87; ++pub const EILSEQ: ::c_int = 88; ++pub const ERESTART: ::c_int = 91; ++pub const ESTRPIPE: ::c_int = 92; ++pub const EUSERS: ::c_int = 94; ++pub const ENOTSOCK: ::c_int = 95; ++pub const EDESTADDRREQ: ::c_int = 96; ++pub const EMSGSIZE: ::c_int = 97; ++pub const EPROTOTYPE: ::c_int = 98; ++pub const ENOPROTOOPT: ::c_int = 99; ++pub const EPROTONOSUPPORT: ::c_int = 120; ++pub const ESOCKTNOSUPPORT: ::c_int = 121; ++pub const EOPNOTSUPP: ::c_int = 122; ++pub const ENOTSUP: ::c_int = EOPNOTSUPP; ++pub const EPFNOSUPPORT: ::c_int = 123; ++pub const EAFNOSUPPORT: ::c_int = 124; ++pub const EADDRINUSE: ::c_int = 125; ++pub const EADDRNOTAVAIL: ::c_int = 126; ++pub const ENETDOWN: ::c_int = 127; ++pub const ENETUNREACH: ::c_int = 128; ++pub const ENETRESET: ::c_int = 129; ++pub const ECONNABORTED: ::c_int = 130; ++pub const ECONNRESET: ::c_int = 131; ++pub const ENOBUFS: ::c_int = 132; ++pub const EISCONN: ::c_int = 133; ++pub const ENOTCONN: ::c_int = 134; ++pub const ESHUTDOWN: ::c_int = 143; ++pub const ETOOMANYREFS: ::c_int = 144; ++pub const ETIMEDOUT: ::c_int = 145; ++pub const ECONNREFUSED: ::c_int = 146; ++pub const EHOSTDOWN: ::c_int = 147; ++pub const EHOSTUNREACH: ::c_int = 148; ++pub const EALREADY: ::c_int = 149; ++pub const EINPROGRESS: ::c_int = 150; ++pub const ESTALE: ::c_int = 151; ++pub const EUCLEAN: ::c_int = 135; ++pub const ENOTNAM: ::c_int = 137; ++pub const ENAVAIL: ::c_int = 138; ++pub const EISNAM: ::c_int = 139; ++pub const EREMOTEIO: ::c_int = 140; ++pub const EDQUOT: ::c_int = 1133; ++pub const ENOMEDIUM: ::c_int = 159; ++pub const EMEDIUMTYPE: ::c_int = 160; ++pub const ECANCELED: ::c_int = 158; ++pub const ENOKEY: ::c_int = 161; ++pub const EKEYEXPIRED: ::c_int = 162; ++pub const EKEYREVOKED: ::c_int = 163; ++pub const EKEYREJECTED: ::c_int = 164; ++pub const EOWNERDEAD: ::c_int = 165; ++pub const ENOTRECOVERABLE: ::c_int = 166; ++pub const ERFKILL: ::c_int = 167; ++ ++pub const MAP_NORESERVE: ::c_int = 0x400; ++pub const MAP_ANON: ::c_int = 0x800; ++pub const MAP_ANONYMOUS: ::c_int = 0x800; ++pub const MAP_GROWSDOWN: ::c_int = 0x1000; ++pub const MAP_DENYWRITE: ::c_int = 0x2000; ++pub const MAP_EXECUTABLE: ::c_int = 0x4000; ++pub const MAP_LOCKED: ::c_int = 0x8000; ++pub const MAP_POPULATE: ::c_int = 0x10000; ++pub const MAP_NONBLOCK: ::c_int = 0x20000; ++pub const MAP_STACK: ::c_int = 0x40000; ++ ++pub const SOCK_STREAM: ::c_int = 2; ++pub const SOCK_DGRAM: ::c_int = 1; ++pub const SOCK_SEQPACKET: ::c_int = 5; ++ ++pub const SOL_SOCKET: ::c_int = 0xffff; ++ ++pub const SO_REUSEADDR: ::c_int = 0x0004; ++pub const SO_KEEPALIVE: ::c_int = 0x0008; ++pub const SO_DONTROUTE: ::c_int = 0x0010; ++pub const SO_BROADCAST: ::c_int = 0x0020; ++pub const SO_LINGER: ::c_int = 0x0080; ++pub const SO_OOBINLINE: ::c_int = 0x0100; ++pub const SO_REUSEPORT: ::c_int = 0x0200; ++pub const SO_TYPE: ::c_int = 0x1008; ++pub const SO_STYLE: ::c_int = SO_TYPE; ++pub const SO_ERROR: ::c_int = 0x1007; ++pub const SO_SNDBUF: ::c_int = 0x1001; ++pub const SO_RCVBUF: ::c_int = 0x1002; ++pub const SO_SNDLOWAT: ::c_int = 0x1003; ++pub const SO_RCVLOWAT: ::c_int = 0x1004; ++pub const SO_SNDTIMEO: ::c_int = 0x1005; ++pub const SO_RCVTIMEO: ::c_int = 0x1006; ++pub const SO_ACCEPTCONN: ::c_int = 0x1009; ++pub const SO_PROTOCOL: ::c_int = 0x1028; ++pub const SO_DOMAIN: ::c_int = 0x1029; ++pub const SO_NO_CHECK: ::c_int = 11; ++pub const SO_PRIORITY: ::c_int = 12; ++pub const SO_BSDCOMPAT: ::c_int = 14; ++pub const SO_PASSCRED: ::c_int = 17; ++pub const SO_PEERCRED: ::c_int = 18; ++pub const SO_SECURITY_AUTHENTICATION: ::c_int = 22; ++pub const SO_SECURITY_ENCRYPTION_TRANSPORT: ::c_int = 23; ++pub const SO_SECURITY_ENCRYPTION_NETWORK: ::c_int = 24; ++pub const SO_BINDTODEVICE: ::c_int = 25; ++pub const SO_ATTACH_FILTER: ::c_int = 26; ++pub const SO_DETACH_FILTER: ::c_int = 27; ++pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; ++pub const SO_PEERNAME: ::c_int = 28; ++pub const SO_TIMESTAMP: ::c_int = 29; ++pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; ++pub const SO_PEERSEC: ::c_int = 30; ++pub const SO_SNDBUFFORCE: ::c_int = 31; ++pub const SO_RCVBUFFORCE: ::c_int = 33; ++pub const SO_PASSSEC: ::c_int = 34; ++pub const SO_TIMESTAMPNS: ::c_int = 35; ++pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; ++pub const SO_MARK: ::c_int = 36; ++pub const SO_TIMESTAMPING: ::c_int = 37; ++pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; ++pub const SO_RXQ_OVFL: ::c_int = 40; ++pub const SO_WIFI_STATUS: ::c_int = 41; ++pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS; ++pub const SO_PEEK_OFF: ::c_int = 42; ++pub const SO_NOFCS: ::c_int = 43; ++pub const SO_LOCK_FILTER: ::c_int = 44; ++pub const SO_SELECT_ERR_QUEUE: ::c_int = 45; ++pub const SO_BUSY_POLL: ::c_int = 46; ++pub const SO_MAX_PACING_RATE: ::c_int = 47; ++pub const SO_BPF_EXTENSIONS: ::c_int = 48; ++ ++pub const FIOCLEX: ::c_ulong = 0x6601; ++pub const FIONBIO: ::c_ulong = 0x667e; ++ ++pub const SA_ONSTACK: ::c_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 = 16384; ++ ++pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; ++pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; ++pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; ++pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; ++pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; ++pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; ++pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; ++pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; ++pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; ++pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; ++pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; ++pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; ++pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; ++pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; ++pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; ++pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; ++pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; ++pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; ++pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; ++pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; ++pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; ++pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; ++pub const TMPFS_MAGIC: ::c_long = 0x01021994; ++pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; ++ ++pub const VEOF: usize = 16; ++pub const VEOL: usize = 17; ++pub const VEOL2: usize = 6; ++pub const VMIN: usize = 4; ++pub const IEXTEN: ::tcflag_t = 0x00000100; ++pub const TOSTOP: ::tcflag_t = 0x00008000; ++pub const FLUSHO: ::tcflag_t = 0x00002000; ++pub const IUTF8: ::tcflag_t = 0x00004000; ++pub const TCSANOW: ::c_int = 0x540e; ++pub const TCSADRAIN: ::c_int = 0x540f; ++pub const TCSAFLUSH: ::c_int = 0x5410; ++ ++pub const CPU_SETSIZE: ::c_int = 0x400; ++ ++pub const PTRACE_TRACEME: ::c_uint = 0; ++pub const PTRACE_PEEKTEXT: ::c_uint = 1; ++pub const PTRACE_PEEKDATA: ::c_uint = 2; ++pub const PTRACE_PEEKUSER: ::c_uint = 3; ++pub const PTRACE_POKETEXT: ::c_uint = 4; ++pub const PTRACE_POKEDATA: ::c_uint = 5; ++pub const PTRACE_POKEUSER: ::c_uint = 6; ++pub const PTRACE_CONT: ::c_uint = 7; ++pub const PTRACE_KILL: ::c_uint = 8; ++pub const PTRACE_SINGLESTEP: ::c_uint = 9; ++pub const PTRACE_ATTACH: ::c_uint = 16; ++pub const PTRACE_DETACH: ::c_uint = 17; ++pub const PTRACE_SYSCALL: ::c_uint = 24; ++pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; ++pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; ++pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; ++pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; ++pub const PTRACE_GETFPREGS: ::c_uint = 14; ++pub const PTRACE_SETFPREGS: ::c_uint = 15; ++pub const PTRACE_GETFPXREGS: ::c_uint = 18; ++pub const PTRACE_SETFPXREGS: ::c_uint = 19; ++pub const PTRACE_GETREGS: ::c_uint = 12; ++pub const PTRACE_SETREGS: ::c_uint = 13; ++ ++pub const EFD_NONBLOCK: ::c_int = 0x80; ++ ++pub const F_GETLK: ::c_int = 14; ++pub const F_GETOWN: ::c_int = 23; ++pub const F_SETOWN: ::c_int = 24; ++pub const F_SETLK: ::c_int = 6; ++pub const F_SETLKW: ::c_int = 7; ++ ++pub const SFD_NONBLOCK: ::c_int = 0x80; ++ ++pub const TCGETS: ::c_ulong = 0x540d; ++pub const TCSETS: ::c_ulong = 0x540e; ++pub const TCSETSW: ::c_ulong = 0x540f; ++pub const TCSETSF: ::c_ulong = 0x5410; ++pub const TCGETA: ::c_ulong = 0x5401; ++pub const TCSETA: ::c_ulong = 0x5402; ++pub const TCSETAW: ::c_ulong = 0x5403; ++pub const TCSETAF: ::c_ulong = 0x5404; ++pub const TCSBRK: ::c_ulong = 0x5405; ++pub const TCXONC: ::c_ulong = 0x5406; ++pub const TCFLSH: ::c_ulong = 0x5407; ++pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; ++pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; ++pub const TIOCINQ: ::c_ulong = 0x467f; ++pub const TIOCLINUX: ::c_ulong = 0x5483; ++pub const TIOCGSERIAL: ::c_ulong = 0x5484; ++pub const TIOCEXCL: ::c_ulong = 0x740d; ++pub const TIOCNXCL: ::c_ulong = 0x740e; ++pub const TIOCSCTTY: ::c_ulong = 0x5480; ++pub const TIOCGPGRP: ::c_ulong = 0x40047477; ++pub const TIOCSPGRP: ::c_ulong = 0x80047476; ++pub const TIOCOUTQ: ::c_ulong = 0x7472; ++pub const TIOCSTI: ::c_ulong = 0x5472; ++pub const TIOCGWINSZ: ::c_ulong = 0x40087468; ++pub const TIOCSWINSZ: ::c_ulong = 0x80087467; ++pub const TIOCMGET: ::c_ulong = 0x741d; ++pub const TIOCMBIS: ::c_ulong = 0x741b; ++pub const TIOCMBIC: ::c_ulong = 0x741c; ++pub const TIOCMSET: ::c_ulong = 0x741a; ++pub const FIONREAD: ::c_ulong = 0x467f; ++pub const TIOCCONS: ::c_ulong = 0x80047478; ++ ++pub const RTLD_DEEPBIND: ::c_int = 0x10; ++pub const RTLD_GLOBAL: ::c_int = 0x4; ++pub const RTLD_NOLOAD: ::c_int = 0x8; ++ ++pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead; ++pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793; ++pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278; ++pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448; ++pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216; ++ ++pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567; ++pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123; ++pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF; ++pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000; ++pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC; ++pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4; ++pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2; ++pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543; ++ ++pub const MCL_CURRENT: ::c_int = 0x0001; ++pub const MCL_FUTURE: ::c_int = 0x0002; ++ ++pub const SIGSTKSZ: ::size_t = 8192; ++pub const CBAUD: ::tcflag_t = 0o0010017; ++pub const TAB1: ::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 B0: ::speed_t = 0o000000; ++pub const B50: ::speed_t = 0o000001; ++pub const B75: ::speed_t = 0o000002; ++pub const B110: ::speed_t = 0o000003; ++pub const B134: ::speed_t = 0o000004; ++pub const B150: ::speed_t = 0o000005; ++pub const B200: ::speed_t = 0o000006; ++pub const B300: ::speed_t = 0o000007; ++pub const B600: ::speed_t = 0o000010; ++pub const B1200: ::speed_t = 0o000011; ++pub const B1800: ::speed_t = 0o000012; ++pub const B2400: ::speed_t = 0o000013; ++pub const B4800: ::speed_t = 0o000014; ++pub const B9600: ::speed_t = 0o000015; ++pub const B19200: ::speed_t = 0o000016; ++pub const B38400: ::speed_t = 0o000017; ++pub const EXTA: ::speed_t = B19200; ++pub const EXTB: ::speed_t = B38400; ++pub const B57600: ::speed_t = 0o010001; ++pub const B115200: ::speed_t = 0o010002; ++pub const B230400: ::speed_t = 0o010003; ++pub const B460800: ::speed_t = 0o010004; ++pub const B500000: ::speed_t = 0o010005; ++pub const B576000: ::speed_t = 0o010006; ++pub const B921600: ::speed_t = 0o010007; ++pub const B1000000: ::speed_t = 0o010010; ++pub const B1152000: ::speed_t = 0o010011; ++pub const B1500000: ::speed_t = 0o010012; ++pub const B2000000: ::speed_t = 0o010013; ++pub const B2500000: ::speed_t = 0o010014; ++pub const B3000000: ::speed_t = 0o010015; ++pub const B3500000: ::speed_t = 0o010016; ++pub const B4000000: ::speed_t = 0o010017; ++ ++cfg_if! { ++ if #[cfg(target_arch = "mips")] { ++ mod mips32; ++ pub use self::mips32::*; ++ } else if #[cfg(target_arch = "mips64")] { ++ mod mips64; ++ pub use self::mips64::*; ++ } else { ++ // Unknown target_arch ++ } ++} diff --cc vendor/libc-0.2.31/src/unix/uclibc/mod.rs index 000000000,000000000..28b413635 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/uclibc/mod.rs @@@ -1,0 -1,0 +1,1890 @@@ ++use dox::{mem, Option}; ++ ++pub type sa_family_t = u16; ++pub type pthread_key_t = ::c_uint; ++pub type speed_t = ::c_uint; ++pub type tcflag_t = ::c_uint; ++pub type loff_t = ::c_longlong; ++pub type clockid_t = ::c_int; ++pub type key_t = ::c_int; ++pub type id_t = ::c_uint; ++pub type useconds_t = u32; ++pub type dev_t = u64; ++pub type socklen_t = u32; ++pub type 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 type idtype_t = ::c_uint; ++ ++pub enum fpos64_t {} // TODO: fill this out with a struct ++ ++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, ++ ++ pub ai_addr: *mut ::sockaddr, ++ ++ pub ai_canonname: *mut c_char, ++ ++ 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, ++ } ++ ++ 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", ++ 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, ++ } ++ ++ pub struct sigevent { ++ pub sigev_value: ::sigval, ++ pub sigev_signo: ::c_int, ++ pub sigev_notify: ::c_int, ++ // Actually a union. We only expose sigev_notify_thread_id because it's ++ // the most useful member ++ pub sigev_notify_thread_id: ::c_int, ++ #[cfg(target_pointer_width = "64")] ++ __unused1: [::c_int; 11], ++ #[cfg(target_pointer_width = "32")] ++ __unused1: [::c_int; 12] ++ } ++ ++ pub struct 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 = "arm", ++ target_arch = "powerpc"))] ++ __align: [::c_long; 0], ++ #[cfg(not(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc")))] ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_MUTEX_T], ++ } ++ ++ pub struct pthread_rwlock_t { ++ #[cfg(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc"))] ++ __align: [::c_long; 0], ++ #[cfg(not(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc")))] ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], ++ } ++ ++ pub struct pthread_mutexattr_t { ++ #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", ++ target_arch = "mips64", target_arch = "s390x", ++ target_arch = "sparc64"))] ++ __align: [::c_int; 0], ++ #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", ++ target_arch = "mips64", target_arch = "s390x", ++ target_arch = "sparc64")))] ++ __align: [::c_long; 0], ++ size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], ++ } ++ ++ pub struct pthread_rwlockattr_t { ++ __lockkind: ::c_int, ++ __pshared: ::c_int, ++ } ++ ++ pub struct pthread_cond_t { ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_COND_T], ++ } ++ ++ pub struct pthread_condattr_t { ++ __align: [::c_int; 0], ++ size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], ++ } ++ ++ 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: ::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: ::time_t, ++ pub dqb_itime: ::time_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, ++ } ++} ++ ++// intentionally not public, only used for fd_set ++cfg_if! { ++ if #[cfg(target_pointer_width = "32")] { ++ const ULONG_SIZE: usize = 32; ++ } else if #[cfg(target_pointer_width = "64")] { ++ const ULONG_SIZE: usize = 64; ++ } else { ++ // Unknown target_pointer_width ++ } ++} ++ ++pub const EXIT_FAILURE: ::c_int = 1; ++pub const EXIT_SUCCESS: ::c_int = 0; ++pub const RAND_MAX: ::c_int = 2147483647; ++pub const EOF: ::c_int = -1; ++pub const SEEK_SET: ::c_int = 0; ++pub const SEEK_CUR: ::c_int = 1; ++pub const SEEK_END: ::c_int = 2; ++pub const _IOFBF: ::c_int = 0; ++pub const _IONBF: ::c_int = 2; ++pub const _IOLBF: ::c_int = 1; ++ ++pub const F_DUPFD: ::c_int = 0; ++pub const F_GETFD: ::c_int = 1; ++pub const F_SETFD: ::c_int = 2; ++pub const F_GETFL: ::c_int = 3; ++pub const F_SETFL: ::c_int = 4; ++ ++// Linux-specific fcntls ++pub const F_SETLEASE: ::c_int = 1024; ++pub const F_GETLEASE: ::c_int = 1025; ++pub const F_NOTIFY: ::c_int = 1026; ++pub const F_DUPFD_CLOEXEC: ::c_int = 1030; ++ ++// TODO(#235): Include file sealing fcntls once we have a way to verify them. ++ ++pub const SIGTRAP: ::c_int = 5; ++ ++pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; ++pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; ++ ++pub const CLOCK_REALTIME: ::clockid_t = 0; ++pub const CLOCK_MONOTONIC: ::clockid_t = 1; ++pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2; ++pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 3; ++// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep ++// 2014.) See also musl/mod.rs ++// pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; ++// pub const CLOCK_TAI: ::clockid_t = 11; ++pub const TIMER_ABSTIME: ::c_int = 1; ++ ++pub const RLIMIT_CPU: ::c_int = 0; ++pub const RLIMIT_FSIZE: ::c_int = 1; ++pub const RLIMIT_DATA: ::c_int = 2; ++pub const RLIMIT_STACK: ::c_int = 3; ++pub const RLIMIT_CORE: ::c_int = 4; ++pub const RLIMIT_LOCKS: ::c_int = 10; ++pub const RLIMIT_SIGPENDING: ::c_int = 11; ++pub const RLIMIT_MSGQUEUE: ::c_int = 12; ++pub const RLIMIT_NICE: ::c_int = 13; ++pub const RLIMIT_RTPRIO: ::c_int = 14; ++ ++pub const RUSAGE_SELF: ::c_int = 0; ++ ++pub const O_RDONLY: ::c_int = 0; ++pub const O_WRONLY: ::c_int = 1; ++pub const O_RDWR: ::c_int = 2; ++ ++pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; ++ ++pub const S_IFIFO: ::mode_t = 4096; ++pub const S_IFCHR: ::mode_t = 8192; ++pub const S_IFBLK: ::mode_t = 24576; ++pub const S_IFDIR: ::mode_t = 16384; ++pub const S_IFREG: ::mode_t = 32768; ++pub const S_IFLNK: ::mode_t = 40960; ++pub const S_IFSOCK: ::mode_t = 49152; ++pub const S_IFMT: ::mode_t = 61440; ++pub const S_IRWXU: ::mode_t = 448; ++pub const S_IXUSR: ::mode_t = 64; ++pub const S_IWUSR: ::mode_t = 128; ++pub const S_IRUSR: ::mode_t = 256; ++pub const S_IRWXG: ::mode_t = 56; ++pub const S_IXGRP: ::mode_t = 8; ++pub const S_IWGRP: ::mode_t = 16; ++pub const S_IRGRP: ::mode_t = 32; ++pub const S_IRWXO: ::mode_t = 7; ++pub const S_IXOTH: ::mode_t = 1; ++pub const S_IWOTH: ::mode_t = 2; ++pub const S_IROTH: ::mode_t = 4; ++pub const F_OK: ::c_int = 0; ++pub const R_OK: ::c_int = 4; ++pub const W_OK: ::c_int = 2; ++pub const X_OK: ::c_int = 1; ++pub const STDIN_FILENO: ::c_int = 0; ++pub const STDOUT_FILENO: ::c_int = 1; ++pub const STDERR_FILENO: ::c_int = 2; ++pub const SIGHUP: ::c_int = 1; ++pub const SIGINT: ::c_int = 2; ++pub const SIGQUIT: ::c_int = 3; ++pub const SIGILL: ::c_int = 4; ++pub const SIGABRT: ::c_int = 6; ++pub const SIGFPE: ::c_int = 8; ++pub const SIGKILL: ::c_int = 9; ++pub const SIGSEGV: ::c_int = 11; ++pub const SIGPIPE: ::c_int = 13; ++pub const SIGALRM: ::c_int = 14; ++pub const SIGTERM: ::c_int = 15; ++ ++pub const PROT_NONE: ::c_int = 0; ++pub const PROT_READ: ::c_int = 1; ++pub const PROT_WRITE: ::c_int = 2; ++pub const PROT_EXEC: ::c_int = 4; ++ ++pub const LC_CTYPE: ::c_int = 0; ++pub const LC_NUMERIC: ::c_int = 1; ++pub const LC_MONETARY: ::c_int = 2; ++pub const LC_TIME: ::c_int = 3; ++pub const LC_COLLATE: ::c_int = 4; ++pub const LC_MESSAGES: ::c_int = 5; ++pub const LC_ALL: ::c_int = 6; ++pub const LC_CTYPE_MASK: ::c_int = (1 << LC_CTYPE); ++pub const LC_NUMERIC_MASK: ::c_int = (1 << LC_NUMERIC); ++pub const LC_TIME_MASK: ::c_int = (1 << LC_TIME); ++pub const LC_COLLATE_MASK: ::c_int = (1 << LC_COLLATE); ++pub const LC_MONETARY_MASK: ::c_int = (1 << LC_MONETARY); ++pub const LC_MESSAGES_MASK: ::c_int = (1 << LC_MESSAGES); ++// LC_ALL_MASK defined per platform ++ ++pub const MAP_FILE: ::c_int = 0x0000; ++pub const MAP_SHARED: ::c_int = 0x0001; ++pub const MAP_PRIVATE: ::c_int = 0x0002; ++pub const MAP_FIXED: ::c_int = 0x0010; ++ ++pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; ++ ++// MS_ flags for msync(2) ++pub const MS_ASYNC: ::c_int = 0x0001; ++pub const MS_INVALIDATE: ::c_int = 0x0002; ++pub const MS_SYNC: ::c_int = 0x0004; ++ ++// MS_ flags for mount(2) ++pub const MS_RDONLY: ::c_ulong = 0x01; ++pub const MS_NOSUID: ::c_ulong = 0x02; ++pub const MS_NODEV: ::c_ulong = 0x04; ++pub const MS_NOEXEC: ::c_ulong = 0x08; ++pub const MS_SYNCHRONOUS: ::c_ulong = 0x10; ++pub const MS_REMOUNT: ::c_ulong = 0x20; ++pub const MS_MANDLOCK: ::c_ulong = 0x40; ++pub const MS_NOATIME: ::c_ulong = 0x0400; ++pub const MS_NODIRATIME: ::c_ulong = 0x0800; ++pub const MS_BIND: ::c_ulong = 0x1000; ++pub const MS_NOUSER: ::c_ulong = 0x80000000; ++pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000; ++pub const MS_MGC_MSK: ::c_ulong = 0xffff0000; ++pub const MS_RMT_MASK: ::c_ulong = 0x800051; ++ ++pub const EPERM: ::c_int = 1; ++pub const ENOENT: ::c_int = 2; ++pub const ESRCH: ::c_int = 3; ++pub const EINTR: ::c_int = 4; ++pub const EIO: ::c_int = 5; ++pub const ENXIO: ::c_int = 6; ++pub const E2BIG: ::c_int = 7; ++pub const ENOEXEC: ::c_int = 8; ++pub const EBADF: ::c_int = 9; ++pub const ECHILD: ::c_int = 10; ++pub const EAGAIN: ::c_int = 11; ++pub const ENOMEM: ::c_int = 12; ++pub const EACCES: ::c_int = 13; ++pub const EFAULT: ::c_int = 14; ++pub const ENOTBLK: ::c_int = 15; ++pub const EBUSY: ::c_int = 16; ++pub const EEXIST: ::c_int = 17; ++pub const EXDEV: ::c_int = 18; ++pub const ENODEV: ::c_int = 19; ++pub const ENOTDIR: ::c_int = 20; ++pub const EISDIR: ::c_int = 21; ++pub const EINVAL: ::c_int = 22; ++pub const ENFILE: ::c_int = 23; ++pub const EMFILE: ::c_int = 24; ++pub const ENOTTY: ::c_int = 25; ++pub const ETXTBSY: ::c_int = 26; ++pub const EFBIG: ::c_int = 27; ++pub const ENOSPC: ::c_int = 28; ++pub const ESPIPE: ::c_int = 29; ++pub const EROFS: ::c_int = 30; ++pub const EMLINK: ::c_int = 31; ++pub const EPIPE: ::c_int = 32; ++pub const EDOM: ::c_int = 33; ++pub const ERANGE: ::c_int = 34; ++pub const EWOULDBLOCK: ::c_int = EAGAIN; ++ ++pub const SCM_RIGHTS: ::c_int = 0x01; ++pub const SCM_CREDENTIALS: ::c_int = 0x02; ++ ++// netinet/in.h ++// NOTE: These are in addition to the constants defined in src/unix/mod.rs ++ ++// IPPROTO_IP defined in src/unix/mod.rs ++/// Hop-by-hop option header ++pub const IPPROTO_HOPOPTS: ::c_int = 0; ++// IPPROTO_ICMP defined in src/unix/mod.rs ++/// group mgmt protocol ++pub const IPPROTO_IGMP: ::c_int = 2; ++/// for compatibility ++pub const IPPROTO_IPIP: ::c_int = 4; ++// IPPROTO_TCP defined in src/unix/mod.rs ++/// exterior gateway protocol ++pub const IPPROTO_EGP: ::c_int = 8; ++/// pup ++pub const IPPROTO_PUP: ::c_int = 12; ++// IPPROTO_UDP defined in src/unix/mod.rs ++/// xns idp ++pub const IPPROTO_IDP: ::c_int = 22; ++/// tp-4 w/ class negotiation ++pub const IPPROTO_TP: ::c_int = 29; ++/// DCCP ++pub const IPPROTO_DCCP: ::c_int = 33; ++// IPPROTO_IPV6 defined in src/unix/mod.rs ++/// IP6 routing header ++pub const IPPROTO_ROUTING: ::c_int = 43; ++/// IP6 fragmentation header ++pub const IPPROTO_FRAGMENT: ::c_int = 44; ++/// resource reservation ++pub const IPPROTO_RSVP: ::c_int = 46; ++/// General Routing Encap. ++pub const IPPROTO_GRE: ::c_int = 47; ++/// IP6 Encap Sec. Payload ++pub const IPPROTO_ESP: ::c_int = 50; ++/// IP6 Auth Header ++pub const IPPROTO_AH: ::c_int = 51; ++// IPPROTO_ICMPV6 defined in src/unix/mod.rs ++/// IP6 no next header ++pub const IPPROTO_NONE: ::c_int = 59; ++/// IP6 destination option ++pub const IPPROTO_DSTOPTS: ::c_int = 60; ++pub const IPPROTO_MTP: ::c_int = 92; ++pub const IPPROTO_BEETPH: ::c_int = 94; ++/// encapsulation header ++pub const IPPROTO_ENCAP: ::c_int = 98; ++/// Protocol indep. multicast ++pub const IPPROTO_PIM: ::c_int = 103; ++/// IP Payload Comp. Protocol ++pub const IPPROTO_COMP: ::c_int = 108; ++/// SCTP ++pub const IPPROTO_SCTP: ::c_int = 132; ++pub const IPPROTO_MH: ::c_int = 135; ++pub const IPPROTO_UDPLITE: ::c_int = 136; ++pub const IPPROTO_MPLS: ::c_int = 137; ++/// raw IP packet ++pub const IPPROTO_RAW: ::c_int = 255; ++pub const IPPROTO_MAX: ::c_int = 256; ++ ++pub const PROT_GROWSDOWN: ::c_int = 0x1000000; ++pub const PROT_GROWSUP: ::c_int = 0x2000000; ++ ++pub const MAP_TYPE: ::c_int = 0x000f; ++ ++pub const MADV_NORMAL: ::c_int = 0; ++pub const MADV_RANDOM: ::c_int = 1; ++pub const MADV_SEQUENTIAL: ::c_int = 2; ++pub const MADV_WILLNEED: ::c_int = 3; ++pub const MADV_DONTNEED: ::c_int = 4; ++pub const MADV_REMOVE: ::c_int = 9; ++pub const MADV_DONTFORK: ::c_int = 10; ++pub const MADV_DOFORK: ::c_int = 11; ++pub const MADV_MERGEABLE: ::c_int = 12; ++pub const MADV_UNMERGEABLE: ::c_int = 13; ++pub const MADV_HWPOISON: ::c_int = 100; ++ ++pub const IFF_UP: ::c_int = 0x1; ++pub const IFF_BROADCAST: ::c_int = 0x2; ++pub const IFF_DEBUG: ::c_int = 0x4; ++pub const IFF_LOOPBACK: ::c_int = 0x8; ++pub const IFF_POINTOPOINT: ::c_int = 0x10; ++pub const IFF_NOTRAILERS: ::c_int = 0x20; ++pub const IFF_RUNNING: ::c_int = 0x40; ++pub const IFF_NOARP: ::c_int = 0x80; ++pub const IFF_PROMISC: ::c_int = 0x100; ++pub const IFF_ALLMULTI: ::c_int = 0x200; ++pub const IFF_MASTER: ::c_int = 0x400; ++pub const IFF_SLAVE: ::c_int = 0x800; ++pub const IFF_MULTICAST: ::c_int = 0x1000; ++pub const IFF_PORTSEL: ::c_int = 0x2000; ++pub const IFF_AUTOMEDIA: ::c_int = 0x4000; ++pub const IFF_DYNAMIC: ::c_int = 0x8000; ++ ++pub const SOL_IP: ::c_int = 0; ++pub const SOL_TCP: ::c_int = 6; ++pub const SOL_IPV6: ::c_int = 41; ++pub const SOL_ICMPV6: ::c_int = 58; ++pub const SOL_RAW: ::c_int = 255; ++pub const SOL_DECNET: ::c_int = 261; ++pub const SOL_X25: ::c_int = 262; ++pub const SOL_PACKET: ::c_int = 263; ++pub const SOL_ATM: ::c_int = 264; ++pub const SOL_AAL: ::c_int = 265; ++pub const SOL_IRDA: ::c_int = 266; ++ ++pub const AF_UNSPEC: ::c_int = 0; ++pub const AF_UNIX: ::c_int = 1; ++pub const AF_LOCAL: ::c_int = 1; ++pub const AF_INET: ::c_int = 2; ++pub const AF_AX25: ::c_int = 3; ++pub const AF_IPX: ::c_int = 4; ++pub const AF_APPLETALK: ::c_int = 5; ++pub const AF_NETROM: ::c_int = 6; ++pub const AF_BRIDGE: ::c_int = 7; ++pub const AF_ATMPVC: ::c_int = 8; ++pub const AF_X25: ::c_int = 9; ++pub const AF_INET6: ::c_int = 10; ++pub const AF_ROSE: ::c_int = 11; ++pub const AF_DECnet: ::c_int = 12; ++pub const AF_NETBEUI: ::c_int = 13; ++pub const AF_SECURITY: ::c_int = 14; ++pub const AF_KEY: ::c_int = 15; ++pub const AF_NETLINK: ::c_int = 16; ++pub const AF_ROUTE: ::c_int = AF_NETLINK; ++pub const AF_PACKET: ::c_int = 17; ++pub const AF_ASH: ::c_int = 18; ++pub const AF_ECONET: ::c_int = 19; ++pub const AF_ATMSVC: ::c_int = 20; ++pub const AF_SNA: ::c_int = 22; ++pub const AF_IRDA: ::c_int = 23; ++pub const AF_PPPOX: ::c_int = 24; ++pub const AF_WANPIPE: ::c_int = 25; ++pub const AF_LLC: ::c_int = 26; ++pub const AF_CAN: ::c_int = 29; ++pub const AF_TIPC: ::c_int = 30; ++pub const AF_BLUETOOTH: ::c_int = 31; ++pub const AF_IUCV: ::c_int = 32; ++pub const AF_RXRPC: ::c_int = 33; ++pub const AF_ISDN: ::c_int = 34; ++pub const AF_PHONET: ::c_int = 35; ++pub const AF_IEEE802154: ::c_int = 36; ++pub const AF_CAIF: ::c_int = 37; ++pub const AF_ALG: ::c_int = 38; ++ ++pub const PF_UNSPEC: ::c_int = AF_UNSPEC; ++pub const PF_UNIX: ::c_int = AF_UNIX; ++pub const PF_LOCAL: ::c_int = AF_LOCAL; ++pub const PF_INET: ::c_int = AF_INET; ++pub const PF_AX25: ::c_int = AF_AX25; ++pub const PF_IPX: ::c_int = AF_IPX; ++pub const PF_APPLETALK: ::c_int = AF_APPLETALK; ++pub const PF_NETROM: ::c_int = AF_NETROM; ++pub const PF_BRIDGE: ::c_int = AF_BRIDGE; ++pub const PF_ATMPVC: ::c_int = AF_ATMPVC; ++pub const PF_X25: ::c_int = AF_X25; ++pub const PF_INET6: ::c_int = AF_INET6; ++pub const PF_ROSE: ::c_int = AF_ROSE; ++pub const PF_DECnet: ::c_int = AF_DECnet; ++pub const PF_NETBEUI: ::c_int = AF_NETBEUI; ++pub const PF_SECURITY: ::c_int = AF_SECURITY; ++pub const PF_KEY: ::c_int = AF_KEY; ++pub const PF_NETLINK: ::c_int = AF_NETLINK; ++pub const PF_ROUTE: ::c_int = AF_ROUTE; ++pub const PF_PACKET: ::c_int = AF_PACKET; ++pub const PF_ASH: ::c_int = AF_ASH; ++pub const PF_ECONET: ::c_int = AF_ECONET; ++pub const PF_ATMSVC: ::c_int = AF_ATMSVC; ++pub const PF_SNA: ::c_int = AF_SNA; ++pub const PF_IRDA: ::c_int = AF_IRDA; ++pub const PF_PPPOX: ::c_int = AF_PPPOX; ++pub const PF_WANPIPE: ::c_int = AF_WANPIPE; ++pub const PF_LLC: ::c_int = AF_LLC; ++pub const PF_CAN: ::c_int = AF_CAN; ++pub const PF_TIPC: ::c_int = AF_TIPC; ++pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; ++pub const PF_IUCV: ::c_int = AF_IUCV; ++pub const PF_RXRPC: ::c_int = AF_RXRPC; ++pub const PF_ISDN: ::c_int = AF_ISDN; ++pub const PF_PHONET: ::c_int = AF_PHONET; ++pub const PF_IEEE802154: ::c_int = AF_IEEE802154; ++pub const PF_CAIF: ::c_int = AF_CAIF; ++pub const PF_ALG: ::c_int = AF_ALG; ++ ++pub const SOMAXCONN: ::c_int = 128; ++ ++pub const MSG_OOB: ::c_int = 1; ++pub const MSG_PEEK: ::c_int = 2; ++pub const MSG_DONTROUTE: ::c_int = 4; ++pub const MSG_CTRUNC: ::c_int = 8; ++pub const MSG_TRUNC: ::c_int = 0x20; ++pub const MSG_DONTWAIT: ::c_int = 0x40; ++pub const MSG_EOR: ::c_int = 0x80; ++pub const MSG_WAITALL: ::c_int = 0x100; ++pub const MSG_FIN: ::c_int = 0x200; ++pub const MSG_SYN: ::c_int = 0x400; ++pub const MSG_CONFIRM: ::c_int = 0x800; ++pub const MSG_RST: ::c_int = 0x1000; ++pub const MSG_ERRQUEUE: ::c_int = 0x2000; ++pub const MSG_NOSIGNAL: ::c_int = 0x4000; ++pub const MSG_MORE: ::c_int = 0x8000; ++pub const MSG_WAITFORONE: ::c_int = 0x10000; ++pub const MSG_CMSG_CLOEXEC: ::c_int = 0x40000000; ++ ++pub const SOCK_RAW: ::c_int = 3; ++pub const IP_MULTICAST_TTL: ::c_int = 33; ++pub const IP_MULTICAST_LOOP: ::c_int = 34; ++pub const IP_TTL: ::c_int = 2; ++pub const IP_HDRINCL: ::c_int = 3; ++pub const IP_ADD_MEMBERSHIP: ::c_int = 35; ++pub const IP_DROP_MEMBERSHIP: ::c_int = 36; ++ ++pub const IPV6_JOIN_GROUP: ::c_int = 20; ++pub const IPV6_LEAVE_GROUP: ::c_int = 21; ++ ++pub const TCP_NODELAY: ::c_int = 1; ++pub const TCP_MAXSEG: ::c_int = 2; ++pub const TCP_CORK: ::c_int = 3; ++pub const TCP_KEEPIDLE: ::c_int = 4; ++pub const TCP_KEEPINTVL: ::c_int = 5; ++pub const TCP_KEEPCNT: ::c_int = 6; ++pub const TCP_SYNCNT: ::c_int = 7; ++pub const TCP_LINGER2: ::c_int = 8; ++pub const TCP_DEFER_ACCEPT: ::c_int = 9; ++pub const TCP_WINDOW_CLAMP: ::c_int = 10; ++pub const TCP_INFO: ::c_int = 11; ++pub const TCP_QUICKACK: ::c_int = 12; ++pub const TCP_CONGESTION: ::c_int = 13; ++ ++pub const IPV6_MULTICAST_LOOP: ::c_int = 19; ++pub const IPV6_V6ONLY: ::c_int = 26; ++ ++pub const SO_DEBUG: ::c_int = 1; ++ ++pub const SHUT_RD: ::c_int = 0; ++pub const SHUT_WR: ::c_int = 1; ++pub const SHUT_RDWR: ::c_int = 2; ++ ++pub const LOCK_SH: ::c_int = 1; ++pub const LOCK_EX: ::c_int = 2; ++pub const LOCK_NB: ::c_int = 4; ++pub const LOCK_UN: ::c_int = 8; ++ ++pub const SS_ONSTACK: ::c_int = 1; ++pub const SS_DISABLE: ::c_int = 2; ++ ++pub const PATH_MAX: ::c_int = 4096; ++ ++pub const FD_SETSIZE: usize = 1024; ++ ++pub const EPOLLIN: ::c_int = 0x1; ++pub const EPOLLPRI: ::c_int = 0x2; ++pub const EPOLLOUT: ::c_int = 0x4; ++pub const EPOLLRDNORM: ::c_int = 0x40; ++pub const EPOLLRDBAND: ::c_int = 0x80; ++pub const EPOLLWRNORM: ::c_int = 0x100; ++pub const EPOLLWRBAND: ::c_int = 0x200; ++pub const EPOLLMSG: ::c_int = 0x400; ++pub const EPOLLERR: ::c_int = 0x8; ++pub const EPOLLHUP: ::c_int = 0x10; ++pub const EPOLLET: ::c_int = 0x80000000; ++ ++pub const EPOLL_CTL_ADD: ::c_int = 1; ++pub const EPOLL_CTL_MOD: ::c_int = 3; ++pub const EPOLL_CTL_DEL: ::c_int = 2; ++ ++pub const MNT_DETACH: ::c_int = 0x2; ++pub const MNT_EXPIRE: ::c_int = 0x4; ++ ++pub const MNT_FORCE: ::c_int = 0x1; ++ ++pub const Q_SYNC: ::c_int = 0x600; ++pub const Q_QUOTAON: ::c_int = 0x100; ++pub const Q_QUOTAOFF: ::c_int = 0x200; ++pub const Q_GETQUOTA: ::c_int = 0x300; ++pub const Q_SETQUOTA: ::c_int = 0x400; ++ ++pub const TCIOFF: ::c_int = 2; ++pub const TCION: ::c_int = 3; ++pub const TCOOFF: ::c_int = 0; ++pub const TCOON: ::c_int = 1; ++pub const TCIFLUSH: ::c_int = 0; ++pub const TCOFLUSH: ::c_int = 1; ++pub const TCIOFLUSH: ::c_int = 2; ++pub const NL0: ::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 AT_REMOVEDIR: ::c_int = 0x200; ++pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400; ++ ++pub const LOG_CRON: ::c_int = 9 << 3; ++pub const LOG_AUTHPRIV: ::c_int = 10 << 3; ++pub const LOG_FTP: ::c_int = 11 << 3; ++pub const LOG_PERROR: ::c_int = 0x20; ++ ++pub const PIPE_BUF: usize = 4096; ++ ++pub const SI_LOAD_SHIFT: ::c_uint = 16; ++ ++pub const SIGEV_SIGNAL: ::c_int = 0; ++pub const SIGEV_NONE: ::c_int = 1; ++pub const SIGEV_THREAD: ::c_int = 2; ++ ++pub const P_ALL: idtype_t = 0; ++pub const P_PID: idtype_t = 1; ++pub const P_PGID: idtype_t = 2; ++ ++pub const UTIME_OMIT: c_long = 1073741822; ++pub const UTIME_NOW: c_long = 1073741823; ++ ++pub const L_tmpnam: ::c_uint = 20; ++pub const _PC_LINK_MAX: ::c_int = 0; ++pub const _PC_MAX_CANON: ::c_int = 1; ++pub const _PC_MAX_INPUT: ::c_int = 2; ++pub const _PC_NAME_MAX: ::c_int = 3; ++pub const _PC_PATH_MAX: ::c_int = 4; ++pub const _PC_PIPE_BUF: ::c_int = 5; ++pub const _PC_CHOWN_RESTRICTED: ::c_int = 6; ++pub const _PC_NO_TRUNC: ::c_int = 7; ++pub const _PC_VDISABLE: ::c_int = 8; ++ ++pub const _SC_ARG_MAX: ::c_int = 0; ++pub const _SC_CHILD_MAX: ::c_int = 1; ++pub const _SC_CLK_TCK: ::c_int = 2; ++pub const _SC_NGROUPS_MAX: ::c_int = 3; ++pub const _SC_OPEN_MAX: ::c_int = 4; ++pub const _SC_STREAM_MAX: ::c_int = 5; ++pub const _SC_TZNAME_MAX: ::c_int = 6; ++pub const _SC_JOB_CONTROL: ::c_int = 7; ++pub const _SC_SAVED_IDS: ::c_int = 8; ++pub const _SC_REALTIME_SIGNALS: ::c_int = 9; ++pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10; ++pub const _SC_TIMERS: ::c_int = 11; ++pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12; ++pub const _SC_PRIORITIZED_IO: ::c_int = 13; ++pub const _SC_SYNCHRONIZED_IO: ::c_int = 14; ++pub const _SC_FSYNC: ::c_int = 15; ++pub const _SC_MAPPED_FILES: ::c_int = 16; ++pub const _SC_MEMLOCK: ::c_int = 17; ++pub const _SC_MEMLOCK_RANGE: ::c_int = 18; ++pub const _SC_MEMORY_PROTECTION: ::c_int = 19; ++pub const _SC_MESSAGE_PASSING: ::c_int = 20; ++pub const _SC_SEMAPHORES: ::c_int = 21; ++pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22; ++pub const _SC_AIO_LISTIO_MAX: ::c_int = 23; ++pub const _SC_AIO_MAX: ::c_int = 24; ++pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25; ++pub const _SC_DELAYTIMER_MAX: ::c_int = 26; ++pub const _SC_MQ_OPEN_MAX: ::c_int = 27; ++pub const _SC_MQ_PRIO_MAX: ::c_int = 28; ++pub const _SC_VERSION: ::c_int = 29; ++pub const _SC_PAGESIZE: ::c_int = 30; ++pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; ++pub const _SC_RTSIG_MAX: ::c_int = 31; ++pub const _SC_SEM_NSEMS_MAX: ::c_int = 32; ++pub const _SC_SEM_VALUE_MAX: ::c_int = 33; ++pub const _SC_SIGQUEUE_MAX: ::c_int = 34; ++pub const _SC_TIMER_MAX: ::c_int = 35; ++pub const _SC_BC_BASE_MAX: ::c_int = 36; ++pub const _SC_BC_DIM_MAX: ::c_int = 37; ++pub const _SC_BC_SCALE_MAX: ::c_int = 38; ++pub const _SC_BC_STRING_MAX: ::c_int = 39; ++pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40; ++pub const _SC_EXPR_NEST_MAX: ::c_int = 42; ++pub const _SC_LINE_MAX: ::c_int = 43; ++pub const _SC_RE_DUP_MAX: ::c_int = 44; ++pub const _SC_2_VERSION: ::c_int = 46; ++pub const _SC_2_C_BIND: ::c_int = 47; ++pub const _SC_2_C_DEV: ::c_int = 48; ++pub const _SC_2_FORT_DEV: ::c_int = 49; ++pub const _SC_2_FORT_RUN: ::c_int = 50; ++pub const _SC_2_SW_DEV: ::c_int = 51; ++pub const _SC_2_LOCALEDEF: ::c_int = 52; ++pub const _SC_IOV_MAX: ::c_int = 60; ++pub const _SC_THREADS: ::c_int = 67; ++pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68; ++pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69; ++pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70; ++pub const _SC_LOGIN_NAME_MAX: ::c_int = 71; ++pub const _SC_TTY_NAME_MAX: ::c_int = 72; ++pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73; ++pub const _SC_THREAD_KEYS_MAX: ::c_int = 74; ++pub const _SC_THREAD_STACK_MIN: ::c_int = 75; ++pub const _SC_THREAD_THREADS_MAX: ::c_int = 76; ++pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77; ++pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78; ++pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79; ++pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80; ++pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81; ++pub const _SC_NPROCESSORS_ONLN: ::c_int = 84; ++pub const _SC_ATEXIT_MAX: ::c_int = 87; ++pub const _SC_XOPEN_VERSION: ::c_int = 89; ++pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90; ++pub const _SC_XOPEN_UNIX: ::c_int = 91; ++pub const _SC_XOPEN_CRYPT: ::c_int = 92; ++pub const _SC_XOPEN_ENH_I18N: ::c_int = 93; ++pub const _SC_XOPEN_SHM: ::c_int = 94; ++pub const _SC_2_CHAR_TERM: ::c_int = 95; ++pub const _SC_2_UPE: ::c_int = 97; ++pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125; ++pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126; ++pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128; ++pub const _SC_XOPEN_LEGACY: ::c_int = 129; ++pub const _SC_XOPEN_REALTIME: ::c_int = 130; ++pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131; ++pub const _SC_HOST_NAME_MAX: ::c_int = 180; ++ ++pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY; ++pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY; ++ ++pub const GLOB_ERR: ::c_int = 1 << 0; ++pub const GLOB_MARK: ::c_int = 1 << 1; ++pub const GLOB_NOSORT: ::c_int = 1 << 2; ++pub const GLOB_DOOFFS: ::c_int = 1 << 3; ++pub const GLOB_NOCHECK: ::c_int = 1 << 4; ++pub const GLOB_APPEND: ::c_int = 1 << 5; ++pub const GLOB_NOESCAPE: ::c_int = 1 << 6; ++ ++pub const GLOB_NOSPACE: ::c_int = 1; ++pub const GLOB_ABORTED: ::c_int = 2; ++pub const GLOB_NOMATCH: ::c_int = 3; ++ ++pub const POSIX_MADV_NORMAL: ::c_int = 0; ++pub const POSIX_MADV_RANDOM: ::c_int = 1; ++pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; ++pub const POSIX_MADV_WILLNEED: ::c_int = 3; ++ ++pub const S_IEXEC: mode_t = 64; ++pub const S_IWRITE: mode_t = 128; ++pub const S_IREAD: mode_t = 256; ++ ++pub const F_LOCK: ::c_int = 1; ++pub const F_TEST: ::c_int = 3; ++pub const F_TLOCK: ::c_int = 2; ++pub const F_ULOCK: ::c_int = 0; ++ ++pub const ST_RDONLY: ::c_ulong = 1; ++pub const ST_NOSUID: ::c_ulong = 2; ++pub const ST_NODEV: ::c_ulong = 4; ++pub const ST_NOEXEC: ::c_ulong = 8; ++pub const ST_SYNCHRONOUS: ::c_ulong = 16; ++pub const ST_MANDLOCK: ::c_ulong = 64; ++pub const ST_WRITE: ::c_ulong = 128; ++pub const ST_APPEND: ::c_ulong = 256; ++pub const ST_IMMUTABLE: ::c_ulong = 512; ++pub const ST_NOATIME: ::c_ulong = 1024; ++pub const ST_NODIRATIME: ::c_ulong = 2048; ++ ++pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void; ++pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; ++pub const RTLD_NODELETE: ::c_int = 0x1000; ++pub const RTLD_NOW: ::c_int = 0x2; ++ ++pub const TCP_MD5SIG: ::c_int = 14; ++ ++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 SHM_R: ::c_int = 0o400; ++pub const SHM_W: ::c_int = 0o200; ++ ++pub const SHM_RDONLY: ::c_int = 0o10000; ++pub const SHM_RND: ::c_int = 0o20000; ++pub const SHM_REMAP: ::c_int = 0o40000; ++ ++pub const SHM_LOCK: ::c_int = 11; ++pub const SHM_UNLOCK: ::c_int = 12; ++ ++pub const SHM_HUGETLB: ::c_int = 0o4000; ++pub const SHM_NORESERVE: ::c_int = 0o10000; ++ ++pub const EPOLLRDHUP: ::c_int = 0x2000; ++pub const EPOLLONESHOT: ::c_int = 0x40000000; ++ ++pub const QFMT_VFS_OLD: ::c_int = 1; ++pub const QFMT_VFS_V0: ::c_int = 2; ++ ++pub const EFD_SEMAPHORE: ::c_int = 0x1; ++ ++pub const LOG_NFACILITIES: ::c_int = 24; ++ ++pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t; ++ ++pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32; ++pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32; ++pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32; ++pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32; ++pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32; ++ ++pub const AI_PASSIVE: ::c_int = 0x0001; ++pub const AI_CANONNAME: ::c_int = 0x0002; ++pub const AI_NUMERICHOST: ::c_int = 0x0004; ++pub const AI_V4MAPPED: ::c_int = 0x0008; ++pub const AI_ALL: ::c_int = 0x0010; ++pub const AI_ADDRCONFIG: ::c_int = 0x0020; ++ ++pub const AI_NUMERICSERV: ::c_int = 0x0400; ++ ++pub const EAI_BADFLAGS: ::c_int = -1; ++pub const EAI_NONAME: ::c_int = -2; ++pub const EAI_AGAIN: ::c_int = -3; ++pub const EAI_FAIL: ::c_int = -4; ++pub const EAI_FAMILY: ::c_int = -6; ++pub const EAI_SOCKTYPE: ::c_int = -7; ++pub const EAI_SERVICE: ::c_int = -8; ++pub const EAI_MEMORY: ::c_int = -10; ++pub const EAI_OVERFLOW: ::c_int = -12; ++ ++pub const NI_NUMERICHOST: ::c_int = 1; ++pub const NI_NUMERICSERV: ::c_int = 2; ++pub const NI_NOFQDN: ::c_int = 4; ++pub const NI_NAMEREQD: ::c_int = 8; ++pub const NI_DGRAM: ::c_int = 16; ++ ++pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1; ++pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2; ++pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4; ++ ++pub const EAI_SYSTEM: ::c_int = -11; ++ ++pub const MREMAP_MAYMOVE: ::c_int = 1; ++pub const MREMAP_FIXED: ::c_int = 2; ++ ++pub const PR_SET_PDEATHSIG: ::c_int = 1; ++pub const PR_GET_PDEATHSIG: ::c_int = 2; ++ ++pub const PR_GET_DUMPABLE: ::c_int = 3; ++pub const PR_SET_DUMPABLE: ::c_int = 4; ++ ++pub const PR_GET_UNALIGN: ::c_int = 5; ++pub const PR_SET_UNALIGN: ::c_int = 6; ++pub const PR_UNALIGN_NOPRINT: ::c_int = 1; ++pub const PR_UNALIGN_SIGBUS: ::c_int = 2; ++ ++pub const PR_GET_KEEPCAPS: ::c_int = 7; ++pub const PR_SET_KEEPCAPS: ::c_int = 8; ++ ++pub const PR_GET_FPEMU: ::c_int = 9; ++pub const PR_SET_FPEMU: ::c_int = 10; ++pub const PR_FPEMU_NOPRINT: ::c_int = 1; ++pub const PR_FPEMU_SIGFPE: ::c_int = 2; ++ ++pub const PR_GET_FPEXC: ::c_int = 11; ++pub const PR_SET_FPEXC: ::c_int = 12; ++pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80; ++pub const PR_FP_EXC_DIV: ::c_int = 0x010000; ++pub const PR_FP_EXC_OVF: ::c_int = 0x020000; ++pub const PR_FP_EXC_UND: ::c_int = 0x040000; ++pub const PR_FP_EXC_RES: ::c_int = 0x080000; ++pub const PR_FP_EXC_INV: ::c_int = 0x100000; ++pub const PR_FP_EXC_DISABLED: ::c_int = 0; ++pub const PR_FP_EXC_NONRECOV: ::c_int = 1; ++pub const PR_FP_EXC_ASYNC: ::c_int = 2; ++pub const PR_FP_EXC_PRECISE: ::c_int = 3; ++ ++pub const PR_GET_TIMING: ::c_int = 13; ++pub const PR_SET_TIMING: ::c_int = 14; ++pub const PR_TIMING_STATISTICAL: ::c_int = 0; ++pub const PR_TIMING_TIMESTAMP: ::c_int = 1; ++ ++pub const PR_SET_NAME: ::c_int = 15; ++pub const PR_GET_NAME: ::c_int = 16; ++ ++pub const PR_GET_ENDIAN: ::c_int = 19; ++pub const PR_SET_ENDIAN: ::c_int = 20; ++pub const PR_ENDIAN_BIG: ::c_int = 0; ++pub const PR_ENDIAN_LITTLE: ::c_int = 1; ++pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2; ++ ++pub const PR_GET_SECCOMP: ::c_int = 21; ++pub const PR_SET_SECCOMP: ::c_int = 22; ++ ++pub const PR_CAPBSET_READ: ::c_int = 23; ++pub const PR_CAPBSET_DROP: ::c_int = 24; ++ ++pub const PR_GET_TSC: ::c_int = 25; ++pub const PR_SET_TSC: ::c_int = 26; ++pub const PR_TSC_ENABLE: ::c_int = 1; ++pub const PR_TSC_SIGSEGV: ::c_int = 2; ++ ++pub const PR_GET_SECUREBITS: ::c_int = 27; ++pub const PR_SET_SECUREBITS: ::c_int = 28; ++ ++pub const PR_SET_TIMERSLACK: ::c_int = 29; ++pub const PR_GET_TIMERSLACK: ::c_int = 30; ++ ++pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31; ++pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32; ++ ++pub const PR_MCE_KILL: ::c_int = 33; ++pub const PR_MCE_KILL_CLEAR: ::c_int = 0; ++pub const PR_MCE_KILL_SET: ::c_int = 1; ++ ++pub const PR_MCE_KILL_LATE: ::c_int = 0; ++pub const PR_MCE_KILL_EARLY: ::c_int = 1; ++pub const PR_MCE_KILL_DEFAULT: ::c_int = 2; ++ ++pub const PR_MCE_KILL_GET: ::c_int = 34; ++ ++pub const PR_SET_MM: ::c_int = 35; ++pub const PR_SET_MM_START_CODE: ::c_int = 1; ++pub const PR_SET_MM_END_CODE: ::c_int = 2; ++pub const PR_SET_MM_START_DATA: ::c_int = 3; ++pub const PR_SET_MM_END_DATA: ::c_int = 4; ++pub const PR_SET_MM_START_STACK: ::c_int = 5; ++pub const PR_SET_MM_START_BRK: ::c_int = 6; ++pub const PR_SET_MM_BRK: ::c_int = 7; ++pub const PR_SET_MM_ARG_START: ::c_int = 8; ++pub const PR_SET_MM_ARG_END: ::c_int = 9; ++pub const PR_SET_MM_ENV_START: ::c_int = 10; ++pub const PR_SET_MM_ENV_END: ::c_int = 11; ++pub const PR_SET_MM_AUXV: ::c_int = 12; ++pub const PR_SET_MM_EXE_FILE: ::c_int = 13; ++pub const PR_SET_MM_MAP: ::c_int = 14; ++pub const PR_SET_MM_MAP_SIZE: ::c_int = 15; ++ ++pub const PR_SET_PTRACER: ::c_int = 0x59616d61; ++ ++pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36; ++pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37; ++ ++pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38; ++pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39; ++ ++pub const PR_GET_TID_ADDRESS: ::c_int = 40; ++ ++pub const PR_SET_THP_DISABLE: ::c_int = 41; ++pub const PR_GET_THP_DISABLE: ::c_int = 42; ++ ++pub const ABDAY_1: ::nl_item = 0x300; ++pub const ABDAY_2: ::nl_item = 0x301; ++pub const ABDAY_3: ::nl_item = 0x302; ++pub const ABDAY_4: ::nl_item = 0x303; ++pub const ABDAY_5: ::nl_item = 0x304; ++pub const ABDAY_6: ::nl_item = 0x305; ++pub const ABDAY_7: ::nl_item = 0x306; ++ ++pub const DAY_1: ::nl_item = 0x307; ++pub const DAY_2: ::nl_item = 0x308; ++pub const DAY_3: ::nl_item = 0x309; ++pub const DAY_4: ::nl_item = 0x30A; ++pub const DAY_5: ::nl_item = 0x30B; ++pub const DAY_6: ::nl_item = 0x30C; ++pub const DAY_7: ::nl_item = 0x30D; ++ ++pub const ABMON_1: ::nl_item = 0x30E; ++pub const ABMON_2: ::nl_item = 0x30F; ++pub const ABMON_3: ::nl_item = 0x310; ++pub const ABMON_4: ::nl_item = 0x311; ++pub const ABMON_5: ::nl_item = 0x312; ++pub const ABMON_6: ::nl_item = 0x313; ++pub const ABMON_7: ::nl_item = 0x314; ++pub const ABMON_8: ::nl_item = 0x315; ++pub const ABMON_9: ::nl_item = 0x316; ++pub const ABMON_10: ::nl_item = 0x317; ++pub const ABMON_11: ::nl_item = 0x318; ++pub const ABMON_12: ::nl_item = 0x319; ++ ++pub const MON_1: ::nl_item = 0x31A; ++pub const MON_2: ::nl_item = 0x31B; ++pub const MON_3: ::nl_item = 0x31C; ++pub const MON_4: ::nl_item = 0x31D; ++pub const MON_5: ::nl_item = 0x31E; ++pub const MON_6: ::nl_item = 0x31F; ++pub const MON_7: ::nl_item = 0x320; ++pub const MON_8: ::nl_item = 0x321; ++pub const MON_9: ::nl_item = 0x322; ++pub const MON_10: ::nl_item = 0x323; ++pub const MON_11: ::nl_item = 0x324; ++pub const MON_12: ::nl_item = 0x325; ++ ++pub const AM_STR: ::nl_item = 0x326; ++pub const PM_STR: ::nl_item = 0x327; ++ ++pub const D_T_FMT: ::nl_item = 0x328; ++pub const D_FMT: ::nl_item = 0x329; ++pub const T_FMT: ::nl_item = 0x32A; ++pub const T_FMT_AMPM: ::nl_item = 0x32B; ++ ++pub const ERA: ::nl_item = 0x32C; ++pub const ERA_D_FMT: ::nl_item = 0x32E; ++pub const ALT_DIGITS: ::nl_item = 0x32F; ++pub const ERA_D_T_FMT: ::nl_item = 0x330; ++pub const ERA_T_FMT: ::nl_item = 0x331; ++ ++pub const CODESET: ::nl_item = 10; ++ ++pub const CRNCYSTR: ::nl_item = 0x215; ++ ++pub const RADIXCHAR: ::nl_item = 0x100; ++pub const THOUSEP: ::nl_item = 0x101; ++ ++pub const NOEXPR: ::nl_item = 0x501; ++pub const YESSTR: ::nl_item = 0x502; ++pub const NOSTR: ::nl_item = 0x503; ++ ++pub const FILENAME_MAX: ::c_uint = 4095; ++ ++pub const AF_MAX: ::c_int = 39; ++ ++f! { ++ pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { ++ let fd = fd as usize; ++ let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ (*set).fds_bits[fd / size] &= !(1 << (fd % size)); ++ return ++ } ++ ++ pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { ++ let fd = fd as usize; ++ let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 ++ } ++ ++ pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { ++ let fd = fd as usize; ++ let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; ++ (*set).fds_bits[fd / size] |= 1 << (fd % size); ++ return ++ } ++ ++ pub fn FD_ZERO(set: *mut fd_set) -> () { ++ for slot in (*set).fds_bits.iter_mut() { ++ *slot = 0; ++ } ++ } ++ ++ pub fn WIFSTOPPED(status: ::c_int) -> bool { ++ (status & 0xff) == 0x7f ++ } ++ ++ pub fn WSTOPSIG(status: ::c_int) -> ::c_int { ++ (status >> 8) & 0xff ++ } ++ ++ pub fn WIFCONTINUED(status: ::c_int) -> bool { ++ status == 0xffff ++ } ++ ++ pub fn WIFSIGNALED(status: ::c_int) -> bool { ++ ((status & 0x7f) + 1) as i8 >= 2 ++ } ++ ++ pub fn WTERMSIG(status: ::c_int) -> ::c_int { ++ status & 0x7f ++ } ++ ++ pub fn WIFEXITED(status: ::c_int) -> bool { ++ (status & 0x7f) == 0 ++ } ++ ++ pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { ++ (status >> 8) & 0xff ++ } ++ ++ pub fn WCOREDUMP(status: ::c_int) -> bool { ++ (status & 0x80) != 0 ++ } ++ ++ pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { ++ for slot in cpuset.bits.iter_mut() { ++ *slot = 0; ++ } ++ } ++ ++ pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { ++ let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc ++ let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); ++ cpuset.bits[idx] |= 1 << offset; ++ () ++ } ++ ++ pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { ++ let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc ++ let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); ++ cpuset.bits[idx] &= !(1 << offset); ++ () ++ } ++ ++ pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { ++ let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); ++ let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); ++ 0 != (cpuset.bits[idx] & (1 << offset)) ++ } ++ ++ pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { ++ set1.bits == set2.bits ++ } ++ ++ pub fn QCMD(cmd: ::c_int, type_: ::c_int) -> ::c_int { ++ (cmd << 8) | (type_ & 0x00ff) ++ } ++} ++ ++extern { ++ 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 clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; ++ pub fn prctl(option: ::c_int, ...) -> ::c_int; ++ pub fn pthread_getattr_np(native: ::pthread_t, ++ attr: *mut ::pthread_attr_t) -> ::c_int; ++ pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, ++ guardsize: *mut ::size_t) -> ::c_int; ++ pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, ++ stackaddr: *mut *mut ::c_void, ++ stacksize: *mut ::size_t) -> ::c_int; ++ pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; ++ pub fn setgroups(ngroups: ::size_t, ++ ptr: *const ::gid_t) -> ::c_int; ++ pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; ++ pub fn sched_setscheduler(pid: ::pid_t, ++ policy: ::c_int, ++ param: *const ::sched_param) -> ::c_int; ++ pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; ++ pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int; ++ pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int; ++ pub fn epoll_create(size: ::c_int) -> ::c_int; ++ pub fn epoll_create1(flags: ::c_int) -> ::c_int; ++ pub fn epoll_ctl(epfd: ::c_int, ++ op: ::c_int, ++ fd: ::c_int, ++ event: *mut ::epoll_event) -> ::c_int; ++ pub fn epoll_wait(epfd: ::c_int, ++ events: *mut ::epoll_event, ++ maxevents: ::c_int, ++ timeout: ::c_int) -> ::c_int; ++ pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; ++ pub fn mount(src: *const ::c_char, ++ target: *const ::c_char, ++ fstype: *const ::c_char, ++ flags: ::c_ulong, ++ data: *const ::c_void) -> ::c_int; ++ pub fn umount(target: *const ::c_char) -> ::c_int; ++ pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int; ++ pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int, ++ child_stack: *mut ::c_void, ++ flags: ::c_int, ++ arg: *mut ::c_void, ...) -> ::c_int; ++ pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; ++ pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; ++ pub fn memrchr(cx: *const ::c_void, ++ c: ::c_int, ++ n: ::size_t) -> *mut ::c_void; ++ pub fn syscall(num: ::c_long, ...) -> ::c_long; ++ pub fn sendfile(out_fd: ::c_int, ++ in_fd: ::c_int, ++ offset: *mut off_t, ++ count: ::size_t) -> ::ssize_t; ++ pub fn splice(fd_in: ::c_int, ++ off_in: *mut ::loff_t, ++ fd_out: ::c_int, ++ off_out: *mut ::loff_t, ++ len: ::size_t, ++ flags: ::c_uint) -> ::ssize_t; ++ pub fn tee(fd_in: ::c_int, ++ fd_out: ::c_int, ++ len: ::size_t, ++ flags: ::c_uint) -> ::ssize_t; ++ pub fn vmsplice(fd: ::c_int, ++ iov: *const ::iovec, ++ nr_segs: ::size_t, ++ flags: ::c_uint) -> ::ssize_t; ++ ++ pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, ++ advise: ::c_int) -> ::c_int; ++ pub fn 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 openat64(fd: ::c_int, ++ path: *const c_char, ++ oflag: ::c_int, ...) -> ::c_int; ++ pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, ++ offset: off64_t) -> ::ssize_t; ++ pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t, ++ offset: off64_t) -> ::ssize_t; ++ pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64; ++ pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64, ++ result: *mut *mut ::dirent64) -> ::c_int; ++ pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; ++ pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; ++ pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; ++ pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; ++ ++ pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; ++ ++ pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t, dev: dev_t) -> ::c_int; ++ pub fn ppoll(fds: *mut ::pollfd, ++ nfds: nfds_t, ++ timeout: *const ::timespec, ++ sigmask: *const sigset_t) -> ::c_int; ++ pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t, ++ clock_id: *mut clockid_t) -> ::c_int; ++ pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, ++ clock_id: ::clockid_t) -> ::c_int; ++ pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, ++ pshared: ::c_int) -> ::c_int; ++ pub fn pthread_condattr_getpshared(attr: *const pthread_condattr_t, ++ pshared: *mut ::c_int) -> ::c_int; ++ pub fn sched_getaffinity(pid: ::pid_t, ++ cpusetsize: ::size_t, ++ cpuset: *mut cpu_set_t) -> ::c_int; ++ pub fn sched_setaffinity(pid: ::pid_t, ++ cpusetsize: ::size_t, ++ cpuset: *const cpu_set_t) -> ::c_int; ++ pub fn unshare(flags: ::c_int) -> ::c_int; ++ pub fn sem_timedwait(sem: *mut sem_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn accept4(fd: ::c_int, addr: *mut ::sockaddr, len: *mut ::socklen_t, ++ flg: ::c_int) -> ::c_int; ++ pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, ++ abstime: *const ::timespec) -> ::c_int; ++ pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, ++ pshared: ::c_int) -> ::c_int; ++ pub fn pthread_mutexattr_getpshared(attr: *const pthread_mutexattr_t, ++ pshared: *mut ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_getkind_np(attr: *const pthread_rwlockattr_t, ++ val: *mut ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_setkind_np(attr: *mut pthread_rwlockattr_t, ++ val: ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_getpshared(attr: *const pthread_rwlockattr_t, ++ val: *mut ::c_int) -> ::c_int; ++ pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, ++ val: ::c_int) -> ::c_int; ++ pub fn ptsname_r(fd: ::c_int, ++ buf: *mut ::c_char, ++ buflen: ::size_t) -> ::c_int; ++ pub fn clearenv() -> ::c_int; ++ pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, ++ options: ::c_int) -> ::c_int; ++ ++ pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; ++ ++ pub fn setpwent(); ++ pub fn endpwent(); ++ pub fn getpwent() -> *mut passwd; ++ pub fn setspent(); ++ pub fn endspent(); ++ pub fn getspent() -> *mut spwd; ++ pub fn getspnam(__name: *const ::c_char) -> *mut spwd; ++ ++ pub fn shm_open(name: *const c_char, oflag: ::c_int, ++ mode: mode_t) -> ::c_int; ++ ++ // System V IPC ++ pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; ++ pub fn shmat(shmid: ::c_int, ++ shmaddr: *const ::c_void, ++ shmflg: ::c_int) -> *mut ::c_void; ++ pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; ++ pub fn shmctl(shmid: ::c_int, ++ cmd: ::c_int, ++ buf: *mut ::shmid_ds) -> ::c_int; ++ pub fn ftok(pathname: *const ::c_char, proj_id: ::c_int) -> ::key_t; ++ pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut msqid_ds) -> ::c_int; ++ pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; ++ pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t, ++ msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t; ++ pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t, ++ msgflg: ::c_int) -> ::c_int; ++ ++ pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) ++ -> ::c_int; ++ pub fn __errno_location() -> *mut ::c_int; ++ ++ pub fn fopen64(filename: *const c_char, ++ mode: *const c_char) -> *mut ::FILE; ++ pub fn freopen64(filename: *const c_char, mode: *const c_char, ++ file: *mut ::FILE) -> *mut ::FILE; ++ pub fn tmpfile64() -> *mut ::FILE; ++ pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int; ++ pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int; ++ pub fn fseeko64(stream: *mut ::FILE, ++ offset: ::off64_t, ++ whence: ::c_int) -> ::c_int; ++ pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; ++ pub fn readahead(fd: ::c_int, offset: ::off64_t, ++ count: ::size_t) -> ::ssize_t; ++ pub fn getxattr(path: *const c_char, name: *const c_char, ++ value: *mut ::c_void, size: ::size_t) -> ::ssize_t; ++ pub fn lgetxattr(path: *const c_char, name: *const c_char, ++ value: *mut ::c_void, size: ::size_t) -> ::ssize_t; ++ pub fn fgetxattr(filedes: ::c_int, name: *const c_char, ++ value: *mut ::c_void, size: ::size_t) -> ::ssize_t; ++ pub fn setxattr(path: *const c_char, name: *const c_char, ++ value: *const ::c_void, size: ::size_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn lsetxattr(path: *const c_char, name: *const c_char, ++ value: *const ::c_void, size: ::size_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn fsetxattr(filedes: ::c_int, name: *const c_char, ++ value: *const ::c_void, size: ::size_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn listxattr(path: *const c_char, list: *mut c_char, ++ size: ::size_t) -> ::ssize_t; ++ pub fn llistxattr(path: *const c_char, list: *mut c_char, ++ size: ::size_t) -> ::ssize_t; ++ pub fn flistxattr(filedes: ::c_int, list: *mut c_char, ++ size: ::size_t) -> ::ssize_t; ++ pub fn removexattr(path: *const c_char, name: *const c_char) -> ::c_int; ++ pub fn lremovexattr(path: *const c_char, name: *const c_char) -> ::c_int; ++ pub fn fremovexattr(filedes: ::c_int, name: *const c_char) -> ::c_int; ++ pub fn signalfd(fd: ::c_int, ++ mask: *const ::sigset_t, ++ flags: ::c_int) -> ::c_int; ++ pub fn quotactl(cmd: ::c_int, ++ special: *const ::c_char, ++ id: ::c_int, ++ data: *mut ::c_char) -> ::c_int; ++ pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; ++ pub fn mq_close(mqd: ::mqd_t) -> ::c_int; ++ pub fn mq_unlink(name: *const ::c_char) -> ::c_int; ++ pub fn mq_receive(mqd: ::mqd_t, ++ msg_ptr: *mut ::c_char, ++ msg_len: ::size_t, ++ msq_prio: *mut ::c_uint) -> ::ssize_t; ++ pub fn mq_send(mqd: ::mqd_t, ++ msg_ptr: *const ::c_char, ++ msg_len: ::size_t, ++ msq_prio: ::c_uint) -> ::c_int; ++ pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; ++ pub fn mq_setattr(mqd: ::mqd_t, ++ newattr: *const ::mq_attr, ++ oldattr: *mut ::mq_attr) -> ::c_int; ++ pub fn epoll_pwait(epfd: ::c_int, ++ events: *mut ::epoll_event, ++ maxevents: ::c_int, ++ timeout: ::c_int, ++ sigmask: *const ::sigset_t) -> ::c_int; ++ pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; ++ pub fn sigtimedwait(set: *const sigset_t, ++ info: *mut siginfo_t, ++ timeout: *const ::timespec) -> ::c_int; ++ pub fn sigwaitinfo(set: *const sigset_t, ++ info: *mut siginfo_t) -> ::c_int; ++ pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; ++ pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit, ++ old_limit: *mut ::rlimit) -> ::c_int; ++ pub fn prlimit64(pid: ::pid_t, ++ resource: ::c_int, ++ new_limit: *const ::rlimit64, ++ old_limit: *mut ::rlimit64) -> ::c_int; ++ pub fn reboot(how_to: ::c_int) -> ::c_int; ++ pub fn setfsgid(gid: ::gid_t) -> ::c_int; ++ pub fn setfsuid(uid: ::uid_t) -> ::c_int; ++ pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; ++ pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; ++ ++ // Not available now on Android ++ pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, ++ mode: ::mode_t) -> ::c_int; ++ pub fn if_nameindex() -> *mut if_nameindex; ++ pub fn if_freenameindex(ptr: *mut if_nameindex); ++ pub fn sync_file_range(fd: ::c_int, offset: ::off64_t, ++ nbytes: ::off64_t, flags: ::c_uint) -> ::c_int; ++ pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; ++ pub fn freeifaddrs(ifa: *mut ::ifaddrs); ++ ++ pub fn mremap(addr: *mut ::c_void, ++ len: ::size_t, ++ new_len: ::size_t, ++ flags: ::c_int, ++ ...) -> *mut ::c_void; ++ ++ pub fn glob(pattern: *const c_char, ++ flags: ::c_int, ++ errfunc: Option ::c_int>, ++ pglob: *mut ::glob_t) -> ::c_int; ++ pub fn globfree(pglob: *mut ::glob_t); ++ ++ pub fn shm_unlink(name: *const ::c_char) -> ::c_int; ++ ++ pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); ++ ++ pub fn telldir(dirp: *mut ::DIR) -> ::c_long; ++ pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) ++ -> ::c_int; ++ ++ pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; ++ ++ pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, ++ flags: ::c_int, addr: *mut ::sockaddr, ++ addrlen: *mut ::socklen_t) -> ::ssize_t; ++ pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; ++ ++ pub fn bind(socket: ::c_int, address: *const ::sockaddr, ++ address_len: ::socklen_t) -> ::c_int; ++ ++ pub fn writev(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ pub fn readv(fd: ::c_int, ++ iov: *const ::iovec, ++ iovcnt: ::c_int) -> ::ssize_t; ++ ++ pub fn sendmsg(fd: ::c_int, ++ msg: *const ::msghdr, ++ flags: ::c_int) -> ::ssize_t; ++ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) ++ -> ::ssize_t; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] ++ pub fn getgrgid_r(uid: ::uid_t, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "sigaltstack$UNIX2003")] ++ #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] ++ pub fn sigaltstack(ss: *const stack_t, ++ oss: *mut stack_t) -> ::c_int; ++ pub fn sem_close(sem: *mut sem_t) -> ::c_int; ++ pub fn getdtablesize() -> ::c_int; ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] ++ pub fn getgrnam_r(name: *const ::c_char, ++ grp: *mut ::group, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut ::group) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "pthread_sigmask$UNIX2003")] ++ pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, ++ oldset: *mut sigset_t) -> ::c_int; ++ pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; ++ pub fn getgrnam(name: *const ::c_char) -> *mut ::group; ++ pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; ++ pub fn sem_unlink(name: *const ::c_char) -> ::c_int; ++ pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")] ++ pub fn getpwnam_r(name: *const ::c_char, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")] ++ pub fn getpwuid_r(uid: ::uid_t, ++ pwd: *mut passwd, ++ buf: *mut ::c_char, ++ buflen: ::size_t, ++ result: *mut *mut passwd) -> ::c_int; ++ #[cfg_attr(all(target_os = "macos", target_arch ="x86"), ++ link_name = "sigwait$UNIX2003")] ++ #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")] ++ pub fn sigwait(set: *const sigset_t, ++ sig: *mut ::c_int) -> ::c_int; ++ pub fn pthread_atfork(prepare: Option, ++ parent: Option, ++ child: Option) -> ::c_int; ++ pub fn pthread_create(native: *mut ::pthread_t, ++ attr: *const ::pthread_attr_t, ++ f: extern fn(*mut ::c_void) -> *mut ::c_void, ++ value: *mut ::c_void) -> ::c_int; ++ pub fn getgrgid(gid: ::gid_t) -> *mut ::group; ++ #[cfg_attr(all(target_os = "macos", target_arch = "x86"), ++ link_name = "popen$UNIX2003")] ++ pub fn popen(command: *const c_char, ++ mode: *const c_char) -> *mut ::FILE; ++} ++ ++cfg_if! { ++ if #[cfg(target_arch = "mips")] { ++ mod mips; ++ pub use self::mips::*; ++ } else if #[cfg(target_arch = "x86_64")] { ++ mod x86_64; ++ pub use self::x86_64::*; ++ } else { ++ pub use unsupported_target; ++ } ++} ++ diff --cc vendor/libc-0.2.31/src/unix/uclibc/x86_64/l4re.rs index 000000000,000000000..f047a82e0 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/uclibc/x86_64/l4re.rs @@@ -1,0 -1,0 +1,46 @@@ ++/// L4Re specifics ++/// This module contains definitions required by various L4Re libc backends. ++/// Some of them are formally not part of the libc, but are a dependency of the ++/// libc and hence we should provide them here. ++ ++pub type l4_umword_t = ::c_ulong; // Unsigned machine word. ++ ++s! { ++ /// CPU sets. ++ pub struct l4_sched_cpu_set_t { ++ // from the L4Re docs ++ /// Combination of granularity and offset. ++ /// ++ /// The granularity defines how many CPUs each bit in map describes. ++ /// The offset is the numer of the first CPU described by the first ++ /// bit in the bitmap. ++ /// offset must be a multiple of 2^graularity. ++ /// ++ /// | MSB | LSB | ++ /// | ---------------- | ------------------- | ++ /// | 8bit granularity | 24bit offset .. | ++ gran_offset: l4_umword_t , ++ /// Bitmap of CPUs. ++ map: l4_umword_t , ++ } ++} ++ ++#[cfg(target_os = "l4re")] ++pub struct pthread_attr_t { ++ pub __detachstate: ::c_int, ++ pub __schedpolicy: ::c_int, ++ pub __schedparam: super::__sched_param, ++ pub __inheritsched: ::c_int, ++ pub __scope: ::c_int, ++ pub __guardsize: ::size_t, ++ pub __stackaddr_set: ::c_int, ++ pub __stackaddr: *mut ::c_void, // better don't use it ++ pub __stacksize: ::size_t, ++ // L4Re specifics ++ pub affinity: l4_sched_cpu_set_t, ++ pub create_flags: ::c_uint, ++} ++ ++// L4Re requires a min stack size of 64k; that isn't defined in uClibc, but ++// somewhere in the core libraries. uClibc wants 16k, but that's not enough. ++pub const PTHREAD_STACK_MIN: usize = 65536; diff --cc vendor/libc-0.2.31/src/unix/uclibc/x86_64/mod.rs index 000000000,000000000..7d082589d new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/unix/uclibc/x86_64/mod.rs @@@ -1,0 -1,0 +1,357 @@@ ++//! Definitions for uclibc on 64bit systems ++//! ++pub type blkcnt_t = i64; ++pub type blksize_t = i64; ++pub type clock_t = i64; ++pub type c_char = u8; ++pub type c_long = i64; ++pub type c_ulong = u64; ++pub type fsblkcnt_t = ::c_ulong; ++pub type fsfilcnt_t = ::c_ulong; ++pub type fsword_t = ::c_long; ++pub type ino_t = ::c_ulong; ++pub type nlink_t = ::c_uint; ++pub type off_t = ::c_long; ++pub type rlim_t = c_ulong; ++pub type rlim64_t = u64; ++// [uClibc docs] Note stat64 has the same shape as stat for x86-64. ++pub type stat64 = stat; ++pub type suseconds_t = ::c_long; ++pub type time_t = ::c_int; ++pub type wchar_t = ::c_int; ++ ++pub type nfds_t = ::c_ulong; ++ ++s! { ++ pub struct dirent { ++ pub d_ino: ::ino64_t, ++ pub d_off: ::off64_t, ++ pub d_reclen: u16, ++ pub d_type: u8, ++ pub d_name: [::c_char; 256], ++ } ++ ++ pub struct dirent64 { ++ pub d_ino: ::ino64_t, ++ pub d_off: ::off64_t, ++ pub d_reclen: u16, ++ pub d_type: u8, ++ pub d_name: [::c_char; 256], ++ } ++ ++ pub struct ipc_perm { ++ pub __key: ::key_t, ++ pub uid: ::uid_t, ++ pub gid: ::gid_t, ++ pub cuid: ::uid_t, ++ pub cgid: ::gid_t, ++ pub mode: ::c_ushort, // read / write ++ __pad1: ::c_ushort, ++ pub __seq: ::c_ushort, ++ __pad2: ::c_ushort, ++ __unused1: ::c_ulong, ++ __unused2: ::c_ulong ++ } ++ ++ #[cfg(not(target_os = "l4re"))] ++ pub struct pthread_attr_t { ++ __detachstate: ::c_int, ++ __schedpolicy: ::c_int, ++ __schedparam: __sched_param, ++ __inheritsched: ::c_int, ++ __scope: ::c_int, ++ __guardsize: ::size_t, ++ __stackaddr_set: ::c_int, ++ __stackaddr: *mut ::c_void, // better don't use it ++ __stacksize: ::size_t, ++ } ++ ++ pub struct __sched_param { ++ __sched_priority: ::c_int, ++ } ++ ++ pub struct siginfo_t { ++ si_signo: ::c_int, // signal number ++ si_errno: ::c_int, // if not zero: error value of signal, see errno.h ++ si_code: ::c_int, // signal code ++ pub _pad: [::c_int; 28], // unported union ++ _align: [usize; 0], ++ } ++ ++ pub struct shmid_ds { ++ pub shm_perm: ::ipc_perm, ++ pub shm_segsz: ::size_t, // segment size in bytes ++ pub shm_atime: ::time_t, // time of last shmat() ++ pub shm_dtime: ::time_t, ++ pub shm_ctime: ::time_t, ++ pub shm_cpid: ::pid_t, ++ pub shm_lpid: ::pid_t, ++ pub shm_nattch: ::shmatt_t, ++ __unused1: ::c_ulong, ++ __unused2: ::c_ulong ++ } ++ ++ pub struct msqid_ds { ++ pub msg_perm: ::ipc_perm, ++ pub msg_stime: ::time_t, ++ pub msg_rtime: ::time_t, ++ pub msg_ctime: ::time_t, ++ __msg_cbytes: ::c_ulong, ++ pub msg_qnum: ::msgqnum_t, ++ pub msg_qbytes: ::msglen_t, ++ pub msg_lspid: ::pid_t, ++ pub msg_lrpid: ::pid_t, ++ __ignored1: ::c_ulong, ++ __ignored2: ::c_ulong, ++ } ++ ++ pub struct sockaddr { ++ pub sa_family: ::sa_family_t, ++ pub sa_data: [::c_char; 14], ++ } ++ ++ pub struct sockaddr_in { ++ pub sin_family: ::sa_family_t, ++ pub sin_port: ::in_port_t, ++ pub sin_addr: ::in_addr, ++ pub sin_zero: [u8; 8], ++ } ++ ++ pub struct sockaddr_in6 { ++ pub sin6_family: ::sa_family_t, ++ pub sin6_port: ::in_port_t, ++ pub sin6_flowinfo: u32, ++ pub sin6_addr: ::in6_addr, ++ pub sin6_scope_id: u32, ++ } ++ ++ // ------------------------------------------------------------ ++ // definitions below are *unverified* and might **break** the software ++// pub struct in_addr { ++// pub s_addr: in_addr_t, ++// } ++// ++// pub struct in6_addr { ++// pub s6_addr: [u8; 16], ++// __align: [u32; 0], ++// } ++ ++ pub struct stat { ++ pub st_dev: ::c_ulong, ++ pub st_ino: ::ino_t, ++ // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of ++ // nlink and mode are swapped on 64 bit systems. ++ pub st_nlink: ::nlink_t, ++ pub st_mode: ::mode_t, ++ pub st_uid: ::uid_t, ++ pub st_gid: ::gid_t, ++ pub st_rdev: ::c_ulong, // dev_t ++ pub st_size: off_t, // file size ++ pub st_blksize: ::blksize_t, ++ pub st_blocks: ::blkcnt_t, ++ pub st_atime: ::time_t, ++ pub st_atime_nsec: ::c_ulong, ++ pub st_mtime: ::time_t, ++ pub st_mtime_nsec: ::c_ulong, ++ pub st_ctime: ::time_t, ++ pub st_ctime_nsec: ::c_ulong, ++ st_pad4: [::c_long; 3] ++ } ++ ++ pub struct sigaction { ++ pub sa_handler: ::sighandler_t, ++ pub sa_flags: ::c_ulong, ++ pub sa_restorer: *mut ::c_void, ++ pub sa_mask: ::sigset_t, ++ } ++ ++ pub struct stack_t { // ToDo ++ pub ss_sp: *mut ::c_void, ++ pub ss_flags: ::c_int, ++ pub ss_size: ::size_t ++ } ++ ++ pub struct statfs { // ToDo ++ pub f_type: fsword_t, ++ pub f_bsize: fsword_t, ++ pub f_blocks: ::fsblkcnt_t, ++ pub f_bfree: ::fsblkcnt_t, ++ pub f_bavail: ::fsblkcnt_t, ++ pub f_files: ::fsfilcnt_t, ++ pub f_ffree: ::fsfilcnt_t, ++ pub f_fsid: ::fsid_t, ++ pub f_namelen: fsword_t, ++ pub f_frsize: fsword_t, ++ f_spare: [fsword_t; 5], ++ } ++ ++ pub struct msghdr { // ToDo ++ pub msg_name: *mut ::c_void, ++ pub msg_namelen: ::socklen_t, ++ pub msg_iov: *mut ::iovec, ++ pub msg_iovlen: ::size_t, ++ pub msg_control: *mut ::c_void, ++ pub msg_controllen: ::size_t, ++ pub msg_flags: ::c_int, ++ } ++ ++ pub struct termios { // ToDo ++ pub c_iflag: ::tcflag_t, ++ pub c_oflag: ::tcflag_t, ++ pub c_cflag: ::tcflag_t, ++ pub c_lflag: ::tcflag_t, ++ pub c_line: ::cc_t, ++ pub c_cc: [::cc_t; ::NCCS], ++ } ++ ++ pub struct sem_t { // ToDo ++ #[cfg(target_pointer_width = "32")] ++ __size: [::c_char; 16], ++ #[cfg(target_pointer_width = "64")] ++ __size: [::c_char; 32], ++ __align: [::c_long; 0], ++ } ++ ++ pub struct pthread_mutex_t { // ToDo ++ #[cfg(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc"))] ++ __align: [::c_long; 0], ++ #[cfg(not(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc")))] ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_MUTEX_T], ++ } ++ ++ pub struct pthread_mutexattr_t { // ToDo ++ #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", ++ target_arch = "mips64", target_arch = "s390x", ++ target_arch = "sparc64"))] ++ __align: [::c_int; 0], ++ #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", ++ target_arch = "mips64", target_arch = "s390x", ++ target_arch = "sparc64")))] ++ __align: [::c_long; 0], ++ size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], ++ } ++ ++ pub struct pthread_cond_t { // ToDo ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_COND_T], ++ } ++ ++ pub struct pthread_condattr_t { // ToDo ++ __align: [::c_int; 0], ++ size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], ++ } ++ ++ pub struct pthread_rwlock_t { // ToDo ++ #[cfg(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc"))] ++ __align: [::c_long; 0], ++ #[cfg(not(any(target_arch = "mips", target_arch = "arm", ++ target_arch = "powerpc")))] ++ __align: [::c_longlong; 0], ++ size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], ++ } ++ ++ pub struct sigset_t { // ToDo ++ __val: [::c_ulong; 16], ++ } ++ ++ pub struct sysinfo { // ToDo ++ pub uptime: ::c_long, ++ pub loads: [::c_ulong; 3], ++ pub totalram: ::c_ulong, ++ pub freeram: ::c_ulong, ++ pub sharedram: ::c_ulong, ++ pub bufferram: ::c_ulong, ++ pub totalswap: ::c_ulong, ++ pub freeswap: ::c_ulong, ++ pub procs: ::c_ushort, ++ pub pad: ::c_ushort, ++ pub totalhigh: ::c_ulong, ++ pub freehigh: ::c_ulong, ++ pub mem_unit: ::c_uint, ++ pub _f: [::c_char; 0], ++ } ++ ++ pub struct glob_t { // ToDo ++ pub gl_pathc: ::size_t, ++ pub gl_pathv: *mut *mut c_char, ++ pub gl_offs: ::size_t, ++ pub gl_flags: ::c_int, ++ __unused1: *mut ::c_void, ++ __unused2: *mut ::c_void, ++ __unused3: *mut ::c_void, ++ __unused4: *mut ::c_void, ++ __unused5: *mut ::c_void, ++ } ++ ++ pub struct rlimit64 { // ToDo ++ pub rlim_cur: rlim64_t, ++ pub rlim_max: rlim64_t, ++ } ++ ++ pub struct cpu_set_t { // ToDo ++ #[cfg(target_pointer_width = "32")] ++ bits: [u32; 32], ++ #[cfg(target_pointer_width = "64")] ++ bits: [u64; 16], ++ } ++ ++ pub struct fsid_t { // ToDo ++ __val: [::c_int; 2], ++ } ++} ++ ++// constants ++pub const EADDRINUSE: ::c_int = 98; // Address already in use ++pub const EADDRNOTAVAIL: ::c_int = 99; // Cannot assign requested address ++pub const ECONNABORTED: ::c_int = 103; // Software caused connection abort ++pub const ECONNREFUSED: ::c_int = 111; // Connection refused ++pub const ECONNRESET: ::c_int = 104; // Connection reset by peer ++pub const EDEADLK: ::c_int = 35; // Resource deadlock would occur ++pub const ENOSYS: ::c_int = 38; // Function not implemented ++pub const ENOTCONN: ::c_int = 107; // Transport endpoint is not connected ++pub const ETIMEDOUT: ::c_int = 110; // connection timed out ++pub const O_APPEND: ::c_int = 02000; ++pub const O_ACCMODE: ::c_int = 0003; ++pub const O_CLOEXEC: ::c_int = 0x80000; ++pub const O_CREAT: ::c_int = 0100; ++pub const O_DIRECTORY: ::c_int = 0200000; ++pub const O_EXCL: ::c_int = 0200; ++pub const O_NONBLOCK: ::c_int = 04000; ++pub const O_TRUNC: ::c_int = 01000; ++pub const NCCS: usize = 32; ++pub const SIG_SETMASK: ::c_int = 2; // Set the set of blocked signals ++pub const PTHREAD_STACK_MIN: usize = 16384; ++pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; ++pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; ++pub const SO_BROADCAST: ::c_int = 6; ++pub const SOCK_DGRAM: ::c_int = 2; // connectionless, unreliable datagrams ++pub const SOCK_STREAM: ::c_int = 1; // …/common/bits/socket_type.h ++pub const SO_ERROR: ::c_int = 4; ++pub const SOL_SOCKET: ::c_int = 1; ++pub const SO_RCVTIMEO: ::c_int = 20; ++pub const SO_REUSEADDR: ::c_int = 2; ++pub const SO_SNDTIMEO: ::c_int = 21; ++pub const 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 RLIM_INFINITY: u64 = 0xffffffffffffffff; ++pub const __SIZEOF_PTHREAD_COND_T: usize = 48; ++pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; ++pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; ++ ++extern { ++ pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; ++} ++ ++cfg_if! { ++ if #[cfg(target_os = "l4re")] { ++ mod l4re; ++ pub use self::l4re::*; ++ } else { } ++} ++ diff --cc vendor/libc-0.2.31/src/windows.rs index 000000000,000000000..bdb0e02f1 new file mode 100644 --- /dev/null +++ b/vendor/libc-0.2.31/src/windows.rs @@@ -1,0 -1,0 +1,248 @@@ ++//! 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 tm { ++ tm_sec: ::c_int, ++ tm_min: ::c_int, ++ tm_hour: ::c_int, ++ tm_mday: ::c_int, ++ tm_mon: ::c_int, ++ tm_year: ::c_int, ++ tm_wday: ::c_int, ++ tm_yday: ::c_int, ++ tm_isdst: ::c_int, ++ } ++ ++ pub struct timeval { ++ pub tv_sec: c_long, ++ pub tv_usec: c_long, ++ } ++ ++ pub struct timespec { ++ pub tv_sec: time_t, ++ pub tv_nsec: c_long, ++ } ++} ++ ++pub 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; ++ ++// inline comment below appeases style checker ++#[cfg(all(target_env = "msvc", feature = "stdbuild"))] // " if " ++#[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))] ++#[link(name = "libcmt", cfg(target_feature = "crt-static"))] ++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 --cc vendor/libgit2-sys-0.6.16/.cargo-checksum.json index 000000000,000000000..793a92ea7 new file mode 100644 --- /dev/null +++ b/vendor/libgit2-sys-0.6.16/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"6f74b4959cef96898f5123148724fc7dee043b9a6b99f219d948851bfbe53cb2"} diff --cc vendor/libgit2-sys-0.6.16/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/libgit2-sys-0.6.16/.cargo-ok diff --cc vendor/libgit2-sys-0.6.16/Cargo.toml index 000000000,000000000..a3f37c337 new file mode 100644 --- /dev/null +++ b/vendor/libgit2-sys-0.6.16/Cargo.toml @@@ -1,0 -1,0 +1,54 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "libgit2-sys" ++version = "0.6.16" ++authors = ["Alex Crichton "] ++build = "build.rs" ++links = "git2" ++description = "Native bindings to the libgit2 library" ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/git2-rs" ++ ++[lib] ++name = "libgit2_sys" ++path = "lib.rs" ++[dependencies.curl-sys] ++version = "0.3.12" ++optional = true ++ ++[dependencies.libz-sys] ++version = ">= 0" ++ ++[dependencies.libssh2-sys] ++version = "0.2.4" ++optional = true ++ ++[dependencies.libc] ++version = "0.2" ++[build-dependencies.pkg-config] ++version = "0.3" ++ ++[build-dependencies.cmake] ++version = "0.1.2" ++ ++[build-dependencies.cc] ++version = "1.0" ++ ++[features] ++curl = ["curl-sys"] ++https = ["openssl-sys"] ++ssh = ["libssh2-sys"] ++[target."cfg(unix)".dependencies.openssl-sys] ++version = "0.9" ++optional = true diff --cc vendor/libgit2-sys-0.6.16/build.rs index 000000000,000000000..1e9e65c0f new file mode 100644 --- /dev/null +++ b/vendor/libgit2-sys-0.6.16/build.rs @@@ -1,0 -1,0 +1,198 @@@ ++extern crate cmake; ++extern crate cc; ++extern crate pkg_config; ++ ++use std::env; ++use std::ffi::OsString; ++use std::fs::{self, File}; ++use std::io::prelude::*; ++use std::path::{Path, PathBuf}; ++use std::process::Command; ++ ++macro_rules! t { ++ ($e:expr) => (match $e{ ++ Ok(e) => e, ++ Err(e) => panic!("{} failed with {}", stringify!($e), e), ++ }) ++} ++ ++fn main() { ++ let https = env::var("CARGO_FEATURE_HTTPS").is_ok(); ++ let ssh = env::var("CARGO_FEATURE_SSH").is_ok(); ++ let curl = env::var("CARGO_FEATURE_CURL").is_ok(); ++ if ssh { ++ register_dep("SSH2"); ++ } ++ if https { ++ register_dep("OPENSSL"); ++ } ++ if curl { ++ register_dep("CURL"); ++ } ++ let has_pkgconfig = Command::new("pkg-config").output().is_ok(); ++ ++ if env::var("LIBGIT2_SYS_USE_PKG_CONFIG").is_ok() { ++ if pkg_config::find_library("libgit2").is_ok() { ++ return ++ } ++ } ++ ++ if !Path::new("libgit2/.git").exists() { ++ let _ = Command::new("git").args(&["submodule", "update", "--init"]) ++ .status(); ++ } ++ ++ let target = env::var("TARGET").unwrap(); ++ let host = env::var("HOST").unwrap(); ++ let windows = target.contains("windows"); ++ let msvc = target.contains("msvc"); ++ let mut cfg = cmake::Config::new("libgit2"); ++ ++ if msvc { ++ // libgit2 passes the /GL flag to enable whole program optimization, but ++ // this requires that the /LTCG flag is passed to the linker later on, ++ // and currently the compiler does not do that, so we disable whole ++ // program optimization entirely. ++ cfg.cflag("/GL-"); ++ ++ // Currently liblibc links to msvcrt which apparently is a dynamic CRT, ++ // so we need to turn this off to get it to link right. ++ let features = env::var("CARGO_CFG_TARGET_FEATURE") ++ .unwrap_or(String::new()); ++ if features.contains("crt-static") { ++ cfg.define("STATIC_CRT", "ON"); ++ } else { ++ cfg.define("STATIC_CRT", "OFF"); ++ } ++ } ++ ++ // libgit2 uses pkg-config to discover libssh2, but this doesn't work on ++ // windows as libssh2 doesn't come with a libssh2.pc file in that install ++ // (or when pkg-config isn't found). As a result we just manually turn on ++ // SSH support in libgit2 (a little jankily) here... ++ if ssh && (windows || !has_pkgconfig) { ++ if let Ok(libssh2_include) = env::var("DEP_SSH2_INCLUDE") { ++ if msvc { ++ cfg.cflag(format!("/I{}", libssh2_include)) ++ .cflag("/DGIT_SSH"); ++ } else { ++ cfg.cflag(format!("-I{}", libssh2_include)) ++ .cflag("-DGIT_SSH"); ++ } ++ } ++ } ++ ++ // When cross-compiling, we're pretty unlikely to find a `dlltool` binary ++ // lying around, so try to find another if it exists ++ if windows && !host.contains("windows") { ++ let c_compiler = cc::Build::new().cargo_metadata(false) ++ .get_compiler(); ++ let exe = c_compiler.path(); ++ let path = env::var_os("PATH").unwrap_or(OsString::new()); ++ let exe = env::split_paths(&path) ++ .map(|p| p.join(&exe)) ++ .find(|p| p.exists()); ++ if let Some(exe) = exe { ++ if let Some(name) = exe.file_name().and_then(|e| e.to_str()) { ++ let name = name.replace("gcc", "dlltool"); ++ let dlltool = exe.with_file_name(name); ++ cfg.define("DLLTOOL", &dlltool); ++ } ++ } ++ } ++ ++ if ssh { ++ cfg.register_dep("SSH2"); ++ } else { ++ cfg.define("USE_SSH", "OFF"); ++ } ++ if https { ++ cfg.register_dep("OPENSSL"); ++ } else { ++ cfg.define("USE_OPENSSL", "OFF"); ++ } ++ if curl { ++ cfg.register_dep("CURL"); ++ } else { ++ cfg.define("CURL", "OFF"); ++ } ++ ++ let _ = fs::remove_dir_all(env::var("OUT_DIR").unwrap()); ++ t!(fs::create_dir_all(env::var("OUT_DIR").unwrap())); ++ ++ // Unset DESTDIR or libgit2.a ends up in it and cargo can't find it ++ env::remove_var("DESTDIR"); ++ let dst = cfg.define("BUILD_SHARED_LIBS", "OFF") ++ .define("BUILD_CLAR", "OFF") ++ .register_dep("Z") ++ .build(); ++ ++ // Make sure libssh2 was detected on unix systems, because it definitely ++ // should have been! ++ if ssh && !msvc { ++ let flags = dst.join("build/CMakeFiles/git2.dir/flags.make"); ++ let mut contents = String::new(); ++ t!(t!(File::open(flags)).read_to_string(&mut contents)); ++ if !contents.contains("-DGIT_SSH") { ++ panic!("libgit2 failed to find libssh2, and SSH support is required"); ++ } ++ } ++ ++ // libgit2 requires the http_parser library for the HTTP transport to be ++ // implemented, and it will attempt to use the system http_parser if it's ++ // available. Detect this situation and report using the system http parser ++ // the same way in this situation. ++ // ++ // Note that other dependencies of libgit2 like openssl, libz, and libssh2 ++ // are tracked via crates instead of this. Ideally this should be a crate as ++ // well. ++ let pkgconfig_file = dst.join("lib/pkgconfig/libgit2.pc"); ++ if let Ok(mut f) = File::open(&pkgconfig_file) { ++ let mut contents = String::new(); ++ t!(f.read_to_string(&mut contents)); ++ if contents.contains("-lhttp_parser") { ++ println!("cargo:rustc-link-lib=http_parser"); ++ } ++ } ++ ++ if target.contains("windows") { ++ println!("cargo:rustc-link-lib=winhttp"); ++ println!("cargo:rustc-link-lib=rpcrt4"); ++ println!("cargo:rustc-link-lib=ole32"); ++ println!("cargo:rustc-link-lib=crypt32"); ++ println!("cargo:rustc-link-lib=static=git2"); ++ println!("cargo:rustc-link-search=native={}/lib", dst.display()); ++ return ++ } ++ ++ println!("cargo:rustc-link-lib=static=git2"); ++ println!("cargo:rustc-link-search=native={}", dst.join("lib").display()); ++ if target.contains("apple") { ++ println!("cargo:rustc-link-lib=iconv"); ++ println!("cargo:rustc-link-lib=framework=Security"); ++ println!("cargo:rustc-link-lib=framework=CoreFoundation"); ++ } ++} ++ ++fn register_dep(dep: &str) { ++ if let Some(s) = env::var_os(&format!("DEP_{}_ROOT", dep)) { ++ prepend("PKG_CONFIG_PATH", Path::new(&s).join("lib/pkgconfig")); ++ return ++ } ++ if let Some(s) = env::var_os(&format!("DEP_{}_INCLUDE", dep)) { ++ let root = Path::new(&s).parent().unwrap(); ++ env::set_var(&format!("DEP_{}_ROOT", dep), root); ++ let path = root.join("lib/pkgconfig"); ++ if path.exists() { ++ prepend("PKG_CONFIG_PATH", path); ++ return ++ } ++ } ++} ++ ++fn prepend(var: &str, val: PathBuf) { ++ let prefix = env::var(var).unwrap_or(String::new()); ++ let mut v = vec![val]; ++ v.extend(env::split_paths(&prefix)); ++ env::set_var(var, &env::join_paths(v).unwrap()); ++} diff --cc vendor/libgit2-sys-0.6.16/lib.rs index 000000000,000000000..e3b3ebe07 new file mode 100644 --- /dev/null +++ b/vendor/libgit2-sys-0.6.16/lib.rs @@@ -1,0 -1,0 +1,2718 @@@ ++#![doc(html_root_url = "http://alexcrichton.com/git2-rs")] ++#![allow(non_camel_case_types, unused_extern_crates)] ++ ++extern crate libc; ++#[cfg(feature = "ssh")] ++extern crate libssh2_sys as libssh2; ++#[cfg(feature = "curl")] ++extern crate curl_sys; ++#[cfg(all(unix, feature = "https"))] ++extern crate openssl_sys; ++extern crate libz_sys as libz; ++ ++use libc::{c_int, c_char, c_uint, size_t, c_uchar, c_void}; ++ ++pub const GIT_OID_RAWSZ: usize = 20; ++pub const GIT_OID_HEXSZ: usize = GIT_OID_RAWSZ * 2; ++pub const GIT_CLONE_OPTIONS_VERSION: c_uint = 1; ++pub const GIT_STASH_APPLY_OPTIONS_VERSION: c_uint = 1; ++pub const GIT_CHECKOUT_OPTIONS_VERSION: c_uint = 1; ++pub const GIT_MERGE_OPTIONS_VERSION: c_uint = 1; ++pub const GIT_REMOTE_CALLBACKS_VERSION: c_uint = 1; ++pub const GIT_STATUS_OPTIONS_VERSION: c_uint = 1; ++pub const GIT_BLAME_OPTIONS_VERSION: c_uint = 1; ++pub const GIT_PROXY_OPTIONS_VERSION: c_uint = 1; ++pub const GIT_SUBMODULE_UPDATE_OPTIONS_VERSION: c_uint = 1; ++ ++macro_rules! git_enum { ++ (pub enum $name:ident { $($variants:tt)* }) => { ++ #[cfg(target_env = "msvc")] ++ pub type $name = i32; ++ #[cfg(not(target_env = "msvc"))] ++ pub type $name = u32; ++ git_enum!(gen, $name, 0, $($variants)*); ++ }; ++ (pub enum $name:ident: $t:ty { $($variants:tt)* }) => { ++ pub type $name = $t; ++ git_enum!(gen, $name, 0, $($variants)*); ++ }; ++ (gen, $name:ident, $val:expr, $variant:ident, $($rest:tt)*) => { ++ pub const $variant: $name = $val; ++ git_enum!(gen, $name, $val+1, $($rest)*); ++ }; ++ (gen, $name:ident, $val:expr, $variant:ident = $e:expr, $($rest:tt)*) => { ++ pub const $variant: $name = $e; ++ git_enum!(gen, $name, $e+1, $($rest)*); ++ }; ++ (gen, $name:ident, $val:expr, ) => {} ++} ++ ++pub enum git_blob {} ++pub enum git_branch_iterator {} ++pub enum git_blame {} ++pub enum git_commit {} ++pub enum git_config {} ++pub enum git_config_iterator {} ++pub enum git_index {} ++pub enum git_object {} ++pub enum git_reference {} ++pub enum git_reference_iterator {} ++pub enum git_annotated_commit {} ++pub enum git_refspec {} ++pub enum git_remote {} ++pub enum git_repository {} ++pub enum git_revwalk {} ++pub enum git_submodule {} ++pub enum git_tag {} ++pub enum git_tree {} ++pub enum git_tree_entry {} ++pub enum git_treebuilder {} ++pub enum git_push {} ++pub enum git_note {} ++pub enum git_note_iterator {} ++pub enum git_status_list {} ++pub enum git_pathspec {} ++pub enum git_pathspec_match_list {} ++pub enum git_diff {} ++pub enum git_diff_stats {} ++pub enum git_patch {} ++pub enum git_reflog {} ++pub enum git_reflog_entry {} ++pub enum git_describe_result {} ++pub enum git_packbuilder {} ++pub enum git_odb {} ++pub enum git_odb_stream {} ++ ++#[repr(C)] ++pub struct git_revspec { ++ pub from: *mut git_object, ++ pub to: *mut git_object, ++ pub flags: c_uint, ++} ++ ++#[repr(C)] ++pub struct git_error { ++ pub message: *mut c_char, ++ pub klass: c_int, ++} ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct git_oid { ++ pub id: [u8; GIT_OID_RAWSZ], ++} ++ ++#[repr(C)] ++#[derive(Copy)] ++pub struct git_strarray { ++ pub strings: *mut *mut c_char, ++ pub count: size_t, ++} ++impl Clone for git_strarray { ++ fn clone(&self) -> git_strarray { *self } ++} ++ ++#[repr(C)] ++#[derive(Copy)] ++pub struct git_oidarray { ++ pub ids: *mut git_oid, ++ pub count: size_t, ++} ++impl Clone for git_oidarray { ++ fn clone(&self) -> git_oidarray { *self } ++} ++ ++#[repr(C)] ++pub struct git_signature { ++ pub name: *mut c_char, ++ pub email: *mut c_char, ++ pub when: git_time, ++} ++ ++#[repr(C)] ++#[derive(Copy, Clone, Eq, PartialEq)] ++pub struct git_time { ++ pub time: git_time_t, ++ pub offset: c_int, ++} ++ ++pub type git_off_t = i64; ++pub type git_time_t = i64; ++ ++git_enum! { ++ pub enum git_revparse_mode_t { ++ GIT_REVPARSE_SINGLE = 1 << 0, ++ GIT_REVPARSE_RANGE = 1 << 1, ++ GIT_REVPARSE_MERGE_BASE = 1 << 2, ++ } ++} ++ ++git_enum! { ++ pub enum git_error_code: c_int { ++ GIT_OK = 0, ++ ++ GIT_ERROR = -1, ++ GIT_ENOTFOUND = -3, ++ GIT_EEXISTS = -4, ++ GIT_EAMBIGUOUS = -5, ++ GIT_EBUFS = -6, ++ GIT_EUSER = -7, ++ GIT_EBAREREPO = -8, ++ GIT_EUNBORNBRANCH = -9, ++ GIT_EUNMERGED = -10, ++ GIT_ENONFASTFORWARD = -11, ++ GIT_EINVALIDSPEC = -12, ++ GIT_ECONFLICT = -13, ++ GIT_ELOCKED = -14, ++ GIT_EMODIFIED = -15, ++ GIT_EAUTH = -16, ++ GIT_ECERTIFICATE = -17, ++ GIT_EAPPLIED = -18, ++ GIT_EPEEL = -19, ++ GIT_EEOF = -20, ++ GIT_EINVALID = -21, ++ GIT_EUNCOMMITTED = -22, ++ GIT_EDIRECTORY = -23, ++ GIT_EMERGECONFLICT = -24, ++ GIT_PASSTHROUGH = -30, ++ GIT_ITEROVER = -31, ++ } ++} ++ ++git_enum! { ++ pub enum git_error_t { ++ GITERR_NONE = 0, ++ GITERR_NOMEMORY, ++ GITERR_OS, ++ GITERR_INVALID, ++ GITERR_REFERENCE, ++ GITERR_ZLIB, ++ GITERR_REPOSITORY, ++ GITERR_CONFIG, ++ GITERR_REGEX, ++ GITERR_ODB, ++ GITERR_INDEX, ++ GITERR_OBJECT, ++ GITERR_NET, ++ GITERR_TAG, ++ GITERR_TREE, ++ GITERR_INDEXER, ++ GITERR_SSL, ++ GITERR_SUBMODULE, ++ GITERR_THREAD, ++ GITERR_STASH, ++ GITERR_CHECKOUT, ++ GITERR_FETCHHEAD, ++ GITERR_MERGE, ++ GITERR_SSH, ++ GITERR_FILTER, ++ GITERR_REVERT, ++ GITERR_CALLBACK, ++ GITERR_CHERRYPICK, ++ GITERR_DESCRIBE, ++ GITERR_REBASE, ++ GITERR_FILESYSTEM, ++ } ++} ++ ++git_enum! { ++ pub enum git_repository_state_t { ++ GIT_REPOSITORY_STATE_NONE, ++ GIT_REPOSITORY_STATE_MERGE, ++ GIT_REPOSITORY_STATE_REVERT, ++ GIT_REPOSITORY_STATE_REVERT_SEQUENCE, ++ GIT_REPOSITORY_STATE_CHERRYPICK, ++ GIT_REPOSITORY_STATE_CHERRYPICK_SEQUENCE, ++ GIT_REPOSITORY_STATE_BISECT, ++ GIT_REPOSITORY_STATE_REBASE, ++ GIT_REPOSITORY_STATE_REBASE_INTERACTIVE, ++ GIT_REPOSITORY_STATE_REBASE_MERGE, ++ GIT_REPOSITORY_STATE_APPLY_MAILBOX, ++ GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE, ++ } ++} ++ ++git_enum! { ++ pub enum git_direction { ++ GIT_DIRECTION_FETCH, ++ GIT_DIRECTION_PUSH, ++ } ++} ++ ++#[repr(C)] ++pub struct git_clone_options { ++ pub version: c_uint, ++ pub checkout_opts: git_checkout_options, ++ pub fetch_opts: git_fetch_options, ++ pub bare: c_int, ++ pub local: git_clone_local_t, ++ pub checkout_branch: *const c_char, ++ pub repository_cb: Option, ++ pub repository_cb_payload: *mut c_void, ++ pub remote_cb: Option, ++ pub remote_cb_payload: *mut c_void, ++} ++ ++git_enum! { ++ pub enum git_clone_local_t { ++ GIT_CLONE_LOCAL_AUTO, ++ GIT_CLONE_LOCAL, ++ GIT_CLONE_NO_LOCAL, ++ GIT_CLONE_LOCAL_NO_LINKS, ++ } ++} ++ ++#[repr(C)] ++pub struct git_checkout_options { ++ pub version: c_uint, ++ pub checkout_strategy: c_uint, ++ pub disable_filters: c_int, ++ pub dir_mode: c_uint, ++ pub file_mode: c_uint, ++ pub file_open_flags: c_int, ++ pub notify_flags: c_uint, ++ pub notify_cb: Option, ++ pub notify_payload: *mut c_void, ++ pub progress_cb: Option, ++ pub progress_payload: *mut c_void, ++ pub paths: git_strarray, ++ pub baseline: *mut git_tree, ++ pub baseline_index: *mut git_index, ++ pub target_directory: *const c_char, ++ pub ancestor_label: *const c_char, ++ pub our_label: *const c_char, ++ pub their_label: *const c_char, ++ pub perfdata_cb: Option, ++ pub perfdata_payload: *mut c_void, ++} ++ ++pub type git_checkout_notify_cb = extern fn(git_checkout_notify_t, ++ *const c_char, ++ *const git_diff_file, ++ *const git_diff_file, ++ *const git_diff_file, ++ *mut c_void) -> c_int; ++pub type git_checkout_progress_cb = extern fn(*const c_char, ++ size_t, ++ size_t, ++ *mut c_void); ++ ++pub type git_checkout_perfdata_cb = extern fn(*const git_checkout_perfdata, ++ *mut c_void); ++ ++#[repr(C)] ++pub struct git_checkout_perfdata { ++ pub mkdir_calls: size_t, ++ pub stat_calls: size_t, ++ pub chmod_calls: size_t, ++} ++ ++#[repr(C)] ++pub struct git_remote_callbacks { ++ pub version: c_uint, ++ pub sideband_progress: Option, ++ pub completion: Option c_int>, ++ pub credentials: Option, ++ pub certificate_check: Option, ++ pub transfer_progress: Option, ++ pub update_tips: Option c_int>, ++ pub pack_progress: Option, ++ pub push_transfer_progress: Option, ++ pub push_update_reference: Option c_int>, ++ pub push_negotiation: Option, ++ pub transport: Option, ++ pub payload: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct git_fetch_options { ++ pub version: c_int, ++ pub callbacks: git_remote_callbacks, ++ pub prune: git_fetch_prune_t, ++ pub update_fetchhead: c_int, ++ pub download_tags: git_remote_autotag_option_t, ++ pub proxy_opts: git_proxy_options, ++ pub custom_headers: git_strarray, ++} ++ ++git_enum! { ++ pub enum git_remote_autotag_option_t { ++ GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, ++ GIT_REMOTE_DOWNLOAD_TAGS_AUTO, ++ GIT_REMOTE_DOWNLOAD_TAGS_NONE, ++ GIT_REMOTE_DOWNLOAD_TAGS_ALL, ++ } ++} ++ ++git_enum! { ++ pub enum git_fetch_prune_t { ++ GIT_FETCH_PRUNE_UNSPECIFIED, ++ GIT_FETCH_PRUNE, ++ GIT_FETCH_NO_PRUNE, ++ } ++} ++ ++git_enum! { ++ pub enum git_remote_completion_type { ++ GIT_REMOTE_COMPLETION_DOWNLOAD, ++ GIT_REMOTE_COMPLETION_INDEXING, ++ GIT_REMOTE_COMPLETION_ERROR, ++ } ++} ++ ++pub type git_transport_message_cb = extern fn(*const c_char, c_int, ++ *mut c_void) -> c_int; ++pub type git_cred_acquire_cb = extern fn(*mut *mut git_cred, ++ *const c_char, *const c_char, ++ c_uint, *mut c_void) -> c_int; ++pub type git_transfer_progress_cb = extern fn(*const git_transfer_progress, ++ *mut c_void) -> c_int; ++pub type git_packbuilder_progress = extern fn(git_packbuilder_stage_t, c_uint, ++ c_uint, *mut c_void) -> c_int; ++pub type git_push_transfer_progress = extern fn(c_uint, c_uint, size_t, ++ *mut c_void) -> c_int; ++pub type git_transport_certificate_check_cb = extern fn(*mut git_cert, ++ c_int, ++ *const c_char, ++ *mut c_void) -> c_int; ++pub type git_push_negotiation = extern fn(*mut *const git_push_update, ++ size_t, ++ *mut c_void) -> c_int; ++ ++#[repr(C)] ++pub struct git_push_update { ++ pub src_refname: *mut c_char, ++ pub dst_refname: *mut c_char, ++ pub src: git_oid, ++ pub dst: git_oid, ++} ++ ++git_enum! { ++ pub enum git_cert_t { ++ GIT_CERT_NONE, ++ GIT_CERT_X509, ++ GIT_CERT_HOSTKEY_LIBSSH2, ++ } ++} ++ ++#[repr(C)] ++pub struct git_cert { ++ pub cert_type: git_cert_t, ++} ++ ++#[repr(C)] ++pub struct git_cert_hostkey { ++ pub parent: git_cert, ++ pub kind: git_cert_ssh_t, ++ pub hash_md5: [u8; 16], ++ pub hash_sha1: [u8; 20], ++} ++ ++#[repr(C)] ++pub struct git_cert_x509 { ++ pub parent: git_cert, ++ pub data: *mut c_void, ++ pub len: size_t, ++} ++ ++git_enum! { ++ pub enum git_cert_ssh_t { ++ GIT_CERT_SSH_MD5 = 1 << 0, ++ GIT_CERT_SSH_SHA1 = 1 << 1, ++ } ++} ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct git_transfer_progress { ++ pub total_objects: c_uint, ++ pub indexed_objects: c_uint, ++ pub received_objects: c_uint, ++ pub local_objects: c_uint, ++ pub total_deltas: c_uint, ++ pub indexed_deltas: c_uint, ++ pub received_bytes: size_t, ++} ++ ++#[repr(C)] ++pub struct git_diff_file { ++ pub id: git_oid, ++ pub path: *const c_char, ++ pub size: git_off_t, ++ pub flags: u32, ++ pub mode: u16, ++} ++ ++pub type git_repository_create_cb = extern fn(*mut *mut git_repository, ++ *const c_char, ++ c_int, *mut c_void) -> c_int; ++pub type git_remote_create_cb = extern fn(*mut *mut git_remote, ++ *mut git_repository, ++ *const c_char, ++ *const c_char, ++ *mut c_void) -> c_int; ++ ++git_enum! { ++ pub enum git_checkout_notify_t { ++ GIT_CHECKOUT_NOTIFY_NONE = 0, ++ GIT_CHECKOUT_NOTIFY_CONFLICT = (1 << 0), ++ GIT_CHECKOUT_NOTIFY_DIRTY = (1 << 1), ++ GIT_CHECKOUT_NOTIFY_UPDATED = (1 << 2), ++ GIT_CHECKOUT_NOTIFY_UNTRACKED = (1 << 3), ++ GIT_CHECKOUT_NOTIFY_IGNORED = (1 << 4), ++ ++ GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFF, ++ } ++} ++ ++git_enum! { ++ pub enum git_status_t { ++ GIT_STATUS_CURRENT = 0, ++ ++ GIT_STATUS_INDEX_NEW = (1 << 0), ++ GIT_STATUS_INDEX_MODIFIED = (1 << 1), ++ GIT_STATUS_INDEX_DELETED = (1 << 2), ++ GIT_STATUS_INDEX_RENAMED = (1 << 3), ++ GIT_STATUS_INDEX_TYPECHANGE = (1 << 4), ++ ++ GIT_STATUS_WT_NEW = (1 << 7), ++ GIT_STATUS_WT_MODIFIED = (1 << 8), ++ GIT_STATUS_WT_DELETED = (1 << 9), ++ GIT_STATUS_WT_TYPECHANGE = (1 << 10), ++ GIT_STATUS_WT_RENAMED = (1 << 11), ++ GIT_STATUS_WT_UNREADABLE = (1 << 12), ++ ++ GIT_STATUS_IGNORED = (1 << 14), ++ GIT_STATUS_CONFLICTED = (1 << 15), ++ } ++} ++ ++git_enum! { ++ pub enum git_status_opt_t { ++ GIT_STATUS_OPT_INCLUDE_UNTRACKED = (1 << 0), ++ GIT_STATUS_OPT_INCLUDE_IGNORED = (1 << 1), ++ GIT_STATUS_OPT_INCLUDE_UNMODIFIED = (1 << 2), ++ GIT_STATUS_OPT_EXCLUDE_SUBMODULES = (1 << 3), ++ GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS = (1 << 4), ++ GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH = (1 << 5), ++ GIT_STATUS_OPT_RECURSE_IGNORED_DIRS = (1 << 6), ++ GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX = (1 << 7), ++ GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR = (1 << 8), ++ GIT_STATUS_OPT_SORT_CASE_SENSITIVELY = (1 << 9), ++ GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY = (1 << 10), ++ ++ GIT_STATUS_OPT_RENAMES_FROM_REWRITES = (1 << 11), ++ GIT_STATUS_OPT_NO_REFRESH = (1 << 12), ++ GIT_STATUS_OPT_UPDATE_INDEX = (1 << 13), ++ GIT_STATUS_OPT_INCLUDE_UNREADABLE = (1 << 14), ++ GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = (1 << 15), ++ } ++} ++ ++git_enum! { ++ pub enum git_status_show_t { ++ GIT_STATUS_SHOW_INDEX_AND_WORKDIR = 0, ++ GIT_STATUS_SHOW_INDEX_ONLY = 1, ++ GIT_STATUS_SHOW_WORKDIR_ONLY = 2, ++ } ++} ++ ++git_enum! { ++ pub enum git_delta_t { ++ GIT_DELTA_UNMODIFIED, ++ GIT_DELTA_ADDED, ++ GIT_DELTA_DELETED, ++ GIT_DELTA_MODIFIED, ++ GIT_DELTA_RENAMED, ++ GIT_DELTA_COPIED, ++ GIT_DELTA_IGNORED, ++ GIT_DELTA_UNTRACKED, ++ GIT_DELTA_TYPECHANGE, ++ GIT_DELTA_UNREADABLE, ++ GIT_DELTA_CONFLICTED, ++ } ++} ++ ++#[repr(C)] ++pub struct git_status_options { ++ pub version: c_uint, ++ pub show: git_status_show_t, ++ pub flags: c_uint, ++ pub pathspec: git_strarray, ++} ++ ++#[repr(C)] ++pub struct git_diff_delta { ++ pub status: git_delta_t, ++ pub flags: u32, ++ pub similarity: u16, ++ pub nfiles: u16, ++ pub old_file: git_diff_file, ++ pub new_file: git_diff_file, ++} ++ ++#[repr(C)] ++pub struct git_status_entry { ++ pub status: git_status_t, ++ pub head_to_index: *mut git_diff_delta, ++ pub index_to_workdir: *mut git_diff_delta ++} ++ ++git_enum! { ++ pub enum git_checkout_strategy_t { ++ GIT_CHECKOUT_NONE = 0, ++ GIT_CHECKOUT_SAFE = (1 << 0), ++ GIT_CHECKOUT_FORCE = (1 << 1), ++ GIT_CHECKOUT_RECREATE_MISSING = (1 << 2), ++ GIT_CHECKOUT_ALLOW_CONFLICTS = (1 << 4), ++ GIT_CHECKOUT_REMOVE_UNTRACKED = (1 << 5), ++ GIT_CHECKOUT_REMOVE_IGNORED = (1 << 6), ++ GIT_CHECKOUT_UPDATE_ONLY = (1 << 7), ++ GIT_CHECKOUT_DONT_UPDATE_INDEX = (1 << 8), ++ GIT_CHECKOUT_NO_REFRESH = (1 << 9), ++ GIT_CHECKOUT_SKIP_UNMERGED = (1 << 10), ++ GIT_CHECKOUT_USE_OURS = (1 << 11), ++ GIT_CHECKOUT_USE_THEIRS = (1 << 12), ++ GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH = (1 << 13), ++ GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES = (1 << 18), ++ GIT_CHECKOUT_DONT_OVERWRITE_IGNORED = (1 << 19), ++ GIT_CHECKOUT_CONFLICT_STYLE_MERGE = (1 << 20), ++ GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 = (1 << 21), ++ ++ GIT_CHECKOUT_UPDATE_SUBMODULES = (1 << 16), ++ GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1 << 17), ++ } ++} ++ ++git_enum! { ++ pub enum git_reset_t { ++ GIT_RESET_SOFT = 1, ++ GIT_RESET_MIXED = 2, ++ GIT_RESET_HARD = 3, ++ } ++} ++ ++git_enum! { ++ pub enum git_otype: c_int { ++ GIT_OBJ_ANY = -2, ++ GIT_OBJ_BAD = -1, ++ GIT_OBJ__EXT1 = 0, ++ GIT_OBJ_COMMIT = 1, ++ GIT_OBJ_TREE = 2, ++ GIT_OBJ_BLOB = 3, ++ GIT_OBJ_TAG = 4, ++ GIT_OBJ__EXT2 = 5, ++ GIT_OBJ_OFS_DELTA = 6, ++ GIT_OBJ_REF_DELTA = 7, ++ } ++} ++ ++git_enum! { ++ pub enum git_ref_t { ++ GIT_REF_INVALID = 0, ++ GIT_REF_OID = 1, ++ GIT_REF_SYMBOLIC = 2, ++ GIT_REF_LISTALL = GIT_REF_OID | GIT_REF_SYMBOLIC, ++ } ++} ++ ++git_enum! { ++ pub enum git_filemode_t { ++ GIT_FILEMODE_UNREADABLE = 0o000000, ++ GIT_FILEMODE_TREE = 0o040000, ++ GIT_FILEMODE_BLOB = 0o100644, ++ GIT_FILEMODE_BLOB_EXECUTABLE = 0o100755, ++ GIT_FILEMODE_LINK = 0o120000, ++ GIT_FILEMODE_COMMIT = 0o160000, ++ } ++} ++ ++git_enum! { ++ pub enum git_treewalk_mode { ++ GIT_TREEWALK_PRE = 0, ++ GIT_TREEWALK_POST = 1, ++ } ++} ++ ++pub type git_treewalk_cb = extern fn(*const c_char, *const git_tree_entry, ++ *mut c_void) -> c_int; ++pub type git_treebuilder_filter_cb = extern fn(*const git_tree_entry, ++ *mut c_void) -> c_int; ++ ++pub type git_revwalk_hide_cb = extern fn(*const git_oid, *mut c_void) -> c_int; ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct git_buf { ++ pub ptr: *mut c_char, ++ pub asize: size_t, ++ pub size: size_t, ++} ++ ++git_enum! { ++ pub enum git_branch_t { ++ GIT_BRANCH_LOCAL = 1, ++ GIT_BRANCH_REMOTE = 2, ++ GIT_BRANCH_ALL = GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE, ++ } ++} ++ ++pub const GIT_BLAME_NORMAL: u32 = 0; ++pub const GIT_BLAME_TRACK_COPIES_SAME_FILE: u32 = 1<<0; ++pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES: u32 = 1<<1; ++pub const GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES: u32 = 1<<2; ++pub const GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES: u32 = 1<<3; ++pub const GIT_BLAME_FIRST_PARENT: u32 = 1<<4; ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct git_blame_options { ++ pub version: c_uint, ++ ++ pub flags: u32, ++ pub min_match_characters: u16, ++ pub newest_commit: git_oid, ++ pub oldest_commit: git_oid, ++ pub min_line: usize, ++ pub max_line: usize, ++} ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct git_blame_hunk { ++ pub lines_in_hunk: usize, ++ pub final_commit_id: git_oid, ++ pub final_start_line_number: usize, ++ pub final_signature: *mut git_signature, ++ pub orig_commit_id: git_oid, ++ pub orig_path: *const c_char, ++ pub orig_start_line_number: usize, ++ pub orig_signature: *mut git_signature, ++ pub boundary: c_char, ++} ++ ++pub type git_index_matched_path_cb = extern fn(*const c_char, *const c_char, ++ *mut c_void) -> c_int; ++ ++git_enum! { ++ pub enum git_idxentry_extended_flag_t { ++ GIT_IDXENTRY_INTENT_TO_ADD = 1 << 13, ++ GIT_IDXENTRY_SKIP_WORKTREE = 1 << 14, ++ GIT_IDXENTRY_EXTENDED2 = 1 << 15, ++ ++ GIT_IDXENTRY_UPDATE = 1 << 0, ++ GIT_IDXENTRY_REMOVE = 1 << 1, ++ GIT_IDXENTRY_UPTODATE = 1 << 2, ++ GIT_IDXENTRY_ADDED = 1 << 3, ++ ++ GIT_IDXENTRY_HASHED = 1 << 4, ++ GIT_IDXENTRY_UNHASHED = 1 << 5, ++ GIT_IDXENTRY_WT_REMOVE = 1 << 6, ++ GIT_IDXENTRY_CONFLICTED = 1 << 7, ++ ++ GIT_IDXENTRY_UNPACKED = 1 << 8, ++ GIT_IDXENTRY_NEW_SKIP_WORKTREE = 1 << 9, ++ } ++} ++ ++git_enum! { ++ pub enum git_indxentry_flag_t { ++ GIT_IDXENTRY_EXTENDED = 0x4000, ++ GIT_IDXENTRY_VALID = 0x8000, ++ } ++} ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct git_index_entry { ++ pub ctime: git_index_time, ++ pub mtime: git_index_time, ++ pub dev: u32, ++ pub ino: u32, ++ pub mode: u32, ++ pub uid: u32, ++ pub gid: u32, ++ pub file_size: u32, ++ pub id: git_oid, ++ pub flags: u16, ++ pub flags_extended: u16, ++ pub path: *const c_char, ++} ++ ++pub const GIT_IDXENTRY_NAMEMASK: u16 = 0xfff; ++pub const GIT_IDXENTRY_STAGEMASK: u16 = 0x3000; ++pub const GIT_IDXENTRY_STAGESHIFT: u16 = 12; ++ ++#[repr(C)] ++#[derive(Copy, Clone, Eq, PartialEq)] ++pub struct git_index_time { ++ pub seconds: i32, ++ pub nanoseconds: u32, ++} ++ ++#[repr(C)] ++pub struct git_config_entry { ++ pub name: *const c_char, ++ pub value: *const c_char, ++ pub level: git_config_level_t, ++ pub free: extern fn(*mut git_config_entry), ++ pub payload: *mut c_void, ++} ++ ++git_enum! { ++ pub enum git_config_level_t: c_int { ++ GIT_CONFIG_LEVEL_PROGRAMDATA = 1, ++ GIT_CONFIG_LEVEL_SYSTEM = 2, ++ GIT_CONFIG_LEVEL_XDG = 3, ++ GIT_CONFIG_LEVEL_GLOBAL = 4, ++ GIT_CONFIG_LEVEL_LOCAL = 5, ++ GIT_CONFIG_LEVEL_APP = 6, ++ GIT_CONFIG_HIGHEST_LEVEL = -1, ++ } ++} ++ ++git_enum! { ++ pub enum git_submodule_update_t { ++ GIT_SUBMODULE_UPDATE_CHECKOUT = 1, ++ GIT_SUBMODULE_UPDATE_REBASE = 2, ++ GIT_SUBMODULE_UPDATE_MERGE = 3, ++ GIT_SUBMODULE_UPDATE_NONE = 4, ++ GIT_SUBMODULE_UPDATE_DEFAULT = 0, ++ } ++} ++ ++git_enum! { ++ pub enum git_submodule_ignore_t: c_int { ++ GIT_SUBMODULE_IGNORE_UNSPECIFIED = -1, ++ ++ GIT_SUBMODULE_IGNORE_NONE = 1, ++ GIT_SUBMODULE_IGNORE_UNTRACKED = 2, ++ GIT_SUBMODULE_IGNORE_DIRTY = 3, ++ GIT_SUBMODULE_IGNORE_ALL = 4, ++ } ++} ++ ++pub type git_submodule_cb = extern fn(*mut git_submodule, ++ *const c_char, ++ *mut c_void) -> c_int; ++ ++#[repr(C)] ++pub struct git_submodule_update_options { ++ pub version: c_uint, ++ pub checkout_opts: git_checkout_options, ++ pub fetch_opts: git_fetch_options, ++ pub allow_fetch: c_int, ++} ++ ++#[repr(C)] ++pub struct git_writestream { ++ pub write: extern fn(*mut git_writestream, ++ *const c_char, ++ size_t) -> c_int, ++ pub close: extern fn(*mut git_writestream) -> c_int, ++ pub free: extern fn(*mut git_writestream), ++} ++ ++#[repr(C)] ++pub struct git_cred { ++ pub credtype: git_credtype_t, ++ pub free: extern fn(*mut git_cred), ++} ++ ++git_enum! { ++ pub enum git_credtype_t { ++ GIT_CREDTYPE_USERPASS_PLAINTEXT = 1 << 0, ++ GIT_CREDTYPE_SSH_KEY = 1 << 1, ++ GIT_CREDTYPE_SSH_CUSTOM = 1 << 2, ++ GIT_CREDTYPE_DEFAULT = 1 << 3, ++ GIT_CREDTYPE_SSH_INTERACTIVE = 1 << 4, ++ GIT_CREDTYPE_USERNAME = 1 << 5, ++ GIT_CREDTYPE_SSH_MEMORY = 1 << 6, ++ } ++} ++ ++pub type git_cred_ssh_interactive_callback = extern fn( ++ name: *const c_char, ++ name_len: c_int, ++ instruction: *const c_char, ++ instruction_len: c_int, ++ num_prompts: c_int, ++ prompts: *const LIBSSH2_USERAUTH_KBDINT_PROMPT, ++ responses: *mut LIBSSH2_USERAUTH_KBDINT_RESPONSE, ++ abstrakt: *mut *mut c_void ++); ++ ++pub type git_cred_sign_callback = extern fn( ++ session: *mut LIBSSH2_SESSION, ++ sig: *mut *mut c_uchar, ++ sig_len: *mut size_t, ++ data: *const c_uchar, ++ data_len: size_t, ++ abstrakt: *mut *mut c_void, ++); ++ ++pub enum LIBSSH2_SESSION {} ++pub enum LIBSSH2_USERAUTH_KBDINT_PROMPT {} ++pub enum LIBSSH2_USERAUTH_KBDINT_RESPONSE {} ++ ++#[repr(C)] ++pub struct git_push_options { ++ pub version: c_uint, ++ pub pb_parallelism: c_uint, ++ pub callbacks: git_remote_callbacks, ++ pub proxy_opts: git_proxy_options, ++ pub custom_headers: git_strarray, ++} ++ ++pub type git_tag_foreach_cb = extern fn(name: *const c_char, ++ oid: *mut git_oid, ++ payload: *mut c_void) -> c_int; ++ ++git_enum! { ++ pub enum git_index_add_option_t { ++ GIT_INDEX_ADD_DEFAULT = 0, ++ GIT_INDEX_ADD_FORCE = 1 << 0, ++ GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = 1 << 1, ++ GIT_INDEX_ADD_CHECK_PATHSPEC = 1 << 2, ++ } ++} ++ ++git_enum! { ++ pub enum git_repository_open_flag_t { ++ GIT_REPOSITORY_OPEN_NO_SEARCH = (1 << 0), ++ GIT_REPOSITORY_OPEN_CROSS_FS = (1 << 1), ++ GIT_REPOSITORY_OPEN_BARE = (1 << 2), ++ GIT_REPOSITORY_OPEN_NO_DOTGIT = (1 << 3), ++ GIT_REPOSITORY_OPEN_FROM_ENV = (1 << 4), ++ } ++} ++ ++#[repr(C)] ++pub struct git_repository_init_options { ++ pub version: c_uint, ++ pub flags: u32, ++ pub mode: u32, ++ pub workdir_path: *const c_char, ++ pub description: *const c_char, ++ pub template_path: *const c_char, ++ pub initial_head: *const c_char, ++ pub origin_url: *const c_char, ++} ++ ++pub const GIT_REPOSITORY_INIT_OPTIONS_VERSION: c_uint = 1; ++ ++git_enum! { ++ pub enum git_repository_init_flag_t { ++ GIT_REPOSITORY_INIT_BARE = (1 << 0), ++ GIT_REPOSITORY_INIT_NO_REINIT = (1 << 1), ++ GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = (1 << 2), ++ GIT_REPOSITORY_INIT_MKDIR = (1 << 3), ++ GIT_REPOSITORY_INIT_MKPATH = (1 << 4), ++ GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = (1 << 5), ++ } ++} ++ ++git_enum! { ++ pub enum git_repository_init_mode_t { ++ GIT_REPOSITORY_INIT_SHARED_UMASK = 0, ++ GIT_REPOSITORY_INIT_SHARED_GROUP = 0o002775, ++ GIT_REPOSITORY_INIT_SHARED_ALL = 0o002777, ++ } ++} ++ ++git_enum! { ++ pub enum git_sort_t { ++ GIT_SORT_NONE = 0, ++ GIT_SORT_TOPOLOGICAL = (1 << 0), ++ GIT_SORT_TIME = (1 << 1), ++ GIT_SORT_REVERSE = (1 << 2), ++ } ++} ++ ++git_enum! { ++ pub enum git_submodule_status_t { ++ GIT_SUBMODULE_STATUS_IN_HEAD = 1 << 0, ++ GIT_SUBMODULE_STATUS_IN_INDEX = 1 << 1, ++ GIT_SUBMODULE_STATUS_IN_CONFIG = 1 << 2, ++ GIT_SUBMODULE_STATUS_IN_WD = 1 << 3, ++ GIT_SUBMODULE_STATUS_INDEX_ADDED = 1 << 4, ++ GIT_SUBMODULE_STATUS_INDEX_DELETED = 1 << 5, ++ GIT_SUBMODULE_STATUS_INDEX_MODIFIED = 1 << 6, ++ GIT_SUBMODULE_STATUS_WD_UNINITIALIZED = 1 << 7, ++ GIT_SUBMODULE_STATUS_WD_ADDED = 1 << 8, ++ GIT_SUBMODULE_STATUS_WD_DELETED = 1 << 9, ++ GIT_SUBMODULE_STATUS_WD_MODIFIED = 1 << 10, ++ GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED = 1 << 11, ++ GIT_SUBMODULE_STATUS_WD_WD_MODIFIED = 1 << 12, ++ GIT_SUBMODULE_STATUS_WD_UNTRACKED = 1 << 13, ++ } ++} ++ ++#[repr(C)] ++pub struct git_remote_head { ++ pub local: c_int, ++ pub oid: git_oid, ++ pub loid: git_oid, ++ pub name: *mut c_char, ++ pub symref_target: *mut c_char, ++} ++ ++git_enum! { ++ pub enum git_pathspec_flag_t { ++ GIT_PATHSPEC_DEFAULT = 0, ++ GIT_PATHSPEC_IGNORE_CASE = 1 << 0, ++ GIT_PATHSPEC_USE_CASE = 1 << 1, ++ GIT_PATHSPEC_NO_GLOB = 1 << 2, ++ GIT_PATHSPEC_NO_MATCH_ERROR = 1 << 3, ++ GIT_PATHSPEC_FIND_FAILURES = 1 << 4, ++ GIT_PATHSPEC_FAILURES_ONLY = 1 << 5, ++ } ++} ++ ++pub type git_diff_file_cb = extern fn(*const git_diff_delta, f32, *mut c_void) ++ -> c_int; ++pub type git_diff_hunk_cb = extern fn(*const git_diff_delta, ++ *const git_diff_hunk, ++ *mut c_void) -> c_int; ++pub type git_diff_line_cb = extern fn(*const git_diff_delta, ++ *const git_diff_hunk, ++ *const git_diff_line, ++ *mut c_void) -> c_int; ++pub type git_diff_binary_cb = extern fn(*const git_diff_delta, ++ *const git_diff_binary, ++ *mut c_void) -> c_int; ++ ++#[repr(C)] ++pub struct git_diff_hunk { ++ pub old_start: c_int, ++ pub old_lines: c_int, ++ pub new_start: c_int, ++ pub new_lines: c_int, ++ pub header_len: size_t, ++ pub header: [c_char; 128], ++} ++ ++git_enum! { ++ pub enum git_diff_line_t { ++ GIT_DIFF_LINE_CONTEXT = b' ' as git_diff_line_t, ++ GIT_DIFF_LINE_ADDITION = b'+' as git_diff_line_t, ++ GIT_DIFF_LINE_DELETION = b'-' as git_diff_line_t, ++ GIT_DIFF_LINE_CONTEXT_EOFNL = b'=' as git_diff_line_t, ++ GIT_DIFF_LINE_ADD_EOFNL = b'>' as git_diff_line_t, ++ GIT_DIFF_LINE_DEL_EOFNL = b'<' as git_diff_line_t, ++ GIT_DIFF_LINE_FILE_HDR = b'F' as git_diff_line_t, ++ GIT_DIFF_LINE_HUNK_HDR = b'H' as git_diff_line_t, ++ GIT_DIFF_LINE_BINARY = b'B' as git_diff_line_t, ++ } ++} ++ ++#[repr(C)] ++pub struct git_diff_line { ++ pub origin: c_char, ++ pub old_lineno: c_int, ++ pub new_lineno: c_int, ++ pub num_lines: c_int, ++ pub content_len: size_t, ++ pub content_offset: git_off_t, ++ pub content: *const c_char, ++} ++ ++#[repr(C)] ++pub struct git_diff_options { ++ pub version: c_uint, ++ pub flags: u32, ++ pub ignore_submodules: git_submodule_ignore_t, ++ pub pathspec: git_strarray, ++ pub notify_cb: git_diff_notify_cb, ++ pub progress_cb: git_diff_progress_cb, ++ pub payload: *mut c_void, ++ pub context_lines: u32, ++ pub interhunk_lines: u32, ++ pub id_abbrev: u16, ++ pub max_size: git_off_t, ++ pub old_prefix: *const c_char, ++ pub new_prefix: *const c_char, ++} ++ ++git_enum! { ++ pub enum git_diff_format_t { ++ GIT_DIFF_FORMAT_PATCH = 1, ++ GIT_DIFF_FORMAT_PATCH_HEADER = 2, ++ GIT_DIFF_FORMAT_RAW = 3, ++ GIT_DIFF_FORMAT_NAME_ONLY = 4, ++ GIT_DIFF_FORMAT_NAME_STATUS = 5, ++ } ++} ++ ++git_enum! { ++ pub enum git_diff_stats_format_t { ++ GIT_DIFF_STATS_NONE = 0, ++ GIT_DIFF_STATS_FULL = 1 << 0, ++ GIT_DIFF_STATS_SHORT = 1 << 1, ++ GIT_DIFF_STATS_NUMBER = 1 << 2, ++ GIT_DIFF_STATS_INCLUDE_SUMMARY = 1 << 3, ++ } ++} ++ ++pub type git_diff_notify_cb = extern fn(*const git_diff, ++ *const git_diff_delta, ++ *const c_char, ++ *mut c_void) -> c_int; ++ ++pub type git_diff_progress_cb = extern fn (*const git_diff, ++ *const c_char, ++ *const c_char, ++ *mut c_void) -> c_int; ++ ++pub const GIT_DIFF_NORMAL: u32 = 0; ++pub const GIT_DIFF_REVERSE: u32 = 1 << 0; ++pub const GIT_DIFF_INCLUDE_IGNORED: u32 = 1 << 1; ++pub const GIT_DIFF_RECURSE_IGNORED_DIRS: u32 = 1 << 2; ++pub const GIT_DIFF_INCLUDE_UNTRACKED: u32 = 1 << 3; ++pub const GIT_DIFF_RECURSE_UNTRACKED_DIRS: u32 = 1 << 4; ++pub const GIT_DIFF_INCLUDE_UNMODIFIED: u32 = 1 << 5; ++pub const GIT_DIFF_INCLUDE_TYPECHANGE: u32 = 1 << 6; ++pub const GIT_DIFF_INCLUDE_TYPECHANGE_TREES: u32 = 1 << 7; ++pub const GIT_DIFF_IGNORE_FILEMODE: u32 = 1 << 8; ++pub const GIT_DIFF_IGNORE_SUBMODULES: u32 = 1 << 9; ++pub const GIT_DIFF_IGNORE_CASE: u32 = 1 << 10; ++pub const GIT_DIFF_DISABLE_PATHSPEC_MATCH: u32 = 1 << 12; ++pub const GIT_DIFF_SKIP_BINARY_CHECK: u32 = 1 << 13; ++pub const GIT_DIFF_ENABLE_FAST_UNTRACKED_DIRS: u32 = 1 << 14; ++pub const GIT_DIFF_UPDATE_INDEX: u32 = 1 << 15; ++pub const GIT_DIFF_INCLUDE_UNREADABLE: u32 = 1 << 16; ++pub const GIT_DIFF_INCLUDE_UNREADABLE_AS_UNTRACKED: u32 = 1 << 17; ++pub const GIT_DIFF_FORCE_TEXT: u32 = 1 << 20; ++pub const GIT_DIFF_FORCE_BINARY: u32 = 1 << 21; ++pub const GIT_DIFF_IGNORE_WHITESPACE: u32 = 1 << 22; ++pub const GIT_DIFF_IGNORE_WHITESPACE_CHANGE: u32 = 1 << 23; ++pub const GIT_DIFF_IGNORE_WHITESPACE_EOL: u32 = 1 << 24; ++pub const GIT_DIFF_SHOW_UNTRACKED_CONTENT: u32 = 1 << 25; ++pub const GIT_DIFF_SHOW_UNMODIFIED: u32 = 1 << 26; ++pub const GIT_DIFF_PATIENCE: u32 = 1 << 28; ++pub const GIT_DIFF_MINIMAL: u32 = 1 << 29; ++pub const GIT_DIFF_SHOW_BINARY: u32 = 1 << 30; ++ ++#[repr(C)] ++pub struct git_diff_find_options { ++ pub version: c_uint, ++ pub flags: u32, ++ pub rename_threshold: u16, ++ pub rename_from_rewrite_threshold: u16, ++ pub copy_threshold: u16, ++ pub break_rewrite_threshold: u16, ++ pub rename_limit: size_t, ++ pub metric: *mut git_diff_similarity_metric, ++} ++ ++#[repr(C)] ++pub struct git_diff_similarity_metric { ++ pub file_signature: extern fn(*mut *mut c_void, ++ *const git_diff_file, ++ *const c_char, ++ *mut c_void) -> c_int, ++ pub buffer_signature: extern fn(*mut *mut c_void, ++ *const git_diff_file, ++ *const c_char, ++ size_t, ++ *mut c_void) -> c_int, ++ pub free_signature: extern fn(*mut c_void, *mut c_void), ++ pub similarity: extern fn(*mut c_int, *mut c_void, *mut c_void, ++ *mut c_void) -> c_int, ++ pub payload: *mut c_void, ++} ++ ++pub const GIT_DIFF_FIND_OPTIONS_VERSION: c_uint = 1; ++ ++pub const GIT_DIFF_FIND_BY_CONFIG: u32 = 0; ++pub const GIT_DIFF_FIND_RENAMES: u32 = 1 << 0; ++pub const GIT_DIFF_FIND_RENAMES_FROM_REWRITES: u32 = 1 << 1; ++pub const GIT_DIFF_FIND_COPIES: u32 = 1 << 2; ++pub const GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED: u32 = 1 << 3; ++pub const GIT_DIFF_FIND_REWRITES: u32 = 1 << 4; ++pub const GIT_DIFF_BREAK_REWRITES: u32 = 1 << 5; ++pub const GIT_DIFF_FIND_AND_BREAK_REWRITES: u32 = ++ GIT_DIFF_FIND_REWRITES | GIT_DIFF_BREAK_REWRITES; ++pub const GIT_DIFF_FIND_FOR_UNTRACKED: u32 = 1 << 6; ++pub const GIT_DIFF_FIND_ALL: u32 = 0x0ff; ++pub const GIT_DIFF_FIND_IGNORE_LEADING_WHITESPACE: u32 = 0; ++pub const GIT_DIFF_FIND_IGNORE_WHITESPACE: u32 = 1 << 12; ++pub const GIT_DIFF_FIND_DONT_IGNORE_WHITESPACE: u32 = 1 << 13; ++pub const GIT_DIFF_FIND_EXACT_MATCH_ONLY: u32 = 1 << 14; ++pub const GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY : u32 = 1 << 15; ++pub const GIT_DIFF_FIND_REMOVE_UNMODIFIED: u32 = 1 << 16; ++ ++#[repr(C)] ++pub struct git_diff_binary { ++ pub contains_data: c_uint, ++ pub old_file: git_diff_binary_file, ++ pub new_file: git_diff_binary_file, ++} ++ ++#[repr(C)] ++pub struct git_diff_binary_file { ++ pub kind: git_diff_binary_t, ++ pub data: *const c_char, ++ pub datalen: size_t, ++ pub inflatedlen: size_t, ++} ++ ++git_enum! { ++ pub enum git_diff_binary_t { ++ GIT_DIFF_BINARY_NONE, ++ GIT_DIFF_BINARY_LITERAL, ++ GIT_DIFF_BINARY_DELTA, ++ } ++} ++ ++#[repr(C)] ++pub struct git_merge_options { ++ pub version: c_uint, ++ pub flags: git_merge_flag_t, ++ pub rename_threshold: c_uint, ++ pub target_limit: c_uint, ++ pub metric: *mut git_diff_similarity_metric, ++ pub recursion_limit: c_uint, ++ pub default_driver: *const c_char, ++ pub file_favor: git_merge_file_favor_t, ++ pub file_flags: git_merge_file_flag_t, ++} ++ ++git_enum! { ++ pub enum git_merge_flag_t { ++ GIT_MERGE_FIND_RENAMES = 1 << 0, ++ GIT_MERGE_FAIL_ON_CONFLICT = 1 << 1, ++ GIT_MERGE_SKIP_REUC = 1 << 2, ++ GIT_MERGE_NO_RECURSIVE = 1 << 3, ++ } ++} ++ ++git_enum! { ++ pub enum git_merge_file_favor_t { ++ GIT_MERGE_FILE_FAVOR_NORMAL = 0, ++ GIT_MERGE_FILE_FAVOR_OURS = 1, ++ GIT_MERGE_FILE_FAVOR_THEIRS = 2, ++ GIT_MERGE_FILE_FAVOR_UNION = 3, ++ } ++} ++ ++git_enum! { ++ pub enum git_merge_file_flag_t { ++ GIT_MERGE_FILE_DEFAULT = 0, ++ GIT_MERGE_FILE_STYLE_MERGE = (1 << 0), ++ GIT_MERGE_FILE_STYLE_DIFF3 = (1 << 1), ++ GIT_MERGE_FILE_SIMPLIFY_ALNUM = (1 << 2), ++ GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 3), ++ GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 4), ++ GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 5), ++ GIT_MERGE_FILE_DIFF_PATIENCE = (1 << 6), ++ GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7), ++ } ++} ++ ++git_enum! { ++ pub enum git_merge_analysis_t { ++ GIT_MERGE_ANALYSIS_NONE = 0, ++ GIT_MERGE_ANALYSIS_NORMAL = (1 << 0), ++ GIT_MERGE_ANALYSIS_UP_TO_DATE = (1 << 1), ++ GIT_MERGE_ANALYSIS_FASTFORWARD = (1 << 2), ++ GIT_MERGE_ANALYSIS_UNBORN = (1 << 3), ++ } ++} ++ ++git_enum! { ++ pub enum git_merge_preference_t { ++ GIT_MERGE_PREFERENCE_NONE = 0, ++ GIT_MERGE_PREFERENCE_NO_FASTFORWARD = (1 << 0), ++ GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1), ++ } ++} ++ ++pub type git_transport_cb = extern fn(out: *mut *mut git_transport, ++ owner: *mut git_remote, ++ param: *mut c_void) -> c_int; ++ ++#[repr(C)] ++pub struct git_transport { ++ pub version: c_uint, ++ pub set_callbacks: extern fn(*mut git_transport, ++ git_transport_message_cb, ++ git_transport_message_cb, ++ git_transport_certificate_check_cb, ++ *mut c_void) -> c_int, ++ pub set_custom_headers: extern fn(*mut git_transport, ++ *const git_strarray) -> c_int, ++ pub connect: extern fn(*mut git_transport, ++ *const c_char, ++ git_cred_acquire_cb, ++ *mut c_void, ++ *const git_proxy_options, ++ c_int, c_int) -> c_int, ++ pub ls: extern fn(*mut *mut *const git_remote_head, ++ *mut size_t, ++ *mut git_transport) -> c_int, ++ pub push: extern fn(*mut git_transport, ++ *mut git_push, ++ *const git_remote_callbacks) -> c_int, ++ pub negotiate_fetch: extern fn(*mut git_transport, ++ *mut git_repository, ++ *const *const git_remote_head, ++ size_t) -> c_int, ++ pub download_pack: extern fn(*mut git_transport, ++ *mut git_repository, ++ *mut git_transfer_progress, ++ git_transfer_progress_cb, ++ *mut c_void) -> c_int, ++ pub is_connected: extern fn(*mut git_transport) -> c_int, ++ pub read_flags: extern fn(*mut git_transport, *mut c_int) -> c_int, ++ pub cancel: extern fn(*mut git_transport), ++ pub close: extern fn(*mut git_transport) -> c_int, ++ pub free: extern fn(*mut git_transport), ++} ++ ++#[repr(C)] ++pub struct git_proxy_options { ++ pub version: c_uint, ++ pub kind: git_proxy_t, ++ pub url: *const c_char, ++ pub credentials: Option, ++ pub certificate_check: Option, ++ pub payload: *mut c_void, ++} ++ ++git_enum! { ++ pub enum git_proxy_t { ++ GIT_PROXY_NONE = 0, ++ GIT_PROXY_AUTO = 1, ++ GIT_PROXY_SPECIFIED = 2, ++ } ++} ++ ++git_enum! { ++ pub enum git_smart_service_t { ++ GIT_SERVICE_UPLOADPACK_LS = 1, ++ GIT_SERVICE_UPLOADPACK = 2, ++ GIT_SERVICE_RECEIVEPACK_LS = 3, ++ GIT_SERVICE_RECEIVEPACK = 4, ++ } ++} ++ ++#[repr(C)] ++pub struct git_smart_subtransport_stream { ++ pub subtransport: *mut git_smart_subtransport, ++ pub read: extern fn(*mut git_smart_subtransport_stream, ++ *mut c_char, ++ size_t, ++ *mut size_t) -> c_int, ++ pub write: extern fn(*mut git_smart_subtransport_stream, ++ *const c_char, ++ size_t) -> c_int, ++ pub free: extern fn(*mut git_smart_subtransport_stream), ++} ++ ++#[repr(C)] ++pub struct git_smart_subtransport { ++ pub action: extern fn(*mut *mut git_smart_subtransport_stream, ++ *mut git_smart_subtransport, ++ *const c_char, ++ git_smart_service_t) -> c_int, ++ pub close: extern fn(*mut git_smart_subtransport) -> c_int, ++ pub free: extern fn(*mut git_smart_subtransport), ++} ++ ++pub type git_smart_subtransport_cb = extern fn(*mut *mut git_smart_subtransport, ++ *mut git_transport, ++ *mut c_void) -> c_int; ++ ++#[repr(C)] ++pub struct git_smart_subtransport_definition { ++ pub callback: git_smart_subtransport_cb, ++ pub rpc: c_uint, ++ pub param: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct git_describe_options { ++ pub version: c_uint, ++ pub max_candidates_tags: c_uint, ++ pub describe_strategy: c_uint, ++ pub pattern: *const c_char, ++ pub only_follow_first_parent: c_int, ++ pub show_commit_oid_as_fallback: c_int, ++} ++ ++git_enum! { ++ pub enum git_describe_strategy_t { ++ GIT_DESCRIBE_DEFAULT, ++ GIT_DESCRIBE_TAGS, ++ GIT_DESCRIBE_ALL, ++ } ++} ++ ++#[repr(C)] ++pub struct git_describe_format_options { ++ pub version: c_uint, ++ pub abbreviated_size: c_uint, ++ pub always_use_long_format: c_int, ++ pub dirty_suffix: *const c_char, ++} ++ ++git_enum! { ++ pub enum git_packbuilder_stage_t { ++ GIT_PACKBUILDER_ADDING_OBJECTS, ++ GIT_PACKBUILDER_DELTAFICATION, ++ } ++} ++ ++git_enum! { ++ pub enum git_stash_flags { ++ GIT_STASH_DEFAULT = 0, ++ GIT_STASH_KEEP_INDEX = 1 << 0, ++ GIT_STASH_INCLUDE_UNTRACKED = 1 << 1, ++ GIT_STASH_INCLUDE_IGNORED = 1 << 2, ++ } ++} ++ ++git_enum! { ++ pub enum git_stash_apply_flags { ++ GIT_STASH_APPLY_DEFAULT = 0, ++ GIT_STASH_APPLY_REINSTATE_INDEX = 1 << 0, ++ } ++} ++ ++git_enum! { ++ pub enum git_stash_apply_progress_t { ++ GIT_STASH_APPLY_PROGRESS_NONE = 0, ++ GIT_STASH_APPLY_PROGRESS_LOADING_STASH, ++ GIT_STASH_APPLY_PROGRESS_ANALYZE_INDEX, ++ GIT_STASH_APPLY_PROGRESS_ANALYZE_MODIFIED, ++ GIT_STASH_APPLY_PROGRESS_ANALYZE_UNTRACKED, ++ GIT_STASH_APPLY_PROGRESS_CHECKOUT_UNTRACKED, ++ GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED, ++ GIT_STASH_APPLY_PROGRESS_DONE, ++ } ++} ++ ++#[repr(C)] ++pub struct git_stash_apply_options { ++ pub version: c_uint, ++ pub flags: git_stash_apply_flags, ++ pub checkout_options: git_checkout_options, ++ pub progress_cb: git_stash_apply_progress_cb, ++ pub progress_payload: *mut c_void, ++} ++ ++pub type git_stash_apply_progress_cb = extern fn(progress: git_stash_apply_progress_t, ++ payload: *mut c_void) -> c_int; ++ ++pub type git_stash_cb = extern fn(index: size_t, ++ message: *const c_char, ++ stash_id: *const git_oid, ++ payload: *mut c_void) -> c_int; ++ ++pub type git_packbuilder_foreach_cb = extern fn(*const c_void, size_t, ++ *mut c_void) -> c_int; ++ ++pub type git_odb_foreach_cb = extern fn(id: *const git_oid, payload: *mut c_void) -> c_int; ++ ++extern { ++ // threads ++ pub fn git_libgit2_init() -> c_int; ++ pub fn git_libgit2_shutdown() -> c_int; ++ ++ // repository ++ pub fn git_repository_free(repo: *mut git_repository); ++ pub fn git_repository_open(repo: *mut *mut git_repository, ++ path: *const c_char) -> c_int; ++ pub fn git_repository_open_ext(repo: *mut *mut git_repository, ++ path: *const c_char, ++ flags: c_uint, ++ ceiling_dirs: *const c_char) -> c_int; ++ pub fn git_repository_init(repo: *mut *mut git_repository, ++ path: *const c_char, ++ is_bare: c_uint) -> c_int; ++ pub fn git_repository_init_ext(out: *mut *mut git_repository, ++ repo_path: *const c_char, ++ opts: *mut git_repository_init_options) ++ -> c_int; ++ pub fn git_repository_init_init_options(opts: *mut git_repository_init_options, ++ version: c_uint) -> c_int; ++ pub fn git_repository_get_namespace(repo: *mut git_repository) ++ -> *const c_char; ++ pub fn git_repository_head(out: *mut *mut git_reference, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_repository_set_head(repo: *mut git_repository, ++ refname: *const c_char) -> c_int; ++ pub fn git_repository_set_head_detached(repo: *mut git_repository, ++ commitish: *const git_oid) -> c_int; ++ pub fn git_repository_is_bare(repo: *mut git_repository) -> c_int; ++ pub fn git_repository_is_empty(repo: *mut git_repository) -> c_int; ++ pub fn git_repository_is_shallow(repo: *mut git_repository) -> c_int; ++ pub fn git_repository_path(repo: *mut git_repository) -> *const c_char; ++ pub fn git_repository_state(repo: *mut git_repository) -> c_int; ++ pub fn git_repository_workdir(repo: *mut git_repository) -> *const c_char; ++ pub fn git_repository_set_workdir(repo: *mut git_repository, ++ workdir: *const c_char, ++ update_gitlink: c_int) -> c_int; ++ pub fn git_repository_index(out: *mut *mut git_index, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_repository_set_index(repo: *mut git_repository, ++ index: *mut git_index); ++ pub fn git_repository_config(out: *mut *mut git_config, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_repository_config_snapshot(out: *mut *mut git_config, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_repository_discover(out: *mut git_buf, ++ start_path: *const c_char, ++ across_fs: c_int, ++ ceiling_dirs: *const c_char) -> c_int; ++ ++ // revparse ++ pub fn git_revparse(revspec: *mut git_revspec, ++ repo: *mut git_repository, ++ spec: *const c_char) -> c_int; ++ pub fn git_revparse_single(out: *mut *mut git_object, ++ repo: *mut git_repository, ++ spec: *const c_char) -> c_int; ++ pub fn git_revparse_ext(object_out: *mut *mut git_object, ++ reference_out: *mut *mut git_reference, ++ repo: *mut git_repository, ++ spec: *const c_char) -> c_int; ++ ++ // object ++ pub fn git_object_dup(dest: *mut *mut git_object, ++ source: *mut git_object) -> c_int; ++ pub fn git_object_id(obj: *const git_object) -> *const git_oid; ++ pub fn git_object_free(object: *mut git_object); ++ pub fn git_object_lookup(dest: *mut *mut git_object, ++ repo: *mut git_repository, ++ id: *const git_oid, ++ kind: git_otype) -> c_int; ++ pub fn git_object_type(obj: *const git_object) -> git_otype; ++ pub fn git_object_peel(peeled: *mut *mut git_object, ++ object: *const git_object, ++ target_type: git_otype) -> c_int; ++ pub fn git_object_short_id(out: *mut git_buf, ++ obj: *const git_object) -> c_int; ++ pub fn git_object_type2string(kind: git_otype) -> *const c_char; ++ pub fn git_object_string2type(s: *const c_char) -> git_otype; ++ pub fn git_object_typeisloose(kind: git_otype) -> c_int; ++ ++ // oid ++ pub fn git_oid_fromraw(out: *mut git_oid, raw: *const c_uchar); ++ pub fn git_oid_fromstrn(out: *mut git_oid, str: *const c_char, ++ len: size_t) -> c_int; ++ pub fn git_oid_tostr(out: *mut c_char, n: size_t, ++ id: *const git_oid) -> *mut c_char; ++ pub fn git_oid_cmp(a: *const git_oid, b: *const git_oid) -> c_int; ++ pub fn git_oid_equal(a: *const git_oid, b: *const git_oid) -> c_int; ++ pub fn git_oid_streq(id: *const git_oid, str: *const c_char) -> c_int; ++ pub fn git_oid_iszero(id: *const git_oid) -> c_int; ++ ++ // giterr ++ pub fn giterr_last() -> *const git_error; ++ pub fn giterr_clear(); ++ pub fn giterr_set_str(error_class: c_int, string: *const c_char); ++ ++ // remote ++ pub fn git_remote_create(out: *mut *mut git_remote, ++ repo: *mut git_repository, ++ name: *const c_char, ++ url: *const c_char) -> c_int; ++ pub fn git_remote_lookup(out: *mut *mut git_remote, ++ repo: *mut git_repository, ++ name: *const c_char) -> c_int; ++ pub fn git_remote_create_anonymous(out: *mut *mut git_remote, ++ repo: *mut git_repository, ++ url: *const c_char) -> c_int; ++ pub fn git_remote_delete(repo: *mut git_repository, ++ name: *const c_char) -> c_int; ++ pub fn git_remote_free(remote: *mut git_remote); ++ pub fn git_remote_name(remote: *const git_remote) -> *const c_char; ++ pub fn git_remote_pushurl(remote: *const git_remote) -> *const c_char; ++ pub fn git_remote_refspec_count(remote: *const git_remote) -> size_t; ++ pub fn git_remote_url(remote: *const git_remote) -> *const c_char; ++ pub fn git_remote_connect(remote: *mut git_remote, ++ dir: git_direction, ++ callbacks: *const git_remote_callbacks, ++ proxy_opts: *const git_proxy_options, ++ custom_headers: *const git_strarray) -> c_int; ++ pub fn git_remote_connected(remote: *const git_remote) -> c_int; ++ pub fn git_remote_disconnect(remote: *mut git_remote); ++ pub fn git_remote_add_fetch(repo: *mut git_repository, ++ remote: *const c_char, ++ refspec: *const c_char) -> c_int; ++ pub fn git_remote_add_push(repo: *mut git_repository, ++ remote: *const c_char, ++ refspec: *const c_char) -> c_int; ++ pub fn git_remote_download(remote: *mut git_remote, ++ refspecs: *const git_strarray, ++ opts: *const git_fetch_options) -> c_int; ++ pub fn git_remote_stop(remote: *mut git_remote); ++ pub fn git_remote_dup(dest: *mut *mut git_remote, ++ source: *mut git_remote) -> c_int; ++ pub fn git_remote_get_fetch_refspecs(array: *mut git_strarray, ++ remote: *const git_remote) -> c_int; ++ pub fn git_remote_get_push_refspecs(array: *mut git_strarray, ++ remote: *const git_remote) -> c_int; ++ pub fn git_remote_get_refspec(remote: *const git_remote, ++ n: size_t) -> *const git_refspec; ++ pub fn git_remote_is_valid_name(remote_name: *const c_char) -> c_int; ++ pub fn git_remote_list(out: *mut git_strarray, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_remote_rename(problems: *mut git_strarray, ++ repo: *mut git_repository, ++ name: *const c_char, ++ new_name: *const c_char) -> c_int; ++ pub fn git_remote_fetch(remote: *mut git_remote, ++ refspecs: *const git_strarray, ++ opts: *const git_fetch_options, ++ reflog_message: *const c_char) -> c_int; ++ pub fn git_remote_push(remote: *mut git_remote, ++ refspecs: *const git_strarray, ++ opts: *const git_push_options) -> c_int; ++ pub fn git_remote_update_tips(remote: *mut git_remote, ++ callbacks: *const git_remote_callbacks, ++ update_fetchead: c_int, ++ download_tags: git_remote_autotag_option_t, ++ reflog_message: *const c_char) -> c_int; ++ pub fn git_remote_set_url(repo: *mut git_repository, ++ remote: *const c_char, ++ url: *const c_char) -> c_int; ++ pub fn git_remote_set_pushurl(repo: *mut git_repository, ++ remote: *const c_char, ++ pushurl: *const c_char) -> c_int; ++ pub fn git_remote_init_callbacks(opts: *mut git_remote_callbacks, ++ version: c_uint) -> c_int; ++ pub fn git_fetch_init_options(opts: *mut git_fetch_options, ++ version: c_uint) -> c_int; ++ pub fn git_remote_stats(remote: *mut git_remote) ++ -> *const git_transfer_progress; ++ pub fn git_remote_ls(out: *mut *mut *const git_remote_head, ++ size: *mut size_t, ++ remote: *mut git_remote) -> c_int; ++ pub fn git_remote_set_autotag(repo: *mut git_repository, ++ remote: *const c_char, ++ value: git_remote_autotag_option_t) -> c_int; ++ pub fn git_remote_prune(remote: *mut git_remote, ++ callbacks: *const git_remote_callbacks) -> c_int; ++ ++ // refspec ++ pub fn git_refspec_direction(spec: *const git_refspec) -> git_direction; ++ pub fn git_refspec_dst(spec: *const git_refspec) -> *const c_char; ++ pub fn git_refspec_dst_matches(spec: *const git_refspec, ++ refname: *const c_char) -> c_int; ++ pub fn git_refspec_src(spec: *const git_refspec) -> *const c_char; ++ pub fn git_refspec_src_matches(spec: *const git_refspec, ++ refname: *const c_char) -> c_int; ++ pub fn git_refspec_force(spec: *const git_refspec) -> c_int; ++ pub fn git_refspec_string(spec: *const git_refspec) -> *const c_char; ++ ++ // strarray ++ pub fn git_strarray_free(array: *mut git_strarray); ++ ++ // oidarray ++ pub fn git_oidarray_free(array: *mut git_oidarray); ++ ++ // signature ++ pub fn git_signature_default(out: *mut *mut git_signature, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_signature_free(sig: *mut git_signature); ++ pub fn git_signature_new(out: *mut *mut git_signature, ++ name: *const c_char, ++ email: *const c_char, ++ time: git_time_t, ++ offset: c_int) -> c_int; ++ pub fn git_signature_now(out: *mut *mut git_signature, ++ name: *const c_char, ++ email: *const c_char) -> c_int; ++ pub fn git_signature_dup(dest: *mut *mut git_signature, ++ sig: *const git_signature) -> c_int; ++ ++ // status ++ pub fn git_status_list_new(out: *mut *mut git_status_list, ++ repo: *mut git_repository, ++ options: *const git_status_options) -> c_int; ++ pub fn git_status_list_entrycount(list: *mut git_status_list) -> size_t; ++ pub fn git_status_byindex(statuslist: *mut git_status_list, ++ idx: size_t) -> *const git_status_entry; ++ pub fn git_status_list_free(list: *mut git_status_list); ++ pub fn git_status_init_options(opts: *mut git_status_options, ++ version: c_uint) -> c_int; ++ pub fn git_status_file(status_flags: *mut c_uint, ++ repo: *mut git_repository, ++ path: *const c_char) -> c_int; ++ pub fn git_status_should_ignore(ignored: *mut c_int, ++ repo: *mut git_repository, ++ path: *const c_char) -> c_int; ++ ++ // clone ++ pub fn git_clone(out: *mut *mut git_repository, ++ url: *const c_char, ++ local_path: *const c_char, ++ options: *const git_clone_options) -> c_int; ++ pub fn git_clone_init_options(opts: *mut git_clone_options, ++ version: c_uint) -> c_int; ++ ++ // reset ++ pub fn git_reset(repo: *mut git_repository, ++ target: *mut git_object, ++ reset_type: git_reset_t, ++ checkout_opts: *const git_checkout_options) -> c_int; ++ pub fn git_reset_default(repo: *mut git_repository, ++ target: *mut git_object, ++ pathspecs: *mut git_strarray) -> c_int; ++ ++ // reference ++ pub fn git_reference_cmp(ref1: *const git_reference, ++ ref2: *const git_reference) -> c_int; ++ pub fn git_reference_delete(r: *mut git_reference) -> c_int; ++ pub fn git_reference_free(r: *mut git_reference); ++ pub fn git_reference_is_branch(r: *const git_reference) -> c_int; ++ pub fn git_reference_is_note(r: *const git_reference) -> c_int; ++ pub fn git_reference_is_remote(r: *const git_reference) -> c_int; ++ pub fn git_reference_is_tag(r: *const git_reference) -> c_int; ++ pub fn git_reference_is_valid_name(name: *const c_char) -> c_int; ++ pub fn git_reference_lookup(out: *mut *mut git_reference, ++ repo: *mut git_repository, ++ name: *const c_char) -> c_int; ++ pub fn git_reference_name(r: *const git_reference) -> *const c_char; ++ pub fn git_reference_name_to_id(out: *mut git_oid, ++ repo: *mut git_repository, ++ name: *const c_char) -> c_int; ++ pub fn git_reference_peel(out: *mut *mut git_object, ++ r: *mut git_reference, ++ otype: git_otype) -> c_int; ++ pub fn git_reference_rename(new_ref: *mut *mut git_reference, ++ r: *mut git_reference, ++ new_name: *const c_char, ++ force: c_int, ++ log_message: *const c_char) -> c_int; ++ pub fn git_reference_resolve(out: *mut *mut git_reference, ++ r: *const git_reference) -> c_int; ++ pub fn git_reference_shorthand(r: *const git_reference) -> *const c_char; ++ pub fn git_reference_symbolic_target(r: *const git_reference) -> *const c_char; ++ pub fn git_reference_target(r: *const git_reference) -> *const git_oid; ++ pub fn git_reference_target_peel(r: *const git_reference) -> *const git_oid; ++ pub fn git_reference_set_target(out: *mut *mut git_reference, ++ r: *mut git_reference, ++ id: *const git_oid, ++ log_message: *const c_char) -> c_int; ++ pub fn git_reference_type(r: *const git_reference) -> git_ref_t; ++ pub fn git_reference_iterator_new(out: *mut *mut git_reference_iterator, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_reference_iterator_glob_new(out: *mut *mut git_reference_iterator, ++ repo: *mut git_repository, ++ glob: *const c_char) -> c_int; ++ pub fn git_reference_iterator_free(iter: *mut git_reference_iterator); ++ pub fn git_reference_next(out: *mut *mut git_reference, ++ iter: *mut git_reference_iterator) -> c_int; ++ pub fn git_reference_next_name(out: *mut *const c_char, ++ iter: *mut git_reference_iterator) -> c_int; ++ pub fn git_reference_create(out: *mut *mut git_reference, ++ repo: *mut git_repository, ++ name: *const c_char, ++ id: *const git_oid, ++ force: c_int, ++ log_message: *const c_char) -> c_int; ++ pub fn git_reference_symbolic_create(out: *mut *mut git_reference, ++ repo: *mut git_repository, ++ name: *const c_char, ++ target: *const c_char, ++ force: c_int, ++ log_message: *const c_char) -> c_int; ++ pub fn git_reference_create_matching(out: *mut *mut git_reference, ++ repo: *mut git_repository, ++ name: *const c_char, ++ id: *const git_oid, ++ force: c_int, ++ current_id: *const git_oid, ++ log_message: *const c_char) -> c_int; ++ pub fn git_reference_symbolic_create_matching(out: *mut *mut git_reference, ++ repo: *mut git_repository, ++ name: *const c_char, ++ target: *const c_char, ++ force: c_int, ++ current_id: *const c_char, ++ log_message: *const c_char) ++ -> c_int; ++ pub fn git_reference_has_log(repo: *mut git_repository, ++ name: *const c_char) -> c_int; ++ pub fn git_reference_ensure_log(repo: *mut git_repository, ++ name: *const c_char) -> c_int; ++ ++ // stash ++ pub fn git_stash_save(out: *mut git_oid, ++ repo: *mut git_repository, ++ stasher: *const git_signature, ++ message: *const c_char, ++ flags: c_uint) -> c_int; ++ ++ pub fn git_stash_apply_init_options(opts: *mut git_stash_apply_options, ++ version: c_uint) -> c_int; ++ ++ pub fn git_stash_apply(repo: *mut git_repository, ++ index: size_t, ++ options: *const git_stash_apply_options) -> c_int; ++ ++ pub fn git_stash_foreach(repo: *mut git_repository, ++ callback: git_stash_cb, ++ payload: *mut c_void) -> c_int; ++ ++ pub fn git_stash_drop(repo: *mut git_repository, ++ index: size_t) -> c_int; ++ ++ pub fn git_stash_pop(repo: *mut git_repository, ++ index: size_t, ++ options: *const git_stash_apply_options) -> c_int; ++ ++ // submodules ++ pub fn git_submodule_add_finalize(submodule: *mut git_submodule) -> c_int; ++ pub fn git_submodule_add_setup(submodule: *mut *mut git_submodule, ++ repo: *mut git_repository, ++ url: *const c_char, ++ path: *const c_char, ++ use_gitlink: c_int) -> c_int; ++ pub fn git_submodule_add_to_index(submodule: *mut git_submodule, ++ write_index: c_int) -> c_int; ++ pub fn git_submodule_branch(submodule: *mut git_submodule) -> *const c_char; ++ pub fn git_submodule_foreach(repo: *mut git_repository, ++ callback: git_submodule_cb, ++ payload: *mut c_void) -> c_int; ++ pub fn git_submodule_free(submodule: *mut git_submodule); ++ pub fn git_submodule_head_id(submodule: *mut git_submodule) -> *const git_oid; ++ pub fn git_submodule_index_id(submodule: *mut git_submodule) -> *const git_oid; ++ pub fn git_submodule_init(submodule: *mut git_submodule, ++ overwrite: c_int) -> c_int; ++ pub fn git_submodule_location(status: *mut c_uint, ++ submodule: *mut git_submodule) -> c_int; ++ pub fn git_submodule_lookup(out: *mut *mut git_submodule, ++ repo: *mut git_repository, ++ name: *const c_char) -> c_int; ++ pub fn git_submodule_name(submodule: *mut git_submodule) -> *const c_char; ++ pub fn git_submodule_open(repo: *mut *mut git_repository, ++ submodule: *mut git_submodule) -> c_int; ++ pub fn git_submodule_path(submodule: *mut git_submodule) -> *const c_char; ++ pub fn git_submodule_reload(submodule: *mut git_submodule, ++ force: c_int) -> c_int; ++ pub fn git_submodule_set_ignore(repo: *mut git_repository, ++ name: *const c_char, ++ ignore: git_submodule_ignore_t) ++ -> c_int; ++ pub fn git_submodule_set_update(repo: *mut git_repository, ++ name: *const c_char, ++ update: git_submodule_update_t) ++ -> c_int; ++ pub fn git_submodule_set_url(repo: *mut git_repository, ++ name: *const c_char, ++ url: *const c_char) -> c_int; ++ pub fn git_submodule_sync(submodule: *mut git_submodule) -> c_int; ++ pub fn git_submodule_update_strategy(submodule: *mut git_submodule) ++ -> git_submodule_update_t; ++ pub fn git_submodule_update(submodule: *mut git_submodule, ++ init: c_int, ++ options: *mut git_submodule_update_options) ++ -> c_int; ++ pub fn git_submodule_update_init_options(options: *mut git_submodule_update_options, ++ version: c_uint) -> c_int; ++ pub fn git_submodule_url(submodule: *mut git_submodule) -> *const c_char; ++ pub fn git_submodule_wd_id(submodule: *mut git_submodule) -> *const git_oid; ++ pub fn git_submodule_status(status: *mut c_uint, ++ repo: *mut git_repository, ++ name: *const c_char, ++ ignore: git_submodule_ignore_t) -> c_int; ++ pub fn git_submodule_set_branch(repo: *mut git_repository, ++ name: *const c_char, ++ branch: *const c_char) -> c_int; ++ ++ // blob ++ pub fn git_blob_free(blob: *mut git_blob); ++ pub fn git_blob_id(blob: *const git_blob) -> *const git_oid; ++ pub fn git_blob_is_binary(blob: *const git_blob) -> c_int; ++ pub fn git_blob_lookup(blob: *mut *mut git_blob, repo: *mut git_repository, ++ id: *const git_oid) -> c_int; ++ pub fn git_blob_lookup_prefix(blob: *mut *mut git_blob, ++ repo: *mut git_repository, ++ id: *const git_oid, ++ len: size_t) -> c_int; ++ pub fn git_blob_rawcontent(blob: *const git_blob) -> *const c_void; ++ pub fn git_blob_rawsize(blob: *const git_blob) -> git_off_t; ++ pub fn git_blob_create_frombuffer(id: *mut git_oid, ++ repo: *mut git_repository, ++ buffer: *const c_void, ++ len: size_t) -> c_int; ++ pub fn git_blob_create_fromdisk(id: *mut git_oid, ++ repo: *mut git_repository, ++ path: *const c_char) -> c_int; ++ pub fn git_blob_create_fromworkdir(id: *mut git_oid, ++ repo: *mut git_repository, ++ relative_path: *const c_char) -> c_int; ++ pub fn git_blob_create_fromstream(out: *mut *mut git_writestream, ++ repo: *mut git_repository, ++ hintpath: *const c_char) -> c_int; ++ pub fn git_blob_create_fromstream_commit(id: *mut git_oid, ++ stream: *mut git_writestream) -> c_int; ++ ++ // tree ++ pub fn git_tree_entry_byid(tree: *const git_tree, ++ id: *const git_oid) -> *const git_tree_entry; ++ pub fn git_tree_entry_byindex(tree: *const git_tree, ++ idx: size_t) -> *const git_tree_entry; ++ pub fn git_tree_entry_byname(tree: *const git_tree, ++ filename: *const c_char) -> *const git_tree_entry; ++ pub fn git_tree_entry_bypath(out: *mut *mut git_tree_entry, ++ tree: *const git_tree, ++ filename: *const c_char) -> c_int; ++ pub fn git_tree_entry_cmp(e1: *const git_tree_entry, ++ e2: *const git_tree_entry) -> c_int; ++ pub fn git_tree_entry_dup(dest: *mut *mut git_tree_entry, ++ src: *const git_tree_entry) -> c_int; ++ pub fn git_tree_entry_filemode(entry: *const git_tree_entry) -> git_filemode_t; ++ pub fn git_tree_entry_filemode_raw(entry: *const git_tree_entry) -> git_filemode_t; ++ pub fn git_tree_entry_free(entry: *mut git_tree_entry); ++ pub fn git_tree_entry_id(entry: *const git_tree_entry) -> *const git_oid; ++ pub fn git_tree_entry_name(entry: *const git_tree_entry) -> *const c_char; ++ pub fn git_tree_entry_to_object(out: *mut *mut git_object, ++ repo: *mut git_repository, ++ entry: *const git_tree_entry) -> c_int; ++ pub fn git_tree_entry_type(entry: *const git_tree_entry) -> git_otype; ++ pub fn git_tree_entrycount(tree: *const git_tree) -> size_t; ++ pub fn git_tree_free(tree: *mut git_tree); ++ pub fn git_tree_id(tree: *const git_tree) -> *const git_oid; ++ pub fn git_tree_lookup(tree: *mut *mut git_tree, ++ repo: *mut git_repository, ++ id: *const git_oid) -> c_int; ++ pub fn git_tree_walk(tree: *const git_tree, ++ mode: git_treewalk_mode, ++ callback: git_treewalk_cb, ++ payload: *mut c_void) -> c_int; ++ ++ // treebuilder ++ pub fn git_treebuilder_new(out: *mut *mut git_treebuilder, ++ repo: *mut git_repository, ++ source: *const git_tree) -> c_int; ++ pub fn git_treebuilder_clear(bld: *mut git_treebuilder); ++ pub fn git_treebuilder_entrycount(bld: *mut git_treebuilder) -> c_uint; ++ pub fn git_treebuilder_free(bld: *mut git_treebuilder); ++ pub fn git_treebuilder_get(bld: *mut git_treebuilder, ++ filename: *const c_char) -> *const git_tree_entry; ++ pub fn git_treebuilder_insert(out: *mut *const git_tree_entry, ++ bld: *mut git_treebuilder, ++ filename: *const c_char, ++ id: *const git_oid, ++ filemode: git_filemode_t) -> c_int; ++ pub fn git_treebuilder_remove(bld: *mut git_treebuilder, ++ filename: *const c_char) -> c_int; ++ pub fn git_treebuilder_filter(bld: *mut git_treebuilder, ++ filter: git_treebuilder_filter_cb, ++ payload: *mut c_void); ++ pub fn git_treebuilder_write(id: *mut git_oid, ++ bld: *mut git_treebuilder) -> c_int; ++ ++ // buf ++ pub fn git_buf_free(buffer: *mut git_buf); ++ pub fn git_buf_grow(buffer: *mut git_buf, target_size: size_t) -> c_int; ++ pub fn git_buf_set(buffer: *mut git_buf, data: *const c_void, ++ datalen: size_t) -> c_int; ++ ++ // commit ++ pub fn git_commit_author(commit: *const git_commit) -> *const git_signature; ++ pub fn git_commit_committer(commit: *const git_commit) -> *const git_signature; ++ pub fn git_commit_free(commit: *mut git_commit); ++ pub fn git_commit_id(commit: *const git_commit) -> *const git_oid; ++ pub fn git_commit_lookup(commit: *mut *mut git_commit, ++ repo: *mut git_repository, ++ id: *const git_oid) -> c_int; ++ pub fn git_commit_message(commit: *const git_commit) -> *const c_char; ++ pub fn git_commit_message_encoding(commit: *const git_commit) -> *const c_char; ++ pub fn git_commit_message_raw(commit: *const git_commit) -> *const c_char; ++ pub fn git_commit_nth_gen_ancestor(commit: *mut *mut git_commit, ++ commit: *const git_commit, ++ n: c_uint) -> c_int; ++ pub fn git_commit_parent(out: *mut *mut git_commit, ++ commit: *const git_commit, ++ n: c_uint) -> c_int; ++ pub fn git_commit_parent_id(commit: *const git_commit, ++ n: c_uint) -> *const git_oid; ++ pub fn git_commit_parentcount(commit: *const git_commit) -> c_uint; ++ pub fn git_commit_raw_header(commit: *const git_commit) -> *const c_char; ++ pub fn git_commit_summary(commit: *mut git_commit) -> *const c_char; ++ pub fn git_commit_time(commit: *const git_commit) -> git_time_t; ++ pub fn git_commit_time_offset(commit: *const git_commit) -> c_int; ++ pub fn git_commit_tree(tree_out: *mut *mut git_tree, ++ commit: *const git_commit) -> c_int; ++ pub fn git_commit_tree_id(commit: *const git_commit) -> *const git_oid; ++ pub fn git_commit_amend(id: *mut git_oid, ++ commit_to_amend: *const git_commit, ++ update_ref: *const c_char, ++ author: *const git_signature, ++ committer: *const git_signature, ++ message_encoding: *const c_char, ++ message: *const c_char, ++ tree: *const git_tree) -> c_int; ++ pub fn git_commit_create(id: *mut git_oid, ++ repo: *mut git_repository, ++ update_ref: *const c_char, ++ author: *const git_signature, ++ committer: *const git_signature, ++ message_encoding: *const c_char, ++ message: *const c_char, ++ tree: *const git_tree, ++ parent_count: size_t, ++ parents: *mut *const git_commit) -> c_int; ++ pub fn git_commit_header_field(out: *mut git_buf, ++ commit: *const git_commit, ++ field: *const c_char) -> c_int; ++ pub fn git_annotated_commit_lookup(out: *mut *mut git_annotated_commit, ++ repo: *mut git_repository, ++ id: *const git_oid) -> c_int; ++ ++ // branch ++ pub fn git_branch_create(out: *mut *mut git_reference, ++ repo: *mut git_repository, ++ branch_name: *const c_char, ++ target: *const git_commit, ++ force: c_int) -> c_int; ++ pub fn git_branch_delete(branch: *mut git_reference) -> c_int; ++ pub fn git_branch_is_head(branch: *const git_reference) -> c_int; ++ pub fn git_branch_iterator_free(iter: *mut git_branch_iterator); ++ pub fn git_branch_iterator_new(iter: *mut *mut git_branch_iterator, ++ repo: *mut git_repository, ++ list_flags: git_branch_t) -> c_int; ++ pub fn git_branch_lookup(out: *mut *mut git_reference, ++ repo: *mut git_repository, ++ branch_name: *const c_char, ++ branch_type: git_branch_t) -> c_int; ++ pub fn git_branch_move(out: *mut *mut git_reference, ++ branch: *mut git_reference, ++ new_branch_name: *const c_char, ++ force: c_int) -> c_int; ++ pub fn git_branch_name(out: *mut *const c_char, ++ branch: *const git_reference) -> c_int; ++ pub fn git_branch_next(out: *mut *mut git_reference, ++ out_type: *mut git_branch_t, ++ iter: *mut git_branch_iterator) -> c_int; ++ pub fn git_branch_set_upstream(branch: *mut git_reference, ++ upstream_name: *const c_char) -> c_int; ++ pub fn git_branch_upstream(out: *mut *mut git_reference, ++ branch: *const git_reference) -> c_int; ++ ++ // index ++ pub fn git_index_add(index: *mut git_index, ++ entry: *const git_index_entry) -> c_int; ++ pub fn git_index_add_all(index: *mut git_index, ++ pathspec: *const git_strarray, ++ flags: c_uint, ++ callback: Option, ++ payload: *mut c_void) -> c_int; ++ pub fn git_index_add_bypath(index: *mut git_index, ++ path: *const c_char) -> c_int; ++ pub fn git_index_add_frombuffer(index: *mut git_index, ++ entry: *const git_index_entry, ++ buffer: *const c_void, ++ len: size_t) -> c_int; ++ pub fn git_index_conflict_add(index: *mut git_index, ++ ancestor_entry: *const git_index_entry, ++ our_entry: *const git_index_entry, ++ their_entry: *const git_index_entry) -> c_int; ++ pub fn git_index_clear(index: *mut git_index) -> c_int; ++ pub fn git_index_entry_stage(entry: *const git_index_entry) -> c_int; ++ pub fn git_index_entrycount(entry: *const git_index) -> size_t; ++ pub fn git_index_find(at_pos: *mut size_t, ++ index: *mut git_index, ++ path: *const c_char) -> c_int; ++ pub fn git_index_free(index: *mut git_index); ++ pub fn git_index_get_byindex(index: *mut git_index, ++ n: size_t) -> *const git_index_entry; ++ pub fn git_index_get_bypath(index: *mut git_index, ++ path: *const c_char, ++ stage: c_int) -> *const git_index_entry; ++ pub fn git_index_has_conflicts(index: *const git_index) -> c_int; ++ pub fn git_index_new(index: *mut *mut git_index) -> c_int; ++ pub fn git_index_open(index: *mut *mut git_index, ++ index_path: *const c_char) -> c_int; ++ pub fn git_index_path(index: *const git_index) -> *const c_char; ++ pub fn git_index_read(index: *mut git_index, force: c_int) -> c_int; ++ pub fn git_index_read_tree(index: *mut git_index, ++ tree: *const git_tree) -> c_int; ++ pub fn git_index_remove(index: *mut git_index, ++ path: *const c_char, ++ stage: c_int) -> c_int; ++ pub fn git_index_remove_all(index: *mut git_index, ++ pathspec: *const git_strarray, ++ callback: Option, ++ payload: *mut c_void) -> c_int; ++ pub fn git_index_remove_bypath(index: *mut git_index, ++ path: *const c_char) -> c_int; ++ pub fn git_index_remove_directory(index: *mut git_index, ++ dir: *const c_char, ++ stage: c_int) -> c_int; ++ pub fn git_index_update_all(index: *mut git_index, ++ pathspec: *const git_strarray, ++ callback: Option, ++ payload: *mut c_void) -> c_int; ++ pub fn git_index_write(index: *mut git_index) -> c_int; ++ pub fn git_index_write_tree(out: *mut git_oid, ++ index: *mut git_index) -> c_int; ++ pub fn git_index_write_tree_to(out: *mut git_oid, ++ index: *mut git_index, ++ repo: *mut git_repository) -> c_int; ++ ++ // config ++ pub fn git_config_add_file_ondisk(cfg: *mut git_config, ++ path: *const c_char, ++ level: git_config_level_t, ++ force: c_int) -> c_int; ++ pub fn git_config_delete_entry(cfg: *mut git_config, ++ name: *const c_char) -> c_int; ++ pub fn git_config_delete_multivar(cfg: *mut git_config, ++ name: *const c_char, ++ regexp: *const c_char) -> c_int; ++ pub fn git_config_find_programdata(out: *mut git_buf) -> c_int; ++ pub fn git_config_find_global(out: *mut git_buf) -> c_int; ++ pub fn git_config_find_system(out: *mut git_buf) -> c_int; ++ pub fn git_config_find_xdg(out: *mut git_buf) -> c_int; ++ pub fn git_config_free(cfg: *mut git_config); ++ pub fn git_config_get_bool(out: *mut c_int, ++ cfg: *const git_config, ++ name: *const c_char) -> c_int; ++ pub fn git_config_get_entry(out: *mut *mut git_config_entry, ++ cfg: *const git_config, ++ name: *const c_char) -> c_int; ++ pub fn git_config_get_int32(out: *mut i32, ++ cfg: *const git_config, ++ name: *const c_char) -> c_int; ++ pub fn git_config_get_int64(out: *mut i64, ++ cfg: *const git_config, ++ name: *const c_char) -> c_int; ++ pub fn git_config_get_string(out: *mut *const c_char, ++ cfg: *const git_config, ++ name: *const c_char) -> c_int; ++ pub fn git_config_get_string_buf(out: *mut git_buf, ++ cfg: *const git_config, ++ name: *const c_char) -> c_int; ++ pub fn git_config_get_path(out: *mut git_buf, ++ cfg: *const git_config, ++ name: *const c_char) -> c_int; ++ pub fn git_config_iterator_free(iter: *mut git_config_iterator); ++ pub fn git_config_iterator_glob_new(out: *mut *mut git_config_iterator, ++ cfg: *const git_config, ++ regexp: *const c_char) -> c_int; ++ pub fn git_config_iterator_new(out: *mut *mut git_config_iterator, ++ cfg: *const git_config) -> c_int; ++ pub fn git_config_new(out: *mut *mut git_config) -> c_int; ++ pub fn git_config_next(entry: *mut *mut git_config_entry, ++ iter: *mut git_config_iterator) -> c_int; ++ pub fn git_config_open_default(out: *mut *mut git_config) -> c_int; ++ pub fn git_config_open_global(out: *mut *mut git_config, ++ config: *mut git_config) -> c_int; ++ pub fn git_config_open_level(out: *mut *mut git_config, ++ parent: *const git_config, ++ level: git_config_level_t) -> c_int; ++ pub fn git_config_open_ondisk(out: *mut *mut git_config, ++ path: *const c_char) -> c_int; ++ pub fn git_config_parse_bool(out: *mut c_int, ++ value: *const c_char) -> c_int; ++ pub fn git_config_parse_int32(out: *mut i32, ++ value: *const c_char) -> c_int; ++ pub fn git_config_parse_int64(out: *mut i64, ++ value: *const c_char) -> c_int; ++ pub fn git_config_set_bool(cfg: *mut git_config, ++ name: *const c_char, ++ value: c_int) -> c_int; ++ pub fn git_config_set_int32(cfg: *mut git_config, ++ name: *const c_char, ++ value: i32) -> c_int; ++ pub fn git_config_set_int64(cfg: *mut git_config, ++ name: *const c_char, ++ value: i64) -> c_int; ++ pub fn git_config_set_multivar(cfg: *mut git_config, ++ name: *const c_char, ++ regexp: *const c_char, ++ value: *const c_char) -> c_int; ++ pub fn git_config_set_string(cfg: *mut git_config, ++ name: *const c_char, ++ value: *const c_char) -> c_int; ++ pub fn git_config_snapshot(out: *mut *mut git_config, ++ config: *mut git_config) -> c_int; ++ pub fn git_config_entry_free(entry: *mut git_config_entry); ++ ++ // cred ++ pub fn git_cred_default_new(out: *mut *mut git_cred) -> c_int; ++ pub fn git_cred_has_username(cred: *mut git_cred) -> c_int; ++ pub fn git_cred_ssh_custom_new(out: *mut *mut git_cred, ++ username: *const c_char, ++ publickey: *const c_char, ++ publickey_len: size_t, ++ sign_callback: git_cred_sign_callback, ++ payload: *mut c_void) -> c_int; ++ pub fn git_cred_ssh_interactive_new(out: *mut *mut git_cred, ++ username: *const c_char, ++ prompt_callback: git_cred_ssh_interactive_callback, ++ payload: *mut c_void) -> c_int; ++ pub fn git_cred_ssh_key_from_agent(out: *mut *mut git_cred, ++ username: *const c_char) -> c_int; ++ pub fn git_cred_ssh_key_new(out: *mut *mut git_cred, ++ username: *const c_char, ++ publickey: *const c_char, ++ privatekey: *const c_char, ++ passphrase: *const c_char) -> c_int; ++ pub fn git_cred_ssh_key_memory_new(out: *mut *mut git_cred, ++ username: *const c_char, ++ publickey: *const c_char, ++ privatekey: *const c_char, ++ passphrase: *const c_char) -> c_int; ++ pub fn git_cred_userpass(cred: *mut *mut git_cred, ++ url: *const c_char, ++ user_from_url: *const c_char, ++ allowed_types: c_uint, ++ payload: *mut c_void) -> c_int; ++ pub fn git_cred_userpass_plaintext_new(out: *mut *mut git_cred, ++ username: *const c_char, ++ password: *const c_char) -> c_int; ++ pub fn git_cred_username_new(cred: *mut *mut git_cred, ++ username: *const c_char) -> c_int; ++ ++ // tags ++ pub fn git_tag_annotation_create(oid: *mut git_oid, ++ repo: *mut git_repository, ++ tag_name: *const c_char, ++ target: *const git_object, ++ tagger: *const git_signature, ++ message: *const c_char) -> c_int; ++ pub fn git_tag_create(oid: *mut git_oid, ++ repo: *mut git_repository, ++ tag_name: *const c_char, ++ target: *const git_object, ++ tagger: *const git_signature, ++ message: *const c_char, ++ force: c_int) -> c_int; ++ pub fn git_tag_create_frombuffer(oid: *mut git_oid, ++ repo: *mut git_repository, ++ buffer: *const c_char, ++ force: c_int) -> c_int; ++ pub fn git_tag_create_lightweight(oid: *mut git_oid, ++ repo: *mut git_repository, ++ tag_name: *const c_char, ++ target: *const git_object, ++ force: c_int) -> c_int; ++ pub fn git_tag_delete(repo: *mut git_repository, ++ tag_name: *const c_char) -> c_int; ++ pub fn git_tag_foreach(repo: *mut git_repository, ++ callback: git_tag_foreach_cb, ++ payload: *mut c_void) -> c_int; ++ pub fn git_tag_free(tag: *mut git_tag); ++ pub fn git_tag_id(tag: *const git_tag) -> *const git_oid; ++ pub fn git_tag_list(tag_names: *mut git_strarray, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_tag_list_match(tag_names: *mut git_strarray, ++ pattern: *const c_char, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_tag_lookup(out: *mut *mut git_tag, ++ repo: *mut git_repository, ++ id: *const git_oid) -> c_int; ++ pub fn git_tag_lookup_prefix(out: *mut *mut git_tag, ++ repo: *mut git_repository, ++ id: *const git_oid, ++ len: size_t) -> c_int; ++ pub fn git_tag_message(tag: *const git_tag) -> *const c_char; ++ pub fn git_tag_name(tag: *const git_tag) -> *const c_char; ++ pub fn git_tag_peel(tag_target_out: *mut *mut git_object, ++ tag: *const git_tag) -> c_int; ++ pub fn git_tag_tagger(tag: *const git_tag) -> *const git_signature; ++ pub fn git_tag_target(target_out: *mut *mut git_object, ++ tag: *const git_tag) -> c_int; ++ pub fn git_tag_target_id(tag: *const git_tag) -> *const git_oid; ++ pub fn git_tag_target_type(tag: *const git_tag) -> git_otype; ++ ++ // checkout ++ pub fn git_checkout_head(repo: *mut git_repository, ++ opts: *const git_checkout_options) -> c_int; ++ pub fn git_checkout_index(repo: *mut git_repository, ++ index: *mut git_index, ++ opts: *const git_checkout_options) -> c_int; ++ pub fn git_checkout_tree(repo: *mut git_repository, ++ treeish: *const git_object, ++ opts: *const git_checkout_options) -> c_int; ++ pub fn git_checkout_init_options(opts: *mut git_checkout_options, ++ version: c_uint) -> c_int; ++ ++ // merge ++ pub fn git_annotated_commit_id(commit: *const git_annotated_commit) ++ -> *const git_oid; ++ pub fn git_annotated_commit_from_ref(out: *mut *mut git_annotated_commit, ++ repo: *mut git_repository, ++ reference: *const git_reference) ++ -> c_int; ++ pub fn git_annotated_commit_free(commit: *mut git_annotated_commit); ++ pub fn git_merge_init_options(opts: *mut git_merge_options, ++ version: c_uint) -> c_int; ++ pub fn git_merge(repo: *mut git_repository, ++ their_heads: *mut *const git_annotated_commit, ++ len: size_t, ++ merge_opts: *const git_merge_options, ++ checkout_opts: *const git_checkout_options) -> c_int; ++ pub fn git_merge_commits(out: *mut *mut git_index, ++ repo: *mut git_repository, ++ our_commit: *const git_commit, ++ their_commit: *const git_commit, ++ opts: *const git_merge_options) -> c_int; ++ pub fn git_merge_trees(out: *mut *mut git_index, ++ repo: *mut git_repository, ++ ancestor_tree: *const git_tree, ++ our_tree: *const git_tree, ++ their_tree: *const git_tree, ++ opts: *const git_merge_options) -> c_int; ++ pub fn git_repository_state_cleanup(repo: *mut git_repository) -> c_int; ++ ++ // merge analysis ++ ++ pub fn git_merge_analysis(analysis_out: *mut git_merge_analysis_t, ++ pref_out: *mut git_merge_preference_t, ++ repo: *mut git_repository, ++ their_heads: *mut *const git_annotated_commit, ++ their_heads_len: usize) -> c_int; ++ ++ // notes ++ pub fn git_note_author(note: *const git_note) -> *const git_signature; ++ pub fn git_note_committer(note: *const git_note) -> *const git_signature; ++ pub fn git_note_create(out: *mut git_oid, ++ repo: *mut git_repository, ++ notes_ref: *const c_char, ++ author: *const git_signature, ++ committer: *const git_signature, ++ oid: *const git_oid, ++ note: *const c_char, ++ force: c_int) -> c_int; ++ pub fn git_note_default_ref(out: *mut git_buf, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_note_free(note: *mut git_note); ++ pub fn git_note_id(note: *const git_note) -> *const git_oid; ++ pub fn git_note_iterator_free(it: *mut git_note_iterator); ++ pub fn git_note_iterator_new(out: *mut *mut git_note_iterator, ++ repo: *mut git_repository, ++ notes_ref: *const c_char) -> c_int; ++ pub fn git_note_message(note: *const git_note) -> *const c_char; ++ pub fn git_note_next(note_id: *mut git_oid, ++ annotated_id: *mut git_oid, ++ it: *mut git_note_iterator) -> c_int; ++ pub fn git_note_read(out: *mut *mut git_note, ++ repo: *mut git_repository, ++ notes_ref: *const c_char, ++ oid: *const git_oid) -> c_int; ++ pub fn git_note_remove(repo: *mut git_repository, ++ notes_ref: *const c_char, ++ author: *const git_signature, ++ committer: *const git_signature, ++ oid: *const git_oid) -> c_int; ++ ++ // blame ++ pub fn git_blame_file(out: *mut *mut git_blame, ++ repo: *mut git_repository, ++ path: *const c_char, ++ options: *mut git_blame_options) -> c_int; ++ pub fn git_blame_free(blame: *mut git_blame); ++ ++ pub fn git_blame_init_options(opts: *mut git_blame_options, ++ version: c_uint) -> c_int; ++ pub fn git_blame_get_hunk_count(blame: *mut git_blame) -> u32; ++ ++ pub fn git_blame_get_hunk_byline(blame: *mut git_blame, ++ lineno: usize) -> *const git_blame_hunk; ++ pub fn git_blame_get_hunk_byindex(blame: *mut git_blame, ++ index: u32) -> *const git_blame_hunk; ++ ++ // revwalk ++ pub fn git_revwalk_new(out: *mut *mut git_revwalk, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_revwalk_free(walk: *mut git_revwalk); ++ ++ pub fn git_revwalk_reset(walk: *mut git_revwalk); ++ ++ pub fn git_revwalk_sorting(walk: *mut git_revwalk, sort_mode: c_uint); ++ ++ pub fn git_revwalk_push_head(walk: *mut git_revwalk) -> c_int; ++ pub fn git_revwalk_push(walk: *mut git_revwalk, ++ oid: *const git_oid) -> c_int; ++ pub fn git_revwalk_push_ref(walk: *mut git_revwalk, ++ refname: *const c_char) -> c_int; ++ pub fn git_revwalk_push_glob(walk: *mut git_revwalk, ++ glob: *const c_char) -> c_int; ++ pub fn git_revwalk_push_range(walk: *mut git_revwalk, ++ range: *const c_char) -> c_int; ++ pub fn git_revwalk_simplify_first_parent(walk: *mut git_revwalk); ++ ++ pub fn git_revwalk_hide_head(walk: *mut git_revwalk) -> c_int; ++ pub fn git_revwalk_hide(walk: *mut git_revwalk, ++ oid: *const git_oid) -> c_int; ++ pub fn git_revwalk_hide_ref(walk: *mut git_revwalk, ++ refname: *const c_char) -> c_int; ++ pub fn git_revwalk_hide_glob(walk: *mut git_revwalk, ++ refname: *const c_char) -> c_int; ++ pub fn git_revwalk_add_hide_cb(walk: *mut git_revwalk, ++ hide_cb: git_revwalk_hide_cb, ++ payload: *mut c_void) -> c_int; ++ ++ pub fn git_revwalk_next(out: *mut git_oid, walk: *mut git_revwalk) -> c_int; ++ ++ // merge ++ pub fn git_merge_base(out: *mut git_oid, ++ repo: *mut git_repository, ++ one: *const git_oid, ++ two: *const git_oid) -> c_int; ++ ++ pub fn git_merge_bases(out: *mut git_oidarray, ++ repo: *mut git_repository, ++ one: *const git_oid, ++ two: *const git_oid) -> c_int; ++ ++ // pathspec ++ pub fn git_pathspec_free(ps: *mut git_pathspec); ++ pub fn git_pathspec_match_diff(out: *mut *mut git_pathspec_match_list, ++ diff: *mut git_diff, ++ flags: u32, ++ ps: *mut git_pathspec) -> c_int; ++ pub fn git_pathspec_match_index(out: *mut *mut git_pathspec_match_list, ++ index: *mut git_index, ++ flags: u32, ++ ps: *mut git_pathspec) -> c_int; ++ pub fn git_pathspec_match_list_diff_entry(m: *const git_pathspec_match_list, ++ pos: size_t) -> *const git_diff_delta; ++ pub fn git_pathspec_match_list_entry(m: *const git_pathspec_match_list, ++ pos: size_t) -> *const c_char; ++ pub fn git_pathspec_match_list_entrycount(m: *const git_pathspec_match_list) ++ -> size_t; ++ pub fn git_pathspec_match_list_failed_entry(m: *const git_pathspec_match_list, ++ pos: size_t) -> *const c_char; ++ pub fn git_pathspec_match_list_failed_entrycount( ++ m: *const git_pathspec_match_list) -> size_t; ++ pub fn git_pathspec_match_list_free(m: *mut git_pathspec_match_list); ++ pub fn git_pathspec_match_tree(out: *mut *mut git_pathspec_match_list, ++ tree: *mut git_tree, ++ flags: u32, ++ ps: *mut git_pathspec) -> c_int; ++ pub fn git_pathspec_match_workdir(out: *mut *mut git_pathspec_match_list, ++ repo: *mut git_repository, ++ flags: u32, ++ ps: *mut git_pathspec) -> c_int; ++ pub fn git_pathspec_matches_path(ps: *const git_pathspec, ++ flags: u32, ++ path: *const c_char) -> c_int; ++ pub fn git_pathspec_new(out: *mut *mut git_pathspec, ++ pathspec: *const git_strarray) -> c_int; ++ ++ // diff ++ pub fn git_diff_blob_to_buffer(old_blob: *const git_blob, ++ old_as_path: *const c_char, ++ buffer: *const c_char, ++ buffer_len: size_t, ++ buffer_as_path: *const c_char, ++ options: *const git_diff_options, ++ file_cb: git_diff_file_cb, ++ binary_cb: git_diff_binary_cb, ++ hunk_cb: git_diff_hunk_cb, ++ line_cb: git_diff_line_cb, ++ payload: *mut c_void) -> c_int; ++ pub fn git_diff_blobs(old_blob: *const git_blob, ++ old_as_path: *const c_char, ++ new_blob: *const git_blob, ++ new_as_path: *const c_char, ++ options: *const git_diff_options, ++ file_cb: git_diff_file_cb, ++ binary_cb: git_diff_binary_cb, ++ hunk_cb: git_diff_hunk_cb, ++ line_cb: git_diff_line_cb, ++ payload: *mut c_void) -> c_int; ++ pub fn git_diff_buffers(old_buffer: *const c_void, ++ old_len: size_t, ++ old_as_path: *const c_char, ++ new_buffer: *const c_void, ++ new_len: size_t, ++ new_as_path: *const c_char, ++ options: *const git_diff_options, ++ file_cb: git_diff_file_cb, ++ binary_cb: git_diff_binary_cb, ++ hunk_cb: git_diff_hunk_cb, ++ line_cb: git_diff_line_cb, ++ payload: *mut c_void) -> c_int; ++ pub fn git_diff_find_similar(diff: *mut git_diff, ++ options: *const git_diff_find_options) -> c_int; ++ pub fn git_diff_find_init_options(opts: *mut git_diff_find_options, ++ version: c_uint) -> c_int; ++ pub fn git_diff_foreach(diff: *mut git_diff, ++ file_cb: git_diff_file_cb, ++ binary_cb: Option, ++ hunk_cb: Option, ++ line_cb: Option, ++ payload: *mut c_void) -> c_int; ++ pub fn git_diff_free(diff: *mut git_diff); ++ pub fn git_diff_get_delta(diff: *const git_diff, ++ idx: size_t) -> *const git_diff_delta; ++ pub fn git_diff_get_stats(out: *mut *mut git_diff_stats, ++ diff: *mut git_diff) -> c_int; ++ pub fn git_diff_index_to_index(diff: *mut *mut git_diff, ++ repo: *mut git_repository, ++ old_index: *mut git_index, ++ new_index: *mut git_index, ++ opts: *const git_diff_options) -> c_int; ++ pub fn git_diff_index_to_workdir(diff: *mut *mut git_diff, ++ repo: *mut git_repository, ++ index: *mut git_index, ++ opts: *const git_diff_options) -> c_int; ++ pub fn git_diff_init_options(opts: *mut git_diff_options, ++ version: c_uint) -> c_int; ++ pub fn git_diff_is_sorted_icase(diff: *const git_diff) -> c_int; ++ pub fn git_diff_merge(onto: *mut git_diff, ++ from: *const git_diff) -> c_int; ++ pub fn git_diff_num_deltas(diff: *const git_diff) -> size_t; ++ pub fn git_diff_num_deltas_of_type(diff: *const git_diff, ++ delta: git_delta_t) -> size_t; ++ pub fn git_diff_print(diff: *mut git_diff, ++ format: git_diff_format_t, ++ print_cb: git_diff_line_cb, ++ payload: *mut c_void) -> c_int; ++ pub fn git_diff_stats_deletions(stats: *const git_diff_stats) -> size_t; ++ pub fn git_diff_stats_files_changed(stats: *const git_diff_stats) -> size_t; ++ pub fn git_diff_stats_free(stats: *mut git_diff_stats); ++ pub fn git_diff_stats_insertions(stats: *const git_diff_stats) -> size_t; ++ pub fn git_diff_stats_to_buf(out: *mut git_buf, ++ stats: *const git_diff_stats, ++ format: git_diff_stats_format_t, ++ width: size_t) -> c_int; ++ pub fn git_diff_status_char(status: git_delta_t) -> c_char; ++ pub fn git_diff_tree_to_index(diff: *mut *mut git_diff, ++ repo: *mut git_repository, ++ old_tree: *mut git_tree, ++ index: *mut git_index, ++ opts: *const git_diff_options) -> c_int; ++ pub fn git_diff_tree_to_tree(diff: *mut *mut git_diff, ++ repo: *mut git_repository, ++ old_tree: *mut git_tree, ++ new_tree: *mut git_tree, ++ opts: *const git_diff_options) -> c_int; ++ pub fn git_diff_tree_to_workdir(diff: *mut *mut git_diff, ++ repo: *mut git_repository, ++ old_tree: *mut git_tree, ++ opts: *const git_diff_options) -> c_int; ++ pub fn git_diff_tree_to_workdir_with_index(diff: *mut *mut git_diff, ++ repo: *mut git_repository, ++ old_tree: *mut git_tree, ++ opts: *const git_diff_options) ++ -> c_int; ++ ++ pub fn git_graph_ahead_behind(ahead: *mut size_t, behind: *mut size_t, ++ repo: *mut git_repository, ++ local: *const git_oid, upstream: *const git_oid) ++ -> c_int; ++ ++ pub fn git_graph_descendant_of(repo: *mut git_repository, ++ commit: *const git_oid, ancestor: *const git_oid) ++ -> c_int; ++ ++ // patch ++ pub fn git_patch_from_diff(out: *mut *mut git_patch, ++ diff: *mut git_diff, ++ idx: size_t) -> c_int; ++ pub fn git_patch_from_blobs(out: *mut *mut git_patch, ++ old_blob: *const git_blob, ++ old_as_path: *const c_char, ++ new_blob: *const git_blob, ++ new_as_path: *const c_char, ++ opts: *const git_diff_options) -> c_int; ++ pub fn git_patch_from_blob_and_buffer(out: *mut *mut git_patch, ++ old_blob: *const git_blob, ++ old_as_path: *const c_char, ++ buffer: *const c_char, ++ buffer_len: size_t, ++ buffer_as_path: *const c_char, ++ opts: *const git_diff_options) -> c_int; ++ pub fn git_patch_from_buffers(out: *mut *mut git_patch, ++ old_buffer: *const c_void, ++ old_len: size_t, ++ old_as_path: *const c_char, ++ new_buffer: *const c_char, ++ new_len: size_t, ++ new_as_path: *const c_char, ++ opts: *const git_diff_options) -> c_int; ++ pub fn git_patch_free(patch: *mut git_patch); ++ pub fn git_patch_get_delta(patch: *const git_patch) -> *const git_diff_delta; ++ pub fn git_patch_num_hunks(patch: *const git_patch) -> size_t; ++ pub fn git_patch_line_stats(total_context: *mut size_t, ++ total_additions: *mut size_t, ++ total_deletions: *mut size_t, ++ patch: *const git_patch) -> c_int; ++ pub fn git_patch_get_hunk(out: *mut *const git_diff_hunk, ++ lines_in_hunk: *mut size_t, ++ patch: *mut git_patch, ++ hunk_idx: size_t) -> c_int; ++ pub fn git_patch_num_lines_in_hunk(patch: *const git_patch, ++ hunk_idx: size_t) -> c_int; ++ pub fn git_patch_get_line_in_hunk(out: *mut *const git_diff_line, ++ patch: *mut git_patch, ++ hunk_idx: size_t, ++ line_of_hunk: size_t) -> c_int; ++ pub fn git_patch_size(patch: *mut git_patch, ++ include_context: c_int, ++ include_hunk_headers: c_int, ++ include_file_headers: c_int) -> size_t; ++ pub fn git_patch_print(patch: *mut git_patch, ++ print_cb: git_diff_line_cb, ++ payload: *mut c_void) -> c_int; ++ pub fn git_patch_to_buf(buf: *mut git_buf, ++ patch: *mut git_patch) -> c_int; ++ ++ // reflog ++ pub fn git_reflog_append(reflog: *mut git_reflog, ++ id: *const git_oid, ++ committer: *const git_signature, ++ msg: *const c_char) -> c_int; ++ pub fn git_reflog_delete(repo: *mut git_repository, ++ name: *const c_char) -> c_int; ++ pub fn git_reflog_drop(reflog: *mut git_reflog, ++ idx: size_t, ++ rewrite_previous_entry: c_int) -> c_int; ++ pub fn git_reflog_entry_byindex(reflog: *const git_reflog, ++ idx: size_t) -> *const git_reflog_entry; ++ pub fn git_reflog_entry_committer(entry: *const git_reflog_entry) ++ -> *const git_signature; ++ pub fn git_reflog_entry_id_new(entry: *const git_reflog_entry) ++ -> *const git_oid; ++ pub fn git_reflog_entry_id_old(entry: *const git_reflog_entry) ++ -> *const git_oid; ++ pub fn git_reflog_entry_message(entry: *const git_reflog_entry) ++ -> *const c_char; ++ pub fn git_reflog_entrycount(reflog: *mut git_reflog) -> size_t; ++ pub fn git_reflog_free(reflog: *mut git_reflog); ++ pub fn git_reflog_read(out: *mut *mut git_reflog, ++ repo: *mut git_repository, ++ name: *const c_char) -> c_int; ++ pub fn git_reflog_rename(repo: *mut git_repository, ++ old_name: *const c_char, ++ name: *const c_char) -> c_int; ++ pub fn git_reflog_write(reflog: *mut git_reflog) -> c_int; ++ ++ // transport ++ pub fn git_transport_register(prefix: *const c_char, ++ cb: git_transport_cb, ++ param: *mut c_void) -> c_int; ++ pub fn git_transport_unregister(prefix: *const c_char) -> c_int; ++ pub fn git_transport_smart(out: *mut *mut git_transport, ++ owner: *mut git_remote, ++ payload: *mut c_void) -> c_int; ++ ++ // describe ++ pub fn git_describe_commit(result: *mut *mut git_describe_result, ++ object: *mut git_object, ++ opts: *mut git_describe_options) -> c_int; ++ pub fn git_describe_format(buf: *mut git_buf, ++ result: *const git_describe_result, ++ opts: *const git_describe_format_options) -> c_int; ++ pub fn git_describe_result_free(result: *mut git_describe_result); ++ pub fn git_describe_workdir(out: *mut *mut git_describe_result, ++ repo: *mut git_repository, ++ opts: *mut git_describe_options) -> c_int; ++ ++ // message ++ pub fn git_message_prettify(out: *mut git_buf, ++ message: *const c_char, ++ strip_comments: c_int, ++ comment_char: c_char) -> c_int; ++ ++ // packbuilder ++ pub fn git_packbuilder_new(out: *mut *mut git_packbuilder, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_packbuilder_set_threads(pb: *mut git_packbuilder, ++ n: c_uint) -> c_uint; ++ pub fn git_packbuilder_insert(pb: *mut git_packbuilder, ++ id: *const git_oid, ++ name: *const c_char) -> c_int; ++ pub fn git_packbuilder_insert_tree(pb: *mut git_packbuilder, ++ id: *const git_oid) -> c_int; ++ pub fn git_packbuilder_insert_commit(pb: *mut git_packbuilder, ++ id: *const git_oid) -> c_int; ++ pub fn git_packbuilder_insert_walk(pb: *mut git_packbuilder, ++ walk: *mut git_revwalk) -> c_int; ++ pub fn git_packbuilder_insert_recur(pb: *mut git_packbuilder, ++ id: *const git_oid, ++ name: *const c_char) -> c_int; ++ pub fn git_packbuilder_write_buf(buf: *mut git_buf, ++ pb: *mut git_packbuilder) -> c_int; ++ pub fn git_packbuilder_write(pb: *mut git_packbuilder, ++ path: *const c_char, ++ mode: c_uint, ++ progress_cb: Option, ++ progress_cb_payload: *mut c_void) -> c_int; ++ pub fn git_packbuilder_hash(pb: *mut git_packbuilder) -> *const git_oid; ++ pub fn git_packbuilder_foreach(pb: *mut git_packbuilder, ++ cb: git_packbuilder_foreach_cb, ++ payload: *mut c_void) -> c_int; ++ pub fn git_packbuilder_object_count(pb: *mut git_packbuilder) -> size_t; ++ pub fn git_packbuilder_written(pb: *mut git_packbuilder) -> size_t; ++ pub fn git_packbuilder_set_callbacks(pb: *mut git_packbuilder, ++ progress_cb: Option, ++ progress_cb_payload: *mut c_void) -> c_int; ++ pub fn git_packbuilder_free(pb: *mut git_packbuilder); ++ ++ // odb ++ pub fn git_repository_odb(out: *mut *mut git_odb, ++ repo: *mut git_repository) -> c_int; ++ pub fn git_odb_free(db: *mut git_odb); ++ pub fn git_odb_open_rstream(out: *mut *mut git_odb_stream, ++ db: *mut git_odb, ++ oid: *const git_oid) -> c_int; ++ pub fn git_odb_stream_read(stream: *mut git_odb_stream, ++ buffer: *mut c_char, ++ len: size_t) -> c_int; ++ pub fn git_odb_open_wstream(out: *mut *mut git_odb_stream, ++ db: *mut git_odb, ++ size: git_off_t, ++ obj_type: git_otype) -> c_int; ++ pub fn git_odb_stream_write(stream: *mut git_odb_stream, ++ buffer: *const c_char, ++ len: size_t) -> c_int; ++ pub fn git_odb_stream_finalize_write(id: *mut git_oid, ++ stream: *mut git_odb_stream) -> c_int; ++ pub fn git_odb_stream_free(stream: *mut git_odb_stream); ++ pub fn git_odb_foreach(db: *mut git_odb, cb: git_odb_foreach_cb, payload: *mut c_void) -> c_int; ++} ++ ++pub fn init() { ++ use std::sync::{Once, ONCE_INIT}; ++ ++ static INIT: Once = ONCE_INIT; ++ INIT.call_once(|| unsafe { ++ openssl_init(); ++ ssh_init(); ++ let r = git_libgit2_init(); ++ assert!(r >= 0, ++ "couldn't initialize the libgit2 library: {}", r); ++ assert_eq!(libc::atexit(shutdown), 0); ++ }); ++ extern fn shutdown() { ++ unsafe { git_libgit2_shutdown(); } ++ } ++} ++ ++#[cfg(all(unix, feature = "https"))] ++#[doc(hidden)] ++pub fn openssl_init() { ++ openssl_sys::init(); ++} ++ ++#[cfg(any(windows, not(feature = "https")))] ++#[doc(hidden)] ++pub fn openssl_init() {} ++ ++#[cfg(feature = "ssh")] ++fn ssh_init() { ++ libssh2::init(); ++} ++ ++#[cfg(not(feature = "ssh"))] ++fn ssh_init() {} diff --cc vendor/libz-sys-1.0.17/.cargo-checksum.json index 000000000,000000000..ca312d01a new file mode 100644 --- /dev/null +++ b/vendor/libz-sys-1.0.17/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"44ebbc760fd2d2f4d93de09a0e13d97e057612052e871da9985cedcb451e6bd5"} diff --cc vendor/libz-sys-1.0.17/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/libz-sys-1.0.17/.cargo-ok diff --cc vendor/libz-sys-1.0.17/.travis.yml index 000000000,000000000..6a764baa5 new file mode 100644 --- /dev/null +++ b/vendor/libz-sys-1.0.17/.travis.yml @@@ -1,0 -1,0 +1,29 @@@ ++language: rust ++sudo: false ++matrix: ++ include: ++ - rust: stable ++ - os: osx ++ ++ - env: LIBZ_SYS_STATIC=1 ++ - env: LIBZ_SYS_STATIC=1 ++ os: osx ++ ++ - rust: beta ++ - rust: nightly ++ before_script: ++ - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH ++ after_success: ++ - travis-cargo doc-upload ++ ++script: ++ - cargo test ++ - cargo run --manifest-path systest/Cargo.toml ++ - cargo doc --no-deps ++ ++notifications: ++ email: ++ on_success: never ++env: ++ global: ++ secure: "eq1KPWs3sNmvrQj6ayLRrY2Jqwpx4p9CNU5gRU6LCdx2otIQqKXY1Jj9E6uvQIspL6ZpCNzYDMDUSsRdNahdx59WQGD/mxdrFWStUonJ4t0al2FIQ97NaEy57r4vw36oViDCzqZudDlsacHZnpCpI8ei6AB73rGXfxc3g3fxk6o=" diff --cc vendor/libz-sys-1.0.17/Cargo.toml index 000000000,000000000..c4d7147e4 new file mode 100644 --- /dev/null +++ b/vendor/libz-sys-1.0.17/Cargo.toml @@@ -1,0 -1,0 +1,32 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "libz-sys" ++version = "1.0.17" ++authors = ["Alex Crichton "] ++build = "build.rs" ++links = "z" ++description = "Bindings to the system libz library (also known as zlib).\n" ++documentation = "https://docs.rs/libz-sys" ++categories = ["external-ffi-bindings"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/libz-sys" ++[dependencies.libc] ++version = "0.2" ++[build-dependencies.cc] ++version = "1.0" ++ ++[build-dependencies.pkg-config] ++version = "0.3" ++[target."cfg(target_env = \"msvc\")".build-dependencies.vcpkg] ++version = "0.2" diff --cc vendor/libz-sys-1.0.17/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/libz-sys-1.0.17/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/libz-sys-1.0.17/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/libz-sys-1.0.17/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/libz-sys-1.0.17/README.md index 000000000,000000000..bc16fd720 new file mode 100644 --- /dev/null +++ b/vendor/libz-sys-1.0.17/README.md @@@ -1,0 -1,0 +1,16 @@@ ++# libz-sys ++ ++A common library for linking `libz` to rust programs (also known as zlib). ++ ++[![Build Status](https://travis-ci.org/alexcrichton/libz-sys.svg?branch=master)](https://travis-ci.org/alexcrichton/libz-sys) ++[![Build status](https://ci.appveyor.com/api/projects/status/et3ae5mgpbokh9g9?svg=true)](https://ci.appveyor.com/project/alexcrichton/libz-sys) ++ ++[Documentation](https://docs.rs/libz-sys) ++ ++# License ++ ++`libz-sys` 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 --cc vendor/libz-sys-1.0.17/appveyor.yml index 000000000,000000000..c9b348d6d new file mode 100644 --- /dev/null +++ b/vendor/libz-sys-1.0.17/appveyor.yml @@@ -1,0 -1,0 +1,29 @@@ ++environment: ++ matrix: ++ - TARGET: x86_64-pc-windows-gnu ++ MSYS_BITS: 64 ++ - TARGET: i686-pc-windows-gnu ++ MSYS_BITS: 32 ++ - TARGET: x86_64-pc-windows-msvc ++ - TARGET: i686-pc-windows-msvc ++ - TARGET: x86_64-pc-windows-msvc ++ VCPKG_DEFAULT_TRIPLET: x64-windows-static ++ RUSTFLAGS: -Ctarget-feature=+crt-static ++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 ++ - if defined MSYS_BITS set PATH=%PATH%;C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin ++ - rustc -V ++ - cargo -V ++ - if defined VCPKG_DEFAULT_TRIPLET git clone https://github.com/Microsoft/vcpkg c:\projects\vcpkg ++ - if defined VCPKG_DEFAULT_TRIPLET c:\projects\vcpkg\bootstrap-vcpkg.bat ++ - if defined VCPKG_DEFAULT_TRIPLET set VCPKG_ROOT=c:\projects\vcpkg ++ - if defined VCPKG_DEFAULT_TRIPLET echo yes > %VCPKG_ROOT%\Downloads\AlwaysAllowDownloads ++ - if defined VCPKG_DEFAULT_TRIPLET %VCPKG_ROOT%\vcpkg.exe install zlib ++ ++build: false ++ ++test_script: ++ - cargo test --target %TARGET% ++ - cargo run --manifest-path systest/Cargo.toml --target %TARGET% diff --cc vendor/libz-sys-1.0.17/build.rs index 000000000,000000000..2759b4611 new file mode 100644 --- /dev/null +++ b/vendor/libz-sys-1.0.17/build.rs @@@ -1,0 -1,0 +1,267 @@@ ++extern crate pkg_config; ++#[cfg(target_env = "msvc")] ++extern crate vcpkg; ++extern crate cc; ++ ++use std::env; ++use std::ffi::OsString; ++use std::fs::{self, File}; ++use std::io::prelude::*; ++use std::io; ++use std::path::{Path, PathBuf}; ++use std::process::Command; ++ ++macro_rules! t { ++ ($e:expr) => (match $e { ++ Ok(n) => n, ++ Err(e) => panic!("\n{} failed with {}\n", stringify!($e), e), ++ }) ++} ++ ++fn main() { ++ let host = env::var("HOST").unwrap(); ++ let target = env::var("TARGET").unwrap(); ++ ++ // Don't run pkg-config if we're linking statically (we'll build below) and ++ // also don't run pkg-config on OSX. That'll end up printing `-L /usr/lib` ++ // which wreaks havoc with linking to an OpenSSL in /usr/local/lib (e.g. ++ // homebrew) ++ let want_static = env::var("LIBZ_SYS_STATIC").unwrap_or(String::new()) == "1"; ++ if !want_static && ++ !(host.contains("apple") && target.contains("apple")) && ++ pkg_config::find_library("zlib").is_ok() { ++ return ++ } ++ ++ // Practically all platforms come with libz installed already, but MSVC is ++ // one of those sole platforms that doesn't! ++ if target.contains("msvc") { ++ if try_vcpkg() { ++ return; ++ } ++ ++ build_msvc_zlib(&target); ++ } else if target.contains("pc-windows-gnu") { ++ build_zlib_mingw(); ++ } else if (target.contains("musl") || ++ target != host || ++ want_static) && ++ !target.contains("windows-gnu") && ++ !target.contains("android") { ++ build_zlib(); ++ } else { ++ println!("cargo:rustc-link-lib=z"); ++ } ++} ++ ++fn build_zlib() { ++ let src = env::current_dir().unwrap().join("src/zlib-1.2.11"); ++ let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); ++ let build = dst.join("build"); ++ t!(fs::create_dir_all(&build)); ++ cp_r(&src, &build); ++ let compiler = cc::Build::new().get_compiler(); ++ let mut cflags = OsString::new(); ++ for arg in compiler.args() { ++ cflags.push(arg); ++ cflags.push(" "); ++ } ++ run(Command::new("./configure") ++ .current_dir(&build) ++ .env("CC", compiler.path()) ++ .env("CFLAGS", cflags) ++ .arg(format!("--prefix={}", dst.display())), "sh"); ++ run(make() ++ .current_dir(&build) ++ .arg("libz.a"), "make"); ++ ++ t!(fs::create_dir_all(dst.join("lib/pkgconfig"))); ++ t!(fs::create_dir_all(dst.join("include"))); ++ t!(fs::copy(build.join("libz.a"), dst.join("lib/libz.a"))); ++ t!(fs::copy(build.join("zlib.h"), dst.join("include/zlib.h"))); ++ t!(fs::copy(build.join("zconf.h"), dst.join("include/zconf.h"))); ++ t!(fs::copy(build.join("zlib.pc"), dst.join("lib/pkgconfig/zlib.pc"))); ++ ++ println!("cargo:rustc-link-lib=static=z"); ++ println!("cargo:rustc-link-search={}/lib", dst.to_string_lossy()); ++ println!("cargo:root={}", dst.to_string_lossy()); ++ println!("cargo:include={}/include", dst.to_string_lossy()); ++} ++ ++fn make() -> Command { ++ let cmd = if cfg!(any(target_os = "freebsd", target_os = "dragonfly")) {"gmake"} else {"make"}; ++ let mut cmd = Command::new(cmd); ++ // We're using the MSYS make which doesn't work with the mingw32-make-style ++ // MAKEFLAGS, so remove that from the env if present. ++ if cfg!(windows) { ++ cmd.env_remove("MAKEFLAGS").env_remove("MFLAGS"); ++ } ++ return cmd ++} ++ ++// We have to run a few shell scripts, which choke quite a bit on both `\` ++// characters and on `C:\` paths, so normalize both of them away. ++fn sanitize_sh(path: &Path) -> String { ++ let path = path.to_str().unwrap().replace("\\", "/"); ++ return change_drive(&path).unwrap_or(path); ++ ++ fn change_drive(s: &str) -> Option { ++ let mut ch = s.chars(); ++ let drive = ch.next().unwrap_or('C'); ++ if ch.next() != Some(':') { ++ return None ++ } ++ if ch.next() != Some('/') { ++ return None ++ } ++ Some(format!("/{}/{}", drive, &s[drive.len_utf8() + 2..])) ++ } ++} ++ ++fn build_zlib_mingw() { ++ let src = env::current_dir().unwrap().join("src/zlib-1.2.11"); ++ let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); ++ let build = dst.join("build"); ++ t!(fs::create_dir_all(&build)); ++ cp_r(&src, &build); ++ let compiler = cc::Build::new().get_compiler(); ++ let mut cflags = OsString::new(); ++ for arg in compiler.args() { ++ cflags.push(arg); ++ cflags.push(" "); ++ } ++ let gcc = sanitize_sh(compiler.path()); ++ let mut cmd = make(); ++ cmd.arg("-f").arg("win32/Makefile.gcc") ++ .current_dir(&build) ++ .arg("install") ++ .arg(format!("prefix={}", sanitize_sh(&dst))) ++ .arg("IMPLIB=") ++ .arg(format!("INCLUDE_PATH={}", sanitize_sh(&dst.join("include")))) ++ .arg(format!("LIBRARY_PATH={}", sanitize_sh(&dst.join("lib")))) ++ .arg(format!("BINARY_PATH={}", sanitize_sh(&dst.join("bin")))) ++ .env("CFLAGS", cflags); ++ ++ if gcc != "gcc" { ++ match gcc.find("gcc") { ++ Some(0) => {} ++ Some(i) => { ++ cmd.arg(format!("PREFIX={}", &gcc[..i])); ++ } ++ None => {} ++ } ++ } ++ run(&mut cmd, "make"); ++ ++ t!(fs::create_dir_all(dst.join("lib/pkgconfig"))); ++ ++ println!("cargo:rustc-link-lib=static=z"); ++ println!("cargo:rustc-link-search={}/lib", dst.to_string_lossy()); ++ println!("cargo:root={}", dst.to_string_lossy()); ++ println!("cargo:include={}/include", dst.to_string_lossy()); ++} ++ ++fn cp_r(dir: &Path, dst: &Path) { ++ for entry in t!(fs::read_dir(dir)) { ++ let entry = t!(entry); ++ let path = entry.path(); ++ let dst = dst.join(path.file_name().unwrap()); ++ if t!(fs::metadata(&path)).is_file() { ++ t!(fs::copy(path, dst)); ++ } else { ++ t!(fs::create_dir_all(&dst)); ++ cp_r(&path, &dst); ++ } ++ } ++} ++ ++fn build_msvc_zlib(target: &str) { ++ let src = t!(env::current_dir()).join("src/zlib-1.2.11"); ++ let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); ++ ++ t!(fs::create_dir_all(dst.join("lib"))); ++ t!(fs::create_dir_all(dst.join("include"))); ++ t!(fs::create_dir_all(dst.join("build"))); ++ cp_r(&src, &dst.join("build")); ++ ++ let features = env::var("CARGO_CFG_TARGET_FEATURE") ++ .unwrap_or(String::new()); ++ if features.contains("crt-static") { ++ let mut makefile = String::new(); ++ let makefile_path = dst.join("build/win32/Makefile.msc"); ++ t!(t!(File::open(&makefile_path)).read_to_string(&mut makefile)); ++ let new_makefile = makefile.replace(" -MD ", " -MT "); ++ t!(t!(File::create(&makefile_path)).write_all(new_makefile.as_bytes())); ++ } ++ ++ let nmake = cc::windows_registry::find(target, "nmake.exe"); ++ let mut nmake = nmake.unwrap_or(Command::new("nmake.exe")); ++ ++ // These env vars are intended for mingw32-make, not `namek`, which chokes ++ // on them anyway. ++ nmake.env_remove("MAKEFLAGS") ++ .env_remove("MFLAGS"); ++ ++ run(nmake.current_dir(dst.join("build")) ++ .arg("/nologo") ++ .arg("/f") ++ .arg(dst.join("build/win32/Makefile.msc")) ++ .arg("zlib.lib"), "nmake.exe"); ++ ++ for file in t!(fs::read_dir(&dst.join("build"))) { ++ let file = t!(file).path(); ++ if let Some(s) = file.file_name().and_then(|s| s.to_str()) { ++ if s.ends_with(".h") { ++ t!(fs::copy(&file, dst.join("include").join(s))); ++ } ++ } ++ } ++ t!(fs::copy(dst.join("build/zlib.lib"), dst.join("lib/zlib.lib"))); ++ ++ println!("cargo:rustc-link-lib=static=zlib"); ++ println!("cargo:rustc-link-search={}/lib", dst.to_string_lossy()); ++ println!("cargo:root={}", dst.to_string_lossy()); ++ println!("cargo:include={}/include", dst.to_string_lossy()); ++} ++ ++fn run(cmd: &mut Command, program: &str) { ++ println!("running: {:?}", cmd); ++ let status = match cmd.status() { ++ Ok(status) => status, ++ Err(ref e) if e.kind() == io::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 fail(s: &str) -> ! { ++ println!("\n\n{}\n\n", s); ++ std::process::exit(1); ++} ++ ++#[cfg(not(target_env = "msvc"))] ++fn try_vcpkg() -> bool { ++ false ++} ++ ++#[cfg(target_env = "msvc")] ++fn try_vcpkg() -> bool { ++ // see if there is a vcpkg tree with zlib installed ++ match vcpkg::Config::new() ++ .emit_includes(true) ++ .lib_names("zlib", "zlib1") ++ .probe("zlib") { ++ Ok(_) => { true }, ++ Err(e) => { ++ println!("note, vcpkg did not find zlib: {}", e); ++ false ++ }, ++ } ++} diff --cc vendor/libz-sys-1.0.17/src/lib.rs index 000000000,000000000..7d5ddee68 new file mode 100644 --- /dev/null +++ b/vendor/libz-sys-1.0.17/src/lib.rs @@@ -1,0 -1,0 +1,236 @@@ ++#![doc(html_root_url = "https://docs.rs/libz-sys/1.0")] ++#![allow(non_camel_case_types)] ++ ++extern crate libc; ++ ++use libc::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong, c_void}; ++ ++pub type alloc_func = unsafe extern fn (voidpf, uInt, uInt) -> voidpf; ++pub type Bytef = u8; ++pub type free_func = unsafe extern fn (voidpf, voidpf); ++pub type gzFile = *mut gzFile_s; ++pub type in_func = unsafe extern fn (*mut c_void, *mut *const c_uchar) -> c_uint; ++pub type out_func = unsafe extern fn (*mut c_void, *mut c_uchar, c_uint) -> c_int; ++pub type uInt = c_uint; ++pub type uLong = c_ulong; ++pub type uLongf = c_ulong; ++pub type voidp = *mut c_void; ++pub type voidpc = *const c_void; ++pub type voidpf = *mut c_void; ++ ++pub enum gzFile_s {} ++pub enum internal_state {} ++ ++#[cfg(unix)] pub type z_off_t = libc::off_t; ++#[cfg(not(unix))] pub type z_off_t = c_long; ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct gz_header { ++ pub text: c_int, ++ pub time: uLong, ++ pub xflags: c_int, ++ pub os: c_int, ++ pub extra: *mut Bytef, ++ pub extra_len: uInt, ++ pub extra_max: uInt, ++ pub name: *mut Bytef, ++ pub name_max: uInt, ++ pub comment: *mut Bytef, ++ pub comm_max: uInt, ++ pub hcrc: c_int, ++ pub done: c_int, ++} ++pub type gz_headerp = *mut gz_header; ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub struct z_stream { ++ pub next_in: *mut Bytef, ++ pub avail_in: uInt, ++ pub total_in: uLong, ++ pub next_out: *mut Bytef, ++ pub avail_out: uInt, ++ pub total_out: uLong, ++ pub msg: *mut c_char, ++ pub state: *mut internal_state, ++ pub zalloc: alloc_func, ++ pub zfree: free_func, ++ pub opaque: voidpf, ++ pub data_type: c_int, ++ pub adler: uLong, ++ pub reserved: uLong, ++} ++pub type z_streamp = *mut z_stream; ++ ++macro_rules! fns { ++ ($($arg:tt)*) => { ++ item! { ++ #[cfg(all(target_env = "msvc", target_pointer_width = "32"))] ++ extern { $($arg)* } ++ } ++ item! { ++ #[cfg(not(all(target_env = "msvc", target_pointer_width = "32")))] ++ extern "system" { $($arg)* } ++ } ++ } ++} ++ ++macro_rules! item { ++ ($i:item) => ($i) ++} ++ ++fns! { ++ pub fn adler32(adler: uLong, buf: *const Bytef, len: uInt) -> uLong; ++ pub fn adler32_combine(adler1: uLong, adler2: uLong, len2: z_off_t) -> uLong; ++ pub fn compress(dest: *mut Bytef, destLen: *mut uLongf, ++ source: *const Bytef, sourceLen: uLong) -> c_int; ++ pub fn compress2(dest: *mut Bytef, destLen: *mut uLongf, ++ source: *const Bytef, sourceLen: uLong, ++ level: c_int) -> c_int; ++ pub fn compressBound(sourceLen: uLong) -> uLong; ++ pub fn crc32(crc: uLong, buf: *const Bytef, len: uInt) -> uLong; ++ pub fn crc32_combine(crc1: uLong, crc2: uLong, len2: z_off_t) -> uLong; ++ pub fn deflate(strm: z_streamp, flush: c_int) -> c_int; ++ pub fn deflateBound(strm: z_streamp, sourceLen: uLong) -> uLong; ++ pub fn deflateCopy(dest: z_streamp, source: z_streamp) -> c_int; ++ pub fn deflateEnd(strm: z_streamp) -> c_int; ++ pub fn deflateInit_(strm: z_streamp, level: c_int, ++ version: *const c_char, ++ stream_size: c_int) -> c_int; ++ pub fn deflateInit2_(strm: z_streamp, ++ level: c_int, ++ method: c_int, ++ windowBits: c_int, ++ memLevel: c_int, ++ strategy: c_int, ++ version: *const c_char, ++ stream_size: c_int) -> c_int; ++ pub fn deflateParams(strm: z_streamp, ++ level: c_int, ++ strategy: c_int) -> c_int; ++ pub fn deflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int; ++ pub fn deflateReset(strm: z_streamp) -> c_int; ++ pub fn deflateSetDictionary(strm: z_streamp, ++ dictionary: *const Bytef, ++ dictLength: uInt) -> c_int; ++ pub fn deflateSetHeader(strm: z_streamp, head: gz_headerp) -> c_int; ++ pub fn deflateTune(strm: z_streamp, ++ good_length: c_int, ++ max_lazy: c_int, ++ nice_length: c_int, ++ max_chain: c_int) -> c_int; ++ pub fn gzdirect(file: gzFile) -> c_int; ++ pub fn gzdopen(fd: c_int, mode: *const c_char) -> gzFile; ++ pub fn gzclearerr(file: gzFile); ++ pub fn gzclose(file: gzFile) -> c_int; ++ pub fn gzeof(file: gzFile) -> c_int; ++ pub fn gzerror(file: gzFile, errnum: *mut c_int) -> *const c_char; ++ pub fn gzflush(file: gzFile, flush: c_int) -> c_int; ++ pub fn gzgetc(file: gzFile) -> c_int; ++ pub fn gzgets(file: gzFile, buf: *mut c_char, len: c_int) -> *mut c_char; ++ pub fn gzopen(path: *const c_char, mode: *const c_char) -> gzFile; ++ pub fn gzputc(file: gzFile, c: c_int) -> c_int; ++ pub fn gzputs(file: gzFile, s: *const c_char) -> c_int; ++ pub fn gzread(file: gzFile, buf: voidp, len: c_uint) -> c_int; ++ pub fn gzrewind(file: gzFile) -> c_int; ++ pub fn gzseek(file: gzFile, offset: z_off_t, whence: c_int) -> z_off_t; ++ pub fn gzsetparams(file: gzFile, level: c_int, strategy: c_int) -> c_int; ++ pub fn gztell(file: gzFile) -> z_off_t; ++ pub fn gzungetc(c: c_int, file: gzFile) -> c_int; ++ pub fn gzwrite(file: gzFile, buf: voidpc, len: c_uint) -> c_int; ++ pub fn inflate(strm: z_streamp, flush: c_int) -> c_int; ++ pub fn inflateBack(strm: z_streamp, ++ _in: in_func, ++ in_desc: *mut c_void, ++ out: out_func, ++ out_desc: *mut c_void) -> c_int; ++ pub fn inflateBackEnd(strm: z_streamp) -> c_int; ++ pub fn inflateBackInit_(strm: z_streamp, ++ windowBits: c_int, ++ window: *mut c_uchar, ++ version: *const c_char, ++ stream_size: c_int) -> c_int; ++ pub fn inflateCopy(dest: z_streamp, source: z_streamp) -> c_int; ++ pub fn inflateEnd(strm: z_streamp) -> c_int; ++ pub fn inflateGetHeader(strm: z_streamp, head: gz_headerp) -> c_int; ++ pub fn inflateInit_(strm: z_streamp, ++ version: *const c_char, ++ stream_size: c_int) -> c_int; ++ pub fn inflateInit2_(strm: z_streamp, ++ windowBits: c_int, ++ version: *const c_char, ++ stream_size: c_int) -> c_int; ++ pub fn inflateMark(strm: z_streamp) -> c_long; ++ pub fn inflatePrime(strm: z_streamp, bits: c_int, value: c_int) -> c_int; ++ pub fn inflateReset(strm: z_streamp) -> c_int; ++ pub fn inflateReset2(strm: z_streamp, windowBits: c_int) -> c_int; ++ pub fn inflateSetDictionary(strm: z_streamp, ++ dictionary: *const Bytef, ++ dictLength: uInt) -> c_int; ++ pub fn inflateSync(strm: z_streamp) -> c_int; ++ pub fn uncompress(dest: *mut Bytef, ++ destLen: *mut uLongf, ++ source: *const Bytef, ++ sourceLen: uLong) -> c_int; ++ pub fn zlibCompileFlags() -> uLong; ++ pub fn zlibVersion() -> *const c_char; ++ ++ ++// The above set of functions currently target 1.2.3.4 (what's present on Ubuntu ++// 12.04, but there's some other APIs that were added later. Should figure out ++// how to expose them... ++// ++// Added in 1.2.5.1 ++// ++// pub fn deflatePending(strm: z_streamp, ++// pending: *mut c_uint, ++// bits: *mut c_int) -> c_int; ++// ++// Addedin 1.2.7.1 ++// pub fn inflateGetDictionary(strm: z_streamp, ++// dictionary: *mut Bytef, ++// dictLength: *mut uInt) -> c_int; ++// ++// Added in 1.2.3.5 ++// pub fn gzbuffer(file: gzFile, size: c_uint) -> c_int; ++// pub fn gzclose_r(file: gzFile) -> c_int; ++// pub fn gzclose_w(file: gzFile) -> c_int; ++// pub fn gzoffset(file: gzFile) -> z_off_t; ++} ++ ++pub const Z_NO_FLUSH: c_int = 0; ++pub const Z_PARTIAL_FLUSH: c_int = 1; ++pub const Z_SYNC_FLUSH: c_int = 2; ++pub const Z_FULL_FLUSH: c_int = 3; ++pub const Z_FINISH: c_int = 4; ++pub const Z_BLOCK: c_int = 5; ++pub const Z_TREES: c_int = 6; ++ ++pub const Z_OK: c_int = 0; ++pub const Z_STREAM_END: c_int = 1; ++pub const Z_NEED_DICT: c_int = 2; ++pub const Z_ERRNO: c_int = -1; ++pub const Z_STREAM_ERROR: c_int = -2; ++pub const Z_DATA_ERROR: c_int = -3; ++pub const Z_MEM_ERROR: c_int = -4; ++pub const Z_BUF_ERROR: c_int = -5; ++pub const Z_VERSION_ERROR: c_int = -6; ++ ++pub const Z_NO_COMPRESSION: c_int = 0; ++pub const Z_BEST_SPEED: c_int = 1; ++pub const Z_BEST_COMPRESSION: c_int = 9; ++pub const Z_DEFAULT_COMPRESSION: c_int = -1; ++ ++pub const Z_FILTERED: c_int = 1; ++pub const Z_HUFFMAN_ONLY: c_int = 2; ++pub const Z_RLE: c_int = 3; ++pub const Z_FIXED: c_int = 4; ++pub const Z_DEFAULT_STRATEGY: c_int = 0; ++ ++pub const Z_BINARY: c_int = 0; ++pub const Z_TEXT: c_int = 1; ++pub const Z_ASCII: c_int = Z_TEXT; ++pub const Z_UNKNOWN: c_int = 2; ++ ++pub const Z_DEFLATED: c_int = 8; diff --cc vendor/miniz-sys-0.1.10/.cargo-checksum.json index 000000000,000000000..494cebdda new file mode 100644 --- /dev/null +++ b/vendor/miniz-sys-0.1.10/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4"} diff --cc vendor/miniz-sys-0.1.10/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/miniz-sys-0.1.10/.cargo-ok diff --cc vendor/miniz-sys-0.1.10/Cargo.toml index 000000000,000000000..ee8f26d20 new file mode 100644 --- /dev/null +++ b/vendor/miniz-sys-0.1.10/Cargo.toml @@@ -1,0 -1,0 +1,31 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "miniz-sys" ++version = "0.1.10" ++authors = ["Alex Crichton "] ++build = "build.rs" ++links = "miniz" ++description = "Bindings to the miniz.c library.\n" ++documentation = "https://docs.rs/miniz-sys" ++categories = ["external-ffi-bindings"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/flate2-rs" ++ ++[lib] ++name = "miniz_sys" ++path = "lib.rs" ++[dependencies.libc] ++version = "0.2" ++[build-dependencies.cc] ++version = "1.0" diff --cc vendor/miniz-sys-0.1.10/build.rs index 000000000,000000000..f8bcfaa13 new file mode 100644 --- /dev/null +++ b/vendor/miniz-sys-0.1.10/build.rs @@@ -1,0 -1,0 +1,8 @@@ ++extern crate cc; ++ ++use std::env; ++ ++fn main() { ++ cc::Build::new().file("miniz.c").compile("miniz"); ++ println!("cargo:root={}", env::var("OUT_DIR").unwrap()); ++} diff --cc vendor/miniz-sys-0.1.10/lib.rs index 000000000,000000000..a4ca1d134 new file mode 100644 --- /dev/null +++ b/vendor/miniz-sys-0.1.10/lib.rs @@@ -1,0 -1,0 +1,77 @@@ ++#![doc(html_root_url = "https://docs.rs/miniz-sys/0.1")] ++#![allow(bad_style)] ++ ++extern crate libc; ++use libc::*; ++ ++pub const MZ_NO_FLUSH: c_int = 0; ++pub const MZ_PARTIAL_FLUSH: c_int = 1; ++pub const MZ_SYNC_FLUSH: c_int = 2; ++pub const MZ_FULL_FLUSH: c_int = 3; ++pub const MZ_FINISH: c_int = 4; ++pub const MZ_BLOCK: c_int = 5; ++ ++pub const MZ_OK: c_int = 0; ++pub const MZ_STREAM_END: c_int = 1; ++pub const MZ_NEED_DICT: c_int = 2; ++pub const MZ_ERRNO: c_int = -1; ++pub const MZ_STREAM_ERROR: c_int = -2; ++pub const MZ_DATA_ERROR: c_int = -3; ++pub const MZ_MEM_ERROR: c_int = -4; ++pub const MZ_BUF_ERROR: c_int = -5; ++pub const MZ_VERSION_ERROR: c_int = -6; ++pub const MZ_PARAM_ERROR: c_int = -10000; ++ ++pub const MZ_DEFLATED: c_int = 8; ++pub const MZ_DEFAULT_WINDOW_BITS: c_int = 15; ++pub const MZ_DEFAULT_STRATEGY: c_int = 0; ++ ++#[repr(C)] ++pub struct mz_stream { ++ pub next_in: *const u8, ++ pub avail_in: c_uint, ++ pub total_in: c_ulong, ++ ++ pub next_out: *mut u8, ++ pub avail_out: c_uint, ++ pub total_out: c_ulong, ++ ++ pub msg: *const c_char, ++ pub state: *mut mz_internal_state, ++ ++ pub zalloc: Option, ++ pub zfree: Option, ++ pub opaque: *mut c_void, ++ ++ pub data_type: c_int, ++ pub adler: c_ulong, ++ pub reserved: c_ulong, ++} ++ ++pub enum mz_internal_state {} ++ ++pub type mz_alloc_func = extern fn(*mut c_void, ++ size_t, ++ size_t) -> *mut c_void; ++pub type mz_free_func = extern fn(*mut c_void, *mut c_void); ++ ++extern { ++ pub fn mz_deflateInit2(stream: *mut mz_stream, ++ level: c_int, ++ method: c_int, ++ window_bits: c_int, ++ mem_level: c_int, ++ strategy: c_int) ++ -> c_int; ++ pub fn mz_deflate(stream: *mut mz_stream, flush: c_int) -> c_int; ++ pub fn mz_deflateEnd(stream: *mut mz_stream) -> c_int; ++ pub fn mz_deflateReset(stream: *mut mz_stream) -> c_int; ++ ++ pub fn mz_inflateInit2(stream: *mut mz_stream, ++ window_bits: c_int) ++ -> c_int; ++ pub fn mz_inflate(stream: *mut mz_stream, flush: c_int) -> c_int; ++ pub fn mz_inflateEnd(stream: *mut mz_stream) -> c_int; ++ ++ pub fn mz_crc32(crc: c_ulong, ptr: *const u8, len: size_t) -> c_ulong; ++} diff --cc vendor/miniz-sys-0.1.10/miniz.c index 000000000,000000000..8042593d6 new file mode 100644 --- /dev/null +++ b/vendor/miniz-sys-0.1.10/miniz.c @@@ -1,0 -1,0 +1,4986 @@@ ++/* miniz.c v1.16 beta r1 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing ++ See "unlicense" statement at the end of this file. ++ Rich Geldreich , last updated Oct. 13, 2013 ++ Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt ++ ++ Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define ++ MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros). ++ ++ * Change History ++ 10/19/13 v1.16 beta r1 - Two key inflator-only robustness and streaming related changes. Also merged in tdefl_compressor_alloc(), tdefl_compressor_free() helpers to make script bindings easier for rustyzip. ++ - The inflator coroutine func. is subtle and complex so I'm being cautious about this release. I would greatly appreciate any help with testing or any feedback. ++ I feel good about these changes, and they've been through several hours of automated testing, but they will probably not fix anything for the majority of prev. users so I'm ++ going to mark this release as beta for a few weeks and continue testing it at work/home on various things. ++ - The inflator in raw (non-zlib) mode is now usable on gzip or similiar data streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520). ++ This version should *never* read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer. This issue was caused by the various Huffman bitbuffer lookahead optimizations, and ++ would not be an issue if the caller knew and enforced the precise size of the raw compressed data *or* if the compressed data was in zlib format (i.e. always followed by the byte aligned zlib adler32). ++ So in other words, you can now call the inflator on deflate streams that are followed by arbitrary amounts of data and it's guaranteed that decompression will stop exactly on the last byte. ++ - The inflator now has a new failure status: TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS (-4). Previously, if the inflator was starved of bytes and could not make progress (because the input buffer was empty and the ++ caller did not set the TINFL_FLAG_HAS_MORE_INPUT flag - say on truncated or corrupted compressed data stream) it would append all 0's to the input and try to soldier on. ++ This is scary, because in the worst case, I believe it was possible for the prev. inflator to start outputting large amounts of literal data. If the caller didn't know when to stop accepting output ++ (because it didn't know how much uncompressed data was expected, or didn't enforce a sane maximum) it could continue forever. v1.16 cannot fall into this failure mode, instead it'll return ++ TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS immediately if it needs 1 or more bytes to make progress, the input buf is empty, and the caller has indicated that no more input is available. This is a "soft" ++ failure, so you can call the inflator again with more input and it will try to continue, or you can give up and fail. This could be very useful in network streaming scenarios. ++ - Added documentation to all the tinfl return status codes, fixed miniz_tester so it accepts double minus params for Linux, tweaked example1.c, added a simple "follower bytes" test to miniz_tester.cpp. ++ 10/13/13 v1.15 r4 - Interim bugfix release while I work on the next major release with Zip64 support (almost there!): ++ - Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug ++ would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place() ++ (which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag). ++ - Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size ++ - Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries. ++ Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice). ++ - Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes ++ - mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed ++ - Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6. ++ - Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti ++ - Merged MZ_FORCEINLINE fix from hdeanclark ++ - Fix include before config #ifdef, thanks emil.brink ++ - Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can ++ set it to 1 for real-time compression). ++ - Merged in some compiler fixes from paulharris's github repro. ++ - Retested this build under Windows (VS 2010, including static analysis), tcc 0.9.26, gcc v4.6 and clang v3.3. ++ - Added example6.c, which dumps an image of the mandelbrot set to a PNG file. ++ - Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more. ++ - In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix possible src file fclose() leak if alignment bytes+local header file write faiiled ++ - In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): Was pushing the wrong central dir header offset, appears harmless in this release, but it became a problem in the zip64 branch ++ 5/20/12 v1.14 - MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include (thanks fermtect). ++ 5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit. ++ - Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. ++ - Eliminated a bunch of warnings when compiling with GCC 32-bit/64. ++ - Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly ++ "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning). ++ - Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64. ++ - Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. ++ - Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. ++ - Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.) ++ - Fix ftell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). ++ 4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's. ++ level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson for the feedback/bug report. ++ 5/28/11 v1.11 - Added statement from unlicense.org ++ 5/27/11 v1.10 - Substantial compressor optimizations: ++ - Level 1 is now ~4x faster than before. The L1 compressor's throughput now varies between 70-110MB/sec. on a ++ - Core i7 (actual throughput varies depending on the type of data, and x64 vs. x86). ++ - Improved baseline L2-L9 compression perf. Also, greatly improved compression perf. issues on some file types. ++ - Refactored the compression code for better readability and maintainability. ++ - Added level 10 compression level (L10 has slightly better ratio than level 9, but could have a potentially large ++ drop in throughput on some files). ++ 5/15/11 v1.09 - Initial stable release. ++ ++ * Low-level Deflate/Inflate implementation notes: ++ ++ Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or ++ greedy parsing, match length filtering, RLE-only, and Huffman-only streams. It performs and compresses ++ approximately as well as zlib. ++ ++ Decompression: Use the "tinfl" API's. The entire decompressor is implemented as a single function ++ coroutine: see tinfl_decompress(). It supports decompression into a 32KB (or larger power of 2) wrapping buffer, or into a memory ++ block large enough to hold the entire file. ++ ++ The low-level tdefl/tinfl API's do not make any use of dynamic memory allocation. ++ ++ * zlib-style API notes: ++ ++ miniz.c implements a fairly large subset of zlib. There's enough functionality present for it to be a drop-in ++ zlib replacement in many apps: ++ The z_stream struct, optional memory allocation callbacks ++ deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound ++ inflateInit/inflateInit2/inflate/inflateEnd ++ compress, compress2, compressBound, uncompress ++ CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines. ++ Supports raw deflate streams or standard zlib streams with adler-32 checking. ++ ++ Limitations: ++ The callback API's are not implemented yet. No support for gzip headers or zlib static dictionaries. ++ I've tried to closely emulate zlib's various flavors of stream flushing and return status codes, but ++ there are no guarantees that miniz.c pulls this off perfectly. ++ ++ * PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, originally written by ++ Alex Evans. Supports 1-4 bytes/pixel images. ++ ++ * ZIP archive API notes: ++ ++ The ZIP archive API's where designed with simplicity and efficiency in mind, with just enough abstraction to ++ get the job done with minimal fuss. There are simple API's to retrieve file information, read files from ++ existing archives, create new archives, append new files to existing archives, or clone archive data from ++ one archive to another. It supports archives located in memory or the heap, on disk (using stdio.h), ++ or you can specify custom file read/write callbacks. ++ ++ - Archive reading: Just call this function to read a single file from a disk archive: ++ ++ void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, ++ size_t *pSize, mz_uint zip_flags); ++ ++ For more complex cases, use the "mz_zip_reader" functions. Upon opening an archive, the entire central ++ directory is located and read as-is into memory, and subsequent file access only occurs when reading individual files. ++ ++ - Archives file scanning: The simple way is to use this function to scan a loaded archive for a specific file: ++ ++ int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); ++ ++ The locate operation can optionally check file comments too, which (as one example) can be used to identify ++ multiple versions of the same file in an archive. This function uses a simple linear search through the central ++ directory, so it's not very fast. ++ ++ Alternately, you can iterate through all the files in an archive (using mz_zip_reader_get_num_files()) and ++ retrieve detailed info on each file by calling mz_zip_reader_file_stat(). ++ ++ - Archive creation: Use the "mz_zip_writer" functions. The ZIP writer immediately writes compressed file data ++ to disk and builds an exact image of the central directory in memory. The central directory image is written ++ all at once at the end of the archive file when the archive is finalized. ++ ++ The archive writer can optionally align each file's local header and file data to any power of 2 alignment, ++ which can be useful when the archive will be read from optical media. Also, the writer supports placing ++ arbitrary data blobs at the very beginning of ZIP archives. Archives written using either feature are still ++ readable by any ZIP tool. ++ ++ - Archive appending: The simple way to add a single file to an archive is to call this function: ++ ++ mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, ++ const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); ++ ++ The archive will be created if it doesn't already exist, otherwise it'll be appended to. ++ Note the appending is done in-place and is not an atomic operation, so if something goes wrong ++ during the operation it's possible the archive could be left without a central directory (although the local ++ file headers and file data will be fine, so the archive will be recoverable). ++ ++ For more complex archive modification scenarios: ++ 1. The safest way is to use a mz_zip_reader to read the existing archive, cloning only those bits you want to ++ preserve into a new archive using using the mz_zip_writer_add_from_zip_reader() function (which compiles the ++ compressed file data as-is). When you're done, delete the old archive and rename the newly written archive, and ++ you're done. This is safe but requires a bunch of temporary disk space or heap memory. ++ ++ 2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using mz_zip_writer_init_from_reader(), ++ append new files as needed, then finalize the archive which will write an updated central directory to the ++ original archive. (This is basically what mz_zip_add_mem_to_archive_file_in_place() does.) There's a ++ possibility that the archive's central directory could be lost with this method if anything goes wrong, though. ++ ++ - ZIP archive support limitations: ++ No zip64 or spanning support. Extraction functions can only handle unencrypted, stored or deflated files. ++ Requires streams capable of seeking. ++ ++ * This is a header file library, like stb_image.c. To get only a header file, either cut and paste the ++ below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then include miniz.c from it. ++ ++ * Important: For best perf. be sure to customize the below macros for your target platform: ++ #define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 ++ #define MINIZ_LITTLE_ENDIAN 1 ++ #define MINIZ_HAS_64BIT_REGISTERS 1 ++ ++ * On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before including miniz.c to ensure miniz ++ uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be able to process large files ++ (i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes). ++*/ ++ ++#ifndef MINIZ_HEADER_INCLUDED ++#define MINIZ_HEADER_INCLUDED ++ ++#include ++ ++// Defines to completely disable specific portions of miniz.c: ++// If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl. ++ ++// Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. ++//#define MINIZ_NO_STDIO ++ ++// If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able to get the current time, or ++// get/set file times, and the C run-time funcs that get/set times won't be called. ++// The current downside is the times written to your archives will be from 1979. ++//#define MINIZ_NO_TIME ++ ++// Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. ++//#define MINIZ_NO_ARCHIVE_APIS ++ ++// Define MINIZ_NO_ARCHIVE_APIS to disable all writing related ZIP archive API's. ++//#define MINIZ_NO_ARCHIVE_WRITING_APIS ++ ++// Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression API's. ++//#define MINIZ_NO_ZLIB_APIS ++ ++// Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib. ++//#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES ++ ++// Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc. ++// Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc ++// callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user ++// functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. ++//#define MINIZ_NO_MALLOC ++ ++#if defined(__TINYC__) && (defined(__linux) || defined(__linux__)) ++ // TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux ++ #define MINIZ_NO_TIME ++#endif ++ ++#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS) ++ #include ++#endif ++ ++#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__) ++// MINIZ_X86_OR_X64_CPU is only used to help set the below macros. ++#define MINIZ_X86_OR_X64_CPU 1 ++#endif ++ ++#if (__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU ++// Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian. ++#define MINIZ_LITTLE_ENDIAN 1 ++#endif ++ ++#if MINIZ_X86_OR_X64_CPU ++// Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses. ++#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 ++#endif ++ ++#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__) ++// Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions). ++#define MINIZ_HAS_64BIT_REGISTERS 1 ++#endif ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++// ------------------- zlib-style API Definitions. ++ ++// For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits! ++typedef unsigned long mz_ulong; ++ ++// mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap. ++void mz_free(void *p); ++ ++#define MZ_ADLER32_INIT (1) ++// mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL. ++mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len); ++ ++#define MZ_CRC32_INIT (0) ++// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL. ++mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len); ++ ++// Compression strategies. ++enum { MZ_DEFAULT_STRATEGY = 0, MZ_FILTERED = 1, MZ_HUFFMAN_ONLY = 2, MZ_RLE = 3, MZ_FIXED = 4 }; ++ ++// Method ++#define MZ_DEFLATED 8 ++ ++#ifndef MINIZ_NO_ZLIB_APIS ++ ++// Heap allocation callbacks. ++// Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. ++typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size); ++typedef void (*mz_free_func)(void *opaque, void *address); ++typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size); ++ ++// TODO: I can't encode "1.16" here, argh ++#define MZ_VERSION "9.1.15" ++#define MZ_VERNUM 0x91F0 ++#define MZ_VER_MAJOR 9 ++#define MZ_VER_MINOR 1 ++#define MZ_VER_REVISION 15 ++#define MZ_VER_SUBREVISION 0 ++ ++// Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs). ++enum { MZ_NO_FLUSH = 0, MZ_PARTIAL_FLUSH = 1, MZ_SYNC_FLUSH = 2, MZ_FULL_FLUSH = 3, MZ_FINISH = 4, MZ_BLOCK = 5 }; ++ ++// Return status codes. MZ_PARAM_ERROR is non-standard. ++enum { MZ_OK = 0, MZ_STREAM_END = 1, MZ_NEED_DICT = 2, MZ_ERRNO = -1, MZ_STREAM_ERROR = -2, MZ_DATA_ERROR = -3, MZ_MEM_ERROR = -4, MZ_BUF_ERROR = -5, MZ_VERSION_ERROR = -6, MZ_PARAM_ERROR = -10000 }; ++ ++// Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL. ++enum { MZ_NO_COMPRESSION = 0, MZ_BEST_SPEED = 1, MZ_BEST_COMPRESSION = 9, MZ_UBER_COMPRESSION = 10, MZ_DEFAULT_LEVEL = 6, MZ_DEFAULT_COMPRESSION = -1 }; ++ ++// Window bits ++#define MZ_DEFAULT_WINDOW_BITS 15 ++ ++struct mz_internal_state; ++ ++// Compression/decompression stream struct. ++typedef struct mz_stream_s ++{ ++ const unsigned char *next_in; // pointer to next byte to read ++ unsigned int avail_in; // number of bytes available at next_in ++ mz_ulong total_in; // total number of bytes consumed so far ++ ++ unsigned char *next_out; // pointer to next byte to write ++ unsigned int avail_out; // number of bytes that can be written to next_out ++ mz_ulong total_out; // total number of bytes produced so far ++ ++ char *msg; // error msg (unused) ++ struct mz_internal_state *state; // internal state, allocated by zalloc/zfree ++ ++ mz_alloc_func zalloc; // optional heap allocation function (defaults to malloc) ++ mz_free_func zfree; // optional heap free function (defaults to free) ++ void *opaque; // heap alloc function user pointer ++ ++ int data_type; // data_type (unused) ++ mz_ulong adler; // adler32 of the source or uncompressed data ++ mz_ulong reserved; // not used ++} mz_stream; ++ ++typedef mz_stream *mz_streamp; ++ ++// Returns the version string of miniz.c. ++const char *mz_version(void); ++ ++// mz_deflateInit() initializes a compressor with default options: ++// Parameters: ++// pStream must point to an initialized mz_stream struct. ++// level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION]. ++// level 1 enables a specially optimized compression function that's been optimized purely for performance, not ratio. ++// (This special func. is currently only enabled when MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.) ++// Return values: ++// MZ_OK on success. ++// MZ_STREAM_ERROR if the stream is bogus. ++// MZ_PARAM_ERROR if the input parameters are bogus. ++// MZ_MEM_ERROR on out of memory. ++int mz_deflateInit(mz_streamp pStream, int level); ++ ++// mz_deflateInit2() is like mz_deflate(), except with more control: ++// Additional parameters: ++// method must be MZ_DEFLATED ++// window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer) ++// mem_level must be between [1, 9] (it's checked but ignored by miniz.c) ++int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy); ++ ++// Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2(). ++int mz_deflateReset(mz_streamp pStream); ++ ++// mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible. ++// Parameters: ++// pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. ++// flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or MZ_FINISH. ++// Return values: ++// MZ_OK on success (when flushing, or if more input is needed but not available, and/or there's more output to be written but the output buffer is full). ++// MZ_STREAM_END if all input has been consumed and all output bytes have been written. Don't call mz_deflate() on the stream anymore. ++// MZ_STREAM_ERROR if the stream is bogus. ++// MZ_PARAM_ERROR if one of the parameters is invalid. ++// MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.) ++int mz_deflate(mz_streamp pStream, int flush); ++ ++// mz_deflateEnd() deinitializes a compressor: ++// Return values: ++// MZ_OK on success. ++// MZ_STREAM_ERROR if the stream is bogus. ++int mz_deflateEnd(mz_streamp pStream); ++ ++// mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH. ++mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len); ++ ++// Single-call compression functions mz_compress() and mz_compress2(): ++// Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure. ++int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); ++int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level); ++ ++// mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). ++mz_ulong mz_compressBound(mz_ulong source_len); ++ ++// Initializes a decompressor. ++int mz_inflateInit(mz_streamp pStream); ++ ++// mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer: ++// window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate). ++int mz_inflateInit2(mz_streamp pStream, int window_bits); ++ ++// Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible. ++// Parameters: ++// pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members. ++// flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH. ++// On the first call, if flush is MZ_FINISH it's assumed the input and output buffers are both sized large enough to decompress the entire stream in a single call (this is slightly faster). ++// MZ_FINISH implies that there are no more source bytes available beside what's already in the input buffer, and that the output buffer is large enough to hold the rest of the decompressed data. ++// Return values: ++// MZ_OK on success. Either more input is needed but not available, and/or there's more output to be written but the output buffer is full. ++// MZ_STREAM_END if all needed input has been consumed and all output bytes have been written. For zlib streams, the adler-32 of the decompressed data has also been verified. ++// MZ_STREAM_ERROR if the stream is bogus. ++// MZ_DATA_ERROR if the deflate stream is invalid. ++// MZ_PARAM_ERROR if one of the parameters is invalid. ++// MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again ++// with more input data, or with more room in the output buffer (except when using single call decompression, described above). ++int mz_inflate(mz_streamp pStream, int flush); ++ ++// Deinitializes a decompressor. ++int mz_inflateEnd(mz_streamp pStream); ++ ++// Single-call decompression. ++// Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. ++int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); ++ ++// Returns a string description of the specified error code, or NULL if the error code is invalid. ++const char *mz_error(int err); ++ ++// Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports. ++// Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project. ++#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES ++ typedef unsigned char Byte; ++ typedef unsigned int uInt; ++ typedef mz_ulong uLong; ++ typedef Byte Bytef; ++ typedef uInt uIntf; ++ typedef char charf; ++ typedef int intf; ++ typedef void *voidpf; ++ typedef uLong uLongf; ++ typedef void *voidp; ++ typedef void *const voidpc; ++ #define Z_NULL 0 ++ #define Z_NO_FLUSH MZ_NO_FLUSH ++ #define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH ++ #define Z_SYNC_FLUSH MZ_SYNC_FLUSH ++ #define Z_FULL_FLUSH MZ_FULL_FLUSH ++ #define Z_FINISH MZ_FINISH ++ #define Z_BLOCK MZ_BLOCK ++ #define Z_OK MZ_OK ++ #define Z_STREAM_END MZ_STREAM_END ++ #define Z_NEED_DICT MZ_NEED_DICT ++ #define Z_ERRNO MZ_ERRNO ++ #define Z_STREAM_ERROR MZ_STREAM_ERROR ++ #define Z_DATA_ERROR MZ_DATA_ERROR ++ #define Z_MEM_ERROR MZ_MEM_ERROR ++ #define Z_BUF_ERROR MZ_BUF_ERROR ++ #define Z_VERSION_ERROR MZ_VERSION_ERROR ++ #define Z_PARAM_ERROR MZ_PARAM_ERROR ++ #define Z_NO_COMPRESSION MZ_NO_COMPRESSION ++ #define Z_BEST_SPEED MZ_BEST_SPEED ++ #define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION ++ #define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION ++ #define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY ++ #define Z_FILTERED MZ_FILTERED ++ #define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY ++ #define Z_RLE MZ_RLE ++ #define Z_FIXED MZ_FIXED ++ #define Z_DEFLATED MZ_DEFLATED ++ #define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS ++ #define alloc_func mz_alloc_func ++ #define free_func mz_free_func ++ #define internal_state mz_internal_state ++ #define z_stream mz_stream ++ #define deflateInit mz_deflateInit ++ #define deflateInit2 mz_deflateInit2 ++ #define deflateReset mz_deflateReset ++ #define deflate mz_deflate ++ #define deflateEnd mz_deflateEnd ++ #define deflateBound mz_deflateBound ++ #define compress mz_compress ++ #define compress2 mz_compress2 ++ #define compressBound mz_compressBound ++ #define inflateInit mz_inflateInit ++ #define inflateInit2 mz_inflateInit2 ++ #define inflate mz_inflate ++ #define inflateEnd mz_inflateEnd ++ #define uncompress mz_uncompress ++ #define crc32 mz_crc32 ++ #define adler32 mz_adler32 ++ #define MAX_WBITS 15 ++ #define MAX_MEM_LEVEL 9 ++ #define zError mz_error ++ #define ZLIB_VERSION MZ_VERSION ++ #define ZLIB_VERNUM MZ_VERNUM ++ #define ZLIB_VER_MAJOR MZ_VER_MAJOR ++ #define ZLIB_VER_MINOR MZ_VER_MINOR ++ #define ZLIB_VER_REVISION MZ_VER_REVISION ++ #define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION ++ #define zlibVersion mz_version ++ #define zlib_version mz_version() ++#endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES ++ ++#endif // MINIZ_NO_ZLIB_APIS ++ ++// ------------------- Types and macros ++ ++typedef unsigned char mz_uint8; ++typedef signed short mz_int16; ++typedef unsigned short mz_uint16; ++typedef unsigned int mz_uint32; ++typedef unsigned int mz_uint; ++typedef long long mz_int64; ++typedef unsigned long long mz_uint64; ++typedef int mz_bool; ++ ++#define MZ_FALSE (0) ++#define MZ_TRUE (1) ++ ++// An attempt to work around MSVC's spammy "warning C4127: conditional expression is constant" message. ++#ifdef _MSC_VER ++ #define MZ_MACRO_END while (0, 0) ++#else ++ #define MZ_MACRO_END while (0) ++#endif ++ ++// ------------------- ZIP archive reading/writing ++ ++#ifndef MINIZ_NO_ARCHIVE_APIS ++ ++enum ++{ ++ MZ_ZIP_MAX_IO_BUF_SIZE = 64*1024, ++ MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 260, ++ MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 256 ++}; ++ ++typedef struct ++{ ++ mz_uint32 m_file_index; ++ mz_uint32 m_central_dir_ofs; ++ mz_uint16 m_version_made_by; ++ mz_uint16 m_version_needed; ++ mz_uint16 m_bit_flag; ++ mz_uint16 m_method; ++#ifndef MINIZ_NO_TIME ++ time_t m_time; ++#endif ++ mz_uint32 m_crc32; ++ mz_uint64 m_comp_size; ++ mz_uint64 m_uncomp_size; ++ mz_uint16 m_internal_attr; ++ mz_uint32 m_external_attr; ++ mz_uint64 m_local_header_ofs; ++ mz_uint32 m_comment_size; ++ char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE]; ++ char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE]; ++} mz_zip_archive_file_stat; ++ ++typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n); ++typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n); ++ ++struct mz_zip_internal_state_tag; ++typedef struct mz_zip_internal_state_tag mz_zip_internal_state; ++ ++typedef enum ++{ ++ MZ_ZIP_MODE_INVALID = 0, ++ MZ_ZIP_MODE_READING = 1, ++ MZ_ZIP_MODE_WRITING = 2, ++ MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3 ++} mz_zip_mode; ++ ++typedef struct mz_zip_archive_tag ++{ ++ mz_uint64 m_archive_size; ++ mz_uint64 m_central_directory_file_ofs; ++ mz_uint m_total_files; ++ mz_zip_mode m_zip_mode; ++ ++ mz_uint m_file_offset_alignment; ++ ++ mz_alloc_func m_pAlloc; ++ mz_free_func m_pFree; ++ mz_realloc_func m_pRealloc; ++ void *m_pAlloc_opaque; ++ ++ mz_file_read_func m_pRead; ++ mz_file_write_func m_pWrite; ++ void *m_pIO_opaque; ++ ++ mz_zip_internal_state *m_pState; ++ ++} mz_zip_archive; ++ ++typedef enum ++{ ++ MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100, ++ MZ_ZIP_FLAG_IGNORE_PATH = 0x0200, ++ MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400, ++ MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800 ++} mz_zip_flags; ++ ++// ZIP archive reading ++ ++// Inits a ZIP archive reader. ++// These functions read and validate the archive's central directory. ++mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags); ++mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags); ++ ++#ifndef MINIZ_NO_STDIO ++mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags); ++#endif ++ ++// Returns the total number of files in the archive. ++mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip); ++ ++// Returns detailed information about an archive file entry. ++mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat); ++ ++// Determines if an archive file entry is a directory entry. ++mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index); ++mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index); ++ ++// Retrieves the filename of an archive file entry. ++// Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename. ++mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size); ++ ++// Attempts to locates a file in the archive's central directory. ++// Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH ++// Returns -1 if the file cannot be found. ++int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags); ++ ++// Extracts a archive file to a memory buffer using no memory allocation. ++mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); ++mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size); ++ ++// Extracts a archive file to a memory buffer. ++mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags); ++mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags); ++ ++// Extracts a archive file to a dynamically allocated heap buffer. ++void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags); ++void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags); ++ ++// Extracts a archive file using a callback function to output the file's data. ++mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); ++mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags); ++ ++#ifndef MINIZ_NO_STDIO ++// Extracts a archive file to a disk file and sets its last accessed and modified times. ++// This function only extracts files, not archive directory records. ++mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags); ++mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags); ++#endif ++ ++// Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used. ++mz_bool mz_zip_reader_end(mz_zip_archive *pZip); ++ ++// ZIP archive writing ++ ++#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS ++ ++// Inits a ZIP archive writer. ++mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size); ++mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size); ++ ++#ifndef MINIZ_NO_STDIO ++mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning); ++#endif ++ ++// Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive. ++// For archives opened using mz_zip_reader_init_file, pFilename must be the archive's filename so it can be reopened for writing. If the file can't be reopened, mz_zip_reader_end() will be called. ++// For archives opened using mz_zip_reader_init_mem, the memory block must be growable using the realloc callback (which defaults to realloc unless you've overridden it). ++// Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. ++// Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before ++// the archive is finalized the file's central directory will be hosed. ++mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename); ++ ++// Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. ++// To add a directory entry, call this method with an archive name ending in a forwardslash with empty buffer. ++// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. ++mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags); ++mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32); ++ ++#ifndef MINIZ_NO_STDIO ++// Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. ++// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. ++mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); ++#endif ++ ++// Adds a file to an archive by fully cloning the data from another archive. ++// This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data, and comment fields. ++mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index); ++ ++// Finalizes the archive by writing the central directory records followed by the end of central directory record. ++// After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). ++// An archive must be manually finalized by calling this function for it to be valid. ++mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip); ++mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize); ++ ++// Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used. ++// Note for the archive to be valid, it must have been finalized before ending. ++mz_bool mz_zip_writer_end(mz_zip_archive *pZip); ++ ++// Misc. high-level helper functions: ++ ++// mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) appends a memory blob to a ZIP archive. ++// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. ++mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags); ++ ++// Reads a single file from an archive into a heap block. ++// Returns NULL on failure. ++void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint zip_flags); ++ ++#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS ++ ++#endif // #ifndef MINIZ_NO_ARCHIVE_APIS ++ ++// ------------------- Low-level Decompression API Definitions ++ ++// Decompression flags used by tinfl_decompress(). ++// TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream. ++// TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input. ++// TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB). ++// TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. ++enum ++{ ++ TINFL_FLAG_PARSE_ZLIB_HEADER = 1, ++ TINFL_FLAG_HAS_MORE_INPUT = 2, ++ TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4, ++ TINFL_FLAG_COMPUTE_ADLER32 = 8 ++}; ++ ++// High level decompression functions: ++// tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc(). ++// On entry: ++// pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress. ++// On return: ++// Function returns a pointer to the decompressed data, or NULL on failure. ++// *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. ++// The caller must call mz_free() on the returned block when it's no longer needed. ++void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); ++ ++// tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. ++// Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. ++#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1)) ++size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); ++ ++// tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer. ++// Returns 1 on success or 0 on failure. ++typedef int (*tinfl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); ++int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); ++ ++struct tinfl_decompressor_tag; typedef struct tinfl_decompressor_tag tinfl_decompressor; ++ ++// Max size of LZ dictionary. ++#define TINFL_LZ_DICT_SIZE 32768 ++ ++// Return status. ++typedef enum ++{ ++ // This flags indicates the inflator needs 1 or more input bytes to make forward progress, but the caller is indicating that no more are available. The compressed data ++ // is probably corrupted. If you call the inflator again with more bytes it'll try to continue processing the input but this is a BAD sign (either the data is corrupted or you called it incorrectly). ++ // If you call it again with no input you'll just get TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS again. ++ TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS = -4, ++ ++ // This flag indicates that one or more of the input parameters was obviously bogus. (You can try calling it again, but if you get this error the calling code is wrong.) ++ TINFL_STATUS_BAD_PARAM = -3, ++ ++ // This flags indicate the inflator is finished but the adler32 check of the uncompressed data didn't match. If you call it again it'll return TINFL_STATUS_DONE. ++ TINFL_STATUS_ADLER32_MISMATCH = -2, ++ ++ // This flags indicate the inflator has somehow failed (bad code, corrupted input, etc.). If you call it again without resetting via tinfl_init() it it'll just keep on returning the same status failure code. ++ TINFL_STATUS_FAILED = -1, ++ ++ // Any status code less than TINFL_STATUS_DONE must indicate a failure. ++ ++ // This flag indicates the inflator has returned every byte of uncompressed data that it can, has consumed every byte that it needed, has successfully reached the end of the deflate stream, and ++ // if zlib headers and adler32 checking enabled that it has successfully checked the uncompressed data's adler32. If you call it again you'll just get TINFL_STATUS_DONE over and over again. ++ TINFL_STATUS_DONE = 0, ++ ++ // This flag indicates the inflator MUST have more input data (even 1 byte) before it can make any more forward progress, or you need to clear the TINFL_FLAG_HAS_MORE_INPUT ++ // flag on the next call if you don't have any more source data. If the source data was somehow corrupted it's also possible (but unlikely) for the inflator to keep on demanding input to ++ // proceed, so be sure to properly set the TINFL_FLAG_HAS_MORE_INPUT flag. ++ TINFL_STATUS_NEEDS_MORE_INPUT = 1, ++ ++ // This flag indicates the inflator definitely has 1 or more bytes of uncompressed data available, but it cannot write this data into the output buffer. ++ // Note if the source compressed data was corrupted it's possible for the inflator to return a lot of uncompressed data to the caller. I've been assuming you know how much uncompressed data to expect ++ // (either exact or worst case) and will stop calling the inflator and fail after receiving too much. In pure streaming scenarios where you have no idea how many bytes to expect this may not be possible ++ // so I may need to add some code to address this. ++ TINFL_STATUS_HAS_MORE_OUTPUT = 2 ++ ++} tinfl_status; ++ ++// Initializes the decompressor to its initial state. ++#define tinfl_init(r) do { (r)->m_state = 0; } MZ_MACRO_END ++#define tinfl_get_adler32(r) (r)->m_check_adler32 ++ ++// Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability. ++// This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output. ++tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags); ++ ++// Internal/private bits follow. ++enum ++{ ++ TINFL_MAX_HUFF_TABLES = 3, TINFL_MAX_HUFF_SYMBOLS_0 = 288, TINFL_MAX_HUFF_SYMBOLS_1 = 32, TINFL_MAX_HUFF_SYMBOLS_2 = 19, ++ TINFL_FAST_LOOKUP_BITS = 10, TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS ++}; ++ ++typedef struct ++{ ++ mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0]; ++ mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2]; ++} tinfl_huff_table; ++ ++#if MINIZ_HAS_64BIT_REGISTERS ++ #define TINFL_USE_64BIT_BITBUF 1 ++#endif ++ ++#if TINFL_USE_64BIT_BITBUF ++ typedef mz_uint64 tinfl_bit_buf_t; ++ #define TINFL_BITBUF_SIZE (64) ++#else ++ typedef mz_uint32 tinfl_bit_buf_t; ++ #define TINFL_BITBUF_SIZE (32) ++#endif ++ ++struct tinfl_decompressor_tag ++{ ++ mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES]; ++ tinfl_bit_buf_t m_bit_buf; ++ size_t m_dist_from_out_buf_start; ++ tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES]; ++ mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137]; ++}; ++ ++// ------------------- Low-level Compression API Definitions ++ ++// Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly slower, and raw/dynamic blocks will be output more frequently). ++#define TDEFL_LESS_MEMORY 0 ++ ++// tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search): ++// TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression). ++enum ++{ ++ TDEFL_HUFFMAN_ONLY = 0, TDEFL_DEFAULT_MAX_PROBES = 128, TDEFL_MAX_PROBES_MASK = 0xFFF ++}; ++ ++// TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data. ++// TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even when not writing zlib headers). ++// TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more efficient lazy parsing. ++// TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's initialization time to the minimum, but the output may vary from run to run given the same input (depending on the contents of memory). ++// TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1) ++// TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled. ++// TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables. ++// TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks. ++// The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK). ++enum ++{ ++ TDEFL_WRITE_ZLIB_HEADER = 0x01000, ++ TDEFL_COMPUTE_ADLER32 = 0x02000, ++ TDEFL_GREEDY_PARSING_FLAG = 0x04000, ++ TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000, ++ TDEFL_RLE_MATCHES = 0x10000, ++ TDEFL_FILTER_MATCHES = 0x20000, ++ TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000, ++ TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000 ++}; ++ ++// High level compression functions: ++// tdefl_compress_mem_to_heap() compresses a block in memory to a heap block allocated via malloc(). ++// On entry: ++// pSrc_buf, src_buf_len: Pointer and size of source block to compress. ++// flags: The max match finder probes (default is 128) logically OR'd against the above flags. Higher probes are slower but improve compression. ++// On return: ++// Function returns a pointer to the compressed data, or NULL on failure. ++// *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data. ++// The caller must free() the returned block when it's no longer needed. ++void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); ++ ++// tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory. ++// Returns 0 on failure. ++size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); ++ ++// Compresses an image to a compressed PNG file in memory. ++// On entry: ++// pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4. ++// The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory. ++// level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL ++// If flip is true, the image will be flipped on the Y axis (useful for OpenGL apps). ++// On return: ++// Function returns a pointer to the compressed data, or NULL on failure. ++// *pLen_out will be set to the size of the PNG image file. ++// The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed. ++void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip); ++void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out); ++ ++// Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. ++typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); ++ ++// tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. ++mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); ++ ++enum { TDEFL_MAX_HUFF_TABLES = 3, TDEFL_MAX_HUFF_SYMBOLS_0 = 288, TDEFL_MAX_HUFF_SYMBOLS_1 = 32, TDEFL_MAX_HUFF_SYMBOLS_2 = 19, TDEFL_LZ_DICT_SIZE = 32768, TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1, TDEFL_MIN_MATCH_LEN = 3, TDEFL_MAX_MATCH_LEN = 258 }; ++ ++// TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes). ++#if TDEFL_LESS_MEMORY ++enum { TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 12, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; ++#else ++enum { TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 15, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; ++#endif ++ ++// The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. ++typedef enum ++{ ++ TDEFL_STATUS_BAD_PARAM = -2, ++ TDEFL_STATUS_PUT_BUF_FAILED = -1, ++ TDEFL_STATUS_OKAY = 0, ++ TDEFL_STATUS_DONE = 1, ++} tdefl_status; ++ ++// Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums ++typedef enum ++{ ++ TDEFL_NO_FLUSH = 0, ++ TDEFL_SYNC_FLUSH = 2, ++ TDEFL_FULL_FLUSH = 3, ++ TDEFL_FINISH = 4 ++} tdefl_flush; ++ ++// tdefl's compression state structure. ++typedef struct ++{ ++ tdefl_put_buf_func_ptr m_pPut_buf_func; ++ void *m_pPut_buf_user; ++ mz_uint m_flags, m_max_probes[2]; ++ int m_greedy_parsing; ++ mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size; ++ mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end; ++ mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer; ++ mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish; ++ tdefl_status m_prev_return_status; ++ const void *m_pIn_buf; ++ void *m_pOut_buf; ++ size_t *m_pIn_buf_size, *m_pOut_buf_size; ++ tdefl_flush m_flush; ++ const mz_uint8 *m_pSrc; ++ size_t m_src_buf_left, m_out_buf_ofs; ++ mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1]; ++ mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; ++ mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; ++ mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; ++ mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]; ++ mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]; ++ mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]; ++ mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]; ++} tdefl_compressor; ++ ++// Initializes the compressor. ++// There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory. ++// pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression. ++// If pBut_buf_func is NULL the user should always call the tdefl_compress() API. ++// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.) ++tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); ++ ++// Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible. ++tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush); ++ ++// tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr. ++// tdefl_compress_buffer() always consumes the entire input buffer. ++tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush); ++ ++tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d); ++mz_uint32 tdefl_get_adler32(tdefl_compressor *d); ++ ++// Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't defined, because it uses some of its macros. ++#ifndef MINIZ_NO_ZLIB_APIS ++// Create tdefl_compress() flags given zlib-style compression parameters. ++// level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) ++// window_bits may be -15 (raw deflate) or 15 (zlib) ++// strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED ++mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy); ++#endif // #ifndef MINIZ_NO_ZLIB_APIS ++ ++// Allocate the tdefl_compressor and tinfl_decompressor structures in C so that ++// non-C language bindings to tdefl_ and tinfl_ API don't need to worry about ++// structure size and allocation mechanism. ++tdefl_compressor *tdefl_compressor_alloc(); ++void tdefl_compressor_free(tdefl_compressor *pComp); ++tinfl_decompressor *tinfl_decompressor_alloc(); ++void tinfl_decompressor_free(tinfl_decompressor *pDecomp); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif // MINIZ_HEADER_INCLUDED ++ ++// ------------------- End of Header: Implementation follows. (If you only want the header, define MINIZ_HEADER_FILE_ONLY.) ++ ++#ifndef MINIZ_HEADER_FILE_ONLY ++ ++typedef unsigned char mz_validate_uint16[sizeof(mz_uint16)==2 ? 1 : -1]; ++typedef unsigned char mz_validate_uint32[sizeof(mz_uint32)==4 ? 1 : -1]; ++typedef unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 : -1]; ++ ++#include ++#include ++ ++#define MZ_ASSERT(x) assert(x) ++ ++#ifdef MINIZ_NO_MALLOC ++ #define MZ_MALLOC(x) NULL ++ #define MZ_FREE(x) (void)x, ((void)0) ++ #define MZ_REALLOC(p, x) NULL ++#else ++ #define MZ_MALLOC(x) malloc(x) ++ #define MZ_FREE(x) free(x) ++ #define MZ_REALLOC(p, x) realloc(p, x) ++#endif ++ ++#define MZ_MAX(a,b) (((a)>(b))?(a):(b)) ++#define MZ_MIN(a,b) (((a)<(b))?(a):(b)) ++#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) ++ ++#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN ++ #define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) ++ #define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) ++#else ++ #define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U)) ++ #define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U)) ++#endif ++ ++#ifdef _MSC_VER ++ #define MZ_FORCEINLINE __forceinline ++#elif defined(__GNUC__) ++ #define MZ_FORCEINLINE inline __attribute__((__always_inline__)) ++#else ++ #define MZ_FORCEINLINE inline ++#endif ++ ++#ifdef __cplusplus ++ extern "C" { ++#endif ++ ++// ------------------- zlib-style API's ++ ++mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) ++{ ++ mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16); size_t block_len = buf_len % 5552; ++ if (!ptr) return MZ_ADLER32_INIT; ++ while (buf_len) { ++ for (i = 0; i + 7 < block_len; i += 8, ptr += 8) { ++ s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1; ++ s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1; ++ } ++ for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1; ++ s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552; ++ } ++ return (s2 << 16) + s1; ++} ++ ++// Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C implementation that balances processor cache usage against speed": http://www.geocities.com/malbrain/ ++mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) ++{ ++ static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c, ++ 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c }; ++ mz_uint32 crcu32 = (mz_uint32)crc; ++ if (!ptr) return MZ_CRC32_INIT; ++ crcu32 = ~crcu32; while (buf_len--) { mz_uint8 b = *ptr++; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)]; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)]; } ++ return ~crcu32; ++} ++ ++void mz_free(void *p) ++{ ++ MZ_FREE(p); ++} ++ ++#ifndef MINIZ_NO_ZLIB_APIS ++ ++static void *def_alloc_func(void *opaque, size_t items, size_t size) { (void)opaque, (void)items, (void)size; return MZ_MALLOC(items * size); } ++static void def_free_func(void *opaque, void *address) { (void)opaque, (void)address; MZ_FREE(address); } ++static void *def_realloc_func(void *opaque, void *address, size_t items, size_t size) { (void)opaque, (void)address, (void)items, (void)size; return MZ_REALLOC(address, items * size); } ++ ++const char *mz_version(void) ++{ ++ return MZ_VERSION; ++} ++ ++int mz_deflateInit(mz_streamp pStream, int level) ++{ ++ return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY); ++} ++ ++int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy) ++{ ++ tdefl_compressor *pComp; ++ mz_uint comp_flags = TDEFL_COMPUTE_ADLER32 | tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy); ++ ++ if (!pStream) return MZ_STREAM_ERROR; ++ if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) || ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS))) return MZ_PARAM_ERROR; ++ ++ pStream->data_type = 0; ++ pStream->adler = MZ_ADLER32_INIT; ++ pStream->msg = NULL; ++ pStream->reserved = 0; ++ pStream->total_in = 0; ++ pStream->total_out = 0; ++ if (!pStream->zalloc) pStream->zalloc = def_alloc_func; ++ if (!pStream->zfree) pStream->zfree = def_free_func; ++ ++ pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1, sizeof(tdefl_compressor)); ++ if (!pComp) ++ return MZ_MEM_ERROR; ++ ++ pStream->state = (struct mz_internal_state *)pComp; ++ ++ if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY) ++ { ++ mz_deflateEnd(pStream); ++ return MZ_PARAM_ERROR; ++ } ++ ++ return MZ_OK; ++} ++ ++int mz_deflateReset(mz_streamp pStream) ++{ ++ if ((!pStream) || (!pStream->state) || (!pStream->zalloc) || (!pStream->zfree)) return MZ_STREAM_ERROR; ++ pStream->total_in = pStream->total_out = 0; ++ tdefl_init((tdefl_compressor*)pStream->state, NULL, NULL, ((tdefl_compressor*)pStream->state)->m_flags); ++ return MZ_OK; ++} ++ ++int mz_deflate(mz_streamp pStream, int flush) ++{ ++ size_t in_bytes, out_bytes; ++ mz_ulong orig_total_in, orig_total_out; ++ int mz_status = MZ_OK; ++ ++ if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) || (!pStream->next_out)) return MZ_STREAM_ERROR; ++ if (!pStream->avail_out) return MZ_BUF_ERROR; ++ ++ if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; ++ ++ if (((tdefl_compressor*)pStream->state)->m_prev_return_status == TDEFL_STATUS_DONE) ++ return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR; ++ ++ orig_total_in = pStream->total_in; orig_total_out = pStream->total_out; ++ for ( ; ; ) ++ { ++ tdefl_status defl_status; ++ in_bytes = pStream->avail_in; out_bytes = pStream->avail_out; ++ ++ defl_status = tdefl_compress((tdefl_compressor*)pStream->state, pStream->next_in, &in_bytes, pStream->next_out, &out_bytes, (tdefl_flush)flush); ++ pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; ++ pStream->total_in += (mz_uint)in_bytes; pStream->adler = tdefl_get_adler32((tdefl_compressor*)pStream->state); ++ ++ pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; ++ pStream->total_out += (mz_uint)out_bytes; ++ ++ if (defl_status < 0) ++ { ++ mz_status = MZ_STREAM_ERROR; ++ break; ++ } ++ else if (defl_status == TDEFL_STATUS_DONE) ++ { ++ mz_status = MZ_STREAM_END; ++ break; ++ } ++ else if (!pStream->avail_out) ++ break; ++ else if ((!pStream->avail_in) && (flush != MZ_FINISH)) ++ { ++ if ((flush) || (pStream->total_in != orig_total_in) || (pStream->total_out != orig_total_out)) ++ break; ++ return MZ_BUF_ERROR; // Can't make forward progress without some input. ++ } ++ } ++ return mz_status; ++} ++ ++int mz_deflateEnd(mz_streamp pStream) ++{ ++ if (!pStream) return MZ_STREAM_ERROR; ++ if (pStream->state) ++ { ++ pStream->zfree(pStream->opaque, pStream->state); ++ pStream->state = NULL; ++ } ++ return MZ_OK; ++} ++ ++mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len) ++{ ++ (void)pStream; ++ // This is really over conservative. (And lame, but it's actually pretty tricky to compute a true upper bound given the way tdefl's blocking works.) ++ return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5); ++} ++ ++int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level) ++{ ++ int status; ++ mz_stream stream; ++ memset(&stream, 0, sizeof(stream)); ++ ++ // In case mz_ulong is 64-bits (argh I hate longs). ++ if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; ++ ++ stream.next_in = pSource; ++ stream.avail_in = (mz_uint32)source_len; ++ stream.next_out = pDest; ++ stream.avail_out = (mz_uint32)*pDest_len; ++ ++ status = mz_deflateInit(&stream, level); ++ if (status != MZ_OK) return status; ++ ++ status = mz_deflate(&stream, MZ_FINISH); ++ if (status != MZ_STREAM_END) ++ { ++ mz_deflateEnd(&stream); ++ return (status == MZ_OK) ? MZ_BUF_ERROR : status; ++ } ++ ++ *pDest_len = stream.total_out; ++ return mz_deflateEnd(&stream); ++} ++ ++int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) ++{ ++ return mz_compress2(pDest, pDest_len, pSource, source_len, MZ_DEFAULT_COMPRESSION); ++} ++ ++mz_ulong mz_compressBound(mz_ulong source_len) ++{ ++ return mz_deflateBound(NULL, source_len); ++} ++ ++typedef struct ++{ ++ tinfl_decompressor m_decomp; ++ mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed; int m_window_bits; ++ mz_uint8 m_dict[TINFL_LZ_DICT_SIZE]; ++ tinfl_status m_last_status; ++} inflate_state; ++ ++int mz_inflateInit2(mz_streamp pStream, int window_bits) ++{ ++ inflate_state *pDecomp; ++ if (!pStream) return MZ_STREAM_ERROR; ++ if ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS)) return MZ_PARAM_ERROR; ++ ++ pStream->data_type = 0; ++ pStream->adler = 0; ++ pStream->msg = NULL; ++ pStream->total_in = 0; ++ pStream->total_out = 0; ++ pStream->reserved = 0; ++ if (!pStream->zalloc) pStream->zalloc = def_alloc_func; ++ if (!pStream->zfree) pStream->zfree = def_free_func; ++ ++ pDecomp = (inflate_state*)pStream->zalloc(pStream->opaque, 1, sizeof(inflate_state)); ++ if (!pDecomp) return MZ_MEM_ERROR; ++ ++ pStream->state = (struct mz_internal_state *)pDecomp; ++ ++ tinfl_init(&pDecomp->m_decomp); ++ pDecomp->m_dict_ofs = 0; ++ pDecomp->m_dict_avail = 0; ++ pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT; ++ pDecomp->m_first_call = 1; ++ pDecomp->m_has_flushed = 0; ++ pDecomp->m_window_bits = window_bits; ++ ++ return MZ_OK; ++} ++ ++int mz_inflateInit(mz_streamp pStream) ++{ ++ return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS); ++} ++ ++int mz_inflate(mz_streamp pStream, int flush) ++{ ++ inflate_state* pState; ++ mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32; ++ size_t in_bytes, out_bytes, orig_avail_in; ++ tinfl_status status; ++ ++ if ((!pStream) || (!pStream->state)) return MZ_STREAM_ERROR; ++ if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH; ++ if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; ++ ++ pState = (inflate_state*)pStream->state; ++ if (pState->m_window_bits > 0) decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER; ++ orig_avail_in = pStream->avail_in; ++ ++ first_call = pState->m_first_call; pState->m_first_call = 0; ++ if (pState->m_last_status < 0) return MZ_DATA_ERROR; ++ ++ if (pState->m_has_flushed && (flush != MZ_FINISH)) return MZ_STREAM_ERROR; ++ pState->m_has_flushed |= (flush == MZ_FINISH); ++ ++ if ((flush == MZ_FINISH) && (first_call)) ++ { ++ // MZ_FINISH on the first call implies that the input and output buffers are large enough to hold the entire compressed/decompressed file. ++ decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF; ++ in_bytes = pStream->avail_in; out_bytes = pStream->avail_out; ++ status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags); ++ pState->m_last_status = status; ++ pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes; ++ pStream->adler = tinfl_get_adler32(&pState->m_decomp); ++ pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; pStream->total_out += (mz_uint)out_bytes; ++ ++ if (status < 0) ++ return MZ_DATA_ERROR; ++ else if (status != TINFL_STATUS_DONE) ++ { ++ pState->m_last_status = TINFL_STATUS_FAILED; ++ return MZ_BUF_ERROR; ++ } ++ return MZ_STREAM_END; ++ } ++ // flush != MZ_FINISH then we must assume there's more input. ++ if (flush != MZ_FINISH) decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT; ++ ++ if (pState->m_dict_avail) ++ { ++ n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); ++ memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); ++ pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n; ++ pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); ++ return ((pState->m_last_status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; ++ } ++ ++ for ( ; ; ) ++ { ++ in_bytes = pStream->avail_in; ++ out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs; ++ ++ status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags); ++ pState->m_last_status = status; ++ ++ pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; ++ pStream->total_in += (mz_uint)in_bytes; pStream->adler = tinfl_get_adler32(&pState->m_decomp); ++ ++ pState->m_dict_avail = (mz_uint)out_bytes; ++ ++ n = MZ_MIN(pState->m_dict_avail, pStream->avail_out); ++ memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n); ++ pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n; ++ pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1); ++ ++ if (status < 0) ++ return MZ_DATA_ERROR; // Stream is corrupted (there could be some uncompressed data left in the output dictionary - oh well). ++ else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in)) ++ return MZ_BUF_ERROR; // Signal caller that we can't make forward progress without supplying more input or by setting flush to MZ_FINISH. ++ else if (flush == MZ_FINISH) ++ { ++ // The output buffer MUST be large to hold the remaining uncompressed data when flush==MZ_FINISH. ++ if (status == TINFL_STATUS_DONE) ++ return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END; ++ // status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's at least 1 more byte on the way. If there's no more room left in the output buffer then something is wrong. ++ else if (!pStream->avail_out) ++ return MZ_BUF_ERROR; ++ } ++ else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || (!pStream->avail_out) || (pState->m_dict_avail)) ++ break; ++ } ++ ++ return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK; ++} ++ ++int mz_inflateEnd(mz_streamp pStream) ++{ ++ if (!pStream) ++ return MZ_STREAM_ERROR; ++ if (pStream->state) ++ { ++ pStream->zfree(pStream->opaque, pStream->state); ++ pStream->state = NULL; ++ } ++ return MZ_OK; ++} ++ ++int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) ++{ ++ mz_stream stream; ++ int status; ++ memset(&stream, 0, sizeof(stream)); ++ ++ // In case mz_ulong is 64-bits (argh I hate longs). ++ if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; ++ ++ stream.next_in = pSource; ++ stream.avail_in = (mz_uint32)source_len; ++ stream.next_out = pDest; ++ stream.avail_out = (mz_uint32)*pDest_len; ++ ++ status = mz_inflateInit(&stream); ++ if (status != MZ_OK) ++ return status; ++ ++ status = mz_inflate(&stream, MZ_FINISH); ++ if (status != MZ_STREAM_END) ++ { ++ mz_inflateEnd(&stream); ++ return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR : status; ++ } ++ *pDest_len = stream.total_out; ++ ++ return mz_inflateEnd(&stream); ++} ++ ++const char *mz_error(int err) ++{ ++ static struct { int m_err; const char *m_pDesc; } s_error_descs[] = ++ { ++ { MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, ++ { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" } ++ }; ++ mz_uint i; for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) if (s_error_descs[i].m_err == err) return s_error_descs[i].m_pDesc; ++ return NULL; ++} ++ ++#endif //MINIZ_NO_ZLIB_APIS ++ ++// ------------------- Low-level Decompression (completely independent from all compression API's) ++ ++#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l) ++#define TINFL_MEMSET(p, c, l) memset(p, c, l) ++ ++#define TINFL_CR_BEGIN switch(r->m_state) { case 0: ++#define TINFL_CR_RETURN(state_index, result) do { status = result; r->m_state = state_index; goto common_exit; case state_index:; } MZ_MACRO_END ++#define TINFL_CR_RETURN_FOREVER(state_index, result) do { for ( ; ; ) { TINFL_CR_RETURN(state_index, result); } } MZ_MACRO_END ++#define TINFL_CR_FINISH } ++ ++#define TINFL_GET_BYTE(state_index, c) do { \ ++ while (pIn_buf_cur >= pIn_buf_end) { \ ++ TINFL_CR_RETURN(state_index, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); \ ++ } c = *pIn_buf_cur++; } MZ_MACRO_END ++ ++#define TINFL_NEED_BITS(state_index, n) do { mz_uint c; TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; } while (num_bits < (mz_uint)(n)) ++#define TINFL_SKIP_BITS(state_index, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END ++#define TINFL_GET_BITS(state_index, b, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } b = bit_buf & ((1 << (n)) - 1); bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END ++ ++// TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes remaining in the input buffer falls below 2. ++// It reads just enough bytes from the input stream that are needed to decode the next Huffman code (and absolutely no more). It works by trying to fully decode a ++// Huffman code by using whatever bits are currently present in the bit buffer. If this fails, it reads another byte, and tries again until it succeeds or until the ++// bit buffer contains >=15 bits (deflate's max. Huffman code size). ++#define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \ ++ do { \ ++ temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \ ++ if (temp >= 0) { \ ++ code_len = temp >> 9; \ ++ if ((code_len) && (num_bits >= code_len)) \ ++ break; \ ++ } else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \ ++ code_len = TINFL_FAST_LOOKUP_BITS; \ ++ do { \ ++ temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \ ++ } while ((temp < 0) && (num_bits >= (code_len + 1))); if (temp >= 0) break; \ ++ } TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; \ ++ } while (num_bits < 15); ++ ++// TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex than you would initially expect because the zlib API expects the decompressor to never read ++// beyond the final byte of the deflate stream. (In other words, when this macro wants to read another byte from the input, it REALLY needs another byte in order to fully ++// decode the next Huffman code.) Handling this properly is particularly important on raw deflate (non-zlib) streams, which aren't followed by a byte aligned adler-32. ++// The slow path is only executed at the very end of the input buffer. ++// v1.16: The original macro handled the case at the very end of the passed-in input buffer, but we also need to handle the case where the user passes in 1+zillion bytes ++// following the deflate data and our non-conservative read-ahead path won't kick in here on this code. This is much trickier. ++#define TINFL_HUFF_DECODE(state_index, sym, pHuff) do { \ ++ int temp; mz_uint code_len, c; \ ++ if (num_bits < 15) { \ ++ if ((pIn_buf_end - pIn_buf_cur) < 2) { \ ++ TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \ ++ } else { \ ++ bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); pIn_buf_cur += 2; num_bits += 16; \ ++ } \ ++ } \ ++ if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \ ++ code_len = temp >> 9, temp &= 511; \ ++ else { \ ++ code_len = TINFL_FAST_LOOKUP_BITS; do { temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; } while (temp < 0); \ ++ } sym = temp; bit_buf >>= code_len; num_bits -= code_len; } MZ_MACRO_END ++ ++tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags) ++{ ++ static const int s_length_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; ++ static const int s_length_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; ++ static const int s_dist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; ++ static const int s_dist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; ++ static const mz_uint8 s_length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; ++ static const int s_min_table_sizes[3] = { 257, 1, 4 }; ++ ++ tinfl_status status = TINFL_STATUS_FAILED; mz_uint32 num_bits, dist, counter, num_extra; tinfl_bit_buf_t bit_buf; ++ const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size; ++ mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size; ++ size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t)-1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start; ++ ++ // Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter). ++ if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) { *pIn_buf_size = *pOut_buf_size = 0; return TINFL_STATUS_BAD_PARAM; } ++ ++ num_bits = r->m_num_bits; bit_buf = r->m_bit_buf; dist = r->m_dist; counter = r->m_counter; num_extra = r->m_num_extra; dist_from_out_buf_start = r->m_dist_from_out_buf_start; ++ TINFL_CR_BEGIN ++ ++ bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0; r->m_z_adler32 = r->m_check_adler32 = 1; ++ if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) ++ { ++ TINFL_GET_BYTE(1, r->m_zhdr0); TINFL_GET_BYTE(2, r->m_zhdr1); ++ counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) || (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8)); ++ if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) || ((out_buf_size_mask + 1) < (size_t)(1U << (8U + (r->m_zhdr0 >> 4))))); ++ if (counter) { TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED); } ++ } ++ ++ do ++ { ++ TINFL_GET_BITS(3, r->m_final, 3); r->m_type = r->m_final >> 1; ++ if (r->m_type == 0) ++ { ++ TINFL_SKIP_BITS(5, num_bits & 7); ++ for (counter = 0; counter < 4; ++counter) { if (num_bits) TINFL_GET_BITS(6, r->m_raw_header[counter], 8); else TINFL_GET_BYTE(7, r->m_raw_header[counter]); } ++ if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) != (mz_uint)(0xFFFF ^ (r->m_raw_header[2] | (r->m_raw_header[3] << 8)))) { TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED); } ++ while ((counter) && (num_bits)) ++ { ++ TINFL_GET_BITS(51, dist, 8); ++ while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT); } ++ *pOut_buf_cur++ = (mz_uint8)dist; ++ counter--; ++ } ++ while (counter) ++ { ++ size_t n; while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT); } ++ while (pIn_buf_cur >= pIn_buf_end) ++ { ++ TINFL_CR_RETURN(38, (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) ? TINFL_STATUS_NEEDS_MORE_INPUT : TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS); ++ } ++ n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur), (size_t)(pIn_buf_end - pIn_buf_cur)), counter); ++ TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n); pIn_buf_cur += n; pOut_buf_cur += n; counter -= (mz_uint)n; ++ } ++ } ++ else if (r->m_type == 3) ++ { ++ TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED); ++ } ++ else ++ { ++ if (r->m_type == 1) ++ { ++ mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i; ++ r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32); ++ for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8; ++ } ++ else ++ { ++ for (counter = 0; counter < 3; counter++) { TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]); r->m_table_sizes[counter] += s_min_table_sizes[counter]; } ++ MZ_CLEAR_OBJ(r->m_tables[2].m_code_size); for (counter = 0; counter < r->m_table_sizes[2]; counter++) { mz_uint s; TINFL_GET_BITS(14, s, 3); r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s; } ++ r->m_table_sizes[2] = 19; ++ } ++ for ( ; (int)r->m_type >= 0; r->m_type--) ++ { ++ int tree_next, tree_cur; tinfl_huff_table *pTable; ++ mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16]; pTable = &r->m_tables[r->m_type]; MZ_CLEAR_OBJ(total_syms); MZ_CLEAR_OBJ(pTable->m_look_up); MZ_CLEAR_OBJ(pTable->m_tree); ++ for (i = 0; i < r->m_table_sizes[r->m_type]; ++i) total_syms[pTable->m_code_size[i]]++; ++ used_syms = 0, total = 0; next_code[0] = next_code[1] = 0; ++ for (i = 1; i <= 15; ++i) { used_syms += total_syms[i]; next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); } ++ if ((65536 != total) && (used_syms > 1)) ++ { ++ TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED); ++ } ++ for (tree_next = -1, sym_index = 0; sym_index < r->m_table_sizes[r->m_type]; ++sym_index) ++ { ++ mz_uint rev_code = 0, l, cur_code, code_size = pTable->m_code_size[sym_index]; if (!code_size) continue; ++ cur_code = next_code[code_size]++; for (l = code_size; l > 0; l--, cur_code >>= 1) rev_code = (rev_code << 1) | (cur_code & 1); ++ if (code_size <= TINFL_FAST_LOOKUP_BITS) { mz_int16 k = (mz_int16)((code_size << 9) | sym_index); while (rev_code < TINFL_FAST_LOOKUP_SIZE) { pTable->m_look_up[rev_code] = k; rev_code += (1 << code_size); } continue; } ++ if (0 == (tree_cur = pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)])) { pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } ++ rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1); ++ for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--) ++ { ++ tree_cur -= ((rev_code >>= 1) & 1); ++ if (!pTable->m_tree[-tree_cur - 1]) { pTable->m_tree[-tree_cur - 1] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } else tree_cur = pTable->m_tree[-tree_cur - 1]; ++ } ++ tree_cur -= ((rev_code >>= 1) & 1); pTable->m_tree[-tree_cur - 1] = (mz_int16)sym_index; ++ } ++ if (r->m_type == 2) ++ { ++ for (counter = 0; counter < (r->m_table_sizes[0] + r->m_table_sizes[1]); ) ++ { ++ mz_uint s; TINFL_HUFF_DECODE(16, dist, &r->m_tables[2]); if (dist < 16) { r->m_len_codes[counter++] = (mz_uint8)dist; continue; } ++ if ((dist == 16) && (!counter)) ++ { ++ TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED); ++ } ++ num_extra = "\02\03\07"[dist - 16]; TINFL_GET_BITS(18, s, num_extra); s += "\03\03\013"[dist - 16]; ++ TINFL_MEMSET(r->m_len_codes + counter, (dist == 16) ? r->m_len_codes[counter - 1] : 0, s); counter += s; ++ } ++ if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter) ++ { ++ TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED); ++ } ++ TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes, r->m_table_sizes[0]); TINFL_MEMCPY(r->m_tables[1].m_code_size, r->m_len_codes + r->m_table_sizes[0], r->m_table_sizes[1]); ++ } ++ } ++ for ( ; ; ) ++ { ++ mz_uint8 *pSrc; ++ for ( ; ; ) ++ { ++ if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2)) ++ { ++ TINFL_HUFF_DECODE(23, counter, &r->m_tables[0]); ++ if (counter >= 256) ++ break; ++ while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT); } ++ *pOut_buf_cur++ = (mz_uint8)counter; ++ } ++ else ++ { ++ int sym2; mz_uint code_len; ++#if TINFL_USE_64BIT_BITBUF ++ if (num_bits < 30) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits); pIn_buf_cur += 4; num_bits += 32; } ++#else ++ if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; } ++#endif ++ if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) ++ code_len = sym2 >> 9; ++ else ++ { ++ code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0); ++ } ++ counter = sym2; bit_buf >>= code_len; num_bits -= code_len; ++ if (counter & 256) ++ break; ++ ++#if !TINFL_USE_64BIT_BITBUF ++ if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; } ++#endif ++ if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) ++ code_len = sym2 >> 9; ++ else ++ { ++ code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0); ++ } ++ bit_buf >>= code_len; num_bits -= code_len; ++ ++ pOut_buf_cur[0] = (mz_uint8)counter; ++ if (sym2 & 256) ++ { ++ pOut_buf_cur++; ++ counter = sym2; ++ break; ++ } ++ pOut_buf_cur[1] = (mz_uint8)sym2; ++ pOut_buf_cur += 2; ++ } ++ } ++ if ((counter &= 511) == 256) break; ++ ++ num_extra = s_length_extra[counter - 257]; counter = s_length_base[counter - 257]; ++ if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(25, extra_bits, num_extra); counter += extra_bits; } ++ ++ TINFL_HUFF_DECODE(26, dist, &r->m_tables[1]); ++ num_extra = s_dist_extra[dist]; dist = s_dist_base[dist]; ++ if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(27, extra_bits, num_extra); dist += extra_bits; } ++ ++ dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start; ++ if ((dist > dist_from_out_buf_start) && (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) ++ { ++ TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED); ++ } ++ ++ pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask); ++ ++ if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end) ++ { ++ while (counter--) ++ { ++ while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT); } ++ *pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask]; ++ } ++ continue; ++ } ++#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES ++ else if ((counter >= 9) && (counter <= dist)) ++ { ++ const mz_uint8 *pSrc_end = pSrc + (counter & ~7); ++ do ++ { ++ ((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0]; ++ ((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1]; ++ pOut_buf_cur += 8; ++ } while ((pSrc += 8) < pSrc_end); ++ if ((counter &= 7) < 3) ++ { ++ if (counter) ++ { ++ pOut_buf_cur[0] = pSrc[0]; ++ if (counter > 1) ++ pOut_buf_cur[1] = pSrc[1]; ++ pOut_buf_cur += counter; ++ } ++ continue; ++ } ++ } ++#endif ++ do ++ { ++ pOut_buf_cur[0] = pSrc[0]; ++ pOut_buf_cur[1] = pSrc[1]; ++ pOut_buf_cur[2] = pSrc[2]; ++ pOut_buf_cur += 3; pSrc += 3; ++ } while ((int)(counter -= 3) > 2); ++ if ((int)counter > 0) ++ { ++ pOut_buf_cur[0] = pSrc[0]; ++ if ((int)counter > 1) ++ pOut_buf_cur[1] = pSrc[1]; ++ pOut_buf_cur += counter; ++ } ++ } ++ } ++ } while (!(r->m_final & 1)); ++ ++ // Ensure byte alignment and put back any bytes from the bitbuf if we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. ++ // I'm being super conservative here. A number of simplifications can be made to the byte alignment part, and the Adler32 check shouldn't ever need to worry about reading from the bitbuf now. ++ TINFL_SKIP_BITS(32, num_bits & 7); ++ while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8)) { --pIn_buf_cur; num_bits -= 8; } bit_buf &= (tinfl_bit_buf_t)((1ULL << num_bits) - 1ULL); ++ MZ_ASSERT(!num_bits); // if this assert fires then we've read beyond the end of non-deflate/zlib streams with following data (such as gzip streams). ++ ++ if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) ++ { ++ for (counter = 0; counter < 4; ++counter) { mz_uint s; if (num_bits) TINFL_GET_BITS(41, s, 8); else TINFL_GET_BYTE(42, s); r->m_z_adler32 = (r->m_z_adler32 << 8) | s; } ++ } ++ TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE); ++ ++ TINFL_CR_FINISH ++ ++common_exit: ++ // As long as we aren't telling the caller that we NEED more input to make forward progress: ++ // Put back any bytes from the bitbuf in case we've looked ahead too far on gzip, or other Deflate streams followed by arbitrary data. ++ // We need to be very careful here to NOT push back any bytes we definitely know we need to make forward progress, though, or we'll lock the caller up into an inf loop. ++ if ((status != TINFL_STATUS_NEEDS_MORE_INPUT) && (status != TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS)) { while ((pIn_buf_cur > pIn_buf_next) && (num_bits >= 8)) { --pIn_buf_cur; num_bits -= 8; } } ++ r->m_num_bits = num_bits; r->m_bit_buf = bit_buf & (tinfl_bit_buf_t)((1ULL << num_bits) - 1ULL); r->m_dist = dist; r->m_counter = counter; r->m_num_extra = num_extra; r->m_dist_from_out_buf_start = dist_from_out_buf_start; ++ *pIn_buf_size = pIn_buf_cur - pIn_buf_next; *pOut_buf_size = pOut_buf_cur - pOut_buf_next; ++ if ((decomp_flags & (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) && (status >= 0)) ++ { ++ const mz_uint8 *ptr = pOut_buf_next; size_t buf_len = *pOut_buf_size; ++ mz_uint32 i, s1 = r->m_check_adler32 & 0xffff, s2 = r->m_check_adler32 >> 16; size_t block_len = buf_len % 5552; ++ while (buf_len) ++ { ++ for (i = 0; i + 7 < block_len; i += 8, ptr += 8) ++ { ++ s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1; ++ s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1; ++ } ++ for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1; ++ s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552; ++ } ++ r->m_check_adler32 = (s2 << 16) + s1; if ((status == TINFL_STATUS_DONE) && (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) && (r->m_check_adler32 != r->m_z_adler32)) status = TINFL_STATUS_ADLER32_MISMATCH; ++ } ++ return status; ++} ++ ++// Higher level helper functions. ++void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) ++{ ++ tinfl_decompressor decomp; void *pBuf = NULL, *pNew_buf; size_t src_buf_ofs = 0, out_buf_capacity = 0; ++ *pOut_len = 0; ++ tinfl_init(&decomp); ++ for ( ; ; ) ++ { ++ size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity; ++ tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8*)pSrc_buf + src_buf_ofs, &src_buf_size, (mz_uint8*)pBuf, pBuf ? (mz_uint8*)pBuf + *pOut_len : NULL, &dst_buf_size, ++ (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); ++ if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT)) ++ { ++ MZ_FREE(pBuf); *pOut_len = 0; return NULL; ++ } ++ src_buf_ofs += src_buf_size; ++ *pOut_len += dst_buf_size; ++ if (status == TINFL_STATUS_DONE) break; ++ new_out_buf_capacity = out_buf_capacity * 2; if (new_out_buf_capacity < 128) new_out_buf_capacity = 128; ++ pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity); ++ if (!pNew_buf) ++ { ++ MZ_FREE(pBuf); *pOut_len = 0; return NULL; ++ } ++ pBuf = pNew_buf; out_buf_capacity = new_out_buf_capacity; ++ } ++ return pBuf; ++} ++ ++size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) ++{ ++ tinfl_decompressor decomp; tinfl_status status; tinfl_init(&decomp); ++ status = tinfl_decompress(&decomp, (const mz_uint8*)pSrc_buf, &src_buf_len, (mz_uint8*)pOut_buf, (mz_uint8*)pOut_buf, &out_buf_len, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); ++ return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED : out_buf_len; ++} ++ ++int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) ++{ ++ int result = 0; ++ tinfl_decompressor decomp; ++ mz_uint8 *pDict = (mz_uint8*)MZ_MALLOC(TINFL_LZ_DICT_SIZE); size_t in_buf_ofs = 0, dict_ofs = 0; ++ if (!pDict) ++ return TINFL_STATUS_FAILED; ++ tinfl_init(&decomp); ++ for ( ; ; ) ++ { ++ size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size = TINFL_LZ_DICT_SIZE - dict_ofs; ++ tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8*)pIn_buf + in_buf_ofs, &in_buf_size, pDict, pDict + dict_ofs, &dst_buf_size, ++ (flags & ~(TINFL_FLAG_HAS_MORE_INPUT | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))); ++ in_buf_ofs += in_buf_size; ++ if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (int)dst_buf_size, pPut_buf_user))) ++ break; ++ if (status != TINFL_STATUS_HAS_MORE_OUTPUT) ++ { ++ result = (status == TINFL_STATUS_DONE); ++ break; ++ } ++ dict_ofs = (dict_ofs + dst_buf_size) & (TINFL_LZ_DICT_SIZE - 1); ++ } ++ MZ_FREE(pDict); ++ *pIn_buf_size = in_buf_ofs; ++ return result; ++} ++ ++// ------------------- Low-level Compression (independent from all decompression API's) ++ ++// Purposely making these tables static for faster init and thread safety. ++static const mz_uint16 s_tdefl_len_sym[256] = { ++ 257,258,259,260,261,262,263,264,265,265,266,266,267,267,268,268,269,269,269,269,270,270,270,270,271,271,271,271,272,272,272,272, ++ 273,273,273,273,273,273,273,273,274,274,274,274,274,274,274,274,275,275,275,275,275,275,275,275,276,276,276,276,276,276,276,276, ++ 277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278, ++ 279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280, ++ 281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281, ++ 282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282, ++ 283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283, ++ 284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,285 }; ++ ++static const mz_uint8 s_tdefl_len_extra[256] = { ++ 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, ++ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, ++ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, ++ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0 }; ++ ++static const mz_uint8 s_tdefl_small_dist_sym[512] = { ++ 0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11, ++ 11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13, ++ 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14, ++ 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, ++ 14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15, ++ 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16, ++ 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, ++ 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, ++ 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17, ++ 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, ++ 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, ++ 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17 }; ++ ++static const mz_uint8 s_tdefl_small_dist_extra[512] = { ++ 0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5, ++ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, ++ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, ++ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, ++ 7,7,7,7,7,7,7,7 }; ++ ++static const mz_uint8 s_tdefl_large_dist_sym[128] = { ++ 0,0,18,19,20,20,21,21,22,22,22,22,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26, ++ 26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, ++ 28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29 }; ++ ++static const mz_uint8 s_tdefl_large_dist_extra[128] = { ++ 0,0,8,8,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, ++ 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13, ++ 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13 }; ++ ++// Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted values. ++typedef struct { mz_uint16 m_key, m_sym_index; } tdefl_sym_freq; ++static tdefl_sym_freq* tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq* pSyms0, tdefl_sym_freq* pSyms1) ++{ ++ mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2]; tdefl_sym_freq* pCur_syms = pSyms0, *pNew_syms = pSyms1; MZ_CLEAR_OBJ(hist); ++ for (i = 0; i < num_syms; i++) { mz_uint freq = pSyms0[i].m_key; hist[freq & 0xFF]++; hist[256 + ((freq >> 8) & 0xFF)]++; } ++ while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256])) total_passes--; ++ for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8) ++ { ++ const mz_uint32* pHist = &hist[pass << 8]; ++ mz_uint offsets[256], cur_ofs = 0; ++ for (i = 0; i < 256; i++) { offsets[i] = cur_ofs; cur_ofs += pHist[i]; } ++ for (i = 0; i < num_syms; i++) pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i]; ++ { tdefl_sym_freq* t = pCur_syms; pCur_syms = pNew_syms; pNew_syms = t; } ++ } ++ return pCur_syms; ++} ++ ++// tdefl_calculate_minimum_redundancy() originally written by: Alistair Moffat, alistair@cs.mu.oz.au, Jyrki Katajainen, jyrki@diku.dk, November 1996. ++static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n) ++{ ++ int root, leaf, next, avbl, used, dpth; ++ if (n==0) return; else if (n==1) { A[0].m_key = 1; return; } ++ A[0].m_key += A[1].m_key; root = 0; leaf = 2; ++ for (next=1; next < n-1; next++) ++ { ++ if (leaf>=n || A[root].m_key=n || (root=0; next--) A[next].m_key = A[A[next].m_key].m_key+1; ++ avbl = 1; used = dpth = 0; root = n-2; next = n-1; ++ while (avbl>0) ++ { ++ while (root>=0 && (int)A[root].m_key==dpth) { used++; root--; } ++ while (avbl>used) { A[next--].m_key = (mz_uint16)(dpth); avbl--; } ++ avbl = 2*used; dpth++; used = 0; ++ } ++} ++ ++// Limits canonical Huffman code table's max code size. ++enum { TDEFL_MAX_SUPPORTED_HUFF_CODESIZE = 32 }; ++static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size) ++{ ++ int i; mz_uint32 total = 0; if (code_list_len <= 1) return; ++ for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++) pNum_codes[max_code_size] += pNum_codes[i]; ++ for (i = max_code_size; i > 0; i--) total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i)); ++ while (total != (1UL << max_code_size)) ++ { ++ pNum_codes[max_code_size]--; ++ for (i = max_code_size - 1; i > 0; i--) if (pNum_codes[i]) { pNum_codes[i]--; pNum_codes[i + 1] += 2; break; } ++ total--; ++ } ++} ++ ++static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int table_len, int code_size_limit, int static_table) ++{ ++ int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE]; mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1]; MZ_CLEAR_OBJ(num_codes); ++ if (static_table) ++ { ++ for (i = 0; i < table_len; i++) num_codes[d->m_huff_code_sizes[table_num][i]]++; ++ } ++ else ++ { ++ tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], *pSyms; ++ int num_used_syms = 0; ++ const mz_uint16 *pSym_count = &d->m_huff_count[table_num][0]; ++ for (i = 0; i < table_len; i++) if (pSym_count[i]) { syms0[num_used_syms].m_key = (mz_uint16)pSym_count[i]; syms0[num_used_syms++].m_sym_index = (mz_uint16)i; } ++ ++ pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1); tdefl_calculate_minimum_redundancy(pSyms, num_used_syms); ++ ++ for (i = 0; i < num_used_syms; i++) num_codes[pSyms[i].m_key]++; ++ ++ tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, code_size_limit); ++ ++ MZ_CLEAR_OBJ(d->m_huff_code_sizes[table_num]); MZ_CLEAR_OBJ(d->m_huff_codes[table_num]); ++ for (i = 1, j = num_used_syms; i <= code_size_limit; i++) ++ for (l = num_codes[i]; l > 0; l--) d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i); ++ } ++ ++ next_code[1] = 0; for (j = 0, i = 2; i <= code_size_limit; i++) next_code[i] = j = ((j + num_codes[i - 1]) << 1); ++ ++ for (i = 0; i < table_len; i++) ++ { ++ mz_uint rev_code = 0, code, code_size; if ((code_size = d->m_huff_code_sizes[table_num][i]) == 0) continue; ++ code = next_code[code_size]++; for (l = code_size; l > 0; l--, code >>= 1) rev_code = (rev_code << 1) | (code & 1); ++ d->m_huff_codes[table_num][i] = (mz_uint16)rev_code; ++ } ++} ++ ++#define TDEFL_PUT_BITS(b, l) do { \ ++ mz_uint bits = b; mz_uint len = l; MZ_ASSERT(bits <= ((1U << len) - 1U)); \ ++ d->m_bit_buffer |= (bits << d->m_bits_in); d->m_bits_in += len; \ ++ while (d->m_bits_in >= 8) { \ ++ if (d->m_pOutput_buf < d->m_pOutput_buf_end) \ ++ *d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \ ++ d->m_bit_buffer >>= 8; \ ++ d->m_bits_in -= 8; \ ++ } \ ++} MZ_MACRO_END ++ ++#define TDEFL_RLE_PREV_CODE_SIZE() { if (rle_repeat_count) { \ ++ if (rle_repeat_count < 3) { \ ++ d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \ ++ while (rle_repeat_count--) packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \ ++ } else { \ ++ d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); packed_code_sizes[num_packed_code_sizes++] = 16; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_repeat_count - 3); \ ++} rle_repeat_count = 0; } } ++ ++#define TDEFL_RLE_ZERO_CODE_SIZE() { if (rle_z_count) { \ ++ if (rle_z_count < 3) { \ ++ d->m_huff_count[2][0] = (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); while (rle_z_count--) packed_code_sizes[num_packed_code_sizes++] = 0; \ ++ } else if (rle_z_count <= 10) { \ ++ d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); packed_code_sizes[num_packed_code_sizes++] = 17; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 3); \ ++ } else { \ ++ d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); packed_code_sizes[num_packed_code_sizes++] = 18; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 11); \ ++} rle_z_count = 0; } } ++ ++static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; ++ ++static void tdefl_start_dynamic_block(tdefl_compressor *d) ++{ ++ int num_lit_codes, num_dist_codes, num_bit_lengths; mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index; ++ mz_uint8 code_sizes_to_pack[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], packed_code_sizes[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], prev_code_size = 0xFF; ++ ++ d->m_huff_count[0][256] = 1; ++ ++ tdefl_optimize_huffman_table(d, 0, TDEFL_MAX_HUFF_SYMBOLS_0, 15, MZ_FALSE); ++ tdefl_optimize_huffman_table(d, 1, TDEFL_MAX_HUFF_SYMBOLS_1, 15, MZ_FALSE); ++ ++ for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--) if (d->m_huff_code_sizes[0][num_lit_codes - 1]) break; ++ for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--) if (d->m_huff_code_sizes[1][num_dist_codes - 1]) break; ++ ++ memcpy(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes); ++ memcpy(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0], num_dist_codes); ++ total_code_sizes_to_pack = num_lit_codes + num_dist_codes; num_packed_code_sizes = 0; rle_z_count = 0; rle_repeat_count = 0; ++ ++ memset(&d->m_huff_count[2][0], 0, sizeof(d->m_huff_count[2][0]) * TDEFL_MAX_HUFF_SYMBOLS_2); ++ for (i = 0; i < total_code_sizes_to_pack; i++) ++ { ++ mz_uint8 code_size = code_sizes_to_pack[i]; ++ if (!code_size) ++ { ++ TDEFL_RLE_PREV_CODE_SIZE(); ++ if (++rle_z_count == 138) { TDEFL_RLE_ZERO_CODE_SIZE(); } ++ } ++ else ++ { ++ TDEFL_RLE_ZERO_CODE_SIZE(); ++ if (code_size != prev_code_size) ++ { ++ TDEFL_RLE_PREV_CODE_SIZE(); ++ d->m_huff_count[2][code_size] = (mz_uint16)(d->m_huff_count[2][code_size] + 1); packed_code_sizes[num_packed_code_sizes++] = code_size; ++ } ++ else if (++rle_repeat_count == 6) ++ { ++ TDEFL_RLE_PREV_CODE_SIZE(); ++ } ++ } ++ prev_code_size = code_size; ++ } ++ if (rle_repeat_count) { TDEFL_RLE_PREV_CODE_SIZE(); } else { TDEFL_RLE_ZERO_CODE_SIZE(); } ++ ++ tdefl_optimize_huffman_table(d, 2, TDEFL_MAX_HUFF_SYMBOLS_2, 7, MZ_FALSE); ++ ++ TDEFL_PUT_BITS(2, 2); ++ ++ TDEFL_PUT_BITS(num_lit_codes - 257, 5); ++ TDEFL_PUT_BITS(num_dist_codes - 1, 5); ++ ++ for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--) if (d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]]) break; ++ num_bit_lengths = MZ_MAX(4, (num_bit_lengths + 1)); TDEFL_PUT_BITS(num_bit_lengths - 4, 4); ++ for (i = 0; (int)i < num_bit_lengths; i++) TDEFL_PUT_BITS(d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3); ++ ++ for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes; ) ++ { ++ mz_uint code = packed_code_sizes[packed_code_sizes_index++]; MZ_ASSERT(code < TDEFL_MAX_HUFF_SYMBOLS_2); ++ TDEFL_PUT_BITS(d->m_huff_codes[2][code], d->m_huff_code_sizes[2][code]); ++ if (code >= 16) TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++], "\02\03\07"[code - 16]); ++ } ++} ++ ++static void tdefl_start_static_block(tdefl_compressor *d) ++{ ++ mz_uint i; ++ mz_uint8 *p = &d->m_huff_code_sizes[0][0]; ++ ++ for (i = 0; i <= 143; ++i) *p++ = 8; ++ for ( ; i <= 255; ++i) *p++ = 9; ++ for ( ; i <= 279; ++i) *p++ = 7; ++ for ( ; i <= 287; ++i) *p++ = 8; ++ ++ memset(d->m_huff_code_sizes[1], 5, 32); ++ ++ tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE); ++ tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE); ++ ++ TDEFL_PUT_BITS(1, 2); ++} ++ ++static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; ++ ++#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS ++static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) ++{ ++ mz_uint flags; ++ mz_uint8 *pLZ_codes; ++ mz_uint8 *pOutput_buf = d->m_pOutput_buf; ++ mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf; ++ mz_uint64 bit_buffer = d->m_bit_buffer; ++ mz_uint bits_in = d->m_bits_in; ++ ++#define TDEFL_PUT_BITS_FAST(b, l) { bit_buffer |= (((mz_uint64)(b)) << bits_in); bits_in += (l); } ++ ++ flags = 1; ++ for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1) ++ { ++ if (flags == 1) ++ flags = *pLZ_codes++ | 0x100; ++ ++ if (flags & 1) ++ { ++ mz_uint s0, s1, n0, n1, sym, num_extra_bits; ++ mz_uint match_len = pLZ_codes[0], match_dist = *(const mz_uint16 *)(pLZ_codes + 1); pLZ_codes += 3; ++ ++ MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); ++ TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); ++ TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); ++ ++ // This sequence coaxes MSVC into using cmov's vs. jmp's. ++ s0 = s_tdefl_small_dist_sym[match_dist & 511]; ++ n0 = s_tdefl_small_dist_extra[match_dist & 511]; ++ s1 = s_tdefl_large_dist_sym[match_dist >> 8]; ++ n1 = s_tdefl_large_dist_extra[match_dist >> 8]; ++ sym = (match_dist < 512) ? s0 : s1; ++ num_extra_bits = (match_dist < 512) ? n0 : n1; ++ ++ MZ_ASSERT(d->m_huff_code_sizes[1][sym]); ++ TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); ++ TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); ++ } ++ else ++ { ++ mz_uint lit = *pLZ_codes++; ++ MZ_ASSERT(d->m_huff_code_sizes[0][lit]); ++ TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); ++ ++ if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) ++ { ++ flags >>= 1; ++ lit = *pLZ_codes++; ++ MZ_ASSERT(d->m_huff_code_sizes[0][lit]); ++ TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); ++ ++ if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end)) ++ { ++ flags >>= 1; ++ lit = *pLZ_codes++; ++ MZ_ASSERT(d->m_huff_code_sizes[0][lit]); ++ TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); ++ } ++ } ++ } ++ ++ if (pOutput_buf >= d->m_pOutput_buf_end) ++ return MZ_FALSE; ++ ++ *(mz_uint64*)pOutput_buf = bit_buffer; ++ pOutput_buf += (bits_in >> 3); ++ bit_buffer >>= (bits_in & ~7); ++ bits_in &= 7; ++ } ++ ++#undef TDEFL_PUT_BITS_FAST ++ ++ d->m_pOutput_buf = pOutput_buf; ++ d->m_bits_in = 0; ++ d->m_bit_buffer = 0; ++ ++ while (bits_in) ++ { ++ mz_uint32 n = MZ_MIN(bits_in, 16); ++ TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n); ++ bit_buffer >>= n; ++ bits_in -= n; ++ } ++ ++ TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); ++ ++ return (d->m_pOutput_buf < d->m_pOutput_buf_end); ++} ++#else ++static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d) ++{ ++ mz_uint flags; ++ mz_uint8 *pLZ_codes; ++ ++ flags = 1; ++ for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1) ++ { ++ if (flags == 1) ++ flags = *pLZ_codes++ | 0x100; ++ if (flags & 1) ++ { ++ mz_uint sym, num_extra_bits; ++ mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); pLZ_codes += 3; ++ ++ MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); ++ TDEFL_PUT_BITS(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]); ++ TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]); ++ ++ if (match_dist < 512) ++ { ++ sym = s_tdefl_small_dist_sym[match_dist]; num_extra_bits = s_tdefl_small_dist_extra[match_dist]; ++ } ++ else ++ { ++ sym = s_tdefl_large_dist_sym[match_dist >> 8]; num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8]; ++ } ++ MZ_ASSERT(d->m_huff_code_sizes[1][sym]); ++ TDEFL_PUT_BITS(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]); ++ TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits); ++ } ++ else ++ { ++ mz_uint lit = *pLZ_codes++; ++ MZ_ASSERT(d->m_huff_code_sizes[0][lit]); ++ TDEFL_PUT_BITS(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]); ++ } ++ } ++ ++ TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]); ++ ++ return (d->m_pOutput_buf < d->m_pOutput_buf_end); ++} ++#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS ++ ++static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block) ++{ ++ if (static_block) ++ tdefl_start_static_block(d); ++ else ++ tdefl_start_dynamic_block(d); ++ return tdefl_compress_lz_codes(d); ++} ++ ++static int tdefl_flush_block(tdefl_compressor *d, int flush) ++{ ++ mz_uint saved_bit_buf, saved_bits_in; ++ mz_uint8 *pSaved_output_buf; ++ mz_bool comp_block_succeeded = MZ_FALSE; ++ int n, use_raw_block = ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size; ++ mz_uint8 *pOutput_buf_start = ((d->m_pPut_buf_func == NULL) && ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs) : d->m_output_buf; ++ ++ d->m_pOutput_buf = pOutput_buf_start; ++ d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16; ++ ++ MZ_ASSERT(!d->m_output_flush_remaining); ++ d->m_output_flush_ofs = 0; ++ d->m_output_flush_remaining = 0; ++ ++ *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left); ++ d->m_pLZ_code_buf -= (d->m_num_flags_left == 8); ++ ++ if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index)) ++ { ++ TDEFL_PUT_BITS(0x78, 8); TDEFL_PUT_BITS(0x01, 8); ++ } ++ ++ TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1); ++ ++ pSaved_output_buf = d->m_pOutput_buf; saved_bit_buf = d->m_bit_buffer; saved_bits_in = d->m_bits_in; ++ ++ if (!use_raw_block) ++ comp_block_succeeded = tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || (d->m_total_lz_bytes < 48)); ++ ++ // If the block gets expanded, forget the current contents of the output buffer and send a raw block instead. ++ if ( ((use_raw_block) || ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >= d->m_total_lz_bytes))) && ++ ((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size) ) ++ { ++ mz_uint i; d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; ++ TDEFL_PUT_BITS(0, 2); ++ if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } ++ for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF) ++ { ++ TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16); ++ } ++ for (i = 0; i < d->m_total_lz_bytes; ++i) ++ { ++ TDEFL_PUT_BITS(d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK], 8); ++ } ++ } ++ // Check for the extremely unlikely (if not impossible) case of the compressed block not fitting into the output buffer when using dynamic codes. ++ else if (!comp_block_succeeded) ++ { ++ d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in; ++ tdefl_compress_block(d, MZ_TRUE); ++ } ++ ++ if (flush) ++ { ++ if (flush == TDEFL_FINISH) ++ { ++ if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } ++ if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) { mz_uint i, a = d->m_adler32; for (i = 0; i < 4; i++) { TDEFL_PUT_BITS((a >> 24) & 0xFF, 8); a <<= 8; } } ++ } ++ else ++ { ++ mz_uint i, z = 0; TDEFL_PUT_BITS(0, 3); if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } for (i = 2; i; --i, z ^= 0xFFFF) { TDEFL_PUT_BITS(z & 0xFFFF, 16); } ++ } ++ } ++ ++ MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end); ++ ++ memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); ++ memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); ++ ++ d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes; d->m_total_lz_bytes = 0; d->m_block_index++; ++ ++ if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0) ++ { ++ if (d->m_pPut_buf_func) ++ { ++ *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; ++ if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user)) ++ return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED); ++ } ++ else if (pOutput_buf_start == d->m_output_buf) ++ { ++ int bytes_to_copy = (int)MZ_MIN((size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs)); ++ memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, bytes_to_copy); ++ d->m_out_buf_ofs += bytes_to_copy; ++ if ((n -= bytes_to_copy) != 0) ++ { ++ d->m_output_flush_ofs = bytes_to_copy; ++ d->m_output_flush_remaining = n; ++ } ++ } ++ else ++ { ++ d->m_out_buf_ofs += n; ++ } ++ } ++ ++ return d->m_output_flush_remaining; ++} ++ ++#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES ++#define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16*)(p) ++static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) ++{ ++ mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; ++ mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; ++ const mz_uint16 *s = (const mz_uint16*)(d->m_dict + pos), *p, *q; ++ mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD(s); ++ MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return; ++ for ( ; ; ) ++ { ++ for ( ; ; ) ++ { ++ if (--num_probes_left == 0) return; ++ #define TDEFL_PROBE \ ++ next_probe_pos = d->m_next[probe_pos]; \ ++ if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \ ++ probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ ++ if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break; ++ TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; ++ } ++ if (!dist) break; q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32; ++ do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && ++ (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) ); ++ if (!probe_len) ++ { ++ *pMatch_dist = dist; *pMatch_len = MZ_MIN(max_match_len, TDEFL_MAX_MATCH_LEN); break; ++ } ++ else if ((probe_len = ((mz_uint)(p - s) * 2) + (mz_uint)(*(const mz_uint8*)p == *(const mz_uint8*)q)) > match_len) ++ { ++ *pMatch_dist = dist; if ((*pMatch_len = match_len = MZ_MIN(max_match_len, probe_len)) == max_match_len) break; ++ c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]); ++ } ++ } ++} ++#else ++static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len) ++{ ++ mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len; ++ mz_uint num_probes_left = d->m_max_probes[match_len >= 32]; ++ const mz_uint8 *s = d->m_dict + pos, *p, *q; ++ mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1]; ++ MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return; ++ for ( ; ; ) ++ { ++ for ( ; ; ) ++ { ++ if (--num_probes_left == 0) return; ++ #define TDEFL_PROBE \ ++ next_probe_pos = d->m_next[probe_pos]; \ ++ if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \ ++ probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \ ++ if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) break; ++ TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; ++ } ++ if (!dist) break; p = s; q = d->m_dict + probe_pos; for (probe_len = 0; probe_len < max_match_len; probe_len++) if (*p++ != *q++) break; ++ if (probe_len > match_len) ++ { ++ *pMatch_dist = dist; if ((*pMatch_len = match_len = probe_len) == max_match_len) return; ++ c0 = d->m_dict[pos + match_len]; c1 = d->m_dict[pos + match_len - 1]; ++ } ++ } ++} ++#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES ++ ++#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN ++static mz_bool tdefl_compress_fast(tdefl_compressor *d) ++{ ++ // Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio. ++ mz_uint lookahead_pos = d->m_lookahead_pos, lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, total_lz_bytes = d->m_total_lz_bytes, num_flags_left = d->m_num_flags_left; ++ mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags; ++ mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; ++ ++ while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size))) ++ { ++ const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096; ++ mz_uint dst_pos = (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; ++ mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size); ++ d->m_src_buf_left -= num_bytes_to_process; ++ lookahead_size += num_bytes_to_process; ++ ++ while (num_bytes_to_process) ++ { ++ mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process); ++ memcpy(d->m_dict + dst_pos, d->m_pSrc, n); ++ if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) ++ memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos)); ++ d->m_pSrc += n; ++ dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK; ++ num_bytes_to_process -= n; ++ } ++ ++ dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size); ++ if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE)) break; ++ ++ while (lookahead_size >= 4) ++ { ++ mz_uint cur_match_dist, cur_match_len = 1; ++ mz_uint8 *pCur_dict = d->m_dict + cur_pos; ++ mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF; ++ mz_uint hash = (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & TDEFL_LEVEL1_HASH_SIZE_MASK; ++ mz_uint probe_pos = d->m_hash[hash]; ++ d->m_hash[hash] = (mz_uint16)lookahead_pos; ++ ++ if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((*(const mz_uint32 *)(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram)) ++ { ++ const mz_uint16 *p = (const mz_uint16 *)pCur_dict; ++ const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos); ++ mz_uint32 probe_len = 32; ++ do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && ++ (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) ); ++ cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q); ++ if (!probe_len) ++ cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0; ++ ++ if ((cur_match_len < TDEFL_MIN_MATCH_LEN) || ((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U))) ++ { ++ cur_match_len = 1; ++ *pLZ_code_buf++ = (mz_uint8)first_trigram; ++ *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); ++ d->m_huff_count[0][(mz_uint8)first_trigram]++; ++ } ++ else ++ { ++ mz_uint32 s0, s1; ++ cur_match_len = MZ_MIN(cur_match_len, lookahead_size); ++ ++ MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 1) && (cur_match_dist <= TDEFL_LZ_DICT_SIZE)); ++ ++ cur_match_dist--; ++ ++ pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN); ++ *(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist; ++ pLZ_code_buf += 3; ++ *pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80); ++ ++ s0 = s_tdefl_small_dist_sym[cur_match_dist & 511]; ++ s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8]; ++ d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++; ++ ++ d->m_huff_count[0][s_tdefl_len_sym[cur_match_len - TDEFL_MIN_MATCH_LEN]]++; ++ } ++ } ++ else ++ { ++ *pLZ_code_buf++ = (mz_uint8)first_trigram; ++ *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); ++ d->m_huff_count[0][(mz_uint8)first_trigram]++; ++ } ++ ++ if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; } ++ ++ total_lz_bytes += cur_match_len; ++ lookahead_pos += cur_match_len; ++ dict_size = MZ_MIN(dict_size + cur_match_len, TDEFL_LZ_DICT_SIZE); ++ cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK; ++ MZ_ASSERT(lookahead_size >= cur_match_len); ++ lookahead_size -= cur_match_len; ++ ++ if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) ++ { ++ int n; ++ d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; ++ d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; ++ if ((n = tdefl_flush_block(d, 0)) != 0) ++ return (n < 0) ? MZ_FALSE : MZ_TRUE; ++ total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left; ++ } ++ } ++ ++ while (lookahead_size) ++ { ++ mz_uint8 lit = d->m_dict[cur_pos]; ++ ++ total_lz_bytes++; ++ *pLZ_code_buf++ = lit; ++ *pLZ_flags = (mz_uint8)(*pLZ_flags >> 1); ++ if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; } ++ ++ d->m_huff_count[0][lit]++; ++ ++ lookahead_pos++; ++ dict_size = MZ_MIN(dict_size + 1, TDEFL_LZ_DICT_SIZE); ++ cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; ++ lookahead_size--; ++ ++ if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) ++ { ++ int n; ++ d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; ++ d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; ++ if ((n = tdefl_flush_block(d, 0)) != 0) ++ return (n < 0) ? MZ_FALSE : MZ_TRUE; ++ total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left; ++ } ++ } ++ } ++ ++ d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size; ++ d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left; ++ return MZ_TRUE; ++} ++#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN ++ ++static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, mz_uint8 lit) ++{ ++ d->m_total_lz_bytes++; ++ *d->m_pLZ_code_buf++ = lit; ++ *d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } ++ d->m_huff_count[0][lit]++; ++} ++ ++static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist) ++{ ++ mz_uint32 s0, s1; ++ ++ MZ_ASSERT((match_len >= TDEFL_MIN_MATCH_LEN) && (match_dist >= 1) && (match_dist <= TDEFL_LZ_DICT_SIZE)); ++ ++ d->m_total_lz_bytes += match_len; ++ ++ d->m_pLZ_code_buf[0] = (mz_uint8)(match_len - TDEFL_MIN_MATCH_LEN); ++ ++ match_dist -= 1; ++ d->m_pLZ_code_buf[1] = (mz_uint8)(match_dist & 0xFF); ++ d->m_pLZ_code_buf[2] = (mz_uint8)(match_dist >> 8); d->m_pLZ_code_buf += 3; ++ ++ *d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; } ++ ++ s0 = s_tdefl_small_dist_sym[match_dist & 511]; s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127]; ++ d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++; ++ ++ if (match_len >= TDEFL_MIN_MATCH_LEN) d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; ++} ++ ++static mz_bool tdefl_compress_normal(tdefl_compressor *d) ++{ ++ const mz_uint8 *pSrc = d->m_pSrc; size_t src_buf_left = d->m_src_buf_left; ++ tdefl_flush flush = d->m_flush; ++ ++ while ((src_buf_left) || ((flush) && (d->m_lookahead_size))) ++ { ++ mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos; ++ // Update dictionary and hash chains. Keeps the lookahead size equal to TDEFL_MAX_MATCH_LEN. ++ if ((d->m_lookahead_size + d->m_dict_size) >= (TDEFL_MIN_MATCH_LEN - 1)) ++ { ++ mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK, ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2; ++ mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK]; ++ mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size); ++ const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process; ++ src_buf_left -= num_bytes_to_process; ++ d->m_lookahead_size += num_bytes_to_process; ++ while (pSrc != pSrc_end) ++ { ++ mz_uint8 c = *pSrc++; d->m_dict[dst_pos] = c; if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; ++ hash = ((hash << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); ++ d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos); ++ dst_pos = (dst_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; ins_pos++; ++ } ++ } ++ else ++ { ++ while ((src_buf_left) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) ++ { ++ mz_uint8 c = *pSrc++; ++ mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK; ++ src_buf_left--; ++ d->m_dict[dst_pos] = c; ++ if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) ++ d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c; ++ if ((++d->m_lookahead_size + d->m_dict_size) >= TDEFL_MIN_MATCH_LEN) ++ { ++ mz_uint ins_pos = d->m_lookahead_pos + (d->m_lookahead_size - 1) - 2; ++ mz_uint hash = ((d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << (TDEFL_LZ_HASH_SHIFT * 2)) ^ (d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1); ++ d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos); ++ } ++ } ++ } ++ d->m_dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - d->m_lookahead_size, d->m_dict_size); ++ if ((!flush) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN)) ++ break; ++ ++ // Simple lazy/greedy parsing state machine. ++ len_to_move = 1; cur_match_dist = 0; cur_match_len = d->m_saved_match_len ? d->m_saved_match_len : (TDEFL_MIN_MATCH_LEN - 1); cur_pos = d->m_lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK; ++ if (d->m_flags & (TDEFL_RLE_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS)) ++ { ++ if ((d->m_dict_size) && (!(d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) ++ { ++ mz_uint8 c = d->m_dict[(cur_pos - 1) & TDEFL_LZ_DICT_SIZE_MASK]; ++ cur_match_len = 0; while (cur_match_len < d->m_lookahead_size) { if (d->m_dict[cur_pos + cur_match_len] != c) break; cur_match_len++; } ++ if (cur_match_len < TDEFL_MIN_MATCH_LEN) cur_match_len = 0; else cur_match_dist = 1; ++ } ++ } ++ else ++ { ++ tdefl_find_match(d, d->m_lookahead_pos, d->m_dict_size, d->m_lookahead_size, &cur_match_dist, &cur_match_len); ++ } ++ if (((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U)) || (cur_pos == cur_match_dist) || ((d->m_flags & TDEFL_FILTER_MATCHES) && (cur_match_len <= 5))) ++ { ++ cur_match_dist = cur_match_len = 0; ++ } ++ if (d->m_saved_match_len) ++ { ++ if (cur_match_len > d->m_saved_match_len) ++ { ++ tdefl_record_literal(d, (mz_uint8)d->m_saved_lit); ++ if (cur_match_len >= 128) ++ { ++ tdefl_record_match(d, cur_match_len, cur_match_dist); ++ d->m_saved_match_len = 0; len_to_move = cur_match_len; ++ } ++ else ++ { ++ d->m_saved_lit = d->m_dict[cur_pos]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; ++ } ++ } ++ else ++ { ++ tdefl_record_match(d, d->m_saved_match_len, d->m_saved_match_dist); ++ len_to_move = d->m_saved_match_len - 1; d->m_saved_match_len = 0; ++ } ++ } ++ else if (!cur_match_dist) ++ tdefl_record_literal(d, d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]); ++ else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) || (cur_match_len >= 128)) ++ { ++ tdefl_record_match(d, cur_match_len, cur_match_dist); ++ len_to_move = cur_match_len; ++ } ++ else ++ { ++ d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len; ++ } ++ // Move the lookahead forward by len_to_move bytes. ++ d->m_lookahead_pos += len_to_move; ++ MZ_ASSERT(d->m_lookahead_size >= len_to_move); ++ d->m_lookahead_size -= len_to_move; ++ d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, TDEFL_LZ_DICT_SIZE); ++ // Check if it's time to flush the current LZ codes to the internal output buffer. ++ if ( (d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) || ++ ( (d->m_total_lz_bytes > 31*1024) && (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >= d->m_total_lz_bytes) || (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) ) ++ { ++ int n; ++ d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left; ++ if ((n = tdefl_flush_block(d, 0)) != 0) ++ return (n < 0) ? MZ_FALSE : MZ_TRUE; ++ } ++ } ++ ++ d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left; ++ return MZ_TRUE; ++} ++ ++static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d) ++{ ++ if (d->m_pIn_buf_size) ++ { ++ *d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf; ++ } ++ ++ if (d->m_pOut_buf_size) ++ { ++ size_t n = MZ_MIN(*d->m_pOut_buf_size - d->m_out_buf_ofs, d->m_output_flush_remaining); ++ memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf + d->m_output_flush_ofs, n); ++ d->m_output_flush_ofs += (mz_uint)n; ++ d->m_output_flush_remaining -= (mz_uint)n; ++ d->m_out_buf_ofs += n; ++ ++ *d->m_pOut_buf_size = d->m_out_buf_ofs; ++ } ++ ++ return (d->m_finished && !d->m_output_flush_remaining) ? TDEFL_STATUS_DONE : TDEFL_STATUS_OKAY; ++} ++ ++tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush) ++{ ++ if (!d) ++ { ++ if (pIn_buf_size) *pIn_buf_size = 0; ++ if (pOut_buf_size) *pOut_buf_size = 0; ++ return TDEFL_STATUS_BAD_PARAM; ++ } ++ ++ d->m_pIn_buf = pIn_buf; d->m_pIn_buf_size = pIn_buf_size; ++ d->m_pOut_buf = pOut_buf; d->m_pOut_buf_size = pOut_buf_size; ++ d->m_pSrc = (const mz_uint8 *)(pIn_buf); d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0; ++ d->m_out_buf_ofs = 0; ++ d->m_flush = flush; ++ ++ if ( ((d->m_pPut_buf_func != NULL) == ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || (d->m_prev_return_status != TDEFL_STATUS_OKAY) || ++ (d->m_wants_to_finish && (flush != TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf) ) ++ { ++ if (pIn_buf_size) *pIn_buf_size = 0; ++ if (pOut_buf_size) *pOut_buf_size = 0; ++ return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM); ++ } ++ d->m_wants_to_finish |= (flush == TDEFL_FINISH); ++ ++ if ((d->m_output_flush_remaining) || (d->m_finished)) ++ return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); ++ ++#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN ++ if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) && ++ ((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) && ++ ((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0)) ++ { ++ if (!tdefl_compress_fast(d)) ++ return d->m_prev_return_status; ++ } ++ else ++#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN ++ { ++ if (!tdefl_compress_normal(d)) ++ return d->m_prev_return_status; ++ } ++ ++ if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) && (pIn_buf)) ++ d->m_adler32 = (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf, d->m_pSrc - (const mz_uint8 *)pIn_buf); ++ ++ if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) && (!d->m_output_flush_remaining)) ++ { ++ if (tdefl_flush_block(d, flush) < 0) ++ return d->m_prev_return_status; ++ d->m_finished = (flush == TDEFL_FINISH); ++ if (flush == TDEFL_FULL_FLUSH) { MZ_CLEAR_OBJ(d->m_hash); MZ_CLEAR_OBJ(d->m_next); d->m_dict_size = 0; } ++ } ++ ++ return (d->m_prev_return_status = tdefl_flush_output_buffer(d)); ++} ++ ++tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush) ++{ ++ MZ_ASSERT(d->m_pPut_buf_func); return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush); ++} ++ ++tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) ++{ ++ d->m_pPut_buf_func = pPut_buf_func; d->m_pPut_buf_user = pPut_buf_user; ++ d->m_flags = (mz_uint)(flags); d->m_max_probes[0] = 1 + ((flags & 0xFFF) + 2) / 3; d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0; ++ d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3; ++ if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG)) MZ_CLEAR_OBJ(d->m_hash); ++ d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size = d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0; ++ d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0; ++ d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; ++ d->m_pOutput_buf = d->m_output_buf; d->m_pOutput_buf_end = d->m_output_buf; d->m_prev_return_status = TDEFL_STATUS_OKAY; ++ d->m_saved_match_dist = d->m_saved_match_len = d->m_saved_lit = 0; d->m_adler32 = 1; ++ d->m_pIn_buf = NULL; d->m_pOut_buf = NULL; ++ d->m_pIn_buf_size = NULL; d->m_pOut_buf_size = NULL; ++ d->m_flush = TDEFL_NO_FLUSH; d->m_pSrc = NULL; d->m_src_buf_left = 0; d->m_out_buf_ofs = 0; ++ memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0); ++ memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1); ++ return TDEFL_STATUS_OKAY; ++} ++ ++tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d) ++{ ++ return d->m_prev_return_status; ++} ++ ++mz_uint32 tdefl_get_adler32(tdefl_compressor *d) ++{ ++ return d->m_adler32; ++} ++ ++mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags) ++{ ++ tdefl_compressor *pComp; mz_bool succeeded; if (((buf_len) && (!pBuf)) || (!pPut_buf_func)) return MZ_FALSE; ++ pComp = (tdefl_compressor*)MZ_MALLOC(sizeof(tdefl_compressor)); if (!pComp) return MZ_FALSE; ++ succeeded = (tdefl_init(pComp, pPut_buf_func, pPut_buf_user, flags) == TDEFL_STATUS_OKAY); ++ succeeded = succeeded && (tdefl_compress_buffer(pComp, pBuf, buf_len, TDEFL_FINISH) == TDEFL_STATUS_DONE); ++ MZ_FREE(pComp); return succeeded; ++} ++ ++typedef struct ++{ ++ size_t m_size, m_capacity; ++ mz_uint8 *m_pBuf; ++ mz_bool m_expandable; ++} tdefl_output_buffer; ++ ++static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser) ++{ ++ tdefl_output_buffer *p = (tdefl_output_buffer *)pUser; ++ size_t new_size = p->m_size + len; ++ if (new_size > p->m_capacity) ++ { ++ size_t new_capacity = p->m_capacity; mz_uint8 *pNew_buf; if (!p->m_expandable) return MZ_FALSE; ++ do { new_capacity = MZ_MAX(128U, new_capacity << 1U); } while (new_size > new_capacity); ++ pNew_buf = (mz_uint8*)MZ_REALLOC(p->m_pBuf, new_capacity); if (!pNew_buf) return MZ_FALSE; ++ p->m_pBuf = pNew_buf; p->m_capacity = new_capacity; ++ } ++ memcpy((mz_uint8*)p->m_pBuf + p->m_size, pBuf, len); p->m_size = new_size; ++ return MZ_TRUE; ++} ++ ++void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags) ++{ ++ tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); ++ if (!pOut_len) return MZ_FALSE; else *pOut_len = 0; ++ out_buf.m_expandable = MZ_TRUE; ++ if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return NULL; ++ *pOut_len = out_buf.m_size; return out_buf.m_pBuf; ++} ++ ++size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags) ++{ ++ tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf); ++ if (!pOut_buf) return 0; ++ out_buf.m_pBuf = (mz_uint8*)pOut_buf; out_buf.m_capacity = out_buf_len; ++ if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return 0; ++ return out_buf.m_size; ++} ++ ++#ifndef MINIZ_NO_ZLIB_APIS ++static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; ++ ++// level may actually range from [0,10] (10 is a "hidden" max level, where we want a bit more compression and it's fine if throughput to fall off a cliff on some files). ++mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy) ++{ ++ mz_uint comp_flags = s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0); ++ if (window_bits > 0) comp_flags |= TDEFL_WRITE_ZLIB_HEADER; ++ ++ if (!level) comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS; ++ else if (strategy == MZ_FILTERED) comp_flags |= TDEFL_FILTER_MATCHES; ++ else if (strategy == MZ_HUFFMAN_ONLY) comp_flags &= ~TDEFL_MAX_PROBES_MASK; ++ else if (strategy == MZ_FIXED) comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS; ++ else if (strategy == MZ_RLE) comp_flags |= TDEFL_RLE_MATCHES; ++ ++ return comp_flags; ++} ++#endif //MINIZ_NO_ZLIB_APIS ++ ++#ifdef _MSC_VER ++#pragma warning (push) ++#pragma warning (disable:4204) // nonstandard extension used : non-constant aggregate initializer (also supported by GNU C and C99, so no big deal) ++#endif ++ ++// Simple PNG writer function by Alex Evans, 2011. Released into the public domain: https://gist.github.com/908299, more context at ++// http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/. ++// This is actually a modification of Alex's original code so PNG files generated by this function pass pngcheck. ++void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip) ++{ ++ // Using a local copy of this array here in case MINIZ_NO_ZLIB_APIS was defined. ++ static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 }; ++ tdefl_compressor *pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); tdefl_output_buffer out_buf; int i, bpl = w * num_chans, y, z; mz_uint32 c; *pLen_out = 0; ++ if (!pComp) return NULL; ++ MZ_CLEAR_OBJ(out_buf); out_buf.m_expandable = MZ_TRUE; out_buf.m_capacity = 57+MZ_MAX(64, (1+bpl)*h); if (NULL == (out_buf.m_pBuf = (mz_uint8*)MZ_MALLOC(out_buf.m_capacity))) { MZ_FREE(pComp); return NULL; } ++ // write dummy header ++ for (z = 41; z; --z) tdefl_output_buffer_putter(&z, 1, &out_buf); ++ // compress image data ++ tdefl_init(pComp, tdefl_output_buffer_putter, &out_buf, s_tdefl_png_num_probes[MZ_MIN(10, level)] | TDEFL_WRITE_ZLIB_HEADER); ++ for (y = 0; y < h; ++y) { tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH); tdefl_compress_buffer(pComp, (mz_uint8*)pImage + (flip ? (h - 1 - y) : y) * bpl, bpl, TDEFL_NO_FLUSH); } ++ if (tdefl_compress_buffer(pComp, NULL, 0, TDEFL_FINISH) != TDEFL_STATUS_DONE) { MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; } ++ // write real header ++ *pLen_out = out_buf.m_size-41; ++ { ++ static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06}; ++ mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, ++ 0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,chans[num_chans],0,0,0,0,0,0,0, ++ (mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54}; ++ c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24); ++ memcpy(out_buf.m_pBuf, pnghdr, 41); ++ } ++ // write footer (IDAT CRC-32, followed by IEND chunk) ++ if (!tdefl_output_buffer_putter("\0\0\0\0\0\0\0\0\x49\x45\x4e\x44\xae\x42\x60\x82", 16, &out_buf)) { *pLen_out = 0; MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; } ++ c = (mz_uint32)mz_crc32(MZ_CRC32_INIT,out_buf.m_pBuf+41-4, *pLen_out+4); for (i=0; i<4; ++i, c<<=8) (out_buf.m_pBuf+out_buf.m_size-16)[i] = (mz_uint8)(c >> 24); ++ // compute final size of file, grab compressed data buffer and return ++ *pLen_out += 57; MZ_FREE(pComp); return out_buf.m_pBuf; ++} ++ ++void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out) ++{ ++ // Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's where #defined out) ++ return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE); ++} ++ ++// Allocate the tdefl_compressor and tinfl_decompressor structures in C so that ++// non-C language bindings to tdefL_ and tinfl_ API don't need to worry about ++// structure size and allocation mechanism. ++tdefl_compressor *tdefl_compressor_alloc() ++{ ++ return (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); ++} ++ ++void tdefl_compressor_free(tdefl_compressor* pComp) ++{ ++ MZ_FREE(pComp); ++} ++ ++tinfl_decompressor *tinfl_decompressor_alloc() ++{ ++ tinfl_decompressor *pDecomp = (tinfl_decompressor *)MZ_MALLOC(sizeof(tinfl_decompressor)); ++ if (pDecomp) ++ tinfl_init(pDecomp); ++ return pDecomp; ++} ++ ++void tinfl_decompressor_free(tinfl_decompressor *pDecomp) ++{ ++ MZ_FREE(pDecomp); ++} ++ ++#ifdef _MSC_VER ++#pragma warning (pop) ++#endif ++ ++// ------------------- .ZIP archive reading ++ ++#ifndef MINIZ_NO_ARCHIVE_APIS ++ ++#ifdef MINIZ_NO_STDIO ++ #define MZ_FILE void * ++#else ++ #include ++ #include ++ ++ #if defined(_MSC_VER) || defined(__MINGW64__) ++ static FILE *mz_fopen(const char *pFilename, const char *pMode) ++ { ++ FILE* pFile = NULL; ++ fopen_s(&pFile, pFilename, pMode); ++ return pFile; ++ } ++ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream) ++ { ++ FILE* pFile = NULL; ++ if (freopen_s(&pFile, pPath, pMode, pStream)) ++ return NULL; ++ return pFile; ++ } ++ #ifndef MINIZ_NO_TIME ++ #include ++ #endif ++ #define MZ_FILE FILE ++ #define MZ_FOPEN mz_fopen ++ #define MZ_FCLOSE fclose ++ #define MZ_FREAD fread ++ #define MZ_FWRITE fwrite ++ #define MZ_FTELL64 _ftelli64 ++ #define MZ_FSEEK64 _fseeki64 ++ #define MZ_FILE_STAT_STRUCT _stat ++ #define MZ_FILE_STAT _stat ++ #define MZ_FFLUSH fflush ++ #define MZ_FREOPEN mz_freopen ++ #define MZ_DELETE_FILE remove ++ #elif defined(__MINGW32__) ++ #ifndef MINIZ_NO_TIME ++ #include ++ #endif ++ #define MZ_FILE FILE ++ #define MZ_FOPEN(f, m) fopen(f, m) ++ #define MZ_FCLOSE fclose ++ #define MZ_FREAD fread ++ #define MZ_FWRITE fwrite ++ #define MZ_FTELL64 ftello64 ++ #define MZ_FSEEK64 fseeko64 ++ #define MZ_FILE_STAT_STRUCT _stat ++ #define MZ_FILE_STAT _stat ++ #define MZ_FFLUSH fflush ++ #define MZ_FREOPEN(f, m, s) freopen(f, m, s) ++ #define MZ_DELETE_FILE remove ++ #elif defined(__TINYC__) ++ #ifndef MINIZ_NO_TIME ++ #include ++ #endif ++ #define MZ_FILE FILE ++ #define MZ_FOPEN(f, m) fopen(f, m) ++ #define MZ_FCLOSE fclose ++ #define MZ_FREAD fread ++ #define MZ_FWRITE fwrite ++ #define MZ_FTELL64 ftell ++ #define MZ_FSEEK64 fseek ++ #define MZ_FILE_STAT_STRUCT stat ++ #define MZ_FILE_STAT stat ++ #define MZ_FFLUSH fflush ++ #define MZ_FREOPEN(f, m, s) freopen(f, m, s) ++ #define MZ_DELETE_FILE remove ++ #elif defined(__GNUC__) && _LARGEFILE64_SOURCE ++ #ifndef MINIZ_NO_TIME ++ #include ++ #endif ++ #define MZ_FILE FILE ++ #define MZ_FOPEN(f, m) fopen64(f, m) ++ #define MZ_FCLOSE fclose ++ #define MZ_FREAD fread ++ #define MZ_FWRITE fwrite ++ #define MZ_FTELL64 ftello64 ++ #define MZ_FSEEK64 fseeko64 ++ #define MZ_FILE_STAT_STRUCT stat64 ++ #define MZ_FILE_STAT stat64 ++ #define MZ_FFLUSH fflush ++ #define MZ_FREOPEN(p, m, s) freopen64(p, m, s) ++ #define MZ_DELETE_FILE remove ++ #else ++ #ifndef MINIZ_NO_TIME ++ #include ++ #endif ++ #define MZ_FILE FILE ++ #define MZ_FOPEN(f, m) fopen(f, m) ++ #define MZ_FCLOSE fclose ++ #define MZ_FREAD fread ++ #define MZ_FWRITE fwrite ++ #define MZ_FTELL64 ftello ++ #define MZ_FSEEK64 fseeko ++ #define MZ_FILE_STAT_STRUCT stat ++ #define MZ_FILE_STAT stat ++ #define MZ_FFLUSH fflush ++ #define MZ_FREOPEN(f, m, s) freopen(f, m, s) ++ #define MZ_DELETE_FILE remove ++ #endif // #ifdef _MSC_VER ++#endif // #ifdef MINIZ_NO_STDIO ++ ++#define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c)) ++ ++// Various ZIP archive enums. To completely avoid cross platform compiler alignment and platform endian issues, miniz.c doesn't use structs for any of this stuff. ++enum ++{ ++ // ZIP archive identifiers and record sizes ++ MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50, MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50, MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50, ++ MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22, ++ // Central directory header record offsets ++ MZ_ZIP_CDH_SIG_OFS = 0, MZ_ZIP_CDH_VERSION_MADE_BY_OFS = 4, MZ_ZIP_CDH_VERSION_NEEDED_OFS = 6, MZ_ZIP_CDH_BIT_FLAG_OFS = 8, ++ MZ_ZIP_CDH_METHOD_OFS = 10, MZ_ZIP_CDH_FILE_TIME_OFS = 12, MZ_ZIP_CDH_FILE_DATE_OFS = 14, MZ_ZIP_CDH_CRC32_OFS = 16, ++ MZ_ZIP_CDH_COMPRESSED_SIZE_OFS = 20, MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS = 24, MZ_ZIP_CDH_FILENAME_LEN_OFS = 28, MZ_ZIP_CDH_EXTRA_LEN_OFS = 30, ++ MZ_ZIP_CDH_COMMENT_LEN_OFS = 32, MZ_ZIP_CDH_DISK_START_OFS = 34, MZ_ZIP_CDH_INTERNAL_ATTR_OFS = 36, MZ_ZIP_CDH_EXTERNAL_ATTR_OFS = 38, MZ_ZIP_CDH_LOCAL_HEADER_OFS = 42, ++ // Local directory header offsets ++ MZ_ZIP_LDH_SIG_OFS = 0, MZ_ZIP_LDH_VERSION_NEEDED_OFS = 4, MZ_ZIP_LDH_BIT_FLAG_OFS = 6, MZ_ZIP_LDH_METHOD_OFS = 8, MZ_ZIP_LDH_FILE_TIME_OFS = 10, ++ MZ_ZIP_LDH_FILE_DATE_OFS = 12, MZ_ZIP_LDH_CRC32_OFS = 14, MZ_ZIP_LDH_COMPRESSED_SIZE_OFS = 18, MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22, ++ MZ_ZIP_LDH_FILENAME_LEN_OFS = 26, MZ_ZIP_LDH_EXTRA_LEN_OFS = 28, ++ // End of central directory offsets ++ MZ_ZIP_ECDH_SIG_OFS = 0, MZ_ZIP_ECDH_NUM_THIS_DISK_OFS = 4, MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS = 6, MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 8, ++ MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS = 10, MZ_ZIP_ECDH_CDIR_SIZE_OFS = 12, MZ_ZIP_ECDH_CDIR_OFS_OFS = 16, MZ_ZIP_ECDH_COMMENT_SIZE_OFS = 20, ++}; ++ ++typedef struct ++{ ++ void *m_p; ++ size_t m_size, m_capacity; ++ mz_uint m_element_size; ++} mz_zip_array; ++ ++struct mz_zip_internal_state_tag ++{ ++ mz_zip_array m_central_dir; ++ mz_zip_array m_central_dir_offsets; ++ mz_zip_array m_sorted_central_dir_offsets; ++ MZ_FILE *m_pFile; ++ void *m_pMem; ++ size_t m_mem_size; ++ size_t m_mem_capacity; ++}; ++ ++#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size ++#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index] ++ ++static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array *pArray) ++{ ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pArray->m_p); ++ memset(pArray, 0, sizeof(mz_zip_array)); ++} ++ ++static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing) ++{ ++ void *pNew_p; size_t new_capacity = min_new_capacity; MZ_ASSERT(pArray->m_element_size); if (pArray->m_capacity >= min_new_capacity) return MZ_TRUE; ++ if (growing) { new_capacity = MZ_MAX(1, pArray->m_capacity); while (new_capacity < min_new_capacity) new_capacity *= 2; } ++ if (NULL == (pNew_p = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pArray->m_p, pArray->m_element_size, new_capacity))) return MZ_FALSE; ++ pArray->m_p = pNew_p; pArray->m_capacity = new_capacity; ++ return MZ_TRUE; ++} ++ ++static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing) ++{ ++ if (new_capacity > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing)) return MZ_FALSE; } ++ return MZ_TRUE; ++} ++ ++static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing) ++{ ++ if (new_size > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing)) return MZ_FALSE; } ++ pArray->m_size = new_size; ++ return MZ_TRUE; ++} ++ ++static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n) ++{ ++ return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE); ++} ++ ++static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray, const void *pElements, size_t n) ++{ ++ size_t orig_size = pArray->m_size; if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE)) return MZ_FALSE; ++ memcpy((mz_uint8*)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size); ++ return MZ_TRUE; ++} ++ ++#ifndef MINIZ_NO_TIME ++static time_t mz_zip_dos_to_time_t(int dos_time, int dos_date) ++{ ++ struct tm tm; ++ memset(&tm, 0, sizeof(tm)); tm.tm_isdst = -1; ++ tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900; tm.tm_mon = ((dos_date >> 5) & 15) - 1; tm.tm_mday = dos_date & 31; ++ tm.tm_hour = (dos_time >> 11) & 31; tm.tm_min = (dos_time >> 5) & 63; tm.tm_sec = (dos_time << 1) & 62; ++ return mktime(&tm); ++} ++ ++static void mz_zip_time_to_dos_time(time_t time, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) ++{ ++#ifdef _MSC_VER ++ struct tm tm_struct; ++ struct tm *tm = &tm_struct; ++ errno_t err = localtime_s(tm, &time); ++ if (err) ++ { ++ *pDOS_date = 0; *pDOS_time = 0; ++ return; ++ } ++#else ++ struct tm *tm = localtime(&time); ++#endif ++ *pDOS_time = (mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1)); ++ *pDOS_date = (mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday); ++} ++#endif ++ ++#ifndef MINIZ_NO_STDIO ++static mz_bool mz_zip_get_file_modified_time(const char *pFilename, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date) ++{ ++#ifdef MINIZ_NO_TIME ++ (void)pFilename; *pDOS_date = *pDOS_time = 0; ++#else ++ struct MZ_FILE_STAT_STRUCT file_stat; ++ // On Linux with x86 glibc, this call will fail on large files (>= 0x80000000 bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh. ++ if (MZ_FILE_STAT(pFilename, &file_stat) != 0) ++ return MZ_FALSE; ++ mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date); ++#endif // #ifdef MINIZ_NO_TIME ++ return MZ_TRUE; ++} ++ ++#ifndef MINIZ_NO_TIME ++static mz_bool mz_zip_set_file_times(const char *pFilename, time_t access_time, time_t modified_time) ++{ ++ struct utimbuf t; t.actime = access_time; t.modtime = modified_time; ++ return !utime(pFilename, &t); ++} ++#endif // #ifndef MINIZ_NO_TIME ++#endif // #ifndef MINIZ_NO_STDIO ++ ++static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint32 flags) ++{ ++ (void)flags; ++ if ((!pZip) || (pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) ++ return MZ_FALSE; ++ ++ if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; ++ if (!pZip->m_pFree) pZip->m_pFree = def_free_func; ++ if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; ++ ++ pZip->m_zip_mode = MZ_ZIP_MODE_READING; ++ pZip->m_archive_size = 0; ++ pZip->m_central_directory_file_ofs = 0; ++ pZip->m_total_files = 0; ++ ++ if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) ++ return MZ_FALSE; ++ memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); ++ MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); ++ MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); ++ MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); ++ return MZ_TRUE; ++} ++ ++static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, mz_uint r_index) ++{ ++ const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; ++ const mz_uint8 *pR = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index)); ++ mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS); ++ mz_uint8 l = 0, r = 0; ++ pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; ++ pE = pL + MZ_MIN(l_len, r_len); ++ while (pL < pE) ++ { ++ if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) ++ break; ++ pL++; pR++; ++ } ++ return (pL == pE) ? (l_len < r_len) : (l < r); ++} ++ ++#define MZ_SWAP_UINT32(a, b) do { mz_uint32 t = a; a = b; b = t; } MZ_MACRO_END ++ ++// Heap sort of lowercased filenames, used to help accelerate plain central directory searches by mz_zip_reader_locate_file(). (Could also use qsort(), but it could allocate memory.) ++static void mz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *pZip) ++{ ++ mz_zip_internal_state *pState = pZip->m_pState; ++ const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; ++ const mz_zip_array *pCentral_dir = &pState->m_central_dir; ++ mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0); ++ const int size = pZip->m_total_files; ++ int start = (size - 2) >> 1, end; ++ while (start >= 0) ++ { ++ int child, root = start; ++ for ( ; ; ) ++ { ++ if ((child = (root << 1) + 1) >= size) ++ break; ++ child += (((child + 1) < size) && (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1]))); ++ if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) ++ break; ++ MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child; ++ } ++ start--; ++ } ++ ++ end = size - 1; ++ while (end > 0) ++ { ++ int child, root = 0; ++ MZ_SWAP_UINT32(pIndices[end], pIndices[0]); ++ for ( ; ; ) ++ { ++ if ((child = (root << 1) + 1) >= end) ++ break; ++ child += (((child + 1) < end) && mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1])); ++ if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child])) ++ break; ++ MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child; ++ } ++ end--; ++ } ++} ++ ++static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint32 flags) ++{ ++ mz_uint cdir_size, num_this_disk, cdir_disk_index; ++ mz_uint64 cdir_ofs; ++ mz_int64 cur_file_ofs; ++ const mz_uint8 *p; ++ mz_uint32 buf_u32[4096 / sizeof(mz_uint32)]; mz_uint8 *pBuf = (mz_uint8 *)buf_u32; ++ mz_bool sort_central_dir = ((flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0); ++ // Basic sanity checks - reject files which are too small, and check the first 4 bytes of the file to make sure a local header is there. ++ if (pZip->m_archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) ++ return MZ_FALSE; ++ // Find the end of central directory record by scanning the file from the end towards the beginning. ++ cur_file_ofs = MZ_MAX((mz_int64)pZip->m_archive_size - (mz_int64)sizeof(buf_u32), 0); ++ for ( ; ; ) ++ { ++ int i, n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs); ++ if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n) ++ return MZ_FALSE; ++ for (i = n - 4; i >= 0; --i) ++ if (MZ_READ_LE32(pBuf + i) == MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) ++ break; ++ if (i >= 0) ++ { ++ cur_file_ofs += i; ++ break; ++ } ++ if ((!cur_file_ofs) || ((pZip->m_archive_size - cur_file_ofs) >= (0xFFFF + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE))) ++ return MZ_FALSE; ++ cur_file_ofs = MZ_MAX(cur_file_ofs - (sizeof(buf_u32) - 3), 0); ++ } ++ // Read and verify the end of central directory record. ++ if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) ++ return MZ_FALSE; ++ if ((MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_SIG_OFS) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) || ++ ((pZip->m_total_files = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS)) != MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS))) ++ return MZ_FALSE; ++ ++ num_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_THIS_DISK_OFS); ++ cdir_disk_index = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS); ++ if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1))) ++ return MZ_FALSE; ++ ++ if ((cdir_size = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_SIZE_OFS)) < pZip->m_total_files * MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) ++ return MZ_FALSE; ++ ++ cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS); ++ if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size) ++ return MZ_FALSE; ++ ++ pZip->m_central_directory_file_ofs = cdir_ofs; ++ ++ if (pZip->m_total_files) ++ { ++ mz_uint i, n; ++ ++ // Read the entire central directory into a heap block, and allocate another heap block to hold the unsorted central dir file record offsets, and another to hold the sorted indices. ++ if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, MZ_FALSE)) || ++ (!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, pZip->m_total_files, MZ_FALSE))) ++ return MZ_FALSE; ++ ++ if (sort_central_dir) ++ { ++ if (!mz_zip_array_resize(pZip, &pZip->m_pState->m_sorted_central_dir_offsets, pZip->m_total_files, MZ_FALSE)) ++ return MZ_FALSE; ++ } ++ ++ if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs, pZip->m_pState->m_central_dir.m_p, cdir_size) != cdir_size) ++ return MZ_FALSE; ++ ++ // Now create an index into the central directory file records, do some basic sanity checking on each record, and check for zip64 entries (which are not yet supported). ++ p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p; ++ for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i) ++ { ++ mz_uint total_header_size, comp_size, decomp_size, disk_index; ++ if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) || (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG)) ++ return MZ_FALSE; ++ MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, i) = (mz_uint32)(p - (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p); ++ if (sort_central_dir) ++ MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_sorted_central_dir_offsets, mz_uint32, i) = i; ++ comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); ++ decomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); ++ if (((!MZ_READ_LE32(p + MZ_ZIP_CDH_METHOD_OFS)) && (decomp_size != comp_size)) || (decomp_size && !comp_size) || (decomp_size == 0xFFFFFFFF) || (comp_size == 0xFFFFFFFF)) ++ return MZ_FALSE; ++ disk_index = MZ_READ_LE16(p + MZ_ZIP_CDH_DISK_START_OFS); ++ if ((disk_index != num_this_disk) && (disk_index != 1)) ++ return MZ_FALSE; ++ if (((mz_uint64)MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS) + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + comp_size) > pZip->m_archive_size) ++ return MZ_FALSE; ++ if ((total_header_size = MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS)) > n) ++ return MZ_FALSE; ++ n -= total_header_size; p += total_header_size; ++ } ++ } ++ ++ if (sort_central_dir) ++ mz_zip_reader_sort_central_dir_offsets_by_filename(pZip); ++ ++ return MZ_TRUE; ++} ++ ++mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags) ++{ ++ if ((!pZip) || (!pZip->m_pRead)) ++ return MZ_FALSE; ++ if (!mz_zip_reader_init_internal(pZip, flags)) ++ return MZ_FALSE; ++ pZip->m_archive_size = size; ++ if (!mz_zip_reader_read_central_dir(pZip, flags)) ++ { ++ mz_zip_reader_end(pZip); ++ return MZ_FALSE; ++ } ++ return MZ_TRUE; ++} ++ ++static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) ++{ ++ mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; ++ size_t s = (file_ofs >= pZip->m_archive_size) ? 0 : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n); ++ memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s); ++ return s; ++} ++ ++mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags) ++{ ++ if (!mz_zip_reader_init_internal(pZip, flags)) ++ return MZ_FALSE; ++ pZip->m_archive_size = size; ++ pZip->m_pRead = mz_zip_mem_read_func; ++ pZip->m_pIO_opaque = pZip; ++#ifdef __cplusplus ++ pZip->m_pState->m_pMem = const_cast(pMem); ++#else ++ pZip->m_pState->m_pMem = (void *)pMem; ++#endif ++ pZip->m_pState->m_mem_size = size; ++ if (!mz_zip_reader_read_central_dir(pZip, flags)) ++ { ++ mz_zip_reader_end(pZip); ++ return MZ_FALSE; ++ } ++ return MZ_TRUE; ++} ++ ++#ifndef MINIZ_NO_STDIO ++static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n) ++{ ++ mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; ++ mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); ++ if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) ++ return 0; ++ return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile); ++} ++ ++mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags) ++{ ++ mz_uint64 file_size; ++ MZ_FILE *pFile = MZ_FOPEN(pFilename, "rb"); ++ if (!pFile) ++ return MZ_FALSE; ++ if (MZ_FSEEK64(pFile, 0, SEEK_END)) ++ { ++ MZ_FCLOSE(pFile); ++ return MZ_FALSE; ++ } ++ file_size = MZ_FTELL64(pFile); ++ if (!mz_zip_reader_init_internal(pZip, flags)) ++ { ++ MZ_FCLOSE(pFile); ++ return MZ_FALSE; ++ } ++ pZip->m_pRead = mz_zip_file_read_func; ++ pZip->m_pIO_opaque = pZip; ++ pZip->m_pState->m_pFile = pFile; ++ pZip->m_archive_size = file_size; ++ if (!mz_zip_reader_read_central_dir(pZip, flags)) ++ { ++ mz_zip_reader_end(pZip); ++ return MZ_FALSE; ++ } ++ return MZ_TRUE; ++} ++#endif // #ifndef MINIZ_NO_STDIO ++ ++mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip) ++{ ++ return pZip ? pZip->m_total_files : 0; ++} ++ ++static MZ_FORCEINLINE const mz_uint8 *mz_zip_reader_get_cdh(mz_zip_archive *pZip, mz_uint file_index) ++{ ++ if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) ++ return NULL; ++ return &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); ++} ++ ++mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index) ++{ ++ mz_uint m_bit_flag; ++ const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); ++ if (!p) ++ return MZ_FALSE; ++ m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); ++ return (m_bit_flag & 1); ++} ++ ++mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index) ++{ ++ mz_uint filename_len, external_attr; ++ const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); ++ if (!p) ++ return MZ_FALSE; ++ ++ // First see if the filename ends with a '/' character. ++ filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); ++ if (filename_len) ++ { ++ if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '/') ++ return MZ_TRUE; ++ } ++ ++ // Bugfix: This code was also checking if the internal attribute was non-zero, which wasn't correct. ++ // Most/all zip writers (hopefully) set DOS file/directory attributes in the low 16-bits, so check for the DOS directory flag and ignore the source OS ID in the created by field. ++ // FIXME: Remove this check? Is it necessary - we already check the filename. ++ external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); ++ if ((external_attr & 0x10) != 0) ++ return MZ_TRUE; ++ ++ return MZ_FALSE; ++} ++ ++mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat) ++{ ++ mz_uint n; ++ const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); ++ if ((!p) || (!pStat)) ++ return MZ_FALSE; ++ ++ // Unpack the central directory record. ++ pStat->m_file_index = file_index; ++ pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index); ++ pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS); ++ pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS); ++ pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS); ++ pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS); ++#ifndef MINIZ_NO_TIME ++ pStat->m_time = mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS), MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS)); ++#endif ++ pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS); ++ pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); ++ pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); ++ pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS); ++ pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS); ++ pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS); ++ ++ // Copy as much of the filename and comment as possible. ++ n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1); ++ memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); pStat->m_filename[n] = '\0'; ++ ++ n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1); ++ pStat->m_comment_size = n; ++ memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n); pStat->m_comment[n] = '\0'; ++ ++ return MZ_TRUE; ++} ++ ++mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size) ++{ ++ mz_uint n; ++ const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); ++ if (!p) { if (filename_buf_size) pFilename[0] = '\0'; return 0; } ++ n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); ++ if (filename_buf_size) ++ { ++ n = MZ_MIN(n, filename_buf_size - 1); ++ memcpy(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); ++ pFilename[n] = '\0'; ++ } ++ return n + 1; ++} ++ ++static MZ_FORCEINLINE mz_bool mz_zip_reader_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags) ++{ ++ mz_uint i; ++ if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE) ++ return 0 == memcmp(pA, pB, len); ++ for (i = 0; i < len; ++i) ++ if (MZ_TOLOWER(pA[i]) != MZ_TOLOWER(pB[i])) ++ return MZ_FALSE; ++ return MZ_TRUE; ++} ++ ++static MZ_FORCEINLINE int mz_zip_reader_filename_compare(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, mz_uint r_len) ++{ ++ const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE; ++ mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS); ++ mz_uint8 l = 0, r = 0; ++ pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; ++ pE = pL + MZ_MIN(l_len, r_len); ++ while (pL < pE) ++ { ++ if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) ++ break; ++ pL++; pR++; ++ } ++ return (pL == pE) ? (int)(l_len - r_len) : (l - r); ++} ++ ++static int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename) ++{ ++ mz_zip_internal_state *pState = pZip->m_pState; ++ const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets; ++ const mz_zip_array *pCentral_dir = &pState->m_central_dir; ++ mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0); ++ const int size = pZip->m_total_files; ++ const mz_uint filename_len = (mz_uint)strlen(pFilename); ++ int l = 0, h = size - 1; ++ while (l <= h) ++ { ++ int m = (l + h) >> 1, file_index = pIndices[m], comp = mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len); ++ if (!comp) ++ return file_index; ++ else if (comp < 0) ++ l = m + 1; ++ else ++ h = m - 1; ++ } ++ return -1; ++} ++ ++int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags) ++{ ++ mz_uint file_index; size_t name_len, comment_len; ++ if ((!pZip) || (!pZip->m_pState) || (!pName) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) ++ return -1; ++ if (((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) && (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size)) ++ return mz_zip_reader_locate_file_binary_search(pZip, pName); ++ name_len = strlen(pName); if (name_len > 0xFFFF) return -1; ++ comment_len = pComment ? strlen(pComment) : 0; if (comment_len > 0xFFFF) return -1; ++ for (file_index = 0; file_index < pZip->m_total_files; file_index++) ++ { ++ const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index)); ++ mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS); ++ const char *pFilename = (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; ++ if (filename_len < name_len) ++ continue; ++ if (comment_len) ++ { ++ mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS); ++ const char *pFile_comment = pFilename + filename_len + file_extra_len; ++ if ((file_comment_len != comment_len) || (!mz_zip_reader_string_equal(pComment, pFile_comment, file_comment_len, flags))) ++ continue; ++ } ++ if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len)) ++ { ++ int ofs = filename_len - 1; ++ do ++ { ++ if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\') || (pFilename[ofs] == ':')) ++ break; ++ } while (--ofs >= 0); ++ ofs++; ++ pFilename += ofs; filename_len -= ofs; ++ } ++ if ((filename_len == name_len) && (mz_zip_reader_string_equal(pName, pFilename, filename_len, flags))) ++ return file_index; ++ } ++ return -1; ++} ++ ++mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) ++{ ++ int status = TINFL_STATUS_DONE; ++ mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail; ++ mz_zip_archive_file_stat file_stat; ++ void *pRead_buf; ++ mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; ++ tinfl_decompressor inflator; ++ ++ if ((buf_size) && (!pBuf)) ++ return MZ_FALSE; ++ ++ if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) ++ return MZ_FALSE; ++ ++ // Empty file, or a directory (but not always a directory - I've seen odd zips with directories that have compressed data which inflates to 0 bytes) ++ if (!file_stat.m_comp_size) ++ return MZ_TRUE; ++ ++ // Entry is a subdirectory (I've seen old zips with dir entries which have compressed deflate data which inflates to 0 bytes, but these entries claim to uncompress to 512 bytes in the headers). ++ // I'm torn how to handle this case - should it fail instead? ++ if (mz_zip_reader_is_file_a_directory(pZip, file_index)) ++ return MZ_TRUE; ++ ++ // Encryption and patch files are not supported. ++ if (file_stat.m_bit_flag & (1 | 32)) ++ return MZ_FALSE; ++ ++ // This function only supports stored and deflate. ++ if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) ++ return MZ_FALSE; ++ ++ // Ensure supplied output buffer is large enough. ++ needed_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size : file_stat.m_uncomp_size; ++ if (buf_size < needed_size) ++ return MZ_FALSE; ++ ++ // Read and parse the local directory entry. ++ cur_file_ofs = file_stat.m_local_header_ofs; ++ if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) ++ return MZ_FALSE; ++ if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) ++ return MZ_FALSE; ++ ++ cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); ++ if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) ++ return MZ_FALSE; ++ ++ if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) ++ { ++ // The file is stored or the caller has requested the compressed data. ++ if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, (size_t)needed_size) != needed_size) ++ return MZ_FALSE; ++ return ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) != 0) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) == file_stat.m_crc32); ++ } ++ ++ // Decompress the file either directly from memory or from a file input buffer. ++ tinfl_init(&inflator); ++ ++ if (pZip->m_pState->m_pMem) ++ { ++ // Read directly from the archive in memory. ++ pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; ++ read_buf_size = read_buf_avail = file_stat.m_comp_size; ++ comp_remaining = 0; ++ } ++ else if (pUser_read_buf) ++ { ++ // Use a user provided read buffer. ++ if (!user_read_buf_size) ++ return MZ_FALSE; ++ pRead_buf = (mz_uint8 *)pUser_read_buf; ++ read_buf_size = user_read_buf_size; ++ read_buf_avail = 0; ++ comp_remaining = file_stat.m_comp_size; ++ } ++ else ++ { ++ // Temporarily allocate a read buffer. ++ read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE); ++#ifdef _MSC_VER ++ if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) ++#else ++ if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF)) ++#endif ++ return MZ_FALSE; ++ if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) ++ return MZ_FALSE; ++ read_buf_avail = 0; ++ comp_remaining = file_stat.m_comp_size; ++ } ++ ++ do ++ { ++ size_t in_buf_size, out_buf_size = (size_t)(file_stat.m_uncomp_size - out_buf_ofs); ++ if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) ++ { ++ read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); ++ if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) ++ { ++ status = TINFL_STATUS_FAILED; ++ break; ++ } ++ cur_file_ofs += read_buf_avail; ++ comp_remaining -= read_buf_avail; ++ read_buf_ofs = 0; ++ } ++ in_buf_size = (size_t)read_buf_avail; ++ status = tinfl_decompress(&inflator, (mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pBuf, (mz_uint8 *)pBuf + out_buf_ofs, &out_buf_size, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF | (comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0)); ++ read_buf_avail -= in_buf_size; ++ read_buf_ofs += in_buf_size; ++ out_buf_ofs += out_buf_size; ++ } while (status == TINFL_STATUS_NEEDS_MORE_INPUT); ++ ++ if (status == TINFL_STATUS_DONE) ++ { ++ // Make sure the entire file was decompressed, and check its CRC. ++ if ((out_buf_ofs != file_stat.m_uncomp_size) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32)) ++ status = TINFL_STATUS_FAILED; ++ } ++ ++ if ((!pZip->m_pState->m_pMem) && (!pUser_read_buf)) ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); ++ ++ return status == TINFL_STATUS_DONE; ++} ++ ++mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size) ++{ ++ int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); ++ if (file_index < 0) ++ return MZ_FALSE; ++ return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size); ++} ++ ++mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags) ++{ ++ return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, NULL, 0); ++} ++ ++mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags) ++{ ++ return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf, buf_size, flags, NULL, 0); ++} ++ ++void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags) ++{ ++ mz_uint64 comp_size, uncomp_size, alloc_size; ++ const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index); ++ void *pBuf; ++ ++ if (pSize) ++ *pSize = 0; ++ if (!p) ++ return NULL; ++ ++ comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); ++ uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS); ++ ++ alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size; ++#ifdef _MSC_VER ++ if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) ++#else ++ if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF)) ++#endif ++ return NULL; ++ if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size))) ++ return NULL; ++ ++ if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size, flags)) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); ++ return NULL; ++ } ++ ++ if (pSize) *pSize = (size_t)alloc_size; ++ return pBuf; ++} ++ ++void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags) ++{ ++ int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); ++ if (file_index < 0) ++ { ++ if (pSize) *pSize = 0; ++ return MZ_FALSE; ++ } ++ return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags); ++} ++ ++mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) ++{ ++ int status = TINFL_STATUS_DONE; mz_uint file_crc32 = MZ_CRC32_INIT; ++ mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs; ++ mz_zip_archive_file_stat file_stat; ++ void *pRead_buf = NULL; void *pWrite_buf = NULL; ++ mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; ++ ++ if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) ++ return MZ_FALSE; ++ ++ // Empty file, or a directory (but not always a directory - I've seen odd zips with directories that have compressed data which inflates to 0 bytes) ++ if (!file_stat.m_comp_size) ++ return MZ_TRUE; ++ ++ // Entry is a subdirectory (I've seen old zips with dir entries which have compressed deflate data which inflates to 0 bytes, but these entries claim to uncompress to 512 bytes in the headers). ++ // I'm torn how to handle this case - should it fail instead? ++ if (mz_zip_reader_is_file_a_directory(pZip, file_index)) ++ return MZ_TRUE; ++ ++ // Encryption and patch files are not supported. ++ if (file_stat.m_bit_flag & (1 | 32)) ++ return MZ_FALSE; ++ ++ // This function only supports stored and deflate. ++ if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED)) ++ return MZ_FALSE; ++ ++ // Read and parse the local directory entry. ++ cur_file_ofs = file_stat.m_local_header_ofs; ++ if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) ++ return MZ_FALSE; ++ if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) ++ return MZ_FALSE; ++ ++ cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); ++ if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size) ++ return MZ_FALSE; ++ ++ // Decompress the file either directly from memory or from a file input buffer. ++ if (pZip->m_pState->m_pMem) ++ { ++ pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs; ++ read_buf_size = read_buf_avail = file_stat.m_comp_size; ++ comp_remaining = 0; ++ } ++ else ++ { ++ read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE); ++ if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size))) ++ return MZ_FALSE; ++ read_buf_avail = 0; ++ comp_remaining = file_stat.m_comp_size; ++ } ++ ++ if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) ++ { ++ // The file is stored or the caller has requested the compressed data. ++ if (pZip->m_pState->m_pMem) ++ { ++#ifdef _MSC_VER ++ if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) ++#else ++ if (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF)) ++#endif ++ return MZ_FALSE; ++ if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)file_stat.m_comp_size) != file_stat.m_comp_size) ++ status = TINFL_STATUS_FAILED; ++ else if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) ++ file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)file_stat.m_comp_size); ++ cur_file_ofs += file_stat.m_comp_size; ++ out_buf_ofs += file_stat.m_comp_size; ++ comp_remaining = 0; ++ } ++ else ++ { ++ while (comp_remaining) ++ { ++ read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); ++ if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) ++ { ++ status = TINFL_STATUS_FAILED; ++ break; ++ } ++ ++ if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) ++ file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)read_buf_avail); ++ ++ if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) ++ { ++ status = TINFL_STATUS_FAILED; ++ break; ++ } ++ cur_file_ofs += read_buf_avail; ++ out_buf_ofs += read_buf_avail; ++ comp_remaining -= read_buf_avail; ++ } ++ } ++ } ++ else ++ { ++ tinfl_decompressor inflator; ++ tinfl_init(&inflator); ++ ++ if (NULL == (pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, TINFL_LZ_DICT_SIZE))) ++ status = TINFL_STATUS_FAILED; ++ else ++ { ++ do ++ { ++ mz_uint8 *pWrite_buf_cur = (mz_uint8 *)pWrite_buf + (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); ++ size_t in_buf_size, out_buf_size = TINFL_LZ_DICT_SIZE - (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1)); ++ if ((!read_buf_avail) && (!pZip->m_pState->m_pMem)) ++ { ++ read_buf_avail = MZ_MIN(read_buf_size, comp_remaining); ++ if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail) ++ { ++ status = TINFL_STATUS_FAILED; ++ break; ++ } ++ cur_file_ofs += read_buf_avail; ++ comp_remaining -= read_buf_avail; ++ read_buf_ofs = 0; ++ } ++ ++ in_buf_size = (size_t)read_buf_avail; ++ status = tinfl_decompress(&inflator, (const mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pWrite_buf, pWrite_buf_cur, &out_buf_size, comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0); ++ read_buf_avail -= in_buf_size; ++ read_buf_ofs += in_buf_size; ++ ++ if (out_buf_size) ++ { ++ if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size) ++ { ++ status = TINFL_STATUS_FAILED; ++ break; ++ } ++ file_crc32 = (mz_uint32)mz_crc32(file_crc32, pWrite_buf_cur, out_buf_size); ++ if ((out_buf_ofs += out_buf_size) > file_stat.m_uncomp_size) ++ { ++ status = TINFL_STATUS_FAILED; ++ break; ++ } ++ } ++ } while ((status == TINFL_STATUS_NEEDS_MORE_INPUT) || (status == TINFL_STATUS_HAS_MORE_OUTPUT)); ++ } ++ } ++ ++ if ((status == TINFL_STATUS_DONE) && (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))) ++ { ++ // Make sure the entire file was decompressed, and check its CRC. ++ if ((out_buf_ofs != file_stat.m_uncomp_size) || (file_crc32 != file_stat.m_crc32)) ++ status = TINFL_STATUS_FAILED; ++ } ++ ++ if (!pZip->m_pState->m_pMem) ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); ++ if (pWrite_buf) ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pWrite_buf); ++ ++ return status == TINFL_STATUS_DONE; ++} ++ ++mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags) ++{ ++ int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); ++ if (file_index < 0) ++ return MZ_FALSE; ++ return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque, flags); ++} ++ ++#ifndef MINIZ_NO_STDIO ++static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const void *pBuf, size_t n) ++{ ++ (void)ofs; return MZ_FWRITE(pBuf, 1, n, (MZ_FILE*)pOpaque); ++} ++ ++mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags) ++{ ++ mz_bool status; ++ mz_zip_archive_file_stat file_stat; ++ MZ_FILE *pFile; ++ if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat)) ++ return MZ_FALSE; ++ pFile = MZ_FOPEN(pDst_filename, "wb"); ++ if (!pFile) ++ return MZ_FALSE; ++ status = mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_file_write_callback, pFile, flags); ++ if (MZ_FCLOSE(pFile) == EOF) ++ return MZ_FALSE; ++#ifndef MINIZ_NO_TIME ++ if (status) ++ mz_zip_set_file_times(pDst_filename, file_stat.m_time, file_stat.m_time); ++#endif ++ return status; ++} ++#endif // #ifndef MINIZ_NO_STDIO ++ ++mz_bool mz_zip_reader_end(mz_zip_archive *pZip) ++{ ++ if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) ++ return MZ_FALSE; ++ ++ if (pZip->m_pState) ++ { ++ mz_zip_internal_state *pState = pZip->m_pState; pZip->m_pState = NULL; ++ mz_zip_array_clear(pZip, &pState->m_central_dir); ++ mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); ++ mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); ++ ++#ifndef MINIZ_NO_STDIO ++ if (pState->m_pFile) ++ { ++ MZ_FCLOSE(pState->m_pFile); ++ pState->m_pFile = NULL; ++ } ++#endif // #ifndef MINIZ_NO_STDIO ++ ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pState); ++ } ++ pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; ++ ++ return MZ_TRUE; ++} ++ ++#ifndef MINIZ_NO_STDIO ++mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags) ++{ ++ int file_index = mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags); ++ if (file_index < 0) ++ return MZ_FALSE; ++ return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags); ++} ++#endif ++ ++// ------------------- .ZIP archive writing ++ ++#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS ++ ++static void mz_write_le16(mz_uint8 *p, mz_uint16 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); } ++static void mz_write_le32(mz_uint8 *p, mz_uint32 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); p[2] = (mz_uint8)(v >> 16); p[3] = (mz_uint8)(v >> 24); } ++#define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v)) ++#define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v)) ++ ++mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size) ++{ ++ if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID)) ++ return MZ_FALSE; ++ ++ if (pZip->m_file_offset_alignment) ++ { ++ // Ensure user specified file offset alignment is a power of 2. ++ if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1)) ++ return MZ_FALSE; ++ } ++ ++ if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func; ++ if (!pZip->m_pFree) pZip->m_pFree = def_free_func; ++ if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func; ++ ++ pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; ++ pZip->m_archive_size = existing_size; ++ pZip->m_central_directory_file_ofs = 0; ++ pZip->m_total_files = 0; ++ ++ if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state)))) ++ return MZ_FALSE; ++ memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state)); ++ MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8)); ++ MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32)); ++ MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32)); ++ return MZ_TRUE; ++} ++ ++static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) ++{ ++ mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; ++ mz_zip_internal_state *pState = pZip->m_pState; ++ mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size); ++#ifdef _MSC_VER ++ if ((!n) || ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) ++#else ++ if ((!n) || ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF))) ++#endif ++ return 0; ++ if (new_size > pState->m_mem_capacity) ++ { ++ void *pNew_block; ++ size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity); while (new_capacity < new_size) new_capacity *= 2; ++ if (NULL == (pNew_block = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity))) ++ return 0; ++ pState->m_pMem = pNew_block; pState->m_mem_capacity = new_capacity; ++ } ++ memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n); ++ pState->m_mem_size = (size_t)new_size; ++ return n; ++} ++ ++mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size) ++{ ++ pZip->m_pWrite = mz_zip_heap_write_func; ++ pZip->m_pIO_opaque = pZip; ++ if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) ++ return MZ_FALSE; ++ if (0 != (initial_allocation_size = MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning))) ++ { ++ if (NULL == (pZip->m_pState->m_pMem = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, initial_allocation_size))) ++ { ++ mz_zip_writer_end(pZip); ++ return MZ_FALSE; ++ } ++ pZip->m_pState->m_mem_capacity = initial_allocation_size; ++ } ++ return MZ_TRUE; ++} ++ ++#ifndef MINIZ_NO_STDIO ++static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n) ++{ ++ mz_zip_archive *pZip = (mz_zip_archive *)pOpaque; ++ mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile); ++ if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET)))) ++ return 0; ++ return MZ_FWRITE(pBuf, 1, n, pZip->m_pState->m_pFile); ++} ++ ++mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning) ++{ ++ MZ_FILE *pFile; ++ pZip->m_pWrite = mz_zip_file_write_func; ++ pZip->m_pIO_opaque = pZip; ++ if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning)) ++ return MZ_FALSE; ++ if (NULL == (pFile = MZ_FOPEN(pFilename, "wb"))) ++ { ++ mz_zip_writer_end(pZip); ++ return MZ_FALSE; ++ } ++ pZip->m_pState->m_pFile = pFile; ++ if (size_to_reserve_at_beginning) ++ { ++ mz_uint64 cur_ofs = 0; char buf[4096]; MZ_CLEAR_OBJ(buf); ++ do ++ { ++ size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning); ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n) ++ { ++ mz_zip_writer_end(pZip); ++ return MZ_FALSE; ++ } ++ cur_ofs += n; size_to_reserve_at_beginning -= n; ++ } while (size_to_reserve_at_beginning); ++ } ++ return MZ_TRUE; ++} ++#endif // #ifndef MINIZ_NO_STDIO ++ ++mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename) ++{ ++ mz_zip_internal_state *pState; ++ if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING)) ++ return MZ_FALSE; ++ // No sense in trying to write to an archive that's already at the support max size ++ if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) ++ return MZ_FALSE; ++ ++ pState = pZip->m_pState; ++ ++ if (pState->m_pFile) ++ { ++#ifdef MINIZ_NO_STDIO ++ pFilename; return MZ_FALSE; ++#else ++ // Archive is being read from stdio - try to reopen as writable. ++ if (pZip->m_pIO_opaque != pZip) ++ return MZ_FALSE; ++ if (!pFilename) ++ return MZ_FALSE; ++ pZip->m_pWrite = mz_zip_file_write_func; ++ if (NULL == (pState->m_pFile = MZ_FREOPEN(pFilename, "r+b", pState->m_pFile))) ++ { ++ // The mz_zip_archive is now in a bogus state because pState->m_pFile is NULL, so just close it. ++ mz_zip_reader_end(pZip); ++ return MZ_FALSE; ++ } ++#endif // #ifdef MINIZ_NO_STDIO ++ } ++ else if (pState->m_pMem) ++ { ++ // Archive lives in a memory block. Assume it's from the heap that we can resize using the realloc callback. ++ if (pZip->m_pIO_opaque != pZip) ++ return MZ_FALSE; ++ pState->m_mem_capacity = pState->m_mem_size; ++ pZip->m_pWrite = mz_zip_heap_write_func; ++ } ++ // Archive is being read via a user provided read function - make sure the user has specified a write function too. ++ else if (!pZip->m_pWrite) ++ return MZ_FALSE; ++ ++ // Start writing new files at the archive's current central directory location. ++ pZip->m_archive_size = pZip->m_central_directory_file_ofs; ++ pZip->m_zip_mode = MZ_ZIP_MODE_WRITING; ++ pZip->m_central_directory_file_ofs = 0; ++ ++ return MZ_TRUE; ++} ++ ++mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags) ++{ ++ return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, level_and_flags, 0, 0); ++} ++ ++typedef struct ++{ ++ mz_zip_archive *m_pZip; ++ mz_uint64 m_cur_archive_file_ofs; ++ mz_uint64 m_comp_size; ++} mz_zip_writer_add_state; ++ ++static mz_bool mz_zip_writer_add_put_buf_callback(const void* pBuf, int len, void *pUser) ++{ ++ mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser; ++ if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque, pState->m_cur_archive_file_ofs, pBuf, len) != len) ++ return MZ_FALSE; ++ pState->m_cur_archive_file_ofs += len; ++ pState->m_comp_size += len; ++ return MZ_TRUE; ++} ++ ++static mz_bool mz_zip_writer_create_local_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date) ++{ ++ (void)pZip; ++ memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE); ++ MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date); ++ MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32); ++ MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, comp_size); ++ MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, uncomp_size); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size); ++ return MZ_TRUE; ++} ++ ++static mz_bool mz_zip_writer_create_central_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) ++{ ++ (void)pZip; ++ memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); ++ MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date); ++ MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32); ++ MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, comp_size); ++ MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, uncomp_size); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size); ++ MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size); ++ MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes); ++ MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_header_ofs); ++ return MZ_TRUE; ++} ++ ++static mz_bool mz_zip_writer_add_to_central_dir(mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size, const void *pExtra, mz_uint16 extra_size, const void *pComment, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes) ++{ ++ mz_zip_internal_state *pState = pZip->m_pState; ++ mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size; ++ size_t orig_central_dir_size = pState->m_central_dir.m_size; ++ mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; ++ ++ // No zip64 support yet ++ if ((local_header_ofs > 0xFFFFFFFF) || (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + comment_size) > 0xFFFFFFFF)) ++ return MZ_FALSE; ++ ++ if (!mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, extra_size, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes)) ++ return MZ_FALSE; ++ ++ if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) || ++ (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) || ++ (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) || ++ (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) || ++ (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, ¢ral_dir_ofs, 1))) ++ { ++ // Try to push the central directory array back into its original state. ++ mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); ++ return MZ_FALSE; ++ } ++ ++ return MZ_TRUE; ++} ++ ++static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name) ++{ ++ // Basic ZIP archive filename validity checks: Valid filenames cannot start with a forward slash, cannot contain a drive letter, and cannot use DOS-style backward slashes. ++ if (*pArchive_name == '/') ++ return MZ_FALSE; ++ while (*pArchive_name) ++ { ++ if ((*pArchive_name == '\\') || (*pArchive_name == ':')) ++ return MZ_FALSE; ++ pArchive_name++; ++ } ++ return MZ_TRUE; ++} ++ ++static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip) ++{ ++ mz_uint32 n; ++ if (!pZip->m_file_offset_alignment) ++ return 0; ++ n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1)); ++ return (pZip->m_file_offset_alignment - n) & (pZip->m_file_offset_alignment - 1); ++} ++ ++static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n) ++{ ++ char buf[4096]; ++ memset(buf, 0, MZ_MIN(sizeof(buf), n)); ++ while (n) ++ { ++ mz_uint32 s = MZ_MIN(sizeof(buf), n); ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s) ++ return MZ_FALSE; ++ cur_file_ofs += s; n -= s; ++ } ++ return MZ_TRUE; ++} ++ ++mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32) ++{ ++ mz_uint16 method = 0, dos_time = 0, dos_date = 0; ++ mz_uint level, ext_attributes = 0, num_alignment_padding_bytes; ++ mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0; ++ size_t archive_name_size; ++ mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; ++ tdefl_compressor *pComp = NULL; ++ mz_bool store_data_uncompressed; ++ mz_zip_internal_state *pState; ++ ++ if ((int)level_and_flags < 0) ++ level_and_flags = MZ_DEFAULT_LEVEL; ++ level = level_and_flags & 0xF; ++ store_data_uncompressed = ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)); ++ ++ if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) || (!pArchive_name) || ((comment_size) && (!pComment)) || (pZip->m_total_files == 0xFFFF) || (level > MZ_UBER_COMPRESSION)) ++ return MZ_FALSE; ++ ++ pState = pZip->m_pState; ++ ++ if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size)) ++ return MZ_FALSE; ++ // No zip64 support yet ++ if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF)) ++ return MZ_FALSE; ++ if (!mz_zip_writer_validate_archive_name(pArchive_name)) ++ return MZ_FALSE; ++ ++#ifndef MINIZ_NO_TIME ++ { ++ time_t cur_time; time(&cur_time); ++ mz_zip_time_to_dos_time(cur_time, &dos_time, &dos_date); ++ } ++#endif // #ifndef MINIZ_NO_TIME ++ ++ archive_name_size = strlen(pArchive_name); ++ if (archive_name_size > 0xFFFF) ++ return MZ_FALSE; ++ ++ num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); ++ ++ // no zip64 support yet ++ if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) ++ return MZ_FALSE; ++ ++ if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/')) ++ { ++ // Set DOS Subdirectory attribute bit. ++ ext_attributes |= 0x10; ++ // Subdirectories cannot contain data. ++ if ((buf_size) || (uncomp_size)) ++ return MZ_FALSE; ++ } ++ ++ // Try to do any allocations before writing to the archive, so if an allocation fails the file remains unmodified. (A good idea if we're doing an in-place modification.) ++ if ((!mz_zip_array_ensure_room(pZip, &pState->m_central_dir, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size)) || (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1))) ++ return MZ_FALSE; ++ ++ if ((!store_data_uncompressed) && (buf_size)) ++ { ++ if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)))) ++ return MZ_FALSE; ++ } ++ ++ if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); ++ return MZ_FALSE; ++ } ++ local_dir_header_ofs += num_alignment_padding_bytes; ++ if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } ++ cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); ++ ++ MZ_CLEAR_OBJ(local_dir_header); ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); ++ return MZ_FALSE; ++ } ++ cur_archive_file_ofs += archive_name_size; ++ ++ if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) ++ { ++ uncomp_crc32 = (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8*)pBuf, buf_size); ++ uncomp_size = buf_size; ++ if (uncomp_size <= 3) ++ { ++ level = 0; ++ store_data_uncompressed = MZ_TRUE; ++ } ++ } ++ ++ if (store_data_uncompressed) ++ { ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf, buf_size) != buf_size) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); ++ return MZ_FALSE; ++ } ++ ++ cur_archive_file_ofs += buf_size; ++ comp_size = buf_size; ++ ++ if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ++ method = MZ_DEFLATED; ++ } ++ else if (buf_size) ++ { ++ mz_zip_writer_add_state state; ++ ++ state.m_pZip = pZip; ++ state.m_cur_archive_file_ofs = cur_archive_file_ofs; ++ state.m_comp_size = 0; ++ ++ if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) || ++ (tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) != TDEFL_STATUS_DONE)) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); ++ return MZ_FALSE; ++ } ++ ++ comp_size = state.m_comp_size; ++ cur_archive_file_ofs = state.m_cur_archive_file_ofs; ++ ++ method = MZ_DEFLATED; ++ } ++ ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); ++ pComp = NULL; ++ ++ // no zip64 support yet ++ if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) ++ return MZ_FALSE; ++ ++ if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) ++ return MZ_FALSE; ++ ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) ++ return MZ_FALSE; ++ ++ if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) ++ return MZ_FALSE; ++ ++ pZip->m_total_files++; ++ pZip->m_archive_size = cur_archive_file_ofs; ++ ++ return MZ_TRUE; ++} ++ ++#ifndef MINIZ_NO_STDIO ++mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) ++{ ++ mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes; ++ mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0; ++ mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0, comp_size = 0; ++ size_t archive_name_size; ++ mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; ++ MZ_FILE *pSrc_file = NULL; ++ ++ if ((int)level_and_flags < 0) ++ level_and_flags = MZ_DEFAULT_LEVEL; ++ level = level_and_flags & 0xF; ++ ++ if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION)) ++ return MZ_FALSE; ++ if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ++ return MZ_FALSE; ++ if (!mz_zip_writer_validate_archive_name(pArchive_name)) ++ return MZ_FALSE; ++ ++ archive_name_size = strlen(pArchive_name); ++ if (archive_name_size > 0xFFFF) ++ return MZ_FALSE; ++ ++ num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); ++ ++ // no zip64 support yet ++ if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) ++ return MZ_FALSE; ++ ++ if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date)) ++ return MZ_FALSE; ++ ++ pSrc_file = MZ_FOPEN(pSrc_filename, "rb"); ++ if (!pSrc_file) ++ return MZ_FALSE; ++ MZ_FSEEK64(pSrc_file, 0, SEEK_END); ++ uncomp_size = MZ_FTELL64(pSrc_file); ++ MZ_FSEEK64(pSrc_file, 0, SEEK_SET); ++ ++ if (uncomp_size > 0xFFFFFFFF) ++ { ++ // No zip64 support yet ++ MZ_FCLOSE(pSrc_file); ++ return MZ_FALSE; ++ } ++ if (uncomp_size <= 3) ++ level = 0; ++ ++ if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) ++ { ++ MZ_FCLOSE(pSrc_file); ++ return MZ_FALSE; ++ } ++ local_dir_header_ofs += num_alignment_padding_bytes; ++ if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } ++ cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); ++ ++ MZ_CLEAR_OBJ(local_dir_header); ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) ++ { ++ MZ_FCLOSE(pSrc_file); ++ return MZ_FALSE; ++ } ++ cur_archive_file_ofs += archive_name_size; ++ ++ if (uncomp_size) ++ { ++ mz_uint64 uncomp_remaining = uncomp_size; ++ void *pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE); ++ if (!pRead_buf) ++ { ++ MZ_FCLOSE(pSrc_file); ++ return MZ_FALSE; ++ } ++ ++ if (!level) ++ { ++ while (uncomp_remaining) ++ { ++ mz_uint n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining); ++ if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n)) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); ++ MZ_FCLOSE(pSrc_file); ++ return MZ_FALSE; ++ } ++ uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n); ++ uncomp_remaining -= n; ++ cur_archive_file_ofs += n; ++ } ++ comp_size = uncomp_size; ++ } ++ else ++ { ++ mz_bool result = MZ_FALSE; ++ mz_zip_writer_add_state state; ++ tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)); ++ if (!pComp) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); ++ MZ_FCLOSE(pSrc_file); ++ return MZ_FALSE; ++ } ++ ++ state.m_pZip = pZip; ++ state.m_cur_archive_file_ofs = cur_archive_file_ofs; ++ state.m_comp_size = 0; ++ ++ if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); ++ MZ_FCLOSE(pSrc_file); ++ return MZ_FALSE; ++ } ++ ++ for ( ; ; ) ++ { ++ size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, MZ_ZIP_MAX_IO_BUF_SIZE); ++ tdefl_status status; ++ ++ if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size) ++ break; ++ ++ uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size); ++ uncomp_remaining -= in_buf_size; ++ ++ status = tdefl_compress_buffer(pComp, pRead_buf, in_buf_size, uncomp_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH); ++ if (status == TDEFL_STATUS_DONE) ++ { ++ result = MZ_TRUE; ++ break; ++ } ++ else if (status != TDEFL_STATUS_OKAY) ++ break; ++ } ++ ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); ++ ++ if (!result) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); ++ MZ_FCLOSE(pSrc_file); ++ return MZ_FALSE; ++ } ++ ++ comp_size = state.m_comp_size; ++ cur_archive_file_ofs = state.m_cur_archive_file_ofs; ++ ++ method = MZ_DEFLATED; ++ } ++ ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); ++ } ++ ++ MZ_FCLOSE(pSrc_file); pSrc_file = NULL; ++ ++ // no zip64 support yet ++ if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) ++ return MZ_FALSE; ++ ++ if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) ++ return MZ_FALSE; ++ ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) ++ return MZ_FALSE; ++ ++ if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) ++ return MZ_FALSE; ++ ++ pZip->m_total_files++; ++ pZip->m_archive_size = cur_archive_file_ofs; ++ ++ return MZ_TRUE; ++} ++#endif // #ifndef MINIZ_NO_STDIO ++ ++mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index) ++{ ++ mz_uint n, bit_flags, num_alignment_padding_bytes; ++ mz_uint64 comp_bytes_remaining, local_dir_header_ofs; ++ mz_uint64 cur_src_file_ofs, cur_dst_file_ofs; ++ mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32; ++ mz_uint8 central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE]; ++ size_t orig_central_dir_size; ++ mz_zip_internal_state *pState; ++ void *pBuf; const mz_uint8 *pSrc_central_header; ++ ++ if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) ++ return MZ_FALSE; ++ if (NULL == (pSrc_central_header = mz_zip_reader_get_cdh(pSource_zip, file_index))) ++ return MZ_FALSE; ++ pState = pZip->m_pState; ++ ++ num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); ++ ++ // no zip64 support yet ++ if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) ++ return MZ_FALSE; ++ ++ cur_src_file_ofs = MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS); ++ cur_dst_file_ofs = pZip->m_archive_size; ++ ++ if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) ++ return MZ_FALSE; ++ if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG) ++ return MZ_FALSE; ++ cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; ++ ++ if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, num_alignment_padding_bytes)) ++ return MZ_FALSE; ++ cur_dst_file_ofs += num_alignment_padding_bytes; ++ local_dir_header_ofs = cur_dst_file_ofs; ++ if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } ++ ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE) ++ return MZ_FALSE; ++ cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE; ++ ++ n = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS); ++ comp_bytes_remaining = n + MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS); ++ ++ if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(sizeof(mz_uint32) * 4, MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining))))) ++ return MZ_FALSE; ++ ++ while (comp_bytes_remaining) ++ { ++ n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining); ++ if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); ++ return MZ_FALSE; ++ } ++ cur_src_file_ofs += n; ++ ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); ++ return MZ_FALSE; ++ } ++ cur_dst_file_ofs += n; ++ ++ comp_bytes_remaining -= n; ++ } ++ ++ bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS); ++ if (bit_flags & 8) ++ { ++ // Copy data descriptor ++ if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); ++ return MZ_FALSE; ++ } ++ ++ n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == 0x08074b50) ? 4 : 3); ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); ++ return MZ_FALSE; ++ } ++ ++ cur_src_file_ofs += n; ++ cur_dst_file_ofs += n; ++ } ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf); ++ ++ // no zip64 support yet ++ if (cur_dst_file_ofs > 0xFFFFFFFF) ++ return MZ_FALSE; ++ ++ orig_central_dir_size = pState->m_central_dir.m_size; ++ ++ memcpy(central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE); ++ MZ_WRITE_LE32(central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_dir_header_ofs); ++ if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) ++ return MZ_FALSE; ++ ++ n = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS); ++ if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n)) ++ { ++ mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); ++ return MZ_FALSE; ++ } ++ ++ if (pState->m_central_dir.m_size > 0xFFFFFFFF) ++ return MZ_FALSE; ++ n = (mz_uint32)orig_central_dir_size; ++ if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1)) ++ { ++ mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE); ++ return MZ_FALSE; ++ } ++ ++ pZip->m_total_files++; ++ pZip->m_archive_size = cur_dst_file_ofs; ++ ++ return MZ_TRUE; ++} ++ ++mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip) ++{ ++ mz_zip_internal_state *pState; ++ mz_uint64 central_dir_ofs, central_dir_size; ++ mz_uint8 hdr[MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE]; ++ ++ if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING)) ++ return MZ_FALSE; ++ ++ pState = pZip->m_pState; ++ ++ // no zip64 support yet ++ if ((pZip->m_total_files > 0xFFFF) || ((pZip->m_archive_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)) ++ return MZ_FALSE; ++ ++ central_dir_ofs = 0; ++ central_dir_size = 0; ++ if (pZip->m_total_files) ++ { ++ // Write central directory ++ central_dir_ofs = pZip->m_archive_size; ++ central_dir_size = pState->m_central_dir.m_size; ++ pZip->m_central_directory_file_ofs = central_dir_ofs; ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, central_dir_ofs, pState->m_central_dir.m_p, (size_t)central_dir_size) != central_dir_size) ++ return MZ_FALSE; ++ pZip->m_archive_size += central_dir_size; ++ } ++ ++ // Write end of central directory record ++ MZ_CLEAR_OBJ(hdr); ++ MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG); ++ MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, pZip->m_total_files); ++ MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, pZip->m_total_files); ++ MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_SIZE_OFS, central_dir_size); ++ MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_OFS_OFS, central_dir_ofs); ++ ++ if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, sizeof(hdr)) != sizeof(hdr)) ++ return MZ_FALSE; ++#ifndef MINIZ_NO_STDIO ++ if ((pState->m_pFile) && (MZ_FFLUSH(pState->m_pFile) == EOF)) ++ return MZ_FALSE; ++#endif // #ifndef MINIZ_NO_STDIO ++ ++ pZip->m_archive_size += sizeof(hdr); ++ ++ pZip->m_zip_mode = MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED; ++ return MZ_TRUE; ++} ++ ++mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize) ++{ ++ if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pSize)) ++ return MZ_FALSE; ++ if (pZip->m_pWrite != mz_zip_heap_write_func) ++ return MZ_FALSE; ++ if (!mz_zip_writer_finalize_archive(pZip)) ++ return MZ_FALSE; ++ ++ *pBuf = pZip->m_pState->m_pMem; ++ *pSize = pZip->m_pState->m_mem_size; ++ pZip->m_pState->m_pMem = NULL; ++ pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0; ++ return MZ_TRUE; ++} ++ ++mz_bool mz_zip_writer_end(mz_zip_archive *pZip) ++{ ++ mz_zip_internal_state *pState; ++ mz_bool status = MZ_TRUE; ++ if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) && (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED))) ++ return MZ_FALSE; ++ ++ pState = pZip->m_pState; ++ pZip->m_pState = NULL; ++ mz_zip_array_clear(pZip, &pState->m_central_dir); ++ mz_zip_array_clear(pZip, &pState->m_central_dir_offsets); ++ mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets); ++ ++#ifndef MINIZ_NO_STDIO ++ if (pState->m_pFile) ++ { ++ MZ_FCLOSE(pState->m_pFile); ++ pState->m_pFile = NULL; ++ } ++#endif // #ifndef MINIZ_NO_STDIO ++ ++ if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem)) ++ { ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem); ++ pState->m_pMem = NULL; ++ } ++ ++ pZip->m_pFree(pZip->m_pAlloc_opaque, pState); ++ pZip->m_zip_mode = MZ_ZIP_MODE_INVALID; ++ return status; ++} ++ ++#ifndef MINIZ_NO_STDIO ++mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) ++{ ++ mz_bool status, created_new_archive = MZ_FALSE; ++ mz_zip_archive zip_archive; ++ struct MZ_FILE_STAT_STRUCT file_stat; ++ MZ_CLEAR_OBJ(zip_archive); ++ if ((int)level_and_flags < 0) ++ level_and_flags = MZ_DEFAULT_LEVEL; ++ if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION)) ++ return MZ_FALSE; ++ if (!mz_zip_writer_validate_archive_name(pArchive_name)) ++ return MZ_FALSE; ++ if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0) ++ { ++ // Create a new archive. ++ if (!mz_zip_writer_init_file(&zip_archive, pZip_filename, 0)) ++ return MZ_FALSE; ++ created_new_archive = MZ_TRUE; ++ } ++ else ++ { ++ // Append to an existing archive. ++ if (!mz_zip_reader_init_file(&zip_archive, pZip_filename, level_and_flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) ++ return MZ_FALSE; ++ if (!mz_zip_writer_init_from_reader(&zip_archive, pZip_filename)) ++ { ++ mz_zip_reader_end(&zip_archive); ++ return MZ_FALSE; ++ } ++ } ++ status = mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0); ++ // Always finalize, even if adding failed for some reason, so we have a valid central directory. (This may not always succeed, but we can try.) ++ if (!mz_zip_writer_finalize_archive(&zip_archive)) ++ status = MZ_FALSE; ++ if (!mz_zip_writer_end(&zip_archive)) ++ status = MZ_FALSE; ++ if ((!status) && (created_new_archive)) ++ { ++ // It's a new archive and something went wrong, so just delete it. ++ int ignoredStatus = MZ_DELETE_FILE(pZip_filename); ++ (void)ignoredStatus; ++ } ++ return status; ++} ++ ++void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags) ++{ ++ int file_index; ++ mz_zip_archive zip_archive; ++ void *p = NULL; ++ ++ if (pSize) ++ *pSize = 0; ++ ++ if ((!pZip_filename) || (!pArchive_name)) ++ return NULL; ++ ++ MZ_CLEAR_OBJ(zip_archive); ++ if (!mz_zip_reader_init_file(&zip_archive, pZip_filename, flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY)) ++ return NULL; ++ ++ if ((file_index = mz_zip_reader_locate_file(&zip_archive, pArchive_name, NULL, flags)) >= 0) ++ p = mz_zip_reader_extract_to_heap(&zip_archive, file_index, pSize, flags); ++ ++ mz_zip_reader_end(&zip_archive); ++ return p; ++} ++ ++#endif // #ifndef MINIZ_NO_STDIO ++ ++#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS ++ ++#endif // #ifndef MINIZ_NO_ARCHIVE_APIS ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif // MINIZ_HEADER_FILE_ONLY ++ ++/* ++ This is free and unencumbered software released into the public domain. ++ ++ Anyone is free to copy, modify, publish, use, compile, sell, or ++ distribute this software, either in source code form or as a compiled ++ binary, for any purpose, commercial or non-commercial, and by any ++ means. ++ ++ In jurisdictions that recognize copyright laws, the author or authors ++ of this software dedicate any and all copyright interest in the ++ software to the public domain. We make this dedication for the benefit ++ of the public at large and to the detriment of our heirs and ++ successors. We intend this dedication to be an overt act of ++ relinquishment in perpetuity of all present and future rights to this ++ software under copyright law. ++ ++ 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 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. ++ ++ For more information, please refer to ++*/ diff --cc vendor/num_cpus-1.7.0/.appveyor.yml index 000000000,000000000..e75d59feb new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/.appveyor.yml @@@ -1,0 -1,0 +1,16 @@@ ++environment: ++ matrix: ++ - TARGET: x86_64-pc-windows-msvc ++ - TARGET: i686-pc-windows-msvc ++ - TARGET: x86_64-pc-windows-gnu ++ - TARGET: i686-pc-windows-gnu ++install: ++ - curl -sSf -o rustup-init.exe https://win.rustup.rs/ ++ - rustup-init.exe -y --default-host %TARGET% ++ - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin ++ - rustc -vV ++ - cargo -vV ++build: false ++test_script: ++ - cargo build --verbose ++ - cargo test --verbose diff --cc vendor/num_cpus-1.7.0/.cargo-checksum.json index 000000000,000000000..eb2b8cb4a new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d"} diff --cc vendor/num_cpus-1.7.0/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/.cargo-ok diff --cc vendor/num_cpus-1.7.0/.travis.yml index 000000000,000000000..73783358c new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/.travis.yml @@@ -1,0 -1,0 +1,66 @@@ ++language: rust ++rust: stable ++dist: trusty ++sudo: false ++ ++cache: cargo ++ ++install: ++ - if [ -z "$NO_ADD" ]; then rustup target add "$TARGET"; fi ++ ++script: ++ - cargo build --verbose --target "$TARGET" ++ # Only run the targets if we are on the same OS. ++ - if [ "$RUN" == "1" ]; then cargo test --verbose --target "$TARGET"; fi ++ ++env: ++ global: ++ # Travis CI servers make 2 cores available to processes via virtualization. ++ # See https://docs.travis-ci.com/user/reference/overview/ ++ - NUM_CPUS_TEST_GET=2 ++ ++matrix: ++ include: ++ # Linux ++ # 32-bit requires multilib. ++ - env: TARGET=i686-unknown-linux-gnu RUN=1 ++ addons: ++ apt: ++ packages: ++ - gcc-multilib ++ # 64-bit stable. ++ - env: TARGET=x86_64-unknown-linux-gnu RUN=1 NO_ADD=1 ++ rust: stable ++ # 64-bit beta. ++ - env: TARGET=x86_64-unknown-linux-gnu RUN=1 NO_ADD=1 ++ rust: beta ++ # 64-bit nightly. ++ - env: TARGET=x86_64-unknown-linux-gnu RUN=1 NO_ADD=1 ++ rust: nightly ++ # Mac OS X ++ - os: osx ++ env: TARGET=i686-apple-darwin RUN=1 ++ - os: osx ++ env: TARGET=x86_64-apple-darwin RUN=1 NO_ADD=1 ++ # Android ++ # - for x86 ++ - env: TARGET=i686-linux-android ++ - env: TARGET=x86_64-linux-android ++ # - for ARM ++ - env: TARGET=arm-linux-androideabi ++ - env: TARGET=aarch64-linux-android ++ # IOS ++ - os: osx ++ osx_image: xcode9 ++ env: TARGET=i386-apple-ios ++ - os: osx ++ osx_image: xcode9 ++ env: TARGET=x86_64-apple-ios ++ # FreeBSD ++ - env: TARGET=x86_64-unknown-freebsd ++ # Fuchsia ++ - env: TARGET=x86_64-unknown-fuchsia ++ # NetBSD ++ - env: TARGET=x86_64-unknown-netbsd ++ # Emscripten ++ - env: TARGET=asmjs-unknown-emscripten diff --cc vendor/num_cpus-1.7.0/CHANGELOG.md index 000000000,000000000..71ecf322f new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/CHANGELOG.md @@@ -1,0 -1,0 +1,76 @@@ ++## v1.7.0 ++ ++#### Features ++ ++- add `get_physical` support for macOS ++ ++#### Fixes ++ ++- use `_SC_NPROCESSORS_CONF` on Unix targets ++ ++### v1.6.2 ++ ++#### Fixes ++ ++- revert 1.6.1 for now ++ ++### v1.6.1 ++ ++#### Fixes ++ ++- fixes sometimes incorrect num on Android/ARM Linux (#45) ++ ++## v1.6.0 ++ ++#### Features ++ ++- `get_physical` gains Windows support ++ ++### v1.5.1 ++ ++#### Fixes ++ ++- fix `get` to return 1 if `sysconf(_SC_NPROCESSORS_ONLN)` failed ++ ++## v1.5.0 ++ ++#### Features ++ ++- `get()` now checks `sched_affinity` on Linux ++ ++## v1.4.0 ++ ++#### Features ++ ++- add `haiku` target support ++ ++## v1.3.0 ++ ++#### Features ++ ++- add `redox` target support ++ ++### v1.2.1 ++ ++#### Fixes ++ ++- fixes `get_physical` count (454ff1b) ++ ++## v1.2.0 ++ ++#### Features ++ ++- add `emscripten` target support ++- add `fuchsia` target support ++ ++## v1.1.0 ++ ++#### Features ++ ++- added `get_physical` function to return number of physical CPUs found ++ ++# v1.0.0 ++ ++#### Features ++ ++- `get` function returns number of CPUs (physical and virtual) of current platform diff --cc vendor/num_cpus-1.7.0/CONTRIBUTING.md index 000000000,000000000..5685b08c6 new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/CONTRIBUTING.md @@@ -1,0 -1,0 +1,16 @@@ ++# Contributing ++ ++## 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 --cc vendor/num_cpus-1.7.0/Cargo.toml index 000000000,000000000..0ed212363 new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/Cargo.toml @@@ -1,0 -1,0 +1,25 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "num_cpus" ++version = "1.7.0" ++authors = ["Sean McArthur "] ++description = "Get the number of CPUs on a machine." ++documentation = "https://docs.rs/num_cpus" ++readme = "README.md" ++keywords = ["cpu", "cpus", "cores"] ++categories = ["hardware-support"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/seanmonstar/num_cpus" ++[dependencies.libc] ++version = "0.2.26" diff --cc vendor/num_cpus-1.7.0/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/num_cpus-1.7.0/LICENSE-MIT index 000000000,000000000..8e91dc998 new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/LICENSE-MIT @@@ -1,0 -1,0 +1,20 @@@ ++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 --cc vendor/num_cpus-1.7.0/README.md index 000000000,000000000..a0bbe97c1 new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/README.md @@@ -1,0 -1,0 +1,28 @@@ ++# num_cpus ++ ++[![crates.io](http://meritbadge.herokuapp.com/num_cpus)](https://crates.io/crates/num_cpus) ++[![Travis CI Status](https://travis-ci.org/seanmonstar/num_cpus.svg?branch=master)](https://travis-ci.org/seanmonstar/num_cpus) ++[![AppVeyor status](https://ci.appveyor.com/api/projects/status/qn8t6grhko5jwno6?svg=true)](https://ci.appveyor.com/project/seanmonstar/num-cpus) ++ ++- [Documentation](https://docs.rs/num_cpus) ++- [CHANGELOG](CHANGELOG.md) ++ ++Count the number of CPUs on the current machine. ++ ++## Usage ++ ++Add to Cargo.toml: ++ ++```toml ++[dependencies] ++num_cpus = "1.0" ++``` ++ ++In your `main.rs` or `lib.rs`: ++ ++```rust ++extern crate num_cpus; ++ ++// count logical cores this process could try to use ++let num = num_cpus::get(); ++``` diff --cc vendor/num_cpus-1.7.0/src/lib.rs index 000000000,000000000..0ec505887 new file mode 100644 --- /dev/null +++ b/vendor/num_cpus-1.7.0/src/lib.rs @@@ -1,0 -1,0 +1,349 @@@ ++//! # num_cpus ++//! ++//! A crate with utilities to determine the number of CPUs available on the ++//! current system. ++//! ++//! ## Example ++//! ++//! ``` ++//! let cpus = num_cpus::get(); ++//! ``` ++#![cfg_attr(test, deny(warnings))] ++#![deny(missing_docs)] ++#![doc(html_root_url = "https://docs.rs/num_cpus/1.7.0")] ++#![allow(non_snake_case)] ++ ++#[cfg(not(windows))] ++extern crate libc; ++ ++ ++/// Returns the number of available CPUs of the current system. ++/// ++/// # Note ++/// ++/// This will check sched affinity on Linux. ++#[inline] ++pub fn get() -> usize { ++ get_num_cpus() ++} ++ ++/// Returns the number of physical cores of the current system. ++/// ++/// If not possible on the particular architecture, returns same as `get()` ++/// which is the logical CPUs. ++#[inline] ++pub fn get_physical() -> usize { ++ get_num_physical_cpus() ++} ++ ++ ++#[cfg(not(any(target_os = "linux", target_os = "windows", target_os="macos")))] ++#[inline] ++fn get_num_physical_cpus() -> usize { ++ // Not implemented, fallback ++ get_num_cpus() ++} ++ ++#[cfg(target_os = "windows")] ++fn get_num_physical_cpus() -> usize { ++ match get_num_physical_cpus_windows() { ++ Some(num) => num, ++ None => get_num_cpus() ++ } ++} ++ ++#[cfg(target_os = "windows")] ++fn get_num_physical_cpus_windows() -> Option { ++ // Inspired by https://msdn.microsoft.com/en-us/library/ms683194 ++ ++ use std::ptr; ++ use std::mem; ++ ++ #[allow(non_upper_case_globals)] ++ const RelationProcessorCore: u32 = 0; ++ ++ #[repr(C)] ++ #[allow(non_camel_case_types)] ++ struct SYSTEM_LOGICAL_PROCESSOR_INFORMATION { ++ mask: usize, ++ relationship: u32, ++ _unused: [u64; 2] ++ } ++ ++ extern "system" { ++ fn GetLogicalProcessorInformation( ++ info: *mut SYSTEM_LOGICAL_PROCESSOR_INFORMATION, ++ length: &mut u32 ++ ) -> u32; ++ } ++ ++ // First we need to determine how much space to reserve. ++ ++ // The required size of the buffer, in bytes. ++ let mut needed_size = 0; ++ ++ unsafe { ++ GetLogicalProcessorInformation(ptr::null_mut(), &mut needed_size); ++ } ++ ++ let struct_size = mem::size_of::() as u32; ++ ++ // Could be 0, or some other bogus size. ++ if needed_size == 0 || needed_size < struct_size || needed_size % struct_size != 0 { ++ return None; ++ } ++ ++ let count = needed_size / struct_size; ++ ++ // Allocate some memory where we will store the processor info. ++ let mut buf = Vec::with_capacity(count as usize); ++ ++ let result; ++ ++ unsafe { ++ result = GetLogicalProcessorInformation(buf.as_mut_ptr(), &mut needed_size); ++ } ++ ++ // Failed for any reason. ++ if result == 0 { ++ return None; ++ } ++ ++ let count = needed_size / struct_size; ++ ++ unsafe { ++ buf.set_len(count as usize); ++ } ++ ++ let phys_proc_count = buf.iter() ++ // Only interested in processor packages (physical processors.) ++ .filter(|proc_info| proc_info.relationship == RelationProcessorCore) ++ .count(); ++ ++ if phys_proc_count == 0 { ++ None ++ } else { ++ Some(phys_proc_count) ++ } ++} ++ ++#[cfg(target_os = "linux")] ++fn get_num_physical_cpus() -> usize { ++ use std::io::BufReader; ++ use std::io::BufRead; ++ use std::fs::File; ++ use std::collections::HashSet; ++ ++ let file = match File::open("/proc/cpuinfo") { ++ Ok(val) => val, ++ Err(_) => {return get_num_cpus()}, ++ }; ++ let reader = BufReader::new(file); ++ let mut set = HashSet::new(); ++ let mut coreid: u32 = 0; ++ let mut physid: u32 = 0; ++ let mut chgcount = 0; ++ for line in reader.lines().filter_map(|result| result.ok()) { ++ let parts: Vec<&str> = line.split(':').map(|s| s.trim()).collect(); ++ if parts.len() != 2 { ++ continue ++ } ++ if parts[0] == "core id" || parts[0] == "physical id" { ++ let value = match parts[1].trim().parse() { ++ Ok(val) => val, ++ Err(_) => break, ++ }; ++ match parts[0] { ++ "core id" => coreid = value, ++ "physical id" => physid = value, ++ _ => {}, ++ } ++ chgcount += 1; ++ } ++ if chgcount == 2 { ++ set.insert((physid, coreid)); ++ chgcount = 0; ++ } ++ } ++ let count = set.len(); ++ if count == 0 { get_num_cpus() } else { count } ++} ++ ++#[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(target_os = "macos")] ++fn get_num_physical_cpus() -> usize { ++ use std::ffi::CStr; ++ use std::ptr; ++ ++ let mut cpus: i32 = 0; ++ let mut cpus_size = std::mem::size_of_val(&cpus); ++ ++ let sysctl_name = CStr::from_bytes_with_nul(b"hw.physicalcpu\0") ++ .expect("byte literal is missing NUL"); ++ ++ unsafe { ++ if 0 != libc::sysctlbyname(sysctl_name.as_ptr(), ++ &mut cpus as *mut _ as *mut _, ++ &mut cpus_size as *mut _ as *mut _, ++ ptr::null_mut(), ++ 0) { ++ return get_num_cpus(); ++ } ++ } ++ cpus as usize ++} ++ ++#[cfg(target_os = "linux")] ++fn get_num_cpus() -> usize { ++ let mut set: libc::cpu_set_t = unsafe { std::mem::zeroed() }; ++ if unsafe { libc::sched_getaffinity(0, std::mem::size_of::(), &mut set) } == 0 { ++ let mut count: u32 = 0; ++ for i in 0..libc::CPU_SETSIZE as usize { ++ if unsafe { libc::CPU_ISSET(i, &set) } { ++ count += 1 ++ } ++ } ++ count as usize ++ } else { ++ let cpus = unsafe { libc::sysconf(libc::_SC_NPROCESSORS_ONLN) }; ++ if cpus < 1 { ++ 1 ++ } else { ++ cpus as usize ++ } ++ } ++} ++ ++#[cfg(any( ++ target_os = "nacl", ++ target_os = "macos", ++ target_os = "ios", ++ target_os = "android", ++ target_os = "solaris", ++ target_os = "fuchsia") ++)] ++fn get_num_cpus() -> usize { ++ // On ARM targets, processors could be turned off to save power. ++ // Use `_SC_NPROCESSORS_CONF` to get the real number. ++ #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] ++ const CONF_NAME: libc::c_int = libc::_SC_NPROCESSORS_CONF; ++ #[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))] ++ const CONF_NAME: libc::c_int = libc::_SC_NPROCESSORS_ONLN; ++ ++ let cpus = unsafe { libc::sysconf(CONF_NAME) }; ++ if cpus < 1 { ++ 1 ++ } else { ++ cpus as usize ++ } ++} ++ ++#[cfg(any(target_os = "emscripten", target_os = "redox", target_os = "haiku"))] ++fn get_num_cpus() -> usize { ++ 1 ++} ++ ++#[cfg(test)] ++mod tests { ++ fn env_var(name: &'static str) -> Option { ++ ::std::env::var(name).ok().map(|val| val.parse().unwrap()) ++ } ++ ++ #[test] ++ fn test_get() { ++ let num = super::get(); ++ if let Some(n) = env_var("NUM_CPUS_TEST_GET") { ++ assert_eq!(num, n); ++ } else { ++ assert!(num > 0); ++ assert!(num < 236_451); ++ } ++ } ++ ++ #[test] ++ fn test_get_physical() { ++ let num = super::get_physical(); ++ if let Some(n) = env_var("NUM_CPUS_TEST_GET_PHYSICAL") { ++ assert_eq!(num, n); ++ } else { ++ assert!(num > 0); ++ assert!(num < 236_451); ++ } ++ } ++} diff --cc vendor/openssl-0.9.19/.cargo-checksum.json index 000000000,000000000..b4a75a34e new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"816914b22eb15671d62c73442a51978f311e911d6a6f6cbdafa6abce1b5038fc"} diff --cc vendor/openssl-0.9.19/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/.cargo-ok diff --cc vendor/openssl-0.9.19/Cargo.toml index 000000000,000000000..3b3ae477f new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/Cargo.toml @@@ -1,0 -1,0 +1,59 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "openssl" ++version = "0.9.19" ++authors = ["Steven Fackler "] ++build = "build.rs" ++description = "OpenSSL bindings" ++documentation = "https://docs.rs/openssl/0.9/openssl" ++readme = "README.md" ++keywords = ["crypto", "tls", "ssl", "dtls"] ++categories = ["cryptography", "api-bindings"] ++license = "Apache-2.0" ++repository = "https://github.com/sfackler/rust-openssl" ++[package.metadata.docs.rs] ++all-features = true ++[dependencies.openssl-sys] ++version = "0.9.19" ++ ++[dependencies.foreign-types] ++version = "0.2" ++ ++[dependencies.libc] ++version = "0.2" ++ ++[dependencies.bitflags] ++version = "0.9" ++ ++[dependencies.lazy_static] ++version = "0.2" ++[dev-dependencies.tempdir] ++version = "0.3" ++ ++[dev-dependencies.hex] ++version = "0.2" ++ ++[dev-dependencies.data-encoding] ++version = "1.2" ++ ++[dev-dependencies.ws2_32-sys] ++version = "0.2" ++ ++[dev-dependencies.winapi] ++version = "0.2" ++ ++[features] ++v101 = [] ++v110 = [] ++v102 = [] diff --cc vendor/openssl-0.9.19/LICENSE index 000000000,000000000..808903ae0 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/LICENSE @@@ -1,0 -1,0 +1,15 @@@ ++Copyright 2011 Google Inc. ++ 2013 Jack Lloyd ++ 2013-2014 Steven Fackler ++ ++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 --cc vendor/openssl-0.9.19/README.md index 000000000,000000000..c505efd3d new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/README.md @@@ -1,0 -1,0 +1,173 @@@ ++# rust-openssl ++ ++[![CircleCI](https://circleci.com/gh/sfackler/rust-openssl.svg?style=shield)](https://circleci.com/gh/sfackler/rust-openssl) [![Build Status](https://travis-ci.org/sfackler/rust-openssl.svg?branch=master)](https://travis-ci.org/sfackler/rust-openssl) [![Build status](https://ci.appveyor.com/api/projects/status/d1knobws948pyynk/branch/master?svg=true)](https://ci.appveyor.com/project/sfackler/rust-openssl/branch/master) ++ ++[Documentation](https://docs.rs/openssl). ++ ++## Warning ++ ++This README does not correspond to rust-openssl 0.7.x or 0.8.x. See ++[here](https://github.com/sfackler/rust-openssl/blob/b8fb29db5c246175a096260eacca38180cd77dd0/README.md) ++for that README. ++ ++## Building ++ ++rust-openssl depends on OpenSSL version 1.0.1 or above, or LibreSSL. Both the ++libraries and headers need to be present in the build environment before this ++crate is compiled, and some instructions of how to do this are in the sections ++below. ++ ++### Linux ++ ++On Linux, you can typically install OpenSSL via your package manager. The ++headers are sometimes provided in a separate package than the runtime libraries ++- look for something like `openssl-devel` or `libssl-dev`. You will also need the ++regular development utilities, like `pkg-config`, as the custom build script relies ++on them. ++ ++```bash ++# On Debian and Ubuntu ++sudo apt-get install pkg-config libssl-dev ++# On Arch Linux ++sudo pacman -S openssl ++# On Fedora ++sudo dnf install openssl-devel ++``` ++ ++If installation via a package manager is not possible, or if you're cross ++compiling to a separate target, you'll typically need to compile OpenSSL from ++source. That can normally be done with: ++ ++``` ++curl -O https://www.openssl.org/source/openssl-1.1.0f.tar.gz ++tar xf openssl-1.1.0f.tar.gz ++cd openssl-1.1.0f ++export CC=... ++./Configure --prefix=... linux-x86_64 -fPIC ++make -j$(nproc) ++make install ++``` ++ ++### OSX ++ ++Although OpenSSL 0.9.8 is preinstalled on OSX this library is being phased out ++of OSX and this crate also does not support that version of OpenSSL. To use this ++crate on OSX you'll need to install OpenSSL via some alternate means, typically ++Homebrew: ++ ++```bash ++brew install openssl ++``` ++ ++Occasionally an update of XCode or MacOS will cause the linker to fail after compilation, to rectify this you may want to try and run: ++ ++```bash ++xcode-select --install ++``` ++ ++If Homebrew is installed to the default location of `/usr/local`, OpenSSL will be ++automatically detected. ++ ++### Windows MSVC ++ ++On MSVC it's unfortunately not always a trivial process acquiring OpenSSL. A couple of possibilities ++are downloading precompiled binaries for OpenSSL 1.1.0, or installing OpenSSL 1.0.2 using vcpkg. ++ ++#### Installing OpenSSL 1.1.0 using precompiled binaries ++ ++Perhaps the easiest way to do this right now is to download [precompiled ++binaries] and install them on your system. Currently it's recommended to ++install the 1.1.0 (non-light) installation if you're choosing this route. ++ ++[precompiled binaries]: http://slproweb.com/products/Win32OpenSSL.html ++ ++Once a precompiled binary is installed you can configure this crate to find the ++installation via an environment variable: ++ ++``` ++set OPENSSL_DIR=C:\OpenSSL-Win64 ++``` ++ ++Now you will need to [install root certificates.](#acquiring-root-certificates) ++ ++#### Installing OpenSSL 1.0.2 using vcpkg ++ ++Install [vcpkg](https://github.com/Microsoft/vcpkg), and install the OpenSSL port like this: ++ ++```Batchfile ++vcpkg install openssl:x64-windows ++set VCPKG_ROOT=c:\path\to\vcpkg\installation ++cargo build ++``` ++ ++For more information see the vcpkg build helper [documentation](http://docs.rs/vcpkg). ++To finsh setting up OpenSSL you will need to [install root certificates.](#acquiring-root-certificates) ++ ++#### Acquiring Root Certificates ++ ++Neither of the above OpenSSL distributions ship with any root certificates. ++So to make requests to servers on the internet, you have to install them ++manually. Download the [cacert.pem file from here], copy it somewhere safe ++(`C:\OpenSSL-Win64\certs` is a good place) and point the `SSL_CERT_FILE` ++environment variable there: ++ ++``` ++set SSL_CERT_FILE=C:\OpenSSL-Win64\certs\cacert.pem ++``` ++ ++[cacert.pem file from here]: https://curl.haxx.se/docs/caextract.html ++ ++After that, you're just a `cargo build` away! ++ ++### Windows GNU (MinGW) ++ ++The easiest way to acquire OpenSSL when working with MinGW is to ensure you're ++using [MSYS2](http://msys2.github.io) and to then execute: ++ ++``` ++# 32-bit ++pacman -S mingw-w64-i686-openssl ++ ++# 64-bit ++pacman -S mingw-w64-x86_64-openssl ++``` ++ ++And after that, a `cargo build` should be all you need! ++ ++### Manual configuration ++ ++rust-openssl's build script will by default attempt to locate OpenSSL via ++pkg-config or other system-specific mechanisms. This will not work in some ++situations however, for example cross compiling or when using a copy of OpenSSL ++other than the normal system install. ++ ++The build script can be configured via environment variables: ++ ++* `OPENSSL_DIR` - If specified, a directory that will be used to find ++ OpenSSL installation. It's expected that under this directory the `include` ++ folder has header files and a `lib` folder has the runtime libraries. ++* `OPENSSL_LIB_DIR` - If specified, a directory that will be used to find ++ OpenSSL libraries. Overrides the `lib` folder implied by `OPENSSL_DIR` ++ (if specified). ++* `OPENSSL_INCLUDE_DIR` - If specified, a directory that will be used to find ++ OpenSSL header files. Overrides the `include` folder implied by `OPENSSL_DIR` ++ (if specified). ++* `OPENSSL_STATIC` - If specified, OpenSSL libraries will be statically rather ++ than dynamically linked. ++* `OPENSSL_LIBS` - If specified, the names of the OpenSSL libraries that will be ++ linked, e.g. `ssl:crypto`. ++ ++If `OPENSSL_DIR` or `OPENSSL_LIB_DIR` and `OPENSSL_INCLUDE_DIR` is specified, ++then the build script will skip the pkg-config step. ++ ++For target-specific configuration, each of these environment variables can be ++prefixed by an upper-cased target, for example, ++`X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR`. This can be useful in cross compilation ++contexts. ++ ++### 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 under the terms of both the Apache License, ++Version 2.0 and the MIT license without any additional terms or conditions. diff --cc vendor/openssl-0.9.19/build.rs index 000000000,000000000..eb8894fd3 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/build.rs @@@ -1,0 -1,0 +1,32 @@@ ++use std::env; ++ ++fn main() { ++ match env::var("DEP_OPENSSL_VERSION") { ++ Ok(ref v) if v == "101" => { ++ println!("cargo:rustc-cfg=ossl101"); ++ println!("cargo:rustc-cfg=ossl10x"); ++ } ++ Ok(ref v) if v == "102" => { ++ println!("cargo:rustc-cfg=ossl102"); ++ println!("cargo:rustc-cfg=ossl10x"); ++ } ++ Ok(ref v) if v == "110" => { ++ println!("cargo:rustc-cfg=ossl110"); ++ } ++ _ => panic!("Unable to detect OpenSSL version"), ++ } ++ ++ if let Ok(_) = env::var("DEP_OPENSSL_LIBRESSL") { ++ println!("cargo:rustc-cfg=libressl"); ++ } ++ ++ if let Ok(v) = env::var("DEP_OPENSSL_LIBRESSL_VERSION") { ++ println!("cargo:rustc-cfg=libressl{}", v); ++ } ++ ++ if let Ok(vars) = env::var("DEP_OPENSSL_CONF") { ++ for var in vars.split(",") { ++ println!("cargo:rustc-cfg=osslconf=\"{}\"", var); ++ } ++ } ++} diff --cc vendor/openssl-0.9.19/src/aes.rs index 000000000,000000000..40546f591 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/aes.rs @@@ -1,0 -1,0 +1,121 @@@ ++//! Low level AES functionality ++//! ++//! The `symm` module should be used in preference to this module in most cases. ++use ffi; ++use std::mem; ++use libc::c_int; ++ ++use symm::Mode; ++ ++#[derive(Debug)] ++pub struct KeyError(()); ++ ++pub struct AesKey(ffi::AES_KEY); ++ ++impl AesKey { ++ /// Prepares a key for encryption. ++ /// ++ /// # Failure ++ /// ++ /// Returns an error if the key is not 128, 192, or 256 bits. ++ pub fn new_encrypt(key: &[u8]) -> Result { ++ unsafe { ++ assert!(key.len() <= c_int::max_value() as usize / 8); ++ ++ let mut aes_key = mem::uninitialized(); ++ let r = ffi::AES_set_encrypt_key( ++ key.as_ptr() as *const _, ++ key.len() as c_int * 8, ++ &mut aes_key, ++ ); ++ if r == 0 { ++ Ok(AesKey(aes_key)) ++ } else { ++ Err(KeyError(())) ++ } ++ } ++ } ++ ++ /// Prepares a key for decryption. ++ /// ++ /// # Failure ++ /// ++ /// Returns an error if the key is not 128, 192, or 256 bits. ++ pub fn new_decrypt(key: &[u8]) -> Result { ++ unsafe { ++ assert!(key.len() <= c_int::max_value() as usize / 8); ++ ++ let mut aes_key = mem::uninitialized(); ++ let r = ffi::AES_set_decrypt_key( ++ key.as_ptr() as *const _, ++ key.len() as c_int * 8, ++ &mut aes_key, ++ ); ++ ++ if r == 0 { ++ Ok(AesKey(aes_key)) ++ } else { ++ Err(KeyError(())) ++ } ++ } ++ } ++} ++ ++/// Performs AES IGE encryption or decryption ++/// ++/// # Panics ++/// ++/// Panics if `in_` is not the same length as `out`, if that length is not a multiple of 16, or if ++/// `iv` is not at least 32 bytes. ++pub fn aes_ige(in_: &[u8], out: &mut [u8], key: &AesKey, iv: &mut [u8], mode: Mode) { ++ unsafe { ++ assert!(in_.len() == out.len()); ++ assert!(in_.len() % ffi::AES_BLOCK_SIZE as usize == 0); ++ assert!(iv.len() >= ffi::AES_BLOCK_SIZE as usize * 2); ++ ++ let mode = match mode { ++ Mode::Encrypt => ffi::AES_ENCRYPT, ++ Mode::Decrypt => ffi::AES_DECRYPT, ++ }; ++ ffi::AES_ige_encrypt( ++ in_.as_ptr() as *const _, ++ out.as_mut_ptr() as *mut _, ++ in_.len(), ++ &key.0, ++ iv.as_mut_ptr() as *mut _, ++ mode, ++ ); ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use hex::FromHex; ++ ++ use symm::Mode; ++ use super::*; ++ ++ // From https://www.mgp25.com/AESIGE/ ++ #[test] ++ fn ige_vector_1() { ++ let raw_key = "000102030405060708090A0B0C0D0E0F"; ++ let raw_iv = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"; ++ let raw_pt = "0000000000000000000000000000000000000000000000000000000000000000"; ++ let raw_ct = "1A8519A6557BE652E9DA8E43DA4EF4453CF456B4CA488AA383C79C98B34797CB"; ++ ++ let key = AesKey::new_encrypt(&Vec::from_hex(raw_key).unwrap()).unwrap(); ++ let mut iv = Vec::from_hex(raw_iv).unwrap(); ++ let pt = Vec::from_hex(raw_pt).unwrap(); ++ let ct = Vec::from_hex(raw_ct).unwrap(); ++ ++ let mut ct_actual = vec![0; ct.len()]; ++ aes_ige(&pt, &mut ct_actual, &key, &mut iv, Mode::Encrypt); ++ assert_eq!(ct_actual, ct); ++ ++ let key = AesKey::new_decrypt(&Vec::from_hex(raw_key).unwrap()).unwrap(); ++ let mut iv = Vec::from_hex(raw_iv).unwrap(); ++ let mut pt_actual = vec![0; pt.len()]; ++ aes_ige(&ct, &mut pt_actual, &key, &mut iv, Mode::Decrypt); ++ assert_eq!(pt_actual, pt); ++ } ++} diff --cc vendor/openssl-0.9.19/src/asn1.rs index 000000000,000000000..a50ec32f2 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/asn1.rs @@@ -1,0 -1,0 +1,174 @@@ ++use ffi; ++use foreign_types::{ForeignType, ForeignTypeRef}; ++use libc::{c_long, c_char, c_int}; ++use std::fmt; ++use std::ptr; ++use std::slice; ++use std::str; ++ ++use {cvt, cvt_p}; ++use bio::MemBio; ++use error::ErrorStack; ++use nid::Nid; ++use string::OpensslString; ++ ++foreign_type! { ++ type CType = ffi::ASN1_GENERALIZEDTIME; ++ fn drop = ffi::ASN1_GENERALIZEDTIME_free; ++ ++ pub struct Asn1GeneralizedTime; ++ pub struct Asn1GeneralizedTimeRef; ++} ++ ++impl fmt::Display for Asn1GeneralizedTimeRef { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ unsafe { ++ let mem_bio = try!(MemBio::new()); ++ try!(cvt(ffi::ASN1_GENERALIZEDTIME_print( ++ mem_bio.as_ptr(), ++ self.as_ptr(), ++ ))); ++ write!(f, "{}", str::from_utf8_unchecked(mem_bio.get_buf())) ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::ASN1_TIME; ++ fn drop = ffi::ASN1_TIME_free; ++ ++ pub struct Asn1Time; ++ pub struct Asn1TimeRef; ++} ++ ++impl fmt::Display for Asn1TimeRef { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ unsafe { ++ let mem_bio = try!(MemBio::new()); ++ try!(cvt(ffi::ASN1_TIME_print(mem_bio.as_ptr(), self.as_ptr()))); ++ write!(f, "{}", str::from_utf8_unchecked(mem_bio.get_buf())) ++ } ++ } ++} ++ ++impl Asn1Time { ++ fn from_period(period: c_long) -> Result { ++ ffi::init(); ++ ++ unsafe { ++ let handle = try!(cvt_p(ffi::X509_gmtime_adj(ptr::null_mut(), period))); ++ Ok(Asn1Time::from_ptr(handle)) ++ } ++ } ++ ++ /// Creates a new time on specified interval in days from now ++ pub fn days_from_now(days: u32) -> Result { ++ Asn1Time::from_period(days as c_long * 60 * 60 * 24) ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::ASN1_STRING; ++ fn drop = ffi::ASN1_STRING_free; ++ ++ pub struct Asn1String; ++ pub struct Asn1StringRef; ++} ++ ++impl Asn1StringRef { ++ pub fn as_utf8(&self) -> Result { ++ unsafe { ++ let mut ptr = ptr::null_mut(); ++ let len = ffi::ASN1_STRING_to_UTF8(&mut ptr, self.as_ptr()); ++ if len < 0 { ++ return Err(ErrorStack::get()); ++ } ++ ++ Ok(OpensslString::from_ptr(ptr as *mut c_char)) ++ } ++ } ++ ++ pub fn as_slice(&self) -> &[u8] { ++ unsafe { slice::from_raw_parts(ASN1_STRING_data(self.as_ptr()), self.len()) } ++ } ++ ++ pub fn len(&self) -> usize { ++ unsafe { ffi::ASN1_STRING_length(self.as_ptr()) as usize } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::ASN1_INTEGER; ++ fn drop = ffi::ASN1_INTEGER_free; ++ ++ pub struct Asn1Integer; ++ pub struct Asn1IntegerRef; ++} ++ ++impl Asn1IntegerRef { ++ pub fn get(&self) -> i64 { ++ unsafe { ::ffi::ASN1_INTEGER_get(self.as_ptr()) as i64 } ++ } ++ ++ pub fn set(&mut self, value: i32) -> Result<(), ErrorStack> { ++ unsafe { cvt(::ffi::ASN1_INTEGER_set(self.as_ptr(), value as c_long)).map(|_| ()) } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::ASN1_BIT_STRING; ++ fn drop = ffi::ASN1_BIT_STRING_free; ++ ++ pub struct Asn1BitString; ++ pub struct Asn1BitStringRef; ++} ++ ++impl Asn1BitStringRef { ++ pub fn as_slice(&self) -> &[u8] { ++ unsafe { slice::from_raw_parts(ASN1_STRING_data(self.as_ptr() as *mut _), self.len()) } ++ } ++ ++ pub fn len(&self) -> usize { ++ unsafe { ffi::ASN1_STRING_length(self.as_ptr() as *mut _) as usize } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::ASN1_OBJECT; ++ fn drop = ffi::ASN1_OBJECT_free; ++ ++ pub struct Asn1Object; ++ pub struct Asn1ObjectRef; ++} ++ ++impl Asn1ObjectRef { ++ /// Returns the NID associated with this OID. ++ pub fn nid(&self) -> Nid { ++ unsafe { Nid::from_raw(ffi::OBJ_obj2nid(self.as_ptr())) } ++ } ++} ++ ++impl fmt::Display for Asn1ObjectRef { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ unsafe { ++ let mut buf = [0; 80]; ++ let len = ffi::OBJ_obj2txt( ++ buf.as_mut_ptr() as *mut _, ++ buf.len() as c_int, ++ self.as_ptr(), ++ 0, ++ ); ++ let s = try!(str::from_utf8(&buf[..len as usize]).map_err(|_| fmt::Error)); ++ fmt.write_str(s) ++ } ++ } ++} ++ ++#[cfg(any(ossl101, ossl102))] ++use ffi::ASN1_STRING_data; ++ ++#[cfg(ossl110)] ++#[allow(bad_style)] ++unsafe fn ASN1_STRING_data(s: *mut ffi::ASN1_STRING) -> *mut ::libc::c_uchar { ++ ffi::ASN1_STRING_get0_data(s) as *mut _ ++} diff --cc vendor/openssl-0.9.19/src/bio.rs index 000000000,000000000..ab00fe423 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/bio.rs @@@ -1,0 -1,0 +1,78 @@@ ++use std::marker::PhantomData; ++use std::ptr; ++use std::slice; ++use libc::c_int; ++use ffi; ++ ++use cvt_p; ++use error::ErrorStack; ++ ++pub struct MemBioSlice<'a>(*mut ffi::BIO, PhantomData<&'a [u8]>); ++ ++impl<'a> Drop for MemBioSlice<'a> { ++ fn drop(&mut self) { ++ unsafe { ++ ffi::BIO_free_all(self.0); ++ } ++ } ++} ++ ++impl<'a> MemBioSlice<'a> { ++ pub fn new(buf: &'a [u8]) -> Result, ErrorStack> { ++ ffi::init(); ++ ++ assert!(buf.len() <= c_int::max_value() as usize); ++ let bio = unsafe { ++ try!(cvt_p(BIO_new_mem_buf( ++ buf.as_ptr() as *const _, ++ buf.len() as c_int, ++ ))) ++ }; ++ ++ Ok(MemBioSlice(bio, PhantomData)) ++ } ++ ++ pub fn as_ptr(&self) -> *mut ffi::BIO { ++ self.0 ++ } ++} ++ ++pub struct MemBio(*mut ffi::BIO); ++ ++impl Drop for MemBio { ++ fn drop(&mut self) { ++ unsafe { ++ ffi::BIO_free_all(self.0); ++ } ++ } ++} ++ ++impl MemBio { ++ pub fn new() -> Result { ++ ffi::init(); ++ ++ let bio = unsafe { try!(cvt_p(ffi::BIO_new(ffi::BIO_s_mem()))) }; ++ Ok(MemBio(bio)) ++ } ++ ++ pub fn as_ptr(&self) -> *mut ffi::BIO { ++ self.0 ++ } ++ ++ pub fn get_buf(&self) -> &[u8] { ++ unsafe { ++ let mut ptr = ptr::null_mut(); ++ let len = ffi::BIO_get_mem_data(self.0, &mut ptr); ++ slice::from_raw_parts(ptr as *const _ as *const _, len as usize) ++ } ++ } ++} ++ ++#[cfg(not(ossl101))] ++use ffi::BIO_new_mem_buf; ++ ++#[cfg(ossl101)] ++#[allow(bad_style)] ++unsafe fn BIO_new_mem_buf(buf: *const ::libc::c_void, len: ::libc::c_int) -> *mut ffi::BIO { ++ ffi::BIO_new_mem_buf(buf as *mut _, len) ++} diff --cc vendor/openssl-0.9.19/src/bn.rs index 000000000,000000000..46d7d8f38 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/bn.rs @@@ -1,0 -1,0 +1,1059 @@@ ++use ffi; ++use foreign_types::{ForeignType, ForeignTypeRef}; ++use libc::c_int; ++use std::cmp::Ordering; ++use std::ffi::CString; ++use std::{fmt, ptr}; ++use std::ops::{Add, Div, Mul, Neg, Rem, Shl, Shr, Sub, Deref}; ++ ++use {cvt, cvt_p, cvt_n}; ++use asn1::Asn1Integer; ++use error::ErrorStack; ++use string::OpensslString; ++ ++#[cfg(ossl10x)] ++use ffi::{get_rfc2409_prime_768 as BN_get_rfc2409_prime_768, ++ get_rfc2409_prime_1024 as BN_get_rfc2409_prime_1024, ++ get_rfc3526_prime_1536 as BN_get_rfc3526_prime_1536, ++ get_rfc3526_prime_2048 as BN_get_rfc3526_prime_2048, ++ get_rfc3526_prime_3072 as BN_get_rfc3526_prime_3072, ++ get_rfc3526_prime_4096 as BN_get_rfc3526_prime_4096, ++ get_rfc3526_prime_6144 as BN_get_rfc3526_prime_6144, ++ get_rfc3526_prime_8192 as BN_get_rfc3526_prime_8192}; ++ ++#[cfg(ossl110)] ++use ffi::{BN_get_rfc2409_prime_768, BN_get_rfc2409_prime_1024, BN_get_rfc3526_prime_1536, ++ BN_get_rfc3526_prime_2048, BN_get_rfc3526_prime_3072, BN_get_rfc3526_prime_4096, ++ BN_get_rfc3526_prime_6144, BN_get_rfc3526_prime_8192}; ++ ++/// Options for the most significant bits of a randomly generated `BigNum`. ++pub struct MsbOption(c_int); ++ ++/// The most significant bit of the number may be 0. ++pub const MSB_MAYBE_ZERO: MsbOption = MsbOption(-1); ++ ++/// The most significant bit of the number must be 1. ++pub const MSB_ONE: MsbOption = MsbOption(0); ++ ++/// The most significant two bits of the number must be 1. ++/// ++/// The number of bits in the product of two such numbers will always be exactly twice the number ++/// of bits in the original numbers. ++pub const TWO_MSB_ONE: MsbOption = MsbOption(1); ++ ++foreign_type! { ++ type CType = ffi::BN_CTX; ++ fn drop = ffi::BN_CTX_free; ++ ++ pub struct BigNumContext; ++ pub struct BigNumContextRef; ++} ++ ++impl BigNumContext { ++ /// Returns a new `BigNumContext`. ++ pub fn new() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(ffi::BN_CTX_new()).map(BigNumContext) ++ } ++ } ++} ++ ++impl BigNumRef { ++ /// Erases the memory used by this `BigNum`, resetting its value to 0. ++ /// ++ /// This can be used to destroy sensitive data such as keys when they are no longer needed. ++ pub fn clear(&mut self) { ++ unsafe { ffi::BN_clear(self.as_ptr()) } ++ } ++ ++ /// Adds a `u32` to `self`. ++ pub fn add_word(&mut self, w: u32) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_add_word(self.as_ptr(), w as ffi::BN_ULONG)).map(|_| ()) } ++ } ++ ++ /// Subtracts a `u32` from `self`. ++ pub fn sub_word(&mut self, w: u32) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_sub_word(self.as_ptr(), w as ffi::BN_ULONG)).map(|_| ()) } ++ } ++ ++ /// Multiplies a `u32` by `self`. ++ pub fn mul_word(&mut self, w: u32) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_mul_word(self.as_ptr(), w as ffi::BN_ULONG)).map(|_| ()) } ++ } ++ ++ /// Divides `self` by a `u32`, returning the remainder. ++ pub fn div_word(&mut self, w: u32) -> Result { ++ unsafe { ++ let r = ffi::BN_div_word(self.as_ptr(), w.into()); ++ if r == ffi::BN_ULONG::max_value() { ++ Err(ErrorStack::get()) ++ } else { ++ Ok(r.into()) ++ } ++ } ++ } ++ ++ /// Returns the result of `self` modulo `w`. ++ pub fn mod_word(&self, w: u32) -> Result { ++ unsafe { ++ let r = ffi::BN_mod_word(self.as_ptr(), w.into()); ++ if r == ffi::BN_ULONG::max_value() { ++ Err(ErrorStack::get()) ++ } else { ++ Ok(r.into()) ++ } ++ } ++ } ++ ++ /// Places a cryptographically-secure pseudo-random number nonnegative ++ /// number less than `self` in `rnd`. ++ pub fn rand_range(&self, rnd: &mut BigNumRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_rand_range(rnd.as_ptr(), self.as_ptr())).map(|_| ()) } ++ } ++ ++ /// The cryptographically weak counterpart to `rand_in_range`. ++ pub fn pseudo_rand_range(&self, rnd: &mut BigNumRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_pseudo_rand_range(rnd.as_ptr(), self.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Sets bit `n`. Equivalent to `self |= (1 << n)`. ++ /// ++ /// When setting a bit outside of `self`, it is expanded. ++ pub fn set_bit(&mut self, n: i32) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_set_bit(self.as_ptr(), n.into())).map(|_| ()) } ++ } ++ ++ /// Clears bit `n`, setting it to 0. Equivalent to `self &= ~(1 << n)`. ++ /// ++ /// When clearing a bit outside of `self`, an error is returned. ++ pub fn clear_bit(&mut self, n: i32) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_clear_bit(self.as_ptr(), n.into())).map(|_| ()) } ++ } ++ ++ /// Returns `true` if the `n`th bit of `self` is set to 1, `false` otherwise. ++ pub fn is_bit_set(&self, n: i32) -> bool { ++ unsafe { ffi::BN_is_bit_set(self.as_ptr(), n.into()) == 1 } ++ } ++ ++ /// Truncates `self` to the lowest `n` bits. ++ /// ++ /// An error occurs if `self` is already shorter than `n` bits. ++ pub fn mask_bits(&mut self, n: i32) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_mask_bits(self.as_ptr(), n.into())).map(|_| ()) } ++ } ++ ++ /// Places `a << 1` in `self`. ++ pub fn lshift1(&mut self, a: &BigNumRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_lshift1(self.as_ptr(), a.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Places `a >> 1` in `self`. ++ pub fn rshift1(&mut self, a: &BigNumRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_rshift1(self.as_ptr(), a.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Places `a + b` in `self`. ++ pub fn checked_add(&mut self, a: &BigNumRef, b: &BigNumRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_add(self.as_ptr(), a.as_ptr(), b.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Places `a - b` in `self`. ++ pub fn checked_sub(&mut self, a: &BigNumRef, b: &BigNumRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_sub(self.as_ptr(), a.as_ptr(), b.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Places `a << n` in `self`. ++ pub fn lshift(&mut self, a: &BigNumRef, n: i32) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_lshift(self.as_ptr(), a.as_ptr(), n.into())).map(|_| ()) } ++ } ++ ++ /// Places `a >> n` in `self`. ++ pub fn rshift(&mut self, a: &BigNumRef, n: i32) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_rshift(self.as_ptr(), a.as_ptr(), n.into())).map(|_| ()) } ++ } ++ ++ pub fn to_owned(&self) -> Result { ++ unsafe { cvt_p(ffi::BN_dup(self.as_ptr())).map(|b| BigNum::from_ptr(b)) } ++ } ++ ++ /// Sets the sign of `self`. ++ pub fn set_negative(&mut self, negative: bool) { ++ unsafe { ffi::BN_set_negative(self.as_ptr(), negative as c_int) } ++ } ++ ++ /// Compare the absolute values of `self` and `oth`. ++ /// ++ /// ``` ++ /// # use openssl::bn::BigNum; ++ /// # use std::cmp::Ordering; ++ /// let s = -BigNum::from_u32(8).unwrap(); ++ /// let o = BigNum::from_u32(8).unwrap(); ++ /// ++ /// assert_eq!(s.ucmp(&o), Ordering::Equal); ++ /// ``` ++ pub fn ucmp(&self, oth: &BigNumRef) -> Ordering { ++ unsafe { ffi::BN_ucmp(self.as_ptr(), oth.as_ptr()).cmp(&0) } ++ } ++ ++ pub fn is_negative(&self) -> bool { ++ self._is_negative() ++ } ++ ++ #[cfg(ossl10x)] ++ fn _is_negative(&self) -> bool { ++ unsafe { (*self.as_ptr()).neg == 1 } ++ } ++ ++ #[cfg(ossl110)] ++ fn _is_negative(&self) -> bool { ++ unsafe { ffi::BN_is_negative(self.as_ptr()) == 1 } ++ } ++ ++ /// Returns the number of significant bits in `self`. ++ pub fn num_bits(&self) -> i32 { ++ unsafe { ffi::BN_num_bits(self.as_ptr()) as i32 } ++ } ++ ++ /// Returns the size of `self` in bytes. ++ pub fn num_bytes(&self) -> i32 { ++ (self.num_bits() + 7) / 8 ++ } ++ ++ /// Generates a cryptographically strong pseudo-random `BigNum`, placing it in `self`. ++ /// ++ /// # Parameters ++ /// ++ /// * `bits`: Length of the number in bits. ++ /// * `msb`: The desired properties of the number. ++ /// * `odd`: If `true`, the generated number will be odd. ++ pub fn rand(&mut self, bits: i32, msb: MsbOption, odd: bool) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_rand( ++ self.as_ptr(), ++ bits.into(), ++ msb.0, ++ odd as c_int, ++ )).map(|_| ()) ++ } ++ } ++ ++ /// The cryptographically weak counterpart to `rand`. ++ pub fn pseudo_rand(&mut self, bits: i32, msb: MsbOption, odd: bool) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_pseudo_rand( ++ self.as_ptr(), ++ bits.into(), ++ msb.0, ++ odd as c_int, ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Generates a prime number, placing it in `self`. ++ /// ++ /// # Parameters ++ /// ++ /// * `bits`: The length of the prime in bits (lower bound). ++ /// * `safe`: If true, returns a "safe" prime `p` so that `(p-1)/2` is also prime. ++ /// * `add`/`rem`: If `add` is set to `Some(add)`, `p % add == rem` will hold, where `p` is the ++ /// generated prime and `rem` is `1` if not specified (`None`). ++ pub fn generate_prime( ++ &mut self, ++ bits: i32, ++ safe: bool, ++ add: Option<&BigNumRef>, ++ rem: Option<&BigNumRef>, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_generate_prime_ex( ++ self.as_ptr(), ++ bits as c_int, ++ safe as c_int, ++ add.map(|n| n.as_ptr()).unwrap_or(ptr::null_mut()), ++ rem.map(|n| n.as_ptr()).unwrap_or(ptr::null_mut()), ++ ptr::null_mut(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `a * b` in `self`. ++ pub fn checked_mul( ++ &mut self, ++ a: &BigNumRef, ++ b: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_mul( ++ self.as_ptr(), ++ a.as_ptr(), ++ b.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `a / b` in `self`. ++ pub fn checked_div( ++ &mut self, ++ a: &BigNumRef, ++ b: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_div( ++ self.as_ptr(), ++ ptr::null_mut(), ++ a.as_ptr(), ++ b.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `a % b` in `self`. ++ pub fn checked_rem( ++ &mut self, ++ a: &BigNumRef, ++ b: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_div( ++ ptr::null_mut(), ++ self.as_ptr(), ++ a.as_ptr(), ++ b.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `a / b` in `self` and `a % b` in `rem`. ++ pub fn div_rem( ++ &mut self, ++ rem: &mut BigNumRef, ++ a: &BigNumRef, ++ b: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_div( ++ self.as_ptr(), ++ rem.as_ptr(), ++ a.as_ptr(), ++ b.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `a²` in `self`. ++ pub fn sqr(&mut self, a: &BigNumRef, ctx: &mut BigNumContextRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::BN_sqr(self.as_ptr(), a.as_ptr(), ctx.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Places the result of `a mod m` in `self`. ++ pub fn nnmod( ++ &mut self, ++ a: &BigNumRef, ++ m: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_nnmod( ++ self.as_ptr(), ++ a.as_ptr(), ++ m.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `(a + b) mod m` in `self`. ++ pub fn mod_add( ++ &mut self, ++ a: &BigNumRef, ++ b: &BigNumRef, ++ m: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_mod_add( ++ self.as_ptr(), ++ a.as_ptr(), ++ b.as_ptr(), ++ m.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `(a - b) mod m` in `self`. ++ pub fn mod_sub( ++ &mut self, ++ a: &BigNumRef, ++ b: &BigNumRef, ++ m: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_mod_sub( ++ self.as_ptr(), ++ a.as_ptr(), ++ b.as_ptr(), ++ m.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `(a * b) mod m` in `self`. ++ pub fn mod_mul( ++ &mut self, ++ a: &BigNumRef, ++ b: &BigNumRef, ++ m: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_mod_mul( ++ self.as_ptr(), ++ a.as_ptr(), ++ b.as_ptr(), ++ m.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `a² mod m` in `self`. ++ pub fn mod_sqr( ++ &mut self, ++ a: &BigNumRef, ++ m: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_mod_sqr( ++ self.as_ptr(), ++ a.as_ptr(), ++ m.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `a^p` in `self`. ++ pub fn exp( ++ &mut self, ++ a: &BigNumRef, ++ p: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_exp( ++ self.as_ptr(), ++ a.as_ptr(), ++ p.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the result of `a^p mod m` in `self`. ++ pub fn mod_exp( ++ &mut self, ++ a: &BigNumRef, ++ p: &BigNumRef, ++ m: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_mod_exp( ++ self.as_ptr(), ++ a.as_ptr(), ++ p.as_ptr(), ++ m.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the inverse of `a` modulo `n` in `self`. ++ pub fn mod_inverse( ++ &mut self, ++ a: &BigNumRef, ++ n: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt_p(ffi::BN_mod_inverse( ++ self.as_ptr(), ++ a.as_ptr(), ++ n.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the greatest common denominator of `a` and `b` in `self`. ++ pub fn gcd( ++ &mut self, ++ a: &BigNumRef, ++ b: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::BN_gcd( ++ self.as_ptr(), ++ a.as_ptr(), ++ b.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Checks whether `self` is prime. ++ /// ++ /// Performs a Miller-Rabin probabilistic primality test with `checks` iterations. ++ /// ++ /// Returns `true` if `self` is prime with an error probability of less than `0.25 ^ checks`. ++ pub fn is_prime(&self, checks: i32, ctx: &mut BigNumContextRef) -> Result { ++ unsafe { ++ cvt_n(ffi::BN_is_prime_ex( ++ self.as_ptr(), ++ checks.into(), ++ ctx.as_ptr(), ++ ptr::null_mut(), ++ )).map(|r| r != 0) ++ } ++ } ++ ++ /// Checks whether `self` is prime with optional trial division. ++ /// ++ /// If `do_trial_division` is `true`, first performs trial division by a number of small primes. ++ /// Then, like `is_prime`, performs a Miller-Rabin probabilistic primality test with `checks` ++ /// iterations. ++ /// ++ /// # Return Value ++ /// ++ /// Returns `true` if `self` is prime with an error probability of less than `0.25 ^ checks`. ++ pub fn is_prime_fasttest( ++ &self, ++ checks: i32, ++ ctx: &mut BigNumContextRef, ++ do_trial_division: bool, ++ ) -> Result { ++ unsafe { ++ cvt_n(ffi::BN_is_prime_fasttest_ex( ++ self.as_ptr(), ++ checks.into(), ++ ctx.as_ptr(), ++ do_trial_division as c_int, ++ ptr::null_mut(), ++ )).map(|r| r != 0) ++ } ++ } ++ ++ /// Returns a big-endian byte vector representation of the absolute value of `self`. ++ /// ++ /// `self` can be recreated by using `from_slice`. ++ /// ++ /// ``` ++ /// # use openssl::bn::BigNum; ++ /// let s = -BigNum::from_u32(4543).unwrap(); ++ /// let r = BigNum::from_u32(4543).unwrap(); ++ /// ++ /// let s_vec = s.to_vec(); ++ /// assert_eq!(BigNum::from_slice(&s_vec).unwrap(), r); ++ /// ``` ++ pub fn to_vec(&self) -> Vec { ++ let size = self.num_bytes() as usize; ++ let mut v = Vec::with_capacity(size); ++ unsafe { ++ ffi::BN_bn2bin(self.as_ptr(), v.as_mut_ptr()); ++ v.set_len(size); ++ } ++ v ++ } ++ ++ /// Returns a decimal string representation of `self`. ++ /// ++ /// ``` ++ /// # use openssl::bn::BigNum; ++ /// let s = -BigNum::from_u32(12345).unwrap(); ++ /// ++ /// assert_eq!(&**s.to_dec_str().unwrap(), "-12345"); ++ /// ``` ++ pub fn to_dec_str(&self) -> Result { ++ unsafe { ++ let buf = try!(cvt_p(ffi::BN_bn2dec(self.as_ptr()))); ++ Ok(OpensslString::from_ptr(buf)) ++ } ++ } ++ ++ /// Returns a hexadecimal string representation of `self`. ++ /// ++ /// ``` ++ /// # use openssl::bn::BigNum; ++ /// let s = -BigNum::from_u32(0x99ff).unwrap(); ++ /// ++ /// assert_eq!(&**s.to_hex_str().unwrap(), "-99FF"); ++ /// ``` ++ pub fn to_hex_str(&self) -> Result { ++ unsafe { ++ let buf = try!(cvt_p(ffi::BN_bn2hex(self.as_ptr()))); ++ Ok(OpensslString::from_ptr(buf)) ++ } ++ } ++ ++ /// Returns an `Asn1Integer` containing the value of `self`. ++ pub fn to_asn1_integer(&self) -> Result { ++ unsafe { ++ cvt_p(ffi::BN_to_ASN1_INTEGER(self.as_ptr(), ptr::null_mut())) ++ .map(|p| Asn1Integer::from_ptr(p)) ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::BIGNUM; ++ fn drop = ffi::BN_free; ++ ++ pub struct BigNum; ++ pub struct BigNumRef; ++} ++ ++impl BigNum { ++ /// Creates a new `BigNum` with the value 0. ++ pub fn new() -> Result { ++ unsafe { ++ ffi::init(); ++ let v = try!(cvt_p(ffi::BN_new())); ++ Ok(BigNum::from_ptr(v)) ++ } ++ } ++ ++ /// Creates a new `BigNum` with the given value. ++ pub fn from_u32(n: u32) -> Result { ++ BigNum::new().and_then(|v| unsafe { ++ cvt(ffi::BN_set_word(v.as_ptr(), n as ffi::BN_ULONG)).map(|_| v) ++ }) ++ } ++ ++ /// Creates a `BigNum` from a decimal string. ++ pub fn from_dec_str(s: &str) -> Result { ++ unsafe { ++ ffi::init(); ++ let c_str = CString::new(s.as_bytes()).unwrap(); ++ let mut bn = ptr::null_mut(); ++ try!(cvt(ffi::BN_dec2bn(&mut bn, c_str.as_ptr() as *const _))); ++ Ok(BigNum::from_ptr(bn)) ++ } ++ } ++ ++ /// Creates a `BigNum` from a hexadecimal string. ++ pub fn from_hex_str(s: &str) -> Result { ++ unsafe { ++ ffi::init(); ++ let c_str = CString::new(s.as_bytes()).unwrap(); ++ let mut bn = ptr::null_mut(); ++ try!(cvt(ffi::BN_hex2bn(&mut bn, c_str.as_ptr() as *const _))); ++ Ok(BigNum::from_ptr(bn)) ++ } ++ } ++ ++ pub fn get_rfc2409_prime_768() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(BN_get_rfc2409_prime_768(ptr::null_mut())).map(BigNum) ++ } ++ } ++ ++ pub fn get_rfc2409_prime_1024() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(BN_get_rfc2409_prime_1024(ptr::null_mut())).map(BigNum) ++ } ++ } ++ ++ pub fn get_rfc3526_prime_1536() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(BN_get_rfc3526_prime_1536(ptr::null_mut())).map(BigNum) ++ } ++ } ++ ++ pub fn get_rfc3526_prime_2048() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(BN_get_rfc3526_prime_2048(ptr::null_mut())).map(BigNum) ++ } ++ } ++ ++ pub fn get_rfc3526_prime_3072() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(BN_get_rfc3526_prime_3072(ptr::null_mut())).map(BigNum) ++ } ++ } ++ ++ pub fn get_rfc3526_prime_4096() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(BN_get_rfc3526_prime_4096(ptr::null_mut())).map(BigNum) ++ } ++ } ++ ++ pub fn get_rfc3526_prime_6144() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(BN_get_rfc3526_prime_6144(ptr::null_mut())).map(BigNum) ++ } ++ } ++ ++ pub fn get_rfc3526_prime_8192() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(BN_get_rfc3526_prime_8192(ptr::null_mut())).map(BigNum) ++ } ++ } ++ ++ /// Creates a new `BigNum` from an unsigned, big-endian encoded number of arbitrary length. ++ /// ++ /// ``` ++ /// # use openssl::bn::BigNum; ++ /// let bignum = BigNum::from_slice(&[0x12, 0x00, 0x34]).unwrap(); ++ /// ++ /// assert_eq!(bignum, BigNum::from_u32(0x120034).unwrap()); ++ /// ``` ++ pub fn from_slice(n: &[u8]) -> Result { ++ unsafe { ++ ffi::init(); ++ assert!(n.len() <= c_int::max_value() as usize); ++ cvt_p(ffi::BN_bin2bn( ++ n.as_ptr(), ++ n.len() as c_int, ++ ptr::null_mut(), ++ )).map(|p| BigNum::from_ptr(p)) ++ } ++ } ++} ++ ++impl AsRef for BigNum { ++ fn as_ref(&self) -> &BigNumRef { ++ self.deref() ++ } ++} ++ ++impl fmt::Debug for BigNumRef { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ match self.to_dec_str() { ++ Ok(s) => f.write_str(&s), ++ Err(e) => Err(e.into()), ++ } ++ } ++} ++ ++impl fmt::Debug for BigNum { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ match self.to_dec_str() { ++ Ok(s) => f.write_str(&s), ++ Err(e) => Err(e.into()), ++ } ++ } ++} ++ ++impl fmt::Display for BigNumRef { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ match self.to_dec_str() { ++ Ok(s) => f.write_str(&s), ++ Err(e) => Err(e.into()), ++ } ++ } ++} ++ ++impl fmt::Display for BigNum { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ match self.to_dec_str() { ++ Ok(s) => f.write_str(&s), ++ Err(e) => Err(e.into()), ++ } ++ } ++} ++ ++impl PartialEq for BigNumRef { ++ fn eq(&self, oth: &BigNumRef) -> bool { ++ self.cmp(oth) == Ordering::Equal ++ } ++} ++ ++impl PartialEq for BigNumRef { ++ fn eq(&self, oth: &BigNum) -> bool { ++ self.eq(oth.deref()) ++ } ++} ++ ++impl Eq for BigNumRef {} ++ ++impl PartialEq for BigNum { ++ fn eq(&self, oth: &BigNum) -> bool { ++ self.deref().eq(oth) ++ } ++} ++ ++impl PartialEq for BigNum { ++ fn eq(&self, oth: &BigNumRef) -> bool { ++ self.deref().eq(oth) ++ } ++} ++ ++impl Eq for BigNum {} ++ ++impl PartialOrd for BigNumRef { ++ fn partial_cmp(&self, oth: &BigNumRef) -> Option { ++ Some(self.cmp(oth)) ++ } ++} ++ ++impl PartialOrd for BigNumRef { ++ fn partial_cmp(&self, oth: &BigNum) -> Option { ++ Some(self.cmp(oth.deref())) ++ } ++} ++ ++impl Ord for BigNumRef { ++ fn cmp(&self, oth: &BigNumRef) -> Ordering { ++ unsafe { ffi::BN_cmp(self.as_ptr(), oth.as_ptr()).cmp(&0) } ++ } ++} ++ ++impl PartialOrd for BigNum { ++ fn partial_cmp(&self, oth: &BigNum) -> Option { ++ self.deref().partial_cmp(oth.deref()) ++ } ++} ++ ++impl PartialOrd for BigNum { ++ fn partial_cmp(&self, oth: &BigNumRef) -> Option { ++ self.deref().partial_cmp(oth) ++ } ++} ++ ++impl Ord for BigNum { ++ fn cmp(&self, oth: &BigNum) -> Ordering { ++ self.deref().cmp(oth.deref()) ++ } ++} ++ ++macro_rules! delegate { ++ ($t:ident, $m:ident) => { ++ impl<'a, 'b> $t<&'b BigNum> for &'a BigNumRef { ++ type Output = BigNum; ++ ++ fn $m(self, oth: &BigNum) -> BigNum { ++ $t::$m(self, oth.deref()) ++ } ++ } ++ ++ impl<'a, 'b> $t<&'b BigNumRef> for &'a BigNum { ++ type Output = BigNum; ++ ++ fn $m(self, oth: &BigNumRef) -> BigNum { ++ $t::$m(self.deref(), oth) ++ } ++ } ++ ++ impl<'a, 'b> $t<&'b BigNum> for &'a BigNum { ++ type Output = BigNum; ++ ++ fn $m(self, oth: &BigNum) -> BigNum { ++ $t::$m(self.deref(), oth.deref()) ++ } ++ } ++ } ++} ++ ++impl<'a, 'b> Add<&'b BigNumRef> for &'a BigNumRef { ++ type Output = BigNum; ++ ++ fn add(self, oth: &BigNumRef) -> BigNum { ++ let mut r = BigNum::new().unwrap(); ++ r.checked_add(self, oth).unwrap(); ++ r ++ } ++} ++ ++delegate!(Add, add); ++ ++impl<'a, 'b> Sub<&'b BigNumRef> for &'a BigNumRef { ++ type Output = BigNum; ++ ++ fn sub(self, oth: &BigNumRef) -> BigNum { ++ let mut r = BigNum::new().unwrap(); ++ r.checked_sub(self, oth).unwrap(); ++ r ++ } ++} ++ ++delegate!(Sub, sub); ++ ++impl<'a, 'b> Mul<&'b BigNumRef> for &'a BigNumRef { ++ type Output = BigNum; ++ ++ fn mul(self, oth: &BigNumRef) -> BigNum { ++ let mut ctx = BigNumContext::new().unwrap(); ++ let mut r = BigNum::new().unwrap(); ++ r.checked_mul(self, oth, &mut ctx).unwrap(); ++ r ++ } ++} ++ ++delegate!(Mul, mul); ++ ++impl<'a, 'b> Div<&'b BigNumRef> for &'a BigNumRef { ++ type Output = BigNum; ++ ++ fn div(self, oth: &'b BigNumRef) -> BigNum { ++ let mut ctx = BigNumContext::new().unwrap(); ++ let mut r = BigNum::new().unwrap(); ++ r.checked_div(self, oth, &mut ctx).unwrap(); ++ r ++ } ++} ++ ++delegate!(Div, div); ++ ++impl<'a, 'b> Rem<&'b BigNumRef> for &'a BigNumRef { ++ type Output = BigNum; ++ ++ fn rem(self, oth: &'b BigNumRef) -> BigNum { ++ let mut ctx = BigNumContext::new().unwrap(); ++ let mut r = BigNum::new().unwrap(); ++ r.checked_rem(self, oth, &mut ctx).unwrap(); ++ r ++ } ++} ++ ++delegate!(Rem, rem); ++ ++impl<'a> Shl for &'a BigNumRef { ++ type Output = BigNum; ++ ++ fn shl(self, n: i32) -> BigNum { ++ let mut r = BigNum::new().unwrap(); ++ r.lshift(self, n).unwrap(); ++ r ++ } ++} ++ ++impl<'a> Shl for &'a BigNum { ++ type Output = BigNum; ++ ++ fn shl(self, n: i32) -> BigNum { ++ self.deref().shl(n) ++ } ++} ++ ++impl<'a> Shr for &'a BigNumRef { ++ type Output = BigNum; ++ ++ fn shr(self, n: i32) -> BigNum { ++ let mut r = BigNum::new().unwrap(); ++ r.rshift(self, n).unwrap(); ++ r ++ } ++} ++ ++impl<'a> Shr for &'a BigNum { ++ type Output = BigNum; ++ ++ fn shr(self, n: i32) -> BigNum { ++ self.deref().shr(n) ++ } ++} ++ ++impl<'a> Neg for &'a BigNumRef { ++ type Output = BigNum; ++ ++ fn neg(self) -> BigNum { ++ self.to_owned().unwrap().neg() ++ } ++} ++ ++impl<'a> Neg for &'a BigNum { ++ type Output = BigNum; ++ ++ fn neg(self) -> BigNum { ++ self.deref().neg() ++ } ++} ++ ++impl Neg for BigNum { ++ type Output = BigNum; ++ ++ fn neg(mut self) -> BigNum { ++ let negative = self.is_negative(); ++ self.set_negative(!negative); ++ self ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use bn::{BigNumContext, BigNum}; ++ ++ #[test] ++ fn test_to_from_slice() { ++ let v0 = BigNum::from_u32(10203004).unwrap(); ++ let vec = v0.to_vec(); ++ let v1 = BigNum::from_slice(&vec).unwrap(); ++ ++ assert!(v0 == v1); ++ } ++ ++ #[test] ++ fn test_negation() { ++ let a = BigNum::from_u32(909829283).unwrap(); ++ ++ assert!(!a.is_negative()); ++ assert!((-a).is_negative()); ++ } ++ ++ #[test] ++ fn test_shift() { ++ let a = BigNum::from_u32(909829283).unwrap(); ++ use std::ops::{Shl, Shr}; ++ ++ assert!(a == a.shl(1).shr(1)); ++ } ++ ++ #[test] ++ fn test_rand_range() { ++ let range = BigNum::from_u32(909829283).unwrap(); ++ let mut result = BigNum::from_dec_str(&range.to_dec_str().unwrap()).unwrap(); ++ range.rand_range(&mut result).unwrap(); ++ assert!(result >= BigNum::from_u32(0).unwrap() && result < range); ++ } ++ ++ #[test] ++ fn test_pseudo_rand_range() { ++ let range = BigNum::from_u32(909829283).unwrap(); ++ let mut result = BigNum::from_dec_str(&range.to_dec_str().unwrap()).unwrap(); ++ range.pseudo_rand_range(&mut result).unwrap(); ++ assert!(result >= BigNum::from_u32(0).unwrap() && result < range); ++ } ++ ++ #[test] ++ fn test_prime_numbers() { ++ let a = BigNum::from_u32(19029017).unwrap(); ++ let mut p = BigNum::new().unwrap(); ++ p.generate_prime(128, true, None, Some(&a)).unwrap(); ++ ++ let mut ctx = BigNumContext::new().unwrap(); ++ assert!(p.is_prime(100, &mut ctx).unwrap()); ++ assert!(p.is_prime_fasttest(100, &mut ctx, true).unwrap()); ++ } ++} diff --cc vendor/openssl-0.9.19/src/cms.rs index 000000000,000000000..9619d0b81 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/cms.rs @@@ -1,0 -1,0 +1,60 @@@ ++//! CMS archive ++ ++use ffi; ++use foreign_types::{ForeignType, ForeignTypeRef}; ++use std::ptr; ++use error::ErrorStack; ++ ++use bio::{MemBio, MemBioSlice}; ++ ++use x509::X509; ++use pkey::PKeyRef; ++ ++use cvt; ++use cvt_p; ++ ++foreign_type! { ++ type CType = ffi::CMS_ContentInfo; ++ fn drop = ffi::CMS_ContentInfo_free; ++ ++ pub struct CmsContentInfo; ++ pub struct CmsContentInfoRef; ++} ++ ++impl CmsContentInfoRef { ++ pub fn decrypt(&self, pkey: &PKeyRef, cert: &X509) -> Result, ErrorStack> { ++ unsafe { ++ let pkey = pkey.as_ptr(); ++ let cert = cert.as_ptr(); ++ let out = try!(MemBio::new()); ++ let flags: u32 = 0; ++ ++ try!(cvt(ffi::CMS_decrypt( ++ self.as_ptr(), ++ pkey, ++ cert, ++ ptr::null_mut(), ++ out.as_ptr(), ++ flags.into(), ++ ))); ++ ++ Ok(out.get_buf().to_owned()) ++ } ++ } ++ ++} ++ ++impl CmsContentInfo { ++ pub fn smime_read_cms(smime: &[u8]) -> Result { ++ unsafe { ++ let bio = try!(MemBioSlice::new(smime)); ++ ++ let cms = try!(cvt_p(ffi::SMIME_read_CMS( ++ bio.as_ptr(), ++ ptr::null_mut(), ++ ))); ++ ++ Ok(CmsContentInfo::from_ptr(cms)) ++ } ++ } ++} diff --cc vendor/openssl-0.9.19/src/conf.rs index 000000000,000000000..a648bb150 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/conf.rs @@@ -1,0 -1,0 +1,37 @@@ ++use ffi; ++ ++use cvt_p; ++use error::ErrorStack; ++ ++pub struct ConfMethod(*mut ffi::CONF_METHOD); ++ ++impl ConfMethod { ++ pub fn default() -> ConfMethod { ++ unsafe { ++ ffi::init(); ++ ConfMethod(ffi::NCONF_default()) ++ } ++ } ++ ++ pub unsafe fn from_ptr(ptr: *mut ffi::CONF_METHOD) -> ConfMethod { ++ ConfMethod(ptr) ++ } ++ ++ pub fn as_ptr(&self) -> *mut ffi::CONF_METHOD { ++ self.0 ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::CONF; ++ fn drop = ffi::NCONF_free; ++ ++ pub struct Conf; ++ pub struct ConfRef; ++} ++ ++impl Conf { ++ pub fn new(method: ConfMethod) -> Result { ++ unsafe { cvt_p(ffi::NCONF_new(method.as_ptr())).map(Conf) } ++ } ++} diff --cc vendor/openssl-0.9.19/src/crypto.rs index 000000000,000000000..9853d99c1 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/crypto.rs @@@ -1,0 -1,0 +1,4 @@@ ++use string::OpensslString; ++ ++#[deprecated(note = "renamed to OpensslString", since = "0.9.7")] ++pub type CryptoString = OpensslString; diff --cc vendor/openssl-0.9.19/src/dh.rs index 000000000,000000000..6dd97844d new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/dh.rs @@@ -1,0 -1,0 +1,160 @@@ ++use error::ErrorStack; ++use ffi; ++use foreign_types::ForeignTypeRef; ++use std::mem; ++use std::ptr; ++ ++use {cvt, cvt_p}; ++use bn::BigNum; ++ ++foreign_type! { ++ type CType = ffi::DH; ++ fn drop = ffi::DH_free; ++ ++ pub struct Dh; ++ ++ pub struct DhRef; ++} ++ ++impl DhRef { ++ to_pem!(ffi::PEM_write_bio_DHparams); ++ to_der!(ffi::i2d_DHparams); ++} ++ ++impl Dh { ++ pub fn from_params(p: BigNum, g: BigNum, q: BigNum) -> Result { ++ unsafe { ++ let dh = Dh(try!(cvt_p(ffi::DH_new()))); ++ try!(cvt(compat::DH_set0_pqg( ++ dh.0, ++ p.as_ptr(), ++ q.as_ptr(), ++ g.as_ptr(), ++ ))); ++ mem::forget((p, g, q)); ++ Ok(dh) ++ } ++ } ++ ++ from_pem!(Dh, ffi::PEM_read_bio_DHparams); ++ from_der!(Dh, ffi::d2i_DHparams); ++ ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ pub fn get_1024_160() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(ffi::DH_get_1024_160()).map(Dh) ++ } ++ } ++ ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ pub fn get_2048_224() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(ffi::DH_get_2048_224()).map(Dh) ++ } ++ } ++ ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ pub fn get_2048_256() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(ffi::DH_get_2048_256()).map(Dh) ++ } ++ } ++} ++ ++#[cfg(ossl110)] ++mod compat { ++ pub use ffi::DH_set0_pqg; ++} ++ ++#[cfg(ossl10x)] ++#[allow(bad_style)] ++mod compat { ++ use ffi; ++ use libc::c_int; ++ ++ pub unsafe fn DH_set0_pqg( ++ dh: *mut ffi::DH, ++ p: *mut ffi::BIGNUM, ++ q: *mut ffi::BIGNUM, ++ g: *mut ffi::BIGNUM, ++ ) -> c_int { ++ (*dh).p = p; ++ (*dh).q = q; ++ (*dh).g = g; ++ 1 ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use dh::Dh; ++ use bn::BigNum; ++ use ssl::{SslMethod, SslContext}; ++ ++ #[test] ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ fn test_dh_rfc5114() { ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let dh1 = Dh::get_1024_160().unwrap(); ++ ctx.set_tmp_dh(&dh1).unwrap(); ++ let dh2 = Dh::get_2048_224().unwrap(); ++ ctx.set_tmp_dh(&dh2).unwrap(); ++ let dh3 = Dh::get_2048_256().unwrap(); ++ ctx.set_tmp_dh(&dh3).unwrap(); ++ } ++ ++ #[test] ++ fn test_dh() { ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let p = BigNum::from_hex_str( ++ "87A8E61DB4B6663CFFBBD19C651959998CEEF608660DD0F25D2CEED4435\ ++ E3B00E00DF8F1D61957D4FAF7DF4561B2AA3016C3D91134096FAA3BF429\ ++ 6D830E9A7C209E0C6497517ABD5A8A9D306BCF67ED91F9E6725B4758C02\ ++ 2E0B1EF4275BF7B6C5BFC11D45F9088B941F54EB1E59BB8BC39A0BF1230\ ++ 7F5C4FDB70C581B23F76B63ACAE1CAA6B7902D52526735488A0EF13C6D9\ ++ A51BFA4AB3AD8347796524D8EF6A167B5A41825D967E144E5140564251C\ ++ CACB83E6B486F6B3CA3F7971506026C0B857F689962856DED4010ABD0BE\ ++ 621C3A3960A54E710C375F26375D7014103A4B54330C198AF126116D227\ ++ 6E11715F693877FAD7EF09CADB094AE91E1A1597", ++ ).unwrap(); ++ let g = BigNum::from_hex_str( ++ "3FB32C9B73134D0B2E77506660EDBD484CA7B18F21EF205407F4793A1A0\ ++ BA12510DBC15077BE463FFF4FED4AAC0BB555BE3A6C1B0C6B47B1BC3773\ ++ BF7E8C6F62901228F8C28CBB18A55AE31341000A650196F931C77A57F2D\ ++ DF463E5E9EC144B777DE62AAAB8A8628AC376D282D6ED3864E67982428E\ ++ BC831D14348F6F2F9193B5045AF2767164E1DFC967C1FB3F2E55A4BD1BF\ ++ FE83B9C80D052B985D182EA0ADB2A3B7313D3FE14C8484B1E052588B9B7\ ++ D2BBD2DF016199ECD06E1557CD0915B3353BBB64E0EC377FD028370DF92\ ++ B52C7891428CDC67EB6184B523D1DB246C32F63078490F00EF8D647D148\ ++ D47954515E2327CFEF98C582664B4C0F6CC41659", ++ ).unwrap(); ++ let q = BigNum::from_hex_str( ++ "8CF83642A709A097B447997640129DA299B1A47D1EB3750BA308B0FE64F\ ++ 5FBD3", ++ ).unwrap(); ++ let dh = Dh::from_params(p, g, q).unwrap(); ++ ctx.set_tmp_dh(&dh).unwrap(); ++ } ++ ++ #[test] ++ fn test_dh_from_pem() { ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let params = include_bytes!("../test/dhparams.pem"); ++ let dh = Dh::from_pem(params).unwrap(); ++ ctx.set_tmp_dh(&dh).unwrap(); ++ } ++ ++ #[test] ++ fn test_dh_from_der() { ++ let params = include_bytes!("../test/dhparams.pem"); ++ let dh = Dh::from_pem(params).unwrap(); ++ let der = dh.to_der().unwrap(); ++ Dh::from_der(&der).unwrap(); ++ } ++} diff --cc vendor/openssl-0.9.19/src/dsa.rs index 000000000,000000000..23ab5743b new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/dsa.rs @@@ -1,0 -1,0 +1,201 @@@ ++use ffi; ++use foreign_types::ForeignTypeRef; ++use libc::{c_int, c_char, c_void}; ++use std::fmt; ++use std::ptr; ++ ++use {cvt, cvt_p}; ++use bio::MemBioSlice; ++use bn::BigNumRef; ++use error::ErrorStack; ++use util::{CallbackState, invoke_passwd_cb_old}; ++ ++foreign_type! { ++ type CType = ffi::DSA; ++ fn drop = ffi::DSA_free; ++ ++ pub struct Dsa; ++ pub struct DsaRef; ++} ++ ++impl DsaRef { ++ private_key_to_pem!(ffi::PEM_write_bio_DSAPrivateKey); ++ public_key_to_pem!(ffi::PEM_write_bio_DSA_PUBKEY); ++ ++ private_key_to_der!(ffi::i2d_DSAPrivateKey); ++ public_key_to_der!(ffi::i2d_DSAPublicKey); ++ ++ // FIXME should return u32 ++ pub fn size(&self) -> Option { ++ if self.q().is_some() { ++ unsafe { Some(ffi::DSA_size(self.as_ptr()) as u32) } ++ } else { ++ None ++ } ++ } ++ ++ pub fn p(&self) -> Option<&BigNumRef> { ++ unsafe { ++ let p = compat::pqg(self.as_ptr())[0]; ++ if p.is_null() { ++ None ++ } else { ++ Some(BigNumRef::from_ptr(p as *mut _)) ++ } ++ } ++ } ++ ++ pub fn q(&self) -> Option<&BigNumRef> { ++ unsafe { ++ let q = compat::pqg(self.as_ptr())[1]; ++ if q.is_null() { ++ None ++ } else { ++ Some(BigNumRef::from_ptr(q as *mut _)) ++ } ++ } ++ } ++ ++ pub fn g(&self) -> Option<&BigNumRef> { ++ unsafe { ++ let g = compat::pqg(self.as_ptr())[2]; ++ if g.is_null() { ++ None ++ } else { ++ Some(BigNumRef::from_ptr(g as *mut _)) ++ } ++ } ++ } ++ ++ pub fn has_public_key(&self) -> bool { ++ unsafe { !compat::keys(self.as_ptr())[0].is_null() } ++ } ++ ++ pub fn has_private_key(&self) -> bool { ++ unsafe { !compat::keys(self.as_ptr())[1].is_null() } ++ } ++} ++ ++impl Dsa { ++ /// Generate a DSA key pair. ++ pub fn generate(bits: u32) -> Result { ++ ffi::init(); ++ unsafe { ++ let dsa = Dsa(try!(cvt_p(ffi::DSA_new()))); ++ try!(cvt(ffi::DSA_generate_parameters_ex( ++ dsa.0, ++ bits as c_int, ++ ptr::null(), ++ 0, ++ ptr::null_mut(), ++ ptr::null_mut(), ++ ptr::null_mut(), ++ ))); ++ try!(cvt(ffi::DSA_generate_key(dsa.0))); ++ Ok(dsa) ++ } ++ } ++ ++ private_key_from_pem!(Dsa, ffi::PEM_read_bio_DSAPrivateKey); ++ private_key_from_der!(Dsa, ffi::d2i_DSAPrivateKey); ++ public_key_from_pem!(Dsa, ffi::PEM_read_bio_DSA_PUBKEY); ++ public_key_from_der!(Dsa, ffi::d2i_DSAPublicKey); ++ ++ #[deprecated(since = "0.9.2", note = "use private_key_from_pem_callback")] ++ pub fn private_key_from_pem_cb(buf: &[u8], pass_cb: F) -> Result ++ where ++ F: FnOnce(&mut [c_char]) -> usize, ++ { ++ ffi::init(); ++ let mut cb = CallbackState::new(pass_cb); ++ let mem_bio = try!(MemBioSlice::new(buf)); ++ ++ unsafe { ++ let cb_ptr = &mut cb as *mut _ as *mut c_void; ++ let dsa = try!(cvt_p(ffi::PEM_read_bio_DSAPrivateKey( ++ mem_bio.as_ptr(), ++ ptr::null_mut(), ++ Some(invoke_passwd_cb_old::), ++ cb_ptr, ++ ))); ++ Ok(Dsa(dsa)) ++ } ++ } ++} ++ ++impl fmt::Debug for Dsa { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "DSA") ++ } ++} ++ ++#[cfg(ossl110)] ++mod compat { ++ use std::ptr; ++ use ffi::{self, BIGNUM, DSA}; ++ ++ pub unsafe fn pqg(d: *const DSA) -> [*const BIGNUM; 3] { ++ let (mut p, mut q, mut g) = (ptr::null(), ptr::null(), ptr::null()); ++ ffi::DSA_get0_pqg(d, &mut p, &mut q, &mut g); ++ [p, q, g] ++ } ++ ++ pub unsafe fn keys(d: *const DSA) -> [*const BIGNUM; 2] { ++ let (mut pub_key, mut priv_key) = (ptr::null(), ptr::null()); ++ ffi::DSA_get0_key(d, &mut pub_key, &mut priv_key); ++ [pub_key, priv_key] ++ } ++} ++ ++#[cfg(ossl10x)] ++mod compat { ++ use ffi::{BIGNUM, DSA}; ++ ++ pub unsafe fn pqg(d: *const DSA) -> [*const BIGNUM; 3] { ++ [(*d).p, (*d).q, (*d).g] ++ } ++ ++ pub unsafe fn keys(d: *const DSA) -> [*const BIGNUM; 2] { ++ [(*d).pub_key, (*d).priv_key] ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use symm::Cipher; ++ ++ use super::*; ++ ++ #[test] ++ pub fn test_generate() { ++ Dsa::generate(1024).unwrap(); ++ } ++ ++ #[test] ++ pub fn test_password() { ++ let key = include_bytes!("../test/dsa-encrypted.pem"); ++ Dsa::private_key_from_pem_passphrase(key, b"mypass").unwrap(); ++ } ++ ++ #[test] ++ fn test_to_password() { ++ let key = Dsa::generate(2048).unwrap(); ++ let pem = key.private_key_to_pem_passphrase(Cipher::aes_128_cbc(), b"foobar") ++ .unwrap(); ++ Dsa::private_key_from_pem_passphrase(&pem, b"foobar").unwrap(); ++ assert!(Dsa::private_key_from_pem_passphrase(&pem, b"fizzbuzz").is_err()); ++ } ++ ++ #[test] ++ pub fn test_password_callback() { ++ let mut password_queried = false; ++ let key = include_bytes!("../test/dsa-encrypted.pem"); ++ Dsa::private_key_from_pem_callback(key, |password| { ++ password_queried = true; ++ password[..6].copy_from_slice(b"mypass"); ++ Ok(6) ++ }).unwrap(); ++ ++ assert!(password_queried); ++ } ++} diff --cc vendor/openssl-0.9.19/src/ec.rs index 000000000,000000000..aded95ab8 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ec.rs @@@ -1,0 -1,0 +1,673 @@@ ++use ffi; ++use foreign_types::{ForeignType, ForeignTypeRef}; ++use std::ptr; ++use std::mem; ++use libc::c_int; ++ ++use {cvt, cvt_n, cvt_p, init}; ++use bn::{BigNumRef, BigNumContextRef}; ++use error::ErrorStack; ++use nid::Nid; ++ ++pub const POINT_CONVERSION_COMPRESSED: PointConversionForm = ++ PointConversionForm(ffi::point_conversion_form_t::POINT_CONVERSION_COMPRESSED); ++ ++pub const POINT_CONVERSION_UNCOMPRESSED: PointConversionForm = ++ PointConversionForm(ffi::point_conversion_form_t::POINT_CONVERSION_UNCOMPRESSED); ++ ++pub const POINT_CONVERSION_HYBRID: PointConversionForm = ++ PointConversionForm(ffi::point_conversion_form_t::POINT_CONVERSION_HYBRID); ++ ++// OPENSSL_EC_EXPLICIT_CURVE, but that was only added in 1.1. ++// Man page documents that 0 can be used in older versions. ++pub const EXPLICIT_CURVE: Asn1Flag = Asn1Flag(0); ++pub const NAMED_CURVE: Asn1Flag = Asn1Flag(ffi::OPENSSL_EC_NAMED_CURVE); ++ ++#[derive(Copy, Clone)] ++pub struct PointConversionForm(ffi::point_conversion_form_t); ++ ++#[derive(Copy, Clone)] ++pub struct Asn1Flag(c_int); ++ ++foreign_type! { ++ type CType = ffi::EC_GROUP; ++ fn drop = ffi::EC_GROUP_free; ++ ++ pub struct EcGroup; ++ pub struct EcGroupRef; ++} ++ ++impl EcGroup { ++ /// Returns the group of a standard named curve. ++ pub fn from_curve_name(nid: Nid) -> Result { ++ unsafe { ++ init(); ++ cvt_p(ffi::EC_GROUP_new_by_curve_name(nid.as_raw())).map(EcGroup) ++ } ++ } ++} ++ ++impl EcGroupRef { ++ /// Places the components of a curve over a prime field in the provided `BigNum`s. ++ pub fn components_gfp( ++ &self, ++ p: &mut BigNumRef, ++ a: &mut BigNumRef, ++ b: &mut BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_GROUP_get_curve_GFp( ++ self.as_ptr(), ++ p.as_ptr(), ++ a.as_ptr(), ++ b.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Places the components of a curve over a binary field in the provided `BigNum`s. ++ #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] ++ pub fn components_gf2m( ++ &self, ++ p: &mut BigNumRef, ++ a: &mut BigNumRef, ++ b: &mut BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_GROUP_get_curve_GF2m( ++ self.as_ptr(), ++ p.as_ptr(), ++ a.as_ptr(), ++ b.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Returns the degree of the curve. ++ pub fn degree(&self) -> u32 { ++ unsafe { ffi::EC_GROUP_get_degree(self.as_ptr()) as u32 } ++ } ++ ++ /// Places the order of the curve in the provided `BigNum`. ++ pub fn order( ++ &self, ++ order: &mut BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_GROUP_get_order( ++ self.as_ptr(), ++ order.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Sets the flag determining if the group corresponds to a named curve or must be explicitly ++ /// parameterized. ++ /// ++ /// This defaults to `EXPLICIT_CURVE` in OpenSSL 1.0.1 and 1.0.2, but `NAMED_CURVE` in OpenSSL ++ /// 1.1.0. ++ pub fn set_asn1_flag(&mut self, flag: Asn1Flag) { ++ unsafe { ++ ffi::EC_GROUP_set_asn1_flag(self.as_ptr(), flag.0); ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::EC_POINT; ++ fn drop = ffi::EC_POINT_free; ++ ++ pub struct EcPoint; ++ pub struct EcPointRef; ++} ++ ++impl EcPointRef { ++ /// Computes `a + b`, storing the result in `self`. ++ pub fn add( ++ &mut self, ++ group: &EcGroupRef, ++ a: &EcPointRef, ++ b: &EcPointRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_POINT_add( ++ group.as_ptr(), ++ self.as_ptr(), ++ a.as_ptr(), ++ b.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Computes `q * m`, storing the result in `self`. ++ pub fn mul( ++ &mut self, ++ group: &EcGroupRef, ++ q: &EcPointRef, ++ m: &BigNumRef, ++ ctx: &BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_POINT_mul( ++ group.as_ptr(), ++ self.as_ptr(), ++ ptr::null(), ++ q.as_ptr(), ++ m.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Computes `generator * n`, storing the result ing `self`. ++ pub fn mul_generator( ++ &mut self, ++ group: &EcGroupRef, ++ n: &BigNumRef, ++ ctx: &BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_POINT_mul( ++ group.as_ptr(), ++ self.as_ptr(), ++ n.as_ptr(), ++ ptr::null(), ++ ptr::null(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Computes `generator * n + q * m`, storing the result in `self`. ++ pub fn mul_full( ++ &mut self, ++ group: &EcGroupRef, ++ n: &BigNumRef, ++ q: &EcPointRef, ++ m: &BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_POINT_mul( ++ group.as_ptr(), ++ self.as_ptr(), ++ n.as_ptr(), ++ q.as_ptr(), ++ m.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Inverts `self`. ++ pub fn invert(&mut self, group: &EcGroupRef, ctx: &BigNumContextRef) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_POINT_invert( ++ group.as_ptr(), ++ self.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Serializes the point to a binary representation. ++ pub fn to_bytes( ++ &self, ++ group: &EcGroupRef, ++ form: PointConversionForm, ++ ctx: &mut BigNumContextRef, ++ ) -> Result, ErrorStack> { ++ unsafe { ++ let len = ffi::EC_POINT_point2oct( ++ group.as_ptr(), ++ self.as_ptr(), ++ form.0, ++ ptr::null_mut(), ++ 0, ++ ctx.as_ptr(), ++ ); ++ if len == 0 { ++ return Err(ErrorStack::get()); ++ } ++ let mut buf = vec![0; len]; ++ let len = ffi::EC_POINT_point2oct( ++ group.as_ptr(), ++ self.as_ptr(), ++ form.0, ++ buf.as_mut_ptr(), ++ len, ++ ctx.as_ptr(), ++ ); ++ if len == 0 { ++ Err(ErrorStack::get()) ++ } else { ++ Ok(buf) ++ } ++ } ++ } ++ ++ /// Determines if this point is equal to another. ++ pub fn eq( ++ &self, ++ group: &EcGroupRef, ++ other: &EcPointRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result { ++ unsafe { ++ let res = try!(cvt_n(ffi::EC_POINT_cmp( ++ group.as_ptr(), ++ self.as_ptr(), ++ other.as_ptr(), ++ ctx.as_ptr(), ++ ))); ++ Ok(res == 0) ++ } ++ } ++ ++ /// Place affine coordinates of a curve over a prime field in the provided x and y BigNum's ++ pub fn affine_coordinates_gfp( ++ &self, ++ group: &EcGroupRef, ++ x: &mut BigNumRef, ++ y: &mut BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_POINT_get_affine_coordinates_GFp( ++ group.as_ptr(), ++ self.as_ptr(), ++ x.as_ptr(), ++ y.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Place affine coordinates of a curve over a binary field in the provided x and y BigNum's ++ #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] ++ pub fn affine_coordinates_gf2m( ++ &self, ++ group: &EcGroupRef, ++ x: &mut BigNumRef, ++ y: &mut BigNumRef, ++ ctx: &mut BigNumContextRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_POINT_get_affine_coordinates_GF2m( ++ group.as_ptr(), ++ self.as_ptr(), ++ x.as_ptr(), ++ y.as_ptr(), ++ ctx.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++} ++ ++impl EcPoint { ++ /// Creates a new point on the specified curve. ++ pub fn new(group: &EcGroupRef) -> Result { ++ unsafe { cvt_p(ffi::EC_POINT_new(group.as_ptr())).map(EcPoint) } ++ } ++ ++ pub fn from_bytes( ++ group: &EcGroupRef, ++ buf: &[u8], ++ ctx: &mut BigNumContextRef, ++ ) -> Result { ++ let point = try!(EcPoint::new(group)); ++ unsafe { ++ try!(cvt(ffi::EC_POINT_oct2point( ++ group.as_ptr(), ++ point.as_ptr(), ++ buf.as_ptr(), ++ buf.len(), ++ ctx.as_ptr(), ++ ))); ++ } ++ Ok(point) ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::EC_KEY; ++ fn drop = ffi::EC_KEY_free; ++ ++ pub struct EcKey; ++ pub struct EcKeyRef; ++} ++ ++impl EcKeyRef { ++ private_key_to_pem!(ffi::PEM_write_bio_ECPrivateKey); ++ private_key_to_der!(ffi::i2d_ECPrivateKey); ++ ++ pub fn group(&self) -> Option<&EcGroupRef> { ++ unsafe { ++ let ptr = ffi::EC_KEY_get0_group(self.as_ptr()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(EcGroupRef::from_ptr(ptr as *mut _)) ++ } ++ } ++ } ++ ++ pub fn public_key(&self) -> Option<&EcPointRef> { ++ unsafe { ++ let ptr = ffi::EC_KEY_get0_public_key(self.as_ptr()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(EcPointRef::from_ptr(ptr as *mut _)) ++ } ++ } ++ } ++ ++ pub fn private_key(&self) -> Option<&BigNumRef> { ++ unsafe { ++ let ptr = ffi::EC_KEY_get0_private_key(self.as_ptr()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(BigNumRef::from_ptr(ptr as *mut _)) ++ } ++ } ++ } ++ ++ /// Checks the key for validity. ++ pub fn check_key(&self) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::EC_KEY_check_key(self.as_ptr())).map(|_| ()) } ++ } ++ ++ pub fn to_owned(&self) -> Result { ++ unsafe { cvt_p(ffi::EC_KEY_dup(self.as_ptr())).map(EcKey) } ++ } ++} ++ ++impl EcKey { ++ /// Constructs an `EcKey` corresponding to a known curve. ++ /// ++ /// It will not have an associated public or private key. This kind of key is primarily useful ++ /// to be provided to the `set_tmp_ecdh` methods on `Ssl` and `SslContextBuilder`. ++ pub fn from_curve_name(nid: Nid) -> Result { ++ unsafe { ++ init(); ++ cvt_p(ffi::EC_KEY_new_by_curve_name(nid.as_raw())).map(EcKey) ++ } ++ } ++ ++ /// Constructs an `EcKey` from the specified group with the associated `EcPoint`, public_key. ++ /// ++ /// This will only have the associated public_key. ++ /// ++ /// # Example ++ /// ++ /// ```no_run ++ /// use openssl::bn::BigNumContext; ++ /// use openssl::ec::*; ++ /// use openssl::nid; ++ /// use openssl::pkey::PKey; ++ /// ++ /// // get bytes from somewhere, i.e. this will not produce a valid key ++ /// let public_key: Vec = vec![]; ++ /// ++ /// // create an EcKey from the binary form of a EcPoint ++ /// let group = EcGroup::from_curve_name(nid::SECP256K1).unwrap(); ++ /// let mut ctx = BigNumContext::new().unwrap(); ++ /// let point = EcPoint::from_bytes(&group, &public_key, &mut ctx).unwrap(); ++ /// let key = EcKey::from_public_key(&group, &point); ++ /// ``` ++ pub fn from_public_key( ++ group: &EcGroupRef, ++ public_key: &EcPointRef, ++ ) -> Result { ++ let mut builder = try!(EcKeyBuilder::new()); ++ try!(builder.set_group(group)); ++ try!(builder.set_public_key(public_key)); ++ Ok(builder.build()) ++ } ++ ++ /// Generates a new public/private key pair on the specified curve. ++ pub fn generate(group: &EcGroupRef) -> Result { ++ let mut builder = try!(EcKeyBuilder::new()); ++ try!(builder.set_group(group)); ++ try!(builder.generate_key()); ++ Ok(builder.build()) ++ } ++ ++ #[deprecated(since = "0.9.2", note = "use from_curve_name")] ++ pub fn new_by_curve_name(nid: Nid) -> Result { ++ EcKey::from_curve_name(nid) ++ } ++ ++ private_key_from_pem!(EcKey, ffi::PEM_read_bio_ECPrivateKey); ++ private_key_from_der!(EcKey, ffi::d2i_ECPrivateKey); ++} ++ ++ ++foreign_type! { ++ type CType = ffi::EC_KEY; ++ fn drop = ffi::EC_KEY_free; ++ ++ pub struct EcKeyBuilder; ++ pub struct EcKeyBuilderRef; ++} ++ ++impl EcKeyBuilder { ++ pub fn new() -> Result { ++ unsafe { ++ init(); ++ cvt_p(ffi::EC_KEY_new()).map(EcKeyBuilder) ++ } ++ } ++ ++ pub fn build(self) -> EcKey { ++ unsafe { ++ let key = EcKey::from_ptr(self.as_ptr()); ++ mem::forget(self); ++ key ++ } ++ } ++} ++ ++impl EcKeyBuilderRef { ++ pub fn set_group(&mut self, group: &EcGroupRef) -> Result<&mut EcKeyBuilderRef, ErrorStack> { ++ unsafe { cvt(ffi::EC_KEY_set_group(self.as_ptr(), group.as_ptr())).map(|_| self) } ++ } ++ ++ pub fn set_public_key( ++ &mut self, ++ public_key: &EcPointRef, ++ ) -> Result<&mut EcKeyBuilderRef, ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_KEY_set_public_key( ++ self.as_ptr(), ++ public_key.as_ptr(), ++ )).map(|_| self) ++ } ++ } ++ ++ pub fn generate_key(&mut self) -> Result<&mut EcKeyBuilderRef, ErrorStack> { ++ unsafe { cvt(ffi::EC_KEY_generate_key(self.as_ptr())).map(|_| self) } ++ } ++ ++ /// Sets the public key based on affine coordinates. ++ pub fn set_public_key_affine_coordinates( ++ &mut self, ++ x: &BigNumRef, ++ y: &BigNumRef, ++ ) -> Result<&mut EcKeyBuilderRef, ErrorStack> { ++ unsafe { ++ cvt(ffi::EC_KEY_set_public_key_affine_coordinates( ++ self.as_ptr(), ++ x.as_ptr(), ++ y.as_ptr(), ++ )).map(|_| self) ++ } ++ } ++ ++ /// Sets the private key. ++ pub fn set_private_key(&mut self, key: &BigNumRef) -> Result<&mut EcKeyBuilderRef, ErrorStack> { ++ unsafe { cvt(ffi::EC_KEY_set_private_key(self.as_ptr(), key.as_ptr())).map(|_| self) } ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use bn::{BigNum, BigNumContext}; ++ use nid; ++ use data_encoding; ++ use super::*; ++ ++ #[test] ++ fn key_new_by_curve_name() { ++ EcKey::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ } ++ ++ #[test] ++ fn generate() { ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let key = EcKey::generate(&group).unwrap(); ++ key.public_key().unwrap(); ++ key.private_key().unwrap(); ++ } ++ ++ #[test] ++ fn dup() { ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let key = EcKey::generate(&group).unwrap(); ++ key.to_owned().unwrap(); ++ } ++ ++ #[test] ++ fn point_new() { ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ EcPoint::new(&group).unwrap(); ++ } ++ ++ #[test] ++ fn point_bytes() { ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let key = EcKey::generate(&group).unwrap(); ++ let point = key.public_key().unwrap(); ++ let mut ctx = BigNumContext::new().unwrap(); ++ let bytes = point ++ .to_bytes(&group, POINT_CONVERSION_COMPRESSED, &mut ctx) ++ .unwrap(); ++ let point2 = EcPoint::from_bytes(&group, &bytes, &mut ctx).unwrap(); ++ assert!(point.eq(&group, &point2, &mut ctx).unwrap()); ++ } ++ ++ #[test] ++ fn mul_generator() { ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let key = EcKey::generate(&group).unwrap(); ++ let mut ctx = BigNumContext::new().unwrap(); ++ let mut public_key = EcPoint::new(&group).unwrap(); ++ public_key ++ .mul_generator(&group, key.private_key().unwrap(), &mut ctx) ++ .unwrap(); ++ assert!( ++ public_key ++ .eq(&group, key.public_key().unwrap(), &mut ctx) ++ .unwrap() ++ ); ++ } ++ ++ #[test] ++ fn key_from_public_key() { ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let key = EcKey::generate(&group).unwrap(); ++ let mut ctx = BigNumContext::new().unwrap(); ++ let bytes = key.public_key() ++ .unwrap() ++ .to_bytes(&group, POINT_CONVERSION_COMPRESSED, &mut ctx) ++ .unwrap(); ++ ++ drop(key); ++ let public_key = EcPoint::from_bytes(&group, &bytes, &mut ctx).unwrap(); ++ let ec_key = EcKey::from_public_key(&group, &public_key).unwrap(); ++ assert!(ec_key.check_key().is_ok()); ++ assert!(ec_key.public_key().is_some()); ++ assert!(ec_key.private_key().is_none()); ++ } ++ ++ #[test] ++ fn key_from_affine_coordinates() { ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let x = data_encoding::base64url::decode_nopad( ++ "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4".as_bytes(), ++ ).unwrap(); ++ let y = data_encoding::base64url::decode_nopad( ++ "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM".as_bytes(), ++ ).unwrap(); ++ ++ let xbn = BigNum::from_slice(&x).unwrap(); ++ let ybn = BigNum::from_slice(&y).unwrap(); ++ ++ let mut builder = EcKeyBuilder::new().unwrap(); ++ builder.set_group(&group).unwrap(); ++ builder ++ .set_public_key_affine_coordinates(&xbn, &ybn) ++ .unwrap(); ++ ++ let ec_key = builder.build(); ++ assert!(ec_key.check_key().is_ok()); ++ assert!(ec_key.public_key().is_some()); ++ } ++ ++ #[test] ++ fn set_private_key() { ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let d = data_encoding::base64url::decode_nopad( ++ "870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE".as_bytes(), ++ ).unwrap(); ++ ++ let dbn = BigNum::from_slice(&d).unwrap(); ++ ++ let mut builder = EcKeyBuilder::new().unwrap(); ++ builder.set_group(&group).unwrap(); ++ builder.set_private_key(&dbn).unwrap(); ++ ++ let ec_key = builder.build(); ++ assert!(ec_key.private_key().is_some()); ++ } ++ ++ #[test] ++ fn get_affine_coordinates() { ++ let raw_x = "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4"; ++ let raw_y = "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM"; ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let x = data_encoding::base64url::decode_nopad(raw_x.as_bytes()).unwrap(); ++ let y = data_encoding::base64url::decode_nopad(raw_y.as_bytes()).unwrap(); ++ ++ let xbn = BigNum::from_slice(&x).unwrap(); ++ let ybn = BigNum::from_slice(&y).unwrap(); ++ ++ let mut builder = EcKeyBuilder::new().unwrap(); ++ builder.set_group(&group).unwrap(); ++ builder ++ .set_public_key_affine_coordinates(&xbn, &ybn) ++ .unwrap(); ++ ++ let ec_key = builder.build(); ++ ++ let mut xbn2 = BigNum::new().unwrap(); ++ let mut ybn2 = BigNum::new().unwrap(); ++ let mut ctx = BigNumContext::new().unwrap(); ++ let ec_key_pk = ec_key.public_key().unwrap(); ++ ec_key_pk ++ .affine_coordinates_gfp(&group, &mut xbn2, &mut ybn2, &mut ctx) ++ .unwrap(); ++ assert_eq!(xbn2, xbn); ++ assert_eq!(ybn2, ybn); ++ } ++} diff --cc vendor/openssl-0.9.19/src/ec_key.rs index 000000000,000000000..cb7c49960 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ec_key.rs @@@ -1,0 -1,0 +1,3 @@@ ++#![deprecated(since = "0.9.2", note = "renamed to `ec`")] ++ ++pub use ec::{EcKey, EcKeyRef}; diff --cc vendor/openssl-0.9.19/src/error.rs index 000000000,000000000..8612a9964 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/error.rs @@@ -1,0 -1,0 +1,227 @@@ ++use libc::{c_ulong, c_char, c_int}; ++use std::fmt; ++use std::error; ++use std::ffi::CStr; ++use std::io; ++use std::str; ++use std::ptr; ++use std::borrow::Cow; ++ ++use ffi; ++ ++#[derive(Debug, Clone)] ++pub struct ErrorStack(Vec); ++ ++impl ErrorStack { ++ /// Returns the contents of the OpenSSL error stack. ++ pub fn get() -> ErrorStack { ++ let mut vec = vec![]; ++ while let Some(err) = Error::get() { ++ vec.push(err); ++ } ++ ErrorStack(vec) ++ } ++} ++ ++impl ErrorStack { ++ /// Returns the errors in the stack. ++ pub fn errors(&self) -> &[Error] { ++ &self.0 ++ } ++} ++ ++impl fmt::Display for ErrorStack { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ let mut first = true; ++ for err in &self.0 { ++ if !first { ++ try!(fmt.write_str(", ")); ++ } ++ try!(write!(fmt, "{}", err)); ++ first = false; ++ } ++ Ok(()) ++ } ++} ++ ++impl error::Error for ErrorStack { ++ fn description(&self) -> &str { ++ "An OpenSSL error stack" ++ } ++} ++ ++impl From for io::Error { ++ fn from(e: ErrorStack) -> io::Error { ++ io::Error::new(io::ErrorKind::Other, e) ++ } ++} ++ ++impl From for fmt::Error { ++ fn from(_: ErrorStack) -> fmt::Error { ++ fmt::Error ++ } ++} ++ ++/// An error reported from OpenSSL. ++#[derive(Clone)] ++pub struct Error { ++ code: c_ulong, ++ file: *const c_char, ++ line: c_int, ++ data: Option>, ++} ++ ++unsafe impl Sync for Error {} ++unsafe impl Send for Error {} ++ ++impl Error { ++ /// Returns the first error on the OpenSSL error stack. ++ pub fn get() -> Option { ++ unsafe { ++ ffi::init(); ++ ++ let mut file = ptr::null(); ++ let mut line = 0; ++ let mut data = ptr::null(); ++ let mut flags = 0; ++ match ffi::ERR_get_error_line_data(&mut file, &mut line, &mut data, &mut flags) { ++ 0 => None, ++ code => { ++ // The memory referenced by data is only valid until that slot is overwritten ++ // in the error stack, so we'll need to copy it off if it's dynamic ++ let data = if flags & ffi::ERR_TXT_STRING != 0 { ++ let bytes = CStr::from_ptr(data as *const _).to_bytes(); ++ let data = str::from_utf8(bytes).unwrap(); ++ let data = if flags & ffi::ERR_TXT_MALLOCED != 0 { ++ Cow::Owned(data.to_string()) ++ } else { ++ Cow::Borrowed(data) ++ }; ++ Some(data) ++ } else { ++ None ++ }; ++ Some(Error { ++ code: code, ++ file: file, ++ line: line, ++ data: data, ++ }) ++ } ++ } ++ } ++ } ++ ++ /// Returns the raw OpenSSL error code for this error. ++ pub fn code(&self) -> c_ulong { ++ self.code ++ } ++ ++ /// Returns the name of the library reporting the error, if available. ++ pub fn library(&self) -> Option<&'static str> { ++ unsafe { ++ let cstr = ffi::ERR_lib_error_string(self.code); ++ if cstr.is_null() { ++ return None; ++ } ++ let bytes = CStr::from_ptr(cstr as *const _).to_bytes(); ++ Some(str::from_utf8(bytes).unwrap()) ++ } ++ } ++ ++ /// Returns the name of the function reporting the error. ++ pub fn function(&self) -> Option<&'static str> { ++ unsafe { ++ let cstr = ffi::ERR_func_error_string(self.code); ++ if cstr.is_null() { ++ return None; ++ } ++ let bytes = CStr::from_ptr(cstr as *const _).to_bytes(); ++ Some(str::from_utf8(bytes).unwrap()) ++ } ++ } ++ ++ /// Returns the reason for the error. ++ pub fn reason(&self) -> Option<&'static str> { ++ unsafe { ++ let cstr = ffi::ERR_reason_error_string(self.code); ++ if cstr.is_null() { ++ return None; ++ } ++ let bytes = CStr::from_ptr(cstr as *const _).to_bytes(); ++ Some(str::from_utf8(bytes).unwrap()) ++ } ++ } ++ ++ /// Returns the name of the source file which encountered the error. ++ pub fn file(&self) -> &'static str { ++ unsafe { ++ assert!(!self.file.is_null()); ++ let bytes = CStr::from_ptr(self.file as *const _).to_bytes(); ++ str::from_utf8(bytes).unwrap() ++ } ++ } ++ ++ /// Returns the line in the source file which encountered the error. ++ pub fn line(&self) -> c_int { ++ self.line ++ } ++ ++ /// Returns additional data describing the error. ++ pub fn data(&self) -> Option<&str> { ++ self.data.as_ref().map(|s| &**s) ++ } ++} ++ ++impl fmt::Debug for Error { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ let mut builder = fmt.debug_struct("Error"); ++ builder.field("code", &self.code()); ++ if let Some(library) = self.library() { ++ builder.field("library", &library); ++ } ++ if let Some(function) = self.function() { ++ builder.field("function", &function); ++ } ++ if let Some(reason) = self.reason() { ++ builder.field("reason", &reason); ++ } ++ builder.field("file", &self.file()); ++ builder.field("line", &self.line()); ++ if let Some(data) = self.data() { ++ builder.field("data", &data); ++ } ++ builder.finish() ++ } ++} ++ ++impl fmt::Display for Error { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ try!(write!(fmt, "error:{:08X}", self.code())); ++ match self.library() { ++ Some(l) => try!(write!(fmt, ":{}", l)), ++ None => try!(write!(fmt, ":lib({})", ffi::ERR_GET_LIB(self.code()))), ++ } ++ match self.function() { ++ Some(f) => try!(write!(fmt, ":{}", f)), ++ None => try!(write!(fmt, ":func({})", ffi::ERR_GET_FUNC(self.code()))), ++ } ++ match self.reason() { ++ Some(r) => try!(write!(fmt, ":{}", r)), ++ None => try!(write!(fmt, ":reason({})", ffi::ERR_GET_FUNC(self.code()))), ++ } ++ write!( ++ fmt, ++ ":{}:{}:{}", ++ self.file(), ++ self.line(), ++ self.data().unwrap_or("") ++ ) ++ } ++} ++ ++impl error::Error for Error { ++ fn description(&self) -> &str { ++ "an OpenSSL error" ++ } ++} diff --cc vendor/openssl-0.9.19/src/ex_data.rs index 000000000,000000000..450dd113f new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ex_data.rs @@@ -1,0 -1,0 +1,26 @@@ ++use libc::c_int; ++use std::marker::PhantomData; ++ ++/// A slot in a type's "extra data" structure. ++/// ++/// It is parameterized over the type containing the extra data as well as the ++/// type of the data in the slot. ++pub struct Index(c_int, PhantomData<(T, U)>); ++ ++impl Copy for Index {} ++ ++impl Clone for Index { ++ fn clone(&self) -> Index { ++ *self ++ } ++} ++ ++impl Index { ++ pub unsafe fn from_raw(idx: c_int) -> Index { ++ Index(idx, PhantomData) ++ } ++ ++ pub fn as_raw(&self) -> c_int { ++ self.0 ++ } ++} diff --cc vendor/openssl-0.9.19/src/hash.rs index 000000000,000000000..13161c695 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/hash.rs @@@ -1,0 -1,0 +1,407 @@@ ++use std::io::prelude::*; ++use std::io; ++use std::ops::{Deref, DerefMut}; ++use std::fmt; ++use ffi; ++ ++#[cfg(ossl110)] ++use ffi::{EVP_MD_CTX_new, EVP_MD_CTX_free}; ++#[cfg(any(ossl101, ossl102))] ++use ffi::{EVP_MD_CTX_create as EVP_MD_CTX_new, EVP_MD_CTX_destroy as EVP_MD_CTX_free}; ++ ++use {cvt, cvt_p}; ++use error::ErrorStack; ++ ++#[derive(Copy, Clone)] ++pub struct MessageDigest(*const ffi::EVP_MD); ++ ++impl MessageDigest { ++ pub fn md5() -> MessageDigest { ++ unsafe { MessageDigest(ffi::EVP_md5()) } ++ } ++ ++ pub fn sha1() -> MessageDigest { ++ unsafe { MessageDigest(ffi::EVP_sha1()) } ++ } ++ ++ pub fn sha224() -> MessageDigest { ++ unsafe { MessageDigest(ffi::EVP_sha224()) } ++ } ++ ++ pub fn sha256() -> MessageDigest { ++ unsafe { MessageDigest(ffi::EVP_sha256()) } ++ } ++ ++ pub fn sha384() -> MessageDigest { ++ unsafe { MessageDigest(ffi::EVP_sha384()) } ++ } ++ ++ pub fn sha512() -> MessageDigest { ++ unsafe { MessageDigest(ffi::EVP_sha512()) } ++ } ++ ++ pub fn ripemd160() -> MessageDigest { ++ unsafe { MessageDigest(ffi::EVP_ripemd160()) } ++ } ++ ++ pub fn as_ptr(&self) -> *const ffi::EVP_MD { ++ self.0 ++ } ++} ++ ++#[derive(PartialEq, Copy, Clone)] ++enum State { ++ Reset, ++ Updated, ++ Finalized, ++} ++ ++use self::State::*; ++ ++/// Provides message digest (hash) computation. ++/// ++/// # Examples ++/// ++/// Calculate a hash in one go: ++/// ++/// ``` ++/// use openssl::hash::{hash, MessageDigest}; ++/// ++/// let data = b"\x42\xF4\x97\xE0"; ++/// let spec = b"\x7c\x43\x0f\x17\x8a\xef\xdf\x14\x87\xfe\xe7\x14\x4e\x96\x41\xe2"; ++/// let res = hash(MessageDigest::md5(), data).unwrap(); ++/// assert_eq!(res, spec); ++/// ``` ++/// ++/// Supply the input in chunks: ++/// ++/// ``` ++/// use openssl::hash::{Hasher, MessageDigest}; ++/// ++/// let data = [b"\x42\xF4", b"\x97\xE0"]; ++/// let spec = b"\x7c\x43\x0f\x17\x8a\xef\xdf\x14\x87\xfe\xe7\x14\x4e\x96\x41\xe2"; ++/// let mut h = Hasher::new(MessageDigest::md5()).unwrap(); ++/// h.update(data[0]).unwrap(); ++/// h.update(data[1]).unwrap(); ++/// let res = h.finish().unwrap(); ++/// assert_eq!(res, spec); ++/// ``` ++/// ++/// # Warning ++/// ++/// Don't actually use MD5 and SHA-1 hashes, they're not secure anymore. ++/// ++/// Don't ever hash passwords, use the functions in the `pkcs5` module or bcrypt/scrypt instead. ++pub struct Hasher { ++ ctx: *mut ffi::EVP_MD_CTX, ++ md: *const ffi::EVP_MD, ++ type_: MessageDigest, ++ state: State, ++} ++ ++impl Hasher { ++ /// Creates a new `Hasher` with the specified hash type. ++ pub fn new(ty: MessageDigest) -> Result { ++ ffi::init(); ++ ++ let ctx = unsafe { try!(cvt_p(EVP_MD_CTX_new())) }; ++ ++ let mut h = Hasher { ++ ctx: ctx, ++ md: ty.as_ptr(), ++ type_: ty, ++ state: Finalized, ++ }; ++ try!(h.init()); ++ Ok(h) ++ } ++ ++ fn init(&mut self) -> Result<(), ErrorStack> { ++ match self.state { ++ Reset => return Ok(()), ++ Updated => { ++ try!(self.finish2()); ++ } ++ Finalized => (), ++ } ++ unsafe { ++ try!(cvt(ffi::EVP_DigestInit_ex(self.ctx, self.md, 0 as *mut _))); ++ } ++ self.state = Reset; ++ Ok(()) ++ } ++ ++ /// Feeds data into the hasher. ++ pub fn update(&mut self, data: &[u8]) -> Result<(), ErrorStack> { ++ if self.state == Finalized { ++ try!(self.init()); ++ } ++ unsafe { ++ try!(cvt(ffi::EVP_DigestUpdate( ++ self.ctx, ++ data.as_ptr() as *mut _, ++ data.len(), ++ ))); ++ } ++ self.state = Updated; ++ Ok(()) ++ } ++ ++ #[deprecated(note = "use finish2 instead", since = "0.9.11")] ++ pub fn finish(&mut self) -> Result, ErrorStack> { ++ self.finish2().map(|b| b.to_vec()) ++ } ++ ++ /// Returns the hash of the data written and resets the hasher. ++ /// ++ /// Unlike `finish`, this method does not allocate. ++ pub fn finish2(&mut self) -> Result { ++ if self.state == Finalized { ++ try!(self.init()); ++ } ++ unsafe { ++ let mut len = ffi::EVP_MAX_MD_SIZE; ++ let mut buf = [0; ffi::EVP_MAX_MD_SIZE as usize]; ++ try!(cvt(ffi::EVP_DigestFinal_ex( ++ self.ctx, ++ buf.as_mut_ptr(), ++ &mut len, ++ ))); ++ self.state = Finalized; ++ Ok(DigestBytes { ++ buf: buf, ++ len: len as usize, ++ }) ++ } ++ } ++} ++ ++impl Write for Hasher { ++ #[inline] ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ try!(self.update(buf)); ++ Ok(buf.len()) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ Ok(()) ++ } ++} ++ ++impl Clone for Hasher { ++ fn clone(&self) -> Hasher { ++ let ctx = unsafe { ++ let ctx = EVP_MD_CTX_new(); ++ assert!(!ctx.is_null()); ++ let r = ffi::EVP_MD_CTX_copy_ex(ctx, self.ctx); ++ assert_eq!(r, 1); ++ ctx ++ }; ++ Hasher { ++ ctx: ctx, ++ md: self.md, ++ type_: self.type_, ++ state: self.state, ++ } ++ } ++} ++ ++impl Drop for Hasher { ++ fn drop(&mut self) { ++ unsafe { ++ if self.state != Finalized { ++ drop(self.finish2()); ++ } ++ EVP_MD_CTX_free(self.ctx); ++ } ++ } ++} ++ ++/// The resulting bytes of a digest. ++/// ++/// This type derefs to a byte slice - it exists to avoid allocating memory to ++/// store the digest data. ++#[derive(Copy)] ++pub struct DigestBytes { ++ buf: [u8; ffi::EVP_MAX_MD_SIZE as usize], ++ len: usize, ++} ++ ++impl Clone for DigestBytes { ++ #[inline] ++ fn clone(&self) -> DigestBytes { ++ *self ++ } ++} ++ ++impl Deref for DigestBytes { ++ type Target = [u8]; ++ ++ #[inline] ++ fn deref(&self) -> &[u8] { ++ &self.buf[..self.len] ++ } ++} ++ ++impl DerefMut for DigestBytes { ++ #[inline] ++ fn deref_mut(&mut self) -> &mut [u8] { ++ &mut self.buf[..self.len] ++ } ++} ++ ++impl AsRef<[u8]> for DigestBytes { ++ #[inline] ++ fn as_ref(&self) -> &[u8] { ++ self.deref() ++ } ++} ++ ++impl fmt::Debug for DigestBytes { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ fmt::Debug::fmt(&**self, fmt) ++ } ++} ++ ++#[deprecated(note = "use hash2 instead", since = "0.9.11")] ++pub fn hash(t: MessageDigest, data: &[u8]) -> Result, ErrorStack> { ++ hash2(t, data).map(|b| b.to_vec()) ++} ++ ++/// Computes the hash of the `data` with the hash `t`. ++/// ++/// Unlike `hash`, this function does not allocate the return value. ++pub fn hash2(t: MessageDigest, data: &[u8]) -> Result { ++ let mut h = try!(Hasher::new(t)); ++ try!(h.update(data)); ++ h.finish2() ++} ++ ++#[cfg(test)] ++mod tests { ++ use hex::{FromHex, ToHex}; ++ use std::io::prelude::*; ++ ++ use super::*; ++ ++ fn hash_test(hashtype: MessageDigest, hashtest: &(&str, &str)) { ++ let res = hash2(hashtype, &Vec::from_hex(hashtest.0).unwrap()).unwrap(); ++ assert_eq!(res.to_hex(), hashtest.1); ++ } ++ ++ fn hash_recycle_test(h: &mut Hasher, hashtest: &(&str, &str)) { ++ let _ = h.write_all(&Vec::from_hex(hashtest.0).unwrap()).unwrap(); ++ let res = h.finish2().unwrap(); ++ assert_eq!(res.to_hex(), hashtest.1); ++ } ++ ++ // Test vectors from http://www.nsrl.nist.gov/testdata/ ++ #[allow(non_upper_case_globals)] ++ const md5_tests: [(&'static str, &'static str); 13] = ++ [ ++ ("", "d41d8cd98f00b204e9800998ecf8427e"), ++ ("7F", "83acb6e67e50e31db6ed341dd2de1595"), ++ ("EC9C", "0b07f0d4ca797d8ac58874f887cb0b68"), ++ ("FEE57A", "e0d583171eb06d56198fc0ef22173907"), ++ ("42F497E0", "7c430f178aefdf1487fee7144e9641e2"), ++ ("C53B777F1C", "75ef141d64cb37ec423da2d9d440c925"), ++ ("89D5B576327B", "ebbaf15eb0ed784c6faa9dc32831bf33"), ++ ("5D4CCE781EB190", "ce175c4b08172019f05e6b5279889f2c"), ++ ("81901FE94932D7B9", "cd4d2f62b8cdb3a0cf968a735a239281"), ++ ("C9FFDEE7788EFB4EC9", "e0841a231ab698db30c6c0f3f246c014"), ++ ("66AC4B7EBA95E53DC10B", "a3b3cea71910d9af56742aa0bb2fe329"), ++ ("A510CD18F7A56852EB0319", "577e216843dd11573574d3fb209b97d8"), ++ ( ++ "AAED18DBE8938C19ED734A8D", ++ "6f80fb775f27e0a4ce5c2f42fc72c5f1", ++ ), ++ ]; ++ ++ #[test] ++ fn test_md5() { ++ for test in md5_tests.iter() { ++ hash_test(MessageDigest::md5(), test); ++ } ++ } ++ ++ #[test] ++ fn test_md5_recycle() { ++ let mut h = Hasher::new(MessageDigest::md5()).unwrap(); ++ for test in md5_tests.iter() { ++ hash_recycle_test(&mut h, test); ++ } ++ } ++ ++ #[test] ++ fn test_finish_twice() { ++ let mut h = Hasher::new(MessageDigest::md5()).unwrap(); ++ h.write_all(&Vec::from_hex(md5_tests[6].0).unwrap()) ++ .unwrap(); ++ h.finish2().unwrap(); ++ let res = h.finish2().unwrap(); ++ let null = hash2(MessageDigest::md5(), &[]).unwrap(); ++ assert_eq!(&*res, &*null); ++ } ++ ++ #[test] ++ fn test_clone() { ++ let i = 7; ++ let inp = Vec::from_hex(md5_tests[i].0).unwrap(); ++ assert!(inp.len() > 2); ++ let p = inp.len() / 2; ++ let h0 = Hasher::new(MessageDigest::md5()).unwrap(); ++ ++ println!("Clone a new hasher"); ++ let mut h1 = h0.clone(); ++ h1.write_all(&inp[..p]).unwrap(); ++ { ++ println!("Clone an updated hasher"); ++ let mut h2 = h1.clone(); ++ h2.write_all(&inp[p..]).unwrap(); ++ let res = h2.finish2().unwrap(); ++ assert_eq!(res.to_hex(), md5_tests[i].1); ++ } ++ h1.write_all(&inp[p..]).unwrap(); ++ let res = h1.finish2().unwrap(); ++ assert_eq!(res.to_hex(), md5_tests[i].1); ++ ++ println!("Clone a finished hasher"); ++ let mut h3 = h1.clone(); ++ h3.write_all(&Vec::from_hex(md5_tests[i + 1].0).unwrap()) ++ .unwrap(); ++ let res = h3.finish2().unwrap(); ++ assert_eq!(res.to_hex(), md5_tests[i + 1].1); ++ } ++ ++ #[test] ++ fn test_sha1() { ++ let tests = [("616263", "a9993e364706816aba3e25717850c26c9cd0d89d")]; ++ ++ for test in tests.iter() { ++ hash_test(MessageDigest::sha1(), test); ++ } ++ } ++ ++ #[test] ++ fn test_sha256() { ++ let tests = [ ++ ( ++ "616263", ++ "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", ++ ), ++ ]; ++ ++ for test in tests.iter() { ++ hash_test(MessageDigest::sha256(), test); ++ } ++ } ++ ++ #[test] ++ fn test_ripemd160() { ++ let tests = [("616263", "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc")]; ++ ++ for test in tests.iter() { ++ hash_test(MessageDigest::ripemd160(), test); ++ } ++ } ++} diff --cc vendor/openssl-0.9.19/src/lib.rs index 000000000,000000000..a6b7885c8 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/lib.rs @@@ -1,0 -1,0 +1,83 @@@ ++#![doc(html_root_url="https://docs.rs/openssl/0.9")] ++ ++#[macro_use] ++extern crate bitflags; ++#[macro_use] ++extern crate foreign_types; ++extern crate libc; ++#[macro_use] ++extern crate lazy_static; ++extern crate openssl_sys as ffi; ++ ++#[cfg(test)] ++extern crate hex; ++#[cfg(test)] ++extern crate tempdir; ++#[cfg(test)] ++extern crate data_encoding; ++ ++#[doc(inline)] ++pub use ffi::init; ++ ++use libc::c_int; ++ ++use error::ErrorStack; ++ ++#[macro_use] ++mod macros; ++ ++mod bio; ++mod util; ++pub mod aes; ++pub mod asn1; ++pub mod bn; ++#[cfg(not(libressl))] ++pub mod cms; ++pub mod conf; ++pub mod crypto; ++pub mod dh; ++pub mod dsa; ++pub mod ec; ++pub mod ec_key; ++pub mod error; ++pub mod ex_data; ++pub mod hash; ++pub mod memcmp; ++pub mod nid; ++pub mod ocsp; ++pub mod pkcs12; ++pub mod pkcs5; ++pub mod pkey; ++pub mod rand; ++pub mod rsa; ++pub mod sign; ++pub mod sha; ++pub mod ssl; ++pub mod stack; ++pub mod string; ++pub mod symm; ++pub mod types; ++pub mod version; ++pub mod x509; ++#[cfg(any(ossl102, ossl110))] ++mod verify; ++ ++fn cvt_p(r: *mut T) -> Result<*mut T, ErrorStack> { ++ if r.is_null() { ++ Err(ErrorStack::get()) ++ } else { ++ Ok(r) ++ } ++} ++ ++fn cvt(r: c_int) -> Result { ++ if r <= 0 { ++ Err(ErrorStack::get()) ++ } else { ++ Ok(r) ++ } ++} ++ ++fn cvt_n(r: c_int) -> Result { ++ if r < 0 { Err(ErrorStack::get()) } else { Ok(r) } ++} diff --cc vendor/openssl-0.9.19/src/macros.rs index 000000000,000000000..b2fe0c18a new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/macros.rs @@@ -1,0 -1,0 +1,216 @@@ ++ ++macro_rules! private_key_from_pem { ++ ($t:ident, $f:path) => { ++ from_pem_inner!(/// Deserializes a PEM-formatted private key. ++ private_key_from_pem, $t, $f); ++ ++ /// Deserializes a PEM-formatted private key, using the supplied password if the key is ++ /// encrypted. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `passphrase` contains an embedded null. ++ pub fn private_key_from_pem_passphrase(pem: &[u8], ++ passphrase: &[u8]) ++ -> Result<$t, ::error::ErrorStack> { ++ unsafe { ++ ffi::init(); ++ let bio = try!(::bio::MemBioSlice::new(pem)); ++ let passphrase = ::std::ffi::CString::new(passphrase).unwrap(); ++ cvt_p($f(bio.as_ptr(), ++ ptr::null_mut(), ++ None, ++ passphrase.as_ptr() as *const _ as *mut _)) ++ .map($t) ++ } ++ } ++ ++ /// Deserializes a PEM-formatted private key, using a callback to retrieve a password if the ++ /// key is encrypted. ++ /// ++ /// The callback should copy the password into the provided buffer and return the number of ++ /// bytes written. ++ pub fn private_key_from_pem_callback(pem: &[u8], ++ callback: F) ++ -> Result<$t, ::error::ErrorStack> ++ where F: FnOnce(&mut [u8]) -> Result ++ { ++ unsafe { ++ ffi::init(); ++ let mut cb = ::util::CallbackState::new(callback); ++ let bio = try!(::bio::MemBioSlice::new(pem)); ++ cvt_p($f(bio.as_ptr(), ++ ptr::null_mut(), ++ Some(::util::invoke_passwd_cb::), ++ &mut cb as *mut _ as *mut _)) ++ .map($t) ++ } ++ } ++ } ++} ++ ++macro_rules! private_key_to_pem { ++ ($f:path) => { ++ /// Serializes the private key to PEM. ++ pub fn private_key_to_pem(&self) -> Result, ::error::ErrorStack> { ++ unsafe { ++ let bio = try!(::bio::MemBio::new()); ++ try!(cvt($f(bio.as_ptr(), ++ self.as_ptr(), ++ ptr::null(), ++ ptr::null_mut(), ++ -1, ++ None, ++ ptr::null_mut()))); ++ Ok(bio.get_buf().to_owned()) ++ } ++ } ++ ++ /// Serializes the private key to PEM, encrypting it with the specified symmetric cipher and ++ /// passphrase. ++ pub fn private_key_to_pem_passphrase(&self, ++ cipher: ::symm::Cipher, ++ passphrase: &[u8]) ++ -> Result, ::error::ErrorStack> { ++ unsafe { ++ let bio = try!(::bio::MemBio::new()); ++ assert!(passphrase.len() <= ::libc::c_int::max_value() as usize); ++ try!(cvt($f(bio.as_ptr(), ++ self.as_ptr(), ++ cipher.as_ptr(), ++ passphrase.as_ptr() as *const _ as *mut _, ++ passphrase.len() as ::libc::c_int, ++ None, ++ ptr::null_mut()))); ++ Ok(bio.get_buf().to_owned()) ++ } ++ } ++ } ++} ++ ++macro_rules! to_pem_inner { ++ (#[$m:meta] $n:ident, $f:path) => { ++ #[$m] ++ pub fn $n(&self) -> Result, ::error::ErrorStack> { ++ unsafe { ++ let bio = try!(::bio::MemBio::new()); ++ try!(cvt($f(bio.as_ptr(), self.as_ptr()))); ++ Ok(bio.get_buf().to_owned()) ++ } ++ } ++ } ++} ++ ++macro_rules! public_key_to_pem { ++ ($f:path) => { ++ to_pem_inner!(/// Serializes a public key to PEM. ++ public_key_to_pem, $f); ++ } ++} ++ ++macro_rules! to_pem { ++ ($f:path) => { ++ to_pem_inner!(/// Serializes this value to PEM. ++ to_pem, $f); ++ } ++} ++ ++macro_rules! to_der_inner { ++ (#[$m:meta] $n:ident, $f:path) => { ++ #[$m] ++ pub fn $n(&self) -> Result, ::error::ErrorStack> { ++ unsafe { ++ let len = try!(::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), ++ ptr::null_mut()))); ++ let mut buf = vec![0; len as usize]; ++ try!(::cvt($f(::foreign_types::ForeignTypeRef::as_ptr(self), ++ &mut buf.as_mut_ptr()))); ++ Ok(buf) ++ } ++ } ++ }; ++} ++ ++macro_rules! to_der { ++ ($f:path) => { ++ to_der_inner!(/// Serializes this value to DER. ++ to_der, $f); ++ } ++} ++ ++macro_rules! private_key_to_der { ++ ($f:path) => { ++ to_der_inner!(/// Serializes the private key to DER. ++ private_key_to_der, $f); ++ } ++} ++ ++macro_rules! public_key_to_der { ++ ($f:path) => { ++ to_der_inner!(/// Serializes the public key to DER. ++ public_key_to_der, $f); ++ } ++} ++ ++macro_rules! from_der_inner { ++ (#[$m:meta] $n:ident, $t:ident, $f:path) => { ++ #[$m] ++ pub fn $n(der: &[u8]) -> Result<$t, ::error::ErrorStack> { ++ unsafe { ++ ::ffi::init(); ++ let len = ::std::cmp::min(der.len(), ::libc::c_long::max_value() as usize) as ::libc::c_long; ++ ::cvt_p($f(::std::ptr::null_mut(), &mut der.as_ptr(), len)) ++ .map($t) ++ } ++ } ++ } ++} ++ ++macro_rules! from_der { ++ ($t:ident, $f:path) => { ++ from_der_inner!(/// Deserializes a value from DER-formatted data. ++ from_der, $t, $f); ++ } ++} ++ ++macro_rules! private_key_from_der { ++ ($t:ident, $f:path) => { ++ from_der_inner!(/// Deserializes a private key from DER-formatted data. ++ private_key_from_der, $t, $f); ++ } ++} ++ ++macro_rules! public_key_from_der { ++ ($t:ident, $f:path) => { ++ from_der_inner!(/// Deserializes a public key from DER-formatted data. ++ public_key_from_der, $t, $f); ++ } ++} ++ ++macro_rules! from_pem_inner { ++ (#[$m:meta] $n:ident, $t:ident, $f:path) => { ++ #[$m] ++ pub fn $n(pem: &[u8]) -> Result<$t, ::error::ErrorStack> { ++ unsafe { ++ ::init(); ++ let bio = try!(::bio::MemBioSlice::new(pem)); ++ cvt_p($f(bio.as_ptr(), ::std::ptr::null_mut(), None, ::std::ptr::null_mut())) ++ .map($t) ++ } ++ } ++ } ++} ++ ++macro_rules! public_key_from_pem { ++ ($t:ident, $f:path) => { ++ from_pem_inner!(/// Deserializes a public key from PEM-formatted data. ++ public_key_from_pem, $t, $f); ++ } ++} ++ ++macro_rules! from_pem { ++ ($t:ident, $f:path) => { ++ from_pem_inner!(/// Deserializes a value from PEM-formatted data. ++ from_pem, $t, $f); ++ } ++} diff --cc vendor/openssl-0.9.19/src/memcmp.rs index 000000000,000000000..0ca12c86d new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/memcmp.rs @@@ -1,0 -1,0 +1,41 @@@ ++use libc::size_t; ++use ffi; ++ ++/// Returns `true` iff `a` and `b` contain the same bytes. ++/// ++/// This operation takes an amount of time dependent on the length of the two ++/// arrays given, but is independent of the contents of a and b. ++/// ++/// # Panics ++/// ++/// This function will panic the current task if `a` and `b` do not have the same ++/// length. ++pub fn eq(a: &[u8], b: &[u8]) -> bool { ++ assert!(a.len() == b.len()); ++ let ret = unsafe { ++ ffi::CRYPTO_memcmp( ++ a.as_ptr() as *const _, ++ b.as_ptr() as *const _, ++ a.len() as size_t, ++ ) ++ }; ++ ret == 0 ++} ++ ++#[cfg(test)] ++mod tests { ++ use super::eq; ++ ++ #[test] ++ fn test_eq() { ++ assert!(eq(&[], &[])); ++ assert!(eq(&[1], &[1])); ++ assert!(!eq(&[1, 2, 3], &[1, 2, 4])); ++ } ++ ++ #[test] ++ #[should_panic] ++ fn test_diff_lens() { ++ eq(&[], &[1]); ++ } ++} diff --cc vendor/openssl-0.9.19/src/nid.rs index 000000000,000000000..afbd60a5b new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/nid.rs @@@ -1,0 -1,0 +1,954 @@@ ++use ffi; ++use libc::c_int; ++ ++#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] ++pub struct Nid(c_int); ++ ++#[allow(non_snake_case)] ++impl Nid { ++ pub fn from_raw(raw: c_int) -> Nid { ++ Nid(raw) ++ } ++ ++ pub fn as_raw(&self) -> c_int { ++ self.0 ++ } ++} ++ ++pub const UNDEF: Nid = Nid(ffi::NID_undef); ++pub const ITU_T: Nid = Nid(ffi::NID_itu_t); ++pub const CCITT: Nid = Nid(ffi::NID_ccitt); ++pub const ISO: Nid = Nid(ffi::NID_iso); ++pub const JOINT_ISO_ITU_T: Nid = Nid(ffi::NID_joint_iso_itu_t); ++pub const JOINT_ISO_CCITT: Nid = Nid(ffi::NID_joint_iso_ccitt); ++pub const MEMBER_BODY: Nid = Nid(ffi::NID_member_body); ++pub const IDENTIFIED_ORGANIZATION: Nid = Nid(ffi::NID_identified_organization); ++pub const HMAC_MD5: Nid = Nid(ffi::NID_hmac_md5); ++pub const HMAC_SHA1: Nid = Nid(ffi::NID_hmac_sha1); ++pub const CERTICOM_ARC: Nid = Nid(ffi::NID_certicom_arc); ++pub const INTERNATIONAL_ORGANIZATIONS: Nid = Nid(ffi::NID_international_organizations); ++pub const WAP: Nid = Nid(ffi::NID_wap); ++pub const WAP_WSG: Nid = Nid(ffi::NID_wap_wsg); ++pub const SELECTED_ATTRIBUTE_TYPES: Nid = Nid(ffi::NID_selected_attribute_types); ++pub const CLEARANCE: Nid = Nid(ffi::NID_clearance); ++pub const ISO_US: Nid = Nid(ffi::NID_ISO_US); ++pub const X9_57: Nid = Nid(ffi::NID_X9_57); ++pub const X9CM: Nid = Nid(ffi::NID_X9cm); ++pub const DSA: Nid = Nid(ffi::NID_dsa); ++pub const DSAWITHSHA1: Nid = Nid(ffi::NID_dsaWithSHA1); ++pub const ANSI_X9_62: Nid = Nid(ffi::NID_ansi_X9_62); ++pub const X9_62_PRIME_FIELD: Nid = Nid(ffi::NID_X9_62_prime_field); ++pub const X9_62_CHARACTERISTIC_TWO_FIELD: Nid = Nid(ffi::NID_X9_62_characteristic_two_field); ++pub const X9_62_ID_CHARACTERISTIC_TWO_BASIS: Nid = Nid(ffi::NID_X9_62_id_characteristic_two_basis); ++pub const X9_62_ONBASIS: Nid = Nid(ffi::NID_X9_62_onBasis); ++pub const X9_62_TPBASIS: Nid = Nid(ffi::NID_X9_62_tpBasis); ++pub const X9_62_PPBASIS: Nid = Nid(ffi::NID_X9_62_ppBasis); ++pub const X9_62_ID_ECPUBLICKEY: Nid = Nid(ffi::NID_X9_62_id_ecPublicKey); ++pub const X9_62_C2PNB163V1: Nid = Nid(ffi::NID_X9_62_c2pnb163v1); ++pub const X9_62_C2PNB163V2: Nid = Nid(ffi::NID_X9_62_c2pnb163v2); ++pub const X9_62_C2PNB163V3: Nid = Nid(ffi::NID_X9_62_c2pnb163v3); ++pub const X9_62_C2PNB176V1: Nid = Nid(ffi::NID_X9_62_c2pnb176v1); ++pub const X9_62_C2TNB191V1: Nid = Nid(ffi::NID_X9_62_c2tnb191v1); ++pub const X9_62_C2TNB191V2: Nid = Nid(ffi::NID_X9_62_c2tnb191v2); ++pub const X9_62_C2TNB191V3: Nid = Nid(ffi::NID_X9_62_c2tnb191v3); ++pub const X9_62_C2ONB191V4: Nid = Nid(ffi::NID_X9_62_c2onb191v4); ++pub const X9_62_C2ONB191V5: Nid = Nid(ffi::NID_X9_62_c2onb191v5); ++pub const X9_62_C2PNB208W1: Nid = Nid(ffi::NID_X9_62_c2pnb208w1); ++pub const X9_62_C2TNB239V1: Nid = Nid(ffi::NID_X9_62_c2tnb239v1); ++pub const X9_62_C2TNB239V2: Nid = Nid(ffi::NID_X9_62_c2tnb239v2); ++pub const X9_62_C2TNB239V3: Nid = Nid(ffi::NID_X9_62_c2tnb239v3); ++pub const X9_62_C2ONB239V4: Nid = Nid(ffi::NID_X9_62_c2onb239v4); ++pub const X9_62_C2ONB239V5: Nid = Nid(ffi::NID_X9_62_c2onb239v5); ++pub const X9_62_C2PNB272W1: Nid = Nid(ffi::NID_X9_62_c2pnb272w1); ++pub const X9_62_C2PNB304W1: Nid = Nid(ffi::NID_X9_62_c2pnb304w1); ++pub const X9_62_C2TNB359V1: Nid = Nid(ffi::NID_X9_62_c2tnb359v1); ++pub const X9_62_C2PNB368W1: Nid = Nid(ffi::NID_X9_62_c2pnb368w1); ++pub const X9_62_C2TNB431R1: Nid = Nid(ffi::NID_X9_62_c2tnb431r1); ++pub const X9_62_PRIME192V1: Nid = Nid(ffi::NID_X9_62_prime192v1); ++pub const X9_62_PRIME192V2: Nid = Nid(ffi::NID_X9_62_prime192v2); ++pub const X9_62_PRIME192V3: Nid = Nid(ffi::NID_X9_62_prime192v3); ++pub const X9_62_PRIME239V1: Nid = Nid(ffi::NID_X9_62_prime239v1); ++pub const X9_62_PRIME239V2: Nid = Nid(ffi::NID_X9_62_prime239v2); ++pub const X9_62_PRIME239V3: Nid = Nid(ffi::NID_X9_62_prime239v3); ++pub const X9_62_PRIME256V1: Nid = Nid(ffi::NID_X9_62_prime256v1); ++pub const ECDSA_WITH_SHA1: Nid = Nid(ffi::NID_ecdsa_with_SHA1); ++pub const ECDSA_WITH_RECOMMENDED: Nid = Nid(ffi::NID_ecdsa_with_Recommended); ++pub const ECDSA_WITH_SPECIFIED: Nid = Nid(ffi::NID_ecdsa_with_Specified); ++pub const ECDSA_WITH_SHA224: Nid = Nid(ffi::NID_ecdsa_with_SHA224); ++pub const ECDSA_WITH_SHA256: Nid = Nid(ffi::NID_ecdsa_with_SHA256); ++pub const ECDSA_WITH_SHA384: Nid = Nid(ffi::NID_ecdsa_with_SHA384); ++pub const ECDSA_WITH_SHA512: Nid = Nid(ffi::NID_ecdsa_with_SHA512); ++pub const SECP112R1: Nid = Nid(ffi::NID_secp112r1); ++pub const SECP112R2: Nid = Nid(ffi::NID_secp112r2); ++pub const SECP128R1: Nid = Nid(ffi::NID_secp128r1); ++pub const SECP128R2: Nid = Nid(ffi::NID_secp128r2); ++pub const SECP160K1: Nid = Nid(ffi::NID_secp160k1); ++pub const SECP160R1: Nid = Nid(ffi::NID_secp160r1); ++pub const SECP160R2: Nid = Nid(ffi::NID_secp160r2); ++pub const SECP192K1: Nid = Nid(ffi::NID_secp192k1); ++pub const SECP224K1: Nid = Nid(ffi::NID_secp224k1); ++pub const SECP224R1: Nid = Nid(ffi::NID_secp224r1); ++pub const SECP256K1: Nid = Nid(ffi::NID_secp256k1); ++pub const SECP384R1: Nid = Nid(ffi::NID_secp384r1); ++pub const SECP521R1: Nid = Nid(ffi::NID_secp521r1); ++pub const SECT113R1: Nid = Nid(ffi::NID_sect113r1); ++pub const SECT113R2: Nid = Nid(ffi::NID_sect113r2); ++pub const SECT131R1: Nid = Nid(ffi::NID_sect131r1); ++pub const SECT131R2: Nid = Nid(ffi::NID_sect131r2); ++pub const SECT163K1: Nid = Nid(ffi::NID_sect163k1); ++pub const SECT163R1: Nid = Nid(ffi::NID_sect163r1); ++pub const SECT163R2: Nid = Nid(ffi::NID_sect163r2); ++pub const SECT193R1: Nid = Nid(ffi::NID_sect193r1); ++pub const SECT193R2: Nid = Nid(ffi::NID_sect193r2); ++pub const SECT233K1: Nid = Nid(ffi::NID_sect233k1); ++pub const SECT233R1: Nid = Nid(ffi::NID_sect233r1); ++pub const SECT239K1: Nid = Nid(ffi::NID_sect239k1); ++pub const SECT283K1: Nid = Nid(ffi::NID_sect283k1); ++pub const SECT283R1: Nid = Nid(ffi::NID_sect283r1); ++pub const SECT409K1: Nid = Nid(ffi::NID_sect409k1); ++pub const SECT409R1: Nid = Nid(ffi::NID_sect409r1); ++pub const SECT571K1: Nid = Nid(ffi::NID_sect571k1); ++pub const SECT571R1: Nid = Nid(ffi::NID_sect571r1); ++pub const WAP_WSG_IDM_ECID_WTLS1: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls1); ++pub const WAP_WSG_IDM_ECID_WTLS3: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls3); ++pub const WAP_WSG_IDM_ECID_WTLS4: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls4); ++pub const WAP_WSG_IDM_ECID_WTLS5: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls5); ++pub const WAP_WSG_IDM_ECID_WTLS6: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls6); ++pub const WAP_WSG_IDM_ECID_WTLS7: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls7); ++pub const WAP_WSG_IDM_ECID_WTLS8: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls8); ++pub const WAP_WSG_IDM_ECID_WTLS9: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls9); ++pub const WAP_WSG_IDM_ECID_WTLS10: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls10); ++pub const WAP_WSG_IDM_ECID_WTLS11: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls11); ++pub const WAP_WSG_IDM_ECID_WTLS12: Nid = Nid(ffi::NID_wap_wsg_idm_ecid_wtls12); ++pub const CAST5_CBC: Nid = Nid(ffi::NID_cast5_cbc); ++pub const CAST5_ECB: Nid = Nid(ffi::NID_cast5_ecb); ++pub const CAST5_CFB64: Nid = Nid(ffi::NID_cast5_cfb64); ++pub const CAST5_OFB64: Nid = Nid(ffi::NID_cast5_ofb64); ++pub const PBEWITHMD5ANDCAST5_CBC: Nid = Nid(ffi::NID_pbeWithMD5AndCast5_CBC); ++pub const ID_PASSWORDBASEDMAC: Nid = Nid(ffi::NID_id_PasswordBasedMAC); ++pub const ID_DHBASEDMAC: Nid = Nid(ffi::NID_id_DHBasedMac); ++pub const RSADSI: Nid = Nid(ffi::NID_rsadsi); ++pub const PKCS: Nid = Nid(ffi::NID_pkcs); ++pub const PKCS1: Nid = Nid(ffi::NID_pkcs1); ++pub const RSAENCRYPTION: Nid = Nid(ffi::NID_rsaEncryption); ++pub const MD2WITHRSAENCRYPTION: Nid = Nid(ffi::NID_md2WithRSAEncryption); ++pub const MD4WITHRSAENCRYPTION: Nid = Nid(ffi::NID_md4WithRSAEncryption); ++pub const MD5WITHRSAENCRYPTION: Nid = Nid(ffi::NID_md5WithRSAEncryption); ++pub const SHA1WITHRSAENCRYPTION: Nid = Nid(ffi::NID_sha1WithRSAEncryption); ++pub const RSAESOAEP: Nid = Nid(ffi::NID_rsaesOaep); ++pub const MGF1: Nid = Nid(ffi::NID_mgf1); ++pub const RSASSAPSS: Nid = Nid(ffi::NID_rsassaPss); ++pub const SHA256WITHRSAENCRYPTION: Nid = Nid(ffi::NID_sha256WithRSAEncryption); ++pub const SHA384WITHRSAENCRYPTION: Nid = Nid(ffi::NID_sha384WithRSAEncryption); ++pub const SHA512WITHRSAENCRYPTION: Nid = Nid(ffi::NID_sha512WithRSAEncryption); ++pub const SHA224WITHRSAENCRYPTION: Nid = Nid(ffi::NID_sha224WithRSAEncryption); ++pub const PKCS3: Nid = Nid(ffi::NID_pkcs3); ++pub const DHKEYAGREEMENT: Nid = Nid(ffi::NID_dhKeyAgreement); ++pub const PKCS5: Nid = Nid(ffi::NID_pkcs5); ++pub const PBEWITHMD2ANDDES_CBC: Nid = Nid(ffi::NID_pbeWithMD2AndDES_CBC); ++pub const PBEWITHMD5ANDDES_CBC: Nid = Nid(ffi::NID_pbeWithMD5AndDES_CBC); ++pub const PBEWITHMD2ANDRC2_CBC: Nid = Nid(ffi::NID_pbeWithMD2AndRC2_CBC); ++pub const PBEWITHMD5ANDRC2_CBC: Nid = Nid(ffi::NID_pbeWithMD5AndRC2_CBC); ++pub const PBEWITHSHA1ANDDES_CBC: Nid = Nid(ffi::NID_pbeWithSHA1AndDES_CBC); ++pub const PBEWITHSHA1ANDRC2_CBC: Nid = Nid(ffi::NID_pbeWithSHA1AndRC2_CBC); ++pub const ID_PBKDF2: Nid = Nid(ffi::NID_id_pbkdf2); ++pub const PBES2: Nid = Nid(ffi::NID_pbes2); ++pub const PBMAC1: Nid = Nid(ffi::NID_pbmac1); ++pub const PKCS7: Nid = Nid(ffi::NID_pkcs7); ++pub const PKCS7_DATA: Nid = Nid(ffi::NID_pkcs7_data); ++pub const PKCS7_SIGNED: Nid = Nid(ffi::NID_pkcs7_signed); ++pub const PKCS7_ENVELOPED: Nid = Nid(ffi::NID_pkcs7_enveloped); ++pub const PKCS7_SIGNEDANDENVELOPED: Nid = Nid(ffi::NID_pkcs7_signedAndEnveloped); ++pub const PKCS7_DIGEST: Nid = Nid(ffi::NID_pkcs7_digest); ++pub const PKCS7_ENCRYPTED: Nid = Nid(ffi::NID_pkcs7_encrypted); ++pub const PKCS9: Nid = Nid(ffi::NID_pkcs9); ++pub const PKCS9_EMAILADDRESS: Nid = Nid(ffi::NID_pkcs9_emailAddress); ++pub const PKCS9_UNSTRUCTUREDNAME: Nid = Nid(ffi::NID_pkcs9_unstructuredName); ++pub const PKCS9_CONTENTTYPE: Nid = Nid(ffi::NID_pkcs9_contentType); ++pub const PKCS9_MESSAGEDIGEST: Nid = Nid(ffi::NID_pkcs9_messageDigest); ++pub const PKCS9_SIGNINGTIME: Nid = Nid(ffi::NID_pkcs9_signingTime); ++pub const PKCS9_COUNTERSIGNATURE: Nid = Nid(ffi::NID_pkcs9_countersignature); ++pub const PKCS9_CHALLENGEPASSWORD: Nid = Nid(ffi::NID_pkcs9_challengePassword); ++pub const PKCS9_UNSTRUCTUREDADDRESS: Nid = Nid(ffi::NID_pkcs9_unstructuredAddress); ++pub const PKCS9_EXTCERTATTRIBUTES: Nid = Nid(ffi::NID_pkcs9_extCertAttributes); ++pub const EXT_REQ: Nid = Nid(ffi::NID_ext_req); ++pub const SMIMECAPABILITIES: Nid = Nid(ffi::NID_SMIMECapabilities); ++pub const SMIME: Nid = Nid(ffi::NID_SMIME); ++pub const ID_SMIME_MOD: Nid = Nid(ffi::NID_id_smime_mod); ++pub const ID_SMIME_CT: Nid = Nid(ffi::NID_id_smime_ct); ++pub const ID_SMIME_AA: Nid = Nid(ffi::NID_id_smime_aa); ++pub const ID_SMIME_ALG: Nid = Nid(ffi::NID_id_smime_alg); ++pub const ID_SMIME_CD: Nid = Nid(ffi::NID_id_smime_cd); ++pub const ID_SMIME_SPQ: Nid = Nid(ffi::NID_id_smime_spq); ++pub const ID_SMIME_CTI: Nid = Nid(ffi::NID_id_smime_cti); ++pub const ID_SMIME_MOD_CMS: Nid = Nid(ffi::NID_id_smime_mod_cms); ++pub const ID_SMIME_MOD_ESS: Nid = Nid(ffi::NID_id_smime_mod_ess); ++pub const ID_SMIME_MOD_OID: Nid = Nid(ffi::NID_id_smime_mod_oid); ++pub const ID_SMIME_MOD_MSG_V3: Nid = Nid(ffi::NID_id_smime_mod_msg_v3); ++pub const ID_SMIME_MOD_ETS_ESIGNATURE_88: Nid = Nid(ffi::NID_id_smime_mod_ets_eSignature_88); ++pub const ID_SMIME_MOD_ETS_ESIGNATURE_97: Nid = Nid(ffi::NID_id_smime_mod_ets_eSignature_97); ++pub const ID_SMIME_MOD_ETS_ESIGPOLICY_88: Nid = Nid(ffi::NID_id_smime_mod_ets_eSigPolicy_88); ++pub const ID_SMIME_MOD_ETS_ESIGPOLICY_97: Nid = Nid(ffi::NID_id_smime_mod_ets_eSigPolicy_97); ++pub const ID_SMIME_CT_RECEIPT: Nid = Nid(ffi::NID_id_smime_ct_receipt); ++pub const ID_SMIME_CT_AUTHDATA: Nid = Nid(ffi::NID_id_smime_ct_authData); ++pub const ID_SMIME_CT_PUBLISHCERT: Nid = Nid(ffi::NID_id_smime_ct_publishCert); ++pub const ID_SMIME_CT_TSTINFO: Nid = Nid(ffi::NID_id_smime_ct_TSTInfo); ++pub const ID_SMIME_CT_TDTINFO: Nid = Nid(ffi::NID_id_smime_ct_TDTInfo); ++pub const ID_SMIME_CT_CONTENTINFO: Nid = Nid(ffi::NID_id_smime_ct_contentInfo); ++pub const ID_SMIME_CT_DVCSREQUESTDATA: Nid = Nid(ffi::NID_id_smime_ct_DVCSRequestData); ++pub const ID_SMIME_CT_DVCSRESPONSEDATA: Nid = Nid(ffi::NID_id_smime_ct_DVCSResponseData); ++pub const ID_SMIME_CT_COMPRESSEDDATA: Nid = Nid(ffi::NID_id_smime_ct_compressedData); ++pub const ID_CT_ASCIITEXTWITHCRLF: Nid = Nid(ffi::NID_id_ct_asciiTextWithCRLF); ++pub const ID_SMIME_AA_RECEIPTREQUEST: Nid = Nid(ffi::NID_id_smime_aa_receiptRequest); ++pub const ID_SMIME_AA_SECURITYLABEL: Nid = Nid(ffi::NID_id_smime_aa_securityLabel); ++pub const ID_SMIME_AA_MLEXPANDHISTORY: Nid = Nid(ffi::NID_id_smime_aa_mlExpandHistory); ++pub const ID_SMIME_AA_CONTENTHINT: Nid = Nid(ffi::NID_id_smime_aa_contentHint); ++pub const ID_SMIME_AA_MSGSIGDIGEST: Nid = Nid(ffi::NID_id_smime_aa_msgSigDigest); ++pub const ID_SMIME_AA_ENCAPCONTENTTYPE: Nid = Nid(ffi::NID_id_smime_aa_encapContentType); ++pub const ID_SMIME_AA_CONTENTIDENTIFIER: Nid = Nid(ffi::NID_id_smime_aa_contentIdentifier); ++pub const ID_SMIME_AA_MACVALUE: Nid = Nid(ffi::NID_id_smime_aa_macValue); ++pub const ID_SMIME_AA_EQUIVALENTLABELS: Nid = Nid(ffi::NID_id_smime_aa_equivalentLabels); ++pub const ID_SMIME_AA_CONTENTREFERENCE: Nid = Nid(ffi::NID_id_smime_aa_contentReference); ++pub const ID_SMIME_AA_ENCRYPKEYPREF: Nid = Nid(ffi::NID_id_smime_aa_encrypKeyPref); ++pub const ID_SMIME_AA_SIGNINGCERTIFICATE: Nid = Nid(ffi::NID_id_smime_aa_signingCertificate); ++pub const ID_SMIME_AA_SMIMEENCRYPTCERTS: Nid = Nid(ffi::NID_id_smime_aa_smimeEncryptCerts); ++pub const ID_SMIME_AA_TIMESTAMPTOKEN: Nid = Nid(ffi::NID_id_smime_aa_timeStampToken); ++pub const ID_SMIME_AA_ETS_SIGPOLICYID: Nid = Nid(ffi::NID_id_smime_aa_ets_sigPolicyId); ++pub const ID_SMIME_AA_ETS_COMMITMENTTYPE: Nid = Nid(ffi::NID_id_smime_aa_ets_commitmentType); ++pub const ID_SMIME_AA_ETS_SIGNERLOCATION: Nid = Nid(ffi::NID_id_smime_aa_ets_signerLocation); ++pub const ID_SMIME_AA_ETS_SIGNERATTR: Nid = Nid(ffi::NID_id_smime_aa_ets_signerAttr); ++pub const ID_SMIME_AA_ETS_OTHERSIGCERT: Nid = Nid(ffi::NID_id_smime_aa_ets_otherSigCert); ++pub const ID_SMIME_AA_ETS_CONTENTTIMESTAMP: Nid = Nid(ffi::NID_id_smime_aa_ets_contentTimestamp); ++pub const ID_SMIME_AA_ETS_CERTIFICATEREFS: Nid = Nid(ffi::NID_id_smime_aa_ets_CertificateRefs); ++pub const ID_SMIME_AA_ETS_REVOCATIONREFS: Nid = Nid(ffi::NID_id_smime_aa_ets_RevocationRefs); ++pub const ID_SMIME_AA_ETS_CERTVALUES: Nid = Nid(ffi::NID_id_smime_aa_ets_certValues); ++pub const ID_SMIME_AA_ETS_REVOCATIONVALUES: Nid = Nid(ffi::NID_id_smime_aa_ets_revocationValues); ++pub const ID_SMIME_AA_ETS_ESCTIMESTAMP: Nid = Nid(ffi::NID_id_smime_aa_ets_escTimeStamp); ++pub const ID_SMIME_AA_ETS_CERTCRLTIMESTAMP: Nid = Nid(ffi::NID_id_smime_aa_ets_certCRLTimestamp); ++pub const ID_SMIME_AA_ETS_ARCHIVETIMESTAMP: Nid = Nid(ffi::NID_id_smime_aa_ets_archiveTimeStamp); ++pub const ID_SMIME_AA_SIGNATURETYPE: Nid = Nid(ffi::NID_id_smime_aa_signatureType); ++pub const ID_SMIME_AA_DVCS_DVC: Nid = Nid(ffi::NID_id_smime_aa_dvcs_dvc); ++pub const ID_SMIME_ALG_ESDHWITH3DES: Nid = Nid(ffi::NID_id_smime_alg_ESDHwith3DES); ++pub const ID_SMIME_ALG_ESDHWITHRC2: Nid = Nid(ffi::NID_id_smime_alg_ESDHwithRC2); ++pub const ID_SMIME_ALG_3DESWRAP: Nid = Nid(ffi::NID_id_smime_alg_3DESwrap); ++pub const ID_SMIME_ALG_RC2WRAP: Nid = Nid(ffi::NID_id_smime_alg_RC2wrap); ++pub const ID_SMIME_ALG_ESDH: Nid = Nid(ffi::NID_id_smime_alg_ESDH); ++pub const ID_SMIME_ALG_CMS3DESWRAP: Nid = Nid(ffi::NID_id_smime_alg_CMS3DESwrap); ++pub const ID_SMIME_ALG_CMSRC2WRAP: Nid = Nid(ffi::NID_id_smime_alg_CMSRC2wrap); ++pub const ID_ALG_PWRI_KEK: Nid = Nid(ffi::NID_id_alg_PWRI_KEK); ++pub const ID_SMIME_CD_LDAP: Nid = Nid(ffi::NID_id_smime_cd_ldap); ++pub const ID_SMIME_SPQ_ETS_SQT_URI: Nid = Nid(ffi::NID_id_smime_spq_ets_sqt_uri); ++pub const ID_SMIME_SPQ_ETS_SQT_UNOTICE: Nid = Nid(ffi::NID_id_smime_spq_ets_sqt_unotice); ++pub const ID_SMIME_CTI_ETS_PROOFOFORIGIN: Nid = Nid(ffi::NID_id_smime_cti_ets_proofOfOrigin); ++pub const ID_SMIME_CTI_ETS_PROOFOFRECEIPT: Nid = Nid(ffi::NID_id_smime_cti_ets_proofOfReceipt); ++pub const ID_SMIME_CTI_ETS_PROOFOFDELIVERY: Nid = Nid(ffi::NID_id_smime_cti_ets_proofOfDelivery); ++pub const ID_SMIME_CTI_ETS_PROOFOFSENDER: Nid = Nid(ffi::NID_id_smime_cti_ets_proofOfSender); ++pub const ID_SMIME_CTI_ETS_PROOFOFAPPROVAL: Nid = Nid(ffi::NID_id_smime_cti_ets_proofOfApproval); ++pub const ID_SMIME_CTI_ETS_PROOFOFCREATION: Nid = Nid(ffi::NID_id_smime_cti_ets_proofOfCreation); ++pub const FRIENDLYNAME: Nid = Nid(ffi::NID_friendlyName); ++pub const LOCALKEYID: Nid = Nid(ffi::NID_localKeyID); ++pub const MS_CSP_NAME: Nid = Nid(ffi::NID_ms_csp_name); ++pub const LOCALKEYSET: Nid = Nid(ffi::NID_LocalKeySet); ++pub const X509CERTIFICATE: Nid = Nid(ffi::NID_x509Certificate); ++pub const SDSICERTIFICATE: Nid = Nid(ffi::NID_sdsiCertificate); ++pub const X509CRL: Nid = Nid(ffi::NID_x509Crl); ++pub const PBE_WITHSHA1AND128BITRC4: Nid = Nid(ffi::NID_pbe_WithSHA1And128BitRC4); ++pub const PBE_WITHSHA1AND40BITRC4: Nid = Nid(ffi::NID_pbe_WithSHA1And40BitRC4); ++pub const PBE_WITHSHA1AND3_KEY_TRIPLEDES_CBC: Nid = ++ Nid(ffi::NID_pbe_WithSHA1And3_Key_TripleDES_CBC); ++pub const PBE_WITHSHA1AND2_KEY_TRIPLEDES_CBC: Nid = ++ Nid(ffi::NID_pbe_WithSHA1And2_Key_TripleDES_CBC); ++pub const PBE_WITHSHA1AND128BITRC2_CBC: Nid = Nid(ffi::NID_pbe_WithSHA1And128BitRC2_CBC); ++pub const PBE_WITHSHA1AND40BITRC2_CBC: Nid = Nid(ffi::NID_pbe_WithSHA1And40BitRC2_CBC); ++pub const KEYBAG: Nid = Nid(ffi::NID_keyBag); ++pub const PKCS8SHROUDEDKEYBAG: Nid = Nid(ffi::NID_pkcs8ShroudedKeyBag); ++pub const CERTBAG: Nid = Nid(ffi::NID_certBag); ++pub const CRLBAG: Nid = Nid(ffi::NID_crlBag); ++pub const SECRETBAG: Nid = Nid(ffi::NID_secretBag); ++pub const SAFECONTENTSBAG: Nid = Nid(ffi::NID_safeContentsBag); ++pub const MD2: Nid = Nid(ffi::NID_md2); ++pub const MD4: Nid = Nid(ffi::NID_md4); ++pub const MD5: Nid = Nid(ffi::NID_md5); ++pub const MD5_SHA1: Nid = Nid(ffi::NID_md5_sha1); ++pub const HMACWITHMD5: Nid = Nid(ffi::NID_hmacWithMD5); ++pub const HMACWITHSHA1: Nid = Nid(ffi::NID_hmacWithSHA1); ++pub const HMACWITHSHA224: Nid = Nid(ffi::NID_hmacWithSHA224); ++pub const HMACWITHSHA256: Nid = Nid(ffi::NID_hmacWithSHA256); ++pub const HMACWITHSHA384: Nid = Nid(ffi::NID_hmacWithSHA384); ++pub const HMACWITHSHA512: Nid = Nid(ffi::NID_hmacWithSHA512); ++pub const RC2_CBC: Nid = Nid(ffi::NID_rc2_cbc); ++pub const RC2_ECB: Nid = Nid(ffi::NID_rc2_ecb); ++pub const RC2_CFB64: Nid = Nid(ffi::NID_rc2_cfb64); ++pub const RC2_OFB64: Nid = Nid(ffi::NID_rc2_ofb64); ++pub const RC2_40_CBC: Nid = Nid(ffi::NID_rc2_40_cbc); ++pub const RC2_64_CBC: Nid = Nid(ffi::NID_rc2_64_cbc); ++pub const RC4: Nid = Nid(ffi::NID_rc4); ++pub const RC4_40: Nid = Nid(ffi::NID_rc4_40); ++pub const DES_EDE3_CBC: Nid = Nid(ffi::NID_des_ede3_cbc); ++pub const RC5_CBC: Nid = Nid(ffi::NID_rc5_cbc); ++pub const RC5_ECB: Nid = Nid(ffi::NID_rc5_ecb); ++pub const RC5_CFB64: Nid = Nid(ffi::NID_rc5_cfb64); ++pub const RC5_OFB64: Nid = Nid(ffi::NID_rc5_ofb64); ++pub const MS_EXT_REQ: Nid = Nid(ffi::NID_ms_ext_req); ++pub const MS_CODE_IND: Nid = Nid(ffi::NID_ms_code_ind); ++pub const MS_CODE_COM: Nid = Nid(ffi::NID_ms_code_com); ++pub const MS_CTL_SIGN: Nid = Nid(ffi::NID_ms_ctl_sign); ++pub const MS_SGC: Nid = Nid(ffi::NID_ms_sgc); ++pub const MS_EFS: Nid = Nid(ffi::NID_ms_efs); ++pub const MS_SMARTCARD_LOGIN: Nid = Nid(ffi::NID_ms_smartcard_login); ++pub const MS_UPN: Nid = Nid(ffi::NID_ms_upn); ++pub const IDEA_CBC: Nid = Nid(ffi::NID_idea_cbc); ++pub const IDEA_ECB: Nid = Nid(ffi::NID_idea_ecb); ++pub const IDEA_CFB64: Nid = Nid(ffi::NID_idea_cfb64); ++pub const IDEA_OFB64: Nid = Nid(ffi::NID_idea_ofb64); ++pub const BF_CBC: Nid = Nid(ffi::NID_bf_cbc); ++pub const BF_ECB: Nid = Nid(ffi::NID_bf_ecb); ++pub const BF_CFB64: Nid = Nid(ffi::NID_bf_cfb64); ++pub const BF_OFB64: Nid = Nid(ffi::NID_bf_ofb64); ++pub const ID_PKIX: Nid = Nid(ffi::NID_id_pkix); ++pub const ID_PKIX_MOD: Nid = Nid(ffi::NID_id_pkix_mod); ++pub const ID_PE: Nid = Nid(ffi::NID_id_pe); ++pub const ID_QT: Nid = Nid(ffi::NID_id_qt); ++pub const ID_KP: Nid = Nid(ffi::NID_id_kp); ++pub const ID_IT: Nid = Nid(ffi::NID_id_it); ++pub const ID_PKIP: Nid = Nid(ffi::NID_id_pkip); ++pub const ID_ALG: Nid = Nid(ffi::NID_id_alg); ++pub const ID_CMC: Nid = Nid(ffi::NID_id_cmc); ++pub const ID_ON: Nid = Nid(ffi::NID_id_on); ++pub const ID_PDA: Nid = Nid(ffi::NID_id_pda); ++pub const ID_ACA: Nid = Nid(ffi::NID_id_aca); ++pub const ID_QCS: Nid = Nid(ffi::NID_id_qcs); ++pub const ID_CCT: Nid = Nid(ffi::NID_id_cct); ++pub const ID_PPL: Nid = Nid(ffi::NID_id_ppl); ++pub const ID_AD: Nid = Nid(ffi::NID_id_ad); ++pub const ID_PKIX1_EXPLICIT_88: Nid = Nid(ffi::NID_id_pkix1_explicit_88); ++pub const ID_PKIX1_IMPLICIT_88: Nid = Nid(ffi::NID_id_pkix1_implicit_88); ++pub const ID_PKIX1_EXPLICIT_93: Nid = Nid(ffi::NID_id_pkix1_explicit_93); ++pub const ID_PKIX1_IMPLICIT_93: Nid = Nid(ffi::NID_id_pkix1_implicit_93); ++pub const ID_MOD_CRMF: Nid = Nid(ffi::NID_id_mod_crmf); ++pub const ID_MOD_CMC: Nid = Nid(ffi::NID_id_mod_cmc); ++pub const ID_MOD_KEA_PROFILE_88: Nid = Nid(ffi::NID_id_mod_kea_profile_88); ++pub const ID_MOD_KEA_PROFILE_93: Nid = Nid(ffi::NID_id_mod_kea_profile_93); ++pub const ID_MOD_CMP: Nid = Nid(ffi::NID_id_mod_cmp); ++pub const ID_MOD_QUALIFIED_CERT_88: Nid = Nid(ffi::NID_id_mod_qualified_cert_88); ++pub const ID_MOD_QUALIFIED_CERT_93: Nid = Nid(ffi::NID_id_mod_qualified_cert_93); ++pub const ID_MOD_ATTRIBUTE_CERT: Nid = Nid(ffi::NID_id_mod_attribute_cert); ++pub const ID_MOD_TIMESTAMP_PROTOCOL: Nid = Nid(ffi::NID_id_mod_timestamp_protocol); ++pub const ID_MOD_OCSP: Nid = Nid(ffi::NID_id_mod_ocsp); ++pub const ID_MOD_DVCS: Nid = Nid(ffi::NID_id_mod_dvcs); ++pub const ID_MOD_CMP2000: Nid = Nid(ffi::NID_id_mod_cmp2000); ++pub const INFO_ACCESS: Nid = Nid(ffi::NID_info_access); ++pub const BIOMETRICINFO: Nid = Nid(ffi::NID_biometricInfo); ++pub const QCSTATEMENTS: Nid = Nid(ffi::NID_qcStatements); ++pub const AC_AUDITENTITY: Nid = Nid(ffi::NID_ac_auditEntity); ++pub const AC_TARGETING: Nid = Nid(ffi::NID_ac_targeting); ++pub const AACONTROLS: Nid = Nid(ffi::NID_aaControls); ++pub const SBGP_IPADDRBLOCK: Nid = Nid(ffi::NID_sbgp_ipAddrBlock); ++pub const SBGP_AUTONOMOUSSYSNUM: Nid = Nid(ffi::NID_sbgp_autonomousSysNum); ++pub const SBGP_ROUTERIDENTIFIER: Nid = Nid(ffi::NID_sbgp_routerIdentifier); ++pub const AC_PROXYING: Nid = Nid(ffi::NID_ac_proxying); ++pub const SINFO_ACCESS: Nid = Nid(ffi::NID_sinfo_access); ++pub const PROXYCERTINFO: Nid = Nid(ffi::NID_proxyCertInfo); ++pub const ID_QT_CPS: Nid = Nid(ffi::NID_id_qt_cps); ++pub const ID_QT_UNOTICE: Nid = Nid(ffi::NID_id_qt_unotice); ++pub const TEXTNOTICE: Nid = Nid(ffi::NID_textNotice); ++pub const SERVER_AUTH: Nid = Nid(ffi::NID_server_auth); ++pub const CLIENT_AUTH: Nid = Nid(ffi::NID_client_auth); ++pub const CODE_SIGN: Nid = Nid(ffi::NID_code_sign); ++pub const EMAIL_PROTECT: Nid = Nid(ffi::NID_email_protect); ++pub const IPSECENDSYSTEM: Nid = Nid(ffi::NID_ipsecEndSystem); ++pub const IPSECTUNNEL: Nid = Nid(ffi::NID_ipsecTunnel); ++pub const IPSECUSER: Nid = Nid(ffi::NID_ipsecUser); ++pub const TIME_STAMP: Nid = Nid(ffi::NID_time_stamp); ++pub const OCSP_SIGN: Nid = Nid(ffi::NID_OCSP_sign); ++pub const DVCS: Nid = Nid(ffi::NID_dvcs); ++pub const ID_IT_CAPROTENCCERT: Nid = Nid(ffi::NID_id_it_caProtEncCert); ++pub const ID_IT_SIGNKEYPAIRTYPES: Nid = Nid(ffi::NID_id_it_signKeyPairTypes); ++pub const ID_IT_ENCKEYPAIRTYPES: Nid = Nid(ffi::NID_id_it_encKeyPairTypes); ++pub const ID_IT_PREFERREDSYMMALG: Nid = Nid(ffi::NID_id_it_preferredSymmAlg); ++pub const ID_IT_CAKEYUPDATEINFO: Nid = Nid(ffi::NID_id_it_caKeyUpdateInfo); ++pub const ID_IT_CURRENTCRL: Nid = Nid(ffi::NID_id_it_currentCRL); ++pub const ID_IT_UNSUPPORTEDOIDS: Nid = Nid(ffi::NID_id_it_unsupportedOIDs); ++pub const ID_IT_SUBSCRIPTIONREQUEST: Nid = Nid(ffi::NID_id_it_subscriptionRequest); ++pub const ID_IT_SUBSCRIPTIONRESPONSE: Nid = Nid(ffi::NID_id_it_subscriptionResponse); ++pub const ID_IT_KEYPAIRPARAMREQ: Nid = Nid(ffi::NID_id_it_keyPairParamReq); ++pub const ID_IT_KEYPAIRPARAMREP: Nid = Nid(ffi::NID_id_it_keyPairParamRep); ++pub const ID_IT_REVPASSPHRASE: Nid = Nid(ffi::NID_id_it_revPassphrase); ++pub const ID_IT_IMPLICITCONFIRM: Nid = Nid(ffi::NID_id_it_implicitConfirm); ++pub const ID_IT_CONFIRMWAITTIME: Nid = Nid(ffi::NID_id_it_confirmWaitTime); ++pub const ID_IT_ORIGPKIMESSAGE: Nid = Nid(ffi::NID_id_it_origPKIMessage); ++pub const ID_IT_SUPPLANGTAGS: Nid = Nid(ffi::NID_id_it_suppLangTags); ++pub const ID_REGCTRL: Nid = Nid(ffi::NID_id_regCtrl); ++pub const ID_REGINFO: Nid = Nid(ffi::NID_id_regInfo); ++pub const ID_REGCTRL_REGTOKEN: Nid = Nid(ffi::NID_id_regCtrl_regToken); ++pub const ID_REGCTRL_AUTHENTICATOR: Nid = Nid(ffi::NID_id_regCtrl_authenticator); ++pub const ID_REGCTRL_PKIPUBLICATIONINFO: Nid = Nid(ffi::NID_id_regCtrl_pkiPublicationInfo); ++pub const ID_REGCTRL_PKIARCHIVEOPTIONS: Nid = Nid(ffi::NID_id_regCtrl_pkiArchiveOptions); ++pub const ID_REGCTRL_OLDCERTID: Nid = Nid(ffi::NID_id_regCtrl_oldCertID); ++pub const ID_REGCTRL_PROTOCOLENCRKEY: Nid = Nid(ffi::NID_id_regCtrl_protocolEncrKey); ++pub const ID_REGINFO_UTF8PAIRS: Nid = Nid(ffi::NID_id_regInfo_utf8Pairs); ++pub const ID_REGINFO_CERTREQ: Nid = Nid(ffi::NID_id_regInfo_certReq); ++pub const ID_ALG_DES40: Nid = Nid(ffi::NID_id_alg_des40); ++pub const ID_ALG_NOSIGNATURE: Nid = Nid(ffi::NID_id_alg_noSignature); ++pub const ID_ALG_DH_SIG_HMAC_SHA1: Nid = Nid(ffi::NID_id_alg_dh_sig_hmac_sha1); ++pub const ID_ALG_DH_POP: Nid = Nid(ffi::NID_id_alg_dh_pop); ++pub const ID_CMC_STATUSINFO: Nid = Nid(ffi::NID_id_cmc_statusInfo); ++pub const ID_CMC_IDENTIFICATION: Nid = Nid(ffi::NID_id_cmc_identification); ++pub const ID_CMC_IDENTITYPROOF: Nid = Nid(ffi::NID_id_cmc_identityProof); ++pub const ID_CMC_DATARETURN: Nid = Nid(ffi::NID_id_cmc_dataReturn); ++pub const ID_CMC_TRANSACTIONID: Nid = Nid(ffi::NID_id_cmc_transactionId); ++pub const ID_CMC_SENDERNONCE: Nid = Nid(ffi::NID_id_cmc_senderNonce); ++pub const ID_CMC_RECIPIENTNONCE: Nid = Nid(ffi::NID_id_cmc_recipientNonce); ++pub const ID_CMC_ADDEXTENSIONS: Nid = Nid(ffi::NID_id_cmc_addExtensions); ++pub const ID_CMC_ENCRYPTEDPOP: Nid = Nid(ffi::NID_id_cmc_encryptedPOP); ++pub const ID_CMC_DECRYPTEDPOP: Nid = Nid(ffi::NID_id_cmc_decryptedPOP); ++pub const ID_CMC_LRAPOPWITNESS: Nid = Nid(ffi::NID_id_cmc_lraPOPWitness); ++pub const ID_CMC_GETCERT: Nid = Nid(ffi::NID_id_cmc_getCert); ++pub const ID_CMC_GETCRL: Nid = Nid(ffi::NID_id_cmc_getCRL); ++pub const ID_CMC_REVOKEREQUEST: Nid = Nid(ffi::NID_id_cmc_revokeRequest); ++pub const ID_CMC_REGINFO: Nid = Nid(ffi::NID_id_cmc_regInfo); ++pub const ID_CMC_RESPONSEINFO: Nid = Nid(ffi::NID_id_cmc_responseInfo); ++pub const ID_CMC_QUERYPENDING: Nid = Nid(ffi::NID_id_cmc_queryPending); ++pub const ID_CMC_POPLINKRANDOM: Nid = Nid(ffi::NID_id_cmc_popLinkRandom); ++pub const ID_CMC_POPLINKWITNESS: Nid = Nid(ffi::NID_id_cmc_popLinkWitness); ++pub const ID_CMC_CONFIRMCERTACCEPTANCE: Nid = Nid(ffi::NID_id_cmc_confirmCertAcceptance); ++pub const ID_ON_PERSONALDATA: Nid = Nid(ffi::NID_id_on_personalData); ++pub const ID_ON_PERMANENTIDENTIFIER: Nid = Nid(ffi::NID_id_on_permanentIdentifier); ++pub const ID_PDA_DATEOFBIRTH: Nid = Nid(ffi::NID_id_pda_dateOfBirth); ++pub const ID_PDA_PLACEOFBIRTH: Nid = Nid(ffi::NID_id_pda_placeOfBirth); ++pub const ID_PDA_GENDER: Nid = Nid(ffi::NID_id_pda_gender); ++pub const ID_PDA_COUNTRYOFCITIZENSHIP: Nid = Nid(ffi::NID_id_pda_countryOfCitizenship); ++pub const ID_PDA_COUNTRYOFRESIDENCE: Nid = Nid(ffi::NID_id_pda_countryOfResidence); ++pub const ID_ACA_AUTHENTICATIONINFO: Nid = Nid(ffi::NID_id_aca_authenticationInfo); ++pub const ID_ACA_ACCESSIDENTITY: Nid = Nid(ffi::NID_id_aca_accessIdentity); ++pub const ID_ACA_CHARGINGIDENTITY: Nid = Nid(ffi::NID_id_aca_chargingIdentity); ++pub const ID_ACA_GROUP: Nid = Nid(ffi::NID_id_aca_group); ++pub const ID_ACA_ROLE: Nid = Nid(ffi::NID_id_aca_role); ++pub const ID_ACA_ENCATTRS: Nid = Nid(ffi::NID_id_aca_encAttrs); ++pub const ID_QCS_PKIXQCSYNTAX_V1: Nid = Nid(ffi::NID_id_qcs_pkixQCSyntax_v1); ++pub const ID_CCT_CRS: Nid = Nid(ffi::NID_id_cct_crs); ++pub const ID_CCT_PKIDATA: Nid = Nid(ffi::NID_id_cct_PKIData); ++pub const ID_CCT_PKIRESPONSE: Nid = Nid(ffi::NID_id_cct_PKIResponse); ++pub const ID_PPL_ANYLANGUAGE: Nid = Nid(ffi::NID_id_ppl_anyLanguage); ++pub const ID_PPL_INHERITALL: Nid = Nid(ffi::NID_id_ppl_inheritAll); ++pub const INDEPENDENT: Nid = Nid(ffi::NID_Independent); ++pub const AD_OCSP: Nid = Nid(ffi::NID_ad_OCSP); ++pub const AD_CA_ISSUERS: Nid = Nid(ffi::NID_ad_ca_issuers); ++pub const AD_TIMESTAMPING: Nid = Nid(ffi::NID_ad_timeStamping); ++pub const AD_DVCS: Nid = Nid(ffi::NID_ad_dvcs); ++pub const CAREPOSITORY: Nid = Nid(ffi::NID_caRepository); ++pub const ID_PKIX_OCSP_BASIC: Nid = Nid(ffi::NID_id_pkix_OCSP_basic); ++pub const ID_PKIX_OCSP_NONCE: Nid = Nid(ffi::NID_id_pkix_OCSP_Nonce); ++pub const ID_PKIX_OCSP_CRLID: Nid = Nid(ffi::NID_id_pkix_OCSP_CrlID); ++pub const ID_PKIX_OCSP_ACCEPTABLERESPONSES: Nid = Nid(ffi::NID_id_pkix_OCSP_acceptableResponses); ++pub const ID_PKIX_OCSP_NOCHECK: Nid = Nid(ffi::NID_id_pkix_OCSP_noCheck); ++pub const ID_PKIX_OCSP_ARCHIVECUTOFF: Nid = Nid(ffi::NID_id_pkix_OCSP_archiveCutoff); ++pub const ID_PKIX_OCSP_SERVICELOCATOR: Nid = Nid(ffi::NID_id_pkix_OCSP_serviceLocator); ++pub const ID_PKIX_OCSP_EXTENDEDSTATUS: Nid = Nid(ffi::NID_id_pkix_OCSP_extendedStatus); ++pub const ID_PKIX_OCSP_VALID: Nid = Nid(ffi::NID_id_pkix_OCSP_valid); ++pub const ID_PKIX_OCSP_PATH: Nid = Nid(ffi::NID_id_pkix_OCSP_path); ++pub const ID_PKIX_OCSP_TRUSTROOT: Nid = Nid(ffi::NID_id_pkix_OCSP_trustRoot); ++pub const ALGORITHM: Nid = Nid(ffi::NID_algorithm); ++pub const MD5WITHRSA: Nid = Nid(ffi::NID_md5WithRSA); ++pub const DES_ECB: Nid = Nid(ffi::NID_des_ecb); ++pub const DES_CBC: Nid = Nid(ffi::NID_des_cbc); ++pub const DES_OFB64: Nid = Nid(ffi::NID_des_ofb64); ++pub const DES_CFB64: Nid = Nid(ffi::NID_des_cfb64); ++pub const RSASIGNATURE: Nid = Nid(ffi::NID_rsaSignature); ++pub const DSA_2: Nid = Nid(ffi::NID_dsa_2); ++pub const DSAWITHSHA: Nid = Nid(ffi::NID_dsaWithSHA); ++pub const SHAWITHRSAENCRYPTION: Nid = Nid(ffi::NID_shaWithRSAEncryption); ++pub const DES_EDE_ECB: Nid = Nid(ffi::NID_des_ede_ecb); ++pub const DES_EDE3_ECB: Nid = Nid(ffi::NID_des_ede3_ecb); ++pub const DES_EDE_CBC: Nid = Nid(ffi::NID_des_ede_cbc); ++pub const DES_EDE_CFB64: Nid = Nid(ffi::NID_des_ede_cfb64); ++pub const DES_EDE3_CFB64: Nid = Nid(ffi::NID_des_ede3_cfb64); ++pub const DES_EDE_OFB64: Nid = Nid(ffi::NID_des_ede_ofb64); ++pub const DES_EDE3_OFB64: Nid = Nid(ffi::NID_des_ede3_ofb64); ++pub const DESX_CBC: Nid = Nid(ffi::NID_desx_cbc); ++pub const SHA: Nid = Nid(ffi::NID_sha); ++pub const SHA1: Nid = Nid(ffi::NID_sha1); ++pub const DSAWITHSHA1_2: Nid = Nid(ffi::NID_dsaWithSHA1_2); ++pub const SHA1WITHRSA: Nid = Nid(ffi::NID_sha1WithRSA); ++pub const RIPEMD160: Nid = Nid(ffi::NID_ripemd160); ++pub const RIPEMD160WITHRSA: Nid = Nid(ffi::NID_ripemd160WithRSA); ++pub const SXNET: Nid = Nid(ffi::NID_sxnet); ++pub const X500: Nid = Nid(ffi::NID_X500); ++pub const X509: Nid = Nid(ffi::NID_X509); ++pub const COMMONNAME: Nid = Nid(ffi::NID_commonName); ++pub const SURNAME: Nid = Nid(ffi::NID_surname); ++pub const SERIALNUMBER: Nid = Nid(ffi::NID_serialNumber); ++pub const COUNTRYNAME: Nid = Nid(ffi::NID_countryName); ++pub const LOCALITYNAME: Nid = Nid(ffi::NID_localityName); ++pub const STATEORPROVINCENAME: Nid = Nid(ffi::NID_stateOrProvinceName); ++pub const STREETADDRESS: Nid = Nid(ffi::NID_streetAddress); ++pub const ORGANIZATIONNAME: Nid = Nid(ffi::NID_organizationName); ++pub const ORGANIZATIONALUNITNAME: Nid = Nid(ffi::NID_organizationalUnitName); ++pub const TITLE: Nid = Nid(ffi::NID_title); ++pub const DESCRIPTION: Nid = Nid(ffi::NID_description); ++pub const SEARCHGUIDE: Nid = Nid(ffi::NID_searchGuide); ++pub const BUSINESSCATEGORY: Nid = Nid(ffi::NID_businessCategory); ++pub const POSTALADDRESS: Nid = Nid(ffi::NID_postalAddress); ++pub const POSTALCODE: Nid = Nid(ffi::NID_postalCode); ++pub const POSTOFFICEBOX: Nid = Nid(ffi::NID_postOfficeBox); ++pub const PHYSICALDELIVERYOFFICENAME: Nid = Nid(ffi::NID_physicalDeliveryOfficeName); ++pub const TELEPHONENUMBER: Nid = Nid(ffi::NID_telephoneNumber); ++pub const TELEXNUMBER: Nid = Nid(ffi::NID_telexNumber); ++pub const TELETEXTERMINALIDENTIFIER: Nid = Nid(ffi::NID_teletexTerminalIdentifier); ++pub const FACSIMILETELEPHONENUMBER: Nid = Nid(ffi::NID_facsimileTelephoneNumber); ++pub const X121ADDRESS: Nid = Nid(ffi::NID_x121Address); ++pub const INTERNATIONALISDNNUMBER: Nid = Nid(ffi::NID_internationaliSDNNumber); ++pub const REGISTEREDADDRESS: Nid = Nid(ffi::NID_registeredAddress); ++pub const DESTINATIONINDICATOR: Nid = Nid(ffi::NID_destinationIndicator); ++pub const PREFERREDDELIVERYMETHOD: Nid = Nid(ffi::NID_preferredDeliveryMethod); ++pub const PRESENTATIONADDRESS: Nid = Nid(ffi::NID_presentationAddress); ++pub const SUPPORTEDAPPLICATIONCONTEXT: Nid = Nid(ffi::NID_supportedApplicationContext); ++pub const MEMBER: Nid = Nid(ffi::NID_member); ++pub const OWNER: Nid = Nid(ffi::NID_owner); ++pub const ROLEOCCUPANT: Nid = Nid(ffi::NID_roleOccupant); ++pub const SEEALSO: Nid = Nid(ffi::NID_seeAlso); ++pub const USERPASSWORD: Nid = Nid(ffi::NID_userPassword); ++pub const USERCERTIFICATE: Nid = Nid(ffi::NID_userCertificate); ++pub const CACERTIFICATE: Nid = Nid(ffi::NID_cACertificate); ++pub const AUTHORITYREVOCATIONLIST: Nid = Nid(ffi::NID_authorityRevocationList); ++pub const CERTIFICATEREVOCATIONLIST: Nid = Nid(ffi::NID_certificateRevocationList); ++pub const CROSSCERTIFICATEPAIR: Nid = Nid(ffi::NID_crossCertificatePair); ++pub const NAME: Nid = Nid(ffi::NID_name); ++pub const GIVENNAME: Nid = Nid(ffi::NID_givenName); ++pub const INITIALS: Nid = Nid(ffi::NID_initials); ++pub const GENERATIONQUALIFIER: Nid = Nid(ffi::NID_generationQualifier); ++pub const X500UNIQUEIDENTIFIER: Nid = Nid(ffi::NID_x500UniqueIdentifier); ++pub const DNQUALIFIER: Nid = Nid(ffi::NID_dnQualifier); ++pub const ENHANCEDSEARCHGUIDE: Nid = Nid(ffi::NID_enhancedSearchGuide); ++pub const PROTOCOLINFORMATION: Nid = Nid(ffi::NID_protocolInformation); ++pub const DISTINGUISHEDNAME: Nid = Nid(ffi::NID_distinguishedName); ++pub const UNIQUEMEMBER: Nid = Nid(ffi::NID_uniqueMember); ++pub const HOUSEIDENTIFIER: Nid = Nid(ffi::NID_houseIdentifier); ++pub const SUPPORTEDALGORITHMS: Nid = Nid(ffi::NID_supportedAlgorithms); ++pub const DELTAREVOCATIONLIST: Nid = Nid(ffi::NID_deltaRevocationList); ++pub const DMDNAME: Nid = Nid(ffi::NID_dmdName); ++pub const PSEUDONYM: Nid = Nid(ffi::NID_pseudonym); ++pub const ROLE: Nid = Nid(ffi::NID_role); ++pub const X500ALGORITHMS: Nid = Nid(ffi::NID_X500algorithms); ++pub const RSA: Nid = Nid(ffi::NID_rsa); ++pub const MDC2WITHRSA: Nid = Nid(ffi::NID_mdc2WithRSA); ++pub const MDC2: Nid = Nid(ffi::NID_mdc2); ++pub const ID_CE: Nid = Nid(ffi::NID_id_ce); ++pub const SUBJECT_DIRECTORY_ATTRIBUTES: Nid = Nid(ffi::NID_subject_directory_attributes); ++pub const SUBJECT_KEY_IDENTIFIER: Nid = Nid(ffi::NID_subject_key_identifier); ++pub const KEY_USAGE: Nid = Nid(ffi::NID_key_usage); ++pub const PRIVATE_KEY_USAGE_PERIOD: Nid = Nid(ffi::NID_private_key_usage_period); ++pub const SUBJECT_ALT_NAME: Nid = Nid(ffi::NID_subject_alt_name); ++pub const ISSUER_ALT_NAME: Nid = Nid(ffi::NID_issuer_alt_name); ++pub const BASIC_CONSTRAINTS: Nid = Nid(ffi::NID_basic_constraints); ++pub const CRL_NUMBER: Nid = Nid(ffi::NID_crl_number); ++pub const CRL_REASON: Nid = Nid(ffi::NID_crl_reason); ++pub const INVALIDITY_DATE: Nid = Nid(ffi::NID_invalidity_date); ++pub const DELTA_CRL: Nid = Nid(ffi::NID_delta_crl); ++pub const ISSUING_DISTRIBUTION_POINT: Nid = Nid(ffi::NID_issuing_distribution_point); ++pub const CERTIFICATE_ISSUER: Nid = Nid(ffi::NID_certificate_issuer); ++pub const NAME_CONSTRAINTS: Nid = Nid(ffi::NID_name_constraints); ++pub const CRL_DISTRIBUTION_POINTS: Nid = Nid(ffi::NID_crl_distribution_points); ++pub const CERTIFICATE_POLICIES: Nid = Nid(ffi::NID_certificate_policies); ++pub const ANY_POLICY: Nid = Nid(ffi::NID_any_policy); ++pub const POLICY_MAPPINGS: Nid = Nid(ffi::NID_policy_mappings); ++pub const AUTHORITY_KEY_IDENTIFIER: Nid = Nid(ffi::NID_authority_key_identifier); ++pub const POLICY_CONSTRAINTS: Nid = Nid(ffi::NID_policy_constraints); ++pub const EXT_KEY_USAGE: Nid = Nid(ffi::NID_ext_key_usage); ++pub const FRESHEST_CRL: Nid = Nid(ffi::NID_freshest_crl); ++pub const INHIBIT_ANY_POLICY: Nid = Nid(ffi::NID_inhibit_any_policy); ++pub const TARGET_INFORMATION: Nid = Nid(ffi::NID_target_information); ++pub const NO_REV_AVAIL: Nid = Nid(ffi::NID_no_rev_avail); ++pub const ANYEXTENDEDKEYUSAGE: Nid = Nid(ffi::NID_anyExtendedKeyUsage); ++pub const NETSCAPE: Nid = Nid(ffi::NID_netscape); ++pub const NETSCAPE_CERT_EXTENSION: Nid = Nid(ffi::NID_netscape_cert_extension); ++pub const NETSCAPE_DATA_TYPE: Nid = Nid(ffi::NID_netscape_data_type); ++pub const NETSCAPE_CERT_TYPE: Nid = Nid(ffi::NID_netscape_cert_type); ++pub const NETSCAPE_BASE_URL: Nid = Nid(ffi::NID_netscape_base_url); ++pub const NETSCAPE_REVOCATION_URL: Nid = Nid(ffi::NID_netscape_revocation_url); ++pub const NETSCAPE_CA_REVOCATION_URL: Nid = Nid(ffi::NID_netscape_ca_revocation_url); ++pub const NETSCAPE_RENEWAL_URL: Nid = Nid(ffi::NID_netscape_renewal_url); ++pub const NETSCAPE_CA_POLICY_URL: Nid = Nid(ffi::NID_netscape_ca_policy_url); ++pub const NETSCAPE_SSL_SERVER_NAME: Nid = Nid(ffi::NID_netscape_ssl_server_name); ++pub const NETSCAPE_COMMENT: Nid = Nid(ffi::NID_netscape_comment); ++pub const NETSCAPE_CERT_SEQUENCE: Nid = Nid(ffi::NID_netscape_cert_sequence); ++pub const NS_SGC: Nid = Nid(ffi::NID_ns_sgc); ++pub const ORG: Nid = Nid(ffi::NID_org); ++pub const DOD: Nid = Nid(ffi::NID_dod); ++pub const IANA: Nid = Nid(ffi::NID_iana); ++pub const DIRECTORY: Nid = Nid(ffi::NID_Directory); ++pub const MANAGEMENT: Nid = Nid(ffi::NID_Management); ++pub const EXPERIMENTAL: Nid = Nid(ffi::NID_Experimental); ++pub const PRIVATE: Nid = Nid(ffi::NID_Private); ++pub const SECURITY: Nid = Nid(ffi::NID_Security); ++pub const SNMPV2: Nid = Nid(ffi::NID_SNMPv2); ++pub const MAIL: Nid = Nid(ffi::NID_Mail); ++pub const ENTERPRISES: Nid = Nid(ffi::NID_Enterprises); ++pub const DCOBJECT: Nid = Nid(ffi::NID_dcObject); ++pub const MIME_MHS: Nid = Nid(ffi::NID_mime_mhs); ++pub const MIME_MHS_HEADINGS: Nid = Nid(ffi::NID_mime_mhs_headings); ++pub const MIME_MHS_BODIES: Nid = Nid(ffi::NID_mime_mhs_bodies); ++pub const ID_HEX_PARTIAL_MESSAGE: Nid = Nid(ffi::NID_id_hex_partial_message); ++pub const ID_HEX_MULTIPART_MESSAGE: Nid = Nid(ffi::NID_id_hex_multipart_message); ++pub const ZLIB_COMPRESSION: Nid = Nid(ffi::NID_zlib_compression); ++pub const AES_128_ECB: Nid = Nid(ffi::NID_aes_128_ecb); ++pub const AES_128_CBC: Nid = Nid(ffi::NID_aes_128_cbc); ++pub const AES_128_OFB128: Nid = Nid(ffi::NID_aes_128_ofb128); ++pub const AES_128_CFB128: Nid = Nid(ffi::NID_aes_128_cfb128); ++pub const ID_AES128_WRAP: Nid = Nid(ffi::NID_id_aes128_wrap); ++pub const AES_128_GCM: Nid = Nid(ffi::NID_aes_128_gcm); ++pub const AES_128_CCM: Nid = Nid(ffi::NID_aes_128_ccm); ++pub const ID_AES128_WRAP_PAD: Nid = Nid(ffi::NID_id_aes128_wrap_pad); ++pub const AES_192_ECB: Nid = Nid(ffi::NID_aes_192_ecb); ++pub const AES_192_CBC: Nid = Nid(ffi::NID_aes_192_cbc); ++pub const AES_192_OFB128: Nid = Nid(ffi::NID_aes_192_ofb128); ++pub const AES_192_CFB128: Nid = Nid(ffi::NID_aes_192_cfb128); ++pub const ID_AES192_WRAP: Nid = Nid(ffi::NID_id_aes192_wrap); ++pub const AES_192_GCM: Nid = Nid(ffi::NID_aes_192_gcm); ++pub const AES_192_CCM: Nid = Nid(ffi::NID_aes_192_ccm); ++pub const ID_AES192_WRAP_PAD: Nid = Nid(ffi::NID_id_aes192_wrap_pad); ++pub const AES_256_ECB: Nid = Nid(ffi::NID_aes_256_ecb); ++pub const AES_256_CBC: Nid = Nid(ffi::NID_aes_256_cbc); ++pub const AES_256_OFB128: Nid = Nid(ffi::NID_aes_256_ofb128); ++pub const AES_256_CFB128: Nid = Nid(ffi::NID_aes_256_cfb128); ++pub const ID_AES256_WRAP: Nid = Nid(ffi::NID_id_aes256_wrap); ++pub const AES_256_GCM: Nid = Nid(ffi::NID_aes_256_gcm); ++pub const AES_256_CCM: Nid = Nid(ffi::NID_aes_256_ccm); ++pub const ID_AES256_WRAP_PAD: Nid = Nid(ffi::NID_id_aes256_wrap_pad); ++pub const AES_128_CFB1: Nid = Nid(ffi::NID_aes_128_cfb1); ++pub const AES_192_CFB1: Nid = Nid(ffi::NID_aes_192_cfb1); ++pub const AES_256_CFB1: Nid = Nid(ffi::NID_aes_256_cfb1); ++pub const AES_128_CFB8: Nid = Nid(ffi::NID_aes_128_cfb8); ++pub const AES_192_CFB8: Nid = Nid(ffi::NID_aes_192_cfb8); ++pub const AES_256_CFB8: Nid = Nid(ffi::NID_aes_256_cfb8); ++pub const AES_128_CTR: Nid = Nid(ffi::NID_aes_128_ctr); ++pub const AES_192_CTR: Nid = Nid(ffi::NID_aes_192_ctr); ++pub const AES_256_CTR: Nid = Nid(ffi::NID_aes_256_ctr); ++pub const AES_128_XTS: Nid = Nid(ffi::NID_aes_128_xts); ++pub const AES_256_XTS: Nid = Nid(ffi::NID_aes_256_xts); ++pub const DES_CFB1: Nid = Nid(ffi::NID_des_cfb1); ++pub const DES_CFB8: Nid = Nid(ffi::NID_des_cfb8); ++pub const DES_EDE3_CFB1: Nid = Nid(ffi::NID_des_ede3_cfb1); ++pub const DES_EDE3_CFB8: Nid = Nid(ffi::NID_des_ede3_cfb8); ++pub const SHA256: Nid = Nid(ffi::NID_sha256); ++pub const SHA384: Nid = Nid(ffi::NID_sha384); ++pub const SHA512: Nid = Nid(ffi::NID_sha512); ++pub const SHA224: Nid = Nid(ffi::NID_sha224); ++pub const DSA_WITH_SHA224: Nid = Nid(ffi::NID_dsa_with_SHA224); ++pub const DSA_WITH_SHA256: Nid = Nid(ffi::NID_dsa_with_SHA256); ++pub const HOLD_INSTRUCTION_CODE: Nid = Nid(ffi::NID_hold_instruction_code); ++pub const HOLD_INSTRUCTION_NONE: Nid = Nid(ffi::NID_hold_instruction_none); ++pub const HOLD_INSTRUCTION_CALL_ISSUER: Nid = Nid(ffi::NID_hold_instruction_call_issuer); ++pub const HOLD_INSTRUCTION_REJECT: Nid = Nid(ffi::NID_hold_instruction_reject); ++pub const DATA: Nid = Nid(ffi::NID_data); ++pub const PSS: Nid = Nid(ffi::NID_pss); ++pub const UCL: Nid = Nid(ffi::NID_ucl); ++pub const PILOT: Nid = Nid(ffi::NID_pilot); ++pub const PILOTATTRIBUTETYPE: Nid = Nid(ffi::NID_pilotAttributeType); ++pub const PILOTATTRIBUTESYNTAX: Nid = Nid(ffi::NID_pilotAttributeSyntax); ++pub const PILOTOBJECTCLASS: Nid = Nid(ffi::NID_pilotObjectClass); ++pub const PILOTGROUPS: Nid = Nid(ffi::NID_pilotGroups); ++pub const IA5STRINGSYNTAX: Nid = Nid(ffi::NID_iA5StringSyntax); ++pub const CASEIGNOREIA5STRINGSYNTAX: Nid = Nid(ffi::NID_caseIgnoreIA5StringSyntax); ++pub const PILOTOBJECT: Nid = Nid(ffi::NID_pilotObject); ++pub const PILOTPERSON: Nid = Nid(ffi::NID_pilotPerson); ++pub const ACCOUNT: Nid = Nid(ffi::NID_account); ++pub const DOCUMENT: Nid = Nid(ffi::NID_document); ++pub const ROOM: Nid = Nid(ffi::NID_room); ++pub const DOCUMENTSERIES: Nid = Nid(ffi::NID_documentSeries); ++pub const DOMAIN: Nid = Nid(ffi::NID_Domain); ++pub const RFC822LOCALPART: Nid = Nid(ffi::NID_rFC822localPart); ++pub const DNSDOMAIN: Nid = Nid(ffi::NID_dNSDomain); ++pub const DOMAINRELATEDOBJECT: Nid = Nid(ffi::NID_domainRelatedObject); ++pub const FRIENDLYCOUNTRY: Nid = Nid(ffi::NID_friendlyCountry); ++pub const SIMPLESECURITYOBJECT: Nid = Nid(ffi::NID_simpleSecurityObject); ++pub const PILOTORGANIZATION: Nid = Nid(ffi::NID_pilotOrganization); ++pub const PILOTDSA: Nid = Nid(ffi::NID_pilotDSA); ++pub const QUALITYLABELLEDDATA: Nid = Nid(ffi::NID_qualityLabelledData); ++pub const USERID: Nid = Nid(ffi::NID_userId); ++pub const TEXTENCODEDORADDRESS: Nid = Nid(ffi::NID_textEncodedORAddress); ++pub const RFC822MAILBOX: Nid = Nid(ffi::NID_rfc822Mailbox); ++pub const INFO: Nid = Nid(ffi::NID_info); ++pub const FAVOURITEDRINK: Nid = Nid(ffi::NID_favouriteDrink); ++pub const ROOMNUMBER: Nid = Nid(ffi::NID_roomNumber); ++pub const PHOTO: Nid = Nid(ffi::NID_photo); ++pub const USERCLASS: Nid = Nid(ffi::NID_userClass); ++pub const HOST: Nid = Nid(ffi::NID_host); ++pub const MANAGER: Nid = Nid(ffi::NID_manager); ++pub const DOCUMENTIDENTIFIER: Nid = Nid(ffi::NID_documentIdentifier); ++pub const DOCUMENTTITLE: Nid = Nid(ffi::NID_documentTitle); ++pub const DOCUMENTVERSION: Nid = Nid(ffi::NID_documentVersion); ++pub const DOCUMENTAUTHOR: Nid = Nid(ffi::NID_documentAuthor); ++pub const DOCUMENTLOCATION: Nid = Nid(ffi::NID_documentLocation); ++pub const HOMETELEPHONENUMBER: Nid = Nid(ffi::NID_homeTelephoneNumber); ++pub const SECRETARY: Nid = Nid(ffi::NID_secretary); ++pub const OTHERMAILBOX: Nid = Nid(ffi::NID_otherMailbox); ++pub const LASTMODIFIEDTIME: Nid = Nid(ffi::NID_lastModifiedTime); ++pub const LASTMODIFIEDBY: Nid = Nid(ffi::NID_lastModifiedBy); ++pub const DOMAINCOMPONENT: Nid = Nid(ffi::NID_domainComponent); ++pub const ARECORD: Nid = Nid(ffi::NID_aRecord); ++pub const PILOTATTRIBUTETYPE27: Nid = Nid(ffi::NID_pilotAttributeType27); ++pub const MXRECORD: Nid = Nid(ffi::NID_mXRecord); ++pub const NSRECORD: Nid = Nid(ffi::NID_nSRecord); ++pub const SOARECORD: Nid = Nid(ffi::NID_sOARecord); ++pub const CNAMERECORD: Nid = Nid(ffi::NID_cNAMERecord); ++pub const ASSOCIATEDDOMAIN: Nid = Nid(ffi::NID_associatedDomain); ++pub const ASSOCIATEDNAME: Nid = Nid(ffi::NID_associatedName); ++pub const HOMEPOSTALADDRESS: Nid = Nid(ffi::NID_homePostalAddress); ++pub const PERSONALTITLE: Nid = Nid(ffi::NID_personalTitle); ++pub const MOBILETELEPHONENUMBER: Nid = Nid(ffi::NID_mobileTelephoneNumber); ++pub const PAGERTELEPHONENUMBER: Nid = Nid(ffi::NID_pagerTelephoneNumber); ++pub const FRIENDLYCOUNTRYNAME: Nid = Nid(ffi::NID_friendlyCountryName); ++pub const ORGANIZATIONALSTATUS: Nid = Nid(ffi::NID_organizationalStatus); ++pub const JANETMAILBOX: Nid = Nid(ffi::NID_janetMailbox); ++pub const MAILPREFERENCEOPTION: Nid = Nid(ffi::NID_mailPreferenceOption); ++pub const BUILDINGNAME: Nid = Nid(ffi::NID_buildingName); ++pub const DSAQUALITY: Nid = Nid(ffi::NID_dSAQuality); ++pub const SINGLELEVELQUALITY: Nid = Nid(ffi::NID_singleLevelQuality); ++pub const SUBTREEMINIMUMQUALITY: Nid = Nid(ffi::NID_subtreeMinimumQuality); ++pub const SUBTREEMAXIMUMQUALITY: Nid = Nid(ffi::NID_subtreeMaximumQuality); ++pub const PERSONALSIGNATURE: Nid = Nid(ffi::NID_personalSignature); ++pub const DITREDIRECT: Nid = Nid(ffi::NID_dITRedirect); ++pub const AUDIO: Nid = Nid(ffi::NID_audio); ++pub const DOCUMENTPUBLISHER: Nid = Nid(ffi::NID_documentPublisher); ++pub const ID_SET: Nid = Nid(ffi::NID_id_set); ++pub const SET_CTYPE: Nid = Nid(ffi::NID_set_ctype); ++pub const SET_MSGEXT: Nid = Nid(ffi::NID_set_msgExt); ++pub const SET_ATTR: Nid = Nid(ffi::NID_set_attr); ++pub const SET_POLICY: Nid = Nid(ffi::NID_set_policy); ++pub const SET_CERTEXT: Nid = Nid(ffi::NID_set_certExt); ++pub const SET_BRAND: Nid = Nid(ffi::NID_set_brand); ++pub const SETCT_PANDATA: Nid = Nid(ffi::NID_setct_PANData); ++pub const SETCT_PANTOKEN: Nid = Nid(ffi::NID_setct_PANToken); ++pub const SETCT_PANONLY: Nid = Nid(ffi::NID_setct_PANOnly); ++pub const SETCT_OIDATA: Nid = Nid(ffi::NID_setct_OIData); ++pub const SETCT_PI: Nid = Nid(ffi::NID_setct_PI); ++pub const SETCT_PIDATA: Nid = Nid(ffi::NID_setct_PIData); ++pub const SETCT_PIDATAUNSIGNED: Nid = Nid(ffi::NID_setct_PIDataUnsigned); ++pub const SETCT_HODINPUT: Nid = Nid(ffi::NID_setct_HODInput); ++pub const SETCT_AUTHRESBAGGAGE: Nid = Nid(ffi::NID_setct_AuthResBaggage); ++pub const SETCT_AUTHREVREQBAGGAGE: Nid = Nid(ffi::NID_setct_AuthRevReqBaggage); ++pub const SETCT_AUTHREVRESBAGGAGE: Nid = Nid(ffi::NID_setct_AuthRevResBaggage); ++pub const SETCT_CAPTOKENSEQ: Nid = Nid(ffi::NID_setct_CapTokenSeq); ++pub const SETCT_PINITRESDATA: Nid = Nid(ffi::NID_setct_PInitResData); ++pub const SETCT_PI_TBS: Nid = Nid(ffi::NID_setct_PI_TBS); ++pub const SETCT_PRESDATA: Nid = Nid(ffi::NID_setct_PResData); ++pub const SETCT_AUTHREQTBS: Nid = Nid(ffi::NID_setct_AuthReqTBS); ++pub const SETCT_AUTHRESTBS: Nid = Nid(ffi::NID_setct_AuthResTBS); ++pub const SETCT_AUTHRESTBSX: Nid = Nid(ffi::NID_setct_AuthResTBSX); ++pub const SETCT_AUTHTOKENTBS: Nid = Nid(ffi::NID_setct_AuthTokenTBS); ++pub const SETCT_CAPTOKENDATA: Nid = Nid(ffi::NID_setct_CapTokenData); ++pub const SETCT_CAPTOKENTBS: Nid = Nid(ffi::NID_setct_CapTokenTBS); ++pub const SETCT_ACQCARDCODEMSG: Nid = Nid(ffi::NID_setct_AcqCardCodeMsg); ++pub const SETCT_AUTHREVREQTBS: Nid = Nid(ffi::NID_setct_AuthRevReqTBS); ++pub const SETCT_AUTHREVRESDATA: Nid = Nid(ffi::NID_setct_AuthRevResData); ++pub const SETCT_AUTHREVRESTBS: Nid = Nid(ffi::NID_setct_AuthRevResTBS); ++pub const SETCT_CAPREQTBS: Nid = Nid(ffi::NID_setct_CapReqTBS); ++pub const SETCT_CAPREQTBSX: Nid = Nid(ffi::NID_setct_CapReqTBSX); ++pub const SETCT_CAPRESDATA: Nid = Nid(ffi::NID_setct_CapResData); ++pub const SETCT_CAPREVREQTBS: Nid = Nid(ffi::NID_setct_CapRevReqTBS); ++pub const SETCT_CAPREVREQTBSX: Nid = Nid(ffi::NID_setct_CapRevReqTBSX); ++pub const SETCT_CAPREVRESDATA: Nid = Nid(ffi::NID_setct_CapRevResData); ++pub const SETCT_CREDREQTBS: Nid = Nid(ffi::NID_setct_CredReqTBS); ++pub const SETCT_CREDREQTBSX: Nid = Nid(ffi::NID_setct_CredReqTBSX); ++pub const SETCT_CREDRESDATA: Nid = Nid(ffi::NID_setct_CredResData); ++pub const SETCT_CREDREVREQTBS: Nid = Nid(ffi::NID_setct_CredRevReqTBS); ++pub const SETCT_CREDREVREQTBSX: Nid = Nid(ffi::NID_setct_CredRevReqTBSX); ++pub const SETCT_CREDREVRESDATA: Nid = Nid(ffi::NID_setct_CredRevResData); ++pub const SETCT_PCERTREQDATA: Nid = Nid(ffi::NID_setct_PCertReqData); ++pub const SETCT_PCERTRESTBS: Nid = Nid(ffi::NID_setct_PCertResTBS); ++pub const SETCT_BATCHADMINREQDATA: Nid = Nid(ffi::NID_setct_BatchAdminReqData); ++pub const SETCT_BATCHADMINRESDATA: Nid = Nid(ffi::NID_setct_BatchAdminResData); ++pub const SETCT_CARDCINITRESTBS: Nid = Nid(ffi::NID_setct_CardCInitResTBS); ++pub const SETCT_MEAQCINITRESTBS: Nid = Nid(ffi::NID_setct_MeAqCInitResTBS); ++pub const SETCT_REGFORMRESTBS: Nid = Nid(ffi::NID_setct_RegFormResTBS); ++pub const SETCT_CERTREQDATA: Nid = Nid(ffi::NID_setct_CertReqData); ++pub const SETCT_CERTREQTBS: Nid = Nid(ffi::NID_setct_CertReqTBS); ++pub const SETCT_CERTRESDATA: Nid = Nid(ffi::NID_setct_CertResData); ++pub const SETCT_CERTINQREQTBS: Nid = Nid(ffi::NID_setct_CertInqReqTBS); ++pub const SETCT_ERRORTBS: Nid = Nid(ffi::NID_setct_ErrorTBS); ++pub const SETCT_PIDUALSIGNEDTBE: Nid = Nid(ffi::NID_setct_PIDualSignedTBE); ++pub const SETCT_PIUNSIGNEDTBE: Nid = Nid(ffi::NID_setct_PIUnsignedTBE); ++pub const SETCT_AUTHREQTBE: Nid = Nid(ffi::NID_setct_AuthReqTBE); ++pub const SETCT_AUTHRESTBE: Nid = Nid(ffi::NID_setct_AuthResTBE); ++pub const SETCT_AUTHRESTBEX: Nid = Nid(ffi::NID_setct_AuthResTBEX); ++pub const SETCT_AUTHTOKENTBE: Nid = Nid(ffi::NID_setct_AuthTokenTBE); ++pub const SETCT_CAPTOKENTBE: Nid = Nid(ffi::NID_setct_CapTokenTBE); ++pub const SETCT_CAPTOKENTBEX: Nid = Nid(ffi::NID_setct_CapTokenTBEX); ++pub const SETCT_ACQCARDCODEMSGTBE: Nid = Nid(ffi::NID_setct_AcqCardCodeMsgTBE); ++pub const SETCT_AUTHREVREQTBE: Nid = Nid(ffi::NID_setct_AuthRevReqTBE); ++pub const SETCT_AUTHREVRESTBE: Nid = Nid(ffi::NID_setct_AuthRevResTBE); ++pub const SETCT_AUTHREVRESTBEB: Nid = Nid(ffi::NID_setct_AuthRevResTBEB); ++pub const SETCT_CAPREQTBE: Nid = Nid(ffi::NID_setct_CapReqTBE); ++pub const SETCT_CAPREQTBEX: Nid = Nid(ffi::NID_setct_CapReqTBEX); ++pub const SETCT_CAPRESTBE: Nid = Nid(ffi::NID_setct_CapResTBE); ++pub const SETCT_CAPREVREQTBE: Nid = Nid(ffi::NID_setct_CapRevReqTBE); ++pub const SETCT_CAPREVREQTBEX: Nid = Nid(ffi::NID_setct_CapRevReqTBEX); ++pub const SETCT_CAPREVRESTBE: Nid = Nid(ffi::NID_setct_CapRevResTBE); ++pub const SETCT_CREDREQTBE: Nid = Nid(ffi::NID_setct_CredReqTBE); ++pub const SETCT_CREDREQTBEX: Nid = Nid(ffi::NID_setct_CredReqTBEX); ++pub const SETCT_CREDRESTBE: Nid = Nid(ffi::NID_setct_CredResTBE); ++pub const SETCT_CREDREVREQTBE: Nid = Nid(ffi::NID_setct_CredRevReqTBE); ++pub const SETCT_CREDREVREQTBEX: Nid = Nid(ffi::NID_setct_CredRevReqTBEX); ++pub const SETCT_CREDREVRESTBE: Nid = Nid(ffi::NID_setct_CredRevResTBE); ++pub const SETCT_BATCHADMINREQTBE: Nid = Nid(ffi::NID_setct_BatchAdminReqTBE); ++pub const SETCT_BATCHADMINRESTBE: Nid = Nid(ffi::NID_setct_BatchAdminResTBE); ++pub const SETCT_REGFORMREQTBE: Nid = Nid(ffi::NID_setct_RegFormReqTBE); ++pub const SETCT_CERTREQTBE: Nid = Nid(ffi::NID_setct_CertReqTBE); ++pub const SETCT_CERTREQTBEX: Nid = Nid(ffi::NID_setct_CertReqTBEX); ++pub const SETCT_CERTRESTBE: Nid = Nid(ffi::NID_setct_CertResTBE); ++pub const SETCT_CRLNOTIFICATIONTBS: Nid = Nid(ffi::NID_setct_CRLNotificationTBS); ++pub const SETCT_CRLNOTIFICATIONRESTBS: Nid = Nid(ffi::NID_setct_CRLNotificationResTBS); ++pub const SETCT_BCIDISTRIBUTIONTBS: Nid = Nid(ffi::NID_setct_BCIDistributionTBS); ++pub const SETEXT_GENCRYPT: Nid = Nid(ffi::NID_setext_genCrypt); ++pub const SETEXT_MIAUTH: Nid = Nid(ffi::NID_setext_miAuth); ++pub const SETEXT_PINSECURE: Nid = Nid(ffi::NID_setext_pinSecure); ++pub const SETEXT_PINANY: Nid = Nid(ffi::NID_setext_pinAny); ++pub const SETEXT_TRACK2: Nid = Nid(ffi::NID_setext_track2); ++pub const SETEXT_CV: Nid = Nid(ffi::NID_setext_cv); ++pub const SET_POLICY_ROOT: Nid = Nid(ffi::NID_set_policy_root); ++pub const SETCEXT_HASHEDROOT: Nid = Nid(ffi::NID_setCext_hashedRoot); ++pub const SETCEXT_CERTTYPE: Nid = Nid(ffi::NID_setCext_certType); ++pub const SETCEXT_MERCHDATA: Nid = Nid(ffi::NID_setCext_merchData); ++pub const SETCEXT_CCERTREQUIRED: Nid = Nid(ffi::NID_setCext_cCertRequired); ++pub const SETCEXT_TUNNELING: Nid = Nid(ffi::NID_setCext_tunneling); ++pub const SETCEXT_SETEXT: Nid = Nid(ffi::NID_setCext_setExt); ++pub const SETCEXT_SETQUALF: Nid = Nid(ffi::NID_setCext_setQualf); ++pub const SETCEXT_PGWYCAPABILITIES: Nid = Nid(ffi::NID_setCext_PGWYcapabilities); ++pub const SETCEXT_TOKENIDENTIFIER: Nid = Nid(ffi::NID_setCext_TokenIdentifier); ++pub const SETCEXT_TRACK2DATA: Nid = Nid(ffi::NID_setCext_Track2Data); ++pub const SETCEXT_TOKENTYPE: Nid = Nid(ffi::NID_setCext_TokenType); ++pub const SETCEXT_ISSUERCAPABILITIES: Nid = Nid(ffi::NID_setCext_IssuerCapabilities); ++pub const SETATTR_CERT: Nid = Nid(ffi::NID_setAttr_Cert); ++pub const SETATTR_PGWYCAP: Nid = Nid(ffi::NID_setAttr_PGWYcap); ++pub const SETATTR_TOKENTYPE: Nid = Nid(ffi::NID_setAttr_TokenType); ++pub const SETATTR_ISSCAP: Nid = Nid(ffi::NID_setAttr_IssCap); ++pub const SET_ROOTKEYTHUMB: Nid = Nid(ffi::NID_set_rootKeyThumb); ++pub const SET_ADDPOLICY: Nid = Nid(ffi::NID_set_addPolicy); ++pub const SETATTR_TOKEN_EMV: Nid = Nid(ffi::NID_setAttr_Token_EMV); ++pub const SETATTR_TOKEN_B0PRIME: Nid = Nid(ffi::NID_setAttr_Token_B0Prime); ++pub const SETATTR_ISSCAP_CVM: Nid = Nid(ffi::NID_setAttr_IssCap_CVM); ++pub const SETATTR_ISSCAP_T2: Nid = Nid(ffi::NID_setAttr_IssCap_T2); ++pub const SETATTR_ISSCAP_SIG: Nid = Nid(ffi::NID_setAttr_IssCap_Sig); ++pub const SETATTR_GENCRYPTGRM: Nid = Nid(ffi::NID_setAttr_GenCryptgrm); ++pub const SETATTR_T2ENC: Nid = Nid(ffi::NID_setAttr_T2Enc); ++pub const SETATTR_T2CLEARTXT: Nid = Nid(ffi::NID_setAttr_T2cleartxt); ++pub const SETATTR_TOKICCSIG: Nid = Nid(ffi::NID_setAttr_TokICCsig); ++pub const SETATTR_SECDEVSIG: Nid = Nid(ffi::NID_setAttr_SecDevSig); ++pub const SET_BRAND_IATA_ATA: Nid = Nid(ffi::NID_set_brand_IATA_ATA); ++pub const SET_BRAND_DINERS: Nid = Nid(ffi::NID_set_brand_Diners); ++pub const SET_BRAND_AMERICANEXPRESS: Nid = Nid(ffi::NID_set_brand_AmericanExpress); ++pub const SET_BRAND_JCB: Nid = Nid(ffi::NID_set_brand_JCB); ++pub const SET_BRAND_VISA: Nid = Nid(ffi::NID_set_brand_Visa); ++pub const SET_BRAND_MASTERCARD: Nid = Nid(ffi::NID_set_brand_MasterCard); ++pub const SET_BRAND_NOVUS: Nid = Nid(ffi::NID_set_brand_Novus); ++pub const DES_CDMF: Nid = Nid(ffi::NID_des_cdmf); ++pub const RSAOAEPENCRYPTIONSET: Nid = Nid(ffi::NID_rsaOAEPEncryptionSET); ++pub const IPSEC3: Nid = Nid(ffi::NID_ipsec3); ++pub const IPSEC4: Nid = Nid(ffi::NID_ipsec4); ++pub const WHIRLPOOL: Nid = Nid(ffi::NID_whirlpool); ++pub const CRYPTOPRO: Nid = Nid(ffi::NID_cryptopro); ++pub const CRYPTOCOM: Nid = Nid(ffi::NID_cryptocom); ++pub const ID_GOSTR3411_94_WITH_GOSTR3410_2001: Nid = ++ Nid(ffi::NID_id_GostR3411_94_with_GostR3410_2001); ++pub const ID_GOSTR3411_94_WITH_GOSTR3410_94: Nid = Nid(ffi::NID_id_GostR3411_94_with_GostR3410_94); ++pub const ID_GOSTR3411_94: Nid = Nid(ffi::NID_id_GostR3411_94); ++pub const ID_HMACGOSTR3411_94: Nid = Nid(ffi::NID_id_HMACGostR3411_94); ++pub const ID_GOSTR3410_2001: Nid = Nid(ffi::NID_id_GostR3410_2001); ++pub const ID_GOSTR3410_94: Nid = Nid(ffi::NID_id_GostR3410_94); ++pub const ID_GOST28147_89: Nid = Nid(ffi::NID_id_Gost28147_89); ++pub const GOST89_CNT: Nid = Nid(ffi::NID_gost89_cnt); ++pub const ID_GOST28147_89_MAC: Nid = Nid(ffi::NID_id_Gost28147_89_MAC); ++pub const ID_GOSTR3411_94_PRF: Nid = Nid(ffi::NID_id_GostR3411_94_prf); ++pub const ID_GOSTR3410_2001DH: Nid = Nid(ffi::NID_id_GostR3410_2001DH); ++pub const ID_GOSTR3410_94DH: Nid = Nid(ffi::NID_id_GostR3410_94DH); ++pub const ID_GOST28147_89_CRYPTOPRO_KEYMESHING: Nid = ++ Nid(ffi::NID_id_Gost28147_89_CryptoPro_KeyMeshing); ++pub const ID_GOST28147_89_NONE_KEYMESHING: Nid = Nid(ffi::NID_id_Gost28147_89_None_KeyMeshing); ++pub const ID_GOSTR3411_94_TESTPARAMSET: Nid = Nid(ffi::NID_id_GostR3411_94_TestParamSet); ++pub const ID_GOSTR3411_94_CRYPTOPROPARAMSET: Nid = Nid(ffi::NID_id_GostR3411_94_CryptoProParamSet); ++pub const ID_GOST28147_89_TESTPARAMSET: Nid = Nid(ffi::NID_id_Gost28147_89_TestParamSet); ++pub const ID_GOST28147_89_CRYPTOPRO_A_PARAMSET: Nid = ++ Nid(ffi::NID_id_Gost28147_89_CryptoPro_A_ParamSet); ++pub const ID_GOST28147_89_CRYPTOPRO_B_PARAMSET: Nid = ++ Nid(ffi::NID_id_Gost28147_89_CryptoPro_B_ParamSet); ++pub const ID_GOST28147_89_CRYPTOPRO_C_PARAMSET: Nid = ++ Nid(ffi::NID_id_Gost28147_89_CryptoPro_C_ParamSet); ++pub const ID_GOST28147_89_CRYPTOPRO_D_PARAMSET: Nid = ++ Nid(ffi::NID_id_Gost28147_89_CryptoPro_D_ParamSet); ++pub const ID_GOST28147_89_CRYPTOPRO_OSCAR_1_1_PARAMSET: Nid = ++ Nid(ffi::NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet); ++pub const ID_GOST28147_89_CRYPTOPRO_OSCAR_1_0_PARAMSET: Nid = ++ Nid(ffi::NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet); ++pub const ID_GOST28147_89_CRYPTOPRO_RIC_1_PARAMSET: Nid = ++ Nid(ffi::NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet); ++pub const ID_GOSTR3410_94_TESTPARAMSET: Nid = Nid(ffi::NID_id_GostR3410_94_TestParamSet); ++pub const ID_GOSTR3410_94_CRYPTOPRO_A_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_94_CryptoPro_A_ParamSet); ++pub const ID_GOSTR3410_94_CRYPTOPRO_B_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_94_CryptoPro_B_ParamSet); ++pub const ID_GOSTR3410_94_CRYPTOPRO_C_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_94_CryptoPro_C_ParamSet); ++pub const ID_GOSTR3410_94_CRYPTOPRO_D_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_94_CryptoPro_D_ParamSet); ++pub const ID_GOSTR3410_94_CRYPTOPRO_XCHA_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_94_CryptoPro_XchA_ParamSet); ++pub const ID_GOSTR3410_94_CRYPTOPRO_XCHB_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_94_CryptoPro_XchB_ParamSet); ++pub const ID_GOSTR3410_94_CRYPTOPRO_XCHC_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_94_CryptoPro_XchC_ParamSet); ++pub const ID_GOSTR3410_2001_TESTPARAMSET: Nid = Nid(ffi::NID_id_GostR3410_2001_TestParamSet); ++pub const ID_GOSTR3410_2001_CRYPTOPRO_A_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_2001_CryptoPro_A_ParamSet); ++pub const ID_GOSTR3410_2001_CRYPTOPRO_B_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_2001_CryptoPro_B_ParamSet); ++pub const ID_GOSTR3410_2001_CRYPTOPRO_C_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_2001_CryptoPro_C_ParamSet); ++pub const ID_GOSTR3410_2001_CRYPTOPRO_XCHA_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet); ++pub const ID_GOSTR3410_2001_CRYPTOPRO_XCHB_PARAMSET: Nid = ++ Nid(ffi::NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet); ++pub const ID_GOSTR3410_94_A: Nid = Nid(ffi::NID_id_GostR3410_94_a); ++pub const ID_GOSTR3410_94_ABIS: Nid = Nid(ffi::NID_id_GostR3410_94_aBis); ++pub const ID_GOSTR3410_94_B: Nid = Nid(ffi::NID_id_GostR3410_94_b); ++pub const ID_GOSTR3410_94_BBIS: Nid = Nid(ffi::NID_id_GostR3410_94_bBis); ++pub const ID_GOST28147_89_CC: Nid = Nid(ffi::NID_id_Gost28147_89_cc); ++pub const ID_GOSTR3410_94_CC: Nid = Nid(ffi::NID_id_GostR3410_94_cc); ++pub const ID_GOSTR3410_2001_CC: Nid = Nid(ffi::NID_id_GostR3410_2001_cc); ++pub const ID_GOSTR3411_94_WITH_GOSTR3410_94_CC: Nid = ++ Nid(ffi::NID_id_GostR3411_94_with_GostR3410_94_cc); ++pub const ID_GOSTR3411_94_WITH_GOSTR3410_2001_CC: Nid = ++ Nid(ffi::NID_id_GostR3411_94_with_GostR3410_2001_cc); ++pub const ID_GOSTR3410_2001_PARAMSET_CC: Nid = Nid(ffi::NID_id_GostR3410_2001_ParamSet_cc); ++pub const CAMELLIA_128_CBC: Nid = Nid(ffi::NID_camellia_128_cbc); ++pub const CAMELLIA_192_CBC: Nid = Nid(ffi::NID_camellia_192_cbc); ++pub const CAMELLIA_256_CBC: Nid = Nid(ffi::NID_camellia_256_cbc); ++pub const ID_CAMELLIA128_WRAP: Nid = Nid(ffi::NID_id_camellia128_wrap); ++pub const ID_CAMELLIA192_WRAP: Nid = Nid(ffi::NID_id_camellia192_wrap); ++pub const ID_CAMELLIA256_WRAP: Nid = Nid(ffi::NID_id_camellia256_wrap); ++pub const CAMELLIA_128_ECB: Nid = Nid(ffi::NID_camellia_128_ecb); ++pub const CAMELLIA_128_OFB128: Nid = Nid(ffi::NID_camellia_128_ofb128); ++pub const CAMELLIA_128_CFB128: Nid = Nid(ffi::NID_camellia_128_cfb128); ++pub const CAMELLIA_192_ECB: Nid = Nid(ffi::NID_camellia_192_ecb); ++pub const CAMELLIA_192_OFB128: Nid = Nid(ffi::NID_camellia_192_ofb128); ++pub const CAMELLIA_192_CFB128: Nid = Nid(ffi::NID_camellia_192_cfb128); ++pub const CAMELLIA_256_ECB: Nid = Nid(ffi::NID_camellia_256_ecb); ++pub const CAMELLIA_256_OFB128: Nid = Nid(ffi::NID_camellia_256_ofb128); ++pub const CAMELLIA_256_CFB128: Nid = Nid(ffi::NID_camellia_256_cfb128); ++pub const CAMELLIA_128_CFB1: Nid = Nid(ffi::NID_camellia_128_cfb1); ++pub const CAMELLIA_192_CFB1: Nid = Nid(ffi::NID_camellia_192_cfb1); ++pub const CAMELLIA_256_CFB1: Nid = Nid(ffi::NID_camellia_256_cfb1); ++pub const CAMELLIA_128_CFB8: Nid = Nid(ffi::NID_camellia_128_cfb8); ++pub const CAMELLIA_192_CFB8: Nid = Nid(ffi::NID_camellia_192_cfb8); ++pub const CAMELLIA_256_CFB8: Nid = Nid(ffi::NID_camellia_256_cfb8); ++pub const KISA: Nid = Nid(ffi::NID_kisa); ++pub const SEED_ECB: Nid = Nid(ffi::NID_seed_ecb); ++pub const SEED_CBC: Nid = Nid(ffi::NID_seed_cbc); ++pub const SEED_CFB128: Nid = Nid(ffi::NID_seed_cfb128); ++pub const SEED_OFB128: Nid = Nid(ffi::NID_seed_ofb128); ++pub const HMAC: Nid = Nid(ffi::NID_hmac); ++pub const CMAC: Nid = Nid(ffi::NID_cmac); ++pub const RC4_HMAC_MD5: Nid = Nid(ffi::NID_rc4_hmac_md5); ++pub const AES_128_CBC_HMAC_SHA1: Nid = Nid(ffi::NID_aes_128_cbc_hmac_sha1); ++pub const AES_192_CBC_HMAC_SHA1: Nid = Nid(ffi::NID_aes_192_cbc_hmac_sha1); ++pub const AES_256_CBC_HMAC_SHA1: Nid = Nid(ffi::NID_aes_256_cbc_hmac_sha1); diff --cc vendor/openssl-0.9.19/src/ocsp.rs index 000000000,000000000..acc3549bb new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ocsp.rs @@@ -1,0 -1,0 +1,314 @@@ ++use ffi; ++use foreign_types::ForeignTypeRef; ++use libc::{c_int, c_long, c_ulong}; ++use std::ptr; ++use std::mem; ++ ++use {cvt, cvt_p}; ++use asn1::Asn1GeneralizedTimeRef; ++use error::ErrorStack; ++use hash::MessageDigest; ++use stack::StackRef; ++use x509::store::X509StoreRef; ++use x509::{X509, X509Ref}; ++ ++bitflags! { ++ pub struct Flag: c_ulong { ++ const FLAG_NO_CERTS = ffi::OCSP_NOCERTS; ++ const FLAG_NO_INTERN = ffi::OCSP_NOINTERN; ++ const FLAG_NO_CHAIN = ffi::OCSP_NOCHAIN; ++ const FLAG_NO_VERIFY = ffi::OCSP_NOVERIFY; ++ const FLAG_NO_EXPLICIT = ffi::OCSP_NOEXPLICIT; ++ const FLAG_NO_CA_SIGN = ffi::OCSP_NOCASIGN; ++ const FLAG_NO_DELEGATED = ffi::OCSP_NODELEGATED; ++ const FLAG_NO_CHECKS = ffi::OCSP_NOCHECKS; ++ const FLAG_TRUST_OTHER = ffi::OCSP_TRUSTOTHER; ++ const FLAG_RESPID_KEY = ffi::OCSP_RESPID_KEY; ++ const FLAG_NO_TIME = ffi::OCSP_NOTIME; ++ } ++} ++ ++pub const RESPONSE_STATUS_SUCCESSFUL: OcspResponseStatus = ++ OcspResponseStatus(ffi::OCSP_RESPONSE_STATUS_SUCCESSFUL); ++pub const RESPONSE_STATUS_MALFORMED_REQUEST: OcspResponseStatus = ++ OcspResponseStatus(ffi::OCSP_RESPONSE_STATUS_MALFORMEDREQUEST); ++pub const RESPONSE_STATUS_INTERNAL_ERROR: OcspResponseStatus = ++ OcspResponseStatus(ffi::OCSP_RESPONSE_STATUS_INTERNALERROR); ++pub const RESPONSE_STATUS_TRY_LATER: OcspResponseStatus = ++ OcspResponseStatus(ffi::OCSP_RESPONSE_STATUS_TRYLATER); ++pub const RESPONSE_STATUS_SIG_REQUIRED: OcspResponseStatus = ++ OcspResponseStatus(ffi::OCSP_RESPONSE_STATUS_SIGREQUIRED); ++pub const RESPONSE_STATUS_UNAUTHORIZED: OcspResponseStatus = ++ OcspResponseStatus(ffi::OCSP_RESPONSE_STATUS_UNAUTHORIZED); ++ ++pub const CERT_STATUS_GOOD: OcspCertStatus = OcspCertStatus(ffi::V_OCSP_CERTSTATUS_GOOD); ++pub const CERT_STATUS_REVOKED: OcspCertStatus = OcspCertStatus(ffi::V_OCSP_CERTSTATUS_REVOKED); ++pub const CERT_STATUS_UNKNOWN: OcspCertStatus = OcspCertStatus(ffi::V_OCSP_CERTSTATUS_UNKNOWN); ++ ++pub const REVOKED_STATUS_NO_STATUS: OcspRevokedStatus = ++ OcspRevokedStatus(ffi::OCSP_REVOKED_STATUS_NOSTATUS); ++pub const REVOKED_STATUS_UNSPECIFIED: OcspRevokedStatus = ++ OcspRevokedStatus(ffi::OCSP_REVOKED_STATUS_UNSPECIFIED); ++pub const REVOKED_STATUS_KEY_COMPROMISE: OcspRevokedStatus = ++ OcspRevokedStatus(ffi::OCSP_REVOKED_STATUS_KEYCOMPROMISE); ++pub const REVOKED_STATUS_CA_COMPROMISE: OcspRevokedStatus = ++ OcspRevokedStatus(ffi::OCSP_REVOKED_STATUS_CACOMPROMISE); ++pub const REVOKED_STATUS_AFFILIATION_CHANGED: OcspRevokedStatus = ++ OcspRevokedStatus(ffi::OCSP_REVOKED_STATUS_AFFILIATIONCHANGED); ++pub const REVOKED_STATUS_SUPERSEDED: OcspRevokedStatus = ++ OcspRevokedStatus(ffi::OCSP_REVOKED_STATUS_SUPERSEDED); ++pub const REVOKED_STATUS_CESSATION_OF_OPERATION: OcspRevokedStatus = ++ OcspRevokedStatus(ffi::OCSP_REVOKED_STATUS_CESSATIONOFOPERATION); ++pub const REVOKED_STATUS_CERTIFICATE_HOLD: OcspRevokedStatus = ++ OcspRevokedStatus(ffi::OCSP_REVOKED_STATUS_CERTIFICATEHOLD); ++pub const REVOKED_STATUS_REMOVE_FROM_CRL: OcspRevokedStatus = ++ OcspRevokedStatus(ffi::OCSP_REVOKED_STATUS_REMOVEFROMCRL); ++ ++#[derive(Copy, Clone, Debug, PartialEq, Eq)] ++pub struct OcspResponseStatus(c_int); ++ ++impl OcspResponseStatus { ++ pub fn from_raw(raw: c_int) -> OcspResponseStatus { ++ OcspResponseStatus(raw) ++ } ++ ++ pub fn as_raw(&self) -> c_int { ++ self.0 ++ } ++} ++ ++#[derive(Copy, Clone, Debug, PartialEq, Eq)] ++pub struct OcspCertStatus(c_int); ++ ++impl OcspCertStatus { ++ pub fn from_raw(raw: c_int) -> OcspCertStatus { ++ OcspCertStatus(raw) ++ } ++ ++ pub fn as_raw(&self) -> c_int { ++ self.0 ++ } ++} ++ ++#[derive(Copy, Clone, Debug, PartialEq, Eq)] ++pub struct OcspRevokedStatus(c_int); ++ ++impl OcspRevokedStatus { ++ pub fn from_raw(raw: c_int) -> OcspRevokedStatus { ++ OcspRevokedStatus(raw) ++ } ++ ++ pub fn as_raw(&self) -> c_int { ++ self.0 ++ } ++} ++ ++pub struct Status<'a> { ++ /// The overall status of the response. ++ pub status: OcspCertStatus, ++ /// If `status` is `CERT_STATUS_REVOKED`, the reason for the revocation. ++ pub reason: OcspRevokedStatus, ++ /// If `status` is `CERT_STATUS_REVOKED`, the time at which the certificate was revoked. ++ pub revocation_time: Option<&'a Asn1GeneralizedTimeRef>, ++ /// The time that this revocation check was performed. ++ pub this_update: &'a Asn1GeneralizedTimeRef, ++ /// The time at which this revocation check expires. ++ pub next_update: &'a Asn1GeneralizedTimeRef, ++} ++ ++impl<'a> Status<'a> { ++ /// Checks validity of the `this_update` and `next_update` fields. ++ /// ++ /// The `nsec` parameter specifies an amount of slack time that will be used when comparing ++ /// those times with the current time to account for delays and clock skew. ++ /// ++ /// The `maxsec` parameter limits the maximum age of the `this_update` parameter to prohibit ++ /// very old responses. ++ pub fn check_validity(&self, nsec: u32, maxsec: Option) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::OCSP_check_validity( ++ self.this_update.as_ptr(), ++ self.next_update.as_ptr(), ++ nsec as c_long, ++ maxsec.map(|n| n as c_long).unwrap_or(-1), ++ )).map(|_| ()) ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::OCSP_BASICRESP; ++ fn drop = ffi::OCSP_BASICRESP_free; ++ ++ pub struct OcspBasicResponse; ++ pub struct OcspBasicResponseRef; ++} ++ ++impl OcspBasicResponseRef { ++ /// Verifies the validity of the response. ++ /// ++ /// The `certs` parameter contains a set of certificates that will be searched when locating the ++ /// OCSP response signing certificate. Some responders do not include this in the response. ++ pub fn verify( ++ &self, ++ certs: &StackRef, ++ store: &X509StoreRef, ++ flags: Flag, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::OCSP_basic_verify( ++ self.as_ptr(), ++ certs.as_ptr(), ++ store.as_ptr(), ++ flags.bits(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Looks up the status for the specified certificate ID. ++ pub fn find_status<'a>(&'a self, id: &OcspCertIdRef) -> Option> { ++ unsafe { ++ let mut status = ffi::V_OCSP_CERTSTATUS_UNKNOWN; ++ let mut reason = ffi::OCSP_REVOKED_STATUS_NOSTATUS; ++ let mut revocation_time = ptr::null_mut(); ++ let mut this_update = ptr::null_mut(); ++ let mut next_update = ptr::null_mut(); ++ ++ let r = ffi::OCSP_resp_find_status( ++ self.as_ptr(), ++ id.as_ptr(), ++ &mut status, ++ &mut reason, ++ &mut revocation_time, ++ &mut this_update, ++ &mut next_update, ++ ); ++ if r == 1 { ++ let revocation_time = if revocation_time.is_null() { ++ None ++ } else { ++ Some(Asn1GeneralizedTimeRef::from_ptr(revocation_time)) ++ }; ++ Some(Status { ++ status: OcspCertStatus(status), ++ reason: OcspRevokedStatus(status), ++ revocation_time: revocation_time, ++ this_update: Asn1GeneralizedTimeRef::from_ptr(this_update), ++ next_update: Asn1GeneralizedTimeRef::from_ptr(next_update), ++ }) ++ } else { ++ None ++ } ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::OCSP_CERTID; ++ fn drop = ffi::OCSP_CERTID_free; ++ ++ pub struct OcspCertId; ++ pub struct OcspCertIdRef; ++} ++ ++impl OcspCertId { ++ /// Constructs a certificate ID for certificate `subject`. ++ pub fn from_cert( ++ digest: MessageDigest, ++ subject: &X509Ref, ++ issuer: &X509Ref, ++ ) -> Result { ++ unsafe { ++ cvt_p(ffi::OCSP_cert_to_id( ++ digest.as_ptr(), ++ subject.as_ptr(), ++ issuer.as_ptr(), ++ )).map(OcspCertId) ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::OCSP_RESPONSE; ++ fn drop = ffi::OCSP_RESPONSE_free; ++ ++ pub struct OcspResponse; ++ pub struct OcspResponseRef; ++} ++ ++impl OcspResponse { ++ /// Creates an OCSP response from the status and optional body. ++ /// ++ /// A body should only be provided if `status` is `RESPONSE_STATUS_SUCCESSFUL`. ++ pub fn create( ++ status: OcspResponseStatus, ++ body: Option<&OcspBasicResponseRef>, ++ ) -> Result { ++ unsafe { ++ ffi::init(); ++ ++ cvt_p(ffi::OCSP_response_create( ++ status.as_raw(), ++ body.map(|r| r.as_ptr()).unwrap_or(ptr::null_mut()), ++ )).map(OcspResponse) ++ } ++ } ++ ++ from_der!(OcspResponse, ffi::d2i_OCSP_RESPONSE); ++} ++ ++impl OcspResponseRef { ++ to_der!(ffi::i2d_OCSP_RESPONSE); ++ ++ /// Returns the status of the response. ++ pub fn status(&self) -> OcspResponseStatus { ++ unsafe { OcspResponseStatus(ffi::OCSP_response_status(self.as_ptr())) } ++ } ++ ++ /// Returns the basic response. ++ /// ++ /// This will only succeed if `status()` returns `RESPONSE_STATUS_SUCCESSFUL`. ++ pub fn basic(&self) -> Result { ++ unsafe { cvt_p(ffi::OCSP_response_get1_basic(self.as_ptr())).map(OcspBasicResponse) } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::OCSP_REQUEST; ++ fn drop = ffi::OCSP_REQUEST_free; ++ ++ pub struct OcspRequest; ++ pub struct OcspRequestRef; ++} ++ ++impl OcspRequest { ++ pub fn new() -> Result { ++ unsafe { ++ ffi::init(); ++ ++ cvt_p(ffi::OCSP_REQUEST_new()).map(OcspRequest) ++ } ++ } ++ ++ from_der!(OcspRequest, ffi::d2i_OCSP_REQUEST); ++} ++ ++impl OcspRequestRef { ++ to_der!(ffi::i2d_OCSP_REQUEST); ++ ++ pub fn add_id(&mut self, id: OcspCertId) -> Result<&mut OcspOneReqRef, ErrorStack> { ++ unsafe { ++ let ptr = try!(cvt_p(ffi::OCSP_request_add0_id(self.as_ptr(), id.as_ptr()))); ++ mem::forget(id); ++ Ok(OcspOneReqRef::from_ptr_mut(ptr)) ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::OCSP_ONEREQ; ++ fn drop = ffi::OCSP_ONEREQ_free; ++ ++ pub struct OcspOneReq; ++ pub struct OcspOneReqRef; ++} diff --cc vendor/openssl-0.9.19/src/pkcs12.rs index 000000000,000000000..d25080372 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/pkcs12.rs @@@ -1,0 -1,0 +1,276 @@@ ++//! PKCS #12 archives. ++ ++use ffi; ++use foreign_types::{ForeignType, ForeignTypeRef}; ++use libc::c_int; ++use std::ptr; ++use std::ffi::CString; ++ ++use {cvt, cvt_p}; ++use pkey::{PKey, PKeyRef}; ++use error::ErrorStack; ++use x509::X509; ++use stack::Stack; ++use nid; ++ ++foreign_type! { ++ type CType = ffi::PKCS12; ++ fn drop = ffi::PKCS12_free; ++ ++ pub struct Pkcs12; ++ pub struct Pkcs12Ref; ++} ++ ++impl Pkcs12Ref { ++ to_der!(ffi::i2d_PKCS12); ++ ++ /// Extracts the contents of the `Pkcs12`. ++ // FIXME should take an &[u8] ++ pub fn parse(&self, pass: &str) -> Result { ++ unsafe { ++ let pass = CString::new(pass).unwrap(); ++ ++ let mut pkey = ptr::null_mut(); ++ let mut cert = ptr::null_mut(); ++ let mut chain = ptr::null_mut(); ++ ++ try!(cvt(ffi::PKCS12_parse( ++ self.as_ptr(), ++ pass.as_ptr(), ++ &mut pkey, ++ &mut cert, ++ &mut chain, ++ ))); ++ ++ let pkey = PKey::from_ptr(pkey); ++ let cert = X509::from_ptr(cert); ++ ++ let chain = if chain.is_null() { ++ try!(Stack::new()) ++ } else { ++ Stack::from_ptr(chain) ++ }; ++ ++ Ok(ParsedPkcs12 { ++ pkey: pkey, ++ cert: cert, ++ chain: chain, ++ }) ++ } ++ } ++} ++ ++impl Pkcs12 { ++ from_der!(Pkcs12, ffi::d2i_PKCS12); ++ ++ /// Creates a new builder for a protected pkcs12 certificate. ++ /// ++ /// This uses the defaults from the OpenSSL library: ++ /// ++ /// * `nid_key` - `nid::PBE_WITHSHA1AND3_KEY_TRIPLEDES_CBC` ++ /// * `nid_cert` - `nid::PBE_WITHSHA1AND40BITRC2_CBC` ++ /// * `iter` - `2048` ++ /// * `mac_iter` - `2048` ++ pub fn builder() -> Pkcs12Builder { ++ ffi::init(); ++ ++ Pkcs12Builder { ++ nid_key: nid::UNDEF, //nid::PBE_WITHSHA1AND3_KEY_TRIPLEDES_CBC, ++ nid_cert: nid::UNDEF, //nid::PBE_WITHSHA1AND40BITRC2_CBC, ++ iter: ffi::PKCS12_DEFAULT_ITER, ++ mac_iter: ffi::PKCS12_DEFAULT_ITER, ++ ca: None, ++ } ++ } ++} ++ ++pub struct ParsedPkcs12 { ++ pub pkey: PKey, ++ pub cert: X509, ++ // FIXME Make this Option in the next breaking release ++ pub chain: Stack, ++} ++ ++pub struct Pkcs12Builder { ++ nid_key: nid::Nid, ++ nid_cert: nid::Nid, ++ iter: c_int, ++ mac_iter: c_int, ++ ca: Option>, ++} ++ ++impl Pkcs12Builder { ++ /// The encryption algorithm that should be used for the key ++ pub fn key_algorithm(&mut self, nid: nid::Nid) -> &mut Self { ++ self.nid_key = nid; ++ self ++ } ++ ++ /// The encryption algorithm that should be used for the cert ++ pub fn cert_algorithm(&mut self, nid: nid::Nid) -> &mut Self { ++ self.nid_cert = nid; ++ self ++ } ++ ++ /// Key iteration count, default is 2048 as of this writing ++ pub fn key_iter(&mut self, iter: u32) -> &mut Self { ++ self.iter = iter as c_int; ++ self ++ } ++ ++ /// MAC iteration count, default is the same as key_iter. ++ /// ++ /// Old implementations don't understand MAC iterations greater than 1, (pre 1.0.1?), if such ++ /// compatibility is required this should be set to 1. ++ pub fn mac_iter(&mut self, mac_iter: u32) -> &mut Self { ++ self.mac_iter = mac_iter as c_int; ++ self ++ } ++ ++ /// An additional set of certificates to include in the archive beyond the one provided to ++ /// `build`. ++ pub fn ca(&mut self, ca: Stack) -> &mut Self { ++ self.ca = Some(ca); ++ self ++ } ++ ++ /// Builds the PKCS #12 object ++ /// ++ /// # Arguments ++ /// ++ /// * `password` - the password used to encrypt the key and certificate ++ /// * `friendly_name` - user defined name for the certificate ++ /// * `pkey` - key to store ++ /// * `cert` - certificate to store ++ pub fn build( ++ self, ++ password: &str, ++ friendly_name: &str, ++ pkey: &PKeyRef, ++ cert: &X509, ++ ) -> Result { ++ unsafe { ++ let pass = CString::new(password).unwrap(); ++ let friendly_name = CString::new(friendly_name).unwrap(); ++ let pkey = pkey.as_ptr(); ++ let cert = cert.as_ptr(); ++ let ca = self.ca.as_ref().map(|ca| ca.as_ptr()).unwrap_or( ++ ptr::null_mut(), ++ ); ++ let nid_key = self.nid_key.as_raw(); ++ let nid_cert = self.nid_cert.as_raw(); ++ ++ // According to the OpenSSL docs, keytype is a non-standard extension for MSIE, ++ // It's values are KEY_SIG or KEY_EX, see the OpenSSL docs for more information: ++ // https://www.openssl.org/docs/man1.0.2/crypto/PKCS12_create.html ++ let keytype = 0; ++ ++ cvt_p(ffi::PKCS12_create( ++ pass.as_ptr() as *const _ as *mut _, ++ friendly_name.as_ptr() as *const _ as *mut _, ++ pkey, ++ cert, ++ ca, ++ nid_key, ++ nid_cert, ++ self.iter, ++ self.mac_iter, ++ keytype, ++ )).map(Pkcs12) ++ } ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use hash::MessageDigest; ++ use hex::ToHex; ++ ++ use asn1::Asn1Time; ++ use rsa::Rsa; ++ use pkey::PKey; ++ use nid; ++ use x509::{X509, X509Name}; ++ use x509::extension::KeyUsage; ++ ++ use super::*; ++ ++ #[test] ++ fn parse() { ++ let der = include_bytes!("../test/identity.p12"); ++ let pkcs12 = Pkcs12::from_der(der).unwrap(); ++ let parsed = pkcs12.parse("mypass").unwrap(); ++ ++ assert_eq!( ++ parsed ++ .cert ++ .fingerprint(MessageDigest::sha1()) ++ .unwrap() ++ .to_hex(), ++ "59172d9313e84459bcff27f967e79e6e9217e584" ++ ); ++ ++ assert_eq!(parsed.chain.len(), 1); ++ assert_eq!( ++ parsed.chain[0] ++ .fingerprint(MessageDigest::sha1()) ++ .unwrap() ++ .to_hex(), ++ "c0cbdf7cdd03c9773e5468e1f6d2da7d5cbb1875" ++ ); ++ } ++ ++ #[test] ++ fn parse_empty_chain() { ++ let der = include_bytes!("../test/keystore-empty-chain.p12"); ++ let pkcs12 = Pkcs12::from_der(der).unwrap(); ++ let parsed = pkcs12.parse("cassandra").unwrap(); ++ ++ assert_eq!(parsed.chain.len(), 0); ++ assert_eq!(parsed.chain.into_iter().collect::>().len(), 0); ++ } ++ ++ #[test] ++ fn create() { ++ let subject_name = "ns.example.com"; ++ let rsa = Rsa::generate(2048).unwrap(); ++ let pkey = PKey::from_rsa(rsa).unwrap(); ++ ++ let mut name = X509Name::builder().unwrap(); ++ name.append_entry_by_nid(nid::COMMONNAME, subject_name) ++ .unwrap(); ++ let name = name.build(); ++ ++ let key_usage = KeyUsage::new().digital_signature().build().unwrap(); ++ ++ let mut builder = X509::builder().unwrap(); ++ builder.set_version(2).unwrap(); ++ builder ++ .set_not_before(&Asn1Time::days_from_now(0).unwrap()) ++ .unwrap(); ++ builder ++ .set_not_after(&Asn1Time::days_from_now(365).unwrap()) ++ .unwrap(); ++ builder.set_subject_name(&name).unwrap(); ++ builder.set_issuer_name(&name).unwrap(); ++ builder.append_extension(key_usage).unwrap(); ++ builder.set_pubkey(&pkey).unwrap(); ++ builder.sign(&pkey, MessageDigest::sha256()).unwrap(); ++ let cert = builder.build(); ++ ++ let pkcs12_builder = Pkcs12::builder(); ++ let pkcs12 = pkcs12_builder ++ .build("mypass", subject_name, &pkey, &cert) ++ .unwrap(); ++ let der = pkcs12.to_der().unwrap(); ++ ++ let pkcs12 = Pkcs12::from_der(&der).unwrap(); ++ let parsed = pkcs12.parse("mypass").unwrap(); ++ ++ assert_eq!( ++ parsed.cert.fingerprint(MessageDigest::sha1()).unwrap(), ++ cert.fingerprint(MessageDigest::sha1()).unwrap() ++ ); ++ assert!(parsed.pkey.public_eq(&pkey)); ++ } ++} diff --cc vendor/openssl-0.9.19/src/pkcs5.rs index 000000000,000000000..0d574c08a new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/pkcs5.rs @@@ -1,0 -1,0 +1,570 @@@ ++use libc::c_int; ++use std::ptr; ++use ffi; ++ ++use cvt; ++use hash::MessageDigest; ++use symm::Cipher; ++use error::ErrorStack; ++ ++#[derive(Clone, Eq, PartialEq, Hash, Debug)] ++pub struct KeyIvPair { ++ pub key: Vec, ++ pub iv: Option>, ++} ++ ++/// Derives a key and an IV from various parameters. ++/// ++/// If specified, `salt` must be 8 bytes in length. ++/// ++/// If the total key and IV length is less than 16 bytes and MD5 is used then ++/// the algorithm is compatible with the key derivation algorithm from PKCS#5 ++/// v1.5 or PBKDF1 from PKCS#5 v2.0. ++/// ++/// New applications should not use this and instead use ++/// `pbkdf2_hmac` or another more modern key derivation algorithm. ++pub fn bytes_to_key( ++ cipher: Cipher, ++ digest: MessageDigest, ++ data: &[u8], ++ salt: Option<&[u8]>, ++ count: i32, ++) -> Result { ++ unsafe { ++ assert!(data.len() <= c_int::max_value() as usize); ++ let salt_ptr = match salt { ++ Some(salt) => { ++ assert_eq!(salt.len(), ffi::PKCS5_SALT_LEN as usize); ++ salt.as_ptr() ++ } ++ None => ptr::null(), ++ }; ++ ++ ffi::init(); ++ ++ let mut iv = cipher.iv_len().map(|l| vec![0; l]); ++ ++ let cipher = cipher.as_ptr(); ++ let digest = digest.as_ptr(); ++ ++ let len = try!(cvt(ffi::EVP_BytesToKey( ++ cipher, ++ digest, ++ salt_ptr, ++ ptr::null(), ++ data.len() as c_int, ++ count.into(), ++ ptr::null_mut(), ++ ptr::null_mut(), ++ ))); ++ ++ let mut key = vec![0; len as usize]; ++ let iv_ptr = iv.as_mut().map(|v| v.as_mut_ptr()).unwrap_or( ++ ptr::null_mut(), ++ ); ++ ++ try!(cvt(ffi::EVP_BytesToKey( ++ cipher, ++ digest, ++ salt_ptr, ++ data.as_ptr(), ++ data.len() as c_int, ++ count as c_int, ++ key.as_mut_ptr(), ++ iv_ptr, ++ ))); ++ ++ Ok(KeyIvPair { key: key, iv: iv }) ++ } ++} ++ ++/// Derives a key from a password and salt using the PBKDF2-HMAC algorithm with a digest function. ++pub fn pbkdf2_hmac( ++ pass: &[u8], ++ salt: &[u8], ++ iter: usize, ++ hash: MessageDigest, ++ key: &mut [u8], ++) -> Result<(), ErrorStack> { ++ unsafe { ++ assert!(pass.len() <= c_int::max_value() as usize); ++ assert!(salt.len() <= c_int::max_value() as usize); ++ assert!(key.len() <= c_int::max_value() as usize); ++ ++ ffi::init(); ++ cvt(ffi::PKCS5_PBKDF2_HMAC( ++ pass.as_ptr() as *const _, ++ pass.len() as c_int, ++ salt.as_ptr(), ++ salt.len() as c_int, ++ iter as c_int, ++ hash.as_ptr(), ++ key.len() as c_int, ++ key.as_mut_ptr(), ++ )).map(|_| ()) ++ } ++} ++ ++/// Derives a key from a password and salt using the scrypt algorithm. ++/// ++/// Requires the `v110` feature and OpenSSL 1.1.0. ++#[cfg(all(feature = "v110", ossl110))] ++pub fn scrypt( ++ pass: &[u8], ++ salt: &[u8], ++ n: u64, ++ r: u64, ++ p: u64, ++ maxmem: u64, ++ key: &mut [u8], ++) -> Result<(), ErrorStack> { ++ unsafe { ++ ffi::init(); ++ cvt(ffi::EVP_PBE_scrypt( ++ pass.as_ptr() as *const _, ++ pass.len(), ++ salt.as_ptr() as *const _, ++ salt.len(), ++ n, ++ r, ++ p, ++ maxmem, ++ key.as_mut_ptr() as *mut _, ++ key.len(), ++ )).map(|_| ()) ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use hash::MessageDigest; ++ use symm::Cipher; ++ ++ // Test vectors from ++ // https://git.lysator.liu.se/nettle/nettle/blob/nettle_3.1.1_release_20150424/testsuite/pbkdf2-test.c ++ #[test] ++ fn pbkdf2_hmac_sha256() { ++ let mut buf = [0; 16]; ++ ++ super::pbkdf2_hmac(b"passwd", b"salt", 1, MessageDigest::sha256(), &mut buf).unwrap(); ++ assert_eq!( ++ buf, ++ &[ ++ 0x55_u8, ++ 0xac_u8, ++ 0x04_u8, ++ 0x6e_u8, ++ 0x56_u8, ++ 0xe3_u8, ++ 0x08_u8, ++ 0x9f_u8, ++ 0xec_u8, ++ 0x16_u8, ++ 0x91_u8, ++ 0xc2_u8, ++ 0x25_u8, ++ 0x44_u8, ++ 0xb6_u8, ++ 0x05_u8, ++ ] ++ [..] ++ ); ++ ++ super::pbkdf2_hmac( ++ b"Password", ++ b"NaCl", ++ 80000, ++ MessageDigest::sha256(), ++ &mut buf, ++ ).unwrap(); ++ assert_eq!( ++ buf, ++ &[ ++ 0x4d_u8, ++ 0xdc_u8, ++ 0xd8_u8, ++ 0xf6_u8, ++ 0x0b_u8, ++ 0x98_u8, ++ 0xbe_u8, ++ 0x21_u8, ++ 0x83_u8, ++ 0x0c_u8, ++ 0xee_u8, ++ 0x5e_u8, ++ 0xf2_u8, ++ 0x27_u8, ++ 0x01_u8, ++ 0xf9_u8, ++ ] ++ [..] ++ ); ++ } ++ ++ // Test vectors from ++ // https://git.lysator.liu.se/nettle/nettle/blob/nettle_3.1.1_release_20150424/testsuite/pbkdf2-test.c ++ #[test] ++ fn pbkdf2_hmac_sha512() { ++ let mut buf = [0; 64]; ++ ++ super::pbkdf2_hmac(b"password", b"NaCL", 1, MessageDigest::sha512(), &mut buf).unwrap(); ++ assert_eq!( ++ &buf[..], ++ &[ ++ 0x73_u8, ++ 0xde_u8, ++ 0xcf_u8, ++ 0xa5_u8, ++ 0x8a_u8, ++ 0xa2_u8, ++ 0xe8_u8, ++ 0x4f_u8, ++ 0x94_u8, ++ 0x77_u8, ++ 0x1a_u8, ++ 0x75_u8, ++ 0x73_u8, ++ 0x6b_u8, ++ 0xb8_u8, ++ 0x8b_u8, ++ 0xd3_u8, ++ 0xc7_u8, ++ 0xb3_u8, ++ 0x82_u8, ++ 0x70_u8, ++ 0xcf_u8, ++ 0xb5_u8, ++ 0x0c_u8, ++ 0xb3_u8, ++ 0x90_u8, ++ 0xed_u8, ++ 0x78_u8, ++ 0xb3_u8, ++ 0x05_u8, ++ 0x65_u8, ++ 0x6a_u8, ++ 0xf8_u8, ++ 0x14_u8, ++ 0x8e_u8, ++ 0x52_u8, ++ 0x45_u8, ++ 0x2b_u8, ++ 0x22_u8, ++ 0x16_u8, ++ 0xb2_u8, ++ 0xb8_u8, ++ 0x09_u8, ++ 0x8b_u8, ++ 0x76_u8, ++ 0x1f_u8, ++ 0xc6_u8, ++ 0x33_u8, ++ 0x60_u8, ++ 0x60_u8, ++ 0xa0_u8, ++ 0x9f_u8, ++ 0x76_u8, ++ 0x41_u8, ++ 0x5e_u8, ++ 0x9f_u8, ++ 0x71_u8, ++ 0xea_u8, ++ 0x47_u8, ++ 0xf9_u8, ++ 0xe9_u8, ++ 0x06_u8, ++ 0x43_u8, ++ 0x06_u8, ++ ] ++ [..] ++ ); ++ ++ super::pbkdf2_hmac( ++ b"pass\0word", ++ b"sa\0lt", ++ 1, ++ MessageDigest::sha512(), ++ &mut buf, ++ ).unwrap(); ++ assert_eq!( ++ &buf[..], ++ &[ ++ 0x71_u8, ++ 0xa0_u8, ++ 0xec_u8, ++ 0x84_u8, ++ 0x2a_u8, ++ 0xbd_u8, ++ 0x5c_u8, ++ 0x67_u8, ++ 0x8b_u8, ++ 0xcf_u8, ++ 0xd1_u8, ++ 0x45_u8, ++ 0xf0_u8, ++ 0x9d_u8, ++ 0x83_u8, ++ 0x52_u8, ++ 0x2f_u8, ++ 0x93_u8, ++ 0x36_u8, ++ 0x15_u8, ++ 0x60_u8, ++ 0x56_u8, ++ 0x3c_u8, ++ 0x4d_u8, ++ 0x0d_u8, ++ 0x63_u8, ++ 0xb8_u8, ++ 0x83_u8, ++ 0x29_u8, ++ 0x87_u8, ++ 0x10_u8, ++ 0x90_u8, ++ 0xe7_u8, ++ 0x66_u8, ++ 0x04_u8, ++ 0xa4_u8, ++ 0x9a_u8, ++ 0xf0_u8, ++ 0x8f_u8, ++ 0xe7_u8, ++ 0xc9_u8, ++ 0xf5_u8, ++ 0x71_u8, ++ 0x56_u8, ++ 0xc8_u8, ++ 0x79_u8, ++ 0x09_u8, ++ 0x96_u8, ++ 0xb2_u8, ++ 0x0f_u8, ++ 0x06_u8, ++ 0xbc_u8, ++ 0x53_u8, ++ 0x5e_u8, ++ 0x5a_u8, ++ 0xb5_u8, ++ 0x44_u8, ++ 0x0d_u8, ++ 0xf7_u8, ++ 0xe8_u8, ++ 0x78_u8, ++ 0x29_u8, ++ 0x6f_u8, ++ 0xa7_u8, ++ ] ++ [..] ++ ); ++ ++ super::pbkdf2_hmac( ++ b"passwordPASSWORDpassword", ++ b"salt\0\0\0", ++ 50, ++ MessageDigest::sha512(), ++ &mut buf, ++ ).unwrap(); ++ assert_eq!( ++ &buf[..], ++ &[ ++ 0x01_u8, ++ 0x68_u8, ++ 0x71_u8, ++ 0xa4_u8, ++ 0xc4_u8, ++ 0xb7_u8, ++ 0x5f_u8, ++ 0x96_u8, ++ 0x85_u8, ++ 0x7f_u8, ++ 0xd2_u8, ++ 0xb9_u8, ++ 0xf8_u8, ++ 0xca_u8, ++ 0x28_u8, ++ 0x02_u8, ++ 0x3b_u8, ++ 0x30_u8, ++ 0xee_u8, ++ 0x2a_u8, ++ 0x39_u8, ++ 0xf5_u8, ++ 0xad_u8, ++ 0xca_u8, ++ 0xc8_u8, ++ 0xc9_u8, ++ 0x37_u8, ++ 0x5f_u8, ++ 0x9b_u8, ++ 0xda_u8, ++ 0x1c_u8, ++ 0xcd_u8, ++ 0x1b_u8, ++ 0x6f_u8, ++ 0x0b_u8, ++ 0x2f_u8, ++ 0xc3_u8, ++ 0xad_u8, ++ 0xda_u8, ++ 0x50_u8, ++ 0x54_u8, ++ 0x12_u8, ++ 0xe7_u8, ++ 0x9d_u8, ++ 0x89_u8, ++ 0x00_u8, ++ 0x56_u8, ++ 0xc6_u8, ++ 0x2e_u8, ++ 0x52_u8, ++ 0x4c_u8, ++ 0x7d_u8, ++ 0x51_u8, ++ 0x15_u8, ++ 0x4b_u8, ++ 0x1a_u8, ++ 0x85_u8, ++ 0x34_u8, ++ 0x57_u8, ++ 0x5b_u8, ++ 0xd0_u8, ++ 0x2d_u8, ++ 0xee_u8, ++ 0x39_u8, ++ ] ++ [..] ++ ); ++ } ++ ++ #[test] ++ fn bytes_to_key() { ++ let salt = [16_u8, 34_u8, 19_u8, 23_u8, 141_u8, 4_u8, 207_u8, 221_u8]; ++ ++ let data = [ ++ 143_u8, ++ 210_u8, ++ 75_u8, ++ 63_u8, ++ 214_u8, ++ 179_u8, ++ 155_u8, ++ 241_u8, ++ 242_u8, ++ 31_u8, ++ 154_u8, ++ 56_u8, ++ 198_u8, ++ 145_u8, ++ 192_u8, ++ 64_u8, ++ 2_u8, ++ 245_u8, ++ 167_u8, ++ 220_u8, ++ 55_u8, ++ 119_u8, ++ 233_u8, ++ 136_u8, ++ 139_u8, ++ 27_u8, ++ 71_u8, ++ 242_u8, ++ 119_u8, ++ 175_u8, ++ 65_u8, ++ 207_u8, ++ ]; ++ ++ ++ ++ let expected_key = vec![ ++ 249_u8, ++ 115_u8, ++ 114_u8, ++ 97_u8, ++ 32_u8, ++ 213_u8, ++ 165_u8, ++ 146_u8, ++ 58_u8, ++ 87_u8, ++ 234_u8, ++ 3_u8, ++ 43_u8, ++ 250_u8, ++ 97_u8, ++ 114_u8, ++ 26_u8, ++ 98_u8, ++ 245_u8, ++ 246_u8, ++ 238_u8, ++ 177_u8, ++ 229_u8, ++ 161_u8, ++ 183_u8, ++ 224_u8, ++ 174_u8, ++ 3_u8, ++ 6_u8, ++ 244_u8, ++ 236_u8, ++ 255_u8, ++ ]; ++ let expected_iv = vec![ ++ 4_u8, ++ 223_u8, ++ 153_u8, ++ 219_u8, ++ 28_u8, ++ 142_u8, ++ 234_u8, ++ 68_u8, ++ 227_u8, ++ 69_u8, ++ 98_u8, ++ 107_u8, ++ 208_u8, ++ 14_u8, ++ 236_u8, ++ 60_u8, ++ ]; ++ ++ assert_eq!( ++ super::bytes_to_key( ++ Cipher::aes_256_cbc(), ++ MessageDigest::sha1(), ++ &data, ++ Some(&salt), ++ 1, ++ ).unwrap(), ++ super::KeyIvPair { ++ key: expected_key, ++ iv: Some(expected_iv), ++ } ++ ); ++ } ++ ++ #[test] ++ #[cfg(all(feature = "v110", ossl110))] ++ fn scrypt() { ++ use hex::ToHex; ++ ++ let pass = "pleaseletmein"; ++ let salt = "SodiumChloride"; ++ let expected = "7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613\ ++ f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887"; ++ ++ let mut actual = [0; 64]; ++ super::scrypt( ++ pass.as_bytes(), ++ salt.as_bytes(), ++ 16384, ++ 8, ++ 1, ++ 0, ++ &mut actual, ++ ).unwrap(); ++ assert_eq!((&actual[..]).to_hex(), expected); ++ } ++} diff --cc vendor/openssl-0.9.19/src/pkey.rs index 000000000,000000000..aba52ae61 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/pkey.rs @@@ -1,0 -1,0 +1,431 @@@ ++use libc::{c_void, c_char, c_int, size_t}; ++use std::ptr; ++use std::mem; ++use std::ffi::CString; ++use ffi; ++use foreign_types::{ForeignType, ForeignTypeRef}; ++ ++use {cvt, cvt_p}; ++use bio::MemBioSlice; ++use dh::Dh; ++use dsa::Dsa; ++use ec::EcKey; ++use rsa::{Rsa, Padding}; ++use error::ErrorStack; ++use util::{CallbackState, invoke_passwd_cb, invoke_passwd_cb_old}; ++ ++foreign_type! { ++ type CType = ffi::EVP_PKEY; ++ fn drop = ffi::EVP_PKEY_free; ++ ++ pub struct PKey; ++ pub struct PKeyRef; ++} ++ ++impl PKeyRef { ++ /// Returns a copy of the internal RSA key. ++ pub fn rsa(&self) -> Result { ++ unsafe { ++ let rsa = try!(cvt_p(ffi::EVP_PKEY_get1_RSA(self.as_ptr()))); ++ Ok(Rsa::from_ptr(rsa)) ++ } ++ } ++ ++ /// Returns a copy of the internal DSA key. ++ pub fn dsa(&self) -> Result { ++ unsafe { ++ let dsa = try!(cvt_p(ffi::EVP_PKEY_get1_DSA(self.as_ptr()))); ++ Ok(Dsa::from_ptr(dsa)) ++ } ++ } ++ ++ /// Returns a copy of the internal DH key. ++ pub fn dh(&self) -> Result { ++ unsafe { ++ let dh = try!(cvt_p(ffi::EVP_PKEY_get1_DH(self.as_ptr()))); ++ Ok(Dh::from_ptr(dh)) ++ } ++ } ++ ++ /// Returns a copy of the internal elliptic curve key. ++ pub fn ec_key(&self) -> Result { ++ unsafe { ++ let ec_key = try!(cvt_p(ffi::EVP_PKEY_get1_EC_KEY(self.as_ptr()))); ++ Ok(EcKey::from_ptr(ec_key)) ++ } ++ } ++ ++ public_key_to_pem!(ffi::PEM_write_bio_PUBKEY); ++ private_key_to_pem!(ffi::PEM_write_bio_PKCS8PrivateKey); ++ ++ private_key_to_der!(ffi::i2d_PrivateKey); ++ public_key_to_der!(ffi::i2d_PUBKEY); ++ ++ /// Returns the size of the key. ++ /// ++ /// This corresponds to the bit length of the modulus of an RSA key, and the bit length of the ++ /// group order for an elliptic curve key, for example. ++ pub fn bits(&self) -> u32 { ++ unsafe { ffi::EVP_PKEY_bits(self.as_ptr()) as u32 } ++ } ++ ++ /// Compares the public component of this key with another. ++ pub fn public_eq(&self, other: &PKeyRef) -> bool { ++ unsafe { ffi::EVP_PKEY_cmp(self.as_ptr(), other.as_ptr()) == 1 } ++ } ++} ++ ++unsafe impl Send for PKey {} ++unsafe impl Sync for PKey {} ++ ++impl PKey { ++ /// Creates a new `PKey` containing an RSA key. ++ pub fn from_rsa(rsa: Rsa) -> Result { ++ unsafe { ++ let evp = try!(cvt_p(ffi::EVP_PKEY_new())); ++ let pkey = PKey(evp); ++ try!(cvt(ffi::EVP_PKEY_assign( ++ pkey.0, ++ ffi::EVP_PKEY_RSA, ++ rsa.as_ptr() as *mut _, ++ ))); ++ mem::forget(rsa); ++ Ok(pkey) ++ } ++ } ++ ++ /// Creates a new `PKey` containing a DSA key. ++ pub fn from_dsa(dsa: Dsa) -> Result { ++ unsafe { ++ let evp = try!(cvt_p(ffi::EVP_PKEY_new())); ++ let pkey = PKey(evp); ++ try!(cvt(ffi::EVP_PKEY_assign( ++ pkey.0, ++ ffi::EVP_PKEY_DSA, ++ dsa.as_ptr() as *mut _, ++ ))); ++ mem::forget(dsa); ++ Ok(pkey) ++ } ++ } ++ ++ /// Creates a new `PKey` containing a Diffie-Hellman key. ++ pub fn from_dh(dh: Dh) -> Result { ++ unsafe { ++ let evp = try!(cvt_p(ffi::EVP_PKEY_new())); ++ let pkey = PKey(evp); ++ try!(cvt(ffi::EVP_PKEY_assign( ++ pkey.0, ++ ffi::EVP_PKEY_DH, ++ dh.as_ptr() as *mut _, ++ ))); ++ mem::forget(dh); ++ Ok(pkey) ++ } ++ } ++ ++ /// Creates a new `PKey` containing an elliptic curve key. ++ pub fn from_ec_key(ec_key: EcKey) -> Result { ++ unsafe { ++ let evp = try!(cvt_p(ffi::EVP_PKEY_new())); ++ let pkey = PKey(evp); ++ try!(cvt(ffi::EVP_PKEY_assign( ++ pkey.0, ++ ffi::EVP_PKEY_EC, ++ ec_key.as_ptr() as *mut _, ++ ))); ++ mem::forget(ec_key); ++ Ok(pkey) ++ } ++ } ++ ++ /// Creates a new `PKey` containing an HMAC key. ++ /// ++ /// # Note ++ /// To compute HMAC values, use the `sign` module. ++ pub fn hmac(key: &[u8]) -> Result { ++ unsafe { ++ assert!(key.len() <= c_int::max_value() as usize); ++ let key = try!(cvt_p(ffi::EVP_PKEY_new_mac_key( ++ ffi::EVP_PKEY_HMAC, ++ ptr::null_mut(), ++ key.as_ptr() as *const _, ++ key.len() as c_int, ++ ))); ++ Ok(PKey(key)) ++ } ++ } ++ ++ private_key_from_pem!(PKey, ffi::PEM_read_bio_PrivateKey); ++ public_key_from_pem!(PKey, ffi::PEM_read_bio_PUBKEY); ++ public_key_from_der!(PKey, ffi::d2i_PUBKEY); ++ private_key_from_der!(PKey, ffi::d2i_AutoPrivateKey); ++ ++ /// Deserializes a DER-formatted PKCS#8 private key, using a callback to retrieve the password ++ /// if the key is encrpyted. ++ /// ++ /// The callback should copy the password into the provided buffer and return the number of ++ /// bytes written. ++ pub fn private_key_from_pkcs8_callback(der: &[u8], callback: F) -> Result ++ where ++ F: FnOnce(&mut [u8]) -> Result, ++ { ++ unsafe { ++ ffi::init(); ++ let mut cb = CallbackState::new(callback); ++ let bio = try!(MemBioSlice::new(der)); ++ cvt_p(ffi::d2i_PKCS8PrivateKey_bio( ++ bio.as_ptr(), ++ ptr::null_mut(), ++ Some(invoke_passwd_cb::), ++ &mut cb as *mut _ as *mut _, ++ )).map(PKey) ++ } ++ } ++ ++ /// Deserializes a DER-formatted PKCS#8 private key, using the supplied password if the key is ++ /// encrypted. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `passphrase` contains an embedded null. ++ pub fn private_key_from_pkcs8_passphrase( ++ der: &[u8], ++ passphrase: &[u8], ++ ) -> Result { ++ unsafe { ++ ffi::init(); ++ let bio = try!(MemBioSlice::new(der)); ++ let passphrase = CString::new(passphrase).unwrap(); ++ cvt_p(ffi::d2i_PKCS8PrivateKey_bio( ++ bio.as_ptr(), ++ ptr::null_mut(), ++ None, ++ passphrase.as_ptr() as *const _ as *mut _, ++ )).map(PKey) ++ } ++ } ++ ++ #[deprecated(since = "0.9.2", note = "use private_key_from_pem_callback")] ++ pub fn private_key_from_pem_cb(buf: &[u8], pass_cb: F) -> Result ++ where ++ F: FnOnce(&mut [c_char]) -> usize, ++ { ++ ffi::init(); ++ let mut cb = CallbackState::new(pass_cb); ++ let mem_bio = try!(MemBioSlice::new(buf)); ++ unsafe { ++ let evp = try!(cvt_p(ffi::PEM_read_bio_PrivateKey( ++ mem_bio.as_ptr(), ++ ptr::null_mut(), ++ Some(invoke_passwd_cb_old::), ++ &mut cb as *mut _ as *mut c_void, ++ ))); ++ Ok(PKey::from_ptr(evp)) ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::EVP_PKEY_CTX; ++ fn drop = ffi::EVP_PKEY_CTX_free; ++ ++ pub struct PKeyCtx; ++ pub struct PKeyCtxRef; ++} ++ ++unsafe impl Send for PKeyCtx {} ++unsafe impl Sync for PKeyCtx {} ++ ++impl PKeyCtx { ++ pub fn from_pkey(pkey: &PKeyRef) -> Result { ++ unsafe { ++ let evp = try!(cvt_p(ffi::EVP_PKEY_CTX_new(pkey.as_ptr(), ptr::null_mut()))); ++ Ok(PKeyCtx(evp)) ++ } ++ } ++} ++ ++impl PKeyCtxRef { ++ pub fn set_rsa_padding(&mut self, pad: Padding) -> Result<(), ErrorStack> { ++ unsafe { ++ try!(cvt(ffi::EVP_PKEY_CTX_set_rsa_padding( ++ self.as_ptr(), ++ pad.as_raw(), ++ ))); ++ } ++ Ok(()) ++ } ++ ++ pub fn rsa_padding(&self) -> Result { ++ let mut pad: c_int = 0; ++ unsafe { ++ try!(cvt( ++ ffi::EVP_PKEY_CTX_get_rsa_padding(self.as_ptr(), &mut pad), ++ )); ++ }; ++ Ok(Padding::from_raw(pad)) ++ } ++ ++ pub fn derive_init(&mut self) -> Result<(), ErrorStack> { ++ unsafe { ++ try!(cvt(ffi::EVP_PKEY_derive_init(self.as_ptr()))); ++ } ++ Ok(()) ++ } ++ ++ pub fn derive_set_peer(&mut self, peer: &PKeyRef) -> Result<(), ErrorStack> { ++ unsafe { ++ try!(cvt( ++ ffi::EVP_PKEY_derive_set_peer(self.as_ptr(), peer.as_ptr()), ++ )); ++ } ++ Ok(()) ++ } ++ ++ pub fn derive(&mut self) -> Result, ErrorStack> { ++ let mut len: size_t = 0; ++ unsafe { ++ try!(cvt(ffi::EVP_PKEY_derive( ++ self.as_ptr(), ++ ptr::null_mut(), ++ &mut len, ++ ))); ++ } ++ ++ let mut key = vec![0u8; len]; ++ unsafe { ++ try!(cvt(ffi::EVP_PKEY_derive( ++ self.as_ptr(), ++ key.as_mut_ptr(), ++ &mut len, ++ ))); ++ } ++ Ok(key) ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use symm::Cipher; ++ use dh::Dh; ++ use dsa::Dsa; ++ use ec::{EcGroup, EcKey}; ++ use rsa::Rsa; ++ use nid; ++ ++ use super::*; ++ ++ #[test] ++ fn test_to_password() { ++ let rsa = Rsa::generate(2048).unwrap(); ++ let pkey = PKey::from_rsa(rsa).unwrap(); ++ let pem = pkey.private_key_to_pem_passphrase(Cipher::aes_128_cbc(), b"foobar") ++ .unwrap(); ++ PKey::private_key_from_pem_passphrase(&pem, b"foobar").unwrap(); ++ assert!(PKey::private_key_from_pem_passphrase(&pem, b"fizzbuzz").is_err()); ++ } ++ ++ #[test] ++ fn test_encrypted_pkcs8_passphrase() { ++ let key = include_bytes!("../test/pkcs8.der"); ++ PKey::private_key_from_pkcs8_passphrase(key, b"mypass").unwrap(); ++ } ++ ++ #[test] ++ fn test_encrypted_pkcs8_callback() { ++ let mut password_queried = false; ++ let key = include_bytes!("../test/pkcs8.der"); ++ PKey::private_key_from_pkcs8_callback(key, |password| { ++ password_queried = true; ++ password[..6].copy_from_slice(b"mypass"); ++ Ok(6) ++ }).unwrap(); ++ assert!(password_queried); ++ } ++ ++ #[test] ++ fn test_private_key_from_pem() { ++ let key = include_bytes!("../test/key.pem"); ++ PKey::private_key_from_pem(key).unwrap(); ++ } ++ ++ #[test] ++ fn test_public_key_from_pem() { ++ let key = include_bytes!("../test/key.pem.pub"); ++ PKey::public_key_from_pem(key).unwrap(); ++ } ++ ++ #[test] ++ fn test_public_key_from_der() { ++ let key = include_bytes!("../test/key.der.pub"); ++ PKey::public_key_from_der(key).unwrap(); ++ } ++ ++ #[test] ++ fn test_private_key_from_der() { ++ let key = include_bytes!("../test/key.der"); ++ PKey::private_key_from_der(key).unwrap(); ++ } ++ ++ #[test] ++ fn test_pem() { ++ let key = include_bytes!("../test/key.pem"); ++ let key = PKey::private_key_from_pem(key).unwrap(); ++ ++ let priv_key = key.private_key_to_pem().unwrap(); ++ let pub_key = key.public_key_to_pem().unwrap(); ++ ++ // As a super-simple verification, just check that the buffers contain ++ // the `PRIVATE KEY` or `PUBLIC KEY` strings. ++ assert!(priv_key.windows(11).any(|s| s == b"PRIVATE KEY")); ++ assert!(pub_key.windows(10).any(|s| s == b"PUBLIC KEY")); ++ } ++ ++ #[test] ++ fn test_rsa_accessor() { ++ let rsa = Rsa::generate(2048).unwrap(); ++ let pkey = PKey::from_rsa(rsa).unwrap(); ++ pkey.rsa().unwrap(); ++ assert!(pkey.dsa().is_err()); ++ } ++ ++ #[test] ++ fn test_dsa_accessor() { ++ let dsa = Dsa::generate(2048).unwrap(); ++ let pkey = PKey::from_dsa(dsa).unwrap(); ++ pkey.dsa().unwrap(); ++ assert!(pkey.rsa().is_err()); ++ } ++ ++ #[test] ++ fn test_dh_accessor() { ++ let dh = include_bytes!("../test/dhparams.pem"); ++ let dh = Dh::from_pem(dh).unwrap(); ++ let pkey = PKey::from_dh(dh).unwrap(); ++ pkey.dh().unwrap(); ++ assert!(pkey.rsa().is_err()); ++ } ++ ++ #[test] ++ fn test_ec_key_accessor() { ++ let ec_key = EcKey::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let pkey = PKey::from_ec_key(ec_key).unwrap(); ++ pkey.ec_key().unwrap(); ++ assert!(pkey.rsa().is_err()); ++ } ++ ++ #[test] ++ fn test_ec_key_derive() { ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let ec_key = EcKey::generate(&group).unwrap(); ++ let ec_key2 = EcKey::generate(&group).unwrap(); ++ let pkey = PKey::from_ec_key(ec_key).unwrap(); ++ let pkey2 = PKey::from_ec_key(ec_key2).unwrap(); ++ let mut pkey_ctx = PKeyCtx::from_pkey(&pkey).unwrap(); ++ pkey_ctx.derive_init().unwrap(); ++ pkey_ctx.derive_set_peer(&pkey2).unwrap(); ++ let shared = pkey_ctx.derive().unwrap(); ++ assert!(!shared.is_empty()); ++ } ++} diff --cc vendor/openssl-0.9.19/src/rand.rs index 000000000,000000000..c1c49e7bd new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/rand.rs @@@ -1,0 -1,0 +1,24 @@@ ++use libc::c_int; ++use ffi; ++ ++use cvt; ++use error::ErrorStack; ++ ++pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> { ++ unsafe { ++ ffi::init(); ++ assert!(buf.len() <= c_int::max_value() as usize); ++ cvt(ffi::RAND_bytes(buf.as_mut_ptr(), buf.len() as c_int)).map(|_| ()) ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use super::rand_bytes; ++ ++ #[test] ++ fn test_rand_bytes() { ++ let mut buf = [0; 32]; ++ rand_bytes(&mut buf).unwrap(); ++ } ++} diff --cc vendor/openssl-0.9.19/src/rsa.rs index 000000000,000000000..e5126e5fa new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/rsa.rs @@@ -1,0 -1,0 +1,495 @@@ ++use ffi; ++use std::fmt; ++use std::ptr; ++use std::mem; ++use libc::{c_int, c_void, c_char}; ++use foreign_types::ForeignTypeRef; ++ ++use {cvt, cvt_p, cvt_n}; ++use bn::{BigNum, BigNumRef}; ++use bio::MemBioSlice; ++use error::ErrorStack; ++use util::{CallbackState, invoke_passwd_cb_old}; ++ ++/// Type of encryption padding to use. ++#[derive(Debug, Copy, Clone, PartialEq, Eq)] ++pub struct Padding(c_int); ++ ++impl Padding { ++ pub fn from_raw(value: c_int) -> Padding { ++ Padding(value) ++ } ++ ++ pub fn as_raw(&self) -> c_int { ++ self.0 ++ } ++} ++ ++pub const NO_PADDING: Padding = Padding(ffi::RSA_NO_PADDING); ++pub const PKCS1_PADDING: Padding = Padding(ffi::RSA_PKCS1_PADDING); ++pub const PKCS1_OAEP_PADDING: Padding = Padding(ffi::RSA_PKCS1_OAEP_PADDING); ++ ++foreign_type! { ++ type CType = ffi::RSA; ++ fn drop = ffi::RSA_free; ++ ++ pub struct Rsa; ++ pub struct RsaRef; ++} ++ ++impl RsaRef { ++ // FIXME these need to specify output format ++ private_key_to_pem!(ffi::PEM_write_bio_RSAPrivateKey); ++ public_key_to_pem!(ffi::PEM_write_bio_RSA_PUBKEY); ++ ++ private_key_to_der!(ffi::i2d_RSAPrivateKey); ++ public_key_to_der!(ffi::i2d_RSA_PUBKEY); ++ ++ to_der_inner!( ++ /// Serializes the public key to DER-encoded PKCS#1. ++ public_key_to_der_pkcs1, ++ ffi::i2d_RSAPublicKey ++ ); ++ ++ // FIXME should return u32 ++ pub fn size(&self) -> usize { ++ unsafe { ++ assert!(self.n().is_some()); ++ ++ ffi::RSA_size(self.as_ptr()) as usize ++ } ++ } ++ ++ /// Decrypts data using the private key, returning the number of decrypted bytes. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `self` has no private components, or if `to` is smaller ++ /// than `self.size()`. ++ pub fn private_decrypt( ++ &self, ++ from: &[u8], ++ to: &mut [u8], ++ padding: Padding, ++ ) -> Result { ++ assert!(self.d().is_some(), "private components missing"); ++ assert!(from.len() <= i32::max_value() as usize); ++ assert!(to.len() >= self.size()); ++ ++ unsafe { ++ let len = try!(cvt_n(ffi::RSA_private_decrypt( ++ from.len() as c_int, ++ from.as_ptr(), ++ to.as_mut_ptr(), ++ self.as_ptr(), ++ padding.0, ++ ))); ++ Ok(len as usize) ++ } ++ } ++ ++ /// Encrypts data using the private key, returning the number of encrypted bytes. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `self` has no private components, or if `to` is smaller ++ /// than `self.size()`. ++ pub fn private_encrypt( ++ &self, ++ from: &[u8], ++ to: &mut [u8], ++ padding: Padding, ++ ) -> Result { ++ assert!(self.d().is_some(), "private components missing"); ++ assert!(from.len() <= i32::max_value() as usize); ++ assert!(to.len() >= self.size()); ++ ++ unsafe { ++ let len = try!(cvt_n(ffi::RSA_private_encrypt( ++ from.len() as c_int, ++ from.as_ptr(), ++ to.as_mut_ptr(), ++ self.as_ptr(), ++ padding.0, ++ ))); ++ Ok(len as usize) ++ } ++ } ++ ++ /// Decrypts data using the public key, returning the number of decrypted bytes. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `to` is smaller than `self.size()`. ++ pub fn public_decrypt( ++ &self, ++ from: &[u8], ++ to: &mut [u8], ++ padding: Padding, ++ ) -> Result { ++ assert!(from.len() <= i32::max_value() as usize); ++ assert!(to.len() >= self.size()); ++ ++ unsafe { ++ let len = try!(cvt_n(ffi::RSA_public_decrypt( ++ from.len() as c_int, ++ from.as_ptr(), ++ to.as_mut_ptr(), ++ self.as_ptr(), ++ padding.0, ++ ))); ++ Ok(len as usize) ++ } ++ } ++ ++ /// Encrypts data using the public key, returning the number of encrypted bytes. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `to` is smaller than `self.size()`. ++ pub fn public_encrypt( ++ &self, ++ from: &[u8], ++ to: &mut [u8], ++ padding: Padding, ++ ) -> Result { ++ assert!(from.len() <= i32::max_value() as usize); ++ assert!(to.len() >= self.size()); ++ ++ unsafe { ++ let len = try!(cvt_n(ffi::RSA_public_encrypt( ++ from.len() as c_int, ++ from.as_ptr(), ++ to.as_mut_ptr(), ++ self.as_ptr(), ++ padding.0, ++ ))); ++ Ok(len as usize) ++ } ++ } ++ ++ pub fn n(&self) -> Option<&BigNumRef> { ++ unsafe { ++ let n = compat::key(self.as_ptr())[0]; ++ if n.is_null() { ++ None ++ } else { ++ Some(BigNumRef::from_ptr(n as *mut _)) ++ } ++ } ++ } ++ ++ pub fn d(&self) -> Option<&BigNumRef> { ++ unsafe { ++ let d = compat::key(self.as_ptr())[2]; ++ if d.is_null() { ++ None ++ } else { ++ Some(BigNumRef::from_ptr(d as *mut _)) ++ } ++ } ++ } ++ ++ pub fn e(&self) -> Option<&BigNumRef> { ++ unsafe { ++ let e = compat::key(self.as_ptr())[1]; ++ if e.is_null() { ++ None ++ } else { ++ Some(BigNumRef::from_ptr(e as *mut _)) ++ } ++ } ++ } ++ ++ pub fn p(&self) -> Option<&BigNumRef> { ++ unsafe { ++ let p = compat::factors(self.as_ptr())[0]; ++ if p.is_null() { ++ None ++ } else { ++ Some(BigNumRef::from_ptr(p as *mut _)) ++ } ++ } ++ } ++ ++ pub fn q(&self) -> Option<&BigNumRef> { ++ unsafe { ++ let q = compat::factors(self.as_ptr())[1]; ++ if q.is_null() { ++ None ++ } else { ++ Some(BigNumRef::from_ptr(q as *mut _)) ++ } ++ } ++ } ++} ++ ++impl Rsa { ++ /// only useful for associating the key material directly with the key, it's safer to use ++ /// the supplied load and save methods for DER formatted keys. ++ pub fn from_public_components(n: BigNum, e: BigNum) -> Result { ++ unsafe { ++ let rsa = Rsa(try!(cvt_p(ffi::RSA_new()))); ++ try!(cvt(compat::set_key( ++ rsa.0, ++ n.as_ptr(), ++ e.as_ptr(), ++ ptr::null_mut(), ++ ))); ++ mem::forget((n, e)); ++ Ok(rsa) ++ } ++ } ++ ++ pub fn from_private_components( ++ n: BigNum, ++ e: BigNum, ++ d: BigNum, ++ p: BigNum, ++ q: BigNum, ++ dp: BigNum, ++ dq: BigNum, ++ qi: BigNum, ++ ) -> Result { ++ unsafe { ++ let rsa = Rsa(try!(cvt_p(ffi::RSA_new()))); ++ try!(cvt( ++ compat::set_key(rsa.0, n.as_ptr(), e.as_ptr(), d.as_ptr()), ++ )); ++ mem::forget((n, e, d)); ++ try!(cvt(compat::set_factors(rsa.0, p.as_ptr(), q.as_ptr()))); ++ mem::forget((p, q)); ++ try!(cvt(compat::set_crt_params( ++ rsa.0, ++ dp.as_ptr(), ++ dq.as_ptr(), ++ qi.as_ptr(), ++ ))); ++ mem::forget((dp, dq, qi)); ++ Ok(rsa) ++ } ++ } ++ ++ /// Generates a public/private key pair with the specified size. ++ /// ++ /// The public exponent will be 65537. ++ pub fn generate(bits: u32) -> Result { ++ ffi::init(); ++ unsafe { ++ let rsa = Rsa(try!(cvt_p(ffi::RSA_new()))); ++ let e = try!(BigNum::from_u32(ffi::RSA_F4 as u32)); ++ try!(cvt(ffi::RSA_generate_key_ex( ++ rsa.0, ++ bits as c_int, ++ e.as_ptr(), ++ ptr::null_mut(), ++ ))); ++ Ok(rsa) ++ } ++ } ++ ++ // FIXME these need to identify input formats ++ private_key_from_pem!(Rsa, ffi::PEM_read_bio_RSAPrivateKey); ++ private_key_from_der!(Rsa, ffi::d2i_RSAPrivateKey); ++ public_key_from_pem!(Rsa, ffi::PEM_read_bio_RSA_PUBKEY); ++ public_key_from_der!(Rsa, ffi::d2i_RSA_PUBKEY); ++ ++ from_der_inner!( ++ /// Deserializes a public key from DER-encoded PKCS#1 data. ++ public_key_from_der_pkcs1, ++ Rsa, ++ ffi::d2i_RSAPublicKey ++ ); ++ ++ #[deprecated(since = "0.9.2", note = "use private_key_from_pem_callback")] ++ pub fn private_key_from_pem_cb(buf: &[u8], pass_cb: F) -> Result ++ where ++ F: FnOnce(&mut [c_char]) -> usize, ++ { ++ ffi::init(); ++ let mut cb = CallbackState::new(pass_cb); ++ let mem_bio = try!(MemBioSlice::new(buf)); ++ ++ unsafe { ++ let cb_ptr = &mut cb as *mut _ as *mut c_void; ++ let rsa = try!(cvt_p(ffi::PEM_read_bio_RSAPrivateKey( ++ mem_bio.as_ptr(), ++ ptr::null_mut(), ++ Some(invoke_passwd_cb_old::), ++ cb_ptr, ++ ))); ++ Ok(Rsa(rsa)) ++ } ++ } ++} ++ ++impl fmt::Debug for Rsa { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "Rsa") ++ } ++} ++ ++#[cfg(ossl110)] ++mod compat { ++ use std::ptr; ++ ++ use ffi::{self, BIGNUM, RSA}; ++ use libc::c_int; ++ ++ pub unsafe fn key(r: *const RSA) -> [*const BIGNUM; 3] { ++ let (mut n, mut e, mut d) = (ptr::null(), ptr::null(), ptr::null()); ++ ffi::RSA_get0_key(r, &mut n, &mut e, &mut d); ++ [n, e, d] ++ } ++ ++ pub unsafe fn factors(r: *const RSA) -> [*const BIGNUM; 2] { ++ let (mut p, mut q) = (ptr::null(), ptr::null()); ++ ffi::RSA_get0_factors(r, &mut p, &mut q); ++ [p, q] ++ } ++ ++ pub unsafe fn set_key(r: *mut RSA, n: *mut BIGNUM, e: *mut BIGNUM, d: *mut BIGNUM) -> c_int { ++ ffi::RSA_set0_key(r, n, e, d) ++ } ++ ++ pub unsafe fn set_factors(r: *mut RSA, p: *mut BIGNUM, q: *mut BIGNUM) -> c_int { ++ ffi::RSA_set0_factors(r, p, q) ++ } ++ ++ pub unsafe fn set_crt_params( ++ r: *mut RSA, ++ dmp1: *mut BIGNUM, ++ dmq1: *mut BIGNUM, ++ iqmp: *mut BIGNUM, ++ ) -> c_int { ++ ffi::RSA_set0_crt_params(r, dmp1, dmq1, iqmp) ++ } ++} ++ ++#[cfg(ossl10x)] ++mod compat { ++ use libc::c_int; ++ use ffi::{BIGNUM, RSA}; ++ ++ pub unsafe fn key(r: *const RSA) -> [*const BIGNUM; 3] { ++ [(*r).n, (*r).e, (*r).d] ++ } ++ ++ pub unsafe fn factors(r: *const RSA) -> [*const BIGNUM; 2] { ++ [(*r).p, (*r).q] ++ } ++ ++ pub unsafe fn set_key(r: *mut RSA, n: *mut BIGNUM, e: *mut BIGNUM, d: *mut BIGNUM) -> c_int { ++ (*r).n = n; ++ (*r).e = e; ++ (*r).d = d; ++ 1 // TODO: is this right? should it be 0? what's success? ++ } ++ ++ pub unsafe fn set_factors(r: *mut RSA, p: *mut BIGNUM, q: *mut BIGNUM) -> c_int { ++ (*r).p = p; ++ (*r).q = q; ++ 1 // TODO: is this right? should it be 0? what's success? ++ } ++ ++ pub unsafe fn set_crt_params( ++ r: *mut RSA, ++ dmp1: *mut BIGNUM, ++ dmq1: *mut BIGNUM, ++ iqmp: *mut BIGNUM, ++ ) -> c_int { ++ (*r).dmp1 = dmp1; ++ (*r).dmq1 = dmq1; ++ (*r).iqmp = iqmp; ++ 1 // TODO: is this right? should it be 0? what's success? ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use symm::Cipher; ++ ++ use super::*; ++ ++ #[test] ++ fn test_from_password() { ++ let key = include_bytes!("../test/rsa-encrypted.pem"); ++ Rsa::private_key_from_pem_passphrase(key, b"mypass").unwrap(); ++ } ++ ++ #[test] ++ fn test_from_password_callback() { ++ let mut password_queried = false; ++ let key = include_bytes!("../test/rsa-encrypted.pem"); ++ Rsa::private_key_from_pem_callback(key, |password| { ++ password_queried = true; ++ password[..6].copy_from_slice(b"mypass"); ++ Ok(6) ++ }).unwrap(); ++ ++ assert!(password_queried); ++ } ++ ++ #[test] ++ fn test_to_password() { ++ let key = Rsa::generate(2048).unwrap(); ++ let pem = key.private_key_to_pem_passphrase(Cipher::aes_128_cbc(), b"foobar") ++ .unwrap(); ++ Rsa::private_key_from_pem_passphrase(&pem, b"foobar").unwrap(); ++ assert!(Rsa::private_key_from_pem_passphrase(&pem, b"fizzbuzz").is_err()); ++ } ++ ++ #[test] ++ fn test_public_encrypt_private_decrypt_with_padding() { ++ let key = include_bytes!("../test/rsa.pem.pub"); ++ let public_key = Rsa::public_key_from_pem(key).unwrap(); ++ ++ let mut result = vec![0; public_key.size()]; ++ let original_data = b"This is test"; ++ let len = public_key ++ .public_encrypt(original_data, &mut result, PKCS1_PADDING) ++ .unwrap(); ++ assert_eq!(len, 256); ++ ++ let pkey = include_bytes!("../test/rsa.pem"); ++ let private_key = Rsa::private_key_from_pem(pkey).unwrap(); ++ let mut dec_result = vec![0; private_key.size()]; ++ let len = private_key ++ .private_decrypt(&result, &mut dec_result, PKCS1_PADDING) ++ .unwrap(); ++ ++ assert_eq!(&dec_result[..len], original_data); ++ } ++ ++ #[test] ++ fn test_private_encrypt() { ++ let k0 = super::Rsa::generate(512).unwrap(); ++ let k0pkey = k0.public_key_to_pem().unwrap(); ++ let k1 = super::Rsa::public_key_from_pem(&k0pkey).unwrap(); ++ ++ let msg = vec![0xdeu8, 0xadu8, 0xd0u8, 0x0du8]; ++ ++ let mut emesg = vec![0; k0.size()]; ++ k0.private_encrypt(&msg, &mut emesg, PKCS1_PADDING).unwrap(); ++ let mut dmesg = vec![0; k1.size()]; ++ let len = k1.public_decrypt(&emesg, &mut dmesg, PKCS1_PADDING) ++ .unwrap(); ++ assert_eq!(msg, &dmesg[..len]); ++ } ++ ++ #[test] ++ fn test_public_encrypt() { ++ let k0 = super::Rsa::generate(512).unwrap(); ++ let k0pkey = k0.private_key_to_pem().unwrap(); ++ let k1 = super::Rsa::private_key_from_pem(&k0pkey).unwrap(); ++ ++ let msg = vec![0xdeu8, 0xadu8, 0xd0u8, 0x0du8]; ++ ++ let mut emesg = vec![0; k0.size()]; ++ k0.public_encrypt(&msg, &mut emesg, PKCS1_PADDING).unwrap(); ++ let mut dmesg = vec![0; k1.size()]; ++ let len = k1.private_decrypt(&emesg, &mut dmesg, PKCS1_PADDING) ++ .unwrap(); ++ assert_eq!(msg, &dmesg[..len]); ++ } ++} diff --cc vendor/openssl-0.9.19/src/sha.rs index 000000000,000000000..5d9baefa6 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/sha.rs @@@ -1,0 -1,0 +1,340 @@@ ++//! The SHA family of hashes. ++use libc::c_void; ++use ffi; ++use std::mem; ++ ++/// Computes the SHA1 hash of some data. ++/// ++/// # Warning ++/// ++/// SHA1 is known to be insecure - it should not be used unless required for ++/// compatibility with existing systems. ++#[inline] ++pub fn sha1(data: &[u8]) -> [u8; 20] { ++ unsafe { ++ let mut hash: [u8; 20] = mem::uninitialized(); ++ ffi::SHA1(data.as_ptr(), data.len(), hash.as_mut_ptr()); ++ hash ++ } ++} ++ ++/// Computes the SHA224 hash of some data. ++#[inline] ++pub fn sha224(data: &[u8]) -> [u8; 28] { ++ unsafe { ++ let mut hash: [u8; 28] = mem::uninitialized(); ++ ffi::SHA224(data.as_ptr(), data.len(), hash.as_mut_ptr()); ++ hash ++ } ++} ++ ++/// Computes the SHA256 hash of some data. ++#[inline] ++pub fn sha256(data: &[u8]) -> [u8; 32] { ++ unsafe { ++ let mut hash: [u8; 32] = mem::uninitialized(); ++ ffi::SHA256(data.as_ptr(), data.len(), hash.as_mut_ptr()); ++ hash ++ } ++} ++ ++/// Computes the SHA384 hash of some data. ++#[inline] ++pub fn sha384(data: &[u8]) -> [u8; 48] { ++ unsafe { ++ let mut hash: [u8; 48] = mem::uninitialized(); ++ ffi::SHA384(data.as_ptr(), data.len(), hash.as_mut_ptr()); ++ hash ++ } ++} ++ ++/// Computes the SHA512 hash of some data. ++#[inline] ++pub fn sha512(data: &[u8]) -> [u8; 64] { ++ unsafe { ++ let mut hash: [u8; 64] = mem::uninitialized(); ++ ffi::SHA512(data.as_ptr(), data.len(), hash.as_mut_ptr()); ++ hash ++ } ++} ++ ++/// An object which calculates a SHA1 hash of some data. ++/// ++/// # Warning ++/// ++/// SHA1 is known to be insecure - it should not be used unless required for ++/// compatibility with existing systems. ++pub struct Sha1(ffi::SHA_CTX); ++ ++impl Sha1 { ++ /// Creates a new hasher. ++ #[inline] ++ pub fn new() -> Sha1 { ++ unsafe { ++ let mut ctx = mem::uninitialized(); ++ ffi::SHA1_Init(&mut ctx); ++ Sha1(ctx) ++ } ++ } ++ ++ /// Feeds some data into the hasher. ++ /// ++ /// This can be called multiple times. ++ #[inline] ++ pub fn update(&mut self, buf: &[u8]) { ++ unsafe { ++ ffi::SHA1_Update(&mut self.0, buf.as_ptr() as *const c_void, buf.len()); ++ } ++ } ++ ++ /// Returns the hash of the data. ++ #[inline] ++ pub fn finish(mut self) -> [u8; 20] { ++ unsafe { ++ let mut hash: [u8; 20] = mem::uninitialized(); ++ ffi::SHA1_Final(hash.as_mut_ptr(), &mut self.0); ++ hash ++ } ++ } ++} ++ ++/// An object which calculates a SHA224 hash of some data. ++pub struct Sha224(ffi::SHA256_CTX); ++ ++impl Sha224 { ++ /// Creates a new hasher. ++ #[inline] ++ pub fn new() -> Sha224 { ++ unsafe { ++ let mut ctx = mem::uninitialized(); ++ ffi::SHA224_Init(&mut ctx); ++ Sha224(ctx) ++ } ++ } ++ ++ /// Feeds some data into the hasher. ++ /// ++ /// This can be called multiple times. ++ #[inline] ++ pub fn update(&mut self, buf: &[u8]) { ++ unsafe { ++ ffi::SHA224_Update(&mut self.0, buf.as_ptr() as *const c_void, buf.len()); ++ } ++ } ++ ++ /// Returns the hash of the data. ++ #[inline] ++ pub fn finish(mut self) -> [u8; 28] { ++ unsafe { ++ let mut hash: [u8; 28] = mem::uninitialized(); ++ ffi::SHA224_Final(hash.as_mut_ptr(), &mut self.0); ++ hash ++ } ++ } ++} ++ ++/// An object which calculates a SHA256 hash of some data. ++pub struct Sha256(ffi::SHA256_CTX); ++ ++impl Sha256 { ++ /// Creates a new hasher. ++ #[inline] ++ pub fn new() -> Sha256 { ++ unsafe { ++ let mut ctx = mem::uninitialized(); ++ ffi::SHA256_Init(&mut ctx); ++ Sha256(ctx) ++ } ++ } ++ ++ /// Feeds some data into the hasher. ++ /// ++ /// This can be called multiple times. ++ #[inline] ++ pub fn update(&mut self, buf: &[u8]) { ++ unsafe { ++ ffi::SHA256_Update(&mut self.0, buf.as_ptr() as *const c_void, buf.len()); ++ } ++ } ++ ++ /// Returns the hash of the data. ++ #[inline] ++ pub fn finish(mut self) -> [u8; 32] { ++ unsafe { ++ let mut hash: [u8; 32] = mem::uninitialized(); ++ ffi::SHA256_Final(hash.as_mut_ptr(), &mut self.0); ++ hash ++ } ++ } ++} ++ ++/// An object which calculates a SHA384 hash of some data. ++pub struct Sha384(ffi::SHA512_CTX); ++ ++impl Sha384 { ++ /// Creates a new hasher. ++ #[inline] ++ pub fn new() -> Sha384 { ++ unsafe { ++ let mut ctx = mem::uninitialized(); ++ ffi::SHA384_Init(&mut ctx); ++ Sha384(ctx) ++ } ++ } ++ ++ /// Feeds some data into the hasher. ++ /// ++ /// This can be called multiple times. ++ #[inline] ++ pub fn update(&mut self, buf: &[u8]) { ++ unsafe { ++ ffi::SHA384_Update(&mut self.0, buf.as_ptr() as *const c_void, buf.len()); ++ } ++ } ++ ++ /// Returns the hash of the data. ++ #[inline] ++ pub fn finish(mut self) -> [u8; 48] { ++ unsafe { ++ let mut hash: [u8; 48] = mem::uninitialized(); ++ ffi::SHA384_Final(hash.as_mut_ptr(), &mut self.0); ++ hash ++ } ++ } ++} ++ ++/// An object which calculates a SHA512 hash of some data. ++pub struct Sha512(ffi::SHA512_CTX); ++ ++impl Sha512 { ++ /// Creates a new hasher. ++ #[inline] ++ pub fn new() -> Sha512 { ++ unsafe { ++ let mut ctx = mem::uninitialized(); ++ ffi::SHA512_Init(&mut ctx); ++ Sha512(ctx) ++ } ++ } ++ ++ /// Feeds some data into the hasher. ++ /// ++ /// This can be called multiple times. ++ #[inline] ++ pub fn update(&mut self, buf: &[u8]) { ++ unsafe { ++ ffi::SHA512_Update(&mut self.0, buf.as_ptr() as *const c_void, buf.len()); ++ } ++ } ++ ++ /// Returns the hash of the data. ++ #[inline] ++ pub fn finish(mut self) -> [u8; 64] { ++ unsafe { ++ let mut hash: [u8; 64] = mem::uninitialized(); ++ ffi::SHA512_Final(hash.as_mut_ptr(), &mut self.0); ++ hash ++ } ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use hex::ToHex; ++ ++ use super::*; ++ ++ #[test] ++ fn standalone_1() { ++ let data = b"abc"; ++ let expected = "a9993e364706816aba3e25717850c26c9cd0d89d"; ++ ++ assert_eq!(sha1(data).to_hex(), expected); ++ } ++ ++ #[test] ++ fn struct_1() { ++ let expected = "a9993e364706816aba3e25717850c26c9cd0d89d"; ++ ++ let mut hasher = Sha1::new(); ++ hasher.update(b"a"); ++ hasher.update(b"bc"); ++ assert_eq!(hasher.finish().to_hex(), expected); ++ } ++ ++ #[test] ++ fn standalone_224() { ++ let data = b"abc"; ++ let expected = "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7"; ++ ++ assert_eq!(sha224(data).to_hex(), expected); ++ } ++ ++ #[test] ++ fn struct_224() { ++ let expected = "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7"; ++ ++ let mut hasher = Sha224::new(); ++ hasher.update(b"a"); ++ hasher.update(b"bc"); ++ assert_eq!(hasher.finish().to_hex(), expected); ++ } ++ ++ #[test] ++ fn standalone_256() { ++ let data = b"abc"; ++ let expected = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; ++ ++ assert_eq!(sha256(data).to_hex(), expected); ++ } ++ ++ #[test] ++ fn struct_256() { ++ let expected = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; ++ ++ let mut hasher = Sha256::new(); ++ hasher.update(b"a"); ++ hasher.update(b"bc"); ++ assert_eq!(hasher.finish().to_hex(), expected); ++ } ++ ++ #[test] ++ fn standalone_384() { ++ let data = b"abc"; ++ let expected = "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e\ ++ 7cc2358baeca134c825a7"; ++ ++ assert_eq!((&sha384(data)[..]).to_hex(), expected); ++ } ++ ++ #[test] ++ fn struct_384() { ++ let expected = "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e\ ++ 7cc2358baeca134c825a7"; ++ ++ let mut hasher = Sha384::new(); ++ hasher.update(b"a"); ++ hasher.update(b"bc"); ++ assert_eq!((&hasher.finish()[..]).to_hex(), expected); ++ } ++ ++ #[test] ++ fn standalone_512() { ++ let data = b"abc"; ++ let expected = "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274\ ++ fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"; ++ ++ assert_eq!((&sha512(data)[..]).to_hex(), expected); ++ } ++ ++ #[test] ++ fn struct_512() { ++ let expected = "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274\ ++ fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"; ++ ++ let mut hasher = Sha512::new(); ++ hasher.update(b"a"); ++ hasher.update(b"bc"); ++ assert_eq!((&hasher.finish()[..]).to_hex(), expected); ++ } ++} diff --cc vendor/openssl-0.9.19/src/sign.rs index 000000000,000000000..96ec8f755 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/sign.rs @@@ -1,0 -1,0 +1,878 @@@ ++//! Message signatures. ++//! ++//! The `Signer` allows for the computation of cryptographic signatures of ++//! data given a private key. The `Verifier` can then be used with the ++//! corresponding public key to verify the integrity and authenticity of that ++//! data given the signature. ++//! ++//! # Examples ++//! ++//! Sign and verify data given an RSA keypair: ++//! ++//! ```rust ++//! use openssl::sign::{Signer, Verifier}; ++//! use openssl::rsa::Rsa; ++//! use openssl::pkey::PKey; ++//! use openssl::hash::MessageDigest; ++//! ++//! // Generate a keypair ++//! let keypair = Rsa::generate(2048).unwrap(); ++//! let keypair = PKey::from_rsa(keypair).unwrap(); ++//! ++//! let data = b"hello, world!"; ++//! let data2 = b"hola, mundo!"; ++//! ++//! // Sign the data ++//! let mut signer = Signer::new(MessageDigest::sha256(), &keypair).unwrap(); ++//! signer.update(data).unwrap(); ++//! signer.update(data2).unwrap(); ++//! let signature = signer.finish().unwrap(); ++//! ++//! // Verify the data ++//! let mut verifier = Verifier::new(MessageDigest::sha256(), &keypair).unwrap(); ++//! verifier.update(data).unwrap(); ++//! verifier.update(data2).unwrap(); ++//! assert!(verifier.finish(&signature).unwrap()); ++//! ``` ++//! ++//! Compute an HMAC: ++//! ++//! ```rust ++//! use openssl::hash::MessageDigest; ++//! use openssl::memcmp; ++//! use openssl::pkey::PKey; ++//! use openssl::sign::Signer; ++//! ++//! // Create a PKey ++//! let key = PKey::hmac(b"my secret").unwrap(); ++//! ++//! let data = b"hello, world!"; ++//! let data2 = b"hola, mundo!"; ++//! ++//! // Compute the HMAC ++//! let mut signer = Signer::new(MessageDigest::sha256(), &key).unwrap(); ++//! signer.update(data).unwrap(); ++//! signer.update(data2).unwrap(); ++//! let hmac = signer.finish().unwrap(); ++//! ++//! // `Verifier` cannot be used with HMACs; use the `memcmp::eq` function instead ++//! // ++//! // Do not simply check for equality with `==`! ++//! # let target = hmac.clone(); ++//! assert!(memcmp::eq(&hmac, &target)); ++//! ``` ++use ffi; ++use foreign_types::ForeignTypeRef; ++use std::io::{self, Write}; ++use std::marker::PhantomData; ++use std::ptr; ++ ++use {cvt, cvt_p}; ++use hash::MessageDigest; ++use pkey::{PKeyRef, PKeyCtxRef}; ++use error::ErrorStack; ++ ++#[cfg(ossl110)] ++use ffi::{EVP_MD_CTX_new, EVP_MD_CTX_free}; ++#[cfg(any(ossl101, ossl102))] ++use ffi::{EVP_MD_CTX_create as EVP_MD_CTX_new, EVP_MD_CTX_destroy as EVP_MD_CTX_free}; ++ ++pub struct Signer<'a> { ++ md_ctx: *mut ffi::EVP_MD_CTX, ++ pkey_ctx: *mut ffi::EVP_PKEY_CTX, ++ pkey_pd: PhantomData<&'a PKeyRef>, ++} ++ ++impl<'a> Drop for Signer<'a> { ++ fn drop(&mut self) { ++ // pkey_ctx is owned by the md_ctx, so no need to explicitly free it. ++ unsafe { ++ EVP_MD_CTX_free(self.md_ctx); ++ } ++ } ++} ++ ++impl<'a> Signer<'a> { ++ pub fn new(type_: MessageDigest, pkey: &'a PKeyRef) -> Result, ErrorStack> { ++ unsafe { ++ ffi::init(); ++ ++ let ctx = try!(cvt_p(EVP_MD_CTX_new())); ++ let mut pctx: *mut ffi::EVP_PKEY_CTX = ptr::null_mut(); ++ let r = ffi::EVP_DigestSignInit( ++ ctx, ++ &mut pctx, ++ type_.as_ptr(), ++ ptr::null_mut(), ++ pkey.as_ptr(), ++ ); ++ if r != 1 { ++ EVP_MD_CTX_free(ctx); ++ return Err(ErrorStack::get()); ++ } ++ ++ assert!(!pctx.is_null()); ++ ++ Ok(Signer { ++ md_ctx: ctx, ++ pkey_ctx: pctx, ++ pkey_pd: PhantomData, ++ }) ++ } ++ } ++ ++ pub fn pkey_ctx(&self) -> &PKeyCtxRef { ++ unsafe { PKeyCtxRef::from_ptr(self.pkey_ctx) } ++ } ++ ++ pub fn pkey_ctx_mut(&mut self) -> &mut PKeyCtxRef { ++ unsafe { PKeyCtxRef::from_ptr_mut(self.pkey_ctx) } ++ } ++ ++ pub fn update(&mut self, buf: &[u8]) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EVP_DigestUpdate( ++ self.md_ctx, ++ buf.as_ptr() as *const _, ++ buf.len(), ++ )).map(|_| ()) ++ } ++ } ++ ++ pub fn finish(&self) -> Result, ErrorStack> { ++ unsafe { ++ let mut len = 0; ++ try!(cvt(ffi::EVP_DigestSignFinal( ++ self.md_ctx, ++ ptr::null_mut(), ++ &mut len, ++ ))); ++ let mut buf = vec![0; len]; ++ try!(cvt(ffi::EVP_DigestSignFinal( ++ self.md_ctx, ++ buf.as_mut_ptr() as *mut _, ++ &mut len, ++ ))); ++ // The advertised length is not always equal to the real length for things like DSA ++ buf.truncate(len); ++ Ok(buf) ++ } ++ } ++} ++ ++impl<'a> Write for Signer<'a> { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ try!(self.update(buf)); ++ Ok(buf.len()) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ Ok(()) ++ } ++} ++ ++pub struct Verifier<'a> { ++ md_ctx: *mut ffi::EVP_MD_CTX, ++ pkey_ctx: *mut ffi::EVP_PKEY_CTX, ++ pkey_pd: PhantomData<&'a PKeyRef>, ++} ++ ++impl<'a> Drop for Verifier<'a> { ++ fn drop(&mut self) { ++ // pkey_ctx is owned by the md_ctx, so no need to explicitly free it. ++ unsafe { ++ EVP_MD_CTX_free(self.md_ctx); ++ } ++ } ++} ++ ++impl<'a> Verifier<'a> { ++ pub fn new(type_: MessageDigest, pkey: &'a PKeyRef) -> Result, ErrorStack> { ++ unsafe { ++ ffi::init(); ++ ++ let ctx = try!(cvt_p(EVP_MD_CTX_new())); ++ let mut pctx: *mut ffi::EVP_PKEY_CTX = ptr::null_mut(); ++ let r = ffi::EVP_DigestVerifyInit( ++ ctx, ++ &mut pctx, ++ type_.as_ptr(), ++ ptr::null_mut(), ++ pkey.as_ptr(), ++ ); ++ if r != 1 { ++ EVP_MD_CTX_free(ctx); ++ return Err(ErrorStack::get()); ++ } ++ ++ assert!(!pctx.is_null()); ++ ++ Ok(Verifier { ++ md_ctx: ctx, ++ pkey_ctx: pctx, ++ pkey_pd: PhantomData, ++ }) ++ } ++ } ++ ++ pub fn pkey_ctx(&self) -> &PKeyCtxRef { ++ unsafe { PKeyCtxRef::from_ptr(self.pkey_ctx) } ++ } ++ ++ pub fn pkey_ctx_mut(&mut self) -> &mut PKeyCtxRef { ++ unsafe { PKeyCtxRef::from_ptr_mut(self.pkey_ctx) } ++ } ++ ++ pub fn update(&mut self, buf: &[u8]) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::EVP_DigestUpdate( ++ self.md_ctx, ++ buf.as_ptr() as *const _, ++ buf.len(), ++ )).map(|_| ()) ++ } ++ } ++ ++ pub fn finish(&self, signature: &[u8]) -> Result { ++ unsafe { ++ let r = ++ EVP_DigestVerifyFinal(self.md_ctx, signature.as_ptr() as *const _, signature.len()); ++ match r { ++ 1 => Ok(true), ++ 0 => { ++ ErrorStack::get(); // discard error stack ++ Ok(false) ++ } ++ _ => Err(ErrorStack::get()), ++ } ++ } ++ } ++} ++ ++impl<'a> Write for Verifier<'a> { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ try!(self.update(buf)); ++ Ok(buf.len()) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ Ok(()) ++ } ++} ++ ++#[cfg(not(ossl101))] ++use ffi::EVP_DigestVerifyFinal; ++ ++#[cfg(ossl101)] ++#[allow(bad_style)] ++unsafe fn EVP_DigestVerifyFinal( ++ ctx: *mut ffi::EVP_MD_CTX, ++ sigret: *const ::libc::c_uchar, ++ siglen: ::libc::size_t, ++) -> ::libc::c_int { ++ ffi::EVP_DigestVerifyFinal(ctx, sigret as *mut _, siglen) ++} ++ ++#[cfg(test)] ++mod test { ++ use hex::FromHex; ++ use std::iter; ++ ++ use hash::MessageDigest; ++ use sign::{Signer, Verifier}; ++ use ec::{EcGroup, EcKey}; ++ use nid; ++ use rsa::{Rsa, PKCS1_PADDING}; ++ use dsa::Dsa; ++ use pkey::PKey; ++ ++ static INPUT: &'static [u8] = &[ ++ 101, ++ 121, ++ 74, ++ 104, ++ 98, ++ 71, ++ 99, ++ 105, ++ 79, ++ 105, ++ 74, ++ 83, ++ 85, ++ 122, ++ 73, ++ 49, ++ 78, ++ 105, ++ 74, ++ 57, ++ 46, ++ 101, ++ 121, ++ 74, ++ 112, ++ 99, ++ 51, ++ 77, ++ 105, ++ 79, ++ 105, ++ 74, ++ 113, ++ 98, ++ 50, ++ 85, ++ 105, ++ 76, ++ 65, ++ 48, ++ 75, ++ 73, ++ 67, ++ 74, ++ 108, ++ 101, ++ 72, ++ 65, ++ 105, ++ 79, ++ 106, ++ 69, ++ 122, ++ 77, ++ 68, ++ 65, ++ 52, ++ 77, ++ 84, ++ 107, ++ 122, ++ 79, ++ 68, ++ 65, ++ 115, ++ 68, ++ 81, ++ 111, ++ 103, ++ 73, ++ 109, ++ 104, ++ 48, ++ 100, ++ 72, ++ 65, ++ 54, ++ 76, ++ 121, ++ 57, ++ 108, ++ 101, ++ 71, ++ 70, ++ 116, ++ 99, ++ 71, ++ 120, ++ 108, ++ 76, ++ 109, ++ 78, ++ 118, ++ 98, ++ 83, ++ 57, ++ 112, ++ 99, ++ 49, ++ 57, ++ 121, ++ 98, ++ 50, ++ 57, ++ 48, ++ 73, ++ 106, ++ 112, ++ 48, ++ 99, ++ 110, ++ 86, ++ 108, ++ 102, ++ 81, ++ ]; ++ ++ static SIGNATURE: &'static [u8] = &[ ++ 112, ++ 46, ++ 33, ++ 137, ++ 67, ++ 232, ++ 143, ++ 209, ++ 30, ++ 181, ++ 216, ++ 45, ++ 191, ++ 120, ++ 69, ++ 243, ++ 65, ++ 6, ++ 174, ++ 27, ++ 129, ++ 255, ++ 247, ++ 115, ++ 17, ++ 22, ++ 173, ++ 209, ++ 113, ++ 125, ++ 131, ++ 101, ++ 109, ++ 66, ++ 10, ++ 253, ++ 60, ++ 150, ++ 238, ++ 221, ++ 115, ++ 162, ++ 102, ++ 62, ++ 81, ++ 102, ++ 104, ++ 123, ++ 0, ++ 11, ++ 135, ++ 34, ++ 110, ++ 1, ++ 135, ++ 237, ++ 16, ++ 115, ++ 249, ++ 69, ++ 229, ++ 130, ++ 173, ++ 252, ++ 239, ++ 22, ++ 216, ++ 90, ++ 121, ++ 142, ++ 232, ++ 198, ++ 109, ++ 219, ++ 61, ++ 184, ++ 151, ++ 91, ++ 23, ++ 208, ++ 148, ++ 2, ++ 190, ++ 237, ++ 213, ++ 217, ++ 217, ++ 112, ++ 7, ++ 16, ++ 141, ++ 178, ++ 129, ++ 96, ++ 213, ++ 248, ++ 4, ++ 12, ++ 167, ++ 68, ++ 87, ++ 98, ++ 184, ++ 31, ++ 190, ++ 127, ++ 249, ++ 217, ++ 46, ++ 10, ++ 231, ++ 111, ++ 36, ++ 242, ++ 91, ++ 51, ++ 187, ++ 230, ++ 244, ++ 74, ++ 230, ++ 30, ++ 177, ++ 4, ++ 10, ++ 203, ++ 32, ++ 4, ++ 77, ++ 62, ++ 249, ++ 18, ++ 142, ++ 212, ++ 1, ++ 48, ++ 121, ++ 91, ++ 212, ++ 189, ++ 59, ++ 65, ++ 238, ++ 202, ++ 208, ++ 102, ++ 171, ++ 101, ++ 25, ++ 129, ++ 253, ++ 228, ++ 141, ++ 247, ++ 127, ++ 55, ++ 45, ++ 195, ++ 139, ++ 159, ++ 175, ++ 221, ++ 59, ++ 239, ++ 177, ++ 139, ++ 93, ++ 163, ++ 204, ++ 60, ++ 46, ++ 176, ++ 47, ++ 158, ++ 58, ++ 65, ++ 214, ++ 18, ++ 202, ++ 173, ++ 21, ++ 145, ++ 18, ++ 115, ++ 160, ++ 95, ++ 35, ++ 185, ++ 232, ++ 56, ++ 250, ++ 175, ++ 132, ++ 157, ++ 105, ++ 132, ++ 41, ++ 239, ++ 90, ++ 30, ++ 136, ++ 121, ++ 130, ++ 54, ++ 195, ++ 212, ++ 14, ++ 96, ++ 69, ++ 34, ++ 165, ++ 68, ++ 200, ++ 242, ++ 122, ++ 122, ++ 45, ++ 184, ++ 6, ++ 99, ++ 209, ++ 108, ++ 247, ++ 202, ++ 234, ++ 86, ++ 222, ++ 64, ++ 92, ++ 178, ++ 33, ++ 90, ++ 69, ++ 178, ++ 194, ++ 85, ++ 102, ++ 181, ++ 90, ++ 193, ++ 167, ++ 72, ++ 160, ++ 112, ++ 223, ++ 200, ++ 163, ++ 42, ++ 70, ++ 149, ++ 67, ++ 208, ++ 25, ++ 238, ++ 251, ++ 71, ++ ]; ++ ++ #[test] ++ fn rsa_sign() { ++ let key = include_bytes!("../test/rsa.pem"); ++ let private_key = Rsa::private_key_from_pem(key).unwrap(); ++ let pkey = PKey::from_rsa(private_key).unwrap(); ++ ++ let mut signer = Signer::new(MessageDigest::sha256(), &pkey).unwrap(); ++ assert_eq!(signer.pkey_ctx_mut().rsa_padding().unwrap(), PKCS1_PADDING); ++ signer ++ .pkey_ctx_mut() ++ .set_rsa_padding(PKCS1_PADDING) ++ .unwrap(); ++ signer.update(INPUT).unwrap(); ++ let result = signer.finish().unwrap(); ++ ++ assert_eq!(result, SIGNATURE); ++ } ++ ++ #[test] ++ fn rsa_verify_ok() { ++ let key = include_bytes!("../test/rsa.pem"); ++ let private_key = Rsa::private_key_from_pem(key).unwrap(); ++ let pkey = PKey::from_rsa(private_key).unwrap(); ++ ++ let mut verifier = Verifier::new(MessageDigest::sha256(), &pkey).unwrap(); ++ assert_eq!( ++ verifier.pkey_ctx_mut().rsa_padding().unwrap(), ++ PKCS1_PADDING ++ ); ++ verifier.update(INPUT).unwrap(); ++ assert!(verifier.finish(SIGNATURE).unwrap()); ++ } ++ ++ #[test] ++ fn rsa_verify_invalid() { ++ let key = include_bytes!("../test/rsa.pem"); ++ let private_key = Rsa::private_key_from_pem(key).unwrap(); ++ let pkey = PKey::from_rsa(private_key).unwrap(); ++ ++ let mut verifier = Verifier::new(MessageDigest::sha256(), &pkey).unwrap(); ++ verifier.update(INPUT).unwrap(); ++ verifier.update(b"foobar").unwrap(); ++ assert!(!verifier.finish(SIGNATURE).unwrap()); ++ } ++ ++ #[test] ++ pub fn dsa_sign_verify() { ++ let input: Vec = (0..25).cycle().take(1024).collect(); ++ ++ let private_key = { ++ let key = include_bytes!("../test/dsa.pem"); ++ PKey::from_dsa(Dsa::private_key_from_pem(key).unwrap()).unwrap() ++ }; ++ ++ let public_key = { ++ let key = include_bytes!("../test/dsa.pem.pub"); ++ PKey::from_dsa(Dsa::public_key_from_pem(key).unwrap()).unwrap() ++ }; ++ ++ let mut signer = Signer::new(MessageDigest::sha1(), &private_key).unwrap(); ++ signer.update(&input).unwrap(); ++ let sig = signer.finish().unwrap(); ++ ++ let mut verifier = Verifier::new(MessageDigest::sha1(), &public_key).unwrap(); ++ verifier.update(&input).unwrap(); ++ assert!(verifier.finish(&sig).unwrap()); ++ } ++ ++ #[test] ++ pub fn dsa_sign_verify_fail() { ++ let input: Vec = (0..25).cycle().take(1024).collect(); ++ ++ let private_key = { ++ let key = include_bytes!("../test/dsa.pem"); ++ PKey::from_dsa(Dsa::private_key_from_pem(key).unwrap()).unwrap() ++ }; ++ ++ let public_key = { ++ let key = include_bytes!("../test/dsa.pem.pub"); ++ PKey::from_dsa(Dsa::public_key_from_pem(key).unwrap()).unwrap() ++ }; ++ ++ let mut signer = Signer::new(MessageDigest::sha1(), &private_key).unwrap(); ++ signer.update(&input).unwrap(); ++ let mut sig = signer.finish().unwrap(); ++ sig[0] -= 1; ++ ++ let mut verifier = Verifier::new(MessageDigest::sha1(), &public_key).unwrap(); ++ verifier.update(&input).unwrap(); ++ match verifier.finish(&sig) { ++ Ok(true) => panic!("unexpected success"), ++ Ok(false) | Err(_) => {} ++ } ++ } ++ ++ fn test_hmac(ty: MessageDigest, tests: &[(Vec, Vec, Vec)]) { ++ for &(ref key, ref data, ref res) in tests.iter() { ++ let pkey = PKey::hmac(key).unwrap(); ++ let mut signer = Signer::new(ty, &pkey).unwrap(); ++ signer.update(data).unwrap(); ++ assert_eq!(signer.finish().unwrap(), *res); ++ } ++ } ++ ++ #[test] ++ fn hmac_md5() { ++ // test vectors from RFC 2202 ++ let tests: [(Vec, Vec, Vec); 7] = ++ [ ++ ( ++ iter::repeat(0x0b_u8).take(16).collect(), ++ b"Hi There".to_vec(), ++ Vec::from_hex("9294727a3638bb1c13f48ef8158bfc9d").unwrap(), ++ ), ++ ( ++ b"Jefe".to_vec(), ++ b"what do ya want for nothing?".to_vec(), ++ Vec::from_hex("750c783e6ab0b503eaa86e310a5db738").unwrap(), ++ ), ++ ( ++ iter::repeat(0xaa_u8).take(16).collect(), ++ iter::repeat(0xdd_u8).take(50).collect(), ++ Vec::from_hex("56be34521d144c88dbb8c733f0e8b3f6").unwrap(), ++ ), ++ ( ++ Vec::from_hex("0102030405060708090a0b0c0d0e0f10111213141516171819").unwrap(), ++ iter::repeat(0xcd_u8).take(50).collect(), ++ Vec::from_hex("697eaf0aca3a3aea3a75164746ffaa79").unwrap(), ++ ), ++ ( ++ iter::repeat(0x0c_u8).take(16).collect(), ++ b"Test With Truncation".to_vec(), ++ Vec::from_hex("56461ef2342edc00f9bab995690efd4c").unwrap(), ++ ), ++ ( ++ iter::repeat(0xaa_u8).take(80).collect(), ++ b"Test Using Larger Than Block-Size Key - Hash Key First".to_vec(), ++ Vec::from_hex("6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd").unwrap(), ++ ), ++ ( ++ iter::repeat(0xaa_u8).take(80).collect(), ++ b"Test Using Larger Than Block-Size Key \ ++ and Larger Than One Block-Size Data" ++ .to_vec(), ++ Vec::from_hex("6f630fad67cda0ee1fb1f562db3aa53e").unwrap(), ++ ), ++ ]; ++ ++ test_hmac(MessageDigest::md5(), &tests); ++ } ++ ++ #[test] ++ fn hmac_sha1() { ++ // test vectors from RFC 2202 ++ let tests: [(Vec, Vec, Vec); 7] = ++ [ ++ ( ++ iter::repeat(0x0b_u8).take(20).collect(), ++ b"Hi There".to_vec(), ++ Vec::from_hex("b617318655057264e28bc0b6fb378c8ef146be00").unwrap(), ++ ), ++ ( ++ b"Jefe".to_vec(), ++ b"what do ya want for nothing?".to_vec(), ++ Vec::from_hex("effcdf6ae5eb2fa2d27416d5f184df9c259a7c79").unwrap(), ++ ), ++ ( ++ iter::repeat(0xaa_u8).take(20).collect(), ++ iter::repeat(0xdd_u8).take(50).collect(), ++ Vec::from_hex("125d7342b9ac11cd91a39af48aa17b4f63f175d3").unwrap(), ++ ), ++ ( ++ Vec::from_hex("0102030405060708090a0b0c0d0e0f10111213141516171819").unwrap(), ++ iter::repeat(0xcd_u8).take(50).collect(), ++ Vec::from_hex("4c9007f4026250c6bc8414f9bf50c86c2d7235da").unwrap(), ++ ), ++ ( ++ iter::repeat(0x0c_u8).take(20).collect(), ++ b"Test With Truncation".to_vec(), ++ Vec::from_hex("4c1a03424b55e07fe7f27be1d58bb9324a9a5a04").unwrap(), ++ ), ++ ( ++ iter::repeat(0xaa_u8).take(80).collect(), ++ b"Test Using Larger Than Block-Size Key - Hash Key First".to_vec(), ++ Vec::from_hex("aa4ae5e15272d00e95705637ce8a3b55ed402112").unwrap(), ++ ), ++ ( ++ iter::repeat(0xaa_u8).take(80).collect(), ++ b"Test Using Larger Than Block-Size Key \ ++ and Larger Than One Block-Size Data" ++ .to_vec(), ++ Vec::from_hex("e8e99d0f45237d786d6bbaa7965c7808bbff1a91").unwrap(), ++ ), ++ ]; ++ ++ test_hmac(MessageDigest::sha1(), &tests); ++ } ++ ++ #[test] ++ fn ec() { ++ let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap(); ++ let key = EcKey::generate(&group).unwrap(); ++ let key = PKey::from_ec_key(key).unwrap(); ++ ++ let mut signer = Signer::new(MessageDigest::sha256(), &key).unwrap(); ++ signer.update(b"hello world").unwrap(); ++ let signature = signer.finish().unwrap(); ++ ++ let mut verifier = Verifier::new(MessageDigest::sha256(), &key).unwrap(); ++ verifier.update(b"hello world").unwrap(); ++ assert!(verifier.finish(&signature).unwrap()); ++ } ++} diff --cc vendor/openssl-0.9.19/src/ssl/bio.rs index 000000000,000000000..86a055a5c new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ssl/bio.rs @@@ -1,0 -1,0 +1,279 @@@ ++use libc::{c_char, c_int, c_long, c_void, strlen}; ++use ffi::{BIO, BIO_CTRL_FLUSH, BIO_new, BIO_clear_retry_flags, BIO_set_retry_read, ++ BIO_set_retry_write}; ++use std::any::Any; ++use std::io; ++use std::io::prelude::*; ++use std::mem; ++use std::panic::{AssertUnwindSafe, catch_unwind}; ++use std::ptr; ++use std::slice; ++ ++use cvt_p; ++use error::ErrorStack; ++ ++pub struct StreamState { ++ pub stream: S, ++ pub error: Option, ++ pub panic: Option>, ++} ++ ++/// Safe wrapper for BIO_METHOD ++pub struct BioMethod(compat::BIO_METHOD); ++ ++impl BioMethod { ++ fn new() -> BioMethod { ++ BioMethod(compat::BIO_METHOD::new::()) ++ } ++} ++ ++unsafe impl Sync for BioMethod {} ++unsafe impl Send for BioMethod {} ++ ++pub fn new(stream: S) -> Result<(*mut BIO, BioMethod), ErrorStack> { ++ let method = BioMethod::new::(); ++ ++ let state = Box::new(StreamState { ++ stream: stream, ++ error: None, ++ panic: None, ++ }); ++ ++ unsafe { ++ let bio = try!(cvt_p(BIO_new(method.0.get()))); ++ compat::BIO_set_data(bio, Box::into_raw(state) as *mut _); ++ compat::BIO_set_init(bio, 1); ++ ++ return Ok((bio, method)); ++ } ++} ++ ++pub unsafe fn take_error(bio: *mut BIO) -> Option { ++ let state = state::(bio); ++ state.error.take() ++} ++ ++pub unsafe fn take_panic(bio: *mut BIO) -> Option> { ++ let state = state::(bio); ++ state.panic.take() ++} ++ ++pub unsafe fn get_ref<'a, S: 'a>(bio: *mut BIO) -> &'a S { ++ let state: &'a StreamState = mem::transmute(compat::BIO_get_data(bio)); ++ &state.stream ++} ++ ++pub unsafe fn get_mut<'a, S: 'a>(bio: *mut BIO) -> &'a mut S { ++ &mut state(bio).stream ++} ++ ++unsafe fn state<'a, S: 'a>(bio: *mut BIO) -> &'a mut StreamState { ++ &mut *(compat::BIO_get_data(bio) as *mut _) ++} ++ ++unsafe extern "C" fn bwrite(bio: *mut BIO, buf: *const c_char, len: c_int) -> c_int { ++ BIO_clear_retry_flags(bio); ++ ++ let state = state::(bio); ++ let buf = slice::from_raw_parts(buf as *const _, len as usize); ++ ++ match catch_unwind(AssertUnwindSafe(|| state.stream.write(buf))) { ++ Ok(Ok(len)) => len as c_int, ++ Ok(Err(err)) => { ++ if retriable_error(&err) { ++ BIO_set_retry_write(bio); ++ } ++ state.error = Some(err); ++ -1 ++ } ++ Err(err) => { ++ state.panic = Some(err); ++ -1 ++ } ++ } ++} ++ ++unsafe extern "C" fn bread(bio: *mut BIO, buf: *mut c_char, len: c_int) -> c_int { ++ BIO_clear_retry_flags(bio); ++ ++ let state = state::(bio); ++ let buf = slice::from_raw_parts_mut(buf as *mut _, len as usize); ++ ++ match catch_unwind(AssertUnwindSafe(|| state.stream.read(buf))) { ++ Ok(Ok(len)) => len as c_int, ++ Ok(Err(err)) => { ++ if retriable_error(&err) { ++ BIO_set_retry_read(bio); ++ } ++ state.error = Some(err); ++ -1 ++ } ++ Err(err) => { ++ state.panic = Some(err); ++ -1 ++ } ++ } ++} ++ ++fn retriable_error(err: &io::Error) -> bool { ++ match err.kind() { ++ io::ErrorKind::WouldBlock | ++ io::ErrorKind::NotConnected => true, ++ _ => false, ++ } ++} ++ ++unsafe extern "C" fn bputs(bio: *mut BIO, s: *const c_char) -> c_int { ++ bwrite::(bio, s, strlen(s) as c_int) ++} ++ ++unsafe extern "C" fn ctrl( ++ bio: *mut BIO, ++ cmd: c_int, ++ _num: c_long, ++ _ptr: *mut c_void, ++) -> c_long { ++ if cmd == BIO_CTRL_FLUSH { ++ let state = state::(bio); ++ ++ match catch_unwind(AssertUnwindSafe(|| state.stream.flush())) { ++ Ok(Ok(())) => 1, ++ Ok(Err(err)) => { ++ state.error = Some(err); ++ 0 ++ } ++ Err(err) => { ++ state.panic = Some(err); ++ 0 ++ } ++ } ++ } else { ++ 0 ++ } ++} ++ ++unsafe extern "C" fn create(bio: *mut BIO) -> c_int { ++ compat::BIO_set_init(bio, 0); ++ compat::BIO_set_num(bio, 0); ++ compat::BIO_set_data(bio, ptr::null_mut()); ++ compat::BIO_set_flags(bio, 0); ++ 1 ++} ++ ++unsafe extern "C" fn destroy(bio: *mut BIO) -> c_int { ++ if bio.is_null() { ++ return 0; ++ } ++ ++ let data = compat::BIO_get_data(bio); ++ assert!(!data.is_null()); ++ Box::>::from_raw(data as *mut _); ++ compat::BIO_set_data(bio, ptr::null_mut()); ++ compat::BIO_set_init(bio, 0); ++ 1 ++} ++ ++#[cfg(ossl110)] ++#[allow(bad_style)] ++mod compat { ++ use std::io::{Read, Write}; ++ ++ use libc::c_int; ++ use ffi; ++ pub use ffi::{BIO_set_init, BIO_set_flags, BIO_set_data, BIO_get_data}; ++ ++ pub unsafe fn BIO_set_num(_bio: *mut ffi::BIO, _num: c_int) {} ++ ++ pub struct BIO_METHOD(*mut ffi::BIO_METHOD); ++ ++ impl BIO_METHOD { ++ pub fn new() -> BIO_METHOD { ++ unsafe { ++ let ptr = ffi::BIO_meth_new(ffi::BIO_TYPE_NONE, b"rust\0".as_ptr() as *const _); ++ assert!(!ptr.is_null()); ++ let ret = BIO_METHOD(ptr); ++ assert!(ffi::BIO_meth_set_write(ptr, super::bwrite::) != 0); ++ assert!(ffi::BIO_meth_set_read(ptr, super::bread::) != 0); ++ assert!(ffi::BIO_meth_set_puts(ptr, super::bputs::) != 0); ++ assert!(ffi::BIO_meth_set_ctrl(ptr, super::ctrl::) != 0); ++ assert!(ffi::BIO_meth_set_create(ptr, super::create) != 0); ++ assert!(ffi::BIO_meth_set_destroy(ptr, super::destroy::) != 0); ++ return ret; ++ } ++ } ++ ++ pub fn get(&self) -> *mut ffi::BIO_METHOD { ++ self.0 ++ } ++ } ++ ++ impl Drop for BIO_METHOD { ++ fn drop(&mut self) { ++ unsafe { ++ ffi::BIO_meth_free(self.0); ++ } ++ } ++ } ++} ++ ++#[cfg(ossl10x)] ++#[allow(bad_style)] ++mod compat { ++ use std::io::{Read, Write}; ++ ++ use ffi; ++ use libc::{c_int, c_void}; ++ ++ pub struct BIO_METHOD(*mut ffi::BIO_METHOD); ++ ++ impl BIO_METHOD { ++ pub fn new() -> BIO_METHOD { ++ let ptr = Box::new(ffi::BIO_METHOD { ++ type_: ffi::BIO_TYPE_NONE, ++ name: b"rust\0".as_ptr() as *const _, ++ bwrite: Some(super::bwrite::), ++ bread: Some(super::bread::), ++ bputs: Some(super::bputs::), ++ bgets: None, ++ ctrl: Some(super::ctrl::), ++ create: Some(super::create), ++ destroy: Some(super::destroy::), ++ callback_ctrl: None, ++ }); ++ ++ BIO_METHOD(Box::into_raw(ptr)) ++ } ++ ++ pub fn get(&self) -> *mut ffi::BIO_METHOD { ++ self.0 ++ } ++ } ++ ++ impl Drop for BIO_METHOD { ++ fn drop(&mut self) { ++ unsafe { ++ Box::::from_raw(self.0); ++ } ++ } ++ } ++ ++ pub unsafe fn BIO_set_init(bio: *mut ffi::BIO, init: c_int) { ++ (*bio).init = init; ++ } ++ ++ pub unsafe fn BIO_set_flags(bio: *mut ffi::BIO, flags: c_int) { ++ (*bio).flags = flags; ++ } ++ ++ pub unsafe fn BIO_get_data(bio: *mut ffi::BIO) -> *mut c_void { ++ (*bio).ptr ++ } ++ ++ pub unsafe fn BIO_set_data(bio: *mut ffi::BIO, data: *mut c_void) { ++ (*bio).ptr = data; ++ } ++ ++ pub unsafe fn BIO_set_num(bio: *mut ffi::BIO, num: c_int) { ++ (*bio).num = num; ++ } ++} diff --cc vendor/openssl-0.9.19/src/ssl/callbacks.rs index 000000000,000000000..d7c480509 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ssl/callbacks.rs @@@ -1,0 -1,0 +1,339 @@@ ++use ffi; ++use libc::{c_int, c_uint, c_char, c_uchar, c_void}; ++use std::any::Any; ++use std::ffi::CStr; ++use std::ptr; ++use std::slice; ++use std::mem; ++use foreign_types::ForeignTypeRef; ++ ++use error::ErrorStack; ++use dh::Dh; ++#[cfg(any(all(feature = "v101", ossl101), all(feature = "v102", ossl102)))] ++use ec_key::EcKey; ++use ssl::{get_callback_idx, get_ssl_callback_idx, SslRef, SniError, NPN_PROTOS_IDX}; ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++use ssl::ALPN_PROTOS_IDX; ++use x509::X509StoreContextRef; ++ ++pub extern "C" fn raw_verify(preverify_ok: c_int, x509_ctx: *mut ffi::X509_STORE_CTX) -> c_int ++where ++ F: Fn(bool, &X509StoreContextRef) -> bool + Any + 'static + Sync + Send, ++{ ++ unsafe { ++ let idx = ffi::SSL_get_ex_data_X509_STORE_CTX_idx(); ++ let ssl = ffi::X509_STORE_CTX_get_ex_data(x509_ctx, idx); ++ let ssl_ctx = ffi::SSL_get_SSL_CTX(ssl as *const _); ++ let verify = ffi::SSL_CTX_get_ex_data(ssl_ctx, get_callback_idx::()); ++ let verify: &F = &*(verify as *mut F); ++ ++ let ctx = X509StoreContextRef::from_ptr(x509_ctx); ++ ++ verify(preverify_ok != 0, ctx) as c_int ++ } ++} ++ ++#[cfg(not(osslconf = "OPENSSL_NO_PSK"))] ++pub extern "C" fn raw_psk( ++ ssl: *mut ffi::SSL, ++ hint: *const c_char, ++ identity: *mut c_char, ++ max_identity_len: c_uint, ++ psk: *mut c_uchar, ++ max_psk_len: c_uint, ++) -> c_uint ++where ++ F: Fn(&mut SslRef, Option<&[u8]>, &mut [u8], &mut [u8]) -> Result ++ + Any ++ + 'static ++ + Sync ++ + Send, ++{ ++ unsafe { ++ let ssl_ctx = ffi::SSL_get_SSL_CTX(ssl as *const _); ++ let callback = ffi::SSL_CTX_get_ex_data(ssl_ctx, get_callback_idx::()); ++ let ssl = SslRef::from_ptr_mut(ssl); ++ let callback = &*(callback as *mut F); ++ let hint = if hint != ptr::null() { ++ Some(CStr::from_ptr(hint).to_bytes()) ++ } else { ++ None ++ }; ++ // Give the callback mutable slices into which it can write the identity and psk. ++ let identity_sl = slice::from_raw_parts_mut(identity as *mut u8, max_identity_len as usize); ++ let psk_sl = slice::from_raw_parts_mut(psk as *mut u8, max_psk_len as usize); ++ match callback(ssl, hint, identity_sl, psk_sl) { ++ Ok(psk_len) => psk_len as u32, ++ _ => 0, ++ } ++ } ++} ++ ++pub extern "C" fn ssl_raw_verify( ++ preverify_ok: c_int, ++ x509_ctx: *mut ffi::X509_STORE_CTX, ++) -> c_int ++where ++ F: Fn(bool, &X509StoreContextRef) -> bool + Any + 'static + Sync + Send, ++{ ++ unsafe { ++ let idx = ffi::SSL_get_ex_data_X509_STORE_CTX_idx(); ++ let ssl = ffi::X509_STORE_CTX_get_ex_data(x509_ctx, idx); ++ let verify = ffi::SSL_get_ex_data(ssl as *const _, get_ssl_callback_idx::()); ++ let verify: &F = &*(verify as *mut F); ++ ++ let ctx = X509StoreContextRef::from_ptr(x509_ctx); ++ ++ verify(preverify_ok != 0, ctx) as c_int ++ } ++} ++ ++pub extern "C" fn raw_sni(ssl: *mut ffi::SSL, al: *mut c_int, _arg: *mut c_void) -> c_int ++where ++ F: Fn(&mut SslRef) -> Result<(), SniError> + Any + 'static + Sync + Send, ++{ ++ unsafe { ++ let ssl_ctx = ffi::SSL_get_SSL_CTX(ssl); ++ let callback = ffi::SSL_CTX_get_ex_data(ssl_ctx, get_callback_idx::()); ++ let callback: &F = &*(callback as *mut F); ++ let ssl = SslRef::from_ptr_mut(ssl); ++ ++ match callback(ssl) { ++ Ok(()) => ffi::SSL_TLSEXT_ERR_OK, ++ Err(SniError::Fatal(e)) => { ++ *al = e; ++ ffi::SSL_TLSEXT_ERR_ALERT_FATAL ++ } ++ Err(SniError::Warning(e)) => { ++ *al = e; ++ ffi::SSL_TLSEXT_ERR_ALERT_WARNING ++ } ++ Err(SniError::NoAck) => ffi::SSL_TLSEXT_ERR_NOACK, ++ } ++ } ++} ++ ++pub unsafe fn select_proto_using( ++ ssl: *mut ffi::SSL, ++ out: *mut *mut c_uchar, ++ outlen: *mut c_uchar, ++ inbuf: *const c_uchar, ++ inlen: c_uint, ++ ex_data: c_int, ++) -> c_int { ++ ++ // First, get the list of protocols (that the client should support) saved in the context ++ // extra data. ++ let ssl_ctx = ffi::SSL_get_SSL_CTX(ssl); ++ let protocols = ffi::SSL_CTX_get_ex_data(ssl_ctx, ex_data); ++ let protocols: &Vec = &*(protocols as *mut Vec); ++ // Prepare the client list parameters to be passed to the OpenSSL function... ++ let client = protocols.as_ptr(); ++ let client_len = protocols.len() as c_uint; ++ // Finally, let OpenSSL find a protocol to be used, by matching the given server and ++ // client lists. ++ if ffi::SSL_select_next_proto(out, outlen, inbuf, inlen, client, client_len) != ++ ffi::OPENSSL_NPN_NEGOTIATED ++ { ++ ffi::SSL_TLSEXT_ERR_NOACK ++ } else { ++ ffi::SSL_TLSEXT_ERR_OK ++ } ++} ++ ++/// The function is given as the callback to `SSL_CTX_set_next_proto_select_cb`. ++/// ++/// It chooses the protocol that the client wishes to use, out of the given list of protocols ++/// supported by the server. It achieves this by delegating to the `SSL_select_next_proto` ++/// function. The list of protocols supported by the client is found in the extra data of the ++/// OpenSSL context. ++pub extern "C" fn raw_next_proto_select_cb( ++ ssl: *mut ffi::SSL, ++ out: *mut *mut c_uchar, ++ outlen: *mut c_uchar, ++ inbuf: *const c_uchar, ++ inlen: c_uint, ++ _arg: *mut c_void, ++) -> c_int { ++ unsafe { select_proto_using(ssl, out, outlen, inbuf, inlen, *NPN_PROTOS_IDX) } ++} ++ ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++pub extern "C" fn raw_alpn_select_cb( ++ ssl: *mut ffi::SSL, ++ out: *mut *const c_uchar, ++ outlen: *mut c_uchar, ++ inbuf: *const c_uchar, ++ inlen: c_uint, ++ _arg: *mut c_void, ++) -> c_int { ++ unsafe { select_proto_using(ssl, out as *mut _, outlen, inbuf, inlen, *ALPN_PROTOS_IDX) } ++} ++ ++pub unsafe extern "C" fn raw_tmp_dh( ++ ssl: *mut ffi::SSL, ++ is_export: c_int, ++ keylength: c_int, ++) -> *mut ffi::DH ++where ++ F: Fn(&mut SslRef, bool, u32) -> Result + Any + 'static + Sync + Send, ++{ ++ let ctx = ffi::SSL_get_SSL_CTX(ssl); ++ let callback = ffi::SSL_CTX_get_ex_data(ctx, get_callback_idx::()); ++ let callback = &*(callback as *mut F); ++ ++ let ssl = SslRef::from_ptr_mut(ssl); ++ match callback(ssl, is_export != 0, keylength as u32) { ++ Ok(dh) => { ++ let ptr = dh.as_ptr(); ++ mem::forget(dh); ++ ptr ++ } ++ Err(_) => { ++ // FIXME reset error stack ++ ptr::null_mut() ++ } ++ } ++} ++ ++#[cfg(any(all(feature = "v101", ossl101), all(feature = "v102", ossl102)))] ++pub unsafe extern "C" fn raw_tmp_ecdh( ++ ssl: *mut ffi::SSL, ++ is_export: c_int, ++ keylength: c_int, ++) -> *mut ffi::EC_KEY ++where ++ F: Fn(&mut SslRef, bool, u32) -> Result + Any + 'static + Sync + Send, ++{ ++ let ctx = ffi::SSL_get_SSL_CTX(ssl); ++ let callback = ffi::SSL_CTX_get_ex_data(ctx, get_callback_idx::()); ++ let callback = &*(callback as *mut F); ++ ++ let ssl = SslRef::from_ptr_mut(ssl); ++ match callback(ssl, is_export != 0, keylength as u32) { ++ Ok(ec_key) => { ++ let ptr = ec_key.as_ptr(); ++ mem::forget(ec_key); ++ ptr ++ } ++ Err(_) => { ++ // FIXME reset error stack ++ ptr::null_mut() ++ } ++ } ++} ++ ++pub unsafe extern "C" fn raw_tmp_dh_ssl( ++ ssl: *mut ffi::SSL, ++ is_export: c_int, ++ keylength: c_int, ++) -> *mut ffi::DH ++where ++ F: Fn(&mut SslRef, bool, u32) -> Result + Any + 'static + Sync + Send, ++{ ++ let callback = ffi::SSL_get_ex_data(ssl, get_ssl_callback_idx::()); ++ let callback = &*(callback as *mut F); ++ ++ let ssl = SslRef::from_ptr_mut(ssl); ++ match callback(ssl, is_export != 0, keylength as u32) { ++ Ok(dh) => { ++ let ptr = dh.as_ptr(); ++ mem::forget(dh); ++ ptr ++ } ++ Err(_) => { ++ // FIXME reset error stack ++ ptr::null_mut() ++ } ++ } ++} ++ ++#[cfg(any(all(feature = "v101", ossl101), all(feature = "v102", ossl102)))] ++pub unsafe extern "C" fn raw_tmp_ecdh_ssl( ++ ssl: *mut ffi::SSL, ++ is_export: c_int, ++ keylength: c_int, ++) -> *mut ffi::EC_KEY ++where ++ F: Fn(&mut SslRef, bool, u32) -> Result + Any + 'static + Sync + Send, ++{ ++ let callback = ffi::SSL_get_ex_data(ssl, get_ssl_callback_idx::()); ++ let callback = &*(callback as *mut F); ++ ++ let ssl = SslRef::from_ptr_mut(ssl); ++ match callback(ssl, is_export != 0, keylength as u32) { ++ Ok(ec_key) => { ++ let ptr = ec_key.as_ptr(); ++ mem::forget(ec_key); ++ ptr ++ } ++ Err(_) => { ++ // FIXME reset error stack ++ ptr::null_mut() ++ } ++ } ++} ++ ++pub unsafe extern "C" fn raw_tlsext_status(ssl: *mut ffi::SSL, _: *mut c_void) -> c_int ++where ++ F: Fn(&mut SslRef) -> Result + Any + 'static + Sync + Send, ++{ ++ let ssl_ctx = ffi::SSL_get_SSL_CTX(ssl as *const _); ++ let callback = ffi::SSL_CTX_get_ex_data(ssl_ctx, get_callback_idx::()); ++ let callback = &*(callback as *mut F); ++ ++ let ssl = SslRef::from_ptr_mut(ssl); ++ let ret = callback(ssl); ++ ++ if ssl.is_server() { ++ match ret { ++ Ok(true) => ffi::SSL_TLSEXT_ERR_OK, ++ Ok(false) => ffi::SSL_TLSEXT_ERR_NOACK, ++ Err(_) => { ++ // FIXME reset error stack ++ ffi::SSL_TLSEXT_ERR_ALERT_FATAL ++ } ++ } ++ } else { ++ match ret { ++ Ok(true) => 1, ++ Ok(false) => 0, ++ Err(_) => { ++ // FIXME reset error stack ++ -1 ++ } ++ } ++ } ++} ++ ++/// The function is given as the callback to `SSL_CTX_set_next_protos_advertised_cb`. ++/// ++/// It causes the parameter `out` to point at a `*const c_uchar` instance that ++/// represents the list of protocols that the server should advertise as those ++/// that it supports. ++/// The list of supported protocols is found in the extra data of the OpenSSL ++/// context. ++pub extern "C" fn raw_next_protos_advertise_cb( ++ ssl: *mut ffi::SSL, ++ out: *mut *const c_uchar, ++ outlen: *mut c_uint, ++ _arg: *mut c_void, ++) -> c_int { ++ unsafe { ++ // First, get the list of (supported) protocols saved in the context extra data. ++ let ssl_ctx = ffi::SSL_get_SSL_CTX(ssl); ++ let protocols = ffi::SSL_CTX_get_ex_data(ssl_ctx, *NPN_PROTOS_IDX); ++ if protocols.is_null() { ++ *out = b"".as_ptr(); ++ *outlen = 0; ++ } else { ++ // If the pointer is valid, put the pointer to the actual byte array into the ++ // output parameter `out`, as well as its length into `outlen`. ++ let protocols: &Vec = &*(protocols as *mut Vec); ++ *out = protocols.as_ptr(); ++ *outlen = protocols.len() as c_uint; ++ } ++ } ++ ++ ffi::SSL_TLSEXT_ERR_OK ++} diff --cc vendor/openssl-0.9.19/src/ssl/connector.rs index 000000000,000000000..076f246f3 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ssl/connector.rs @@@ -1,0 -1,0 +1,541 @@@ ++use std::io::{Read, Write}; ++ ++use dh::Dh; ++use error::ErrorStack; ++use ssl::{self, SslMethod, SslContextBuilder, SslContext, Ssl, SSL_VERIFY_PEER, SslStream, ++ HandshakeError}; ++use pkey::PKeyRef; ++use version; ++use x509::X509Ref; ++ ++#[cfg(ossl101)] ++lazy_static! { ++ static ref HOSTNAME_IDX: ::ex_data::Index = Ssl::new_ex_index().unwrap(); ++} ++ ++// ffdhe2048 from https://wiki.mozilla.org/Security/Server_Side_TLS#ffdhe2048 ++const DHPARAM_PEM: &'static str = " ++-----BEGIN DH PARAMETERS----- ++MIIBCAKCAQEA//////////+t+FRYortKmq/cViAnPTzx2LnFg84tNpWp4TZBFGQz +++8yTnc4kmz75fS/jY2MMddj2gbICrsRhetPfHtXV/WVhJDP1H18GbtCFY2VVPe0a ++87VXE15/V8k1mE8McODmi3fipona8+/och3xWKE2rec1MKzKT0g6eXq8CrGCsyT7 ++YdEIqUuyyOP7uWrat2DX9GgdT0Kj3jlN9K5W7edjcrsZCwenyO4KbXCeAvzhzffi ++7MA0BM0oNC9hkXL+nOmFg/+OTxIy7vKBg8P+OxtMb61zO7X8vC7CIAXFjvGDfRaD ++ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg== ++-----END DH PARAMETERS----- ++"; ++ ++fn ctx(method: SslMethod) -> Result { ++ let mut ctx = try!(SslContextBuilder::new(method)); ++ ++ let mut opts = ssl::SSL_OP_ALL; ++ opts &= !ssl::SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG; ++ opts &= !ssl::SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS; ++ opts |= ssl::SSL_OP_NO_TICKET; ++ opts |= ssl::SSL_OP_NO_COMPRESSION; ++ opts |= ssl::SSL_OP_NO_SSLV2; ++ opts |= ssl::SSL_OP_NO_SSLV3; ++ opts |= ssl::SSL_OP_SINGLE_DH_USE; ++ opts |= ssl::SSL_OP_SINGLE_ECDH_USE; ++ opts |= ssl::SSL_OP_CIPHER_SERVER_PREFERENCE; ++ ctx.set_options(opts); ++ ++ let mut mode = ssl::SSL_MODE_AUTO_RETRY | ++ ssl::SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER | ++ ssl::SSL_MODE_ENABLE_PARTIAL_WRITE; ++ ++ // This is quite a useful optimization for saving memory, but historically ++ // caused CVEs in OpenSSL pre-1.0.1h, according to ++ // https://bugs.python.org/issue25672 ++ if version::number() >= 0x1000108f { ++ mode |= ssl::SSL_MODE_RELEASE_BUFFERS; ++ } ++ ++ ctx.set_mode(mode); ++ ++ Ok(ctx) ++} ++ ++/// A builder for `SslConnector`s. ++pub struct SslConnectorBuilder(SslContextBuilder); ++ ++impl SslConnectorBuilder { ++ /// Creates a new builder for TLS connections. ++ /// ++ /// The default configuration is subject to change, and is currently derived from Python. ++ pub fn new(method: SslMethod) -> Result { ++ let mut ctx = try!(ctx(method)); ++ try!(ctx.set_default_verify_paths()); ++ // From https://github.com/python/cpython/blob/a170fa162dc03f0a014373349e548954fff2e567/Lib/ssl.py#L193 ++ try!(ctx.set_cipher_list( ++ "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:\ ++ TLS13-AES-128-GCM-SHA256:\ ++ ECDH+AESGCM:ECDH+CHACHA20:DH+AESGCM:DH+CHACHA20:ECDH+AES256:DH+AES256:\ ++ ECDH+AES128:DH+AES:ECDH+HIGH:DH+HIGH:RSA+AESGCM:RSA+AES:RSA+HIGH:\ ++ !aNULL:!eNULL:!MD5:!3DES" ++ )); ++ setup_verify(&mut ctx); ++ ++ Ok(SslConnectorBuilder(ctx)) ++ } ++ ++ /// Returns a shared reference to the inner `SslContextBuilder`. ++ pub fn builder(&self) -> &SslContextBuilder { ++ &self.0 ++ } ++ ++ /// Returns a mutable reference to the inner `SslContextBuilder`. ++ pub fn builder_mut(&mut self) -> &mut SslContextBuilder { ++ &mut self.0 ++ } ++ ++ /// Consumes the builder, returning a `SslConnector`. ++ pub fn build(self) -> SslConnector { ++ SslConnector(self.0.build()) ++ } ++} ++ ++/// A type which wraps client-side streams in a TLS session. ++/// ++/// OpenSSL's default configuration is highly insecure. This connector manages the OpenSSL ++/// structures, configuring cipher suites, session options, hostname verification, and more. ++/// ++/// OpenSSL's built in hostname verification is used when linking against OpenSSL 1.0.2 or 1.1.0, ++/// and a custom implementation is used when linking against OpenSSL 1.0.1. ++#[derive(Clone)] ++pub struct SslConnector(SslContext); ++ ++impl SslConnector { ++ /// Initiates a client-side TLS session on a stream. ++ /// ++ /// The domain is used for SNI and hostname verification. ++ pub fn connect(&self, domain: &str, stream: S) -> Result, HandshakeError> ++ where ++ S: Read + Write, ++ { ++ try!(self.configure()).connect(domain, stream) ++ } ++ ++ /// Initiates a client-side TLS session on a stream without performing hostname verification. ++ /// ++ /// # Warning ++ /// ++ /// You should think very carefully before you use this method. If hostname verification is not ++ /// used, *any* valid certificate for *any* site will be trusted for use from any other. This ++ /// introduces a significant vulnerability to man-in-the-middle attacks. ++ pub fn danger_connect_without_providing_domain_for_certificate_verification_and_server_name_indication( ++ &self, stream: S) -> Result, HandshakeError> ++ where S: Read + Write ++ { ++ try!(self.configure()) ++ .danger_connect_without_providing_domain_for_certificate_verification_and_server_name_indication(stream) ++ } ++ ++ /// Returns a structure allowing for configuration of a single TLS session before connection. ++ pub fn configure(&self) -> Result { ++ Ssl::new(&self.0).map(ConnectConfiguration) ++ } ++} ++ ++/// A type which allows for configuration of a client-side TLS session before connection. ++pub struct ConnectConfiguration(Ssl); ++ ++impl ConnectConfiguration { ++ /// Returns a shared reference to the inner `Ssl`. ++ pub fn ssl(&self) -> &Ssl { ++ &self.0 ++ } ++ ++ /// Returns a mutable reference to the inner `Ssl`. ++ pub fn ssl_mut(&mut self) -> &mut Ssl { ++ &mut self.0 ++ } ++ ++ /// Initiates a client-side TLS session on a stream. ++ /// ++ /// The domain is used for SNI and hostname verification. ++ pub fn connect(mut self, domain: &str, stream: S) -> Result, HandshakeError> ++ where ++ S: Read + Write, ++ { ++ try!(self.0.set_hostname(domain)); ++ try!(setup_verify_hostname(&mut self.0, domain)); ++ ++ self.0.connect(stream) ++ } ++ ++ /// Initiates a client-side TLS session on a stream without performing hostname verification. ++ /// ++ /// The verification configuration of the connector's `SslContext` is not overridden. ++ /// ++ /// # Warning ++ /// ++ /// You should think very carefully before you use this method. If hostname verification is not ++ /// used, *any* valid certificate for *any* site will be trusted for use from any other. This ++ /// introduces a significant vulnerability to man-in-the-middle attacks. ++ pub fn danger_connect_without_providing_domain_for_certificate_verification_and_server_name_indication( ++ self, stream: S) -> Result, HandshakeError> ++ where S: Read + Write ++ { ++ self.0.connect(stream) ++ } ++} ++ ++/// A builder for `SslAcceptor`s. ++pub struct SslAcceptorBuilder(SslContextBuilder); ++ ++impl SslAcceptorBuilder { ++ /// Creates a new builder configured to connect to non-legacy clients. This should generally be ++ /// considered a reasonable default choice. ++ /// ++ /// This corresponds to the intermediate configuration of Mozilla's server side TLS ++ /// recommendations. See its [documentation][docs] for more details on specifics. ++ /// ++ /// [docs]: https://wiki.mozilla.org/Security/Server_Side_TLS ++ pub fn mozilla_intermediate( ++ method: SslMethod, ++ private_key: &PKeyRef, ++ certificate: &X509Ref, ++ chain: I, ++ ) -> Result ++ where ++ I: IntoIterator, ++ I::Item: AsRef, ++ { ++ let builder = try!(SslAcceptorBuilder::mozilla_intermediate_raw(method)); ++ builder.finish_setup(private_key, certificate, chain) ++ } ++ ++ /// Creates a new builder configured to connect to modern clients. ++ /// ++ /// This corresponds to the modern configuration of Mozilla's server side TLS recommendations. ++ /// See its [documentation][docs] for more details on specifics. ++ /// ++ /// [docs]: https://wiki.mozilla.org/Security/Server_Side_TLS ++ pub fn mozilla_modern( ++ method: SslMethod, ++ private_key: &PKeyRef, ++ certificate: &X509Ref, ++ chain: I, ++ ) -> Result ++ where ++ I: IntoIterator, ++ I::Item: AsRef, ++ { ++ let builder = try!(SslAcceptorBuilder::mozilla_modern_raw(method)); ++ builder.finish_setup(private_key, certificate, chain) ++ } ++ ++ /// Like `mozilla_intermediate`, but does not load the certificate chain and private key. ++ pub fn mozilla_intermediate_raw(method: SslMethod) -> Result { ++ let mut ctx = try!(ctx(method)); ++ let dh = try!(Dh::from_pem(DHPARAM_PEM.as_bytes())); ++ try!(ctx.set_tmp_dh(&dh)); ++ try!(setup_curves(&mut ctx)); ++ try!(ctx.set_cipher_list( ++ "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:\ ++ ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:\ ++ ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:\ ++ DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:\ ++ ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:\ ++ ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:\ ++ ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:\ ++ DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:\ ++ EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:\ ++ AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS", ++ )); ++ Ok(SslAcceptorBuilder(ctx)) ++ } ++ ++ /// Like `mozilla_modern`, but does not load the certificate chain and private key. ++ pub fn mozilla_modern_raw(method: SslMethod) -> Result { ++ let mut ctx = try!(ctx(method)); ++ try!(setup_curves(&mut ctx)); ++ try!(ctx.set_cipher_list( ++ "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:\ ++ ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:\ ++ ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:\ ++ ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256", ++ )); ++ Ok(SslAcceptorBuilder(ctx)) ++ } ++ ++ fn finish_setup( ++ mut self, ++ private_key: &PKeyRef, ++ certificate: &X509Ref, ++ chain: I, ++ ) -> Result ++ where ++ I: IntoIterator, ++ I::Item: AsRef, ++ { ++ try!(self.0.set_private_key(private_key)); ++ try!(self.0.set_certificate(certificate)); ++ try!(self.0.check_private_key()); ++ for cert in chain { ++ try!(self.0.add_extra_chain_cert(cert.as_ref().to_owned())); ++ } ++ Ok(self) ++ } ++ ++ /// Returns a shared reference to the inner `SslContextBuilder`. ++ pub fn builder(&self) -> &SslContextBuilder { ++ &self.0 ++ } ++ ++ /// Returns a mutable reference to the inner `SslContextBuilder`. ++ pub fn builder_mut(&mut self) -> &mut SslContextBuilder { ++ &mut self.0 ++ } ++ ++ /// Consumes the builder, returning a `SslAcceptor`. ++ pub fn build(self) -> SslAcceptor { ++ SslAcceptor(self.0.build()) ++ } ++} ++ ++#[cfg(ossl101)] ++fn setup_curves(ctx: &mut SslContextBuilder) -> Result<(), ErrorStack> { ++ use ec::EcKey; ++ use nid; ++ ++ let curve = try!(EcKey::from_curve_name(nid::X9_62_PRIME256V1)); ++ ctx.set_tmp_ecdh(&curve) ++} ++ ++#[cfg(ossl102)] ++fn setup_curves(ctx: &mut SslContextBuilder) -> Result<(), ErrorStack> { ++ ctx._set_ecdh_auto(true) ++} ++ ++#[cfg(ossl110)] ++fn setup_curves(_: &mut SslContextBuilder) -> Result<(), ErrorStack> { ++ Ok(()) ++} ++ ++/// A type which wraps server-side streams in a TLS session. ++/// ++/// OpenSSL's default configuration is highly insecure. This connector manages the OpenSSL ++/// structures, configuring cipher suites, session options, and more. ++#[derive(Clone)] ++pub struct SslAcceptor(SslContext); ++ ++impl SslAcceptor { ++ /// Initiates a server-side TLS session on a stream. ++ pub fn accept(&self, stream: S) -> Result, HandshakeError> ++ where ++ S: Read + Write, ++ { ++ let ssl = try!(Ssl::new(&self.0)); ++ ssl.accept(stream) ++ } ++} ++ ++#[cfg(any(ossl102, ossl110))] ++fn setup_verify(ctx: &mut SslContextBuilder) { ++ ctx.set_verify(SSL_VERIFY_PEER); ++} ++ ++#[cfg(ossl101)] ++fn setup_verify(ctx: &mut SslContextBuilder) { ++ ctx.set_verify_callback(SSL_VERIFY_PEER, |p, x509| { ++ let hostname = match x509.ssl() { ++ Ok(Some(ssl)) => ssl.ex_data(*HOSTNAME_IDX), ++ _ => None, ++ }; ++ match hostname { ++ Some(hostname) => verify::verify_callback(hostname, p, x509), ++ None => p, ++ } ++ }); ++} ++ ++#[cfg(any(ossl102, ossl110))] ++fn setup_verify_hostname(ssl: &mut Ssl, domain: &str) -> Result<(), ErrorStack> { ++ let param = ssl._param_mut(); ++ param.set_hostflags(::verify::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS); ++ match domain.parse() { ++ Ok(ip) => param.set_ip(ip), ++ Err(_) => param.set_host(domain), ++ } ++} ++ ++#[cfg(ossl101)] ++fn setup_verify_hostname(ssl: &mut Ssl, domain: &str) -> Result<(), ErrorStack> { ++ let domain = domain.to_string(); ++ ssl.set_ex_data(*HOSTNAME_IDX, domain); ++ Ok(()) ++} ++ ++#[cfg(ossl101)] ++mod verify { ++ use std::net::IpAddr; ++ use std::str; ++ ++ use nid; ++ use x509::{X509StoreContextRef, X509Ref, X509NameRef, GeneralName}; ++ use stack::Stack; ++ ++ pub fn verify_callback( ++ domain: &str, ++ preverify_ok: bool, ++ x509_ctx: &X509StoreContextRef, ++ ) -> bool { ++ if !preverify_ok || x509_ctx.error_depth() != 0 { ++ return preverify_ok; ++ } ++ ++ match x509_ctx.current_cert() { ++ Some(x509) => verify_hostname(domain, &x509), ++ None => true, ++ } ++ } ++ ++ fn verify_hostname(domain: &str, cert: &X509Ref) -> bool { ++ match cert.subject_alt_names() { ++ Some(names) => verify_subject_alt_names(domain, names), ++ None => verify_subject_name(domain, &cert.subject_name()), ++ } ++ } ++ ++ fn verify_subject_alt_names(domain: &str, names: Stack) -> bool { ++ let ip = domain.parse(); ++ ++ for name in &names { ++ match ip { ++ Ok(ip) => { ++ if let Some(actual) = name.ipaddress() { ++ if matches_ip(&ip, actual) { ++ return true; ++ } ++ } ++ } ++ Err(_) => { ++ if let Some(pattern) = name.dnsname() { ++ if matches_dns(pattern, domain, false) { ++ return true; ++ } ++ } ++ } ++ } ++ } ++ ++ false ++ } ++ ++ fn verify_subject_name(domain: &str, subject_name: &X509NameRef) -> bool { ++ if let Some(pattern) = subject_name.entries_by_nid(nid::COMMONNAME).next() { ++ let pattern = match str::from_utf8(pattern.data().as_slice()) { ++ Ok(pattern) => pattern, ++ Err(_) => return false, ++ }; ++ ++ // Unlike with SANs, IP addresses in the subject name don't have a ++ // different encoding. We need to pass this down to matches_dns to ++ // disallow wildcard matches with bogus patterns like *.0.0.1 ++ let is_ip = domain.parse::().is_ok(); ++ ++ if matches_dns(&pattern, domain, is_ip) { ++ return true; ++ } ++ } ++ ++ false ++ } ++ ++ fn matches_dns(mut pattern: &str, mut hostname: &str, is_ip: bool) -> bool { ++ // first strip trailing . off of pattern and hostname to normalize ++ if pattern.ends_with('.') { ++ pattern = &pattern[..pattern.len() - 1]; ++ } ++ if hostname.ends_with('.') { ++ hostname = &hostname[..hostname.len() - 1]; ++ } ++ ++ matches_wildcard(pattern, hostname, is_ip).unwrap_or_else(|| pattern == hostname) ++ } ++ ++ fn matches_wildcard(pattern: &str, hostname: &str, is_ip: bool) -> Option { ++ // IP addresses and internationalized domains can't involved in wildcards ++ if is_ip || pattern.starts_with("xn--") { ++ return None; ++ } ++ ++ let wildcard_location = match pattern.find('*') { ++ Some(l) => l, ++ None => return None, ++ }; ++ ++ let mut dot_idxs = pattern.match_indices('.').map(|(l, _)| l); ++ let wildcard_end = match dot_idxs.next() { ++ Some(l) => l, ++ None => return None, ++ }; ++ ++ // Never match wildcards if the pattern has less than 2 '.'s (no *.com) ++ // ++ // This is a bit dubious, as it doesn't disallow other TLDs like *.co.uk. ++ // Chrome has a black- and white-list for this, but Firefox (via NSS) does ++ // the same thing we do here. ++ // ++ // The Public Suffix (https://www.publicsuffix.org/) list could ++ // potentially be used here, but it's both huge and updated frequently ++ // enough that management would be a PITA. ++ if dot_idxs.next().is_none() { ++ return None; ++ } ++ ++ // Wildcards can only be in the first component ++ if wildcard_location > wildcard_end { ++ return None; ++ } ++ ++ let hostname_label_end = match hostname.find('.') { ++ Some(l) => l, ++ None => return None, ++ }; ++ ++ // check that the non-wildcard parts are identical ++ if pattern[wildcard_end..] != hostname[hostname_label_end..] { ++ return Some(false); ++ } ++ ++ let wildcard_prefix = &pattern[..wildcard_location]; ++ let wildcard_suffix = &pattern[wildcard_location + 1..wildcard_end]; ++ ++ let hostname_label = &hostname[..hostname_label_end]; ++ ++ // check the prefix of the first label ++ if !hostname_label.starts_with(wildcard_prefix) { ++ return Some(false); ++ } ++ ++ // and the suffix ++ if !hostname_label[wildcard_prefix.len()..].ends_with(wildcard_suffix) { ++ return Some(false); ++ } ++ ++ Some(true) ++ } ++ ++ fn matches_ip(expected: &IpAddr, actual: &[u8]) -> bool { ++ match (expected, actual.len()) { ++ (&IpAddr::V4(ref addr), 4) => actual == addr.octets(), ++ (&IpAddr::V6(ref addr), 16) => { ++ let segments = [ ++ ((actual[0] as u16) << 8) | actual[1] as u16, ++ ((actual[2] as u16) << 8) | actual[3] as u16, ++ ((actual[4] as u16) << 8) | actual[5] as u16, ++ ((actual[6] as u16) << 8) | actual[7] as u16, ++ ((actual[8] as u16) << 8) | actual[9] as u16, ++ ((actual[10] as u16) << 8) | actual[11] as u16, ++ ((actual[12] as u16) << 8) | actual[13] as u16, ++ ((actual[14] as u16) << 8) | actual[15] as u16, ++ ]; ++ segments == addr.segments() ++ } ++ _ => false, ++ } ++ } ++} diff --cc vendor/openssl-0.9.19/src/ssl/error.rs index 000000000,000000000..74782d7a3 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ssl/error.rs @@@ -1,0 -1,0 +1,120 @@@ ++use std::any::Any; ++use std::error; ++use std::error::Error as StdError; ++use std::fmt; ++use std::io; ++ ++use error::ErrorStack; ++use ssl::MidHandshakeSslStream; ++ ++/// An SSL error. ++#[derive(Debug)] ++pub enum Error { ++ /// The SSL session has been closed by the other end ++ ZeroReturn, ++ /// An attempt to read data from the underlying socket returned ++ /// `WouldBlock`. Wait for read readiness and reattempt the operation. ++ WantRead(io::Error), ++ /// An attempt to write data from the underlying socket returned ++ /// `WouldBlock`. Wait for write readiness and reattempt the operation. ++ WantWrite(io::Error), ++ /// The client certificate callback requested to be called again. ++ WantX509Lookup, ++ /// An error reported by the underlying stream. ++ Stream(io::Error), ++ /// An error in the OpenSSL library. ++ Ssl(ErrorStack), ++} ++ ++impl fmt::Display for Error { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ try!(fmt.write_str(self.description())); ++ if let Some(err) = self.cause() { ++ write!(fmt, ": {}", err) ++ } else { ++ Ok(()) ++ } ++ } ++} ++ ++impl error::Error for Error { ++ fn description(&self) -> &str { ++ match *self { ++ Error::ZeroReturn => "The SSL session was closed by the other end", ++ Error::WantRead(_) => "A read attempt returned a `WouldBlock` error", ++ Error::WantWrite(_) => "A write attempt returned a `WouldBlock` error", ++ Error::WantX509Lookup => "The client certificate callback requested to be called again", ++ Error::Stream(_) => "The underlying stream reported an error", ++ Error::Ssl(_) => "The OpenSSL library reported an error", ++ } ++ } ++ ++ fn cause(&self) -> Option<&error::Error> { ++ match *self { ++ Error::WantRead(ref err) => Some(err), ++ Error::WantWrite(ref err) => Some(err), ++ Error::Stream(ref err) => Some(err), ++ Error::Ssl(ref err) => Some(err), ++ _ => None, ++ } ++ } ++} ++ ++impl From for Error { ++ fn from(e: ErrorStack) -> Error { ++ Error::Ssl(e) ++ } ++} ++ ++/// An error or intermediate state after a TLS handshake attempt. ++#[derive(Debug)] ++pub enum HandshakeError { ++ /// Setup failed. ++ SetupFailure(ErrorStack), ++ /// The handshake failed. ++ Failure(MidHandshakeSslStream), ++ /// The handshake was interrupted midway through. This error will never be returned for blocking streams. ++ // FIXME change to WouldBlock ++ Interrupted(MidHandshakeSslStream), ++} ++ ++impl StdError for HandshakeError { ++ fn description(&self) -> &str { ++ match *self { ++ HandshakeError::SetupFailure(_) => "stream setup failed", ++ HandshakeError::Failure(_) => "the handshake failed", ++ HandshakeError::Interrupted(_) => "the handshake was interrupted", ++ } ++ } ++ ++ fn cause(&self) -> Option<&StdError> { ++ match *self { ++ HandshakeError::SetupFailure(ref e) => Some(e), ++ HandshakeError::Failure(ref s) | ++ HandshakeError::Interrupted(ref s) => Some(s.error()), ++ } ++ } ++} ++ ++impl fmt::Display for HandshakeError { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ try!(f.write_str(StdError::description(self))); ++ match *self { ++ HandshakeError::SetupFailure(ref e) => try!(write!(f, ": {}", e)), ++ HandshakeError::Failure(ref s) | ++ HandshakeError::Interrupted(ref s) => { ++ try!(write!(f, ": {}", s.error())); ++ if let Some(err) = s.ssl().verify_result() { ++ try!(write!(f, ": {}", err)); ++ } ++ } ++ } ++ Ok(()) ++ } ++} ++ ++impl From for HandshakeError { ++ fn from(e: ErrorStack) -> HandshakeError { ++ HandshakeError::SetupFailure(e) ++ } ++} diff --cc vendor/openssl-0.9.19/src/ssl/mod.rs index 000000000,000000000..762118a5d new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ssl/mod.rs @@@ -1,0 -1,0 +1,2025 @@@ ++//! SSL/TLS support. ++//! ++//! `SslConnector` and `SslAcceptor` should be used in most cases - they handle ++//! configuration of the OpenSSL primitives for you. ++//! ++//! # Examples ++//! ++//! To connect as a client to a remote server: ++//! ++//! ``` ++//! use openssl::ssl::{SslMethod, SslConnectorBuilder}; ++//! use std::io::{Read, Write}; ++//! use std::net::TcpStream; ++//! ++//! let connector = SslConnectorBuilder::new(SslMethod::tls()).unwrap().build(); ++//! ++//! let stream = TcpStream::connect("google.com:443").unwrap(); ++//! let mut stream = connector.connect("google.com", stream).unwrap(); ++//! ++//! stream.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap(); ++//! let mut res = vec![]; ++//! stream.read_to_end(&mut res).unwrap(); ++//! println!("{}", String::from_utf8_lossy(&res)); ++//! ``` ++//! ++//! To accept connections as a server from remote clients: ++//! ++//! ```no_run ++//! use openssl::pkcs12::Pkcs12; ++//! use openssl::ssl::{SslMethod, SslAcceptorBuilder, SslStream}; ++//! use std::fs::File; ++//! use std::io::{Read, Write}; ++//! use std::net::{TcpListener, TcpStream}; ++//! use std::sync::Arc; ++//! use std::thread; ++//! ++//! // In this example we retrieve our keypair and certificate chain from a PKCS #12 archive, ++//! // but but they can also be retrieved from, for example, individual PEM- or DER-formatted ++//! // files. See the documentation for the `PKey` and `X509` types for more details. ++//! let mut file = File::open("identity.pfx").unwrap(); ++//! let mut pkcs12 = vec![]; ++//! file.read_to_end(&mut pkcs12).unwrap(); ++//! let pkcs12 = Pkcs12::from_der(&pkcs12).unwrap(); ++//! let identity = pkcs12.parse("password123").unwrap(); ++//! ++//! let acceptor = SslAcceptorBuilder::mozilla_intermediate(SslMethod::tls(), ++//! &identity.pkey, ++//! &identity.cert, ++//! &identity.chain) ++//! .unwrap() ++//! .build(); ++//! let acceptor = Arc::new(acceptor); ++//! ++//! let listener = TcpListener::bind("0.0.0.0:8443").unwrap(); ++//! ++//! fn handle_client(stream: SslStream) { ++//! // ... ++//! } ++//! ++//! for stream in listener.incoming() { ++//! match stream { ++//! Ok(stream) => { ++//! let acceptor = acceptor.clone(); ++//! thread::spawn(move || { ++//! let stream = acceptor.accept(stream).unwrap(); ++//! handle_client(stream); ++//! }); ++//! } ++//! Err(e) => { /* connection failed */ } ++//! } ++//! } ++//! ``` ++use ffi; ++use foreign_types::{ForeignType, ForeignTypeRef, Opaque}; ++use libc::{c_int, c_void, c_long, c_ulong}; ++use libc::{c_uchar, c_uint}; ++use std::any::Any; ++use std::any::TypeId; ++use std::borrow::Borrow; ++use std::cmp; ++use std::collections::HashMap; ++use std::ffi::{CStr, CString}; ++use std::fmt; ++use std::io; ++use std::io::prelude::*; ++use std::marker::PhantomData; ++use std::mem; ++use std::ops::{Deref, DerefMut}; ++use std::panic::resume_unwind; ++use std::path::Path; ++use std::ptr; ++use std::slice; ++use std::str; ++use std::sync::Mutex; ++ ++use {init, cvt, cvt_p, cvt_n}; ++use dh::{Dh, DhRef}; ++use ec::EcKeyRef; ++#[cfg(any(all(feature = "v101", ossl101), all(feature = "v102", ossl102)))] ++use ec::EcKey; ++use x509::{X509StoreContextRef, X509FileType, X509, X509Ref, X509VerifyError, X509Name}; ++use x509::store::{X509StoreBuilderRef, X509StoreRef}; ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++use x509::store::X509Store; ++#[cfg(any(ossl102, ossl110))] ++use verify::X509VerifyParamRef; ++use pkey::PKeyRef; ++use error::ErrorStack; ++use ex_data::Index; ++use stack::{Stack, StackRef}; ++use ssl::bio::BioMethod; ++use ssl::callbacks::*; ++ ++pub use ssl::connector::{SslConnectorBuilder, SslConnector, SslAcceptorBuilder, SslAcceptor, ++ ConnectConfiguration}; ++pub use ssl::error::{Error, HandshakeError}; ++ ++mod error; ++mod callbacks; ++mod connector; ++mod bio; ++#[cfg(test)] ++mod tests; ++ ++// FIXME drop SSL_ prefix ++// FIXME remvove flags not used in OpenSSL 1.1 ++bitflags! { ++ pub struct SslOption: c_ulong { ++ const SSL_OP_MICROSOFT_SESS_ID_BUG = ffi::SSL_OP_MICROSOFT_SESS_ID_BUG; ++ const SSL_OP_NETSCAPE_CHALLENGE_BUG = ffi::SSL_OP_NETSCAPE_CHALLENGE_BUG; ++ const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = ++ ffi::SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG; ++ const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER = ffi::SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER; ++ const SSL_OP_SSLEAY_080_CLIENT_DH_BUG = ffi::SSL_OP_SSLEAY_080_CLIENT_DH_BUG; ++ const SSL_OP_TLS_D5_BUG = ffi::SSL_OP_TLS_D5_BUG; ++ const SSL_OP_TLS_BLOCK_PADDING_BUG = ffi::SSL_OP_TLS_BLOCK_PADDING_BUG; ++ const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = ffi::SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS; ++ const SSL_OP_ALL = ffi::SSL_OP_ALL; ++ const SSL_OP_NO_QUERY_MTU = ffi::SSL_OP_NO_QUERY_MTU; ++ const SSL_OP_COOKIE_EXCHANGE = ffi::SSL_OP_COOKIE_EXCHANGE; ++ const SSL_OP_NO_TICKET = ffi::SSL_OP_NO_TICKET; ++ const SSL_OP_CISCO_ANYCONNECT = ffi::SSL_OP_CISCO_ANYCONNECT; ++ const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION = ++ ffi::SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION; ++ const SSL_OP_NO_COMPRESSION = ffi::SSL_OP_NO_COMPRESSION; ++ const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION = ++ ffi::SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION; ++ const SSL_OP_SINGLE_ECDH_USE = ffi::SSL_OP_SINGLE_ECDH_USE; ++ const SSL_OP_SINGLE_DH_USE = ffi::SSL_OP_SINGLE_DH_USE; ++ const SSL_OP_CIPHER_SERVER_PREFERENCE = ffi::SSL_OP_CIPHER_SERVER_PREFERENCE; ++ const SSL_OP_TLS_ROLLBACK_BUG = ffi::SSL_OP_TLS_ROLLBACK_BUG; ++ const SSL_OP_NO_SSLV2 = ffi::SSL_OP_NO_SSLv2; ++ const SSL_OP_NO_SSLV3 = ffi::SSL_OP_NO_SSLv3; ++ const SSL_OP_NO_TLSV1 = ffi::SSL_OP_NO_TLSv1; ++ const SSL_OP_NO_TLSV1_2 = ffi::SSL_OP_NO_TLSv1_2; ++ const SSL_OP_NO_TLSV1_1 = ffi::SSL_OP_NO_TLSv1_1; ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ const SSL_OP_NO_DTLSV1 = ffi::SSL_OP_NO_DTLSv1; ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ const SSL_OP_NO_DTLSV1_2 = ffi::SSL_OP_NO_DTLSv1_2; ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ const SSL_OP_NO_SSL_MASK = ffi::SSL_OP_NO_SSL_MASK; ++ } ++} ++ ++bitflags! { ++ pub struct SslMode: c_long { ++ const SSL_MODE_ENABLE_PARTIAL_WRITE = ffi::SSL_MODE_ENABLE_PARTIAL_WRITE; ++ const SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = ffi::SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER; ++ const SSL_MODE_AUTO_RETRY = ffi::SSL_MODE_AUTO_RETRY; ++ const SSL_MODE_NO_AUTO_CHAIN = ffi::SSL_MODE_NO_AUTO_CHAIN; ++ const SSL_MODE_RELEASE_BUFFERS = ffi::SSL_MODE_RELEASE_BUFFERS; ++ #[cfg(not(libressl))] ++ const SSL_MODE_SEND_CLIENTHELLO_TIME = ffi::SSL_MODE_SEND_CLIENTHELLO_TIME; ++ #[cfg(not(libressl))] ++ const SSL_MODE_SEND_SERVERHELLO_TIME = ffi::SSL_MODE_SEND_SERVERHELLO_TIME; ++ #[cfg(not(libressl))] ++ const SSL_MODE_SEND_FALLBACK_SCSV = ffi::SSL_MODE_SEND_FALLBACK_SCSV; ++ } ++} ++ ++#[derive(Copy, Clone)] ++pub struct SslMethod(*const ffi::SSL_METHOD); ++ ++impl SslMethod { ++ /// Support all versions of the TLS protocol. ++ /// ++ /// This corresponds to `TLS_method` on OpenSSL 1.1.0 and `SSLv23_method` ++ /// on OpenSSL 1.0.x. ++ pub fn tls() -> SslMethod { ++ SslMethod(compat::tls_method()) ++ } ++ ++ /// Support all versions of the DTLS protocol. ++ /// ++ /// This corresponds to `DTLS_method` on OpenSSL 1.1.0 and `DTLSv1_method` ++ /// on OpenSSL 1.0.x. ++ pub fn dtls() -> SslMethod { ++ SslMethod(compat::dtls_method()) ++ } ++ ++ pub unsafe fn from_ptr(ptr: *const ffi::SSL_METHOD) -> SslMethod { ++ SslMethod(ptr) ++ } ++ ++ pub fn as_ptr(&self) -> *const ffi::SSL_METHOD { ++ self.0 ++ } ++} ++ ++/// Determines the type of certificate verification used ++bitflags! { ++ pub struct SslVerifyMode: i32 { ++ /// Verify that the server's certificate is trusted ++ const SSL_VERIFY_PEER = ::ffi::SSL_VERIFY_PEER; ++ /// Do not verify the server's certificate ++ const SSL_VERIFY_NONE = ::ffi::SSL_VERIFY_NONE; ++ /// Terminate handshake if client did not return a certificate. ++ /// Use together with SSL_VERIFY_PEER. ++ const SSL_VERIFY_FAIL_IF_NO_PEER_CERT = ::ffi::SSL_VERIFY_FAIL_IF_NO_PEER_CERT; ++ } ++} ++ ++#[derive(Copy, Clone)] ++pub struct StatusType(c_int); ++ ++impl StatusType { ++ pub fn from_raw(raw: c_int) -> StatusType { ++ StatusType(raw) ++ } ++ ++ pub fn as_raw(&self) -> c_int { ++ self.0 ++ } ++} ++ ++/// An OSCP status. ++pub const STATUS_TYPE_OCSP: StatusType = StatusType(ffi::TLSEXT_STATUSTYPE_ocsp); ++ ++lazy_static! { ++ static ref INDEXES: Mutex> = Mutex::new(HashMap::new()); ++ static ref SSL_INDEXES: Mutex> = Mutex::new(HashMap::new()); ++} ++ ++// Creates a static index for user data of type T ++// Registers a destructor for the data which will be called ++// when context is freed ++fn get_callback_idx() -> c_int { ++ *INDEXES ++ .lock() ++ .unwrap() ++ .entry(TypeId::of::()) ++ .or_insert_with(|| get_new_idx::()) ++} ++ ++fn get_ssl_callback_idx() -> c_int { ++ *SSL_INDEXES ++ .lock() ++ .unwrap() ++ .entry(TypeId::of::()) ++ .or_insert_with(|| get_new_ssl_idx::()) ++} ++ ++lazy_static! { ++ static ref NPN_PROTOS_IDX: c_int = get_new_idx::>(); ++} ++ ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++lazy_static! { ++ static ref ALPN_PROTOS_IDX: c_int = get_new_idx::>(); ++} ++ ++unsafe extern "C" fn free_data_box( ++ _parent: *mut c_void, ++ ptr: *mut c_void, ++ _ad: *mut ffi::CRYPTO_EX_DATA, ++ _idx: c_int, ++ _argl: c_long, ++ _argp: *mut c_void, ++) { ++ if !ptr.is_null() { ++ Box::::from_raw(ptr as *mut T); ++ } ++} ++ ++/// Determine a new index to use for SSL CTX ex data. ++/// Registers a destruct for the data which will be called by openssl when the context is freed. ++fn get_new_idx() -> c_int { ++ unsafe { ++ let idx = compat::get_new_idx(free_data_box::); ++ assert!(idx >= 0); ++ idx ++ } ++} ++ ++fn get_new_ssl_idx() -> c_int { ++ unsafe { ++ let idx = compat::get_new_ssl_idx(free_data_box::); ++ assert!(idx >= 0); ++ idx ++ } ++} ++ ++/// Convert a set of byte slices into a series of byte strings encoded for SSL. Encoding is a byte ++/// containing the length followed by the string. ++fn ssl_encode_byte_strings(strings: &[&[u8]]) -> Vec { ++ let mut enc = Vec::new(); ++ for string in strings { ++ let len = string.len() as u8; ++ if len as usize != string.len() { ++ // If the item does not fit, discard it ++ continue; ++ } ++ enc.push(len); ++ enc.extend(string[..len as usize].to_vec()); ++ } ++ enc ++} ++ ++/// An error returned from an SNI callback. ++pub enum SniError { ++ Fatal(c_int), ++ Warning(c_int), ++ NoAck, ++} ++ ++/// A builder for `SslContext`s. ++pub struct SslContextBuilder(*mut ffi::SSL_CTX); ++ ++unsafe impl Sync for SslContextBuilder {} ++unsafe impl Send for SslContextBuilder {} ++ ++impl Drop for SslContextBuilder { ++ fn drop(&mut self) { ++ unsafe { ffi::SSL_CTX_free(self.as_ptr()) } ++ } ++} ++ ++impl SslContextBuilder { ++ pub fn new(method: SslMethod) -> Result { ++ unsafe { ++ init(); ++ let ctx = try!(cvt_p(ffi::SSL_CTX_new(method.as_ptr()))); ++ ++ Ok(SslContextBuilder::from_ptr(ctx)) ++ } ++ } ++ ++ pub unsafe fn from_ptr(ctx: *mut ffi::SSL_CTX) -> SslContextBuilder { ++ SslContextBuilder(ctx) ++ } ++ ++ pub fn as_ptr(&self) -> *mut ffi::SSL_CTX { ++ self.0 ++ } ++ ++ /// Configures the certificate verification method for new connections. ++ pub fn set_verify(&mut self, mode: SslVerifyMode) { ++ unsafe { ++ ffi::SSL_CTX_set_verify(self.as_ptr(), mode.bits as c_int, None); ++ } ++ } ++ ++ /// Configures the certificate verification method for new connections and ++ /// registers a verification callback. ++ pub fn set_verify_callback(&mut self, mode: SslVerifyMode, verify: F) ++ where ++ F: Fn(bool, &X509StoreContextRef) -> bool + Any + 'static + Sync + Send, ++ { ++ unsafe { ++ let verify = Box::new(verify); ++ ffi::SSL_CTX_set_ex_data( ++ self.as_ptr(), ++ get_callback_idx::(), ++ mem::transmute(verify), ++ ); ++ ffi::SSL_CTX_set_verify(self.as_ptr(), mode.bits as c_int, Some(raw_verify::)); ++ } ++ } ++ ++ /// Configures the server name indication (SNI) callback for new connections ++ /// ++ /// Obtain the server name with `servername` then set the corresponding context ++ /// with `set_ssl_context` ++ pub fn set_servername_callback(&mut self, callback: F) ++ where ++ F: Fn(&mut SslRef) -> Result<(), SniError> + Any + 'static + Sync + Send, ++ { ++ unsafe { ++ let callback = Box::new(callback); ++ ffi::SSL_CTX_set_ex_data( ++ self.as_ptr(), ++ get_callback_idx::(), ++ mem::transmute(callback), ++ ); ++ let f: extern "C" fn(_, _, _) -> _ = raw_sni::; ++ let f: extern "C" fn() = mem::transmute(f); ++ ffi::SSL_CTX_set_tlsext_servername_callback(self.as_ptr(), Some(f)); ++ } ++ } ++ ++ /// Sets verification depth ++ pub fn set_verify_depth(&mut self, depth: u32) { ++ unsafe { ++ ffi::SSL_CTX_set_verify_depth(self.as_ptr(), depth as c_int); ++ } ++ } ++ ++ /// Sets a custom X509Store for verifying peer certificates. ++ /// ++ /// Requires the `v102` feature and OpenSSL 1.0.2, or the `v110` feature and OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ pub fn set_verify_cert_store(&mut self, cert_store: X509Store) -> Result<(), ErrorStack> { ++ unsafe { ++ let ptr = cert_store.as_ptr(); ++ try!(cvt( ++ ffi::SSL_CTX_set0_verify_cert_store(self.as_ptr(), ptr) as ++ c_int, ++ )); ++ mem::forget(cert_store); ++ ++ Ok(()) ++ } ++ } ++ ++ pub fn set_read_ahead(&mut self, read_ahead: bool) { ++ unsafe { ++ ffi::SSL_CTX_set_read_ahead(self.as_ptr(), read_ahead as c_long); ++ } ++ } ++ ++ pub fn set_mode(&mut self, mode: SslMode) -> SslMode { ++ unsafe { ++ let mode = ffi::SSL_CTX_set_mode(self.as_ptr(), mode.bits()); ++ SslMode::from_bits(mode).unwrap() ++ } ++ } ++ ++ pub fn set_tmp_dh(&mut self, dh: &DhRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::SSL_CTX_set_tmp_dh(self.as_ptr(), dh.as_ptr()) as c_int).map(|_| ()) } ++ } ++ ++ pub fn set_tmp_dh_callback(&mut self, callback: F) ++ where ++ F: Fn(&mut SslRef, bool, u32) -> Result + Any + 'static + Sync + Send, ++ { ++ unsafe { ++ let callback = Box::new(callback); ++ ffi::SSL_CTX_set_ex_data( ++ self.as_ptr(), ++ get_callback_idx::(), ++ Box::into_raw(callback) as *mut c_void, ++ ); ++ let f: unsafe extern "C" fn(_, _, _) -> _ = raw_tmp_dh::; ++ ffi::SSL_CTX_set_tmp_dh_callback(self.as_ptr(), f); ++ } ++ } ++ ++ pub fn set_tmp_ecdh(&mut self, key: &EcKeyRef) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::SSL_CTX_set_tmp_ecdh(self.as_ptr(), key.as_ptr()) as ++ c_int).map(|_| ()) ++ } ++ } ++ ++ /// Requires the `v101` feature and OpenSSL 1.0.1, or the `v102` feature and OpenSSL 1.0.2. ++ #[cfg(any(all(feature = "v101", ossl101), all(feature = "v102", ossl102)))] ++ pub fn set_tmp_ecdh_callback(&mut self, callback: F) ++ where ++ F: Fn(&mut SslRef, bool, u32) -> Result + Any + 'static + Sync + Send, ++ { ++ unsafe { ++ let callback = Box::new(callback); ++ ffi::SSL_CTX_set_ex_data( ++ self.as_ptr(), ++ get_callback_idx::(), ++ Box::into_raw(callback) as *mut c_void, ++ ); ++ let f: unsafe extern "C" fn(_, _, _) -> _ = raw_tmp_ecdh::; ++ ffi::SSL_CTX_set_tmp_ecdh_callback(self.as_ptr(), f); ++ } ++ } ++ ++ /// Use the default locations of trusted certificates for verification. ++ /// ++ /// These locations are read from the `SSL_CERT_FILE` and `SSL_CERT_DIR` ++ /// environment variables if present, or defaults specified at OpenSSL ++ /// build time otherwise. ++ pub fn set_default_verify_paths(&mut self) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::SSL_CTX_set_default_verify_paths(self.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Specifies the file that contains trusted CA certificates. ++ pub fn set_ca_file>(&mut self, file: P) -> Result<(), ErrorStack> { ++ let file = CString::new(file.as_ref().as_os_str().to_str().unwrap()).unwrap(); ++ unsafe { ++ cvt(ffi::SSL_CTX_load_verify_locations( ++ self.as_ptr(), ++ file.as_ptr() as *const _, ++ ptr::null(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Sets the list of CAs sent to the client. ++ /// ++ /// The CA certificates must still be added to the trust root. ++ pub fn set_client_ca_list(&mut self, list: Stack) { ++ unsafe { ++ ffi::SSL_CTX_set_client_CA_list(self.as_ptr(), list.as_ptr()); ++ mem::forget(list); ++ } ++ } ++ ++ /// Set the context identifier for sessions ++ /// ++ /// This value identifies the server's session cache to clients, telling them when they're ++ /// able to reuse sessions. Should be set to a unique value per server, unless multiple servers ++ /// share a session cache. ++ /// ++ /// This value should be set when using client certificates, or each request will fail ++ /// handshake and need to be restarted. ++ pub fn set_session_id_context(&mut self, sid_ctx: &[u8]) -> Result<(), ErrorStack> { ++ unsafe { ++ assert!(sid_ctx.len() <= c_uint::max_value() as usize); ++ cvt(ffi::SSL_CTX_set_session_id_context( ++ self.as_ptr(), ++ sid_ctx.as_ptr(), ++ sid_ctx.len() as c_uint, ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Loads a certificate from a file. ++ pub fn set_certificate_file>( ++ &mut self, ++ file: P, ++ file_type: X509FileType, ++ ) -> Result<(), ErrorStack> { ++ let file = CString::new(file.as_ref().as_os_str().to_str().unwrap()).unwrap(); ++ unsafe { ++ cvt(ffi::SSL_CTX_use_certificate_file( ++ self.as_ptr(), ++ file.as_ptr() as *const _, ++ file_type.as_raw(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Loads a certificate chain from a file. ++ /// ++ /// The file should contain a sequence of PEM-formatted certificates, the first being the leaf ++ /// certificate, and the remainder forming the chain of certificates up to and including the ++ /// trusted root certificate. ++ pub fn set_certificate_chain_file>( ++ &mut self, ++ file: P, ++ ) -> Result<(), ErrorStack> { ++ let file = CString::new(file.as_ref().as_os_str().to_str().unwrap()).unwrap(); ++ unsafe { ++ cvt(ffi::SSL_CTX_use_certificate_chain_file( ++ self.as_ptr(), ++ file.as_ptr() as *const _, ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Sets the certificate. ++ pub fn set_certificate(&mut self, cert: &X509Ref) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::SSL_CTX_use_certificate(self.as_ptr(), cert.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Appends a certificate to the certificate chain. ++ /// ++ /// This chain should contain all certificates necessary to go from the certificate specified by ++ /// `set_certificate` to a trusted root. ++ pub fn add_extra_chain_cert(&mut self, cert: X509) -> Result<(), ErrorStack> { ++ unsafe { ++ try!(cvt(ffi::SSL_CTX_add_extra_chain_cert( ++ self.as_ptr(), ++ cert.as_ptr(), ++ ) as c_int)); ++ mem::forget(cert); ++ Ok(()) ++ } ++ } ++ ++ /// Loads the private key from a file. ++ pub fn set_private_key_file>( ++ &mut self, ++ file: P, ++ file_type: X509FileType, ++ ) -> Result<(), ErrorStack> { ++ let file = CString::new(file.as_ref().as_os_str().to_str().unwrap()).unwrap(); ++ unsafe { ++ cvt(ffi::SSL_CTX_use_PrivateKey_file( ++ self.as_ptr(), ++ file.as_ptr() as *const _, ++ file_type.as_raw(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Sets the private key. ++ pub fn set_private_key(&mut self, key: &PKeyRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::SSL_CTX_use_PrivateKey(self.as_ptr(), key.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Sets the cipher configuration. ++ /// ++ /// See `man 1 ciphers` for details on the format. ++ pub fn set_cipher_list(&mut self, cipher_list: &str) -> Result<(), ErrorStack> { ++ let cipher_list = CString::new(cipher_list).unwrap(); ++ unsafe { ++ cvt(ffi::SSL_CTX_set_cipher_list( ++ self.as_ptr(), ++ cipher_list.as_ptr() as *const _, ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Enables ECDHE key exchange with an automatically chosen curve list. ++ /// ++ /// Requires the `v102` feature and OpenSSL 1.0.2. ++ #[cfg(all(feature = "v102", any(ossl102, libressl)))] ++ pub fn set_ecdh_auto(&mut self, onoff: bool) -> Result<(), ErrorStack> { ++ self._set_ecdh_auto(onoff) ++ } ++ ++ #[cfg(any(ossl102, libressl))] ++ fn _set_ecdh_auto(&mut self, onoff: bool) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::SSL_CTX_set_ecdh_auto(self.as_ptr(), onoff as c_int)).map(|_| ()) } ++ } ++ ++ pub fn set_options(&mut self, option: SslOption) -> SslOption { ++ let ret = unsafe { compat::SSL_CTX_set_options(self.as_ptr(), option.bits()) }; ++ SslOption::from_bits(ret).unwrap() ++ } ++ ++ pub fn options(&self) -> SslOption { ++ let ret = unsafe { compat::SSL_CTX_get_options(self.as_ptr()) }; ++ SslOption::from_bits(ret).unwrap() ++ } ++ ++ pub fn clear_options(&mut self, option: SslOption) -> SslOption { ++ let ret = unsafe { compat::SSL_CTX_clear_options(self.as_ptr(), option.bits()) }; ++ SslOption::from_bits(ret).unwrap() ++ } ++ ++ /// Set the protocols to be used during Next Protocol Negotiation (the protocols ++ /// supported by the application). ++ #[cfg(not(libressl261))] ++ pub fn set_npn_protocols(&mut self, protocols: &[&[u8]]) -> Result<(), ErrorStack> { ++ // Firstly, convert the list of protocols to a byte-array that can be passed to OpenSSL ++ // APIs -- a list of length-prefixed strings. ++ let protocols: Box> = Box::new(ssl_encode_byte_strings(protocols)); ++ ++ unsafe { ++ // Attach the protocol list to the OpenSSL context structure, ++ // so that we can refer to it within the callback. ++ try!(cvt(ffi::SSL_CTX_set_ex_data( ++ self.as_ptr(), ++ *NPN_PROTOS_IDX, ++ Box::into_raw(protocols) as *mut c_void, ++ ))); ++ // Now register the callback that performs the default protocol ++ // matching based on the client-supported list of protocols that ++ // has been saved. ++ ffi::SSL_CTX_set_next_proto_select_cb( ++ self.as_ptr(), ++ raw_next_proto_select_cb, ++ ptr::null_mut(), ++ ); ++ // Also register the callback to advertise these protocols, if a server socket is ++ // created with the context. ++ ffi::SSL_CTX_set_next_protos_advertised_cb( ++ self.as_ptr(), ++ raw_next_protos_advertise_cb, ++ ptr::null_mut(), ++ ); ++ Ok(()) ++ } ++ } ++ ++ /// Set the protocols to be used during ALPN (application layer protocol negotiation). ++ /// If this is a server, these are the protocols we report to the client. ++ /// If this is a client, these are the protocols we try to match with those reported by the ++ /// server. ++ /// ++ /// Note that ordering of the protocols controls the priority with which they are chosen. ++ /// ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ pub fn set_alpn_protocols(&mut self, protocols: &[&[u8]]) -> Result<(), ErrorStack> { ++ let protocols: Box> = Box::new(ssl_encode_byte_strings(protocols)); ++ unsafe { ++ // Set the context's internal protocol list for use if we are a server ++ let r = ffi::SSL_CTX_set_alpn_protos( ++ self.as_ptr(), ++ protocols.as_ptr(), ++ protocols.len() as c_uint, ++ ); ++ // fun fact, SSL_CTX_set_alpn_protos has a reversed return code D: ++ if r != 0 { ++ return Err(ErrorStack::get()); ++ } ++ ++ // Rather than use the argument to the callback to contain our data, store it in the ++ // ssl ctx's ex_data so that we can configure a function to free it later. In the ++ // future, it might make sense to pull this into our internal struct Ssl instead of ++ // leaning on openssl and using function pointers. ++ try!(cvt(ffi::SSL_CTX_set_ex_data( ++ self.as_ptr(), ++ *ALPN_PROTOS_IDX, ++ Box::into_raw(protocols) as *mut c_void, ++ ))); ++ ++ // Now register the callback that performs the default protocol ++ // matching based on the client-supported list of protocols that ++ // has been saved. ++ ffi::SSL_CTX_set_alpn_select_cb(self.as_ptr(), raw_alpn_select_cb, ptr::null_mut()); ++ ++ Ok(()) ++ } ++ } ++ ++ /// Checks consistency between the private key and certificate. ++ pub fn check_private_key(&self) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::SSL_CTX_check_private_key(self.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Returns a shared reference to the context's certificate store. ++ pub fn cert_store(&self) -> &X509StoreBuilderRef { ++ unsafe { X509StoreBuilderRef::from_ptr(ffi::SSL_CTX_get_cert_store(self.as_ptr())) } ++ } ++ ++ /// Returns a mutable reference to the context's certificate store. ++ pub fn cert_store_mut(&mut self) -> &mut X509StoreBuilderRef { ++ unsafe { X509StoreBuilderRef::from_ptr_mut(ffi::SSL_CTX_get_cert_store(self.as_ptr())) } ++ } ++ ++ /// Sets the callback dealing with OCSP stapling. ++ /// ++ /// On the client side, this callback is responsible for validating the OCSP status response ++ /// returned by the server. The status may be retrieved with the `SslRef::ocsp_status` method. ++ /// A response of `Ok(true)` indicates that the OCSP status is valid, and a response of ++ /// `Ok(false)` indicates that the OCSP status is invalid and the handshake should be ++ /// terminated. ++ /// ++ /// On the server side, this callback is resopnsible for setting the OCSP status response to be ++ /// returned to clients. The status may be set with the `SslRef::set_ocsp_status` method. A ++ /// response of `Ok(true)` indicates that the OCSP status should be returned to the client, and ++ /// `Ok(false)` indicates that the status should not be returned to the client. ++ pub fn set_status_callback(&mut self, callback: F) -> Result<(), ErrorStack> ++ where ++ F: Fn(&mut SslRef) -> Result + Any + 'static + Sync + Send, ++ { ++ unsafe { ++ let callback = Box::new(callback); ++ ffi::SSL_CTX_set_ex_data( ++ self.as_ptr(), ++ get_callback_idx::(), ++ Box::into_raw(callback) as *mut c_void, ++ ); ++ let f: unsafe extern "C" fn(_, _) -> _ = raw_tlsext_status::; ++ cvt(ffi::SSL_CTX_set_tlsext_status_cb( ++ self.as_ptr(), ++ Some(f), ++ ) as c_int).map(|_| ()) ++ } ++ } ++ ++ /// Sets the callback for providing an identity and pre-shared key for a TLS-PSK client. ++ /// ++ /// The callback will be called with the SSL context, an identity hint if one was provided ++ /// by the server, a mut slice for each of the identity and pre-shared key bytes. The identity ++ /// must be written as a null-terminated C string. ++ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))] ++ pub fn set_psk_callback(&mut self, callback: F) ++ where ++ F: Fn(&mut SslRef, Option<&[u8]>, &mut [u8], &mut [u8]) -> Result ++ + Any ++ + 'static ++ + Sync ++ + Send, ++ { ++ unsafe { ++ let callback = Box::new(callback); ++ ffi::SSL_CTX_set_ex_data( ++ self.as_ptr(), ++ get_callback_idx::(), ++ mem::transmute(callback), ++ ); ++ ffi::SSL_CTX_set_psk_client_callback(self.as_ptr(), Some(raw_psk::)) ++ } ++ } ++ ++ /// Sets the extra data at the specified index. ++ pub fn set_ex_data(&mut self, index: Index, data: T) { ++ unsafe { ++ let data = Box::new(data); ++ ffi::SSL_CTX_set_ex_data( ++ self.as_ptr(), ++ index.as_raw(), ++ Box::into_raw(data) as *mut c_void, ++ ); ++ } ++ } ++ ++ pub fn build(self) -> SslContext { ++ let ctx = SslContext(self.0); ++ mem::forget(self); ++ ctx ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::SSL_CTX; ++ fn drop = ffi::SSL_CTX_free; ++ ++ pub struct SslContext; ++ pub struct SslContextRef; ++} ++ ++unsafe impl Send for SslContext {} ++unsafe impl Sync for SslContext {} ++ ++impl Clone for SslContext { ++ fn clone(&self) -> Self { ++ unsafe { ++ compat::SSL_CTX_up_ref(self.as_ptr()); ++ SslContext::from_ptr(self.as_ptr()) ++ } ++ } ++} ++ ++// TODO: add useful info here ++impl fmt::Debug for SslContext { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ write!(fmt, "SslContext") ++ } ++} ++ ++impl SslContext { ++ pub fn builder(method: SslMethod) -> Result { ++ SslContextBuilder::new(method) ++ } ++ ++ /// Returns a new extra data index. ++ /// ++ /// Each invocation of this function is guaranteed to return a distinct ++ /// index. ++ pub fn new_ex_index() -> Result, ErrorStack> ++ where ++ T: 'static + Sync + Send, ++ { ++ unsafe { ++ ffi::init(); ++ let idx = try!(cvt_n(compat::get_new_idx(free_data_box::))); ++ Ok(Index::from_raw(idx)) ++ } ++ } ++} ++ ++impl SslContextRef { ++ /// Returns the certificate associated with this `SslContext`, if present. ++ /// ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ pub fn certificate(&self) -> Option<&X509Ref> { ++ unsafe { ++ let ptr = ffi::SSL_CTX_get0_certificate(self.as_ptr()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(X509Ref::from_ptr(ptr)) ++ } ++ } ++ } ++ ++ /// Returns the private key associated with this `SslContext`, if present. ++ /// ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ pub fn private_key(&self) -> Option<&PKeyRef> { ++ unsafe { ++ let ptr = ffi::SSL_CTX_get0_privatekey(self.as_ptr()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(PKeyRef::from_ptr(ptr)) ++ } ++ } ++ } ++ ++ /// Returns the certificate store used for verification. ++ pub fn cert_store(&self) -> &X509StoreRef { ++ unsafe { X509StoreRef::from_ptr(ffi::SSL_CTX_get_cert_store(self.as_ptr())) } ++ } ++ ++ pub fn extra_chain_certs(&self) -> &StackRef { ++ unsafe { ++ let mut chain = ptr::null_mut(); ++ ffi::SSL_CTX_get_extra_chain_certs(self.as_ptr(), &mut chain); ++ assert!(!chain.is_null()); ++ StackRef::from_ptr(chain) ++ } ++ } ++ ++ /// Returns a reference to the extra data at the specified index. ++ pub fn ex_data(&self, index: Index) -> Option<&T> { ++ unsafe { ++ let data = ffi::SSL_CTX_get_ex_data(self.as_ptr(), index.as_raw()); ++ if data.is_null() { ++ None ++ } else { ++ Some(&*(data as *const T)) ++ } ++ } ++ } ++} ++ ++pub struct CipherBits { ++ /// The number of secret bits used for the cipher. ++ pub secret: i32, ++ ++ /// The number of bits processed by the chosen algorithm. ++ pub algorithm: i32, ++} ++ ++pub struct SslCipher(*mut ffi::SSL_CIPHER); ++ ++impl ForeignType for SslCipher { ++ type CType = ffi::SSL_CIPHER; ++ type Ref = SslCipherRef; ++ ++ #[inline] ++ unsafe fn from_ptr(ptr: *mut ffi::SSL_CIPHER) -> SslCipher { ++ SslCipher(ptr) ++ } ++ ++ #[inline] ++ fn as_ptr(&self) -> *mut ffi::SSL_CIPHER { ++ self.0 ++ } ++} ++ ++impl Deref for SslCipher { ++ type Target = SslCipherRef; ++ ++ fn deref(&self) -> &SslCipherRef { ++ unsafe { SslCipherRef::from_ptr(self.0) } ++ } ++} ++ ++impl DerefMut for SslCipher { ++ fn deref_mut(&mut self) -> &mut SslCipherRef { ++ unsafe { SslCipherRef::from_ptr_mut(self.0) } ++ } ++} ++ ++pub struct SslCipherRef(Opaque); ++ ++impl ForeignTypeRef for SslCipherRef { ++ type CType = ffi::SSL_CIPHER; ++} ++ ++impl SslCipherRef { ++ /// Returns the name of cipher. ++ pub fn name(&self) -> &str { ++ let name = unsafe { ++ let ptr = ffi::SSL_CIPHER_get_name(self.as_ptr()); ++ CStr::from_ptr(ptr as *const _) ++ }; ++ ++ str::from_utf8(name.to_bytes()).unwrap() ++ } ++ ++ /// Returns the SSL/TLS protocol version that first defined the cipher. ++ pub fn version(&self) -> &str { ++ let version = unsafe { ++ let ptr = ffi::SSL_CIPHER_get_version(self.as_ptr()); ++ CStr::from_ptr(ptr as *const _) ++ }; ++ ++ str::from_utf8(version.to_bytes()).unwrap() ++ } ++ ++ /// Returns the number of bits used for the cipher. ++ pub fn bits(&self) -> CipherBits { ++ unsafe { ++ let mut algo_bits = 0; ++ let secret_bits = ffi::SSL_CIPHER_get_bits(self.as_ptr(), &mut algo_bits); ++ CipherBits { ++ secret: secret_bits.into(), ++ algorithm: algo_bits.into(), ++ } ++ } ++ } ++ ++ /// Returns a textual description of the cipher used ++ pub fn description(&self) -> String { ++ unsafe { ++ // SSL_CIPHER_description requires a buffer of at least 128 bytes. ++ let mut buf = [0; 128]; ++ let ptr = ffi::SSL_CIPHER_description(self.as_ptr(), buf.as_mut_ptr(), 128); ++ String::from_utf8(CStr::from_ptr(ptr as *const _).to_bytes().to_vec()).unwrap() ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::SSL_SESSION; ++ fn drop = ffi::SSL_SESSION_free; ++ ++ pub struct SslSession; ++ pub struct SslSessionRef; ++} ++ ++unsafe impl Sync for SslSession {} ++unsafe impl Send for SslSession {} ++ ++impl Clone for SslSession { ++ fn clone(&self) -> SslSession { ++ self.to_owned() ++ } ++} ++ ++impl Borrow for SslSession { ++ fn borrow(&self) -> &SslSessionRef { ++ &self ++ } ++} ++ ++impl ToOwned for SslSessionRef { ++ type Owned = SslSession; ++ ++ fn to_owned(&self) -> SslSession { ++ unsafe { ++ compat::SSL_SESSION_up_ref(self.as_ptr()); ++ SslSession(self.as_ptr()) ++ } ++ } ++} ++ ++impl SslSessionRef { ++ /// Returns the SSL session ID. ++ pub fn id(&self) -> &[u8] { ++ unsafe { ++ let mut len = 0; ++ let p = ffi::SSL_SESSION_get_id(self.as_ptr(), &mut len); ++ slice::from_raw_parts(p as *const u8, len as usize) ++ } ++ } ++ ++ /// Returns the length of the master key. ++ pub fn master_key_len(&self) -> usize { ++ unsafe { compat::SSL_SESSION_get_master_key(self.as_ptr(), ptr::null_mut(), 0) } ++ } ++ ++ /// Copies the master key into the provided buffer. ++ /// ++ /// Returns the number of bytes written. ++ pub fn master_key(&self, buf: &mut [u8]) -> usize { ++ unsafe { compat::SSL_SESSION_get_master_key(self.as_ptr(), buf.as_mut_ptr(), buf.len()) } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::SSL; ++ fn drop = ffi::SSL_free; ++ ++ pub struct Ssl; ++ pub struct SslRef; ++} ++ ++impl Ssl { ++ /// Returns a new extra data index. ++ /// ++ /// Each invocation of this function is guaranteed to return a distinct ++ /// index. ++ pub fn new_ex_index() -> Result, ErrorStack> ++ where ++ T: 'static + Sync + Send, ++ { ++ unsafe { ++ ffi::init(); ++ let idx = try!(cvt_n(compat::get_new_ssl_idx(free_data_box::))); ++ Ok(Index::from_raw(idx)) ++ } ++ } ++} ++ ++impl fmt::Debug for SslRef { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ let mut builder = fmt.debug_struct("Ssl"); ++ builder.field("state", &self.state_string_long()); ++ if let Some(err) = self.verify_result() { ++ builder.field("verify_result", &err); ++ } ++ builder.finish() ++ } ++} ++ ++impl SslRef { ++ fn get_raw_rbio(&self) -> *mut ffi::BIO { ++ unsafe { ffi::SSL_get_rbio(self.as_ptr()) } ++ } ++ ++ fn read(&mut self, buf: &mut [u8]) -> c_int { ++ let len = cmp::min(c_int::max_value() as usize, buf.len()) as c_int; ++ unsafe { ffi::SSL_read(self.as_ptr(), buf.as_ptr() as *mut c_void, len) } ++ } ++ ++ fn write(&mut self, buf: &[u8]) -> c_int { ++ let len = cmp::min(c_int::max_value() as usize, buf.len()) as c_int; ++ unsafe { ffi::SSL_write(self.as_ptr(), buf.as_ptr() as *const c_void, len) } ++ } ++ ++ fn get_error(&self, ret: c_int) -> c_int { ++ unsafe { ffi::SSL_get_error(self.as_ptr(), ret) } ++ } ++ ++ /// Sets the verification mode to be used during the handshake process. ++ /// ++ /// Use `set_verify_callback` to additionally add a callback. ++ pub fn set_verify(&mut self, mode: SslVerifyMode) { ++ unsafe { ffi::SSL_set_verify(self.as_ptr(), mode.bits as c_int, None) } ++ } ++ ++ /// Sets the certificate verification callback to be used during the ++ /// handshake process. ++ /// ++ /// The callback is provided with a boolean indicating if the ++ /// preveification process was successful, and an object providing access ++ /// to the certificate chain. It should return `true` if the certificate ++ /// chain is valid and `false` otherwise. ++ pub fn set_verify_callback(&mut self, mode: SslVerifyMode, verify: F) ++ where ++ F: Fn(bool, &X509StoreContextRef) -> bool + Any + 'static + Sync + Send, ++ { ++ unsafe { ++ let verify = Box::new(verify); ++ ffi::SSL_set_ex_data( ++ self.as_ptr(), ++ get_ssl_callback_idx::(), ++ mem::transmute(verify), ++ ); ++ ffi::SSL_set_verify(self.as_ptr(), mode.bits as c_int, Some(ssl_raw_verify::)); ++ } ++ } ++ ++ pub fn set_tmp_dh(&mut self, dh: &DhRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::SSL_set_tmp_dh(self.as_ptr(), dh.as_ptr()) as c_int).map(|_| ()) } ++ } ++ ++ pub fn set_tmp_dh_callback(&mut self, callback: F) ++ where ++ F: Fn(&mut SslRef, bool, u32) -> Result + Any + 'static + Sync + Send, ++ { ++ unsafe { ++ let callback = Box::new(callback); ++ ffi::SSL_set_ex_data( ++ self.as_ptr(), ++ get_ssl_callback_idx::(), ++ Box::into_raw(callback) as *mut c_void, ++ ); ++ let f: unsafe extern "C" fn(_, _, _) -> _ = raw_tmp_dh_ssl::; ++ ffi::SSL_set_tmp_dh_callback(self.as_ptr(), f); ++ } ++ } ++ ++ pub fn set_tmp_ecdh(&mut self, key: &EcKeyRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::SSL_set_tmp_ecdh(self.as_ptr(), key.as_ptr()) as c_int).map(|_| ()) } ++ } ++ ++ /// Requires the `v101` feature and OpenSSL 1.0.1, or the `v102` feature and OpenSSL 1.0.2. ++ #[cfg(any(all(feature = "v101", ossl101), all(feature = "v102", ossl102)))] ++ pub fn set_tmp_ecdh_callback(&mut self, callback: F) ++ where ++ F: Fn(&mut SslRef, bool, u32) -> Result + Any + 'static + Sync + Send, ++ { ++ unsafe { ++ let callback = Box::new(callback); ++ ffi::SSL_set_ex_data( ++ self.as_ptr(), ++ get_ssl_callback_idx::(), ++ Box::into_raw(callback) as *mut c_void, ++ ); ++ let f: unsafe extern "C" fn(_, _, _) -> _ = raw_tmp_ecdh_ssl::; ++ ffi::SSL_set_tmp_ecdh_callback(self.as_ptr(), f); ++ } ++ } ++ ++ /// If `onoff` is set to `true`, enable ECDHE for key exchange with ++ /// compatible clients, and automatically select an appropriate elliptic ++ /// curve. ++ /// ++ /// Requires the `v102` feature and OpenSSL 1.0.2. ++ #[cfg(all(feature = "v102", ossl102))] ++ pub fn set_ecdh_auto(&mut self, onoff: bool) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::SSL_set_ecdh_auto(self.as_ptr(), onoff as c_int)).map(|_| ()) } ++ } ++ ++ pub fn current_cipher(&self) -> Option<&SslCipherRef> { ++ unsafe { ++ let ptr = ffi::SSL_get_current_cipher(self.as_ptr()); ++ ++ if ptr.is_null() { ++ None ++ } else { ++ Some(SslCipherRef::from_ptr(ptr as *mut _)) ++ } ++ } ++ } ++ ++ pub fn state_string(&self) -> &'static str { ++ let state = unsafe { ++ let ptr = ffi::SSL_state_string(self.as_ptr()); ++ CStr::from_ptr(ptr as *const _) ++ }; ++ ++ str::from_utf8(state.to_bytes()).unwrap() ++ } ++ ++ pub fn state_string_long(&self) -> &'static str { ++ let state = unsafe { ++ let ptr = ffi::SSL_state_string_long(self.as_ptr()); ++ CStr::from_ptr(ptr as *const _) ++ }; ++ ++ str::from_utf8(state.to_bytes()).unwrap() ++ } ++ ++ /// Sets the host name to be used with SNI (Server Name Indication). ++ pub fn set_hostname(&mut self, hostname: &str) -> Result<(), ErrorStack> { ++ let cstr = CString::new(hostname).unwrap(); ++ unsafe { ++ cvt(ffi::SSL_set_tlsext_host_name( ++ self.as_ptr(), ++ cstr.as_ptr() as *mut _, ++ ) as c_int).map(|_| ()) ++ } ++ } ++ ++ /// Returns the certificate of the peer, if present. ++ pub fn peer_certificate(&self) -> Option { ++ unsafe { ++ let ptr = ffi::SSL_get_peer_certificate(self.as_ptr()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(X509::from_ptr(ptr)) ++ } ++ } ++ } ++ ++ /// Returns the certificate chain of the peer, if present. ++ /// ++ /// On the client side, the chain includes the leaf certificate, but on the server side it does ++ /// not. Fun! ++ pub fn peer_cert_chain(&self) -> Option<&StackRef> { ++ unsafe { ++ let ptr = ffi::SSL_get_peer_cert_chain(self.as_ptr()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(StackRef::from_ptr(ptr)) ++ } ++ } ++ } ++ ++ /// Returns the certificate associated with this `Ssl`, if present. ++ pub fn certificate(&self) -> Option<&X509Ref> { ++ unsafe { ++ let ptr = ffi::SSL_get_certificate(self.as_ptr()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(X509Ref::from_ptr(ptr)) ++ } ++ } ++ } ++ ++ /// Returns the private key associated with this `Ssl`, if present. ++ pub fn private_key(&self) -> Option<&PKeyRef> { ++ unsafe { ++ let ptr = ffi::SSL_get_privatekey(self.as_ptr()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(PKeyRef::from_ptr(ptr)) ++ } ++ } ++ } ++ ++ /// Returns the name of the protocol used for the connection, e.g. "TLSv1.2", "SSLv3", etc. ++ pub fn version(&self) -> &'static str { ++ let version = unsafe { ++ let ptr = ffi::SSL_get_version(self.as_ptr()); ++ CStr::from_ptr(ptr as *const _) ++ }; ++ ++ str::from_utf8(version.to_bytes()).unwrap() ++ } ++ ++ /// Returns the protocol selected by performing Next Protocol Negotiation, if any. ++ /// ++ /// The protocol's name is returned is an opaque sequence of bytes. It is up to the client ++ /// to interpret it. ++ #[cfg(not(libressl261))] ++ pub fn selected_npn_protocol(&self) -> Option<&[u8]> { ++ unsafe { ++ let mut data: *const c_uchar = ptr::null(); ++ let mut len: c_uint = 0; ++ // Get the negotiated protocol from the SSL instance. ++ // `data` will point at a `c_uchar` array; `len` will contain the length of this array. ++ ffi::SSL_get0_next_proto_negotiated(self.as_ptr(), &mut data, &mut len); ++ ++ if data.is_null() { ++ None ++ } else { ++ Some(slice::from_raw_parts(data, len as usize)) ++ } ++ } ++ } ++ ++ /// Returns the protocol selected by performing ALPN, if any. ++ /// ++ /// The protocol's name is returned is an opaque sequence of bytes. It is up to the client ++ /// to interpret it. ++ /// ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or OpenSSL 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ pub fn selected_alpn_protocol(&self) -> Option<&[u8]> { ++ unsafe { ++ let mut data: *const c_uchar = ptr::null(); ++ let mut len: c_uint = 0; ++ // Get the negotiated protocol from the SSL instance. ++ // `data` will point at a `c_uchar` array; `len` will contain the length of this array. ++ ffi::SSL_get0_alpn_selected(self.as_ptr(), &mut data, &mut len); ++ ++ if data.is_null() { ++ None ++ } else { ++ Some(slice::from_raw_parts(data, len as usize)) ++ } ++ } ++ } ++ ++ /// Returns the number of bytes remaining in the currently processed TLS ++ /// record. ++ pub fn pending(&self) -> usize { ++ unsafe { ffi::SSL_pending(self.as_ptr()) as usize } ++ } ++ ++ /// Returns the compression currently in use. ++ /// ++ /// The result will be either None, indicating no compression is in use, or ++ /// a string with the compression name. ++ pub fn compression(&self) -> Option<&str> { ++ self._compression() ++ } ++ ++ #[cfg(not(osslconf = "OPENSSL_NO_COMP"))] ++ fn _compression(&self) -> Option<&str> { ++ unsafe { ++ let ptr = ffi::SSL_get_current_compression(self.as_ptr()); ++ if ptr == ptr::null() { ++ return None; ++ } ++ let meth = ffi::SSL_COMP_get_name(ptr); ++ Some( ++ str::from_utf8(CStr::from_ptr(meth as *const _).to_bytes()).unwrap(), ++ ) ++ } ++ } ++ ++ #[cfg(osslconf = "OPENSSL_NO_COMP")] ++ fn _compression(&self) -> Option<&str> { ++ None ++ } ++ ++ /// Returns the server's name for the current connection ++ pub fn servername(&self) -> Option<&str> { ++ unsafe { ++ let name = ffi::SSL_get_servername(self.as_ptr(), ffi::TLSEXT_NAMETYPE_host_name); ++ if name == ptr::null() { ++ return None; ++ } ++ ++ Some( ++ str::from_utf8(CStr::from_ptr(name as *const _).to_bytes()).unwrap(), ++ ) ++ } ++ } ++ ++ /// Changes the context corresponding to the current connection. ++ pub fn set_ssl_context(&mut self, ctx: &SslContextRef) -> Result<(), ErrorStack> { ++ unsafe { cvt_p(ffi::SSL_set_SSL_CTX(self.as_ptr(), ctx.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Returns the context corresponding to the current connection ++ pub fn ssl_context(&self) -> &SslContextRef { ++ unsafe { ++ let ssl_ctx = ffi::SSL_get_SSL_CTX(self.as_ptr()); ++ SslContextRef::from_ptr(ssl_ctx) ++ } ++ } ++ ++ /// Returns the X509 verification configuration. ++ /// ++ /// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or 1.1.0. ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ pub fn param_mut(&mut self) -> &mut X509VerifyParamRef { ++ self._param_mut() ++ } ++ ++ #[cfg(any(ossl102, ossl110))] ++ fn _param_mut(&mut self) -> &mut X509VerifyParamRef { ++ unsafe { X509VerifyParamRef::from_ptr_mut(ffi::SSL_get0_param(self.as_ptr())) } ++ } ++ ++ /// Returns the result of X509 certificate verification. ++ pub fn verify_result(&self) -> Option { ++ unsafe { X509VerifyError::from_raw(ffi::SSL_get_verify_result(self.as_ptr())) } ++ } ++ ++ /// Returns the SSL session. ++ pub fn session(&self) -> Option<&SslSessionRef> { ++ unsafe { ++ let p = ffi::SSL_get_session(self.as_ptr()); ++ if p.is_null() { ++ None ++ } else { ++ Some(SslSessionRef::from_ptr(p)) ++ } ++ } ++ } ++ ++ /// Sets the session to be used. ++ /// ++ /// # Safety ++ /// ++ /// The caller of this method is responsible for ensuring that the session is associated ++ /// with the same `SslContext` as this `Ssl`. ++ pub unsafe fn set_session(&mut self, session: &SslSessionRef) -> Result<(), ErrorStack> { ++ cvt(ffi::SSL_set_session(self.as_ptr(), session.as_ptr())).map(|_| ()) ++ } ++ ++ /// Determines if the session provided to `set_session` was successfully reused. ++ pub fn session_reused(&self) -> bool { ++ unsafe { ffi::SSL_session_reused(self.as_ptr()) != 0 } ++ } ++ ++ /// Sets the status response a client wishes the server to reply with. ++ pub fn set_status_type(&mut self, type_: StatusType) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::SSL_set_tlsext_status_type( ++ self.as_ptr(), ++ type_.as_raw(), ++ ) as c_int).map(|_| ()) ++ } ++ } ++ ++ /// Returns the server's OCSP response, if present. ++ pub fn ocsp_status(&self) -> Option<&[u8]> { ++ unsafe { ++ let mut p = ptr::null_mut(); ++ let len = ffi::SSL_get_tlsext_status_ocsp_resp(self.as_ptr(), &mut p); ++ ++ if len < 0 { ++ None ++ } else { ++ Some(slice::from_raw_parts(p as *const u8, len as usize)) ++ } ++ } ++ } ++ ++ /// Sets the OCSP response to be returned to the client. ++ pub fn set_ocsp_status(&mut self, response: &[u8]) -> Result<(), ErrorStack> { ++ unsafe { ++ assert!(response.len() <= c_int::max_value() as usize); ++ let p = try!(cvt_p(ffi::CRYPTO_malloc( ++ response.len() as _, ++ concat!(file!(), "\0").as_ptr() as *const _, ++ line!() as c_int, ++ ))); ++ ptr::copy_nonoverlapping(response.as_ptr(), p as *mut u8, response.len()); ++ cvt(ffi::SSL_set_tlsext_status_ocsp_resp( ++ self.as_ptr(), ++ p as *mut c_uchar, ++ response.len() as c_long, ++ ) as c_int).map(|_| ()) ++ } ++ } ++ ++ /// Determines if this `Ssl` is configured for server-side or client-side use. ++ pub fn is_server(&self) -> bool { ++ unsafe { compat::SSL_is_server(self.as_ptr()) != 0 } ++ } ++ ++ /// Sets the extra data at the specified index. ++ pub fn set_ex_data(&mut self, index: Index, data: T) { ++ unsafe { ++ let data = Box::new(data); ++ ffi::SSL_set_ex_data( ++ self.as_ptr(), ++ index.as_raw(), ++ Box::into_raw(data) as *mut c_void, ++ ); ++ } ++ } ++ ++ /// Returns a reference to the extra data at the specified index. ++ pub fn ex_data(&self, index: Index) -> Option<&T> { ++ unsafe { ++ let data = ffi::SSL_get_ex_data(self.as_ptr(), index.as_raw()); ++ if data.is_null() { ++ None ++ } else { ++ Some(&*(data as *const T)) ++ } ++ } ++ } ++} ++ ++unsafe impl Sync for Ssl {} ++unsafe impl Send for Ssl {} ++ ++impl fmt::Debug for Ssl { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ fmt::Debug::fmt(&**self, fmt) ++ } ++} ++ ++impl Ssl { ++ pub fn new(ctx: &SslContext) -> Result { ++ unsafe { ++ let ssl = try!(cvt_p(ffi::SSL_new(ctx.as_ptr()))); ++ Ok(Ssl::from_ptr(ssl)) ++ } ++ } ++ ++ /// Creates an SSL/TLS client operating over the provided stream. ++ /// ++ /// # Warning ++ /// ++ /// OpenSSL's default configuration is insecure. It is highly recommended to use ++ /// `SslConnector` rather than `Ssl` directly, as it manages that configuration. ++ pub fn connect(self, stream: S) -> Result, HandshakeError> ++ where ++ S: Read + Write, ++ { ++ let mut stream = SslStream::new_base(self, stream); ++ let ret = unsafe { ffi::SSL_connect(stream.ssl.as_ptr()) }; ++ if ret > 0 { ++ Ok(stream) ++ } else { ++ match stream.make_error(ret) { ++ e @ Error::WantWrite(_) | ++ e @ Error::WantRead(_) => { ++ Err(HandshakeError::Interrupted(MidHandshakeSslStream { ++ stream: stream, ++ error: e, ++ })) ++ } ++ err => { ++ Err(HandshakeError::Failure(MidHandshakeSslStream { ++ stream: stream, ++ error: err, ++ })) ++ } ++ } ++ } ++ } ++ ++ /// Creates an SSL/TLS server operating over the provided stream. ++ /// ++ /// # Warning ++ /// ++ /// OpenSSL's default configuration is insecure. It is highly recommended to use ++ /// `SslAcceptor` rather than `Ssl` directly, as it manages that configuration. ++ pub fn accept(self, stream: S) -> Result, HandshakeError> ++ where ++ S: Read + Write, ++ { ++ let mut stream = SslStream::new_base(self, stream); ++ let ret = unsafe { ffi::SSL_accept(stream.ssl.as_ptr()) }; ++ if ret > 0 { ++ Ok(stream) ++ } else { ++ match stream.make_error(ret) { ++ e @ Error::WantWrite(_) | ++ e @ Error::WantRead(_) => { ++ Err(HandshakeError::Interrupted(MidHandshakeSslStream { ++ stream: stream, ++ error: e, ++ })) ++ } ++ err => { ++ Err(HandshakeError::Failure(MidHandshakeSslStream { ++ stream: stream, ++ error: err, ++ })) ++ } ++ } ++ } ++ } ++} ++ ++/// An SSL stream midway through the handshake process. ++#[derive(Debug)] ++pub struct MidHandshakeSslStream { ++ stream: SslStream, ++ error: Error, ++} ++ ++impl MidHandshakeSslStream { ++ /// Returns a shared reference to the inner stream. ++ pub fn get_ref(&self) -> &S { ++ self.stream.get_ref() ++ } ++ ++ /// Returns a mutable reference to the inner stream. ++ pub fn get_mut(&mut self) -> &mut S { ++ self.stream.get_mut() ++ } ++ ++ /// Returns a shared reference to the `Ssl` of the stream. ++ pub fn ssl(&self) -> &SslRef { ++ self.stream.ssl() ++ } ++ ++ /// Returns the underlying error which interrupted this handshake. ++ pub fn error(&self) -> &Error { ++ &self.error ++ } ++ ++ /// Consumes `self`, returning its error. ++ pub fn into_error(self) -> Error { ++ self.error ++ } ++ ++ /// Restarts the handshake process. ++ pub fn handshake(mut self) -> Result, HandshakeError> { ++ let ret = unsafe { ffi::SSL_do_handshake(self.stream.ssl.as_ptr()) }; ++ if ret > 0 { ++ Ok(self.stream) ++ } else { ++ match self.stream.make_error(ret) { ++ e @ Error::WantWrite(_) | ++ e @ Error::WantRead(_) => { ++ self.error = e; ++ Err(HandshakeError::Interrupted(self)) ++ } ++ err => { ++ self.error = err; ++ Err(HandshakeError::Failure(self)) ++ } ++ } ++ } ++ } ++} ++ ++/// A stream wrapper which handles SSL encryption for an underlying stream. ++pub struct SslStream { ++ ssl: Ssl, ++ _method: BioMethod, // NOTE: this *must* be after the Ssl field so things drop right ++ _p: PhantomData, ++} ++ ++impl fmt::Debug for SslStream ++where ++ S: fmt::Debug, ++{ ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ fmt.debug_struct("SslStream") ++ .field("stream", &self.get_ref()) ++ .field("ssl", &self.ssl()) ++ .finish() ++ } ++} ++ ++impl SslStream { ++ fn new_base(ssl: Ssl, stream: S) -> Self { ++ unsafe { ++ let (bio, method) = bio::new(stream).unwrap(); ++ ffi::SSL_set_bio(ssl.as_ptr(), bio, bio); ++ ++ SslStream { ++ ssl: ssl, ++ _method: method, ++ _p: PhantomData, ++ } ++ } ++ } ++ ++ /// Like `read`, but returns an `ssl::Error` rather than an `io::Error`. ++ /// ++ /// This is particularly useful with a nonblocking socket, where the error ++ /// value will identify if OpenSSL is waiting on read or write readiness. ++ pub fn ssl_read(&mut self, buf: &mut [u8]) -> Result { ++ // The intepretation of the return code here is a little odd with a ++ // zero-length write. OpenSSL will likely correctly report back to us ++ // that it read zero bytes, but zero is also the sentinel for "error". ++ // To avoid that confusion short-circuit that logic and return quickly ++ // if `buf` has a length of zero. ++ if buf.len() == 0 { ++ return Ok(0); ++ } ++ ++ let ret = self.ssl.read(buf); ++ if ret > 0 { ++ Ok(ret as usize) ++ } else { ++ match self.make_error(ret) { ++ // Don't treat unexpected EOFs as errors when reading ++ Error::Stream(ref e) if e.kind() == io::ErrorKind::ConnectionAborted => Ok(0), ++ e => Err(e), ++ } ++ } ++ } ++ ++ /// Like `write`, but returns an `ssl::Error` rather than an `io::Error`. ++ /// ++ /// This is particularly useful with a nonblocking socket, where the error ++ /// value will identify if OpenSSL is waiting on read or write readiness. ++ pub fn ssl_write(&mut self, buf: &[u8]) -> Result { ++ // See above for why we short-circuit on zero-length buffers ++ if buf.len() == 0 { ++ return Ok(0); ++ } ++ ++ let ret = self.ssl.write(buf); ++ if ret > 0 { ++ Ok(ret as usize) ++ } else { ++ Err(self.make_error(ret)) ++ } ++ } ++ ++ /// Shuts down the session. ++ /// ++ /// The shutdown process consists of two steps. The first step sends a ++ /// close notify message to the peer, after which `ShutdownResult::Sent` ++ /// is returned. The second step awaits the receipt of a close notify ++ /// message from the peer, after which `ShutdownResult::Received` is ++ /// returned. ++ /// ++ /// While the connection may be closed after the first step, it is ++ /// recommended to fully shut the session down. In particular, it must ++ /// be fully shut down if the connection is to be used for further ++ /// communication in the future. ++ pub fn shutdown(&mut self) -> Result { ++ match unsafe { ffi::SSL_shutdown(self.ssl.as_ptr()) } { ++ 0 => Ok(ShutdownResult::Sent), ++ 1 => Ok(ShutdownResult::Received), ++ n => Err(self.make_error(n)), ++ } ++ } ++} ++ ++impl SslStream { ++ fn make_error(&mut self, ret: c_int) -> Error { ++ self.check_panic(); ++ ++ match self.ssl.get_error(ret) { ++ ffi::SSL_ERROR_SSL => Error::Ssl(ErrorStack::get()), ++ ffi::SSL_ERROR_SYSCALL => { ++ let errs = ErrorStack::get(); ++ if errs.errors().is_empty() { ++ match self.get_bio_error() { ++ Some(err) => Error::Stream(err), ++ None => { ++ Error::Stream(io::Error::new( ++ io::ErrorKind::ConnectionAborted, ++ "unexpected EOF observed", ++ )) ++ } ++ } ++ } else { ++ Error::Ssl(errs) ++ } ++ } ++ ffi::SSL_ERROR_ZERO_RETURN => Error::ZeroReturn, ++ ffi::SSL_ERROR_WANT_WRITE => { ++ let err = match self.get_bio_error() { ++ Some(err) => err, ++ None => { ++ io::Error::new( ++ io::ErrorKind::Other, ++ "BUG: got an SSL_ERROR_WANT_WRITE with no error in the BIO", ++ ) ++ } ++ }; ++ Error::WantWrite(err) ++ } ++ ffi::SSL_ERROR_WANT_READ => { ++ let err = match self.get_bio_error() { ++ Some(err) => err, ++ None => { ++ io::Error::new( ++ io::ErrorKind::Other, ++ "BUG: got an SSL_ERROR_WANT_WRITE with no error in the BIO", ++ ) ++ } ++ }; ++ Error::WantRead(err) ++ } ++ err => { ++ Error::Stream(io::Error::new( ++ io::ErrorKind::InvalidData, ++ format!("unexpected error {}", err), ++ )) ++ } ++ } ++ } ++ ++ fn check_panic(&mut self) { ++ if let Some(err) = unsafe { bio::take_panic::(self.ssl.get_raw_rbio()) } { ++ resume_unwind(err) ++ } ++ } ++ ++ fn get_bio_error(&mut self) -> Option { ++ unsafe { bio::take_error::(self.ssl.get_raw_rbio()) } ++ } ++ ++ /// Returns a reference to the underlying stream. ++ pub fn get_ref(&self) -> &S { ++ unsafe { ++ let bio = self.ssl.get_raw_rbio(); ++ bio::get_ref(bio) ++ } ++ } ++ ++ /// Returns a mutable reference to the underlying stream. ++ /// ++ /// ## Warning ++ /// ++ /// It is inadvisable to read from or write to the underlying stream as it ++ /// will most likely corrupt the SSL session. ++ pub fn get_mut(&mut self) -> &mut S { ++ unsafe { ++ let bio = self.ssl.get_raw_rbio(); ++ bio::get_mut(bio) ++ } ++ } ++ ++ /// Returns the OpenSSL `Ssl` object associated with this stream. ++ pub fn ssl(&self) -> &SslRef { ++ &self.ssl ++ } ++} ++ ++impl Read for SslStream { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ match self.ssl_read(buf) { ++ Ok(n) => Ok(n), ++ Err(Error::ZeroReturn) => Ok(0), ++ Err(Error::Stream(e)) => Err(e), ++ Err(Error::WantRead(e)) => Err(e), ++ Err(Error::WantWrite(e)) => Err(e), ++ Err(e) => Err(io::Error::new(io::ErrorKind::Other, e)), ++ } ++ } ++} ++ ++impl Write for SslStream { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.ssl_write(buf).map_err(|e| match e { ++ Error::Stream(e) => e, ++ Error::WantRead(e) => e, ++ Error::WantWrite(e) => e, ++ e => io::Error::new(io::ErrorKind::Other, e), ++ }) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.get_mut().flush() ++ } ++} ++ ++/// The result of a shutdown request. ++#[derive(Copy, Clone, Debug, PartialEq, Eq)] ++pub enum ShutdownResult { ++ /// A close notify message has been sent to the peer. ++ Sent, ++ ++ /// A close notify response message has been received from the peer. ++ Received, ++} ++ ++#[cfg(ossl110)] ++mod compat { ++ use std::ptr; ++ ++ use ffi; ++ use libc::c_int; ++ ++ pub use ffi::{SSL_CTX_get_options, SSL_CTX_set_options, SSL_CTX_clear_options, SSL_CTX_up_ref, ++ SSL_SESSION_get_master_key, SSL_is_server, SSL_SESSION_up_ref}; ++ ++ pub unsafe fn get_new_idx(f: ffi::CRYPTO_EX_free) -> c_int { ++ ffi::CRYPTO_get_ex_new_index( ++ ffi::CRYPTO_EX_INDEX_SSL_CTX, ++ 0, ++ ptr::null_mut(), ++ None, ++ None, ++ Some(f), ++ ) ++ } ++ ++ pub unsafe fn get_new_ssl_idx(f: ffi::CRYPTO_EX_free) -> c_int { ++ ffi::CRYPTO_get_ex_new_index( ++ ffi::CRYPTO_EX_INDEX_SSL, ++ 0, ++ ptr::null_mut(), ++ None, ++ None, ++ Some(f), ++ ) ++ } ++ ++ pub fn tls_method() -> *const ffi::SSL_METHOD { ++ unsafe { ffi::TLS_method() } ++ } ++ ++ pub fn dtls_method() -> *const ffi::SSL_METHOD { ++ unsafe { ffi::DTLS_method() } ++ } ++} ++ ++#[cfg(ossl10x)] ++#[allow(bad_style)] ++mod compat { ++ use std::ptr; ++ ++ use ffi; ++ use libc::{self, c_long, c_ulong, c_int, size_t, c_uchar}; ++ ++ pub unsafe fn SSL_CTX_get_options(ctx: *const ffi::SSL_CTX) -> c_ulong { ++ ffi::SSL_CTX_ctrl(ctx as *mut _, ffi::SSL_CTRL_OPTIONS, 0, ptr::null_mut()) as c_ulong ++ } ++ ++ pub unsafe fn SSL_CTX_set_options(ctx: *const ffi::SSL_CTX, op: c_ulong) -> c_ulong { ++ ffi::SSL_CTX_ctrl( ++ ctx as *mut _, ++ ffi::SSL_CTRL_OPTIONS, ++ op as c_long, ++ ptr::null_mut(), ++ ) as c_ulong ++ } ++ ++ pub unsafe fn SSL_CTX_clear_options(ctx: *const ffi::SSL_CTX, op: c_ulong) -> c_ulong { ++ ffi::SSL_CTX_ctrl( ++ ctx as *mut _, ++ ffi::SSL_CTRL_CLEAR_OPTIONS, ++ op as c_long, ++ ptr::null_mut(), ++ ) as c_ulong ++ } ++ ++ pub unsafe fn get_new_idx(f: ffi::CRYPTO_EX_free) -> c_int { ++ ffi::SSL_CTX_get_ex_new_index(0, ptr::null_mut(), None, None, Some(f)) ++ } ++ ++ pub unsafe fn get_new_ssl_idx(f: ffi::CRYPTO_EX_free) -> c_int { ++ ffi::SSL_get_ex_new_index(0, ptr::null_mut(), None, None, Some(f)) ++ } ++ ++ pub unsafe fn SSL_CTX_up_ref(ssl: *mut ffi::SSL_CTX) -> libc::c_int { ++ ffi::CRYPTO_add_lock( ++ &mut (*ssl).references, ++ 1, ++ ffi::CRYPTO_LOCK_SSL_CTX, ++ "mod.rs\0".as_ptr() as *const _, ++ line!() as libc::c_int, ++ ); ++ 0 ++ } ++ ++ pub unsafe fn SSL_SESSION_get_master_key( ++ session: *const ffi::SSL_SESSION, ++ out: *mut c_uchar, ++ mut outlen: size_t, ++ ) -> size_t { ++ if outlen == 0 { ++ return (*session).master_key_length as size_t; ++ } ++ if outlen > (*session).master_key_length as size_t { ++ outlen = (*session).master_key_length as size_t; ++ } ++ ptr::copy_nonoverlapping((*session).master_key.as_ptr(), out, outlen); ++ outlen ++ } ++ ++ pub fn tls_method() -> *const ffi::SSL_METHOD { ++ unsafe { ffi::SSLv23_method() } ++ } ++ ++ pub fn dtls_method() -> *const ffi::SSL_METHOD { ++ unsafe { ffi::DTLSv1_method() } ++ } ++ ++ pub unsafe fn SSL_is_server(s: *mut ffi::SSL) -> c_int { ++ (*s).server ++ } ++ ++ pub unsafe fn SSL_SESSION_up_ref(ses: *mut ffi::SSL_SESSION) -> c_int { ++ ffi::CRYPTO_add_lock( ++ &mut (*ses).references, ++ 1, ++ ffi::CRYPTO_LOCK_SSL_CTX, ++ "mod.rs\0".as_ptr() as *const _, ++ line!() as libc::c_int, ++ ); ++ 0 ++ } ++} diff --cc vendor/openssl-0.9.19/src/ssl/tests/mod.rs index 000000000,000000000..a3ac68326 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ssl/tests/mod.rs @@@ -1,0 -1,0 +1,1418 @@@ ++#![allow(unused_imports)] ++ ++use std::env; ++use std::fs::File; ++use std::io::prelude::*; ++use std::io::{self, BufReader}; ++use std::iter; ++use std::mem; ++use std::net::{TcpStream, TcpListener, SocketAddr}; ++use std::path::Path; ++use std::process::{Command, Child, Stdio, ChildStdin}; ++use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; ++use std::thread; ++use std::time::Duration; ++use tempdir::TempDir; ++ ++use dh::Dh; ++use hash::MessageDigest; ++use ocsp::{OcspResponse, RESPONSE_STATUS_UNAUTHORIZED}; ++use ssl; ++use ssl::{SslMethod, HandshakeError, SslContext, SslStream, Ssl, ShutdownResult, ++ SslConnectorBuilder, SslAcceptorBuilder, Error, SSL_VERIFY_PEER, SSL_VERIFY_NONE, ++ STATUS_TYPE_OCSP}; ++use x509::{X509StoreContext, X509, X509Name, X509_FILETYPE_PEM}; ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++use x509::verify::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS; ++use pkey::PKey; ++ ++use std::net::UdpSocket; ++ ++mod select; ++ ++static ROOT_CERT: &'static [u8] = include_bytes!("../../../test/root-ca.pem"); ++static CERT: &'static [u8] = include_bytes!("../../../test/cert.pem"); ++static KEY: &'static [u8] = include_bytes!("../../../test/key.pem"); ++ ++fn next_addr() -> SocketAddr { ++ use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; ++ static PORT: AtomicUsize = ATOMIC_USIZE_INIT; ++ let port = 15411 + PORT.fetch_add(1, Ordering::SeqCst); ++ ++ format!("127.0.0.1:{}", port).parse().unwrap() ++} ++ ++struct Server { ++ p: Child, ++ _temp: TempDir, ++} ++ ++impl Server { ++ fn spawn(args: &[&str], input: Option>) -> (Server, SocketAddr) { ++ let td = TempDir::new("openssl").unwrap(); ++ let cert = td.path().join("cert.pem"); ++ let key = td.path().join("key.pem"); ++ File::create(&cert).unwrap().write_all(CERT).unwrap(); ++ File::create(&key).unwrap().write_all(KEY).unwrap(); ++ ++ let addr = next_addr(); ++ let mut child = Command::new("openssl") ++ .arg("s_server") ++ .arg("-accept") ++ .arg(addr.port().to_string()) ++ .args(args) ++ .arg("-cert") ++ .arg(&cert) ++ .arg("-key") ++ .arg(&key) ++ .arg("-no_dhe") ++ .stdout(Stdio::null()) ++ .stderr(Stdio::null()) ++ .stdin(Stdio::piped()) ++ .spawn() ++ .unwrap(); ++ let stdin = child.stdin.take().unwrap(); ++ if let Some(mut input) = input { ++ thread::spawn(move || input(stdin)); ++ } ++ ( ++ Server { ++ p: child, ++ _temp: td, ++ }, ++ addr, ++ ) ++ } ++ ++ fn new_tcp(args: &[&str]) -> (Server, TcpStream) { ++ let (server, addr) = Server::spawn(args, None); ++ for _ in 0..20 { ++ match TcpStream::connect(&addr) { ++ Ok(s) => return (server, s), ++ Err(ref e) if e.kind() == io::ErrorKind::ConnectionRefused => { ++ thread::sleep(Duration::from_millis(100)); ++ } ++ Err(e) => panic!("wut: {}", e), ++ } ++ } ++ panic!("server never came online"); ++ } ++ ++ fn new() -> (Server, TcpStream) { ++ Server::new_tcp(&["-www"]) ++ } ++ ++ #[allow(dead_code)] ++ fn new_alpn() -> (Server, TcpStream) { ++ Server::new_tcp( ++ &[ ++ "-www", ++ "-nextprotoneg", ++ "http/1.1,spdy/3.1", ++ "-alpn", ++ "http/1.1,spdy/3.1", ++ ], ++ ) ++ } ++} ++ ++impl Drop for Server { ++ fn drop(&mut self) { ++ let _ = self.p.kill(); ++ let _ = self.p.wait(); ++ } ++} ++ ++macro_rules! run_test( ++ ($module:ident, $blk:expr) => ( ++ #[cfg(test)] ++ mod $module { ++ use std::io; ++ use std::io::prelude::*; ++ use std::path::Path; ++ use std::net::UdpSocket; ++ use std::net::TcpStream; ++ use ssl; ++ use ssl::SslMethod; ++ use ssl::{SslContext, Ssl, SslStream}; ++ use ssl::SSL_VERIFY_PEER; ++ use hash::MessageDigest; ++ use x509::X509StoreContext; ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ use x509::X509; ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ use x509::store::X509StoreBuilder; ++ use hex::FromHex; ++ use foreign_types::ForeignTypeRef; ++ use super::Server; ++ #[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++ use super::ROOT_CERT; ++ ++ #[test] ++ fn sslv23() { ++ let (_s, stream) = Server::new(); ++ $blk(SslMethod::tls(), stream); ++ } ++ } ++ ); ++); ++ ++run_test!( ++ new_ctx, ++ |method, _| { SslContext::builder(method).unwrap(); } ++); ++ ++run_test!(verify_untrusted, |method, stream| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ++ match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(_) => panic!("expected failure"), ++ Err(err) => println!("error {:?}", err), ++ } ++}); ++ ++run_test!(verify_trusted, |method, stream| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ++ match ctx.set_ca_file(&Path::new("test/root-ca.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(_) => (), ++ Err(err) => panic!("Expected success, got {:?}", err), ++ } ++}); ++ ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++run_test!(verify_trusted_with_set_cert, |method, stream| { ++ let x509 = X509::from_pem(ROOT_CERT).unwrap(); ++ let mut store = X509StoreBuilder::new().unwrap(); ++ store.add_cert(x509).unwrap(); ++ ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ++ match ctx.set_verify_cert_store(store.build()) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(_) => (), ++ Err(err) => panic!("Expected success, got {:?}", err), ++ } ++}); ++ ++run_test!(verify_untrusted_callback_override_ok, |method, stream| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_verify_callback(SSL_VERIFY_PEER, |_, _| true); ++ ++ match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(_) => (), ++ Err(err) => panic!("Expected success, got {:?}", err), ++ } ++}); ++ ++run_test!(verify_untrusted_callback_override_bad, |method, stream| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_verify_callback(SSL_VERIFY_PEER, |_, _| false); ++ ++ assert!(Ssl::new(&ctx.build()).unwrap().connect(stream).is_err()); ++}); ++ ++run_test!(verify_trusted_callback_override_ok, |method, stream| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_verify_callback(SSL_VERIFY_PEER, |_, _| true); ++ ++ match ctx.set_ca_file(&Path::new("test/cert.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(_) => (), ++ Err(err) => panic!("Expected success, got {:?}", err), ++ } ++}); ++ ++run_test!(verify_trusted_callback_override_bad, |method, stream| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_verify_callback(SSL_VERIFY_PEER, |_, _| false); ++ ++ match ctx.set_ca_file(&Path::new("test/cert.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ assert!(Ssl::new(&ctx.build()).unwrap().connect(stream).is_err()); ++}); ++ ++run_test!(verify_callback_load_certs, |method, stream| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_verify_callback(SSL_VERIFY_PEER, |_, x509_ctx| { ++ assert!(x509_ctx.current_cert().is_some()); ++ true ++ }); ++ ++ assert!(Ssl::new(&ctx.build()).unwrap().connect(stream).is_ok()); ++}); ++ ++run_test!(verify_trusted_get_error_ok, |method, stream| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_verify_callback(SSL_VERIFY_PEER, |_, x509_ctx| { ++ assert!(x509_ctx.error().is_none()); ++ true ++ }); ++ ++ match ctx.set_ca_file(&Path::new("test/root-ca.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ assert!(Ssl::new(&ctx.build()).unwrap().connect(stream).is_ok()); ++}); ++ ++run_test!(verify_trusted_get_error_err, |method, stream| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_verify_callback(SSL_VERIFY_PEER, |_, x509_ctx| { ++ assert!(x509_ctx.error().is_some()); ++ false ++ }); ++ ++ assert!(Ssl::new(&ctx.build()).unwrap().connect(stream).is_err()); ++}); ++ ++run_test!(verify_callback_data, |method, stream| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ++ // Node id was generated as SHA256 hash of certificate "test/cert.pem" ++ // in DER format. ++ // Command: openssl x509 -in test/cert.pem -outform DER | openssl dgst -sha256 ++ // Please update if "test/cert.pem" will ever change ++ let node_hash_str = "59172d9313e84459bcff27f967e79e6e9217e584"; ++ let node_id = Vec::from_hex(node_hash_str).unwrap(); ++ ctx.set_verify_callback(SSL_VERIFY_PEER, move |_preverify_ok, x509_ctx| { ++ let cert = x509_ctx.current_cert(); ++ match cert { ++ None => false, ++ Some(cert) => { ++ let fingerprint = cert.fingerprint(MessageDigest::sha1()).unwrap(); ++ fingerprint == node_id ++ } ++ } ++ }); ++ ctx.set_verify_depth(1); ++ ++ match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(_) => (), ++ Err(err) => panic!("Expected success, got {:?}", err), ++ } ++}); ++ ++run_test!(ssl_verify_callback, |method, stream| { ++ use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; ++ ++ static CHECKED: AtomicUsize = ATOMIC_USIZE_INIT; ++ ++ let ctx = SslContext::builder(method).unwrap(); ++ let mut ssl = Ssl::new(&ctx.build()).unwrap(); ++ ++ let node_hash_str = "59172d9313e84459bcff27f967e79e6e9217e584"; ++ let node_id = Vec::from_hex(node_hash_str).unwrap(); ++ ssl.set_verify_callback(SSL_VERIFY_PEER, move |_, x509| { ++ CHECKED.store(1, Ordering::SeqCst); ++ match x509.current_cert() { ++ None => false, ++ Some(cert) => { ++ let fingerprint = cert.fingerprint(MessageDigest::sha1()).unwrap(); ++ fingerprint == node_id ++ } ++ } ++ }); ++ ++ match ssl.connect(stream) { ++ Ok(_) => (), ++ Err(err) => panic!("Expected success, got {:?}", err), ++ } ++ ++ assert_eq!(CHECKED.load(Ordering::SeqCst), 1); ++}); ++ ++// Make sure every write call translates to a write call to the underlying socket. ++#[test] ++fn test_write_hits_stream() { ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let addr = listener.local_addr().unwrap(); ++ ++ let guard = thread::spawn(move || { ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let stream = TcpStream::connect(addr).unwrap(); ++ let mut stream = Ssl::new(&ctx.build()).unwrap().connect(stream).unwrap(); ++ ++ stream.write_all(b"hello").unwrap(); ++ stream ++ }); ++ ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.set_private_key_file(&Path::new("test/key.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ let stream = listener.accept().unwrap().0; ++ let mut stream = Ssl::new(&ctx.build()).unwrap().accept(stream).unwrap(); ++ ++ let mut buf = [0; 5]; ++ assert_eq!(5, stream.read(&mut buf).unwrap()); ++ assert_eq!(&b"hello"[..], &buf[..]); ++ guard.join().unwrap(); ++} ++ ++#[test] ++fn test_set_certificate_and_private_key() { ++ let key = include_bytes!("../../../test/key.pem"); ++ let key = PKey::private_key_from_pem(key).unwrap(); ++ let cert = include_bytes!("../../../test/cert.pem"); ++ let cert = X509::from_pem(cert).unwrap(); ++ ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_private_key(&key).unwrap(); ++ ctx.set_certificate(&cert).unwrap(); ++ ++ assert!(ctx.check_private_key().is_ok()); ++} ++ ++run_test!(get_ctx_options, |method, _| { ++ let ctx = SslContext::builder(method).unwrap(); ++ ctx.options(); ++}); ++ ++run_test!(set_ctx_options, |method, _| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ let opts = ctx.set_options(ssl::SSL_OP_NO_TICKET); ++ assert!(opts.contains(ssl::SSL_OP_NO_TICKET)); ++}); ++ ++run_test!(clear_ctx_options, |method, _| { ++ let mut ctx = SslContext::builder(method).unwrap(); ++ ctx.set_options(ssl::SSL_OP_ALL); ++ let opts = ctx.clear_options(ssl::SSL_OP_ALL); ++ assert!(!opts.contains(ssl::SSL_OP_ALL)); ++}); ++ ++#[test] ++fn test_write() { ++ let (_s, stream) = Server::new(); ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let mut stream = Ssl::new(&ctx.build()).unwrap().connect(stream).unwrap(); ++ stream.write_all("hello".as_bytes()).unwrap(); ++ stream.flush().unwrap(); ++ stream.write_all(" there".as_bytes()).unwrap(); ++ stream.flush().unwrap(); ++} ++ ++#[test] ++fn zero_length_buffers() { ++ let (_s, stream) = Server::new(); ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let mut stream = Ssl::new(&ctx.build()).unwrap().connect(stream).unwrap(); ++ ++ assert_eq!(stream.write(b"").unwrap(), 0); ++ assert_eq!(stream.read(&mut []).unwrap(), 0); ++} ++ ++run_test!(get_peer_certificate, |method, stream| { ++ let ctx = SslContext::builder(method).unwrap(); ++ let stream = Ssl::new(&ctx.build()).unwrap().connect(stream).unwrap(); ++ let cert = stream.ssl().peer_certificate().unwrap(); ++ let fingerprint = cert.fingerprint(MessageDigest::sha1()).unwrap(); ++ let node_hash_str = "59172d9313e84459bcff27f967e79e6e9217e584"; ++ let node_id = Vec::from_hex(node_hash_str).unwrap(); ++ assert_eq!(node_id, fingerprint) ++}); ++ ++#[test] ++fn test_read() { ++ let (_s, tcp) = Server::new(); ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let mut stream = Ssl::new(&ctx.build()).unwrap().connect(tcp).unwrap(); ++ stream.write_all("GET /\r\n\r\n".as_bytes()).unwrap(); ++ stream.flush().unwrap(); ++ io::copy(&mut stream, &mut io::sink()).ok().expect( ++ "read error", ++ ); ++} ++ ++#[test] ++fn test_pending() { ++ let (_s, tcp) = Server::new(); ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let mut stream = Ssl::new(&ctx.build()).unwrap().connect(tcp).unwrap(); ++ stream.write_all("GET /\r\n\r\n".as_bytes()).unwrap(); ++ stream.flush().unwrap(); ++ ++ // wait for the response and read first byte... ++ let mut buf = [0u8; 16 * 1024]; ++ stream.read(&mut buf[..1]).unwrap(); ++ ++ let pending = stream.ssl().pending(); ++ let len = stream.read(&mut buf[1..]).unwrap(); ++ ++ assert_eq!(pending, len); ++ ++ stream.read(&mut buf[..1]).unwrap(); ++ ++ let pending = stream.ssl().pending(); ++ let len = stream.read(&mut buf[1..]).unwrap(); ++ assert_eq!(pending, len); ++} ++ ++#[test] ++fn test_state() { ++ let (_s, tcp) = Server::new(); ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let stream = Ssl::new(&ctx.build()).unwrap().connect(tcp).unwrap(); ++ assert_eq!(stream.ssl().state_string(), "SSLOK "); ++ assert_eq!( ++ stream.ssl().state_string_long(), ++ "SSL negotiation finished successfully" ++ ); ++} ++ ++/// Tests that connecting with the client using ALPN, but the server not does not ++/// break the existing connection behavior. ++#[test] ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++fn test_connect_with_unilateral_alpn() { ++ let (_s, stream) = Server::new(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_alpn_protocols(&[b"http/1.1", b"spdy/3.1"]).unwrap(); ++ match ctx.set_ca_file(&Path::new("test/root-ca.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ let stream = match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(stream) => stream, ++ Err(err) => panic!("Expected success, got {:?}", err), ++ }; ++ // Since the socket to which we connected is not configured to use ALPN, ++ // there should be no selected protocol... ++ assert!(stream.ssl().selected_alpn_protocol().is_none()); ++} ++ ++/// Tests that connecting with the client using NPN, but the server not does not ++/// break the existing connection behavior. ++#[test] ++#[cfg(not(libressl261))] ++fn test_connect_with_unilateral_npn() { ++ let (_s, stream) = Server::new(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_npn_protocols(&[b"http/1.1", b"spdy/3.1"]).unwrap(); ++ match ctx.set_ca_file(&Path::new("test/root-ca.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ let stream = match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(stream) => stream, ++ Err(err) => panic!("Expected success, got {:?}", err), ++ }; ++ // Since the socket to which we connected is not configured to use NPN, ++ // there should be no selected protocol... ++ assert!(stream.ssl().selected_npn_protocol().is_none()); ++} ++ ++/// Tests that when both the client as well as the server use ALPN and their ++/// lists of supported protocols have an overlap, the correct protocol is chosen. ++#[test] ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++fn test_connect_with_alpn_successful_multiple_matching() { ++ let (_s, stream) = Server::new_alpn(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_alpn_protocols(&[b"spdy/3.1", b"http/1.1"]).unwrap(); ++ match ctx.set_ca_file(&Path::new("test/root-ca.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ let stream = match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(stream) => stream, ++ Err(err) => panic!("Expected success, got {:?}", err), ++ }; ++ // The server prefers "http/1.1", so that is chosen, even though the client ++ // would prefer "spdy/3.1" ++ assert_eq!(b"http/1.1", stream.ssl().selected_alpn_protocol().unwrap()); ++} ++ ++/// Tests that when both the client as well as the server use NPN and their ++/// lists of supported protocols have an overlap, the correct protocol is chosen. ++#[test] ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++fn test_connect_with_npn_successful_multiple_matching() { ++ let (_s, stream) = Server::new_alpn(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_npn_protocols(&[b"spdy/3.1", b"http/1.1"]).unwrap(); ++ match ctx.set_ca_file(&Path::new("test/root-ca.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ let stream = match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(stream) => stream, ++ Err(err) => panic!("Expected success, got {:?}", err), ++ }; ++ // The server prefers "http/1.1", so that is chosen, even though the client ++ // would prefer "spdy/3.1" ++ assert_eq!(b"http/1.1", stream.ssl().selected_npn_protocol().unwrap()); ++} ++ ++/// Tests that when both the client as well as the server use ALPN and their ++/// lists of supported protocols have an overlap -- with only ONE protocol ++/// being valid for both. ++#[test] ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++fn test_connect_with_alpn_successful_single_match() { ++ let (_s, stream) = Server::new_alpn(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_alpn_protocols(&[b"spdy/3.1"]).unwrap(); ++ match ctx.set_ca_file(&Path::new("test/root-ca.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ let stream = match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(stream) => stream, ++ Err(err) => panic!("Expected success, got {:?}", err), ++ }; ++ // The client now only supports one of the server's protocols, so that one ++ // is used. ++ assert_eq!(b"spdy/3.1", stream.ssl().selected_alpn_protocol().unwrap()); ++} ++ ++ ++/// Tests that when both the client as well as the server use NPN and their ++/// lists of supported protocols have an overlap -- with only ONE protocol ++/// being valid for both. ++#[test] ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++fn test_connect_with_npn_successful_single_match() { ++ let (_s, stream) = Server::new_alpn(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_npn_protocols(&[b"spdy/3.1"]).unwrap(); ++ match ctx.set_ca_file(&Path::new("test/root-ca.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ let stream = match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(stream) => stream, ++ Err(err) => panic!("Expected success, got {:?}", err), ++ }; ++ // The client now only supports one of the server's protocols, so that one ++ // is used. ++ assert_eq!(b"spdy/3.1", stream.ssl().selected_npn_protocol().unwrap()); ++} ++ ++/// Tests that when the `SslStream` is created as a server stream, the protocols ++/// are correctly advertised to the client. ++#[test] ++#[cfg(not(libressl261))] ++fn test_npn_server_advertise_multiple() { ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let localhost = listener.local_addr().unwrap(); ++ // We create a different context instance for the server... ++ let listener_ctx = { ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_npn_protocols(&[b"http/1.1", b"spdy/3.1"]).unwrap(); ++ assert!( ++ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509_FILETYPE_PEM) ++ .is_ok() ++ ); ++ ctx.set_private_key_file(&Path::new("test/key.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.build() ++ }; ++ // Have the listener wait on the connection in a different thread. ++ thread::spawn(move || { ++ let (stream, _) = listener.accept().unwrap(); ++ Ssl::new(&listener_ctx).unwrap().accept(stream).unwrap(); ++ }); ++ ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_npn_protocols(&[b"spdy/3.1"]).unwrap(); ++ match ctx.set_ca_file(&Path::new("test/root-ca.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ // Now connect to the socket and make sure the protocol negotiation works... ++ let stream = TcpStream::connect(localhost).unwrap(); ++ let stream = match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(stream) => stream, ++ Err(err) => panic!("Expected success, got {:?}", err), ++ }; ++ // SPDY is selected since that's the only thing the client supports. ++ assert_eq!(b"spdy/3.1", stream.ssl().selected_npn_protocol().unwrap()); ++} ++ ++/// Tests that when the `SslStream` is created as a server stream, the protocols ++/// are correctly advertised to the client. ++#[test] ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++fn test_alpn_server_advertise_multiple() { ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let localhost = listener.local_addr().unwrap(); ++ // We create a different context instance for the server... ++ let listener_ctx = { ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_alpn_protocols(&[b"http/1.1", b"spdy/3.1"]).unwrap(); ++ assert!( ++ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509_FILETYPE_PEM) ++ .is_ok() ++ ); ++ ctx.set_private_key_file(&Path::new("test/key.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.build() ++ }; ++ // Have the listener wait on the connection in a different thread. ++ thread::spawn(move || { ++ let (stream, _) = listener.accept().unwrap(); ++ Ssl::new(&listener_ctx).unwrap().accept(stream).unwrap(); ++ }); ++ ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_alpn_protocols(&[b"spdy/3.1"]).unwrap(); ++ match ctx.set_ca_file(&Path::new("test/root-ca.pem")) { ++ Ok(_) => {} ++ Err(err) => panic!("Unexpected error {:?}", err), ++ } ++ // Now connect to the socket and make sure the protocol negotiation works... ++ let stream = TcpStream::connect(localhost).unwrap(); ++ let stream = match Ssl::new(&ctx.build()).unwrap().connect(stream) { ++ Ok(stream) => stream, ++ Err(err) => panic!("Expected success, got {:?}", err), ++ }; ++ // SPDY is selected since that's the only thing the client supports. ++ assert_eq!(b"spdy/3.1", stream.ssl().selected_alpn_protocol().unwrap()); ++} ++ ++/// Test that Servers supporting ALPN don't report a protocol when none of their protocols match ++/// the client's reported protocol. ++#[test] ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++fn test_alpn_server_select_none() { ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let localhost = listener.local_addr().unwrap(); ++ // We create a different context instance for the server... ++ let listener_ctx = { ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_alpn_protocols(&[b"http/1.1", b"spdy/3.1"]).unwrap(); ++ assert!( ++ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509_FILETYPE_PEM) ++ .is_ok() ++ ); ++ ctx.set_private_key_file(&Path::new("test/key.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.build() ++ }; ++ // Have the listener wait on the connection in a different thread. ++ thread::spawn(move || { ++ let (stream, _) = listener.accept().unwrap(); ++ Ssl::new(&listener_ctx).unwrap().accept(stream).unwrap(); ++ }); ++ ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ctx.set_alpn_protocols(&[b"http/2"]).unwrap(); ++ ctx.set_ca_file(&Path::new("test/root-ca.pem")).unwrap(); ++ // Now connect to the socket and make sure the protocol negotiation works... ++ let stream = TcpStream::connect(localhost).unwrap(); ++ let stream = Ssl::new(&ctx.build()).unwrap().connect(stream).unwrap(); ++ ++ // Since the protocols from the server and client don't overlap at all, no protocol is selected ++ assert_eq!(None, stream.ssl().selected_alpn_protocol()); ++} ++ ++fn wait_io(stream: &TcpStream, read: bool, timeout_ms: u32) -> bool { ++ unsafe { ++ let mut set: select::fd_set = mem::zeroed(); ++ select::fd_set(&mut set, stream); ++ ++ let write = if read { ++ 0 as *mut _ ++ } else { ++ &mut set as *mut _ ++ }; ++ let read = if !read { ++ 0 as *mut _ ++ } else { ++ &mut set as *mut _ ++ }; ++ select::select(stream, read, write, 0 as *mut _, timeout_ms).unwrap() ++ } ++} ++ ++fn handshake(res: Result, HandshakeError>) -> SslStream { ++ match res { ++ Ok(s) => s, ++ Err(HandshakeError::Interrupted(s)) => { ++ wait_io(s.get_ref(), true, 1_000); ++ handshake(s.handshake()) ++ } ++ Err(err) => panic!("error on handshake {:?}", err), ++ } ++} ++ ++#[test] ++fn test_write_nonblocking() { ++ let (_s, stream) = Server::new(); ++ stream.set_nonblocking(true).unwrap(); ++ let cx = SslContext::builder(SslMethod::tls()).unwrap().build(); ++ let mut stream = handshake(Ssl::new(&cx).unwrap().connect(stream)); ++ ++ let mut iterations = 0; ++ loop { ++ iterations += 1; ++ if iterations > 7 { ++ // Probably a safe assumption for the foreseeable future of ++ // openssl. ++ panic!("Too many read/write round trips in handshake!!"); ++ } ++ let result = stream.ssl_write(b"hello"); ++ match result { ++ Ok(_) => { ++ break; ++ } ++ Err(Error::WantRead(_)) => { ++ assert!(wait_io(stream.get_ref(), true, 1000)); ++ } ++ Err(Error::WantWrite(_)) => { ++ assert!(wait_io(stream.get_ref(), false, 1000)); ++ } ++ Err(other) => { ++ panic!("Unexpected SSL Error: {:?}", other); ++ } ++ } ++ } ++ ++ // Second write should succeed immediately--plenty of space in kernel ++ // buffer, and handshake just completed. ++ stream.write(" there".as_bytes()).unwrap(); ++} ++ ++#[test] ++#[cfg_attr(any(libressl, windows, target_arch = "arm"), ignore)] // FIXME(#467) ++fn test_read_nonblocking() { ++ let (_s, stream) = Server::new(); ++ stream.set_nonblocking(true).unwrap(); ++ let cx = SslContext::builder(SslMethod::tls()).unwrap().build(); ++ let mut stream = handshake(Ssl::new(&cx).unwrap().connect(stream)); ++ ++ let mut iterations = 0; ++ loop { ++ iterations += 1; ++ if iterations > 7 { ++ // Probably a safe assumption for the foreseeable future of ++ // openssl. ++ panic!("Too many read/write round trips in handshake!!"); ++ } ++ let result = stream.ssl_write(b"GET /\r\n\r\n"); ++ match result { ++ Ok(n) => { ++ assert_eq!(n, 9); ++ break; ++ } ++ Err(Error::WantRead(..)) => { ++ assert!(wait_io(stream.get_ref(), true, 1000)); ++ } ++ Err(Error::WantWrite(..)) => { ++ assert!(wait_io(stream.get_ref(), false, 1000)); ++ } ++ Err(other) => { ++ panic!("Unexpected SSL Error: {:?}", other); ++ } ++ } ++ } ++ let mut input_buffer = [0u8; 1500]; ++ let result = stream.ssl_read(&mut input_buffer); ++ let bytes_read = match result { ++ Ok(n) => { ++ // This branch is unlikely, but on an overloaded VM with ++ // unlucky context switching, the response could actually ++ // be in the receive buffer before we issue the read() syscall... ++ n ++ } ++ Err(Error::WantRead(..)) => { ++ assert!(wait_io(stream.get_ref(), true, 3000)); ++ // Second read should return application data. ++ stream.read(&mut input_buffer).unwrap() ++ } ++ Err(other) => { ++ panic!("Unexpected SSL Error: {:?}", other); ++ } ++ }; ++ assert!(bytes_read >= 5); ++ assert_eq!(&input_buffer[..5], b"HTTP/"); ++} ++ ++#[test] ++#[should_panic(expected = "blammo")] ++fn write_panic() { ++ struct ExplodingStream(TcpStream); ++ ++ impl Read for ExplodingStream { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.0.read(buf) ++ } ++ } ++ ++ impl Write for ExplodingStream { ++ fn write(&mut self, _: &[u8]) -> io::Result { ++ panic!("blammo"); ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.0.flush() ++ } ++ } ++ ++ let (_s, stream) = Server::new(); ++ let stream = ExplodingStream(stream); ++ ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let _ = Ssl::new(&ctx.build()).unwrap().connect(stream); ++} ++ ++#[test] ++#[should_panic(expected = "blammo")] ++fn read_panic() { ++ struct ExplodingStream(TcpStream); ++ ++ impl Read for ExplodingStream { ++ fn read(&mut self, _: &mut [u8]) -> io::Result { ++ panic!("blammo"); ++ } ++ } ++ ++ impl Write for ExplodingStream { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.0.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.0.flush() ++ } ++ } ++ ++ let (_s, stream) = Server::new(); ++ let stream = ExplodingStream(stream); ++ ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let _ = Ssl::new(&ctx.build()).unwrap().connect(stream); ++} ++ ++#[test] ++#[should_panic(expected = "blammo")] ++fn flush_panic() { ++ struct ExplodingStream(TcpStream); ++ ++ impl Read for ExplodingStream { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.0.read(buf) ++ } ++ } ++ ++ impl Write for ExplodingStream { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.0.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ panic!("blammo"); ++ } ++ } ++ ++ let (_s, stream) = Server::new(); ++ let stream = ExplodingStream(stream); ++ ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let mut stream = Ssl::new(&ctx.build()) ++ .unwrap() ++ .connect(stream) ++ .ok() ++ .unwrap(); ++ let _ = stream.flush(); ++} ++ ++#[test] ++fn refcount_ssl_context() { ++ let mut ssl = { ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ssl::Ssl::new(&ctx.build()).unwrap() ++ }; ++ ++ { ++ let new_ctx_a = SslContext::builder(SslMethod::tls()).unwrap().build(); ++ let _new_ctx_b = ssl.set_ssl_context(&new_ctx_a); ++ } ++} ++ ++#[test] ++fn default_verify_paths() { ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_default_verify_paths().unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ let s = TcpStream::connect("google.com:443").unwrap(); ++ let mut socket = Ssl::new(&ctx.build()).unwrap().connect(s).unwrap(); ++ ++ socket.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap(); ++ let mut result = vec![]; ++ socket.read_to_end(&mut result).unwrap(); ++ ++ println!("{}", String::from_utf8_lossy(&result)); ++ assert!(result.starts_with(b"HTTP/1.0")); ++ assert!(result.ends_with(b"\r\n") || result.ends_with(b"")); ++} ++ ++#[test] ++fn add_extra_chain_cert() { ++ let cert = include_bytes!("../../../test/cert.pem"); ++ let cert = X509::from_pem(cert).unwrap(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.add_extra_chain_cert(cert).unwrap(); ++} ++ ++#[test] ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++fn verify_valid_hostname() { ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_default_verify_paths().unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ++ let mut ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.param_mut().set_hostflags( ++ X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS, ++ ); ++ ssl.param_mut().set_host("google.com").unwrap(); ++ ++ let s = TcpStream::connect("google.com:443").unwrap(); ++ let mut socket = ssl.connect(s).unwrap(); ++ ++ socket.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap(); ++ let mut result = vec![]; ++ socket.read_to_end(&mut result).unwrap(); ++ ++ println!("{}", String::from_utf8_lossy(&result)); ++ assert!(result.starts_with(b"HTTP/1.0")); ++ assert!(result.ends_with(b"\r\n") || result.ends_with(b"")); ++} ++ ++#[test] ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++fn verify_invalid_hostname() { ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_default_verify_paths().unwrap(); ++ ctx.set_verify(SSL_VERIFY_PEER); ++ ++ let mut ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.param_mut().set_hostflags( ++ X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS, ++ ); ++ ssl.param_mut().set_host("foobar.com").unwrap(); ++ ++ let s = TcpStream::connect("google.com:443").unwrap(); ++ assert!(ssl.connect(s).is_err()); ++} ++ ++#[test] ++fn connector_valid_hostname() { ++ let connector = SslConnectorBuilder::new(SslMethod::tls()).unwrap().build(); ++ ++ let s = TcpStream::connect("google.com:443").unwrap(); ++ let mut socket = connector.connect("google.com", s).unwrap(); ++ ++ socket.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap(); ++ let mut result = vec![]; ++ socket.read_to_end(&mut result).unwrap(); ++ ++ println!("{}", String::from_utf8_lossy(&result)); ++ assert!(result.starts_with(b"HTTP/1.0")); ++ assert!(result.ends_with(b"\r\n") || result.ends_with(b"")); ++} ++ ++#[test] ++fn connector_invalid_hostname() { ++ let connector = SslConnectorBuilder::new(SslMethod::tls()).unwrap().build(); ++ ++ let s = TcpStream::connect("google.com:443").unwrap(); ++ assert!(connector.connect("foobar.com", s).is_err()); ++} ++ ++#[test] ++fn connector_invalid_no_hostname_verification() { ++ let connector = SslConnectorBuilder::new(SslMethod::tls()).unwrap().build(); ++ ++ let s = TcpStream::connect("google.com:443").unwrap(); ++ connector.danger_connect_without_providing_domain_for_certificate_verification_and_server_name_indication(s) ++ .unwrap(); ++} ++ ++#[test] ++fn connector_no_hostname_still_verifies() { ++ let (_s, tcp) = Server::new(); ++ ++ let connector = SslConnectorBuilder::new(SslMethod::tls()).unwrap().build(); ++ ++ assert!(connector.danger_connect_without_providing_domain_for_certificate_verification_and_server_name_indication(tcp) ++ .is_err()); ++} ++ ++#[test] ++fn connector_no_hostname_can_disable_verify() { ++ let (_s, tcp) = Server::new(); ++ ++ let mut connector = SslConnectorBuilder::new(SslMethod::tls()).unwrap(); ++ connector.builder_mut().set_verify(SSL_VERIFY_NONE); ++ let connector = connector.build(); ++ ++ connector.danger_connect_without_providing_domain_for_certificate_verification_and_server_name_indication(tcp).unwrap(); ++} ++ ++#[test] ++fn connector_client_server_mozilla_intermediate() { ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let port = listener.local_addr().unwrap().port(); ++ ++ let t = thread::spawn(move || { ++ let key = PKey::private_key_from_pem(KEY).unwrap(); ++ let cert = X509::from_pem(CERT).unwrap(); ++ let connector = ++ SslAcceptorBuilder::mozilla_intermediate(SslMethod::tls(), &key, &cert, None::) ++ .unwrap() ++ .build(); ++ let stream = listener.accept().unwrap().0; ++ let mut stream = connector.accept(stream).unwrap(); ++ ++ stream.write_all(b"hello").unwrap(); ++ }); ++ ++ let mut connector = SslConnectorBuilder::new(SslMethod::tls()).unwrap(); ++ connector ++ .builder_mut() ++ .set_ca_file("test/root-ca.pem") ++ .unwrap(); ++ let connector = connector.build(); ++ ++ let stream = TcpStream::connect(("127.0.0.1", port)).unwrap(); ++ let mut stream = connector.connect("foobar.com", stream).unwrap(); ++ ++ let mut buf = [0; 5]; ++ stream.read_exact(&mut buf).unwrap(); ++ assert_eq!(b"hello", &buf); ++ ++ t.join().unwrap(); ++} ++ ++#[test] ++fn connector_client_server_mozilla_modern() { ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let port = listener.local_addr().unwrap().port(); ++ ++ let t = thread::spawn(move || { ++ let key = PKey::private_key_from_pem(KEY).unwrap(); ++ let cert = X509::from_pem(CERT).unwrap(); ++ let connector = ++ SslAcceptorBuilder::mozilla_modern(SslMethod::tls(), &key, &cert, None::) ++ .unwrap() ++ .build(); ++ let stream = listener.accept().unwrap().0; ++ let mut stream = connector.accept(stream).unwrap(); ++ ++ stream.write_all(b"hello").unwrap(); ++ }); ++ ++ let mut connector = SslConnectorBuilder::new(SslMethod::tls()).unwrap(); ++ connector ++ .builder_mut() ++ .set_ca_file("test/root-ca.pem") ++ .unwrap(); ++ let connector = connector.build(); ++ ++ let stream = TcpStream::connect(("127.0.0.1", port)).unwrap(); ++ let mut stream = connector.connect("foobar.com", stream).unwrap(); ++ ++ let mut buf = [0; 5]; ++ stream.read_exact(&mut buf).unwrap(); ++ assert_eq!(b"hello", &buf); ++ ++ t.join().unwrap(); ++} ++ ++#[test] ++fn shutdown() { ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let port = listener.local_addr().unwrap().port(); ++ ++ thread::spawn(move || { ++ let stream = listener.accept().unwrap().0; ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.set_private_key_file(&Path::new("test/key.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ let ssl = Ssl::new(&ctx.build()).unwrap(); ++ let mut stream = ssl.accept(stream).unwrap(); ++ ++ stream.write_all(b"hello").unwrap(); ++ let mut buf = [0; 1]; ++ assert_eq!(stream.read(&mut buf).unwrap(), 0); ++ assert_eq!(stream.shutdown().unwrap(), ShutdownResult::Received); ++ }); ++ ++ let stream = TcpStream::connect(("127.0.0.1", port)).unwrap(); ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ let ssl = Ssl::new(&ctx.build()).unwrap(); ++ let mut stream = ssl.connect(stream).unwrap(); ++ ++ let mut buf = [0; 5]; ++ stream.read_exact(&mut buf).unwrap(); ++ assert_eq!(b"hello", &buf); ++ ++ assert_eq!(stream.shutdown().unwrap(), ShutdownResult::Sent); ++ assert_eq!(stream.shutdown().unwrap(), ShutdownResult::Received); ++} ++ ++#[test] ++fn client_ca_list() { ++ let names = X509Name::load_client_ca_file("test/root-ca.pem").unwrap(); ++ assert_eq!(names.len(), 1); ++ ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_client_ca_list(names); ++} ++ ++#[test] ++fn cert_store() { ++ let (_s, tcp) = Server::new(); ++ ++ let cert = X509::from_pem(ROOT_CERT).unwrap(); ++ ++ let mut ctx = SslConnectorBuilder::new(SslMethod::tls()).unwrap(); ++ ctx.builder_mut().cert_store_mut().add_cert(cert).unwrap(); ++ let ctx = ctx.build(); ++ ++ ctx.connect("foobar.com", tcp).unwrap(); ++} ++ ++#[test] ++fn tmp_dh_callback() { ++ static CALLED_BACK: AtomicBool = ATOMIC_BOOL_INIT; ++ ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let port = listener.local_addr().unwrap().port(); ++ ++ thread::spawn(move || { ++ let stream = listener.accept().unwrap().0; ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.set_private_key_file(&Path::new("test/key.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.set_tmp_dh_callback(|_, _, _| { ++ CALLED_BACK.store(true, Ordering::SeqCst); ++ let dh = include_bytes!("../../../test/dhparams.pem"); ++ Dh::from_pem(dh) ++ }); ++ let ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.accept(stream).unwrap(); ++ }); ++ ++ let stream = TcpStream::connect(("127.0.0.1", port)).unwrap(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_cipher_list("EDH").unwrap(); ++ let ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.connect(stream).unwrap(); ++ ++ assert!(CALLED_BACK.load(Ordering::SeqCst)); ++} ++ ++#[test] ++#[cfg(any(all(feature = "v101", ossl101, not(libressl261)), all(feature = "v102", ossl102)))] ++fn tmp_ecdh_callback() { ++ use ec::EcKey; ++ use nid; ++ ++ static CALLED_BACK: AtomicBool = ATOMIC_BOOL_INIT; ++ ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let port = listener.local_addr().unwrap().port(); ++ ++ thread::spawn(move || { ++ let stream = listener.accept().unwrap().0; ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.set_private_key_file(&Path::new("test/key.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.set_tmp_ecdh_callback(|_, _, _| { ++ CALLED_BACK.store(true, Ordering::SeqCst); ++ EcKey::new_by_curve_name(nid::X9_62_PRIME256V1) ++ }); ++ let ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.accept(stream).unwrap(); ++ }); ++ ++ let stream = TcpStream::connect(("127.0.0.1", port)).unwrap(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_cipher_list("ECDH").unwrap(); ++ let ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.connect(stream).unwrap(); ++ ++ assert!(CALLED_BACK.load(Ordering::SeqCst)); ++} ++ ++#[test] ++fn tmp_dh_callback_ssl() { ++ static CALLED_BACK: AtomicBool = ATOMIC_BOOL_INIT; ++ ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let port = listener.local_addr().unwrap().port(); ++ ++ thread::spawn(move || { ++ let stream = listener.accept().unwrap().0; ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.set_private_key_file(&Path::new("test/key.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ let mut ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.set_tmp_dh_callback(|_, _, _| { ++ CALLED_BACK.store(true, Ordering::SeqCst); ++ let dh = include_bytes!("../../../test/dhparams.pem"); ++ Dh::from_pem(dh) ++ }); ++ ssl.accept(stream).unwrap(); ++ }); ++ ++ let stream = TcpStream::connect(("127.0.0.1", port)).unwrap(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_cipher_list("EDH").unwrap(); ++ let ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.connect(stream).unwrap(); ++ ++ assert!(CALLED_BACK.load(Ordering::SeqCst)); ++} ++ ++#[test] ++#[cfg(any(all(feature = "v101", ossl101, not(libressl261)), all(feature = "v102", ossl102)))] ++fn tmp_ecdh_callback_ssl() { ++ use ec::EcKey; ++ use nid; ++ ++ static CALLED_BACK: AtomicBool = ATOMIC_BOOL_INIT; ++ ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let port = listener.local_addr().unwrap().port(); ++ ++ thread::spawn(move || { ++ let stream = listener.accept().unwrap().0; ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.set_private_key_file(&Path::new("test/key.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ let mut ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.set_tmp_ecdh_callback(|_, _, _| { ++ CALLED_BACK.store(true, Ordering::SeqCst); ++ EcKey::new_by_curve_name(nid::X9_62_PRIME256V1) ++ }); ++ ssl.accept(stream).unwrap(); ++ }); ++ ++ let stream = TcpStream::connect(("127.0.0.1", port)).unwrap(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_cipher_list("ECDH").unwrap(); ++ let ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.connect(stream).unwrap(); ++ ++ assert!(CALLED_BACK.load(Ordering::SeqCst)); ++} ++ ++#[test] ++fn idle_session() { ++ let ctx = SslContext::builder(SslMethod::tls()).unwrap().build(); ++ let ssl = Ssl::new(&ctx).unwrap(); ++ assert!(ssl.session().is_none()); ++} ++ ++#[test] ++fn active_session() { ++ let connector = SslConnectorBuilder::new(SslMethod::tls()).unwrap().build(); ++ ++ let s = TcpStream::connect("google.com:443").unwrap(); ++ let socket = connector.connect("google.com", s).unwrap(); ++ let session = socket.ssl().session().unwrap(); ++ let len = session.master_key_len(); ++ let mut buf = vec![0; len - 1]; ++ let copied = session.master_key(&mut buf); ++ assert_eq!(copied, buf.len()); ++ let mut buf = vec![0; len + 1]; ++ let copied = session.master_key(&mut buf); ++ assert_eq!(copied, len); ++} ++ ++#[test] ++fn status_callbacks() { ++ static CALLED_BACK_SERVER: AtomicBool = ATOMIC_BOOL_INIT; ++ static CALLED_BACK_CLIENT: AtomicBool = ATOMIC_BOOL_INIT; ++ ++ let listener = TcpListener::bind("127.0.0.1:0").unwrap(); ++ let port = listener.local_addr().unwrap().port(); ++ ++ let guard = thread::spawn(move || { ++ let stream = listener.accept().unwrap().0; ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.set_private_key_file(&Path::new("test/key.pem"), X509_FILETYPE_PEM) ++ .unwrap(); ++ ctx.set_status_callback(|ssl| { ++ CALLED_BACK_SERVER.store(true, Ordering::SeqCst); ++ let response = OcspResponse::create(RESPONSE_STATUS_UNAUTHORIZED, None).unwrap(); ++ let response = response.to_der().unwrap(); ++ ssl.set_ocsp_status(&response).unwrap(); ++ Ok(true) ++ }).unwrap(); ++ let ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.accept(stream).unwrap(); ++ }); ++ ++ let stream = TcpStream::connect(("127.0.0.1", port)).unwrap(); ++ let mut ctx = SslContext::builder(SslMethod::tls()).unwrap(); ++ ctx.set_status_callback(|ssl| { ++ CALLED_BACK_CLIENT.store(true, Ordering::SeqCst); ++ let response = OcspResponse::from_der(ssl.ocsp_status().unwrap()).unwrap(); ++ assert_eq!(response.status(), RESPONSE_STATUS_UNAUTHORIZED); ++ Ok(true) ++ }).unwrap(); ++ let mut ssl = Ssl::new(&ctx.build()).unwrap(); ++ ssl.set_status_type(STATUS_TYPE_OCSP).unwrap(); ++ ssl.connect(stream).unwrap(); ++ ++ assert!(CALLED_BACK_SERVER.load(Ordering::SeqCst)); ++ assert!(CALLED_BACK_CLIENT.load(Ordering::SeqCst)); ++ ++ guard.join().unwrap(); ++} ++ ++fn _check_kinds() { ++ fn is_send() {} ++ fn is_sync() {} ++ ++ is_send::>(); ++ is_sync::>(); ++} diff --cc vendor/openssl-0.9.19/src/ssl/tests/select.rs index 000000000,000000000..36d5ed495 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/ssl/tests/select.rs @@@ -1,0 -1,0 +1,74 @@@ ++use libc; ++pub use self::imp::*; ++ ++#[cfg(unix)] ++mod imp { ++ use std::os::unix::prelude::*; ++ use std::io; ++ use libc; ++ ++ pub use libc::fd_set; ++ ++ pub fn fd_set(set: &mut fd_set, f: &F) { ++ unsafe { ++ libc::FD_SET(f.as_raw_fd(), set); ++ } ++ } ++ ++ pub unsafe fn select( ++ max: &F, ++ read: *mut fd_set, ++ write: *mut fd_set, ++ error: *mut fd_set, ++ timeout_ms: u32, ++ ) -> io::Result { ++ let mut timeout = libc::timeval { ++ tv_sec: (timeout_ms / 1000) as libc::time_t, ++ tv_usec: (timeout_ms % 1000 * 1000) as libc::suseconds_t, ++ }; ++ let rc = libc::select(max.as_raw_fd() + 1, read, write, error, &mut timeout); ++ if rc < 0 { ++ Err(io::Error::last_os_error()) ++ } else { ++ Ok(rc != 0) ++ } ++ } ++} ++ ++#[cfg(windows)] ++mod imp { ++ extern crate winapi; ++ extern crate ws2_32; ++ ++ use std::os::windows::prelude::*; ++ use std::io; ++ use libc::{c_uint, c_long}; ++ use self::winapi::SOCKET; ++ use self::winapi::winsock2; ++ ++ pub use self::winapi::winsock2::fd_set; ++ ++ pub fn fd_set(set: &mut fd_set, f: &F) { ++ set.fd_array[set.fd_count as usize] = f.as_raw_socket(); ++ set.fd_count += 1; ++ } ++ ++ pub unsafe fn select( ++ _max: &F, ++ read: *mut fd_set, ++ write: *mut fd_set, ++ error: *mut fd_set, ++ timeout_ms: u32, ++ ) -> io::Result { ++ let mut timeout = winsock2::timeval { ++ tv_sec: (timeout_ms / 1000) as c_long, ++ tv_usec: (timeout_ms % 1000 * 1000) as c_long, ++ }; ++ let rc = ws2_32::select(1, read, write, error, &mut timeout); ++ if rc < 0 { ++ Err(io::Error::last_os_error()) ++ } else { ++ Ok(rc != 0) ++ } ++ } ++} diff --cc vendor/openssl-0.9.19/src/stack.rs index 000000000,000000000..d20d95f7d new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/stack.rs @@@ -1,0 -1,0 +1,360 @@@ ++use foreign_types::{ForeignTypeRef, ForeignType, Opaque}; ++use libc::c_int; ++use std::borrow::Borrow; ++use std::convert::AsRef; ++use std::iter; ++use std::marker::PhantomData; ++use std::mem; ++use ffi; ++ ++use {cvt, cvt_p}; ++use error::ErrorStack; ++use std::ops::{Deref, DerefMut, Index, IndexMut}; ++ ++#[cfg(ossl10x)] ++use ffi::{sk_pop as OPENSSL_sk_pop, sk_free as OPENSSL_sk_free, sk_num as OPENSSL_sk_num, ++ sk_value as OPENSSL_sk_value, _STACK as OPENSSL_STACK, ++ sk_new_null as OPENSSL_sk_new_null, sk_push as OPENSSL_sk_push}; ++#[cfg(ossl110)] ++use ffi::{OPENSSL_sk_pop, OPENSSL_sk_free, OPENSSL_sk_num, OPENSSL_sk_value, OPENSSL_STACK, ++ OPENSSL_sk_new_null, OPENSSL_sk_push}; ++ ++/// Trait implemented by types which can be placed in a stack. ++/// ++/// It should not be implemented for any type outside of this crate. ++pub trait Stackable: ForeignType { ++ /// The C stack type for this element. ++ /// ++ /// Generally called `stack_st_{ELEMENT_TYPE}`, normally hidden by the ++ /// `STACK_OF(ELEMENT_TYPE)` macro in the OpenSSL API. ++ type StackType; ++} ++ ++/// An owned stack of `T`. ++pub struct Stack(*mut T::StackType); ++ ++impl Stack { ++ pub fn new() -> Result, ErrorStack> { ++ unsafe { ++ ffi::init(); ++ let ptr = try!(cvt_p(OPENSSL_sk_new_null())); ++ Ok(Stack(ptr as *mut _)) ++ } ++ } ++} ++ ++impl Drop for Stack { ++ fn drop(&mut self) { ++ unsafe { ++ while let Some(_) = self.pop() {} ++ OPENSSL_sk_free(self.0 as *mut _); ++ } ++ } ++} ++ ++impl iter::IntoIterator for Stack { ++ type IntoIter = IntoIter; ++ type Item = T; ++ ++ fn into_iter(self) -> IntoIter { ++ let it = IntoIter { ++ stack: self.0, ++ idx: 0, ++ }; ++ mem::forget(self); ++ it ++ } ++} ++ ++impl AsRef> for Stack { ++ fn as_ref(&self) -> &StackRef { ++ &*self ++ } ++} ++ ++impl Borrow> for Stack { ++ fn borrow(&self) -> &StackRef { ++ &*self ++ } ++} ++ ++impl ForeignType for Stack { ++ type CType = T::StackType; ++ type Ref = StackRef; ++ ++ #[inline] ++ unsafe fn from_ptr(ptr: *mut T::StackType) -> Stack { ++ assert!( ++ !ptr.is_null(), ++ "Must not instantiate a Stack from a null-ptr - use Stack::new() in \ ++ that case" ++ ); ++ Stack(ptr) ++ } ++ ++ #[inline] ++ fn as_ptr(&self) -> *mut T::StackType { ++ self.0 ++ } ++} ++ ++impl Deref for Stack { ++ type Target = StackRef; ++ ++ fn deref(&self) -> &StackRef { ++ unsafe { StackRef::from_ptr(self.0) } ++ } ++} ++ ++impl DerefMut for Stack { ++ fn deref_mut(&mut self) -> &mut StackRef { ++ unsafe { StackRef::from_ptr_mut(self.0) } ++ } ++} ++ ++pub struct IntoIter { ++ stack: *mut T::StackType, ++ idx: c_int, ++} ++ ++impl IntoIter { ++ fn stack_len(&self) -> c_int { ++ unsafe { OPENSSL_sk_num(self.stack as *mut _) } ++ } ++} ++ ++impl Drop for IntoIter { ++ fn drop(&mut self) { ++ unsafe { ++ while let Some(_) = self.next() {} ++ OPENSSL_sk_free(self.stack as *mut _); ++ } ++ } ++} ++ ++impl Iterator for IntoIter { ++ type Item = T; ++ ++ fn next(&mut self) -> Option { ++ unsafe { ++ if self.idx == self.stack_len() { ++ None ++ } else { ++ let ptr = OPENSSL_sk_value(self.stack as *mut _, self.idx); ++ self.idx += 1; ++ Some(T::from_ptr(ptr as *mut _)) ++ } ++ } ++ } ++ ++ fn size_hint(&self) -> (usize, Option) { ++ let size = (self.stack_len() - self.idx) as usize; ++ (size, Some(size)) ++ } ++} ++ ++impl ExactSizeIterator for IntoIter {} ++ ++pub struct StackRef(Opaque, PhantomData); ++ ++impl ForeignTypeRef for StackRef { ++ type CType = T::StackType; ++} ++ ++impl StackRef { ++ fn as_stack(&self) -> *mut OPENSSL_STACK { ++ self.as_ptr() as *mut _ ++ } ++ ++ /// Returns the number of items in the stack ++ pub fn len(&self) -> usize { ++ unsafe { OPENSSL_sk_num(self.as_stack()) as usize } ++ } ++ ++ pub fn iter(&self) -> Iter { ++ // Unfortunately we can't simply convert the stack into a ++ // slice and use that because OpenSSL 1.1.0 doesn't directly ++ // expose the stack data (we have to use `OPENSSL_sk_value` ++ // instead). We have to rewrite the entire iteration framework ++ // instead. ++ ++ Iter { ++ stack: self, ++ pos: 0, ++ } ++ } ++ ++ pub fn iter_mut(&mut self) -> IterMut { ++ IterMut { ++ stack: self, ++ pos: 0, ++ } ++ } ++ ++ /// Returns a reference to the element at the given index in the ++ /// stack or `None` if the index is out of bounds ++ pub fn get(&self, idx: usize) -> Option<&T::Ref> { ++ unsafe { ++ if idx >= self.len() { ++ return None; ++ } ++ ++ Some(T::Ref::from_ptr(self._get(idx))) ++ } ++ } ++ ++ /// Returns a mutable reference to the element at the given index in the ++ /// stack or `None` if the index is out of bounds ++ pub fn get_mut(&mut self, idx: usize) -> Option<&mut T::Ref> { ++ unsafe { ++ if idx >= self.len() { ++ return None; ++ } ++ ++ Some(T::Ref::from_ptr_mut(self._get(idx))) ++ } ++ } ++ ++ /// Pushes a value onto the top of the stack. ++ pub fn push(&mut self, data: T) -> Result<(), ErrorStack> { ++ unsafe { ++ try!(cvt( ++ OPENSSL_sk_push(self.as_stack(), data.as_ptr() as *mut _), ++ )); ++ mem::forget(data); ++ Ok(()) ++ } ++ } ++ ++ /// Removes the last element from the stack and returns it. ++ pub fn pop(&mut self) -> Option { ++ unsafe { ++ let ptr = OPENSSL_sk_pop(self.as_stack()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(T::from_ptr(ptr as *mut _)) ++ } ++ } ++ } ++ ++ unsafe fn _get(&self, idx: usize) -> *mut T::CType { ++ OPENSSL_sk_value(self.as_stack(), idx as c_int) as *mut _ ++ } ++} ++ ++impl Index for StackRef { ++ type Output = T::Ref; ++ ++ fn index(&self, index: usize) -> &T::Ref { ++ self.get(index).unwrap() ++ } ++} ++ ++impl IndexMut for StackRef { ++ fn index_mut(&mut self, index: usize) -> &mut T::Ref { ++ self.get_mut(index).unwrap() ++ } ++} ++ ++impl<'a, T: Stackable> iter::IntoIterator for &'a StackRef { ++ type Item = &'a T::Ref; ++ type IntoIter = Iter<'a, T>; ++ ++ fn into_iter(self) -> Iter<'a, T> { ++ self.iter() ++ } ++} ++ ++impl<'a, T: Stackable> iter::IntoIterator for &'a mut StackRef { ++ type Item = &'a mut T::Ref; ++ type IntoIter = IterMut<'a, T>; ++ ++ fn into_iter(self) -> IterMut<'a, T> { ++ self.iter_mut() ++ } ++} ++ ++impl<'a, T: Stackable> iter::IntoIterator for &'a Stack { ++ type Item = &'a T::Ref; ++ type IntoIter = Iter<'a, T>; ++ ++ fn into_iter(self) -> Iter<'a, T> { ++ self.iter() ++ } ++} ++ ++impl<'a, T: Stackable> iter::IntoIterator for &'a mut Stack { ++ type Item = &'a mut T::Ref; ++ type IntoIter = IterMut<'a, T>; ++ ++ fn into_iter(self) -> IterMut<'a, T> { ++ self.iter_mut() ++ } ++} ++ ++/// An iterator over the stack's contents. ++pub struct Iter<'a, T: Stackable> ++where ++ T: 'a, ++{ ++ stack: &'a StackRef, ++ pos: usize, ++} ++ ++impl<'a, T: Stackable> iter::Iterator for Iter<'a, T> { ++ type Item = &'a T::Ref; ++ ++ fn next(&mut self) -> Option<&'a T::Ref> { ++ let n = self.stack.get(self.pos); ++ ++ if n.is_some() { ++ self.pos += 1; ++ } ++ ++ n ++ } ++ ++ fn size_hint(&self) -> (usize, Option) { ++ let rem = self.stack.len() - self.pos; ++ ++ (rem, Some(rem)) ++ } ++} ++ ++impl<'a, T: Stackable> iter::ExactSizeIterator for Iter<'a, T> {} ++ ++/// A mutable iterator over the stack's contents. ++pub struct IterMut<'a, T: Stackable + 'a> { ++ stack: &'a mut StackRef, ++ pos: usize, ++} ++ ++impl<'a, T: Stackable> iter::Iterator for IterMut<'a, T> { ++ type Item = &'a mut T::Ref; ++ ++ fn next(&mut self) -> Option<&'a mut T::Ref> { ++ if self.pos >= self.stack.len() { ++ None ++ } else { ++ // Rust won't allow us to get a mutable reference into ++ // `stack` in this situation since it can't statically ++ // guarantee that we won't return several references to ++ // the same object, so we have to use unsafe code for ++ // mutable iterators. ++ let n = unsafe { Some(T::Ref::from_ptr_mut(self.stack._get(self.pos))) }; ++ ++ self.pos += 1; ++ ++ n ++ } ++ } ++ ++ fn size_hint(&self) -> (usize, Option) { ++ let rem = self.stack.len() - self.pos; ++ ++ (rem, Some(rem)) ++ } ++} ++ ++impl<'a, T: Stackable> iter::ExactSizeIterator for IterMut<'a, T> {} diff --cc vendor/openssl-0.9.19/src/string.rs index 000000000,000000000..0324d5776 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/string.rs @@@ -1,0 -1,0 +1,82 @@@ ++use ffi; ++use foreign_types::{ForeignType, ForeignTypeRef}; ++use libc::{c_char, c_void}; ++use std::fmt; ++use std::ffi::CStr; ++use std::ops::Deref; ++use std::str; ++ ++use stack::Stackable; ++ ++foreign_type! { ++ type CType = c_char; ++ fn drop = free; ++ ++ pub struct OpensslString; ++ pub struct OpensslStringRef; ++} ++ ++impl OpensslString { ++ #[deprecated(note = "use from_ptr", since = "0.9.7")] ++ pub unsafe fn from_raw_parts(buf: *mut u8, _: usize) -> OpensslString { ++ OpensslString::from_ptr(buf as *mut c_char) ++ } ++ ++ #[deprecated(note = "use from_ptr", since = "0.9.7")] ++ pub unsafe fn from_null_terminated(buf: *mut c_char) -> OpensslString { ++ OpensslString::from_ptr(buf) ++ } ++} ++ ++impl fmt::Display for OpensslString { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ fmt::Display::fmt(&**self, f) ++ } ++} ++ ++impl fmt::Debug for OpensslString { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ fmt::Debug::fmt(&**self, f) ++ } ++} ++ ++impl Stackable for OpensslString { ++ type StackType = ffi::stack_st_OPENSSL_STRING; ++} ++ ++impl Deref for OpensslStringRef { ++ type Target = str; ++ ++ fn deref(&self) -> &str { ++ unsafe { ++ let slice = CStr::from_ptr(self.as_ptr()).to_bytes(); ++ str::from_utf8_unchecked(slice) ++ } ++ } ++} ++ ++impl fmt::Display for OpensslStringRef { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ fmt::Display::fmt(&**self, f) ++ } ++} ++ ++impl fmt::Debug for OpensslStringRef { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ fmt::Debug::fmt(&**self, f) ++ } ++} ++ ++#[cfg(not(ossl110))] ++unsafe fn free(buf: *mut c_char) { ++ ::ffi::CRYPTO_free(buf as *mut c_void); ++} ++ ++#[cfg(ossl110)] ++unsafe fn free(buf: *mut c_char) { ++ ::ffi::CRYPTO_free( ++ buf as *mut c_void, ++ concat!(file!(), "\0").as_ptr() as *const c_char, ++ line!() as ::libc::c_int, ++ ); ++} diff --cc vendor/openssl-0.9.19/src/symm.rs index 000000000,000000000..f593126a3 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/symm.rs @@@ -1,0 -1,0 +1,981 @@@ ++use std::cmp; ++use std::ptr; ++use libc::c_int; ++use ffi; ++ ++use {cvt, cvt_p}; ++use error::ErrorStack; ++ ++#[derive(Copy, Clone)] ++pub enum Mode { ++ Encrypt, ++ Decrypt, ++} ++ ++#[derive(Copy, Clone)] ++pub struct Cipher(*const ffi::EVP_CIPHER); ++ ++impl Cipher { ++ pub fn aes_128_ecb() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_128_ecb()) } ++ } ++ ++ pub fn aes_128_cbc() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_128_cbc()) } ++ } ++ ++ pub fn aes_128_xts() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_128_xts()) } ++ } ++ ++ pub fn aes_128_ctr() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_128_ctr()) } ++ } ++ ++ pub fn aes_128_cfb1() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_128_cfb1()) } ++ } ++ ++ pub fn aes_128_cfb128() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_128_cfb128()) } ++ } ++ ++ pub fn aes_128_cfb8() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_128_cfb8()) } ++ } ++ ++ pub fn aes_128_gcm() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_128_gcm()) } ++ } ++ ++ pub fn aes_256_ecb() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_256_ecb()) } ++ } ++ ++ pub fn aes_256_cbc() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_256_cbc()) } ++ } ++ ++ pub fn aes_256_xts() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_256_xts()) } ++ } ++ ++ pub fn aes_256_ctr() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_256_ctr()) } ++ } ++ ++ pub fn aes_256_cfb1() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_256_cfb1()) } ++ } ++ ++ pub fn aes_256_cfb128() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_256_cfb128()) } ++ } ++ ++ pub fn aes_256_cfb8() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_256_cfb8()) } ++ } ++ ++ pub fn aes_256_gcm() -> Cipher { ++ unsafe { Cipher(ffi::EVP_aes_256_gcm()) } ++ } ++ ++ pub fn bf_cbc() -> Cipher { ++ unsafe { Cipher(ffi::EVP_bf_cbc()) } ++ } ++ ++ pub fn bf_ecb() -> Cipher { ++ unsafe { Cipher(ffi::EVP_bf_ecb()) } ++ } ++ ++ pub fn bf_cfb64() -> Cipher { ++ unsafe { Cipher(ffi::EVP_bf_cfb64()) } ++ } ++ ++ pub fn bf_ofb() -> Cipher { ++ unsafe { Cipher(ffi::EVP_bf_ofb()) } ++ } ++ ++ pub fn des_cbc() -> Cipher { ++ unsafe { Cipher(ffi::EVP_des_cbc()) } ++ } ++ ++ pub fn des_ecb() -> Cipher { ++ unsafe { Cipher(ffi::EVP_des_ecb()) } ++ } ++ ++ pub fn rc4() -> Cipher { ++ unsafe { Cipher(ffi::EVP_rc4()) } ++ } ++ ++ /// Requires the `v110` feature and OpenSSL 1.1.0. ++ #[cfg(all(ossl110, feature = "v110"))] ++ pub fn chacha20() -> Cipher { ++ unsafe { Cipher(ffi::EVP_chacha20()) } ++ } ++ ++ /// Requires the `v110` feature and OpenSSL 1.1.0. ++ #[cfg(all(ossl110, feature = "v110"))] ++ pub fn chacha20_poly1305() -> Cipher { ++ unsafe { Cipher(ffi::EVP_chacha20_poly1305()) } ++ } ++ ++ pub unsafe fn from_ptr(ptr: *const ffi::EVP_CIPHER) -> Cipher { ++ Cipher(ptr) ++ } ++ ++ pub fn as_ptr(&self) -> *const ffi::EVP_CIPHER { ++ self.0 ++ } ++ ++ /// Returns the length of keys used with this cipher. ++ pub fn key_len(&self) -> usize { ++ unsafe { EVP_CIPHER_key_length(self.0) as usize } ++ } ++ ++ /// Returns the length of the IV used with this cipher, or `None` if the ++ /// cipher does not use an IV. ++ pub fn iv_len(&self) -> Option { ++ unsafe { ++ let len = EVP_CIPHER_iv_length(self.0) as usize; ++ if len == 0 { None } else { Some(len) } ++ } ++ } ++ ++ /// Returns the block size of the cipher. ++ /// ++ /// # Note ++ /// ++ /// Stream ciphers such as RC4 have a block size of 1. ++ pub fn block_size(&self) -> usize { ++ unsafe { EVP_CIPHER_block_size(self.0) as usize } ++ } ++} ++ ++/// Represents a symmetric cipher context. ++pub struct Crypter { ++ ctx: *mut ffi::EVP_CIPHER_CTX, ++ block_size: usize, ++} ++ ++impl Crypter { ++ /// Creates a new `Crypter`. ++ /// ++ /// # Panics ++ /// ++ /// Panics if an IV is required by the cipher but not provided. ++ pub fn new( ++ t: Cipher, ++ mode: Mode, ++ key: &[u8], ++ iv: Option<&[u8]>, ++ ) -> Result { ++ ffi::init(); ++ ++ unsafe { ++ let ctx = try!(cvt_p(ffi::EVP_CIPHER_CTX_new())); ++ let crypter = Crypter { ++ ctx: ctx, ++ block_size: t.block_size(), ++ }; ++ ++ let mode = match mode { ++ Mode::Encrypt => 1, ++ Mode::Decrypt => 0, ++ }; ++ ++ try!(cvt(ffi::EVP_CipherInit_ex( ++ crypter.ctx, ++ t.as_ptr(), ++ ptr::null_mut(), ++ ptr::null_mut(), ++ ptr::null_mut(), ++ mode, ++ ))); ++ ++ assert!(key.len() <= c_int::max_value() as usize); ++ try!(cvt(ffi::EVP_CIPHER_CTX_set_key_length( ++ crypter.ctx, ++ key.len() as c_int, ++ ))); ++ ++ let key = key.as_ptr() as *mut _; ++ let iv = match (iv, t.iv_len()) { ++ (Some(iv), Some(len)) => { ++ if iv.len() != len { ++ assert!(iv.len() <= c_int::max_value() as usize); ++ try!(cvt(ffi::EVP_CIPHER_CTX_ctrl( ++ crypter.ctx, ++ ffi::EVP_CTRL_GCM_SET_IVLEN, ++ iv.len() as c_int, ++ ptr::null_mut(), ++ ))); ++ } ++ iv.as_ptr() as *mut _ ++ } ++ (Some(_), None) | (None, None) => ptr::null_mut(), ++ (None, Some(_)) => panic!("an IV is required for this cipher"), ++ }; ++ try!(cvt(ffi::EVP_CipherInit_ex( ++ crypter.ctx, ++ ptr::null(), ++ ptr::null_mut(), ++ key, ++ iv, ++ mode, ++ ))); ++ ++ Ok(crypter) ++ } ++ } ++ ++ /// Enables or disables padding. ++ /// ++ /// If padding is disabled, total amount of data encrypted/decrypted must ++ /// be a multiple of the cipher's block size. ++ pub fn pad(&mut self, padding: bool) { ++ unsafe { ++ ffi::EVP_CIPHER_CTX_set_padding(self.ctx, padding as c_int); ++ } ++ } ++ ++ /// Sets the tag used to authenticate ciphertext in AEAD ciphers such as AES GCM. ++ /// ++ /// When decrypting cipher text using an AEAD cipher, this must be called before `finalize`. ++ pub fn set_tag(&mut self, tag: &[u8]) -> Result<(), ErrorStack> { ++ unsafe { ++ assert!(tag.len() <= c_int::max_value() as usize); ++ // NB: this constant is actually more general than just GCM. ++ cvt(ffi::EVP_CIPHER_CTX_ctrl( ++ self.ctx, ++ ffi::EVP_CTRL_GCM_SET_TAG, ++ tag.len() as c_int, ++ tag.as_ptr() as *mut _, ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Feeds Additional Authenticated Data (AAD) through the cipher. ++ /// ++ /// This can only be used with AEAD ciphers such as AES GCM. Data fed in is not encrypted, but ++ /// is factored into the authentication tag. It must be called before the first call to ++ /// `update`. ++ pub fn aad_update(&mut self, input: &[u8]) -> Result<(), ErrorStack> { ++ unsafe { ++ assert!(input.len() <= c_int::max_value() as usize); ++ let mut len = 0; ++ cvt(ffi::EVP_CipherUpdate( ++ self.ctx, ++ ptr::null_mut(), ++ &mut len, ++ input.as_ptr(), ++ input.len() as c_int, ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Feeds data from `input` through the cipher, writing encrypted/decrypted ++ /// bytes into `output`. ++ /// ++ /// The number of bytes written to `output` is returned. Note that this may ++ /// not be equal to the length of `input`. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `output.len() < input.len() + block_size` where ++ /// `block_size` is the block size of the cipher (see `Cipher::block_size`), ++ /// or if `output.len() > c_int::max_value()`. ++ pub fn update(&mut self, input: &[u8], output: &mut [u8]) -> Result { ++ unsafe { ++ assert!(output.len() >= input.len() + self.block_size); ++ assert!(output.len() <= c_int::max_value() as usize); ++ let mut outl = output.len() as c_int; ++ let inl = input.len() as c_int; ++ ++ try!(cvt(ffi::EVP_CipherUpdate( ++ self.ctx, ++ output.as_mut_ptr(), ++ &mut outl, ++ input.as_ptr(), ++ inl, ++ ))); ++ ++ Ok(outl as usize) ++ } ++ } ++ ++ /// Finishes the encryption/decryption process, writing any remaining data ++ /// to `output`. ++ /// ++ /// The number of bytes written to `output` is returned. ++ /// ++ /// `update` should not be called after this method. ++ /// ++ /// # Panics ++ /// ++ /// Panics if `output` is less than the cipher's block size. ++ pub fn finalize(&mut self, output: &mut [u8]) -> Result { ++ unsafe { ++ assert!(output.len() >= self.block_size); ++ let mut outl = cmp::min(output.len(), c_int::max_value() as usize) as c_int; ++ ++ try!(cvt(ffi::EVP_CipherFinal( ++ self.ctx, ++ output.as_mut_ptr(), ++ &mut outl, ++ ))); ++ ++ Ok(outl as usize) ++ } ++ } ++ ++ /// Retrieves the authentication tag used to authenticate ciphertext in AEAD ciphers such ++ /// as AES GCM. ++ /// ++ /// When encrypting data with an AEAD cipher, this must be called after `finalize`. ++ /// ++ /// The size of the buffer indicates the required size of the tag. While some ciphers support a ++ /// range of tag sizes, it is recommended to pick the maximum size. For AES GCM, this is 16 ++ /// bytes, for example. ++ pub fn get_tag(&self, tag: &mut [u8]) -> Result<(), ErrorStack> { ++ unsafe { ++ assert!(tag.len() <= c_int::max_value() as usize); ++ cvt(ffi::EVP_CIPHER_CTX_ctrl( ++ self.ctx, ++ ffi::EVP_CTRL_GCM_GET_TAG, ++ tag.len() as c_int, ++ tag.as_mut_ptr() as *mut _, ++ )).map(|_| ()) ++ } ++ } ++} ++ ++impl Drop for Crypter { ++ fn drop(&mut self) { ++ unsafe { ++ ffi::EVP_CIPHER_CTX_free(self.ctx); ++ } ++ } ++} ++ ++/// Encrypts data, using the specified crypter type in encrypt mode with the ++/// specified key and iv; returns the resulting (encrypted) data. ++pub fn encrypt( ++ t: Cipher, ++ key: &[u8], ++ iv: Option<&[u8]>, ++ data: &[u8], ++) -> Result, ErrorStack> { ++ cipher(t, Mode::Encrypt, key, iv, data) ++} ++ ++/// Decrypts data, using the specified crypter type in decrypt mode with the ++/// specified key and iv; returns the resulting (decrypted) data. ++pub fn decrypt( ++ t: Cipher, ++ key: &[u8], ++ iv: Option<&[u8]>, ++ data: &[u8], ++) -> Result, ErrorStack> { ++ cipher(t, Mode::Decrypt, key, iv, data) ++} ++ ++fn cipher( ++ t: Cipher, ++ mode: Mode, ++ key: &[u8], ++ iv: Option<&[u8]>, ++ data: &[u8], ++) -> Result, ErrorStack> { ++ let mut c = try!(Crypter::new(t, mode, key, iv)); ++ let mut out = vec![0; data.len() + t.block_size()]; ++ let count = try!(c.update(data, &mut out)); ++ let rest = try!(c.finalize(&mut out[count..])); ++ out.truncate(count + rest); ++ Ok(out) ++} ++ ++/// Like `encrypt`, but for AEAD ciphers such as AES GCM. ++/// ++/// Additional Authenticated Data can be provided in the `aad` field, and the authentication tag ++/// will be copied into the `tag` field. ++/// ++/// The size of the `tag` buffer indicates the required size of the tag. While some ciphers support ++/// a range of tag sizes, it is recommended to pick the maximum size. For AES GCM, this is 16 bytes, ++/// for example. ++pub fn encrypt_aead( ++ t: Cipher, ++ key: &[u8], ++ iv: Option<&[u8]>, ++ aad: &[u8], ++ data: &[u8], ++ tag: &mut [u8], ++) -> Result, ErrorStack> { ++ let mut c = try!(Crypter::new(t, Mode::Encrypt, key, iv)); ++ let mut out = vec![0; data.len() + t.block_size()]; ++ try!(c.aad_update(aad)); ++ let count = try!(c.update(data, &mut out)); ++ let rest = try!(c.finalize(&mut out[count..])); ++ try!(c.get_tag(tag)); ++ out.truncate(count + rest); ++ Ok(out) ++} ++ ++/// Like `decrypt`, but for AEAD ciphers such as AES GCM. ++/// ++/// Additional Authenticated Data can be provided in the `aad` field, and the authentication tag ++/// should be provided in the `tag` field. ++pub fn decrypt_aead( ++ t: Cipher, ++ key: &[u8], ++ iv: Option<&[u8]>, ++ aad: &[u8], ++ data: &[u8], ++ tag: &[u8], ++) -> Result, ErrorStack> { ++ let mut c = try!(Crypter::new(t, Mode::Decrypt, key, iv)); ++ let mut out = vec![0; data.len() + t.block_size()]; ++ try!(c.aad_update(aad)); ++ let count = try!(c.update(data, &mut out)); ++ try!(c.set_tag(tag)); ++ let rest = try!(c.finalize(&mut out[count..])); ++ out.truncate(count + rest); ++ Ok(out) ++} ++ ++#[cfg(ossl110)] ++use ffi::{EVP_CIPHER_iv_length, EVP_CIPHER_block_size, EVP_CIPHER_key_length}; ++ ++#[cfg(ossl10x)] ++#[allow(bad_style)] ++mod compat { ++ use libc::c_int; ++ use ffi::EVP_CIPHER; ++ ++ pub unsafe fn EVP_CIPHER_iv_length(ptr: *const EVP_CIPHER) -> c_int { ++ (*ptr).iv_len ++ } ++ ++ pub unsafe fn EVP_CIPHER_block_size(ptr: *const EVP_CIPHER) -> c_int { ++ (*ptr).block_size ++ } ++ ++ pub unsafe fn EVP_CIPHER_key_length(ptr: *const EVP_CIPHER) -> c_int { ++ (*ptr).key_len ++ } ++} ++#[cfg(ossl10x)] ++use self::compat::*; ++ ++#[cfg(test)] ++mod tests { ++ use hex::{FromHex, ToHex}; ++ use super::*; ++ ++ // Test vectors from FIPS-197: ++ // http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf ++ #[test] ++ fn test_aes_256_ecb() { ++ let k0 = [ ++ 0x00u8, ++ 0x01u8, ++ 0x02u8, ++ 0x03u8, ++ 0x04u8, ++ 0x05u8, ++ 0x06u8, ++ 0x07u8, ++ 0x08u8, ++ 0x09u8, ++ 0x0au8, ++ 0x0bu8, ++ 0x0cu8, ++ 0x0du8, ++ 0x0eu8, ++ 0x0fu8, ++ 0x10u8, ++ 0x11u8, ++ 0x12u8, ++ 0x13u8, ++ 0x14u8, ++ 0x15u8, ++ 0x16u8, ++ 0x17u8, ++ 0x18u8, ++ 0x19u8, ++ 0x1au8, ++ 0x1bu8, ++ 0x1cu8, ++ 0x1du8, ++ 0x1eu8, ++ 0x1fu8, ++ ]; ++ let p0 = [ ++ 0x00u8, ++ 0x11u8, ++ 0x22u8, ++ 0x33u8, ++ 0x44u8, ++ 0x55u8, ++ 0x66u8, ++ 0x77u8, ++ 0x88u8, ++ 0x99u8, ++ 0xaau8, ++ 0xbbu8, ++ 0xccu8, ++ 0xddu8, ++ 0xeeu8, ++ 0xffu8, ++ ]; ++ let c0 = [ ++ 0x8eu8, ++ 0xa2u8, ++ 0xb7u8, ++ 0xcau8, ++ 0x51u8, ++ 0x67u8, ++ 0x45u8, ++ 0xbfu8, ++ 0xeau8, ++ 0xfcu8, ++ 0x49u8, ++ 0x90u8, ++ 0x4bu8, ++ 0x49u8, ++ 0x60u8, ++ 0x89u8, ++ ]; ++ let mut c = super::Crypter::new( ++ super::Cipher::aes_256_ecb(), ++ super::Mode::Encrypt, ++ &k0, ++ None, ++ ).unwrap(); ++ c.pad(false); ++ let mut r0 = vec![0; c0.len() + super::Cipher::aes_256_ecb().block_size()]; ++ let count = c.update(&p0, &mut r0).unwrap(); ++ let rest = c.finalize(&mut r0[count..]).unwrap(); ++ r0.truncate(count + rest); ++ assert_eq!(r0.to_hex(), c0.to_hex()); ++ ++ let mut c = super::Crypter::new( ++ super::Cipher::aes_256_ecb(), ++ super::Mode::Decrypt, ++ &k0, ++ None, ++ ).unwrap(); ++ c.pad(false); ++ let mut p1 = vec![0; r0.len() + super::Cipher::aes_256_ecb().block_size()]; ++ let count = c.update(&r0, &mut p1).unwrap(); ++ let rest = c.finalize(&mut p1[count..]).unwrap(); ++ p1.truncate(count + rest); ++ assert_eq!(p1.to_hex(), p0.to_hex()); ++ } ++ ++ #[test] ++ fn test_aes_256_cbc_decrypt() { ++ let iv = [ ++ 4_u8, ++ 223_u8, ++ 153_u8, ++ 219_u8, ++ 28_u8, ++ 142_u8, ++ 234_u8, ++ 68_u8, ++ 227_u8, ++ 69_u8, ++ 98_u8, ++ 107_u8, ++ 208_u8, ++ 14_u8, ++ 236_u8, ++ 60_u8, ++ ]; ++ let data = [ ++ 143_u8, ++ 210_u8, ++ 75_u8, ++ 63_u8, ++ 214_u8, ++ 179_u8, ++ 155_u8, ++ 241_u8, ++ 242_u8, ++ 31_u8, ++ 154_u8, ++ 56_u8, ++ 198_u8, ++ 145_u8, ++ 192_u8, ++ 64_u8, ++ 2_u8, ++ 245_u8, ++ 167_u8, ++ 220_u8, ++ 55_u8, ++ 119_u8, ++ 233_u8, ++ 136_u8, ++ 139_u8, ++ 27_u8, ++ 71_u8, ++ 242_u8, ++ 119_u8, ++ 175_u8, ++ 65_u8, ++ 207_u8, ++ ]; ++ let ciphered_data = [ ++ 0x4a_u8, ++ 0x2e_u8, ++ 0xe5_u8, ++ 0x6_u8, ++ 0xbf_u8, ++ 0xcf_u8, ++ 0xf2_u8, ++ 0xd7_u8, ++ 0xea_u8, ++ 0x2d_u8, ++ 0xb1_u8, ++ 0x85_u8, ++ 0x6c_u8, ++ 0x93_u8, ++ 0x65_u8, ++ 0x6f_u8, ++ ]; ++ let mut cr = super::Crypter::new( ++ super::Cipher::aes_256_cbc(), ++ super::Mode::Decrypt, ++ &data, ++ Some(&iv), ++ ).unwrap(); ++ cr.pad(false); ++ let mut unciphered_data = vec![0; data.len() + super::Cipher::aes_256_cbc().block_size()]; ++ let count = cr.update(&ciphered_data, &mut unciphered_data).unwrap(); ++ let rest = cr.finalize(&mut unciphered_data[count..]).unwrap(); ++ unciphered_data.truncate(count + rest); ++ ++ let expected_unciphered_data = b"I love turtles.\x01"; ++ ++ assert_eq!(&unciphered_data, expected_unciphered_data); ++ } ++ ++ fn cipher_test(ciphertype: super::Cipher, pt: &str, ct: &str, key: &str, iv: &str) { ++ let pt = Vec::from_hex(pt).unwrap(); ++ let ct = Vec::from_hex(ct).unwrap(); ++ let key = Vec::from_hex(key).unwrap(); ++ let iv = Vec::from_hex(iv).unwrap(); ++ ++ let computed = super::decrypt(ciphertype, &key, Some(&iv), &ct).unwrap(); ++ let expected = pt; ++ ++ if computed != expected { ++ println!("Computed: {}", computed.to_hex()); ++ println!("Expected: {}", expected.to_hex()); ++ if computed.len() != expected.len() { ++ println!( ++ "Lengths differ: {} in computed vs {} expected", ++ computed.len(), ++ expected.len() ++ ); ++ } ++ panic!("test failure"); ++ } ++ } ++ ++ fn cipher_test_nopad(ciphertype: super::Cipher, pt: &str, ct: &str, key: &str, iv: &str) { ++ let pt = Vec::from_hex(pt).unwrap(); ++ let ct = Vec::from_hex(ct).unwrap(); ++ let key = Vec::from_hex(key).unwrap(); ++ let iv = Vec::from_hex(iv).unwrap(); ++ ++ let computed = { ++ let mut c = Crypter::new(ciphertype, Mode::Decrypt, &key, Some(&iv)).unwrap(); ++ c.pad(false); ++ let mut out = vec![0; ct.len() + ciphertype.block_size()]; ++ let count = c.update(&ct, &mut out).unwrap(); ++ let rest = c.finalize(&mut out[count..]).unwrap(); ++ out.truncate(count + rest); ++ out ++ }; ++ let expected = pt; ++ ++ if computed != expected { ++ println!("Computed: {}", computed.to_hex()); ++ println!("Expected: {}", expected.to_hex()); ++ if computed.len() != expected.len() { ++ println!( ++ "Lengths differ: {} in computed vs {} expected", ++ computed.len(), ++ expected.len() ++ ); ++ } ++ panic!("test failure"); ++ } ++ } ++ ++ #[test] ++ fn test_rc4() { ++ ++ let pt = "0000000000000000000000000000000000000000000000000000000000000000000000000000"; ++ let ct = "A68686B04D686AA107BD8D4CAB191A3EEC0A6294BC78B60F65C25CB47BD7BB3A48EFC4D26BE4"; ++ let key = "97CD440324DA5FD1F7955C1C13B6B466"; ++ let iv = ""; ++ ++ cipher_test(super::Cipher::rc4(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_aes256_xts() { ++ // Test case 174 from ++ // http://csrc.nist.gov/groups/STM/cavp/documents/aes/XTSTestVectors.zip ++ let pt = "77f4ef63d734ebd028508da66c22cdebdd52ecd6ee2ab0a50bc8ad0cfd692ca5fcd4e6dedc45df7f\ ++ 6503f462611dc542"; ++ let ct = "ce7d905a7776ac72f240d22aafed5e4eb7566cdc7211220e970da634ce015f131a5ecb8d400bc9e8\ ++ 4f0b81d8725dbbc7"; ++ let key = "b6bfef891f83b5ff073f2231267be51eb084b791fa19a154399c0684c8b2dfcb37de77d28bbda3b\ ++ 4180026ad640b74243b3133e7b9fae629403f6733423dae28"; ++ let iv = "db200efb7eaaa737dbdf40babb68953f"; ++ ++ cipher_test(super::Cipher::aes_256_xts(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_aes128_ctr() { ++ ++ let pt = "6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411\ ++ E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710"; ++ let ct = "874D6191B620E3261BEF6864990DB6CE9806F66B7970FDFF8617187BB9FFFDFF5AE4DF3EDBD5D35E\ ++ 5B4F09020DB03EAB1E031DDA2FBE03D1792170A0F3009CEE"; ++ let key = "2B7E151628AED2A6ABF7158809CF4F3C"; ++ let iv = "F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"; ++ ++ cipher_test(super::Cipher::aes_128_ctr(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_aes128_cfb1() { ++ // Lifted from http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf ++ ++ let pt = "6bc1"; ++ let ct = "68b3"; ++ let key = "2b7e151628aed2a6abf7158809cf4f3c"; ++ let iv = "000102030405060708090a0b0c0d0e0f"; ++ ++ cipher_test(super::Cipher::aes_128_cfb1(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_aes128_cfb128() { ++ ++ let pt = "6bc1bee22e409f96e93d7e117393172a"; ++ let ct = "3b3fd92eb72dad20333449f8e83cfb4a"; ++ let key = "2b7e151628aed2a6abf7158809cf4f3c"; ++ let iv = "000102030405060708090a0b0c0d0e0f"; ++ ++ cipher_test(super::Cipher::aes_128_cfb128(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_aes128_cfb8() { ++ ++ let pt = "6bc1bee22e409f96e93d7e117393172aae2d"; ++ let ct = "3b79424c9c0dd436bace9e0ed4586a4f32b9"; ++ let key = "2b7e151628aed2a6abf7158809cf4f3c"; ++ let iv = "000102030405060708090a0b0c0d0e0f"; ++ ++ cipher_test(super::Cipher::aes_128_cfb8(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_aes256_cfb1() { ++ ++ let pt = "6bc1"; ++ let ct = "9029"; ++ let key = "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; ++ let iv = "000102030405060708090a0b0c0d0e0f"; ++ ++ cipher_test(super::Cipher::aes_256_cfb1(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_aes256_cfb128() { ++ ++ let pt = "6bc1bee22e409f96e93d7e117393172a"; ++ let ct = "dc7e84bfda79164b7ecd8486985d3860"; ++ let key = "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; ++ let iv = "000102030405060708090a0b0c0d0e0f"; ++ ++ cipher_test(super::Cipher::aes_256_cfb128(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_aes256_cfb8() { ++ ++ let pt = "6bc1bee22e409f96e93d7e117393172aae2d"; ++ let ct = "dc1f1a8520a64db55fcc8ac554844e889700"; ++ let key = "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"; ++ let iv = "000102030405060708090a0b0c0d0e0f"; ++ ++ cipher_test(super::Cipher::aes_256_cfb8(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_bf_cbc() { ++ // https://www.schneier.com/code/vectors.txt ++ ++ let pt = "37363534333231204E6F77206973207468652074696D6520666F722000000000"; ++ let ct = "6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC"; ++ let key = "0123456789ABCDEFF0E1D2C3B4A59687"; ++ let iv = "FEDCBA9876543210"; ++ ++ cipher_test_nopad(super::Cipher::bf_cbc(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_bf_ecb() { ++ ++ let pt = "5CD54CA83DEF57DA"; ++ let ct = "B1B8CC0B250F09A0"; ++ let key = "0131D9619DC1376E"; ++ let iv = "0000000000000000"; ++ ++ cipher_test_nopad(super::Cipher::bf_ecb(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_bf_cfb64() { ++ ++ let pt = "37363534333231204E6F77206973207468652074696D6520666F722000"; ++ let ct = "E73214A2822139CAF26ECF6D2EB9E76E3DA3DE04D1517200519D57A6C3"; ++ let key = "0123456789ABCDEFF0E1D2C3B4A59687"; ++ let iv = "FEDCBA9876543210"; ++ ++ cipher_test_nopad(super::Cipher::bf_cfb64(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_bf_ofb() { ++ ++ let pt = "37363534333231204E6F77206973207468652074696D6520666F722000"; ++ let ct = "E73214A2822139CA62B343CC5B65587310DD908D0C241B2263C2CF80DA"; ++ let key = "0123456789ABCDEFF0E1D2C3B4A59687"; ++ let iv = "FEDCBA9876543210"; ++ ++ cipher_test_nopad(super::Cipher::bf_ofb(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_des_cbc() { ++ ++ let pt = "54686973206973206120746573742e"; ++ let ct = "6f2867cfefda048a4046ef7e556c7132"; ++ let key = "7cb66337f3d3c0fe"; ++ let iv = "0001020304050607"; ++ ++ cipher_test(super::Cipher::des_cbc(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_des_ecb() { ++ ++ let pt = "54686973206973206120746573742e"; ++ let ct = "0050ab8aecec758843fe157b4dde938c"; ++ let key = "7cb66337f3d3c0fe"; ++ let iv = "0001020304050607"; ++ ++ cipher_test(super::Cipher::des_ecb(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ fn test_aes128_gcm() { ++ let key = "0e00c76561d2bd9b40c3c15427e2b08f"; ++ let iv = "492cadaccd3ca3fbc9cf9f06eb3325c4e159850b0dbe98199b89b7af528806610b6f63998e1eae80c348e7\ ++ 4cbb921d8326631631fc6a5d304f39166daf7ea15fa1977f101819adb510b50fe9932e12c5a85aa3fd1e73\ ++ d8d760af218be829903a77c63359d75edd91b4f6ed5465a72662f5055999e059e7654a8edc921aa0d496"; ++ let pt = "fef03c2d7fb15bf0d2df18007d99f967c878ad59359034f7bb2c19af120685d78e32f6b8b83b032019956c\ ++ a9c0195721476b85"; ++ let aad = "d8f1163d8c840292a2b2dacf4ac7c36aff8733f18fabb4fa5594544125e03d1e6e5d6d0fd61656c8d8f327\ ++ c92839ae5539bb469c9257f109ebff85aad7bd220fdaa95c022dbd0c7bb2d878ad504122c943045d3c5eba\ ++ 8f1f56c0"; ++ let ct = "4f6cf471be7cbd2575cd5a1747aea8fe9dea83e51936beac3e68f66206922060c697ffa7af80ad6bb68f2c\ ++ f4fc97416ee52abe"; ++ let tag = "e20b6655"; ++ ++ // this tag is smaller than you'd normally want, but I pulled this test from the part of ++ // the NIST test vectors that cover 4 byte tags. ++ let mut actual_tag = [0; 4]; ++ let out = encrypt_aead( ++ Cipher::aes_128_gcm(), ++ &Vec::from_hex(key).unwrap(), ++ Some(&Vec::from_hex(iv).unwrap()), ++ &Vec::from_hex(aad).unwrap(), ++ &Vec::from_hex(pt).unwrap(), ++ &mut actual_tag, ++ ).unwrap(); ++ assert_eq!(ct, out.to_hex()); ++ assert_eq!(tag, actual_tag.to_hex()); ++ ++ let out = decrypt_aead( ++ Cipher::aes_128_gcm(), ++ &Vec::from_hex(key).unwrap(), ++ Some(&Vec::from_hex(iv).unwrap()), ++ &Vec::from_hex(aad).unwrap(), ++ &Vec::from_hex(ct).unwrap(), ++ &Vec::from_hex(tag).unwrap(), ++ ).unwrap(); ++ assert_eq!(pt, out.to_hex()); ++ } ++ ++ #[test] ++ #[cfg(all(ossl110, feature = "v110"))] ++ fn test_chacha20() { ++ let key = "0000000000000000000000000000000000000000000000000000000000000000"; ++ let iv = "00000000000000000000000000000000"; ++ let pt = "000000000000000000000000000000000000000000000000000000000000000000000000000000000\ ++ 00000000000000000000000000000000000000000000000"; ++ let ct = "76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7\ ++ 724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586"; ++ ++ cipher_test(Cipher::chacha20(), pt, ct, key, iv); ++ } ++ ++ #[test] ++ #[cfg(all(ossl110, feature = "v110"))] ++ fn test_chacha20_poly1305() { ++ let key = "808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f"; ++ let iv = "070000004041424344454647"; ++ let aad = "50515253c0c1c2c3c4c5c6c7"; ++ let pt = "4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393\ ++ a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f722074\ ++ 6865206675747572652c2073756e73637265656e20776f756c642062652069742e"; ++ let ct = "d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca967128\ ++ 2fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fa\ ++ b324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116"; ++ let tag = "1ae10b594f09e26a7e902ecbd0600691"; ++ ++ let mut actual_tag = [0; 16]; ++ let out = encrypt_aead( ++ Cipher::chacha20_poly1305(), ++ &Vec::from_hex(key).unwrap(), ++ Some(&Vec::from_hex(iv).unwrap()), ++ &Vec::from_hex(aad).unwrap(), ++ &Vec::from_hex(pt).unwrap(), ++ &mut actual_tag, ++ ).unwrap(); ++ assert_eq!(ct, out.to_hex()); ++ assert_eq!(tag, actual_tag.to_hex()); ++ ++ let out = decrypt_aead( ++ Cipher::chacha20_poly1305(), ++ &Vec::from_hex(key).unwrap(), ++ Some(&Vec::from_hex(iv).unwrap()), ++ &Vec::from_hex(aad).unwrap(), ++ &Vec::from_hex(ct).unwrap(), ++ &Vec::from_hex(tag).unwrap(), ++ ).unwrap(); ++ assert_eq!(pt, out.to_hex()); ++ } ++} diff --cc vendor/openssl-0.9.19/src/types.rs index 000000000,000000000..25ffe501b new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/types.rs @@@ -1,0 -1,0 +1,5 @@@ ++#[deprecated(note = "use foreign_types instead", since = "0.9.7")] ++pub use foreign_types::ForeignType as OpenSslType; ++ ++#[deprecated(note = "use foreign_types instead", since = "0.9.7")] ++pub use foreign_types::ForeignTypeRef as OpenSslTypeRef; diff --cc vendor/openssl-0.9.19/src/util.rs index 000000000,000000000..e40105872 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/util.rs @@@ -1,0 -1,0 +1,92 @@@ ++use libc::{c_int, c_char, c_void}; ++use std::any::Any; ++use std::panic::{self, AssertUnwindSafe}; ++use std::slice; ++ ++use error::ErrorStack; ++ ++/// Wraps a user-supplied callback and a slot for panics thrown inside the callback (while FFI ++/// frames are on the stack). ++/// ++/// When dropped, checks if the callback has panicked, and resumes unwinding if so. ++pub struct CallbackState { ++ /// The user callback. Taken out of the `Option` when called. ++ cb: Option, ++ /// If the callback panics, we place the panic object here, to be re-thrown once OpenSSL ++ /// returns. ++ panic: Option>, ++} ++ ++impl CallbackState { ++ pub fn new(callback: F) -> Self { ++ CallbackState { ++ cb: Some(callback), ++ panic: None, ++ } ++ } ++} ++ ++impl Drop for CallbackState { ++ fn drop(&mut self) { ++ if let Some(panic) = self.panic.take() { ++ panic::resume_unwind(panic); ++ } ++ } ++} ++ ++pub unsafe extern "C" fn invoke_passwd_cb_old( ++ buf: *mut c_char, ++ size: c_int, ++ _rwflag: c_int, ++ cb_state: *mut c_void, ++) -> c_int ++where ++ F: FnOnce(&mut [c_char]) -> usize, ++{ ++ let callback = &mut *(cb_state as *mut CallbackState); ++ ++ let result = panic::catch_unwind(AssertUnwindSafe(|| { ++ let pass_slice = slice::from_raw_parts_mut(buf, size as usize); ++ callback.cb.take().unwrap()(pass_slice) ++ })); ++ ++ match result { ++ Ok(len) => len as c_int, ++ Err(err) => { ++ callback.panic = Some(err); ++ 0 ++ } ++ } ++} ++ ++/// Password callback function, passed to private key loading functions. ++/// ++/// `cb_state` is expected to be a pointer to a `CallbackState`. ++pub unsafe extern "C" fn invoke_passwd_cb( ++ buf: *mut c_char, ++ size: c_int, ++ _rwflag: c_int, ++ cb_state: *mut c_void, ++) -> c_int ++where ++ F: FnOnce(&mut [u8]) -> Result, ++{ ++ let callback = &mut *(cb_state as *mut CallbackState); ++ ++ let result = panic::catch_unwind(AssertUnwindSafe(|| { ++ let pass_slice = slice::from_raw_parts_mut(buf as *mut u8, size as usize); ++ callback.cb.take().unwrap()(pass_slice) ++ })); ++ ++ match result { ++ Ok(Ok(len)) => len as c_int, ++ Ok(Err(_)) => { ++ // FIXME restore error stack ++ 0 ++ } ++ Err(err) => { ++ callback.panic = Some(err); ++ 0 ++ } ++ } ++} diff --cc vendor/openssl-0.9.19/src/verify.rs index 000000000,000000000..7b2fa612e new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/verify.rs @@@ -1,0 -1,0 +1,68 @@@ ++use libc::c_uint; ++use ffi; ++use foreign_types::ForeignTypeRef; ++use std::net::IpAddr; ++ ++use cvt; ++use error::ErrorStack; ++ ++bitflags! { ++ pub struct X509CheckFlags: c_uint { ++ const X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT = ffi::X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT; ++ const X509_CHECK_FLAG_NO_WILDCARDS = ffi::X509_CHECK_FLAG_NO_WILDCARDS; ++ const X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS = ffi::X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS; ++ const X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS = ffi::X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS; ++ const X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS ++ = ffi::X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS; ++ /// Requires the `v110` feature and OpenSSL 1.1.0. ++ #[cfg(all(feature = "v110", ossl110))] ++ const X509_CHECK_FLAG_NEVER_CHECK_SUBJECT = ffi::X509_CHECK_FLAG_NEVER_CHECK_SUBJECT; ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::X509_VERIFY_PARAM; ++ fn drop = ffi::X509_VERIFY_PARAM_free; ++ ++ pub struct X509VerifyParam; ++ pub struct X509VerifyParamRef; ++} ++ ++impl X509VerifyParamRef { ++ pub fn set_hostflags(&mut self, hostflags: X509CheckFlags) { ++ unsafe { ++ ffi::X509_VERIFY_PARAM_set_hostflags(self.as_ptr(), hostflags.bits); ++ } ++ } ++ ++ pub fn set_host(&mut self, host: &str) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::X509_VERIFY_PARAM_set1_host( ++ self.as_ptr(), ++ host.as_ptr() as *const _, ++ host.len(), ++ )).map(|_| ()) ++ } ++ } ++ ++ pub fn set_ip(&mut self, ip: IpAddr) -> Result<(), ErrorStack> { ++ unsafe { ++ let mut buf = [0; 16]; ++ let len = match ip { ++ IpAddr::V4(addr) => { ++ buf[..4].copy_from_slice(&addr.octets()); ++ 4 ++ } ++ IpAddr::V6(addr) => { ++ buf.copy_from_slice(&addr.octets()); ++ 16 ++ } ++ }; ++ cvt(ffi::X509_VERIFY_PARAM_set1_ip( ++ self.as_ptr(), ++ buf.as_ptr() as *const _, ++ len, ++ )).map(|_| ()) ++ } ++ } ++} diff --cc vendor/openssl-0.9.19/src/version.rs index 000000000,000000000..7254d7ba8 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/version.rs @@@ -1,0 -1,0 +1,126 @@@ ++// 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. ++// ++ ++use std::ffi::CStr; ++ ++#[cfg(ossl10x)] ++use ffi::{SSLEAY_VERSION as OPENSSL_VERSION, SSLEAY_CFLAGS as OPENSSL_CFLAGS, ++ SSLEAY_BUILT_ON as OPENSSL_BUILT_ON, SSLEAY_PLATFORM as OPENSSL_PLATFORM, ++ SSLEAY_DIR as OPENSSL_DIR, SSLeay as OpenSSL_version_num, ++ SSLeay_version as OpenSSL_version}; ++ ++#[cfg(ossl110)] ++use ffi::{OPENSSL_VERSION, OPENSSL_CFLAGS, OPENSSL_BUILT_ON, OPENSSL_PLATFORM, OPENSSL_DIR, ++ OpenSSL_version_num, OpenSSL_version}; ++ ++/// OPENSSL_VERSION_NUMBER is a numeric release version identifier: ++/// ++/// `MNNFFPPS: major minor fix patch status` ++/// ++/// The status nibble has one of the values 0 for development, 1 to e for betas 1 to 14, and f for release. ++/// ++/// for example ++/// ++/// `0x000906000 == 0.9.6 dev` ++/// `0x000906023 == 0.9.6b beta 3` ++/// `0x00090605f == 0.9.6e release` ++/// ++/// Versions prior to 0.9.3 have identifiers < 0x0930. Versions between 0.9.3 and 0.9.5 had a version identifier with this interpretation: ++/// ++/// `MMNNFFRBB major minor fix final beta/patch` ++/// ++/// for example ++/// ++/// `0x000904100 == 0.9.4 release` ++/// `0x000905000 == 0.9.5 dev` ++/// ++/// Version 0.9.5a had an interim interpretation that is like the current one, except the patch level got the highest bit set, to keep continuity. The number was therefore 0x0090581f ++/// ++/// The return value of this function can be compared to the macro to make sure that the correct version of the library has been loaded, especially when using DLLs on Windows systems. ++pub fn number() -> i64 { ++ unsafe { OpenSSL_version_num() as i64 } ++} ++ ++ ++/// The text variant of the version number and the release date. For example, "OpenSSL 0.9.5a 1 Apr 2000". ++pub fn version() -> &'static str { ++ unsafe { ++ CStr::from_ptr(OpenSSL_version(OPENSSL_VERSION)) ++ .to_str() ++ .unwrap() ++ } ++} ++ ++/// The compiler flags set for the compilation process in the form "compiler: ..." if available or ++/// "compiler: information not available" otherwise. ++pub fn c_flags() -> &'static str { ++ unsafe { ++ CStr::from_ptr(OpenSSL_version(OPENSSL_CFLAGS)) ++ .to_str() ++ .unwrap() ++ } ++} ++ ++/// The date of the build process in the form "built on: ..." if available or "built on: date not available" otherwise. ++pub fn built_on() -> &'static str { ++ unsafe { ++ CStr::from_ptr(OpenSSL_version(OPENSSL_BUILT_ON)) ++ .to_str() ++ .unwrap() ++ } ++} ++ ++/// The "Configure" target of the library build in the form "platform: ..." if available or "platform: information not available" otherwise. ++pub fn platform() -> &'static str { ++ unsafe { ++ CStr::from_ptr(OpenSSL_version(OPENSSL_PLATFORM)) ++ .to_str() ++ .unwrap() ++ } ++} ++ ++/// The "OPENSSLDIR" setting of the library build in the form "OPENSSLDIR: "..."" if available or "OPENSSLDIR: N/A" otherwise. ++pub fn dir() -> &'static str { ++ unsafe { ++ CStr::from_ptr(OpenSSL_version(OPENSSL_DIR)) ++ .to_str() ++ .unwrap() ++ } ++} ++ ++/// This test ensures that we do not segfault when calling the functions of this module ++/// and that the strings respect a reasonable format. ++#[test] ++fn test_versions() { ++ println!("Number: '{}'", number()); ++ println!("Version: '{}'", version()); ++ println!("C flags: '{}'", c_flags()); ++ println!("Built on: '{}'", built_on()); ++ println!("Platform: '{}'", platform()); ++ println!("Dir: '{}'", dir()); ++ ++ #[cfg(not(libressl))] ++ fn expected_name() -> &'static str { ++ "OpenSSL" ++ } ++ #[cfg(libressl)] ++ fn expected_name() -> &'static str { ++ "LibreSSL" ++ } ++ ++ assert!(number() > 0); ++ assert!(version().starts_with(expected_name())); ++ assert!(c_flags().starts_with("compiler:")); ++ assert!(built_on().starts_with("built on:")); ++ assert!(dir().starts_with("OPENSSLDIR:")); ++} diff --cc vendor/openssl-0.9.19/src/x509/extension.rs index 000000000,000000000..83a826603 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/x509/extension.rs @@@ -1,0 -1,0 +1,672 @@@ ++use std::fmt::{self, Write}; ++ ++use error::ErrorStack; ++use nid::{self, Nid}; ++use x509::{X509v3Context, X509Extension}; ++ ++/// Type-only version of the `Extension` enum. ++/// ++/// See the `Extension` documentation for more information on the different ++/// variants. ++#[derive(Clone, Hash, PartialEq, Eq)] ++#[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++pub enum ExtensionType { ++ KeyUsage, ++ ExtKeyUsage, ++ SubjectAltName, ++ IssuerAltName, ++ OtherNid(Nid), ++ OtherStr(String), ++} ++ ++/// A X.509 v3 certificate extension. ++/// ++/// Only one extension of each type is allow in a certificate. ++/// See RFC 3280 for more information about extensions. ++#[derive(Clone)] ++#[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++pub enum Extension { ++ /// The purposes of the key contained in the certificate ++ KeyUsage(Vec), ++ /// The extended purposes of the key contained in the certificate ++ ExtKeyUsage(Vec), ++ /// Subject Alternative Names ++ SubjectAltName(Vec<(AltNameOption, String)>), ++ /// Issuer Alternative Names ++ IssuerAltName(Vec<(AltNameOption, String)>), ++ /// Arbitrary extensions by NID. See `man x509v3_config` for value syntax. ++ /// ++ /// You must not use this to add extensions which this enum can express directly. ++ /// ++ /// ``` ++ /// use openssl::x509::extension::Extension::*; ++ /// use openssl::nid; ++ /// ++ /// # let generator = openssl::x509::X509Generator::new(); ++ /// generator.add_extension(OtherNid(nid::BASIC_CONSTRAINTS,"critical,CA:TRUE".to_owned())); ++ /// ``` ++ OtherNid(Nid, String), ++ /// Arbitrary extensions by OID string. See `man ASN1_generate_nconf` for value syntax. ++ /// ++ /// You must not use this to add extensions which this enum can express directly. ++ /// ++ /// ``` ++ /// use openssl::x509::extension::Extension::*; ++ /// ++ /// # let generator = openssl::x509::X509Generator::new(); ++ /// generator.add_extension(OtherStr("2.999.2".to_owned(),"ASN1:UTF8:example value".to_owned())); ++ /// ``` ++ OtherStr(String, String), ++} ++ ++impl Extension { ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn get_type(&self) -> ExtensionType { ++ match self { ++ &Extension::KeyUsage(_) => ExtensionType::KeyUsage, ++ &Extension::ExtKeyUsage(_) => ExtensionType::ExtKeyUsage, ++ &Extension::SubjectAltName(_) => ExtensionType::SubjectAltName, ++ &Extension::IssuerAltName(_) => ExtensionType::IssuerAltName, ++ &Extension::OtherNid(nid, _) => ExtensionType::OtherNid(nid), ++ &Extension::OtherStr(ref s, _) => ExtensionType::OtherStr(s.clone()), ++ } ++ } ++} ++ ++impl ExtensionType { ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn get_nid(&self) -> Option { ++ match self { ++ &ExtensionType::KeyUsage => Some(nid::KEY_USAGE), ++ &ExtensionType::ExtKeyUsage => Some(nid::EXT_KEY_USAGE), ++ &ExtensionType::SubjectAltName => Some(nid::SUBJECT_ALT_NAME), ++ &ExtensionType::IssuerAltName => Some(nid::ISSUER_ALT_NAME), ++ &ExtensionType::OtherNid(nid) => Some(nid), ++ &ExtensionType::OtherStr(_) => None, ++ } ++ } ++ ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn get_name(&self) -> Option<&str> { ++ match self { ++ &ExtensionType::OtherStr(ref s) => Some(s), ++ _ => None, ++ } ++ } ++} ++ ++// FIXME: This would be nicer as a method on Iterator. This can ++// eventually be replaced by the successor to std::slice::SliceConcatExt.connect ++fn join, T: ToString>(iter: I, sep: &str) -> String { ++ iter.enumerate().fold(String::new(), |mut acc, (idx, v)| { ++ if idx > 0 { ++ acc.push_str(sep) ++ }; ++ acc.push_str(&v.to_string()); ++ acc ++ }) ++} ++ ++impl ToString for Extension { ++ fn to_string(&self) -> String { ++ match self { ++ &Extension::KeyUsage(ref purposes) => join(purposes.iter(), ","), ++ &Extension::ExtKeyUsage(ref purposes) => join(purposes.iter(), ","), ++ &Extension::SubjectAltName(ref names) => { ++ join( ++ names.iter().map(|&(ref opt, ref val)| { ++ opt.to_string() + ":" + &val ++ }), ++ ",", ++ ) ++ } ++ &Extension::IssuerAltName(ref names) => { ++ join( ++ names.iter().map(|&(ref opt, ref val)| { ++ opt.to_string() + ":" + &val ++ }), ++ ",", ++ ) ++ } ++ &Extension::OtherNid(_, ref value) => value.clone(), ++ &Extension::OtherStr(_, ref value) => value.clone(), ++ } ++ } ++} ++ ++#[derive(Clone, Copy)] ++#[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++pub enum KeyUsageOption { ++ DigitalSignature, ++ NonRepudiation, ++ KeyEncipherment, ++ DataEncipherment, ++ KeyAgreement, ++ KeyCertSign, ++ CRLSign, ++ EncipherOnly, ++ DecipherOnly, ++} ++ ++impl fmt::Display for KeyUsageOption { ++ fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { ++ f.pad(match self { ++ &KeyUsageOption::DigitalSignature => "digitalSignature", ++ &KeyUsageOption::NonRepudiation => "nonRepudiation", ++ &KeyUsageOption::KeyEncipherment => "keyEncipherment", ++ &KeyUsageOption::DataEncipherment => "dataEncipherment", ++ &KeyUsageOption::KeyAgreement => "keyAgreement", ++ &KeyUsageOption::KeyCertSign => "keyCertSign", ++ &KeyUsageOption::CRLSign => "cRLSign", ++ &KeyUsageOption::EncipherOnly => "encipherOnly", ++ &KeyUsageOption::DecipherOnly => "decipherOnly", ++ }) ++ } ++} ++ ++#[derive(Clone)] ++#[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++pub enum ExtKeyUsageOption { ++ ServerAuth, ++ ClientAuth, ++ CodeSigning, ++ EmailProtection, ++ TimeStamping, ++ MsCodeInd, ++ MsCodeCom, ++ MsCtlSign, ++ MsSgc, ++ MsEfs, ++ NsSgc, ++ /// An arbitrary key usage by OID. ++ Other(String), ++} ++ ++impl fmt::Display for ExtKeyUsageOption { ++ fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { ++ f.pad(match self { ++ &ExtKeyUsageOption::ServerAuth => "serverAuth", ++ &ExtKeyUsageOption::ClientAuth => "clientAuth", ++ &ExtKeyUsageOption::CodeSigning => "codeSigning", ++ &ExtKeyUsageOption::EmailProtection => "emailProtection", ++ &ExtKeyUsageOption::TimeStamping => "timeStamping", ++ &ExtKeyUsageOption::MsCodeInd => "msCodeInd", ++ &ExtKeyUsageOption::MsCodeCom => "msCodeCom", ++ &ExtKeyUsageOption::MsCtlSign => "msCTLSign", ++ &ExtKeyUsageOption::MsSgc => "msSGC", ++ &ExtKeyUsageOption::MsEfs => "msEFS", ++ &ExtKeyUsageOption::NsSgc => "nsSGC", ++ &ExtKeyUsageOption::Other(ref s) => &s[..], ++ }) ++ } ++} ++ ++#[derive(Clone, Copy)] ++#[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++pub enum AltNameOption { ++ /// The value is specified as OID;content. See `man ASN1_generate_nconf` for more information on the content syntax. ++ /// ++ /// ``` ++ /// use openssl::x509::extension::Extension::*; ++ /// use openssl::x509::extension::AltNameOption::Other as OtherName; ++ /// ++ /// # let generator = openssl::x509::X509Generator::new(); ++ /// generator.add_extension(SubjectAltName(vec![(OtherName,"2.999.3;ASN1:UTF8:some other name".to_owned())])); ++ /// ``` ++ Other, ++ Email, ++ DNS, ++ // X400, // Not supported by OpenSSL ++ Directory, ++ // EDIParty, // Not supported by OpenSSL ++ URI, ++ IPAddress, ++ RegisteredID, ++} ++ ++impl fmt::Display for AltNameOption { ++ fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { ++ f.pad(match self { ++ &AltNameOption::Other => "otherName", ++ &AltNameOption::Email => "email", ++ &AltNameOption::DNS => "DNS", ++ &AltNameOption::Directory => "dirName", ++ &AltNameOption::URI => "URI", ++ &AltNameOption::IPAddress => "IP", ++ &AltNameOption::RegisteredID => "RID", ++ }) ++ } ++} ++ ++pub struct BasicConstraints { ++ critical: bool, ++ ca: bool, ++ pathlen: Option, ++} ++ ++impl BasicConstraints { ++ pub fn new() -> BasicConstraints { ++ BasicConstraints { ++ critical: false, ++ ca: false, ++ pathlen: None, ++ } ++ } ++ ++ pub fn critical(&mut self) -> &mut BasicConstraints { ++ self.critical = true; ++ self ++ } ++ ++ pub fn ca(&mut self) -> &mut BasicConstraints { ++ self.ca = true; ++ self ++ } ++ ++ pub fn pathlen(&mut self, pathlen: u32) -> &mut BasicConstraints { ++ self.pathlen = Some(pathlen); ++ self ++ } ++ ++ pub fn build(&self) -> Result { ++ let mut value = String::new(); ++ if self.critical { ++ value.push_str("critical,"); ++ } ++ value.push_str("CA:"); ++ if self.ca { ++ value.push_str("TRUE"); ++ } else { ++ value.push_str("FALSE"); ++ } ++ if let Some(pathlen) = self.pathlen { ++ write!(value, ",pathlen:{}", pathlen).unwrap(); ++ } ++ X509Extension::new_nid(None, None, nid::BASIC_CONSTRAINTS, &value) ++ } ++} ++ ++pub struct KeyUsage { ++ critical: bool, ++ digital_signature: bool, ++ non_repudiation: bool, ++ key_encipherment: bool, ++ data_encipherment: bool, ++ key_agreement: bool, ++ key_cert_sign: bool, ++ crl_sign: bool, ++ encipher_only: bool, ++ decipher_only: bool, ++} ++ ++impl KeyUsage { ++ pub fn new() -> KeyUsage { ++ KeyUsage { ++ critical: false, ++ digital_signature: false, ++ non_repudiation: false, ++ key_encipherment: false, ++ data_encipherment: false, ++ key_agreement: false, ++ key_cert_sign: false, ++ crl_sign: false, ++ encipher_only: false, ++ decipher_only: false, ++ } ++ } ++ ++ pub fn critical(&mut self) -> &mut KeyUsage { ++ self.critical = true; ++ self ++ } ++ ++ pub fn digital_signature(&mut self) -> &mut KeyUsage { ++ self.digital_signature = true; ++ self ++ } ++ ++ pub fn non_repudiation(&mut self) -> &mut KeyUsage { ++ self.non_repudiation = true; ++ self ++ } ++ ++ pub fn key_encipherment(&mut self) -> &mut KeyUsage { ++ self.key_encipherment = true; ++ self ++ } ++ ++ pub fn data_encipherment(&mut self) -> &mut KeyUsage { ++ self.data_encipherment = true; ++ self ++ } ++ ++ pub fn key_agreement(&mut self) -> &mut KeyUsage { ++ self.key_agreement = true; ++ self ++ } ++ ++ pub fn key_cert_sign(&mut self) -> &mut KeyUsage { ++ self.key_cert_sign = true; ++ self ++ } ++ ++ pub fn crl_sign(&mut self) -> &mut KeyUsage { ++ self.crl_sign = true; ++ self ++ } ++ ++ pub fn encipher_only(&mut self) -> &mut KeyUsage { ++ self.encipher_only = true; ++ self ++ } ++ ++ pub fn decipher_only(&mut self) -> &mut KeyUsage { ++ self.decipher_only = true; ++ self ++ } ++ ++ pub fn build(&self) -> Result { ++ let mut value = String::new(); ++ let mut first = true; ++ append(&mut value, &mut first, self.critical, "critical"); ++ append( ++ &mut value, ++ &mut first, ++ self.digital_signature, ++ "digitalSignature", ++ ); ++ append( ++ &mut value, ++ &mut first, ++ self.non_repudiation, ++ "nonRepudiation", ++ ); ++ append( ++ &mut value, ++ &mut first, ++ self.key_encipherment, ++ "keyEncipherment", ++ ); ++ append( ++ &mut value, ++ &mut first, ++ self.data_encipherment, ++ "dataEncipherment", ++ ); ++ append(&mut value, &mut first, self.key_agreement, "keyAgreement"); ++ append(&mut value, &mut first, self.key_cert_sign, "keyCertSign"); ++ append(&mut value, &mut first, self.crl_sign, "cRLSign"); ++ append(&mut value, &mut first, self.encipher_only, "encipherOnly"); ++ append(&mut value, &mut first, self.decipher_only, "decipherOnly"); ++ X509Extension::new_nid(None, None, nid::KEY_USAGE, &value) ++ } ++} ++ ++pub struct ExtendedKeyUsage { ++ critical: bool, ++ server_auth: bool, ++ client_auth: bool, ++ code_signing: bool, ++ email_protection: bool, ++ time_stamping: bool, ++ ms_code_ind: bool, ++ ms_code_com: bool, ++ ms_ctl_sign: bool, ++ ms_sgc: bool, ++ ms_efs: bool, ++ ns_sgc: bool, ++ other: Vec, ++} ++ ++impl ExtendedKeyUsage { ++ pub fn new() -> ExtendedKeyUsage { ++ ExtendedKeyUsage { ++ critical: false, ++ server_auth: false, ++ client_auth: false, ++ code_signing: false, ++ email_protection: false, ++ time_stamping: false, ++ ms_code_ind: false, ++ ms_code_com: false, ++ ms_ctl_sign: false, ++ ms_sgc: false, ++ ms_efs: false, ++ ns_sgc: false, ++ other: vec![], ++ } ++ } ++ ++ pub fn critical(&mut self) -> &mut ExtendedKeyUsage { ++ self.critical = true; ++ self ++ } ++ ++ pub fn server_auth(&mut self) -> &mut ExtendedKeyUsage { ++ self.server_auth = true; ++ self ++ } ++ ++ pub fn client_auth(&mut self) -> &mut ExtendedKeyUsage { ++ self.client_auth = true; ++ self ++ } ++ ++ pub fn code_signing(&mut self) -> &mut ExtendedKeyUsage { ++ self.code_signing = true; ++ self ++ } ++ ++ pub fn time_stamping(&mut self) -> &mut ExtendedKeyUsage { ++ self.time_stamping = true; ++ self ++ } ++ ++ pub fn ms_code_ind(&mut self) -> &mut ExtendedKeyUsage { ++ self.ms_code_ind = true; ++ self ++ } ++ ++ pub fn ms_code_com(&mut self) -> &mut ExtendedKeyUsage { ++ self.ms_code_com = true; ++ self ++ } ++ ++ pub fn ms_ctl_sign(&mut self) -> &mut ExtendedKeyUsage { ++ self.ms_ctl_sign = true; ++ self ++ } ++ ++ pub fn ms_sgc(&mut self) -> &mut ExtendedKeyUsage { ++ self.ms_sgc = true; ++ self ++ } ++ ++ pub fn ms_efs(&mut self) -> &mut ExtendedKeyUsage { ++ self.ms_efs = true; ++ self ++ } ++ ++ pub fn ns_sgc(&mut self) -> &mut ExtendedKeyUsage { ++ self.ns_sgc = true; ++ self ++ } ++ ++ pub fn other(&mut self, other: &str) -> &mut ExtendedKeyUsage { ++ self.other.push(other.to_owned()); ++ self ++ } ++ ++ pub fn build(&self) -> Result { ++ let mut value = String::new(); ++ let mut first = true; ++ append(&mut value, &mut first, self.critical, "critical"); ++ append(&mut value, &mut first, self.server_auth, "serverAuth"); ++ append(&mut value, &mut first, self.client_auth, "clientAuth"); ++ append(&mut value, &mut first, self.code_signing, "codeSigning"); ++ append( ++ &mut value, ++ &mut first, ++ self.email_protection, ++ "emailProtection", ++ ); ++ append(&mut value, &mut first, self.time_stamping, "timeStamping"); ++ append(&mut value, &mut first, self.ms_code_ind, "msCodeInd"); ++ append(&mut value, &mut first, self.ms_code_com, "msCodeCom"); ++ append(&mut value, &mut first, self.ms_ctl_sign, "msCTLSign"); ++ append(&mut value, &mut first, self.ms_sgc, "msSGC"); ++ append(&mut value, &mut first, self.ms_efs, "msEFS"); ++ append(&mut value, &mut first, self.ns_sgc, "nsSGC"); ++ for other in &self.other { ++ append(&mut value, &mut first, true, other); ++ } ++ X509Extension::new_nid(None, None, nid::EXT_KEY_USAGE, &value) ++ } ++} ++ ++pub struct SubjectKeyIdentifier { ++ critical: bool, ++} ++ ++impl SubjectKeyIdentifier { ++ pub fn new() -> SubjectKeyIdentifier { ++ SubjectKeyIdentifier { critical: false } ++ } ++ ++ pub fn critical(&mut self) -> &mut SubjectKeyIdentifier { ++ self.critical = true; ++ self ++ } ++ ++ pub fn build(&self, ctx: &X509v3Context) -> Result { ++ let mut value = String::new(); ++ let mut first = true; ++ append(&mut value, &mut first, self.critical, "critical"); ++ append(&mut value, &mut first, true, "hash"); ++ X509Extension::new_nid(None, Some(ctx), nid::SUBJECT_KEY_IDENTIFIER, &value) ++ } ++} ++ ++pub struct AuthorityKeyIdentifier { ++ critical: bool, ++ keyid: Option, ++ issuer: Option, ++} ++ ++impl AuthorityKeyIdentifier { ++ pub fn new() -> AuthorityKeyIdentifier { ++ AuthorityKeyIdentifier { ++ critical: false, ++ keyid: None, ++ issuer: None, ++ } ++ } ++ ++ pub fn critical(&mut self) -> &mut AuthorityKeyIdentifier { ++ self.critical = true; ++ self ++ } ++ ++ pub fn keyid(&mut self, always: bool) -> &mut AuthorityKeyIdentifier { ++ self.keyid = Some(always); ++ self ++ } ++ ++ pub fn issuer(&mut self, always: bool) -> &mut AuthorityKeyIdentifier { ++ self.issuer = Some(always); ++ self ++ } ++ ++ pub fn build(&self, ctx: &X509v3Context) -> Result { ++ let mut value = String::new(); ++ let mut first = true; ++ append(&mut value, &mut first, self.critical, "critical"); ++ match self.keyid { ++ Some(true) => append(&mut value, &mut first, true, "keyid:always"), ++ Some(false) => append(&mut value, &mut first, true, "keyid"), ++ None => {} ++ } ++ match self.issuer { ++ Some(true) => append(&mut value, &mut first, true, "issuer:always"), ++ Some(false) => append(&mut value, &mut first, true, "issuer"), ++ None => {} ++ } ++ X509Extension::new_nid(None, Some(ctx), nid::AUTHORITY_KEY_IDENTIFIER, &value) ++ } ++} ++ ++pub struct SubjectAlternativeName { ++ critical: bool, ++ names: Vec, ++} ++ ++impl SubjectAlternativeName { ++ pub fn new() -> SubjectAlternativeName { ++ SubjectAlternativeName { ++ critical: false, ++ names: vec![], ++ } ++ } ++ ++ pub fn critical(&mut self) -> &mut SubjectAlternativeName { ++ self.critical = true; ++ self ++ } ++ ++ pub fn email(&mut self, email: &str) -> &mut SubjectAlternativeName { ++ self.names.push(format!("email:{}", email)); ++ self ++ } ++ ++ pub fn uri(&mut self, uri: &str) -> &mut SubjectAlternativeName { ++ self.names.push(format!("URI:{}", uri)); ++ self ++ } ++ ++ pub fn dns(&mut self, dns: &str) -> &mut SubjectAlternativeName { ++ self.names.push(format!("DNS:{}", dns)); ++ self ++ } ++ ++ pub fn rid(&mut self, rid: &str) -> &mut SubjectAlternativeName { ++ self.names.push(format!("RID:{}", rid)); ++ self ++ } ++ ++ pub fn ip(&mut self, ip: &str) -> &mut SubjectAlternativeName { ++ self.names.push(format!("IP:{}", ip)); ++ self ++ } ++ ++ pub fn dir_name(&mut self, dir_name: &str) -> &mut SubjectAlternativeName { ++ self.names.push(format!("dirName:{}", dir_name)); ++ self ++ } ++ ++ pub fn other_name(&mut self, other_name: &str) -> &mut SubjectAlternativeName { ++ self.names.push(format!("otherName:{}", other_name)); ++ self ++ } ++ ++ pub fn build(&self, ctx: &X509v3Context) -> Result { ++ let mut value = String::new(); ++ let mut first = true; ++ append(&mut value, &mut first, self.critical, "critical"); ++ for name in &self.names { ++ append(&mut value, &mut first, true, name); ++ } ++ X509Extension::new_nid(None, Some(ctx), nid::SUBJECT_ALT_NAME, &value) ++ } ++} ++ ++fn append(value: &mut String, first: &mut bool, should: bool, element: &str) { ++ if !should { ++ return; ++ } ++ ++ if !*first { ++ value.push(','); ++ } ++ *first = false; ++ value.push_str(element); ++} diff --cc vendor/openssl-0.9.19/src/x509/mod.rs index 000000000,000000000..c0594746a new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/x509/mod.rs @@@ -1,0 -1,0 +1,1238 @@@ ++#![allow(deprecated)] ++use libc::{c_int, c_long}; ++use ffi; ++use foreign_types::{ForeignType, ForeignTypeRef}; ++use std::borrow::Borrow; ++use std::collections::HashMap; ++use std::error::Error; ++use std::ffi::{CStr, CString}; ++use std::fmt; ++use std::marker::PhantomData; ++use std::mem; ++use std::path::Path; ++use std::ptr; ++use std::slice; ++use std::str; ++ ++use {cvt, cvt_p, cvt_n}; ++use asn1::{Asn1StringRef, Asn1Time, Asn1TimeRef, Asn1BitStringRef, Asn1IntegerRef, Asn1ObjectRef}; ++use bio::MemBioSlice; ++use bn::{BigNum, MSB_MAYBE_ZERO}; ++use conf::ConfRef; ++use error::ErrorStack; ++use hash::MessageDigest; ++use nid::{self, Nid}; ++use pkey::{PKey, PKeyRef}; ++use stack::{Stack, StackRef, Stackable}; ++use string::OpensslString; ++use ssl::SslRef; ++ ++#[cfg(ossl10x)] ++use ffi::{X509_set_notBefore, X509_set_notAfter, ASN1_STRING_data, X509_STORE_CTX_get_chain}; ++#[cfg(ossl110)] ++use ffi::{X509_set1_notBefore as X509_set_notBefore, X509_set1_notAfter as X509_set_notAfter, ++ ASN1_STRING_get0_data as ASN1_STRING_data, ++ X509_STORE_CTX_get0_chain as X509_STORE_CTX_get_chain}; ++ ++#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))] ++pub mod verify; ++ ++use x509::extension::{ExtensionType, Extension}; ++ ++pub mod extension; ++pub mod store; ++ ++#[cfg(test)] ++mod tests; ++ ++pub struct X509FileType(c_int); ++ ++impl X509FileType { ++ pub fn as_raw(&self) -> c_int { ++ self.0 ++ } ++} ++ ++pub const X509_FILETYPE_PEM: X509FileType = X509FileType(ffi::X509_FILETYPE_PEM); ++pub const X509_FILETYPE_ASN1: X509FileType = X509FileType(ffi::X509_FILETYPE_ASN1); ++pub const X509_FILETYPE_DEFAULT: X509FileType = X509FileType(ffi::X509_FILETYPE_DEFAULT); ++ ++foreign_type! { ++ type CType = ffi::X509_STORE_CTX; ++ fn drop = ffi::X509_STORE_CTX_free; ++ ++ pub struct X509StoreContext; ++ pub struct X509StoreContextRef; ++} ++ ++impl X509StoreContextRef { ++ pub fn error(&self) -> Option { ++ unsafe { X509VerifyError::from_raw(ffi::X509_STORE_CTX_get_error(self.as_ptr()) as c_long) } ++ } ++ ++ pub fn current_cert(&self) -> Option<&X509Ref> { ++ unsafe { ++ let ptr = ffi::X509_STORE_CTX_get_current_cert(self.as_ptr()); ++ if ptr.is_null() { ++ None ++ } else { ++ Some(X509Ref::from_ptr(ptr)) ++ } ++ } ++ } ++ ++ pub fn error_depth(&self) -> u32 { ++ unsafe { ffi::X509_STORE_CTX_get_error_depth(self.as_ptr()) as u32 } ++ } ++ ++ pub fn chain(&self) -> Option<&StackRef> { ++ unsafe { ++ let chain = X509_STORE_CTX_get_chain(self.as_ptr()); ++ ++ if chain.is_null() { ++ return None; ++ } ++ ++ Some(StackRef::from_ptr(chain)) ++ } ++ } ++ ++ /// Returns a reference to the `Ssl` associated with this context. ++ pub fn ssl(&self) -> Result, ErrorStack> { ++ unsafe { ++ let idx = try!(cvt_n(ffi::SSL_get_ex_data_X509_STORE_CTX_idx())); ++ let ssl = ffi::X509_STORE_CTX_get_ex_data(self.as_ptr(), idx); ++ if ssl.is_null() { ++ Ok(None) ++ } else { ++ Ok(Some(SslRef::from_ptr(ssl as *mut ffi::SSL))) ++ } ++ } ++ } ++} ++ ++#[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++pub struct X509Generator { ++ days: u32, ++ names: Vec<(String, String)>, ++ extensions: Extensions, ++ hash_type: MessageDigest, ++} ++ ++#[allow(deprecated)] ++impl X509Generator { ++ /// Creates a new generator with the following defaults: ++ /// ++ /// validity period: 365 days ++ /// ++ /// CN: "rust-openssl" ++ /// ++ /// hash: SHA1 ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn new() -> X509Generator { ++ X509Generator { ++ days: 365, ++ names: vec![], ++ extensions: Extensions::new(), ++ hash_type: MessageDigest::sha1(), ++ } ++ } ++ ++ /// Sets certificate validity period in days since today ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn set_valid_period(mut self, days: u32) -> X509Generator { ++ self.days = days; ++ self ++ } ++ ++ /// Add attribute to the name of the certificate ++ /// ++ /// ``` ++ /// # let generator = openssl::x509::X509Generator::new(); ++ /// generator.add_name("CN".to_string(),"example.com".to_string()); ++ /// ``` ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn add_name(mut self, attr_type: String, attr_value: String) -> X509Generator { ++ self.names.push((attr_type, attr_value)); ++ self ++ } ++ ++ /// Add multiple attributes to the name of the certificate ++ /// ++ /// ``` ++ /// # let generator = openssl::x509::X509Generator::new(); ++ /// generator.add_names(vec![("CN".to_string(),"example.com".to_string())]); ++ /// ``` ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn add_names(mut self, attrs: I) -> X509Generator ++ where ++ I: IntoIterator, ++ { ++ self.names.extend(attrs); ++ self ++ } ++ ++ /// Add an extension to a certificate ++ /// ++ /// If the extension already exists, it will be replaced. ++ /// ++ /// ``` ++ /// use openssl::x509::extension::Extension::*; ++ /// use openssl::x509::extension::KeyUsageOption::*; ++ /// ++ /// # let generator = openssl::x509::X509Generator::new(); ++ /// generator.add_extension(KeyUsage(vec![DigitalSignature, KeyEncipherment])); ++ /// ``` ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn add_extension(mut self, ext: extension::Extension) -> X509Generator { ++ self.extensions.add(ext); ++ self ++ } ++ ++ /// Add multiple extensions to a certificate ++ /// ++ /// If any of the extensions already exist, they will be replaced. ++ /// ++ /// ``` ++ /// use openssl::x509::extension::Extension::*; ++ /// use openssl::x509::extension::KeyUsageOption::*; ++ /// ++ /// # let generator = openssl::x509::X509Generator::new(); ++ /// generator.add_extensions(vec![KeyUsage(vec![DigitalSignature, KeyEncipherment])]); ++ /// ``` ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn add_extensions(mut self, exts: I) -> X509Generator ++ where ++ I: IntoIterator, ++ { ++ for ext in exts { ++ self.extensions.add(ext); ++ } ++ ++ self ++ } ++ ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn set_sign_hash(mut self, hash_type: MessageDigest) -> X509Generator { ++ self.hash_type = hash_type; ++ self ++ } ++ ++ /// Sets the certificate public-key, then self-sign and return it ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn sign(&self, p_key: &PKeyRef) -> Result { ++ let mut builder = try!(X509::builder()); ++ try!(builder.set_version(2)); ++ ++ let mut serial = try!(BigNum::new()); ++ try!(serial.rand(128, MSB_MAYBE_ZERO, false)); ++ let serial = try!(serial.to_asn1_integer()); ++ try!(builder.set_serial_number(&serial)); ++ ++ let not_before = try!(Asn1Time::days_from_now(0)); ++ try!(builder.set_not_before(¬_before)); ++ let not_after = try!(Asn1Time::days_from_now(self.days)); ++ try!(builder.set_not_after(¬_after)); ++ ++ try!(builder.set_pubkey(p_key)); ++ ++ let mut name = try!(X509Name::builder()); ++ if self.names.is_empty() { ++ try!(name.append_entry_by_nid(nid::COMMONNAME, "rust-openssl")); ++ } else { ++ for &(ref key, ref value) in &self.names { ++ try!(name.append_entry_by_text(key, value)); ++ } ++ } ++ let name = name.build(); ++ ++ try!(builder.set_subject_name(&name)); ++ try!(builder.set_issuer_name(&name)); ++ ++ for (exttype, ext) in self.extensions.iter() { ++ let extension = match exttype.get_nid() { ++ Some(nid) => { ++ let ctx = builder.x509v3_context(None, None); ++ try!(X509Extension::new_nid( ++ None, ++ Some(&ctx), ++ nid, ++ &ext.to_string(), ++ )) ++ } ++ None => { ++ let ctx = builder.x509v3_context(None, None); ++ try!(X509Extension::new( ++ None, ++ Some(&ctx), ++ &exttype.get_name().unwrap(), ++ &ext.to_string(), ++ )) ++ } ++ }; ++ try!(builder.append_extension(extension)); ++ } ++ ++ try!(builder.sign(p_key, self.hash_type)); ++ Ok(builder.build()) ++ } ++ ++ /// Obtain a certificate signing request (CSR) ++ #[deprecated(since = "0.9.7", note = "use X509Builder and X509ReqBuilder instead")] ++ pub fn request(&self, p_key: &PKeyRef) -> Result { ++ let cert = match self.sign(p_key) { ++ Ok(c) => c, ++ Err(x) => return Err(x), ++ }; ++ ++ unsafe { ++ let req = try!(cvt_p(ffi::X509_to_X509_REQ( ++ cert.as_ptr(), ++ ptr::null_mut(), ++ ptr::null(), ++ ))); ++ let req = X509Req::from_ptr(req); ++ ++ let exts = compat::X509_get0_extensions(cert.as_ptr()); ++ if exts != ptr::null_mut() { ++ try!(cvt( ++ ffi::X509_REQ_add_extensions(req.as_ptr(), exts as *mut _), ++ )); ++ } ++ ++ let hash_fn = self.hash_type.as_ptr(); ++ try!(cvt( ++ ffi::X509_REQ_sign(req.as_ptr(), p_key.as_ptr(), hash_fn), ++ )); ++ ++ Ok(req) ++ } ++ } ++} ++ ++/// A builder type which can create `X509` objects. ++pub struct X509Builder(X509); ++ ++impl X509Builder { ++ /// Creates a new builder. ++ pub fn new() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(ffi::X509_new()).map(|p| X509Builder(X509(p))) ++ } ++ } ++ ++ /// Sets the notAfter constraint on the certificate. ++ pub fn set_not_after(&mut self, not_after: &Asn1TimeRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(X509_set_notAfter(self.0.as_ptr(), not_after.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Sets the notBefore constraint on the certificate. ++ pub fn set_not_before(&mut self, not_before: &Asn1TimeRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(X509_set_notBefore(self.0.as_ptr(), not_before.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Sets the version of the certificate. ++ /// ++ /// Note that the version is zero-indexed; that is, a certificate corresponding to version 3 of ++ /// the X.509 standard should pass `2` to this method. ++ pub fn set_version(&mut self, version: i32) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::X509_set_version(self.0.as_ptr(), version.into())).map(|_| ()) } ++ } ++ ++ /// Sets the serial number of the certificate. ++ pub fn set_serial_number(&mut self, serial_number: &Asn1IntegerRef) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::X509_set_serialNumber( ++ self.0.as_ptr(), ++ serial_number.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Sets the issuer name of the certificate. ++ pub fn set_issuer_name(&mut self, issuer_name: &X509NameRef) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::X509_set_issuer_name( ++ self.0.as_ptr(), ++ issuer_name.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Sets the subject name of the certificate. ++ /// ++ /// When building certificates, the `C`, `ST`, and `O` options are common when using the openssl command line tools. ++ /// The `CN` field is used for the common name, such as a DNS name. ++ /// ++ /// ``` ++ /// use openssl::x509::{X509, X509NameBuilder}; ++ /// ++ /// let mut x509_name = openssl::x509::X509NameBuilder::new().unwrap(); ++ /// x509_name.append_entry_by_text("C", "US").unwrap(); ++ /// x509_name.append_entry_by_text("ST", "CA").unwrap(); ++ /// x509_name.append_entry_by_text("O", "Some organization").unwrap(); ++ /// x509_name.append_entry_by_text("CN", "www.example.com").unwrap(); ++ /// let x509_name = x509_name.build(); ++ /// ++ /// let mut x509 = openssl::x509::X509::builder().unwrap(); ++ /// x509.set_subject_name(&x509_name).unwrap(); ++ /// ``` ++ pub fn set_subject_name(&mut self, subject_name: &X509NameRef) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::X509_set_subject_name( ++ self.0.as_ptr(), ++ subject_name.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ /// Sets the public key associated with the certificate. ++ pub fn set_pubkey(&mut self, key: &PKeyRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::X509_set_pubkey(self.0.as_ptr(), key.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Returns a context object which is needed to create certain X509 extension values. ++ /// ++ /// Set `issuer` to `None` if the certificate will be self-signed. ++ pub fn x509v3_context<'a>( ++ &'a self, ++ issuer: Option<&'a X509Ref>, ++ conf: Option<&'a ConfRef>, ++ ) -> X509v3Context<'a> { ++ unsafe { ++ let mut ctx = mem::zeroed(); ++ ++ let issuer = match issuer { ++ Some(issuer) => issuer.as_ptr(), ++ None => self.0.as_ptr(), ++ }; ++ let subject = self.0.as_ptr(); ++ ffi::X509V3_set_ctx( ++ &mut ctx, ++ issuer, ++ subject, ++ ptr::null_mut(), ++ ptr::null_mut(), ++ 0, ++ ); ++ ++ // nodb case taken care of since we zeroed ctx above ++ if let Some(conf) = conf { ++ ffi::X509V3_set_nconf(&mut ctx, conf.as_ptr()); ++ } ++ ++ X509v3Context(ctx, PhantomData) ++ } ++ } ++ ++ /// Adds an X509 extension value to the certificate. ++ pub fn append_extension(&mut self, extension: X509Extension) -> Result<(), ErrorStack> { ++ unsafe { ++ try!(cvt( ++ ffi::X509_add_ext(self.0.as_ptr(), extension.as_ptr(), -1), ++ )); ++ mem::forget(extension); ++ Ok(()) ++ } ++ } ++ ++ /// Signs the certificate with a private key. ++ pub fn sign(&mut self, key: &PKeyRef, hash: MessageDigest) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::X509_sign(self.0.as_ptr(), key.as_ptr(), hash.as_ptr())).map(|_| ()) } ++ } ++ ++ /// Consumes the builder, returning the certificate. ++ pub fn build(self) -> X509 { ++ self.0 ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::X509; ++ fn drop = ffi::X509_free; ++ ++ pub struct X509; ++ pub struct X509Ref; ++} ++ ++impl X509Ref { ++ pub fn subject_name(&self) -> &X509NameRef { ++ unsafe { ++ let name = ffi::X509_get_subject_name(self.as_ptr()); ++ X509NameRef::from_ptr(name) ++ } ++ } ++ ++ /// Returns this certificate's SAN entries, if they exist. ++ pub fn subject_alt_names(&self) -> Option> { ++ unsafe { ++ let stack = ffi::X509_get_ext_d2i( ++ self.as_ptr(), ++ ffi::NID_subject_alt_name, ++ ptr::null_mut(), ++ ptr::null_mut(), ++ ); ++ if stack.is_null() { ++ return None; ++ } ++ ++ Some(Stack::from_ptr(stack as *mut _)) ++ } ++ } ++ ++ pub fn public_key(&self) -> Result { ++ unsafe { ++ let pkey = try!(cvt_p(ffi::X509_get_pubkey(self.as_ptr()))); ++ Ok(PKey::from_ptr(pkey)) ++ } ++ } ++ ++ /// Returns certificate fingerprint calculated using provided hash ++ pub fn fingerprint(&self, hash_type: MessageDigest) -> Result, ErrorStack> { ++ unsafe { ++ let evp = hash_type.as_ptr(); ++ let mut len = ffi::EVP_MAX_MD_SIZE; ++ let mut buf = vec![0u8; len as usize]; ++ try!(cvt(ffi::X509_digest( ++ self.as_ptr(), ++ evp, ++ buf.as_mut_ptr() as *mut _, ++ &mut len, ++ ))); ++ buf.truncate(len as usize); ++ Ok(buf) ++ } ++ } ++ ++ /// Returns the certificate's Not After validity period. ++ pub fn not_after(&self) -> &Asn1TimeRef { ++ unsafe { ++ let date = compat::X509_get_notAfter(self.as_ptr()); ++ assert!(!date.is_null()); ++ Asn1TimeRef::from_ptr(date) ++ } ++ } ++ ++ /// Returns the certificate's Not Before validity period. ++ pub fn not_before(&self) -> &Asn1TimeRef { ++ unsafe { ++ let date = compat::X509_get_notBefore(self.as_ptr()); ++ assert!(!date.is_null()); ++ Asn1TimeRef::from_ptr(date) ++ } ++ } ++ ++ /// Returns the certificate's signature ++ pub fn signature(&self) -> &Asn1BitStringRef { ++ unsafe { ++ let mut signature = ptr::null(); ++ compat::X509_get0_signature(&mut signature, ptr::null_mut(), self.as_ptr()); ++ assert!(!signature.is_null()); ++ Asn1BitStringRef::from_ptr(signature as *mut _) ++ } ++ } ++ ++ /// Returns the certificate's signature algorithm. ++ pub fn signature_algorithm(&self) -> &X509AlgorithmRef { ++ unsafe { ++ let mut algor = ptr::null(); ++ compat::X509_get0_signature(ptr::null_mut(), &mut algor, self.as_ptr()); ++ assert!(!algor.is_null()); ++ X509AlgorithmRef::from_ptr(algor as *mut _) ++ } ++ } ++ ++ /// Returns the list of OCSP responder URLs specified in the certificate's Authority Information ++ /// Access field. ++ pub fn ocsp_responders(&self) -> Result, ErrorStack> { ++ unsafe { cvt_p(ffi::X509_get1_ocsp(self.as_ptr())).map(|p| Stack::from_ptr(p)) } ++ } ++ ++ /// Checks that this certificate issued `subject`. ++ pub fn issued(&self, subject: &X509Ref) -> Result<(), X509VerifyError> { ++ unsafe { ++ let r = ffi::X509_check_issued(self.as_ptr(), subject.as_ptr()); ++ match X509VerifyError::from_raw(r as c_long) { ++ Some(e) => Err(e), ++ None => Ok(()), ++ } ++ } ++ } ++ ++ to_pem!(ffi::PEM_write_bio_X509); ++ to_der!(ffi::i2d_X509); ++} ++ ++impl ToOwned for X509Ref { ++ type Owned = X509; ++ ++ fn to_owned(&self) -> X509 { ++ unsafe { ++ compat::X509_up_ref(self.as_ptr()); ++ X509::from_ptr(self.as_ptr()) ++ } ++ } ++} ++ ++impl X509 { ++ /// Returns a new builder. ++ pub fn builder() -> Result { ++ X509Builder::new() ++ } ++ ++ from_pem!(X509, ffi::PEM_read_bio_X509); ++ from_der!(X509, ffi::d2i_X509); ++ ++ /// Deserializes a list of PEM-formatted certificates. ++ pub fn stack_from_pem(pem: &[u8]) -> Result, ErrorStack> { ++ unsafe { ++ ffi::init(); ++ let bio = try!(MemBioSlice::new(pem)); ++ ++ let mut certs = vec![]; ++ loop { ++ let r = ++ ffi::PEM_read_bio_X509(bio.as_ptr(), ptr::null_mut(), None, ptr::null_mut()); ++ if r.is_null() { ++ let err = ffi::ERR_peek_last_error(); ++ if ffi::ERR_GET_LIB(err) == ffi::ERR_LIB_PEM && ++ ffi::ERR_GET_REASON(err) == ffi::PEM_R_NO_START_LINE ++ { ++ ffi::ERR_clear_error(); ++ break; ++ } ++ ++ return Err(ErrorStack::get()); ++ } else { ++ certs.push(X509(r)); ++ } ++ } ++ ++ Ok(certs) ++ } ++ } ++} ++ ++impl Clone for X509 { ++ fn clone(&self) -> X509 { ++ X509Ref::to_owned(self) ++ } ++} ++ ++impl AsRef for X509 { ++ fn as_ref(&self) -> &X509Ref { ++ &*self ++ } ++} ++ ++impl AsRef for X509Ref { ++ fn as_ref(&self) -> &X509Ref { ++ self ++ } ++} ++ ++impl Borrow for X509 { ++ fn borrow(&self) -> &X509Ref { ++ &*self ++ } ++} ++ ++impl Stackable for X509 { ++ type StackType = ffi::stack_st_X509; ++} ++ ++/// A context object required to construct certain X509 extension values. ++pub struct X509v3Context<'a>(ffi::X509V3_CTX, PhantomData<(&'a X509Ref, &'a ConfRef)>); ++ ++impl<'a> X509v3Context<'a> { ++ pub fn as_ptr(&self) -> *mut ffi::X509V3_CTX { ++ &self.0 as *const _ as *mut _ ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::X509_EXTENSION; ++ fn drop = ffi::X509_EXTENSION_free; ++ ++ pub struct X509Extension; ++ pub struct X509ExtensionRef; ++} ++ ++impl Stackable for X509Extension { ++ type StackType = ffi::stack_st_X509_EXTENSION; ++} ++ ++impl X509Extension { ++ /// Constructs an X509 extension value. See `man x509v3_config` for information on supported ++ /// names and their value formats. ++ /// ++ /// Some extension types, such as `subjectAlternativeName`, require an `X509v3Context` to be ++ /// provided. ++ /// ++ /// See the extension module for builder types which will construct certain common extensions. ++ pub fn new( ++ conf: Option<&ConfRef>, ++ context: Option<&X509v3Context>, ++ name: &str, ++ value: &str, ++ ) -> Result { ++ let name = CString::new(name).unwrap(); ++ let value = CString::new(value).unwrap(); ++ unsafe { ++ ffi::init(); ++ let conf = conf.map_or(ptr::null_mut(), ConfRef::as_ptr); ++ let context = context.map_or(ptr::null_mut(), X509v3Context::as_ptr); ++ let name = name.as_ptr() as *mut _; ++ let value = value.as_ptr() as *mut _; ++ ++ cvt_p(ffi::X509V3_EXT_nconf(conf, context, name, value)).map(X509Extension) ++ } ++ } ++ ++ /// Constructs an X509 extension value. See `man x509v3_config` for information on supported ++ /// extensions and their value formats. ++ /// ++ /// Some extension types, such as `nid::SUBJECT_ALTERNATIVE_NAME`, require an `X509v3Context` to ++ /// be provided. ++ /// ++ /// See the extension module for builder types which will construct certain common extensions. ++ pub fn new_nid( ++ conf: Option<&ConfRef>, ++ context: Option<&X509v3Context>, ++ name: Nid, ++ value: &str, ++ ) -> Result { ++ let value = CString::new(value).unwrap(); ++ unsafe { ++ ffi::init(); ++ let conf = conf.map_or(ptr::null_mut(), ConfRef::as_ptr); ++ let context = context.map_or(ptr::null_mut(), X509v3Context::as_ptr); ++ let name = name.as_raw(); ++ let value = value.as_ptr() as *mut _; ++ ++ cvt_p(ffi::X509V3_EXT_nconf_nid(conf, context, name, value)).map(X509Extension) ++ } ++ } ++} ++ ++pub struct X509NameBuilder(X509Name); ++ ++impl X509NameBuilder { ++ pub fn new() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(ffi::X509_NAME_new()).map(|p| X509NameBuilder(X509Name(p))) ++ } ++ } ++ ++ pub fn append_entry_by_text(&mut self, field: &str, value: &str) -> Result<(), ErrorStack> { ++ unsafe { ++ let field = CString::new(field).unwrap(); ++ assert!(value.len() <= c_int::max_value() as usize); ++ cvt(ffi::X509_NAME_add_entry_by_txt( ++ self.0.as_ptr(), ++ field.as_ptr() as *mut _, ++ ffi::MBSTRING_UTF8, ++ value.as_ptr(), ++ value.len() as c_int, ++ -1, ++ 0, ++ )).map(|_| ()) ++ } ++ } ++ ++ pub fn append_entry_by_nid(&mut self, field: Nid, value: &str) -> Result<(), ErrorStack> { ++ unsafe { ++ assert!(value.len() <= c_int::max_value() as usize); ++ cvt(ffi::X509_NAME_add_entry_by_NID( ++ self.0.as_ptr(), ++ field.as_raw(), ++ ffi::MBSTRING_UTF8, ++ value.as_ptr() as *mut _, ++ value.len() as c_int, ++ -1, ++ 0, ++ )).map(|_| ()) ++ } ++ } ++ ++ pub fn build(self) -> X509Name { ++ self.0 ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::X509_NAME; ++ fn drop = ffi::X509_NAME_free; ++ ++ pub struct X509Name; ++ pub struct X509NameRef; ++} ++ ++impl X509Name { ++ /// Returns a new builder. ++ pub fn builder() -> Result { ++ X509NameBuilder::new() ++ } ++ ++ /// Loads subject names from a file containing PEM-formatted certificates. ++ /// ++ /// This is commonly used in conjunction with `SslContextBuilder::set_client_ca_list`. ++ pub fn load_client_ca_file>(file: P) -> Result, ErrorStack> { ++ let file = CString::new(file.as_ref().as_os_str().to_str().unwrap()).unwrap(); ++ unsafe { cvt_p(ffi::SSL_load_client_CA_file(file.as_ptr())).map(|p| Stack::from_ptr(p)) } ++ } ++} ++ ++impl Stackable for X509Name { ++ type StackType = ffi::stack_st_X509_NAME; ++} ++ ++impl X509NameRef { ++ pub fn entries_by_nid<'a>(&'a self, nid: Nid) -> X509NameEntries<'a> { ++ X509NameEntries { ++ name: self, ++ nid: nid, ++ loc: -1, ++ } ++ } ++} ++ ++pub struct X509NameEntries<'a> { ++ name: &'a X509NameRef, ++ nid: Nid, ++ loc: c_int, ++} ++ ++impl<'a> Iterator for X509NameEntries<'a> { ++ type Item = &'a X509NameEntryRef; ++ ++ fn next(&mut self) -> Option<&'a X509NameEntryRef> { ++ unsafe { ++ self.loc = ++ ffi::X509_NAME_get_index_by_NID(self.name.as_ptr(), self.nid.as_raw(), self.loc); ++ ++ if self.loc == -1 { ++ return None; ++ } ++ ++ let entry = ffi::X509_NAME_get_entry(self.name.as_ptr(), self.loc); ++ assert!(!entry.is_null()); ++ ++ Some(X509NameEntryRef::from_ptr(entry)) ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::X509_NAME_ENTRY; ++ fn drop = ffi::X509_NAME_ENTRY_free; ++ ++ pub struct X509NameEntry; ++ pub struct X509NameEntryRef; ++} ++ ++impl X509NameEntryRef { ++ pub fn data(&self) -> &Asn1StringRef { ++ unsafe { ++ let data = ffi::X509_NAME_ENTRY_get_data(self.as_ptr()); ++ Asn1StringRef::from_ptr(data) ++ } ++ } ++} ++ ++pub struct X509ReqBuilder(X509Req); ++ ++impl X509ReqBuilder { ++ pub fn new() -> Result { ++ unsafe { ++ ffi::init(); ++ cvt_p(ffi::X509_REQ_new()).map(|p| X509ReqBuilder(X509Req(p))) ++ } ++ ++ } ++ ++ pub fn set_version(&mut self, version: i32) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::X509_REQ_set_version(self.0.as_ptr(), version.into())).map(|_| ()) } ++ } ++ ++ pub fn set_subject_name(&mut self, subject_name: &X509NameRef) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::X509_REQ_set_subject_name( ++ self.0.as_ptr(), ++ subject_name.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ pub fn set_pubkey(&mut self, key: &PKeyRef) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::X509_REQ_set_pubkey(self.0.as_ptr(), key.as_ptr())).map(|_| ()) } ++ } ++ ++ pub fn x509v3_context<'a>(&'a self, conf: Option<&'a ConfRef>) -> X509v3Context<'a> { ++ unsafe { ++ let mut ctx = mem::zeroed(); ++ ++ ffi::X509V3_set_ctx( ++ &mut ctx, ++ ptr::null_mut(), ++ ptr::null_mut(), ++ self.0.as_ptr(), ++ ptr::null_mut(), ++ 0, ++ ); ++ ++ // nodb case taken care of since we zeroed ctx above ++ if let Some(conf) = conf { ++ ffi::X509V3_set_nconf(&mut ctx, conf.as_ptr()); ++ } ++ ++ X509v3Context(ctx, PhantomData) ++ } ++ } ++ ++ pub fn add_extensions( ++ &mut self, ++ extensions: &StackRef, ++ ) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::X509_REQ_add_extensions( ++ self.0.as_ptr(), ++ extensions.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ pub fn sign(&mut self, key: &PKeyRef, hash: MessageDigest) -> Result<(), ErrorStack> { ++ unsafe { ++ cvt(ffi::X509_REQ_sign( ++ self.0.as_ptr(), ++ key.as_ptr(), ++ hash.as_ptr(), ++ )).map(|_| ()) ++ } ++ } ++ ++ pub fn build(self) -> X509Req { ++ self.0 ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::X509_REQ; ++ fn drop = ffi::X509_REQ_free; ++ ++ pub struct X509Req; ++ pub struct X509ReqRef; ++} ++ ++impl X509Req { ++ pub fn builder() -> Result { ++ X509ReqBuilder::new() ++ } ++ ++ /// Reads CSR from PEM ++ pub fn from_pem(buf: &[u8]) -> Result { ++ let mem_bio = try!(MemBioSlice::new(buf)); ++ unsafe { ++ let handle = try!(cvt_p(ffi::PEM_read_bio_X509_REQ( ++ mem_bio.as_ptr(), ++ ptr::null_mut(), ++ None, ++ ptr::null_mut(), ++ ))); ++ Ok(X509Req::from_ptr(handle)) ++ } ++ } ++ ++ from_der!(X509Req, ffi::d2i_X509_REQ); ++} ++ ++impl X509ReqRef { ++ to_pem!(ffi::PEM_write_bio_X509_REQ); ++ to_der!(ffi::i2d_X509_REQ); ++ ++ pub fn version(&self) -> i32 { ++ unsafe { compat::X509_REQ_get_version(self.as_ptr()) as i32 } ++ } ++ ++ pub fn subject_name(&self) -> &X509NameRef { ++ unsafe { ++ let name = compat::X509_REQ_get_subject_name(self.as_ptr()); ++ assert!(!name.is_null()); ++ X509NameRef::from_ptr(name) ++ } ++ } ++} ++ ++/// A collection of X.509 extensions. ++/// ++/// Upholds the invariant that a certificate MUST NOT include more than one ++/// instance of a particular extension, according to RFC 3280 §4.2. Also ++/// ensures that extensions are added to the certificate during signing ++/// in the order they were inserted, which is required for certain ++/// extensions like SubjectKeyIdentifier and AuthorityKeyIdentifier. ++struct Extensions { ++ /// The extensions contained in the collection. ++ extensions: Vec, ++ /// A map of used to keep track of added extensions and their indexes in `self.extensions`. ++ indexes: HashMap, ++} ++ ++impl Extensions { ++ /// Creates a new `Extensions`. ++ pub fn new() -> Extensions { ++ Extensions { ++ extensions: vec![], ++ indexes: HashMap::new(), ++ } ++ } ++ ++ /// Adds a new `Extension`, replacing any existing one of the same ++ /// `ExtensionType`. ++ pub fn add(&mut self, ext: Extension) { ++ let ext_type = ext.get_type(); ++ ++ if let Some(index) = self.indexes.get(&ext_type) { ++ self.extensions[*index] = ext; ++ return; ++ } ++ ++ self.extensions.push(ext); ++ self.indexes.insert(ext_type, self.extensions.len() - 1); ++ } ++ ++ /// Returns an `ExtensionsIter` for the collection. ++ pub fn iter(&self) -> ExtensionsIter { ++ ExtensionsIter { ++ current: 0, ++ extensions: &self.extensions, ++ } ++ } ++} ++ ++/// An iterator that iterates over `(ExtensionType, Extension)` for each ++/// extension in the collection. ++struct ExtensionsIter<'a> { ++ current: usize, ++ extensions: &'a Vec, ++} ++ ++impl<'a> Iterator for ExtensionsIter<'a> { ++ type Item = (ExtensionType, &'a Extension); ++ ++ fn next(&mut self) -> Option { ++ if self.current < self.extensions.len() { ++ let ext = &self.extensions[self.current]; ++ ++ self.current += 1; ++ ++ Some((ext.get_type(), ext)) ++ } else { ++ None ++ } ++ } ++} ++ ++pub struct X509VerifyError(c_long); ++ ++impl fmt::Debug for X509VerifyError { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ fmt.debug_struct("X509VerifyError") ++ .field("code", &self.0) ++ .field("error", &self.error_string()) ++ .finish() ++ } ++} ++ ++impl fmt::Display for X509VerifyError { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ fmt.write_str(self.error_string()) ++ } ++} ++ ++impl Error for X509VerifyError { ++ fn description(&self) -> &str { ++ "an X509 validation error" ++ } ++} ++ ++impl X509VerifyError { ++ /// Creates an `X509VerifyError` from a raw error number. ++ /// ++ /// `None` will be returned if `err` is `X509_V_OK`. ++ /// ++ /// # Safety ++ /// ++ /// Some methods on `X509VerifyError` are not thread safe if the error ++ /// number is invalid. ++ pub unsafe fn from_raw(err: c_long) -> Option { ++ if err == ffi::X509_V_OK as c_long { ++ None ++ } else { ++ Some(X509VerifyError(err)) ++ } ++ } ++ ++ pub fn as_raw(&self) -> c_long { ++ self.0 ++ } ++ ++ pub fn error_string(&self) -> &'static str { ++ ffi::init(); ++ ++ unsafe { ++ let s = ffi::X509_verify_cert_error_string(self.0); ++ str::from_utf8(CStr::from_ptr(s).to_bytes()).unwrap() ++ } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::GENERAL_NAME; ++ fn drop = ffi::GENERAL_NAME_free; ++ ++ pub struct GeneralName; ++ pub struct GeneralNameRef; ++} ++ ++impl GeneralNameRef { ++ /// Returns the contents of this `GeneralName` if it is a `dNSName`. ++ pub fn dnsname(&self) -> Option<&str> { ++ unsafe { ++ if (*self.as_ptr()).type_ != ffi::GEN_DNS { ++ return None; ++ } ++ ++ let ptr = ASN1_STRING_data((*self.as_ptr()).d as *mut _); ++ let len = ffi::ASN1_STRING_length((*self.as_ptr()).d as *mut _); ++ ++ let slice = slice::from_raw_parts(ptr as *const u8, len as usize); ++ // dNSNames are stated to be ASCII (specifically IA5). Hopefully ++ // OpenSSL checks that when loading a certificate but if not we'll ++ // use this instead of from_utf8_unchecked just in case. ++ str::from_utf8(slice).ok() ++ } ++ } ++ ++ /// Returns the contents of this `GeneralName` if it is an `iPAddress`. ++ pub fn ipaddress(&self) -> Option<&[u8]> { ++ unsafe { ++ if (*self.as_ptr()).type_ != ffi::GEN_IPADD { ++ return None; ++ } ++ ++ let ptr = ASN1_STRING_data((*self.as_ptr()).d as *mut _); ++ let len = ffi::ASN1_STRING_length((*self.as_ptr()).d as *mut _); ++ ++ Some(slice::from_raw_parts(ptr as *const u8, len as usize)) ++ } ++ } ++} ++ ++impl Stackable for GeneralName { ++ type StackType = ffi::stack_st_GENERAL_NAME; ++} ++ ++foreign_type! { ++ type CType = ffi::X509_ALGOR; ++ fn drop = ffi::X509_ALGOR_free; ++ ++ pub struct X509Algorithm; ++ pub struct X509AlgorithmRef; ++} ++ ++impl X509AlgorithmRef { ++ /// Returns the ASN.1 OID of this algorithm. ++ pub fn object(&self) -> &Asn1ObjectRef { ++ unsafe { ++ let mut oid = ptr::null(); ++ compat::X509_ALGOR_get0(&mut oid, ptr::null_mut(), ptr::null_mut(), self.as_ptr()); ++ assert!(!oid.is_null()); ++ Asn1ObjectRef::from_ptr(oid as *mut _) ++ } ++ } ++} ++ ++#[cfg(ossl110)] ++mod compat { ++ pub use ffi::X509_getm_notAfter as X509_get_notAfter; ++ pub use ffi::X509_getm_notBefore as X509_get_notBefore; ++ pub use ffi::X509_up_ref; ++ pub use ffi::X509_get0_extensions; ++ pub use ffi::X509_REQ_get_version; ++ pub use ffi::X509_REQ_get_subject_name; ++ pub use ffi::X509_get0_signature; ++ pub use ffi::X509_ALGOR_get0; ++} ++ ++#[cfg(ossl10x)] ++#[allow(bad_style)] ++mod compat { ++ use libc::{c_int, c_void}; ++ use ffi; ++ ++ pub unsafe fn X509_get_notAfter(x: *mut ffi::X509) -> *mut ffi::ASN1_TIME { ++ (*(*(*x).cert_info).validity).notAfter ++ } ++ ++ pub unsafe fn X509_get_notBefore(x: *mut ffi::X509) -> *mut ffi::ASN1_TIME { ++ (*(*(*x).cert_info).validity).notBefore ++ } ++ ++ pub unsafe fn X509_up_ref(x: *mut ffi::X509) { ++ ffi::CRYPTO_add_lock( ++ &mut (*x).references, ++ 1, ++ ffi::CRYPTO_LOCK_X509, ++ "mod.rs\0".as_ptr() as *const _, ++ line!() as c_int, ++ ); ++ } ++ ++ pub unsafe fn X509_get0_extensions( ++ cert: *const ffi::X509, ++ ) -> *const ffi::stack_st_X509_EXTENSION { ++ let info = (*cert).cert_info; ++ if info.is_null() { ++ 0 as *mut _ ++ } else { ++ (*info).extensions ++ } ++ } ++ ++ pub unsafe fn X509_REQ_get_version(x: *mut ffi::X509_REQ) -> ::libc::c_long { ++ ::ffi::ASN1_INTEGER_get((*(*x).req_info).version) ++ } ++ ++ pub unsafe fn X509_REQ_get_subject_name(x: *mut ffi::X509_REQ) -> *mut ::ffi::X509_NAME { ++ (*(*x).req_info).subject ++ } ++ ++ pub unsafe fn X509_get0_signature( ++ psig: *mut *const ffi::ASN1_BIT_STRING, ++ palg: *mut *const ffi::X509_ALGOR, ++ x: *const ffi::X509, ++ ) { ++ if !psig.is_null() { ++ *psig = (*x).signature; ++ } ++ if !palg.is_null() { ++ *palg = (*x).sig_alg; ++ } ++ } ++ ++ pub unsafe fn X509_ALGOR_get0( ++ paobj: *mut *const ffi::ASN1_OBJECT, ++ pptype: *mut c_int, ++ pval: *mut *mut c_void, ++ alg: *const ffi::X509_ALGOR, ++ ) { ++ if !paobj.is_null() { ++ *paobj = (*alg).algorithm; ++ } ++ assert!(pptype.is_null()); ++ assert!(pval.is_null()); ++ } ++} diff --cc vendor/openssl-0.9.19/src/x509/store.rs index 000000000,000000000..198679b53 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/x509/store.rs @@@ -1,0 -1,0 +1,63 @@@ ++use ffi; ++use foreign_types::ForeignTypeRef; ++use std::mem; ++ ++use {cvt, cvt_p}; ++use error::ErrorStack; ++use x509::X509; ++ ++foreign_type! { ++ type CType = ffi::X509_STORE; ++ fn drop = ffi::X509_STORE_free; ++ ++ pub struct X509StoreBuilder; ++ pub struct X509StoreBuilderRef; ++} ++ ++impl X509StoreBuilder { ++ /// Returns a builder for a certificate store. ++ /// ++ /// The store is initially empty. ++ pub fn new() -> Result { ++ unsafe { ++ ffi::init(); ++ ++ cvt_p(ffi::X509_STORE_new()).map(X509StoreBuilder) ++ } ++ } ++ ++ /// Constructs the `X509Store`. ++ pub fn build(self) -> X509Store { ++ let store = X509Store(self.0); ++ mem::forget(self); ++ store ++ } ++} ++ ++impl X509StoreBuilderRef { ++ /// Adds a certificate to the certificate store. ++ pub fn add_cert(&mut self, cert: X509) -> Result<(), ErrorStack> { ++ unsafe { ++ let ptr = cert.as_ptr(); ++ mem::forget(cert); // the cert will be freed inside of X509_STORE_add_cert on error ++ cvt(ffi::X509_STORE_add_cert(self.as_ptr(), ptr)).map(|_| ()) ++ } ++ } ++ ++ /// Load certificates from their default locations. ++ /// ++ /// These locations are read from the `SSL_CERT_FILE` and `SSL_CERT_DIR` ++ /// environment variables if present, or defaults specified at OpenSSL ++ /// build time otherwise. ++ pub fn set_default_paths(&mut self) -> Result<(), ErrorStack> { ++ unsafe { cvt(ffi::X509_STORE_set_default_paths(self.as_ptr())).map(|_| ()) } ++ } ++} ++ ++foreign_type! { ++ type CType = ffi::X509_STORE; ++ fn drop = ffi::X509_STORE_free; ++ ++ pub struct X509Store; ++ pub struct X509StoreRef; ++} diff --cc vendor/openssl-0.9.19/src/x509/tests.rs index 000000000,000000000..76eeba3fe new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/x509/tests.rs @@@ -1,0 -1,0 +1,407 @@@ ++use hex::{FromHex, ToHex}; ++ ++use asn1::Asn1Time; ++use bn::{BigNum, MSB_MAYBE_ZERO}; ++use ec::{NAMED_CURVE, EcGroup, EcKey}; ++use hash::MessageDigest; ++use nid::X9_62_PRIME256V1; ++use pkey::PKey; ++use rsa::Rsa; ++use stack::Stack; ++use x509::{X509, X509Generator, X509Name, X509Req}; ++use x509::extension::{Extension, BasicConstraints, KeyUsage, ExtendedKeyUsage, ++ SubjectKeyIdentifier, AuthorityKeyIdentifier, SubjectAlternativeName}; ++use ssl::{SslMethod, SslContextBuilder}; ++use x509::extension::AltNameOption as SAN; ++use x509::extension::KeyUsageOption::{DigitalSignature, KeyEncipherment}; ++use x509::extension::ExtKeyUsageOption::{self, ClientAuth, ServerAuth}; ++use nid; ++ ++fn get_generator() -> X509Generator { ++ X509Generator::new() ++ .set_valid_period(365 * 2) ++ .add_name("CN".to_string(), "test_me".to_string()) ++ .set_sign_hash(MessageDigest::sha1()) ++ .add_extension(Extension::KeyUsage(vec![DigitalSignature, KeyEncipherment])) ++ .add_extension(Extension::ExtKeyUsage(vec![ ++ ClientAuth, ++ ServerAuth, ++ ExtKeyUsageOption::Other("2.999.1".to_owned()), ++ ])) ++ .add_extension(Extension::SubjectAltName( ++ vec![(SAN::DNS, "example.com".to_owned())], ++ )) ++ .add_extension(Extension::OtherNid( ++ nid::BASIC_CONSTRAINTS, ++ "critical,CA:TRUE".to_owned(), ++ )) ++ .add_extension(Extension::OtherStr( ++ "2.999.2".to_owned(), ++ "ASN1:UTF8:example value".to_owned(), ++ )) ++} ++ ++fn pkey() -> PKey { ++ let rsa = Rsa::generate(2048).unwrap(); ++ PKey::from_rsa(rsa).unwrap() ++} ++ ++#[test] ++fn test_cert_gen() { ++ let pkey = pkey(); ++ let cert = get_generator().sign(&pkey).unwrap(); ++ ++ // FIXME: check data in result to be correct, needs implementation ++ // of X509 getters ++ ++ assert_eq!( ++ pkey.public_key_to_pem().unwrap(), ++ cert.public_key().unwrap().public_key_to_pem().unwrap() ++ ); ++} ++ ++/// SubjectKeyIdentifier must be added before AuthorityKeyIdentifier or OpenSSL ++/// is "unable to get issuer keyid." This test ensures the order of insertion ++/// for extensions is preserved when the cert is signed. ++#[test] ++fn test_cert_gen_extension_ordering() { ++ let pkey = pkey(); ++ get_generator() ++ .add_extension(Extension::OtherNid( ++ nid::SUBJECT_KEY_IDENTIFIER, ++ "hash".to_owned(), ++ )) ++ .add_extension(Extension::OtherNid( ++ nid::AUTHORITY_KEY_IDENTIFIER, ++ "keyid:always".to_owned(), ++ )) ++ .sign(&pkey) ++ .expect("Failed to generate cert with order-dependent extensions"); ++} ++ ++/// Proves that a passing result from `test_cert_gen_extension_ordering` is ++/// deterministic by reversing the order of extensions and asserting failure. ++#[test] ++fn test_cert_gen_extension_bad_ordering() { ++ let pkey = pkey(); ++ let result = get_generator() ++ .add_extension(Extension::OtherNid( ++ nid::AUTHORITY_KEY_IDENTIFIER, ++ "keyid:always".to_owned(), ++ )) ++ .add_extension(Extension::OtherNid( ++ nid::SUBJECT_KEY_IDENTIFIER, ++ "hash".to_owned(), ++ )) ++ .sign(&pkey); ++ ++ assert!(result.is_err()); ++} ++ ++#[test] ++fn test_req_gen() { ++ let pkey = pkey(); ++ ++ let req = get_generator().request(&pkey).unwrap(); ++ let reqpem = req.to_pem().unwrap(); ++ ++ let req = X509Req::from_pem(&reqpem).ok().expect("Failed to load PEM"); ++ let cn = (*req) ++ .subject_name() ++ .entries_by_nid(nid::COMMONNAME) ++ .next() ++ .unwrap(); ++ assert_eq!(0, (*req).version()); ++ assert_eq!(cn.data().as_slice(), b"test_me"); ++ ++ // FIXME: check data in result to be correct, needs implementation ++ // of X509_REQ getters ++} ++ ++#[test] ++fn test_cert_loading() { ++ let cert = include_bytes!("../../test/cert.pem"); ++ let cert = X509::from_pem(cert).ok().expect("Failed to load PEM"); ++ let fingerprint = cert.fingerprint(MessageDigest::sha1()).unwrap(); ++ ++ let hash_str = "59172d9313e84459bcff27f967e79e6e9217e584"; ++ let hash_vec = Vec::from_hex(hash_str).unwrap(); ++ ++ assert_eq!(fingerprint, hash_vec); ++} ++ ++#[test] ++fn test_cert_issue_validity() { ++ let cert = include_bytes!("../../test/cert.pem"); ++ let cert = X509::from_pem(cert).ok().expect("Failed to load PEM"); ++ let not_before = cert.not_before().to_string(); ++ let not_after = cert.not_after().to_string(); ++ ++ assert_eq!(not_before, "Aug 14 17:00:03 2016 GMT"); ++ assert_eq!(not_after, "Aug 12 17:00:03 2026 GMT"); ++} ++ ++#[test] ++fn test_save_der() { ++ let cert = include_bytes!("../../test/cert.pem"); ++ let cert = X509::from_pem(cert).ok().expect("Failed to load PEM"); ++ ++ let der = cert.to_der().unwrap(); ++ assert!(!der.is_empty()); ++} ++ ++#[test] ++fn test_subject_read_cn() { ++ let cert = include_bytes!("../../test/cert.pem"); ++ let cert = X509::from_pem(cert).unwrap(); ++ let subject = cert.subject_name(); ++ let cn = subject.entries_by_nid(nid::COMMONNAME).next().unwrap(); ++ assert_eq!(cn.data().as_slice(), b"foobar.com") ++} ++ ++#[test] ++fn test_nid_values() { ++ let cert = include_bytes!("../../test/nid_test_cert.pem"); ++ let cert = X509::from_pem(cert).unwrap(); ++ let subject = cert.subject_name(); ++ ++ let cn = subject.entries_by_nid(nid::COMMONNAME).next().unwrap(); ++ assert_eq!(cn.data().as_slice(), b"example.com"); ++ ++ let email = subject ++ .entries_by_nid(nid::PKCS9_EMAILADDRESS) ++ .next() ++ .unwrap(); ++ assert_eq!(email.data().as_slice(), b"test@example.com"); ++ ++ let friendly = subject.entries_by_nid(nid::FRIENDLYNAME).next().unwrap(); ++ assert_eq!(&**friendly.data().as_utf8().unwrap(), "Example"); ++} ++ ++#[test] ++fn test_nid_uid_value() { ++ let cert = include_bytes!("../../test/nid_uid_test_cert.pem"); ++ let cert = X509::from_pem(cert).unwrap(); ++ let subject = cert.subject_name(); ++ ++ let cn = subject.entries_by_nid(nid::USERID).next().unwrap(); ++ assert_eq!(cn.data().as_slice(), b"this is the userId"); ++} ++ ++#[test] ++fn test_subject_alt_name() { ++ let cert = include_bytes!("../../test/alt_name_cert.pem"); ++ let cert = X509::from_pem(cert).unwrap(); ++ ++ let subject_alt_names = cert.subject_alt_names().unwrap(); ++ assert_eq!(3, subject_alt_names.len()); ++ assert_eq!(Some("foobar.com"), subject_alt_names[0].dnsname()); ++ assert_eq!(subject_alt_names[1].ipaddress(), Some(&[127, 0, 0, 1][..])); ++ assert_eq!( ++ subject_alt_names[2].ipaddress(), ++ Some(&b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01"[..]) ++ ); ++} ++ ++#[test] ++fn test_subject_alt_name_iter() { ++ let cert = include_bytes!("../../test/alt_name_cert.pem"); ++ let cert = X509::from_pem(cert).ok().expect("Failed to load PEM"); ++ ++ let subject_alt_names = cert.subject_alt_names().unwrap(); ++ let mut subject_alt_names_iter = subject_alt_names.iter(); ++ assert_eq!( ++ subject_alt_names_iter.next().unwrap().dnsname(), ++ Some("foobar.com") ++ ); ++ assert_eq!( ++ subject_alt_names_iter.next().unwrap().ipaddress(), ++ Some(&[127, 0, 0, 1][..]) ++ ); ++ assert_eq!( ++ subject_alt_names_iter.next().unwrap().ipaddress(), ++ Some(&b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01"[..]) ++ ); ++ assert!(subject_alt_names_iter.next().is_none()); ++} ++ ++#[test] ++fn x509_builder() { ++ let pkey = pkey(); ++ ++ let mut name = X509Name::builder().unwrap(); ++ name.append_entry_by_nid(nid::COMMONNAME, "foobar.com") ++ .unwrap(); ++ let name = name.build(); ++ ++ let mut builder = X509::builder().unwrap(); ++ builder.set_version(2).unwrap(); ++ builder.set_subject_name(&name).unwrap(); ++ builder.set_issuer_name(&name).unwrap(); ++ builder ++ .set_not_before(&Asn1Time::days_from_now(0).unwrap()) ++ .unwrap(); ++ builder ++ .set_not_after(&Asn1Time::days_from_now(365).unwrap()) ++ .unwrap(); ++ builder.set_pubkey(&pkey).unwrap(); ++ ++ let mut serial = BigNum::new().unwrap(); ++ serial.rand(128, MSB_MAYBE_ZERO, false).unwrap(); ++ builder ++ .set_serial_number(&serial.to_asn1_integer().unwrap()) ++ .unwrap(); ++ ++ let basic_constraints = BasicConstraints::new().critical().ca().build().unwrap(); ++ builder.append_extension(basic_constraints).unwrap(); ++ let key_usage = KeyUsage::new() ++ .digital_signature() ++ .key_encipherment() ++ .build() ++ .unwrap(); ++ builder.append_extension(key_usage).unwrap(); ++ let ext_key_usage = ExtendedKeyUsage::new() ++ .client_auth() ++ .server_auth() ++ .other("2.999.1") ++ .build() ++ .unwrap(); ++ builder.append_extension(ext_key_usage).unwrap(); ++ let subject_key_identifier = SubjectKeyIdentifier::new() ++ .build(&builder.x509v3_context(None, None)) ++ .unwrap(); ++ builder.append_extension(subject_key_identifier).unwrap(); ++ let authority_key_identifier = AuthorityKeyIdentifier::new() ++ .keyid(true) ++ .build(&builder.x509v3_context(None, None)) ++ .unwrap(); ++ builder.append_extension(authority_key_identifier).unwrap(); ++ let subject_alternative_name = SubjectAlternativeName::new() ++ .dns("example.com") ++ .build(&builder.x509v3_context(None, None)) ++ .unwrap(); ++ builder.append_extension(subject_alternative_name).unwrap(); ++ ++ builder.sign(&pkey, MessageDigest::sha256()).unwrap(); ++ ++ let x509 = builder.build(); ++ ++ assert!(pkey.public_eq(&x509.public_key().unwrap())); ++ ++ let cn = x509.subject_name() ++ .entries_by_nid(nid::COMMONNAME) ++ .next() ++ .unwrap(); ++ assert_eq!("foobar.com".as_bytes(), cn.data().as_slice()); ++} ++ ++#[test] ++fn x509_req_builder() { ++ let pkey = pkey(); ++ ++ let mut name = X509Name::builder().unwrap(); ++ name.append_entry_by_nid(nid::COMMONNAME, "foobar.com") ++ .unwrap(); ++ let name = name.build(); ++ ++ let mut builder = X509Req::builder().unwrap(); ++ builder.set_version(2).unwrap(); ++ builder.set_subject_name(&name).unwrap(); ++ builder.set_pubkey(&pkey).unwrap(); ++ ++ let mut extensions = Stack::new().unwrap(); ++ let key_usage = KeyUsage::new() ++ .digital_signature() ++ .key_encipherment() ++ .build() ++ .unwrap(); ++ extensions.push(key_usage).unwrap(); ++ let subject_alternative_name = SubjectAlternativeName::new() ++ .dns("example.com") ++ .build(&builder.x509v3_context(None)) ++ .unwrap(); ++ extensions.push(subject_alternative_name).unwrap(); ++ builder.add_extensions(&extensions).unwrap(); ++ ++ builder.sign(&pkey, MessageDigest::sha256()).unwrap(); ++} ++ ++#[test] ++fn test_stack_from_pem() { ++ let certs = include_bytes!("../../test/certs.pem"); ++ let certs = X509::stack_from_pem(certs).unwrap(); ++ ++ assert_eq!(certs.len(), 2); ++ assert_eq!( ++ certs[0] ++ .fingerprint(MessageDigest::sha1()) ++ .unwrap() ++ .to_hex(), ++ "59172d9313e84459bcff27f967e79e6e9217e584" ++ ); ++ assert_eq!( ++ certs[1] ++ .fingerprint(MessageDigest::sha1()) ++ .unwrap() ++ .to_hex(), ++ "c0cbdf7cdd03c9773e5468e1f6d2da7d5cbb1875" ++ ); ++} ++ ++#[test] ++fn issued() { ++ let cert = include_bytes!("../../test/cert.pem"); ++ let cert = X509::from_pem(cert).unwrap(); ++ let ca = include_bytes!("../../test/root-ca.pem"); ++ let ca = X509::from_pem(ca).unwrap(); ++ ++ ca.issued(&cert).unwrap(); ++ cert.issued(&cert).err().unwrap(); ++} ++ ++#[test] ++fn ecdsa_cert() { ++ let mut group = EcGroup::from_curve_name(X9_62_PRIME256V1).unwrap(); ++ group.set_asn1_flag(NAMED_CURVE); ++ let key = EcKey::generate(&group).unwrap(); ++ let key = PKey::from_ec_key(key).unwrap(); ++ ++ let cert = X509Generator::new() ++ .set_valid_period(365) ++ .add_name("CN".to_owned(), "TestServer".to_owned()) ++ .set_sign_hash(MessageDigest::sha256()) ++ .sign(&key) ++ .unwrap(); ++ ++ let mut ctx = SslContextBuilder::new(SslMethod::tls()).unwrap(); ++ ctx.set_certificate(&cert).unwrap(); ++ ctx.set_private_key(&key).unwrap(); ++ ctx.check_private_key().unwrap(); ++} ++ ++#[test] ++fn signature() { ++ let cert = include_bytes!("../../test/cert.pem"); ++ let cert = X509::from_pem(cert).unwrap(); ++ let signature = cert.signature(); ++ assert_eq!( ++ signature.as_slice().to_hex(), ++ "4af607b889790b43470442cfa551cdb8b6d0b0340d2958f76b9e3ef6ad4992230cead6842587f0ecad5\ ++ 78e6e11a221521e940187e3d6652de14e84e82f6671f097cc47932e022add3c0cb54a26bf27fa84c107\ ++ 4971caa6bee2e42d34a5b066c427f2d452038082b8073993399548088429de034fdd589dcfb0dd33be7\ ++ ebdfdf698a28d628a89568881d658151276bde333600969502c4e62e1d3470a683364dfb241f78d310a\ ++ 89c119297df093eb36b7fd7540224f488806780305d1e79ffc938fe2275441726522ab36d88348e6c51\ ++ f13dcc46b5e1cdac23c974fd5ef86aa41e91c9311655090a52333bc79687c748d833595d4c5f987508f\ ++ e121997410d37c" ++ ); ++ let algorithm = cert.signature_algorithm(); ++ assert_eq!(algorithm.object().nid(), nid::SHA256WITHRSAENCRYPTION); ++ assert_eq!(algorithm.object().to_string(), "sha256WithRSAEncryption"); ++} ++ ++#[test] ++fn clone_x509() { ++ let cert = include_bytes!("../../test/cert.pem"); ++ let cert = X509::from_pem(cert).unwrap(); ++ cert.clone(); ++} diff --cc vendor/openssl-0.9.19/src/x509/verify.rs index 000000000,000000000..c062125fd new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/src/x509/verify.rs @@@ -1,0 -1,0 +1,5 @@@ ++//! X509 certificate verification ++//! ++//! Requires the `v102` or `v110` features and OpenSSL 1.0.2 or 1.1.0. ++ ++pub use verify::*; diff --cc vendor/openssl-0.9.19/test/alt_name_cert.pem index 000000000,000000000..9f75f1259 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/alt_name_cert.pem @@@ -1,0 -1,0 +1,25 @@@ ++-----BEGIN CERTIFICATE----- ++MIIEOjCCAyKgAwIBAgIJAJz42fzGUJGeMA0GCSqGSIb3DQEBCwUAMH8xCzAJBgNV ++BAYTAlVTMQswCQYDVQQIDAJOWTERMA8GA1UEBwwITmV3IFlvcmsxFTATBgNVBAoM ++DEV4YW1wbGUsIExMQzEYMBYGA1UEAwwPRXhhbXBsZSBDb21wYW55MR8wHQYJKoZI ++hvcNAQkBFhB0ZXN0QGV4YW1wbGUuY29tMB4XDTE2MDQzMDA0MDg1NloXDTE3MDQz ++MDA0MDg1NlowfzELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5ZMREwDwYDVQQHDAhO ++ZXcgWW9yazEVMBMGA1UECgwMRXhhbXBsZSwgTExDMRgwFgYDVQQDDA9FeGFtcGxl ++IENvbXBhbnkxHzAdBgkqhkiG9w0BCQEWEHRlc3RAZXhhbXBsZS5jb20wggEiMA0G ++CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDggl2TbtO5Ewi/q8kV56xK6HBpwsj9 ++wBoqGi6hkKm/8lhLTkuUG6WbEUepi7n9d7tjI9hwYN7MKtppAnS+d+Zh6sKMgLJn ++hONkbQBJkYWwuIxRVXORCdyZDNzXP1rlb6ynmj6mItuPTRVNNMaZP+24fgXtwGk8 ++P2nqA1ONbmyaP27txV+Rd8fmQvW3vSmq7iDob661TOtLZRqqVRpnLDGpLXTCptYz ++dLN1nDWKjBUFpPGDxvfcSE3Yf9LaQM2uDHRygSgTFusbwarAGrAk8krsm/Tiaumx ++Ls74MY6OEoLnPbEi5epWLqPmoE1nxrvYLtaWh3TTET3H72yL0+1PZTkpAgMBAAGj ++gbgwgbUwHQYDVR0OBBYEFAIcHhTPUqVdK85u47vo8z0viJGPMB8GA1UdIwQYMBaA ++FAIcHhTPUqVdK85u47vo8z0viJGPMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgWgMC0G ++A1UdEQQmMCSCCmZvb2Jhci5jb22HBH8AAAGHEAAAAAAAAAAAAAAAAAAAAAEwLAYJ ++YIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMA0GCSqG ++SIb3DQEBCwUAA4IBAQDeYsuJaxbnxR2wDRSbxMpPp2b6fHPxC1vArKTSrQ/X+5s7 ++YcQ29jkzD8FbET8iPsCOn/IECBiDKOpckkO6dBWM05ma9HHzWjQOJ7Lo6gEsvk4d +++M/jJz5IaJ7hOxp1hGqwNQ+PJQOZMmlruNcOzPU36qaWJ03+NYOKar5VpIrRxCNc ++uehTArmJqDLQPfgETEhMYfpkqf3s/cGb1uyeCpzgIRPpf4Ki1Oys5cV/BqIn7n5g ++7sUrhXboYL4+eYt5V4rcc4rLI5J5IP/a1Z+Z6UVH+Mbiyl0iD8aRr/bo9WvKih3C ++2LBO0Apl0tkXUOMWp7G0UYHVEndwPjZnVoM42f11 ++-----END CERTIFICATE----- diff --cc vendor/openssl-0.9.19/test/cert.pem index 000000000,000000000..032fe60e9 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/cert.pem @@@ -1,0 -1,0 +1,19 @@@ ++-----BEGIN CERTIFICATE----- ++MIIDGzCCAgMCCQCHcfe97pgvpTANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJB ++VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 ++cyBQdHkgTHRkMB4XDTE2MDgxNDE3MDAwM1oXDTI2MDgxMjE3MDAwM1owWjELMAkG ++A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 ++IFdpZGdpdHMgUHR5IEx0ZDETMBEGA1UEAwwKZm9vYmFyLmNvbTCCASIwDQYJKoZI ++hvcNAQEBBQADggEPADCCAQoCggEBAKj0JYxEsxejUIX+I5GH0Hg2G0kX/y1H0+Ub ++3mw2/Ja5BD/yN96/7zMSumXF8uS3SkmpyiJkbyD01TSRTqjlP7/VCBlyUIChlpLQ ++mrGaijZiT/VCyPXqmcwFzXS5IOTpX1olJfW8rA41U1LCIcDUyFf6LtZ/v8rSeKr6 ++TuE6SGV4WRaBm1SrjWBeHVV866CRrtSS1ieT2asFsAyOZqWhk2fakwwBDFWDhOGI ++ubfO+5aq9cBJbNRlzsgB3UZs3gC0O6GzbnZ6oT0TiJMeTsXXjABLUlaq/rrqFF4Y ++euZkkbHTFBMz288PUc3m3ZTcpN+E7+ZOUBRZXKD20K07NugqCzUCAwEAATANBgkq ++hkiG9w0BAQsFAAOCAQEASvYHuIl5C0NHBELPpVHNuLbQsDQNKVj3a54+9q1JkiMM ++6taEJYfw7K1Xjm4RoiFSHpQBh+PWZS3hToToL2Zx8JfMR5MuAirdPAy1Sia/J/qE ++wQdJccqmvuLkLTSlsGbEJ/LUUgOAgrgHOZM5lUgIhCneA0/dWJ3PsN0zvn69/faY ++oo1iiolWiIHWWBUSdr3jM2AJaVAsTmLh00cKaDNk37JB940xConBGSl98JPrNrf9 ++dUAiT0iIBngDBdHnn/yTj+InVEFyZSKrNtiDSObFHxPcxGteHNrCPJdP1e+GqkHp ++HJMRZVCQpSMzvHlofHSNgzWV1MX5h1CP4SGZdBDTfA== ++-----END CERTIFICATE----- diff --cc vendor/openssl-0.9.19/test/certs.pem index 000000000,000000000..9d3516620 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/certs.pem @@@ -1,0 -1,0 +1,40 @@@ ++-----BEGIN CERTIFICATE----- ++MIIDGzCCAgMCCQCHcfe97pgvpTANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJB ++VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 ++cyBQdHkgTHRkMB4XDTE2MDgxNDE3MDAwM1oXDTI2MDgxMjE3MDAwM1owWjELMAkG ++A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0 ++IFdpZGdpdHMgUHR5IEx0ZDETMBEGA1UEAwwKZm9vYmFyLmNvbTCCASIwDQYJKoZI ++hvcNAQEBBQADggEPADCCAQoCggEBAKj0JYxEsxejUIX+I5GH0Hg2G0kX/y1H0+Ub ++3mw2/Ja5BD/yN96/7zMSumXF8uS3SkmpyiJkbyD01TSRTqjlP7/VCBlyUIChlpLQ ++mrGaijZiT/VCyPXqmcwFzXS5IOTpX1olJfW8rA41U1LCIcDUyFf6LtZ/v8rSeKr6 ++TuE6SGV4WRaBm1SrjWBeHVV866CRrtSS1ieT2asFsAyOZqWhk2fakwwBDFWDhOGI ++ubfO+5aq9cBJbNRlzsgB3UZs3gC0O6GzbnZ6oT0TiJMeTsXXjABLUlaq/rrqFF4Y ++euZkkbHTFBMz288PUc3m3ZTcpN+E7+ZOUBRZXKD20K07NugqCzUCAwEAATANBgkq ++hkiG9w0BAQsFAAOCAQEASvYHuIl5C0NHBELPpVHNuLbQsDQNKVj3a54+9q1JkiMM ++6taEJYfw7K1Xjm4RoiFSHpQBh+PWZS3hToToL2Zx8JfMR5MuAirdPAy1Sia/J/qE ++wQdJccqmvuLkLTSlsGbEJ/LUUgOAgrgHOZM5lUgIhCneA0/dWJ3PsN0zvn69/faY ++oo1iiolWiIHWWBUSdr3jM2AJaVAsTmLh00cKaDNk37JB940xConBGSl98JPrNrf9 ++dUAiT0iIBngDBdHnn/yTj+InVEFyZSKrNtiDSObFHxPcxGteHNrCPJdP1e+GqkHp ++HJMRZVCQpSMzvHlofHSNgzWV1MX5h1CP4SGZdBDTfA== ++-----END CERTIFICATE----- ++-----BEGIN CERTIFICATE----- ++MIIDXTCCAkWgAwIBAgIJAOIvDiVb18eVMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV ++BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX ++aWRnaXRzIFB0eSBMdGQwHhcNMTYwODE0MTY1NjExWhcNMjYwODEyMTY1NjExWjBF ++MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 ++ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB ++CgKCAQEArVHWFn52Lbl1l59exduZntVSZyDYpzDND+S2LUcO6fRBWhV/1Kzox+2G ++ZptbuMGmfI3iAnb0CFT4uC3kBkQQlXonGATSVyaFTFR+jq/lc0SP+9Bd7SBXieIV ++eIXlY1TvlwIvj3Ntw9zX+scTA4SXxH6M0rKv9gTOub2vCMSHeF16X8DQr4XsZuQr ++7Cp7j1I4aqOJyap5JTl5ijmG8cnu0n+8UcRlBzy99dLWJG0AfI3VRJdWpGTNVZ92 ++aFff3RpK3F/WI2gp3qV1ynRAKuvmncGC3LDvYfcc2dgsc1N6Ffq8GIrkgRob6eBc ++klDHp1d023Lwre+VaVDSo1//Y72UFwIDAQABo1AwTjAdBgNVHQ4EFgQUbNOlA6sN ++XyzJjYqciKeId7g3/ZowHwYDVR0jBBgwFoAUbNOlA6sNXyzJjYqciKeId7g3/Zow ++DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAVVaR5QWLZIRR4Dw6TSBn ++BQiLpBSXN6oAxdDw6n4PtwW6CzydaA+creiK6LfwEsiifUfQe9f+T+TBSpdIYtMv ++Z2H2tjlFX8VrjUFvPrvn5c28CuLI0foBgY8XGSkR2YMYzWw2jPEq3Th/KM5Catn3 ++AFm3bGKWMtGPR4v+90chEN0jzaAmJYRrVUh9vea27bOCn31Nse6XXQPmSI6Gyncy ++OAPUsvPClF3IjeL1tmBotWqSGn1cYxLo+Lwjk22A9h6vjcNQRyZF2VLVvtwYrNU3 ++mwJ6GCLsLHpwW/yjyvn8iEltnJvByM/eeRnfXV6WDObyiZsE/n6DxIRJodQzFqy9 ++GA== ++-----END CERTIFICATE----- diff --cc vendor/openssl-0.9.19/test/dhparams.pem index 000000000,000000000..6e4d4c68c new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/dhparams.pem @@@ -1,0 -1,0 +1,8 @@@ ++-----BEGIN DH PARAMETERS----- ++MIIBCAKCAQEAh3Betv+hf5jNsOmGXU8oxuABD2B8r0yU8FVgjnCZBSVo61qJ0A2d ++J6r8rYKbjtolnrZN/V4IPSzYvxurHbu8nbiFVyhOySPchI2Fu+YT/HsSe/0MH9bW ++gJTNzmutWoy9VxtWLCmXnOSZHep3MZ1ZNimno6Kh2qQ7VJr0+KF8GbxUKOPv4SqK ++NBwouIQXFc0pE9kGhcGKbr7TnHhyJFCRLNP1OVDQZbcoKjk1Vh+5sy7vM2VUTQmM ++yOToT2LEZVAUJXNumcYMki9MIwfYCwYZbNt0ZEolyHzUEesuyHfU1eJd6+sKEjUz ++5GteQIR7AehxZIS+cytu7BXO7B0owLJ2awIBAg== ++-----END DH PARAMETERS----- diff --cc vendor/openssl-0.9.19/test/dsa-encrypted.pem index 000000000,000000000..9b1984eb7 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/dsa-encrypted.pem @@@ -1,0 -1,0 +1,15 @@@ ++-----BEGIN DSA PRIVATE KEY----- ++Proc-Type: 4,ENCRYPTED ++DEK-Info: DES-EDE3-CBC,5B99FC62C376CA1F ++ ++5nN039tLa3AHnSaQ0lk+Zsguu1EE+EyUlW1GHKs7ls2gOsZH1kR0+A+MiwNKlP24 ++Syy8KYyAbgsirhtwN5IOSsA97feR/vHTY4xQ8nEef8tB7VeRJzOFLHGgS0hwIxOM ++Tb8gb4y0FtoWdAgorieP4c1emu8VwTTkHd44AArDXsP1Y7s+a3IEMcHcc3tW+qBk ++xuVnqBEETL1t0I5rKy+AYvPmGgEZ0dGRRnUlVMC5jMTozJFcStdSzKUY27prUBz2 ++FREOJOA/dIjVn1UGijI64Io5sPCAbDPPmG2k4kywbEbd7Ee/MxEvRNcAyv4boyA8 ++GnHZTILKi/WY5+SNlHE3YepCFo1XU+59SovB1lDhRmi43L4vfdGc/6y8L/+rbLuU ++Y58DxLdOZLTjpf9GLLf9WcpHhNZhwFfBFA8HuT8FtKDPqlf2t65z+1AVV8JTH2wM ++BrRHXTrBKn8YgafXD5MisKFmajoAtNZTvhYGm0D8BLIiNwOwLsGfXZ0hYAie0eoI ++Xl6MbHp1n/e+R+XKJ3M9DPM8mzWntlltAhS5+Az0Zi4aBdzqQaTpqvEku21sygq8 ++Hwm0fpAq7y4bMnjNbMqQVw== ++-----END DSA PRIVATE KEY----- diff --cc vendor/openssl-0.9.19/test/dsa.pem index 000000000,000000000..9b5501848 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/dsa.pem @@@ -1,0 -1,0 +1,12 @@@ ++-----BEGIN DSA PRIVATE KEY----- ++MIIBuwIBAAKBgQCkKe/jtYKJNQafaE7kg2aaJOEPUV0Doi451jkXHp5UfLh6+t42 ++eabSGkE9WBAlILgaB8yHckLe9+zozN39+SUDp94kb2r38/8w/9Ffhbsep9uiyOj2 ++ZRQur6SkpKQDKcnAd6IMZXZcvdSgPC90A6qraYUZKq7Csjn63gbC+IvXHwIVAIgS ++PE43lXD8/rGYxos4cxCgGGAxAoGASMV56WhLvVQtWMVI36WSIxbZnC2EsnNIKeVW ++yXnP/OmPJ2mdezG7i1alcwsO2TnSLbvjvGPlyzIqZzHvWC8EmDqsfbU+n8we/Eal ++sm5nloC8m9ECWpbTzbNdvrAAj9UPVWjcDwg7grAGGysh6lGbBv5P+4zL/niq1UiE ++LnKcifgCgYEAo6mAasO0+MVcu8shxxUXXNeTLsZ8NB/BIx9EZ/dzE23ivNW8dq1A ++eecAAYhssI2m/CspQvyKw+seCvg4FccxJgB3+mGOe+blFHwO3eAwoyRn/t3DZDHh ++FjxKKRsQdy4BkZv+vhTyIYYCw0iPZ5Wfln+pyGGTveIDED1MPG+J6c8CFCJAUlEl ++4nHvbC15xLXXpd46zycY ++-----END DSA PRIVATE KEY----- diff --cc vendor/openssl-0.9.19/test/dsa.pem.pub index 000000000,000000000..ae298d093 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/dsa.pem.pub @@@ -1,0 -1,0 +1,12 @@@ ++-----BEGIN PUBLIC KEY----- ++MIIBtzCCASsGByqGSM44BAEwggEeAoGBAKQp7+O1gok1Bp9oTuSDZpok4Q9RXQOi ++LjnWORcenlR8uHr63jZ5ptIaQT1YECUguBoHzIdyQt737OjM3f35JQOn3iRvavfz ++/zD/0V+Fux6n26LI6PZlFC6vpKSkpAMpycB3ogxldly91KA8L3QDqqtphRkqrsKy ++OfreBsL4i9cfAhUAiBI8TjeVcPz+sZjGizhzEKAYYDECgYBIxXnpaEu9VC1YxUjf ++pZIjFtmcLYSyc0gp5VbJec/86Y8naZ17MbuLVqVzCw7ZOdItu+O8Y+XLMipnMe9Y ++LwSYOqx9tT6fzB78RqWybmeWgLyb0QJaltPNs12+sACP1Q9VaNwPCDuCsAYbKyHq ++UZsG/k/7jMv+eKrVSIQucpyJ+AOBhQACgYEAo6mAasO0+MVcu8shxxUXXNeTLsZ8 ++NB/BIx9EZ/dzE23ivNW8dq1AeecAAYhssI2m/CspQvyKw+seCvg4FccxJgB3+mGO ++e+blFHwO3eAwoyRn/t3DZDHhFjxKKRsQdy4BkZv+vhTyIYYCw0iPZ5Wfln+pyGGT ++veIDED1MPG+J6c8= ++-----END PUBLIC KEY----- diff --cc vendor/openssl-0.9.19/test/dsaparam.pem index 000000000,000000000..53bda543b new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/dsaparam.pem @@@ -1,0 -1,0 +1,9 @@@ ++-----BEGIN DSA PARAMETERS----- ++MIIBHgKBgQCkKe/jtYKJNQafaE7kg2aaJOEPUV0Doi451jkXHp5UfLh6+t42eabS ++GkE9WBAlILgaB8yHckLe9+zozN39+SUDp94kb2r38/8w/9Ffhbsep9uiyOj2ZRQu ++r6SkpKQDKcnAd6IMZXZcvdSgPC90A6qraYUZKq7Csjn63gbC+IvXHwIVAIgSPE43 ++lXD8/rGYxos4cxCgGGAxAoGASMV56WhLvVQtWMVI36WSIxbZnC2EsnNIKeVWyXnP ++/OmPJ2mdezG7i1alcwsO2TnSLbvjvGPlyzIqZzHvWC8EmDqsfbU+n8we/Ealsm5n ++loC8m9ECWpbTzbNdvrAAj9UPVWjcDwg7grAGGysh6lGbBv5P+4zL/niq1UiELnKc ++ifg= ++-----END DSA PARAMETERS----- diff --cc vendor/openssl-0.9.19/test/identity.p12 index 000000000,000000000..d16abb8c7 new file mode 100644 Binary files differ diff --cc vendor/openssl-0.9.19/test/key.der index 000000000,000000000..6b6209fd1 new file mode 100644 Binary files differ diff --cc vendor/openssl-0.9.19/test/key.der.pub index 000000000,000000000..395b04a94 new file mode 100644 Binary files differ diff --cc vendor/openssl-0.9.19/test/key.pem index 000000000,000000000..d381795d3 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/key.pem @@@ -1,0 -1,0 +1,28 @@@ ++-----BEGIN PRIVATE KEY----- ++MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCo9CWMRLMXo1CF ++/iORh9B4NhtJF/8tR9PlG95sNvyWuQQ/8jfev+8zErplxfLkt0pJqcoiZG8g9NU0 ++kU6o5T+/1QgZclCAoZaS0Jqxmoo2Yk/1Qsj16pnMBc10uSDk6V9aJSX1vKwONVNS ++wiHA1MhX+i7Wf7/K0niq+k7hOkhleFkWgZtUq41gXh1VfOugka7UktYnk9mrBbAM ++jmaloZNn2pMMAQxVg4ThiLm3zvuWqvXASWzUZc7IAd1GbN4AtDuhs252eqE9E4iT ++Hk7F14wAS1JWqv666hReGHrmZJGx0xQTM9vPD1HN5t2U3KTfhO/mTlAUWVyg9tCt ++OzboKgs1AgMBAAECggEBAKLj6IOJBKXolczpzb8UkyAjAkGBektcseV07gelJ/fk ++3z0LuWPv5p12E/HlXB24vU2x/ikUbbP3eMsawRzDEahQqmNmPEkYAYUAy/Qpi9GN ++DYvn3LqDec4jVgeQKS+p9H2DzUpTogp8zR2//yzbuWBg2+F//xh7vU0S0RQCziPM ++x7RSBgbhxSfChfEJbS2sDnzfh0jRQmoY95iFv7puet1FJtzdZ4fgCd1RqmC2lFM5 ++H0eZtN/Cz19lieVs0b996DErdEBqClVZO00eYbRozCDaBzRU3ybB/dMrGJxhkkXm ++wb3kWMtziH9qOYsostuHIFu8eKFLloKxFnq2R4DGxOECgYEA2KUIZISOeGJSBcLJ ++JAUK2gvgXPNo4HHWIwOA9xeN3ZJlsnPlffXQNnm6t1st1V2gfMm9I2n0m/F0y2B/ ++n/XGSa8bghfPA9l0c2h58lkL3JQJR/paa8ycTz+YZPrznEyN7Qa0RrJXUvZv9lQL ++Hc3+FHcSHgMqDV2f2bHAEu9YGi0CgYEAx6VEIPNvrHFgjo/jk1RTuk+m0xEWQsZL ++Cs+izQMr2TaeJn8LG+93AvFuYn0J0nT3WuStLPrUg8i4IhSS6lf1tId5ivIZPm4r ++YwMyblBJXhnHbk7Uqodjfw/3s6V2HAu++B7hTdyVr9DFuST9uv4m8bkPV8rfX1jE ++I2rAPVWvgikCgYB+wNAQP547wQrMZBLbCDg5KwmyWJfb+b6X7czexOEz6humNTjo ++YZHYzY/5B1fhpk3ntQD8X1nGg5caBvOk21+QbOtjShrM3cXMYCw5JvBRtitX+Zo9 ++yBEMLOE0877ki8XeEDYZxu5gk98d+D4oygUGZEQtWxyXhVepPt5qNa8OYQKBgQDH ++RVgZI6KFlqzv3wMh3PutbS9wYQ+9GrtwUQuIYe/0YSW9+vSVr5E0qNKrD28sV39F ++hBauXLady0yvB6YUrjMbPFW+sCMuQzyfGWPO4+g3OrfqjFiM1ZIkE0YEU9Tt7XNx ++qTDtTI1D7bhNMnTnniI1B6ge0und+3XafAThs5L48QKBgQCTTpfqMt8kU3tcI9sf ++0MK03y7kA76d5uw0pZbWFy7KI4qnzWutCzb+FMPWWsoFtLJLPZy//u/ZCUVFVa4d ++0Y/ASNQIESVPXFLAltlLo4MSmsg1vCBsbviEEaPeEjvMrgki93pYtd/aOSgkYC1T ++mEq154s5rmqh+h+XRIf7Au0SLw== ++-----END PRIVATE KEY----- diff --cc vendor/openssl-0.9.19/test/key.pem.pub index 000000000,000000000..2a8225696 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/key.pem.pub @@@ -1,0 -1,0 +1,9 @@@ ++-----BEGIN PUBLIC KEY----- ++MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr1bXMptaIgOL9PVL8a7W ++KG/C8+IbxP018eMBQZT0SnPQmXp0Q8Aai/F+AEDE7b5sO5U7WdxU4GRYw0wqkQNF ++si78KNfoj2ZMlx6NRfl4UKuzrpGTPgQxuKDYedngPpWcbmW4P3zEL2Y7b18n9NJr ++atRUzH1Zh/ReRO525Xadu58aviPw1Mzgse7cKyzb03Gll9noLnYNIIpO8jL+QyrD ++8qNmfacmR20U0a6XDTtmsmk7AitGETICbTT0KRf+oAP0yIHoonllPpNLUEPZQjrp ++ClS/S/wKdj7gaq9TaMbHULhFMjbCV8cuPu//rUAuWp3riaznZGOVQyn3Dp2CB3ad ++yQIDAQAB ++-----END PUBLIC KEY----- diff --cc vendor/openssl-0.9.19/test/keystore-empty-chain.p12 index 000000000,000000000..c39930a5c new file mode 100644 Binary files differ diff --cc vendor/openssl-0.9.19/test/nid_test_cert.pem index 000000000,000000000..6f17e734c new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/nid_test_cert.pem @@@ -1,0 -1,0 +1,12 @@@ ++-----BEGIN CERTIFICATE----- ++MIIB1DCCAX6gAwIBAgIJAMzXWZGWHleWMA0GCSqGSIb3DQEBCwUAMFYxHzAdBgkq ++hkiG9w0BCQEWEHRlc3RAZXhhbXBsZS5jb20xFDASBgNVBAMMC2V4YW1wbGUuY29t ++MR0wGwYJKoZIhvcNAQkUHg4ARQB4AGEAbQBwAGwAZTAeFw0xNTA3MDEwNjQ3NDRa ++Fw0xNTA3MzEwNjQ3NDRaMFYxHzAdBgkqhkiG9w0BCQEWEHRlc3RAZXhhbXBsZS5j ++b20xFDASBgNVBAMMC2V4YW1wbGUuY29tMR0wGwYJKoZIhvcNAQkUHg4ARQB4AGEA ++bQBwAGwAZTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCmejzp4+o35FD0hAnx2trL ++08h07X5jZca9DgZH35hWXPh7fMucLt/IPXIRnz2zKEa/Mo6D2V/fx03Mqo0epid7 ++AgMBAAGjLzAtMB0GA1UdDgQWBBRQa57tXz3rZNRz+fTbo3w3jQJMBTAMBgNVHRME ++BTADAQH/MA0GCSqGSIb3DQEBCwUAA0EAm0iY9cr+gvC+vcQIebdofpQ4GcDW8U6W ++Bxs8ZXinLl69P0jYLum3+XITNFRiyQqcivaxdxthxDNOX7P+aKwkJA== ++-----END CERTIFICATE----- diff --cc vendor/openssl-0.9.19/test/nid_uid_test_cert.pem index 000000000,000000000..de6722abe new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/nid_uid_test_cert.pem @@@ -1,0 -1,0 +1,24 @@@ ++-----BEGIN CERTIFICATE----- ++MIIEGTCCAwGgAwIBAgIJAItKTzcGfL1lMA0GCSqGSIb3DQEBCwUAMIGiMSIwIAYK ++CZImiZPyLGQBAQwSdGhpcyBpcyB0aGUgdXNlcklkMQswCQYDVQQGEwJVUzETMBEG ++A1UECAwKQ2FsaWZvcm5pYTESMBAGA1UEBwwJU3Vubnl2YWxlMRUwEwYDVQQKDAxS ++dXN0IE9wZW5TU0wxDDAKBgNVBAsMA09TUzEhMB8GA1UEAwwYcnVzdC1vcGVuc3Ns ++LmV4YW1wbGUuY29tMB4XDTE2MDIwMjE3MjIwMVoXDTE2MDMwMzE3MjIwMVowgaIx ++IjAgBgoJkiaJk/IsZAEBDBJ0aGlzIGlzIHRoZSB1c2VySWQxCzAJBgNVBAYTAlVT ++MRMwEQYDVQQIDApDYWxpZm9ybmlhMRIwEAYDVQQHDAlTdW5ueXZhbGUxFTATBgNV ++BAoMDFJ1c3QgT3BlblNTTDEMMAoGA1UECwwDT1NTMSEwHwYDVQQDDBhydXN0LW9w ++ZW5zc2wuZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB ++AQDa3Gc+IE5DOhTv1m5DZW8qKiyNLd7v4DaAYLXSsDuLs+9wJ+Bs+wlBfrg+PT0t ++EJlPaLL9IfD5eR3WpFu62TUexYhnJh+3vhCGsFHOXcTjtM+wy/dzZtOVh2wTzvqE ++/FHBGw1eG3Ww+RkSFbwYmtm8JhIN8ffYxGn2O0yQpxypf5hNPYrC81zX+52X2w1h ++jDYLpYt55w+e6q+iRRFk0tKiWHEqqh/r6UQQRpj2EeS+xTloZlO6h0nl2NPkVF3r ++CXBoT8Ittxr7sqcYqf8TAA0I4qZRYXKYehFmv/VkSt85CcURJ/zXeoJ1TpxSvQie ++2R9cRDkYROrIOAFbB/0mmHLBAgMBAAGjUDBOMB0GA1UdDgQWBBRKfPqtgrbdbTmH ++XR6RC/p8t/65GjAfBgNVHSMEGDAWgBRKfPqtgrbdbTmHXR6RC/p8t/65GjAMBgNV ++HRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCKfeGRduGsIwKNiGcDUNkNrc7Z ++f8SWAmb/R6xiDfgjbhrtfBDowIZ5natEkTgf6kQPMJKyjg2NEM2uJWBc55rLOHIv ++es1wQOlYjfEUmFD3lTIt2TM/IUgXn2j+zV1CRkJthQLVFChXsidd0Bqq2fBjd3ad ++Yjzrxf3uOTBAs27koh2INNHfcUZCRsx8hP739zz2kw/r5NB/9iyENEyJKQvxo0jb ++oN0JK2joGZrWetDukQrqf032TsdkboW5JresYybbAD3326Ljp+hlT/3WINc+3nZJ ++Dn+pPMdpuZ5BUZ+u+XyNEPum3k3P3K19AF+zWYGooX0J1cmuCBrrqce20Lwy ++-----END CERTIFICATE----- diff --cc vendor/openssl-0.9.19/test/pkcs8.der index 000000000,000000000..47a2db8ad new file mode 100644 Binary files differ diff --cc vendor/openssl-0.9.19/test/root-ca.key index 000000000,000000000..746ae2a68 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/root-ca.key @@@ -1,0 -1,0 +1,27 @@@ ++-----BEGIN RSA PRIVATE KEY----- ++MIIEpQIBAAKCAQEArVHWFn52Lbl1l59exduZntVSZyDYpzDND+S2LUcO6fRBWhV/ ++1Kzox+2GZptbuMGmfI3iAnb0CFT4uC3kBkQQlXonGATSVyaFTFR+jq/lc0SP+9Bd ++7SBXieIVeIXlY1TvlwIvj3Ntw9zX+scTA4SXxH6M0rKv9gTOub2vCMSHeF16X8DQ ++r4XsZuQr7Cp7j1I4aqOJyap5JTl5ijmG8cnu0n+8UcRlBzy99dLWJG0AfI3VRJdW ++pGTNVZ92aFff3RpK3F/WI2gp3qV1ynRAKuvmncGC3LDvYfcc2dgsc1N6Ffq8GIrk ++gRob6eBcklDHp1d023Lwre+VaVDSo1//Y72UFwIDAQABAoIBAGZrnd/dC2kp11uq ++Sg8SHk3GMdPPjTf/lq51sVJAU4fdV2Eso0XCiCzdKDcqR6F+jiu8jHp4YO0riW8N ++b1pkjohGjyOaddIaaVsZ80/OkgDz20Ird9XQ7uoEODvopA12+755BDH5PDwqHVeM ++nKfPiwAK6Jz6CxGO9bq9ZNoBiSyO1uofaB4Cpp8t74XVeAuPiI/Bb6WJ8TW5K5dt ++x0Jihdo46QgZR+z4PnyWIoACkhSoQmtTb9NUrpKceBcxdCrZ/kEmYpnPq/PuSw6g ++6HthjYP/H9Xulz69UR5Ez6z+1pU1rKFmQ46qK7X3zVHg233MlGekMzxdmShEjzCP ++BMGYpQECgYEA5tqTZsUJwx3HDhkaZ/XOtaQqwOnZm9wPwTjGbV1t4+NUJzsl5gjP ++ho+I8ZSGZ6MnNSh+ClpYhUHYBq0rTuAAYL2arcMOuOs1GrMmiZJbXm8zq8M7gYr5 ++V99H/7akSx66WV/agPkLIvh/BWxlWgQcoVAIzZibbLUxr7Ye50pCLfECgYEAwDLn ++mFz0mFMvGtaSp8RnTDTFCz9czCeDt0GujCxG1epdvtuxlg/S1QH+mGzA/AHkiu7z ++uzCwGKWozNTdRkqVwYoJTB+AYHseSkuGP+a1zr39w+xBW/vESb2oP95GIwprXcG2 ++b/qdeQVzuLQhYoqWI2u8CBwlHFfpQO4Bp2ea+ocCgYEAurIgLSfCqlpFpiAlG9hN ++8NYwgU1d4E+LKj+JMd8yRO+PGh8amjub4X3pST5NqDjpN3Nk42iHWFWUqGmZsbM0 ++ewg7tLUgDeqiStKBoxaK8AdMqWc9k5lZ53e6mZISsnHKUQdVBaLjH8gJqdAs8yyK ++HudEB0mYwMSUxz6pJXIHrXECgYEAhJkaCpXm8chB8UQj/baUhZDKeI4IWZjRWHbq ++Ey7g1+hPMMOk6yCTlf1ARqyRH8u2ftuIL5bRhs+Te21IE5yVYOb4rxn0mZuXNC6S ++ujdTKwUMtESkeu9hZnaAQz/4J2ii1hY05WCDj+DhC4bKmY9/MYS8PuQb/kfwVqld ++Xr8tvrUCgYEAmslHocXBUFXyRDkEOx/aKo+t9fPBr95PBZzFUt9ejrTP4PXsLa46 ++3/PNOCGdrQxh5qHHcvLwR4bPL++Dj+qMUTJXANrArKPDpE2WqH6pqWIC6yaZvzUk ++17QbpXR6bHcdJV045pWpw40UCStTocVynY1lBfOw8VqxBIBlpVBBzew= ++-----END RSA PRIVATE KEY----- diff --cc vendor/openssl-0.9.19/test/root-ca.pem index 000000000,000000000..4ec2f5388 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/root-ca.pem @@@ -1,0 -1,0 +1,21 @@@ ++-----BEGIN CERTIFICATE----- ++MIIDXTCCAkWgAwIBAgIJAOIvDiVb18eVMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV ++BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX ++aWRnaXRzIFB0eSBMdGQwHhcNMTYwODE0MTY1NjExWhcNMjYwODEyMTY1NjExWjBF ++MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 ++ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB ++CgKCAQEArVHWFn52Lbl1l59exduZntVSZyDYpzDND+S2LUcO6fRBWhV/1Kzox+2G ++ZptbuMGmfI3iAnb0CFT4uC3kBkQQlXonGATSVyaFTFR+jq/lc0SP+9Bd7SBXieIV ++eIXlY1TvlwIvj3Ntw9zX+scTA4SXxH6M0rKv9gTOub2vCMSHeF16X8DQr4XsZuQr ++7Cp7j1I4aqOJyap5JTl5ijmG8cnu0n+8UcRlBzy99dLWJG0AfI3VRJdWpGTNVZ92 ++aFff3RpK3F/WI2gp3qV1ynRAKuvmncGC3LDvYfcc2dgsc1N6Ffq8GIrkgRob6eBc ++klDHp1d023Lwre+VaVDSo1//Y72UFwIDAQABo1AwTjAdBgNVHQ4EFgQUbNOlA6sN ++XyzJjYqciKeId7g3/ZowHwYDVR0jBBgwFoAUbNOlA6sNXyzJjYqciKeId7g3/Zow ++DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAVVaR5QWLZIRR4Dw6TSBn ++BQiLpBSXN6oAxdDw6n4PtwW6CzydaA+creiK6LfwEsiifUfQe9f+T+TBSpdIYtMv ++Z2H2tjlFX8VrjUFvPrvn5c28CuLI0foBgY8XGSkR2YMYzWw2jPEq3Th/KM5Catn3 ++AFm3bGKWMtGPR4v+90chEN0jzaAmJYRrVUh9vea27bOCn31Nse6XXQPmSI6Gyncy ++OAPUsvPClF3IjeL1tmBotWqSGn1cYxLo+Lwjk22A9h6vjcNQRyZF2VLVvtwYrNU3 ++mwJ6GCLsLHpwW/yjyvn8iEltnJvByM/eeRnfXV6WDObyiZsE/n6DxIRJodQzFqy9 ++GA== ++-----END CERTIFICATE----- diff --cc vendor/openssl-0.9.19/test/rsa-encrypted.pem index 000000000,000000000..a62499972 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/rsa-encrypted.pem @@@ -1,0 -1,0 +1,30 @@@ ++-----BEGIN RSA PRIVATE KEY----- ++Proc-Type: 4,ENCRYPTED ++DEK-Info: AES-128-CBC,E2F16153E2BA3D617285A68C896BA6AF ++ ++vO9SnhtGjGe8pG1pN//vsONnvJr+DjU+lFCiSqGMPT7tezDnbehLfS+9kus2HV7r ++HmI14JvVG9O7NpF7zMyBRlHYdWcCCWED9Yar0NsWN9419e5pMe/bqIXAzAiJbtT4 ++OB9U5XF3m+349zjN1dVXPPLGRmMC1pcHAlofeb5nIUFTvUi5xcsbe1itGjgkkvHb ++Bt8NioHTBun8kKrlsFQOuB55ylBU/eWG8DQBtvFOmQ7iWp0RnGQfh8k5e5rcZNpQ ++fD9ygc7UVISl0xTrIG4IH15g34H+nrBauKtIPOpNPuXQPOMHCZv3XH8wnhrWHHwT ++ZFnQBdXbSpQtMsRh0phG2G+VIlyCgSn4+CxjCJ+TgFtsoK/tU0unmRYc59QnTxxb ++qkHYsPs3E0NApQAgH1ENEGl1M+FGLYQH7gftjc3ophBTeRA17sRmD7Y4QBInggsq ++Gv6tImPVBdekAjz/Ls/EyMwjAvvrL5eAokqrIsAarGo+zmbJKHzknw2KUz2En0+k ++YYaxB4oy9u7bzuQlvio6xYHJEb4K197bby4Dldmqv7YCCJBJwhOBAInMD687viKv ++vcUwL8YuS6cW5E8MbvEENlY4+lvKKj3M8Bnyb79cYIPQe92EuCwXU9DZXPRMLwwM ++oFEJpF5E/PmNJzu+B52ahHtDrh83WSx71fWqjdTqwkPZhAYo3ztsfFkb/UqUcq8u ++rBSebeUjZh0XZ9B04eshZQ5vJUcXGtYIe/77beV3Pv89/fw+zTZjpiP9Q3sZALzf ++Qt0YGp0/6qBuqR1tcqdu65AS2hun7yFw7uRavqYKvww4axRiz2do+xWmZFuoCAwD ++EWktaUujltpvAc1lo7lg4C6nByefJB9Xqk22N/vpqOsWr1NbAntT42Qj/HF9BVWR ++osvN3yMnKYWYe6oSTVnNBDM5obWAIHd3I9gcxTOTb1KsEwt2RrDs5EpB5ptS3Fjo ++JfBRhNZQ3cXttrIIhsHgDn9BDNg865/xpIgktKj0gEd60Abx0PqkAIm6IZTh4Efg ++7uZwfzxB+saOcddbrW2gNdzVZMC0s2Ye3sqHhtLbAJ3BlXYTxE4CAvTg54Ny+5hF ++IjvjlOKgXceSG1cSfk21/wyp9RY3Ft0AEYvvp0kZScWZaoA2aSFDUrchXVhgrEbn ++lJ7UptjefwRFIreAlwbKSbIDDNWnyzvIWyHfQ2aYqgnb7W7XqNPSgH9cALCfzirI ++dlRHjha0bMUtrjPCC/YfMXzJBVniy0gG6Pd5uC7vz/Awn6/6HRQVNaTQASphPBQ7 ++bJuz+JTfzI9OUVCMRMdnb6b35U4P9tibFmnPvzTIPe+3WUmf8aRsLS3NN3G1Webd ++PMYVZpMycPaAI0Ht87axhsOzlxCWHYWjdHa+WoNNc1J90TxLCmAHquh5BDaWvjMK ++0DySftJZjV7Tf1p2KosmU83LRl39B5NHMbZb1xOEZl9IWwhT/PVKTVZ25xdxWLfb ++hF4l8rfvKehIp5r4t8zW1bvI2Hl6vrUvmcUVWt3BfKjxlgwRVD0vvwonMt1INesF ++204vUBeXbDsUUicLwOyUgaFvJ3XU3dOyvL9MhOgM5OgoFRRhG+4AS8a5JCD8iLtq ++-----END RSA PRIVATE KEY----- diff --cc vendor/openssl-0.9.19/test/rsa.pem index 000000000,000000000..d8185fed6 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/rsa.pem @@@ -1,0 -1,0 +1,27 @@@ ++-----BEGIN RSA PRIVATE KEY----- ++MIIEowIBAAKCAQEAofgWCuLjybRlzo0tZWJjNiuSfb4p4fAkd/wWJcyQoTbji9k0 ++l8W26mPddxHmfHQp+Vaw+4qPCJrcS2mJPMEzP1Pt0Bm4d4QlL+yRT+SFd2lZS+pC ++gNMsD1W/YpRPEwOWvG6b32690r2jZ47soMZo9wGzjb/7OMg0LOL+bSf63kpaSHSX ++ndS5z5rexMdbBYUsLA9e+KXBdQOS+UTo7WTBEMa2R2CapHg665xsmtdVMTBQY4uD ++Zlxvb3qCo5ZwKh9kG4LT6/I5IhlJH7aGhyxXFvUK+DWNmoudF8NAco9/h9iaGNj8 ++q2ethFkMLs91kzk2PAcDTW9gb54h4FRWyuXpoQIDAQABAoIBABKucaRpzQorw35S ++bEUAVx8dYXUdZOlJcHtiWQ+dC6V8ljxAHj/PLyzTveyI5QO/xkObCyjIL303l2cf ++UhPu2MFaJdjVzqACXuOrLot/eSFvxjvqVidTtAZExqFRJ9mylUVAoLvhowVWmC1O ++n95fZCXxTUtxNEG1Xcc7m0rtzJKs45J+N/V9DP1edYH6USyPSWGp6wuA+KgHRnKK ++Vf9GRx80JQY7nVNkL17eHoTWEwga+lwi0FEoW9Y7lDtWXYmKBWhUE+U8PGxlJf8f ++40493HDw1WRQ/aSLoS4QTp3rn7gYgeHEvfJdkkf0UMhlknlo53M09EFPdadQ4TlU ++bjqKc50CgYEA4BzEEOtIpmVdVEZNCqS7baC4crd0pqnRH/5IB3jw3bcxGn6QLvnE ++tfdUdiYrqBdss1l58BQ3KhooKeQTa9AB0Hw/Py5PJdTJNPY8cQn7ouZ2KKDcmnPG ++BY5t7yLc1QlQ5xHdwW1VhvKn+nXqhJTBgIPgtldC+KDV5z+y2XDwGUcCgYEAuQPE ++fgmVtjL0Uyyx88GZFF1fOunH3+7cepKmtH4pxhtCoHqpWmT8YAmZxaewHgHAjLYs ++p1ZSe7zFYHj7C6ul7TjeLQeZD/YwD66t62wDmpe/HlB+TnBA+njbglfIsRLtXlnD ++zQkv5dTltRJ11BKBBypeeF6689rjcJIDEz9RWdcCgYAHAp9XcCSrn8wVkMVkKdb7 ++DOX4IKjzdahm+ctDAJN4O/y7OW5FKebvUjdAIt2GuoTZ71iTG+7F0F+lP88jtjP4 ++U4qe7VHoewl4MKOfXZKTe+YCS1XbNvfgwJ3Ltyl1OH9hWvu2yza7q+d5PCsDzqtm ++27kxuvULVeya+TEdAB1ijQKBgQCH/3r6YrVH/uCWGy6bzV1nGNOdjKc9tmkfOJmN ++54dxdixdpozCQ6U4OxZrsj3FcOhHBsqAHvX2uuYjagqvo3cOj1TRqNocX40omfCC ++Mx3bD1yPPf/6TI2XECva/ggqEY2mYzmIiA5LVVmc5nrybr+lssFKneeyxN2Wq93S ++0iJMdQKBgCGHewxzoa1r8ZMD0LETNrToK423K377UCYqXfg5XMclbrjPbEC3YI1Z ++NqMtuhdBJqUnBi6tjKMF+34Xf0CUN8ncuXGO2CAYvO8PdyCixHX52ybaDjy1FtCE ++6yUXjoKNXKvUm7MWGsAYH6f4IegOetN5NvmUMFStCSkh7ixZLkN1 ++-----END RSA PRIVATE KEY----- diff --cc vendor/openssl-0.9.19/test/rsa.pem.pub index 000000000,000000000..093f2ba12 new file mode 100644 --- /dev/null +++ b/vendor/openssl-0.9.19/test/rsa.pem.pub @@@ -1,0 -1,0 +1,9 @@@ ++-----BEGIN PUBLIC KEY----- ++MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAofgWCuLjybRlzo0tZWJj ++NiuSfb4p4fAkd/wWJcyQoTbji9k0l8W26mPddxHmfHQp+Vaw+4qPCJrcS2mJPMEz ++P1Pt0Bm4d4QlL+yRT+SFd2lZS+pCgNMsD1W/YpRPEwOWvG6b32690r2jZ47soMZo ++9wGzjb/7OMg0LOL+bSf63kpaSHSXndS5z5rexMdbBYUsLA9e+KXBdQOS+UTo7WTB ++EMa2R2CapHg665xsmtdVMTBQY4uDZlxvb3qCo5ZwKh9kG4LT6/I5IhlJH7aGhyxX ++FvUK+DWNmoudF8NAco9/h9iaGNj8q2ethFkMLs91kzk2PAcDTW9gb54h4FRWyuXp ++oQIDAQAB ++-----END PUBLIC KEY----- diff --cc vendor/openssl-sys-0.9.19/.cargo-checksum.json index 000000000,000000000..53af2c33b new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"1e4c63a7d559c1e5afa6d6a9e6fa34bbc5f800ffc9ae08b72c605420b0c4f5e8"} diff --cc vendor/openssl-sys-0.9.19/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/.cargo-ok diff --cc vendor/openssl-sys-0.9.19/Cargo.toml index 000000000,000000000..46667f2aa new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/Cargo.toml @@@ -1,0 -1,0 +1,35 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "openssl-sys" ++version = "0.9.19" ++authors = ["Alex Crichton ", "Steven Fackler "] ++build = "build.rs" ++links = "openssl" ++description = "FFI bindings to OpenSSL" ++documentation = "https://docs.rs/openssl-sys/0.9" ++readme = "README.md" ++categories = ["cryptography", "external-ffi-bindings"] ++license = "MIT" ++repository = "https://github.com/sfackler/rust-openssl" ++[package.metadata.pkg-config] ++openssl = "1.0.1" ++[dependencies.libc] ++version = "0.2" ++[build-dependencies.pkg-config] ++version = "0.3.9" ++ ++[build-dependencies.cc] ++version = "1.0" ++[target."cfg(target_env = \"msvc\")".build-dependencies.vcpkg] ++version = "0.2" diff --cc vendor/openssl-sys-0.9.19/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/openssl-sys-0.9.19/README.md index 000000000,000000000..c505efd3d new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/README.md @@@ -1,0 -1,0 +1,173 @@@ ++# rust-openssl ++ ++[![CircleCI](https://circleci.com/gh/sfackler/rust-openssl.svg?style=shield)](https://circleci.com/gh/sfackler/rust-openssl) [![Build Status](https://travis-ci.org/sfackler/rust-openssl.svg?branch=master)](https://travis-ci.org/sfackler/rust-openssl) [![Build status](https://ci.appveyor.com/api/projects/status/d1knobws948pyynk/branch/master?svg=true)](https://ci.appveyor.com/project/sfackler/rust-openssl/branch/master) ++ ++[Documentation](https://docs.rs/openssl). ++ ++## Warning ++ ++This README does not correspond to rust-openssl 0.7.x or 0.8.x. See ++[here](https://github.com/sfackler/rust-openssl/blob/b8fb29db5c246175a096260eacca38180cd77dd0/README.md) ++for that README. ++ ++## Building ++ ++rust-openssl depends on OpenSSL version 1.0.1 or above, or LibreSSL. Both the ++libraries and headers need to be present in the build environment before this ++crate is compiled, and some instructions of how to do this are in the sections ++below. ++ ++### Linux ++ ++On Linux, you can typically install OpenSSL via your package manager. The ++headers are sometimes provided in a separate package than the runtime libraries ++- look for something like `openssl-devel` or `libssl-dev`. You will also need the ++regular development utilities, like `pkg-config`, as the custom build script relies ++on them. ++ ++```bash ++# On Debian and Ubuntu ++sudo apt-get install pkg-config libssl-dev ++# On Arch Linux ++sudo pacman -S openssl ++# On Fedora ++sudo dnf install openssl-devel ++``` ++ ++If installation via a package manager is not possible, or if you're cross ++compiling to a separate target, you'll typically need to compile OpenSSL from ++source. That can normally be done with: ++ ++``` ++curl -O https://www.openssl.org/source/openssl-1.1.0f.tar.gz ++tar xf openssl-1.1.0f.tar.gz ++cd openssl-1.1.0f ++export CC=... ++./Configure --prefix=... linux-x86_64 -fPIC ++make -j$(nproc) ++make install ++``` ++ ++### OSX ++ ++Although OpenSSL 0.9.8 is preinstalled on OSX this library is being phased out ++of OSX and this crate also does not support that version of OpenSSL. To use this ++crate on OSX you'll need to install OpenSSL via some alternate means, typically ++Homebrew: ++ ++```bash ++brew install openssl ++``` ++ ++Occasionally an update of XCode or MacOS will cause the linker to fail after compilation, to rectify this you may want to try and run: ++ ++```bash ++xcode-select --install ++``` ++ ++If Homebrew is installed to the default location of `/usr/local`, OpenSSL will be ++automatically detected. ++ ++### Windows MSVC ++ ++On MSVC it's unfortunately not always a trivial process acquiring OpenSSL. A couple of possibilities ++are downloading precompiled binaries for OpenSSL 1.1.0, or installing OpenSSL 1.0.2 using vcpkg. ++ ++#### Installing OpenSSL 1.1.0 using precompiled binaries ++ ++Perhaps the easiest way to do this right now is to download [precompiled ++binaries] and install them on your system. Currently it's recommended to ++install the 1.1.0 (non-light) installation if you're choosing this route. ++ ++[precompiled binaries]: http://slproweb.com/products/Win32OpenSSL.html ++ ++Once a precompiled binary is installed you can configure this crate to find the ++installation via an environment variable: ++ ++``` ++set OPENSSL_DIR=C:\OpenSSL-Win64 ++``` ++ ++Now you will need to [install root certificates.](#acquiring-root-certificates) ++ ++#### Installing OpenSSL 1.0.2 using vcpkg ++ ++Install [vcpkg](https://github.com/Microsoft/vcpkg), and install the OpenSSL port like this: ++ ++```Batchfile ++vcpkg install openssl:x64-windows ++set VCPKG_ROOT=c:\path\to\vcpkg\installation ++cargo build ++``` ++ ++For more information see the vcpkg build helper [documentation](http://docs.rs/vcpkg). ++To finsh setting up OpenSSL you will need to [install root certificates.](#acquiring-root-certificates) ++ ++#### Acquiring Root Certificates ++ ++Neither of the above OpenSSL distributions ship with any root certificates. ++So to make requests to servers on the internet, you have to install them ++manually. Download the [cacert.pem file from here], copy it somewhere safe ++(`C:\OpenSSL-Win64\certs` is a good place) and point the `SSL_CERT_FILE` ++environment variable there: ++ ++``` ++set SSL_CERT_FILE=C:\OpenSSL-Win64\certs\cacert.pem ++``` ++ ++[cacert.pem file from here]: https://curl.haxx.se/docs/caextract.html ++ ++After that, you're just a `cargo build` away! ++ ++### Windows GNU (MinGW) ++ ++The easiest way to acquire OpenSSL when working with MinGW is to ensure you're ++using [MSYS2](http://msys2.github.io) and to then execute: ++ ++``` ++# 32-bit ++pacman -S mingw-w64-i686-openssl ++ ++# 64-bit ++pacman -S mingw-w64-x86_64-openssl ++``` ++ ++And after that, a `cargo build` should be all you need! ++ ++### Manual configuration ++ ++rust-openssl's build script will by default attempt to locate OpenSSL via ++pkg-config or other system-specific mechanisms. This will not work in some ++situations however, for example cross compiling or when using a copy of OpenSSL ++other than the normal system install. ++ ++The build script can be configured via environment variables: ++ ++* `OPENSSL_DIR` - If specified, a directory that will be used to find ++ OpenSSL installation. It's expected that under this directory the `include` ++ folder has header files and a `lib` folder has the runtime libraries. ++* `OPENSSL_LIB_DIR` - If specified, a directory that will be used to find ++ OpenSSL libraries. Overrides the `lib` folder implied by `OPENSSL_DIR` ++ (if specified). ++* `OPENSSL_INCLUDE_DIR` - If specified, a directory that will be used to find ++ OpenSSL header files. Overrides the `include` folder implied by `OPENSSL_DIR` ++ (if specified). ++* `OPENSSL_STATIC` - If specified, OpenSSL libraries will be statically rather ++ than dynamically linked. ++* `OPENSSL_LIBS` - If specified, the names of the OpenSSL libraries that will be ++ linked, e.g. `ssl:crypto`. ++ ++If `OPENSSL_DIR` or `OPENSSL_LIB_DIR` and `OPENSSL_INCLUDE_DIR` is specified, ++then the build script will skip the pkg-config step. ++ ++For target-specific configuration, each of these environment variables can be ++prefixed by an upper-cased target, for example, ++`X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR`. This can be useful in cross compilation ++contexts. ++ ++### 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 under the terms of both the Apache License, ++Version 2.0 and the MIT license without any additional terms or conditions. diff --cc vendor/openssl-sys-0.9.19/build.rs index 000000000,000000000..4848f236a new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/build.rs @@@ -1,0 -1,0 +1,545 @@@ ++extern crate pkg_config; ++#[cfg(target_env = "msvc")] ++extern crate vcpkg; ++extern crate cc; ++ ++use std::collections::HashSet; ++use std::env; ++use std::ffi::OsString; ++use std::fs::File; ++use std::io::{BufWriter, Write}; ++use std::path::{Path, PathBuf}; ++use std::panic::{self, AssertUnwindSafe}; ++use std::process::Command; ++ ++// The set of `OPENSSL_NO_`s that we care about. ++const DEFINES: &'static [&'static str] = &[ ++ "OPENSSL_NO_BUF_FREELISTS", ++ "OPENSSL_NO_COMP", ++ "OPENSSL_NO_EC", ++ "OPENSSL_NO_EC2M", ++ "OPENSSL_NO_ENGINE", ++ "OPENSSL_NO_KRB5", ++ "OPENSSL_NO_NEXTPROTONEG", ++ "OPENSSL_NO_PSK", ++ "OPENSSL_NO_RFC3779", ++ "OPENSSL_NO_SHA", ++ "OPENSSL_NO_SRP", ++ "OPENSSL_NO_SSL3_METHOD", ++ "OPENSSL_NO_TLSEXT", ++]; ++ ++enum Version { ++ Openssl110, ++ Openssl102, ++ Openssl101, ++ Libressl, ++} ++ ++fn env(name: &str) -> Option { ++ let prefix = env::var("TARGET").unwrap().to_uppercase().replace("-", "_"); ++ let prefixed = format!("{}_{}", prefix, name); ++ println!("cargo:rerun-if-env-changed={}", prefixed); ++ ++ if let Some(var) = env::var_os(&prefixed) { ++ return Some(var); ++ } ++ ++ println!("cargo:rerun-if-env-changed={}", name); ++ env::var_os(name) ++} ++ ++fn main() { ++ let target = env::var("TARGET").unwrap(); ++ ++ let lib_dir = env("OPENSSL_LIB_DIR").map(PathBuf::from); ++ let include_dir = env("OPENSSL_INCLUDE_DIR").map(PathBuf::from); ++ ++ let (lib_dir, include_dir) = if lib_dir.is_none() || include_dir.is_none() { ++ let openssl_dir = env("OPENSSL_DIR").unwrap_or_else(|| find_openssl_dir(&target)); ++ let openssl_dir = Path::new(&openssl_dir); ++ let lib_dir = lib_dir.unwrap_or_else(|| openssl_dir.join("lib")); ++ let include_dir = include_dir.unwrap_or_else(|| openssl_dir.join("include")); ++ (lib_dir, include_dir) ++ } else { ++ (lib_dir.unwrap(), include_dir.unwrap()) ++ }; ++ ++ if !Path::new(&lib_dir).exists() { ++ panic!( ++ "OpenSSL library directory does not exist: {}", ++ lib_dir.to_string_lossy() ++ ); ++ } ++ if !Path::new(&include_dir).exists() { ++ panic!( ++ "OpenSSL include directory does not exist: {}", ++ include_dir.to_string_lossy() ++ ); ++ } ++ ++ println!( ++ "cargo:rustc-link-search=native={}", ++ lib_dir.to_string_lossy() ++ ); ++ println!("cargo:include={}", include_dir.to_string_lossy()); ++ ++ let version = validate_headers(&[include_dir.clone().into()]); ++ ++ let libs_env = env("OPENSSL_LIBS"); ++ let libs = match libs_env.as_ref().and_then(|s| s.to_str()) { ++ Some(ref v) => v.split(":").collect(), ++ None => { ++ match version { ++ Version::Openssl101 | ++ Version::Openssl102 if target.contains("windows") => vec!["ssleay32", "libeay32"], ++ Version::Openssl110 if target.contains("windows") => vec!["libssl", "libcrypto"], ++ _ => vec!["ssl", "crypto"], ++ } ++ } ++ }; ++ ++ ++ let kind = determine_mode(Path::new(&lib_dir), &libs); ++ for lib in libs.into_iter() { ++ println!("cargo:rustc-link-lib={}={}", kind, lib); ++ } ++} ++ ++fn find_openssl_dir(target: &str) -> OsString { ++ let host = env::var("HOST").unwrap(); ++ ++ if host.contains("apple-darwin") && target.contains("apple-darwin") { ++ let homebrew = Path::new("/usr/local/opt/openssl@1.1"); ++ if homebrew.exists() { ++ return homebrew.to_path_buf().into(); ++ } ++ let homebrew = Path::new("/usr/local/opt/openssl"); ++ if homebrew.exists() { ++ return homebrew.to_path_buf().into(); ++ } ++ } ++ ++ try_pkg_config(); ++ try_vcpkg(); ++ ++ let mut msg = format!( ++ " ++ ++Could not find directory of OpenSSL installation, and this `-sys` crate cannot ++proceed without this knowledge. If OpenSSL is installed and this crate had ++trouble finding it, you can set the `OPENSSL_DIR` environment variable for the ++compilation process. ++ ++If you're in a situation where you think the directory *should* be found ++automatically, please open a bug at https://github.com/sfackler/rust-openssl ++and include information about your system as well as this message. ++ ++ $HOST = {} ++ $TARGET = {} ++ openssl-sys = {} ++ ++", ++ host, ++ target, ++ env!("CARGO_PKG_VERSION") ++ ); ++ ++ if host.contains("apple-darwin") && target.contains("apple-darwin") { ++ let system = Path::new("/usr/lib/libssl.0.9.8.dylib"); ++ if system.exists() { ++ msg.push_str(&format!( ++ " ++ ++It looks like you're compiling on macOS, where the system contains a version of ++OpenSSL 0.9.8. This crate no longer supports OpenSSL 0.9.8. ++ ++As a consumer of this crate, you can fix this error by using Homebrew to ++install the `openssl` package, or as a maintainer you can use the openssl-sys ++0.7 crate for support with OpenSSL 0.9.8. ++ ++Unfortunately though the compile cannot continue, so aborting. ++ ++" ++ )); ++ } ++ } ++ ++ if host.contains("unknown-linux") && target.contains("unknown-linux-gnu") { ++ if Command::new("pkg-config").output().is_err() { ++ msg.push_str(&format!( ++ " ++It looks like you're compiling on Linux and also targeting Linux. Currently this ++requires the `pkg-config` utility to find OpenSSL but unfortunately `pkg-config` ++could not be found. If you have OpenSSL installed you can likely fix this by ++installing `pkg-config`. ++ ++" ++ )); ++ } ++ } ++ ++ if host.contains("windows") && target.contains("windows-gnu") { ++ msg.push_str(&format!( ++ " ++It looks like you're compiling for MinGW but you may not have either OpenSSL or ++pkg-config installed. You can install these two dependencies with: ++ ++ pacman -S openssl-devel pkg-config ++ ++and try building this crate again. ++ ++" ++ )); ++ } ++ ++ if host.contains("windows") && target.contains("windows-msvc") { ++ msg.push_str(&format!( ++ " ++It looks like you're compiling for MSVC but we couldn't detect an OpenSSL ++installation. If there isn't one installed then you can try the rust-openssl ++README for more information about how to download precompiled binaries of ++OpenSSL: ++ ++ https://github.com/sfackler/rust-openssl#windows ++ ++" ++ )); ++ } ++ ++ panic!(msg); ++} ++ ++/// Attempt to find OpenSSL through pkg-config. ++/// ++/// Note that if this succeeds then the function does not return as pkg-config ++/// typically tells us all the information that we need. ++fn try_pkg_config() { ++ let target = env::var("TARGET").unwrap(); ++ let host = env::var("HOST").unwrap(); ++ ++ // If we're going to windows-gnu we can use pkg-config, but only so long as ++ // we're coming from a windows host. ++ // ++ // Otherwise if we're going to windows we probably can't use pkg-config. ++ if target.contains("windows-gnu") && host.contains("windows") { ++ env::set_var("PKG_CONFIG_ALLOW_CROSS", "1"); ++ } else if target.contains("windows") { ++ return; ++ } ++ ++ let lib = match pkg_config::Config::new().print_system_libs(false).find( ++ "openssl", ++ ) { ++ Ok(lib) => lib, ++ Err(e) => { ++ println!("run pkg_config fail: {:?}", e); ++ return; ++ } ++ }; ++ ++ validate_headers(&lib.include_paths); ++ ++ for include in lib.include_paths.iter() { ++ println!("cargo:include={}", include.display()); ++ } ++ ++ std::process::exit(0); ++} ++ ++/// Attempt to find OpenSSL through vcpkg. ++/// ++/// Note that if this succeeds then the function does not return as vcpkg ++/// should emit all of the cargo metadata that we need. ++#[cfg(target_env = "msvc")] ++fn try_vcpkg() { ++ ++ // vcpkg will not emit any metadata if it can not find libraries ++ // appropriate for the target triple with the desired linkage. ++ ++ let mut lib = vcpkg::Config::new() ++ .emit_includes(true) ++ .lib_name("libcrypto") ++ .lib_name("libssl") ++ .probe("openssl"); ++ ++ if let Err(e) = lib { ++ println!("note: vcpkg did not find openssl as libcrypto and libssl : {:?}", ++ e); ++ lib = vcpkg::Config::new() ++ .emit_includes(true) ++ .lib_name("libeay32") ++ .lib_name("ssleay32") ++ .probe("openssl"); ++ } ++ if let Err(e) = lib { ++ println!("note: vcpkg did not find openssl as ssleay32 and libeay32: {:?}", ++ e); ++ return; ++ } ++ ++ let lib = lib.unwrap(); ++ validate_headers(&lib.include_paths); ++ ++ println!("cargo:rustc-link-lib=user32"); ++ println!("cargo:rustc-link-lib=gdi32"); ++ println!("cargo:rustc-link-lib=crypt32"); ++ ++ std::process::exit(0); ++} ++ ++#[cfg(not(target_env = "msvc"))] ++fn try_vcpkg() {} ++ ++/// Validates the header files found in `include_dir` and then returns the ++/// version string of OpenSSL. ++fn validate_headers(include_dirs: &[PathBuf]) -> Version { ++ // This `*-sys` crate only works with OpenSSL 1.0.1, 1.0.2, and 1.1.0. To ++ // correctly expose the right API from this crate, take a look at ++ // `opensslv.h` to see what version OpenSSL claims to be. ++ // ++ // OpenSSL has a number of build-time configuration options which affect ++ // various structs and such. Since OpenSSL 1.1.0 this isn't really a problem ++ // as the library is much more FFI-friendly, but 1.0.{1,2} suffer this problem. ++ // ++ // To handle all this conditional compilation we slurp up the configuration ++ // file of OpenSSL, `opensslconf.h`, and then dump out everything it defines ++ // as our own #[cfg] directives. That way the `ossl10x.rs` bindings can ++ // account for compile differences and such. ++ let mut path = PathBuf::from(env::var_os("OUT_DIR").unwrap()); ++ path.push("expando.c"); ++ let mut file = BufWriter::new(File::create(&path).unwrap()); ++ ++ write!( ++ file, ++ "\ ++#include ++#include ++ ++#if LIBRESSL_VERSION_NUMBER >= 0x20602000 ++RUST_LIBRESSL_NEW ++#elif LIBRESSL_VERSION_NUMBER >= 0x20601000 ++RUST_LIBRESSL_261 ++#elif LIBRESSL_VERSION_NUMBER >= 0x20600000 ++RUST_LIBRESSL_260 ++#elif LIBRESSL_VERSION_NUMBER >= 0x20506000 ++RUST_LIBRESSL_NEW ++#elif LIBRESSL_VERSION_NUMBER >= 0x20505000 ++RUST_LIBRESSL_255 ++#elif LIBRESSL_VERSION_NUMBER >= 0x20504000 ++RUST_LIBRESSL_254 ++#elif LIBRESSL_VERSION_NUMBER >= 0x20503000 ++RUST_LIBRESSL_253 ++#elif LIBRESSL_VERSION_NUMBER >= 0x20502000 ++RUST_LIBRESSL_252 ++#elif LIBRESSL_VERSION_NUMBER >= 0x20501000 ++RUST_LIBRESSL_251 ++#elif LIBRESSL_VERSION_NUMBER >= 0x20500000 ++RUST_LIBRESSL_250 ++#elif defined (LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20500000 ++RUST_LIBRESSL_OLD ++#elif OPENSSL_VERSION_NUMBER >= 0x10101000 ++RUST_OPENSSL_NEW ++#elif OPENSSL_VERSION_NUMBER >= 0x10100060 ++RUST_OPENSSL_110F ++#elif OPENSSL_VERSION_NUMBER >= 0x10100000 ++RUST_OPENSSL_110 ++#elif OPENSSL_VERSION_NUMBER >= 0x10002000 ++RUST_OPENSSL_102 ++#elif OPENSSL_VERSION_NUMBER >= 0x10001000 ++RUST_OPENSSL_101 ++#else ++RUST_OPENSSL_OLD ++#endif ++" ++ ).unwrap(); ++ ++ for define in DEFINES { ++ write!( ++ file, ++ "\ ++#ifdef {define} ++RUST_{define}_RUST ++#endif ++", ++ define = define ++ ).unwrap(); ++ } ++ ++ file.flush().unwrap(); ++ drop(file); ++ ++ let mut gcc = cc::Build::new(); ++ for include_dir in include_dirs { ++ gcc.include(include_dir); ++ } ++ // https://github.com/alexcrichton/gcc-rs/issues/133 ++ let expanded = match panic::catch_unwind(AssertUnwindSafe(|| gcc.file(&path).expand())) { ++ Ok(expanded) => expanded, ++ Err(_) => { ++ panic!( ++ " ++Failed to find OpenSSL development headers. ++ ++You can try fixing this setting the `OPENSSL_DIR` environment variable ++pointing to your OpenSSL installation or installing OpenSSL headers package ++specific to your distribution: ++ ++ # On Ubuntu ++ sudo apt-get install libssl-dev ++ # On Arch Linux ++ sudo pacman -S openssl ++ # On Fedora ++ sudo dnf install openssl-devel ++ ++See rust-openssl README for more information: ++ ++ https://github.com/sfackler/rust-openssl#linux ++" ++ ); ++ } ++ }; ++ let expanded = String::from_utf8(expanded).unwrap(); ++ ++ let mut enabled = vec![]; ++ for &define in DEFINES { ++ if expanded.contains(&format!("RUST_{}_RUST", define)) { ++ println!("cargo:rustc-cfg=osslconf=\"{}\"", define); ++ enabled.push(define); ++ } ++ } ++ println!("cargo:conf={}", enabled.join(",")); ++ ++ if expanded.contains("RUST_LIBRESSL_250") { ++ println!("cargo:rustc-cfg=libressl"); ++ println!("cargo:rustc-cfg=libressl250"); ++ println!("cargo:libressl=true"); ++ println!("cargo:libressl_version=250"); ++ println!("cargo:version=101"); ++ Version::Libressl ++ } else if expanded.contains("RUST_LIBRESSL_251") { ++ println!("cargo:rustc-cfg=libressl"); ++ println!("cargo:rustc-cfg=libressl251"); ++ println!("cargo:libressl=true"); ++ println!("cargo:libressl_version=251"); ++ println!("cargo:version=101"); ++ Version::Libressl ++ } else if expanded.contains("RUST_LIBRESSL_252") { ++ println!("cargo:rustc-cfg=libressl"); ++ println!("cargo:rustc-cfg=libressl252"); ++ println!("cargo:libressl=true"); ++ println!("cargo:libressl_version=252"); ++ println!("cargo:version=101"); ++ Version::Libressl ++ } else if expanded.contains("RUST_LIBRESSL_253") { ++ println!("cargo:rustc-cfg=libressl"); ++ println!("cargo:rustc-cfg=libressl253"); ++ println!("cargo:libressl=true"); ++ println!("cargo:libressl_version=253"); ++ println!("cargo:version=101"); ++ Version::Libressl ++ } else if expanded.contains("RUST_LIBRESSL_254") { ++ println!("cargo:rustc-cfg=libressl"); ++ println!("cargo:rustc-cfg=libressl254"); ++ println!("cargo:libressl=true"); ++ println!("cargo:libressl_version=254"); ++ println!("cargo:version=101"); ++ Version::Libressl ++ } else if expanded.contains("RUST_LIBRESSL_255") { ++ println!("cargo:rustc-cfg=libressl"); ++ println!("cargo:rustc-cfg=libressl255"); ++ println!("cargo:libressl=true"); ++ println!("cargo:libressl_version=255"); ++ println!("cargo:version=101"); ++ Version::Libressl ++ } else if expanded.contains("RUST_LIBRESSL_260") { ++ println!("cargo:rustc-cfg=libressl"); ++ println!("cargo:rustc-cfg=libressl260"); ++ println!("cargo:libressl=true"); ++ println!("cargo:libressl_version=260"); ++ println!("cargo:version=101"); ++ Version::Libressl ++ } else if expanded.contains("RUST_LIBRESSL_261") { ++ println!("cargo:rustc-cfg=libressl"); ++ println!("cargo:rustc-cfg=libressl261"); ++ println!("cargo:libressl=true"); ++ println!("cargo:libressl_version=261"); ++ println!("cargo:version=101"); ++ Version::Libressl ++ } else if expanded.contains("RUST_OPENSSL_110F") { ++ println!("cargo:rustc-cfg=ossl110"); ++ println!("cargo:rustc-cfg=ossl110f"); ++ println!("cargo:version=110"); ++ println!("cargo:patch=f"); ++ Version::Openssl110 ++ } else if expanded.contains("RUST_OPENSSL_110") { ++ println!("cargo:rustc-cfg=ossl110"); ++ println!("cargo:version=110"); ++ Version::Openssl110 ++ } else if expanded.contains("RUST_OPENSSL_102") { ++ println!("cargo:rustc-cfg=ossl102"); ++ println!("cargo:version=102"); ++ Version::Openssl102 ++ } else if expanded.contains("RUST_OPENSSL_101") { ++ println!("cargo:rustc-cfg=ossl101"); ++ println!("cargo:version=101"); ++ Version::Openssl101 ++ } else { ++ panic!( ++ " ++ ++This crate is only compatible with OpenSSL 1.0.1, 1.0.2, and 1.1.0, or LibreSSL ++2.5 and 2.6.0, but a different version of OpenSSL was found. The build is now ++aborting due to this version mismatch. ++ ++" ++ ); ++ } ++} ++ ++/// Given a libdir for OpenSSL (where artifacts are located) as well as the name ++/// of the libraries we're linking to, figure out whether we should link them ++/// statically or dynamically. ++fn determine_mode(libdir: &Path, libs: &[&str]) -> &'static str { ++ // First see if a mode was explicitly requested ++ let kind = env("OPENSSL_STATIC"); ++ match kind.as_ref().and_then(|s| s.to_str()).map(|s| &s[..]) { ++ Some("0") => return "dylib", ++ Some(_) => return "static", ++ None => {} ++ } ++ ++ // Next, see what files we actually have to link against, and see what our ++ // possibilities even are. ++ let files = libdir ++ .read_dir() ++ .unwrap() ++ .map(|e| e.unwrap()) ++ .map(|e| e.file_name()) ++ .filter_map(|e| e.into_string().ok()) ++ .collect::>(); ++ let can_static = libs.iter().all(|l| { ++ files.contains(&format!("lib{}.a", l)) || files.contains(&format!("{}.lib", l)) ++ }); ++ let can_dylib = libs.iter().all(|l| { ++ files.contains(&format!("lib{}.so", l)) || files.contains(&format!("{}.dll", l)) || ++ files.contains(&format!("lib{}.dylib", l)) ++ }); ++ match (can_static, can_dylib) { ++ (true, false) => return "static", ++ (false, true) => return "dylib", ++ (false, false) => { ++ panic!( ++ "OpenSSL libdir at `{}` does not contain the required files \ ++ to either statically or dynamically link OpenSSL", ++ libdir.display() ++ ); ++ } ++ (true, true) => {} ++ } ++ ++ // Ok, we've got not explicit preference and can *either* link statically or ++ // link dynamically. In the interest of "security upgrades" and/or "best ++ // practices with security libs", let's link dynamically. ++ "dylib" ++} diff --cc vendor/openssl-sys-0.9.19/src/lib.rs index 000000000,000000000..b7951f0aa new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/src/lib.rs @@@ -1,0 -1,0 +1,2679 @@@ ++#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] ++#![allow(dead_code, overflowing_literals)] ++#![doc(html_root_url="https://docs.rs/openssl-sys/0.9")] ++ ++extern crate libc; ++ ++use libc::{c_void, c_int, c_char, c_ulong, c_long, c_uint, c_uchar, size_t, FILE}; ++use std::ptr; ++use std::mem; ++ ++#[cfg(any(ossl101, ossl102))] ++mod ossl10x; ++#[cfg(any(ossl101, ossl102))] ++pub use ossl10x::*; ++ ++#[cfg(ossl110)] ++mod ossl110; ++#[cfg(ossl110)] ++pub use ossl110::*; ++ ++#[cfg(libressl)] ++mod libressl; ++#[cfg(libressl)] ++pub use libressl::*; ++ ++pub enum ASN1_INTEGER {} ++pub enum ASN1_GENERALIZEDTIME {} ++pub enum ASN1_STRING {} ++pub enum ASN1_BIT_STRING {} ++pub enum ASN1_TIME {} ++pub enum ASN1_TYPE {} ++pub enum ASN1_OBJECT {} ++pub enum BN_CTX {} ++pub enum BN_GENCB {} ++pub enum CMS_ContentInfo {} ++pub enum CONF {} ++pub enum CONF_METHOD {} ++pub enum COMP_METHOD {} ++pub enum EC_KEY {} ++pub enum EC_GROUP {} ++pub enum EC_METHOD {} ++pub enum EC_POINT {} ++pub enum ENGINE {} ++pub enum EVP_CIPHER_CTX {} ++pub enum EVP_MD {} ++pub enum EVP_PKEY_CTX {} ++pub enum OCSP_BASICRESP {} ++pub enum OCSP_CERTID {} ++pub enum OCSP_RESPONSE {} ++pub enum OCSP_REQUEST {} ++pub enum OCSP_ONEREQ {} ++pub enum SSL_CIPHER {} ++pub enum SSL_METHOD {} ++pub enum X509_CRL {} ++pub enum X509_EXTENSION {} ++pub enum X509_NAME {} ++pub enum X509_NAME_ENTRY {} ++pub enum X509_STORE {} ++pub enum X509_STORE_CTX {} ++pub enum bio_st {} ++pub enum DH_METHOD {} ++pub enum RSA_METHOD {} ++pub enum BN_MONT_CTX {} ++pub enum BN_BLINDING {} ++pub enum DSA_METHOD {} ++pub enum EVP_PKEY_ASN1_METHOD {} ++ ++pub type bio_info_cb = Option< ++ unsafe extern "C" fn(*mut BIO, ++ c_int, ++ *const c_char, ++ c_int, ++ c_long, ++ c_long), ++>; ++pub type GEN_SESSION_CB = Option< ++ unsafe extern "C" fn(*const SSL, *mut c_uchar, *mut c_uint) ++ -> c_int, ++>; ++pub type tls_session_ticket_ext_cb_fn = Option< ++ unsafe extern "C" fn(*mut SSL, ++ *const c_uchar, ++ c_int, ++ *mut c_void) ++ -> c_int, ++>; ++pub type tls_session_secret_cb_fn = Option< ++ unsafe extern "C" fn(*mut SSL, ++ *mut c_void, ++ *mut c_int, ++ *mut stack_st_SSL_CIPHER, ++ *mut *mut SSL_CIPHER, ++ *mut c_void) ++ -> c_int, ++>; ++ ++#[repr(C)] ++#[derive(Copy, Clone)] ++pub enum point_conversion_form_t { ++ POINT_CONVERSION_COMPRESSED = 2, ++ POINT_CONVERSION_UNCOMPRESSED = 4, ++ POINT_CONVERSION_HYBRID = 6, ++} ++ ++#[repr(C)] ++pub struct AES_KEY { ++ // There is some business with AES_LONG which is there to ensure the values here are 32 bits ++ rd_key: [u32; 4 * (AES_MAXNR as usize + 1)], ++ rounds: c_int, ++} ++ ++#[repr(C)] ++pub struct GENERAL_NAME { ++ pub type_: c_int, ++ pub d: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct X509V3_CTX { ++ flags: c_int, ++ issuer_cert: *mut c_void, ++ subject_cert: *mut c_void, ++ subject_req: *mut c_void, ++ crl: *mut c_void, ++ db_meth: *mut c_void, ++ db: *mut c_void, ++ // I like the last comment line, it is copied from OpenSSL sources: ++ // Maybe more here ++} ++ ++#[repr(C)] ++pub struct SHA_CTX { ++ pub h0: SHA_LONG, ++ pub h1: SHA_LONG, ++ pub h2: SHA_LONG, ++ pub h3: SHA_LONG, ++ pub h4: SHA_LONG, ++ pub Nl: SHA_LONG, ++ pub Nh: SHA_LONG, ++ pub data: [SHA_LONG; SHA_LBLOCK as usize], ++ pub num: c_uint, ++} ++ ++#[repr(C)] ++pub struct SHA256_CTX { ++ pub h: [SHA_LONG; 8], ++ pub Nl: SHA_LONG, ++ pub Nh: SHA_LONG, ++ pub data: [SHA_LONG; SHA_LBLOCK as usize], ++ pub num: c_uint, ++ pub md_len: c_uint, ++} ++ ++#[repr(C)] ++pub struct SHA512_CTX { ++ pub h: [SHA_LONG64; 8], ++ pub Nl: SHA_LONG64, ++ pub Nh: SHA_LONG64, ++ // this is a union but we don't want to require 1.19 ++ u: [SHA_LONG64; SHA_LBLOCK as usize], ++ pub num: c_uint, ++ pub md_len: c_uint, ++} ++ ++#[cfg(target_pointer_width = "64")] ++pub type BN_ULONG = libc::c_ulonglong; ++#[cfg(target_pointer_width = "32")] ++pub type BN_ULONG = c_uint; ++ ++pub type CRYPTO_EX_new = unsafe extern "C" fn(parent: *mut c_void, ++ ptr: *mut c_void, ++ ad: *const CRYPTO_EX_DATA, ++ idx: c_int, ++ argl: c_long, ++ argp: *const c_void) ++ -> c_int; ++pub type CRYPTO_EX_dup = unsafe extern "C" fn(to: *mut CRYPTO_EX_DATA, ++ from: *mut CRYPTO_EX_DATA, ++ from_d: *mut c_void, ++ idx: c_int, ++ argl: c_long, ++ argp: *mut c_void) ++ -> c_int; ++pub type CRYPTO_EX_free = unsafe extern "C" fn(parent: *mut c_void, ++ ptr: *mut c_void, ++ ad: *mut CRYPTO_EX_DATA, ++ idx: c_int, ++ argl: c_long, ++ argp: *mut c_void); ++pub type PasswordCallback = unsafe extern "C" fn(buf: *mut c_char, ++ size: c_int, ++ rwflag: c_int, ++ user_data: *mut c_void) ++ -> c_int; ++ ++pub type SHA_LONG = c_uint; ++pub type SHA_LONG64 = u64; ++ ++pub const AES_ENCRYPT: c_int = 1; ++pub const AES_DECRYPT: c_int = 0; ++ ++pub const AES_MAXNR: c_int = 14; ++pub const AES_BLOCK_SIZE: c_int = 16; ++ ++pub const BIO_TYPE_NONE: c_int = 0; ++ ++pub const BIO_CTRL_EOF: c_int = 2; ++pub const BIO_CTRL_INFO: c_int = 3; ++pub const BIO_CTRL_FLUSH: c_int = 11; ++pub const BIO_C_SET_BUF_MEM_EOF_RETURN: c_int = 130; ++ ++pub const BIO_FLAGS_READ: c_int = 0x01; ++pub const BIO_FLAGS_WRITE: c_int = 0x02; ++pub const BIO_FLAGS_IO_SPECIAL: c_int = 0x04; ++pub const BIO_FLAGS_RWS: c_int = BIO_FLAGS_READ | BIO_FLAGS_WRITE | BIO_FLAGS_IO_SPECIAL; ++pub const BIO_FLAGS_SHOULD_RETRY: c_int = 0x08; ++ ++pub const CRYPTO_LOCK: c_int = 1; ++ ++pub const ERR_TXT_MALLOCED: c_int = 0x01; ++pub const ERR_TXT_STRING: c_int = 0x02; ++ ++pub const ERR_LIB_PEM: c_int = 9; ++pub const PEM_R_NO_START_LINE: c_int = 108; ++ ++pub const EVP_MAX_MD_SIZE: c_uint = 64; ++pub const EVP_PKEY_RSA: c_int = NID_rsaEncryption; ++pub const EVP_PKEY_HMAC: c_int = NID_hmac; ++pub const EVP_PKEY_DSA: c_int = NID_dsa; ++pub const EVP_PKEY_DH: c_int = NID_dhKeyAgreement; ++pub const EVP_PKEY_EC: c_int = NID_X9_62_id_ecPublicKey; ++ ++pub const EVP_PKEY_ALG_CTRL: c_int = 0x1000; ++ ++pub const EVP_PKEY_CTRL_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 1; ++ ++pub const EVP_PKEY_CTRL_GET_RSA_PADDING: c_int = EVP_PKEY_ALG_CTRL + 6; ++ ++pub const EVP_CTRL_GCM_SET_IVLEN: c_int = 0x9; ++pub const EVP_CTRL_GCM_GET_TAG: c_int = 0x10; ++pub const EVP_CTRL_GCM_SET_TAG: c_int = 0x11; ++ ++pub const MBSTRING_ASC: c_int = MBSTRING_FLAG | 1; ++pub const MBSTRING_BMP: c_int = MBSTRING_FLAG | 2; ++pub const MBSTRING_FLAG: c_int = 0x1000; ++pub const MBSTRING_UNIV: c_int = MBSTRING_FLAG | 4; ++pub const MBSTRING_UTF8: c_int = MBSTRING_FLAG; ++ ++pub const NID_undef: c_int = 0; ++pub const NID_itu_t: c_int = 645; ++pub const NID_ccitt: c_int = 404; ++pub const NID_iso: c_int = 181; ++pub const NID_joint_iso_itu_t: c_int = 646; ++pub const NID_joint_iso_ccitt: c_int = 393; ++pub const NID_member_body: c_int = 182; ++pub const NID_identified_organization: c_int = 676; ++pub const NID_hmac_md5: c_int = 780; ++pub const NID_hmac_sha1: c_int = 781; ++pub const NID_certicom_arc: c_int = 677; ++pub const NID_international_organizations: c_int = 647; ++pub const NID_wap: c_int = 678; ++pub const NID_wap_wsg: c_int = 679; ++pub const NID_selected_attribute_types: c_int = 394; ++pub const NID_clearance: c_int = 395; ++pub const NID_ISO_US: c_int = 183; ++pub const NID_X9_57: c_int = 184; ++pub const NID_X9cm: c_int = 185; ++pub const NID_dsa: c_int = 116; ++pub const NID_dsaWithSHA1: c_int = 113; ++pub const NID_ansi_X9_62: c_int = 405; ++pub const NID_X9_62_prime_field: c_int = 406; ++pub const NID_X9_62_characteristic_two_field: c_int = 407; ++pub const NID_X9_62_id_characteristic_two_basis: c_int = 680; ++pub const NID_X9_62_onBasis: c_int = 681; ++pub const NID_X9_62_tpBasis: c_int = 682; ++pub const NID_X9_62_ppBasis: c_int = 683; ++pub const NID_X9_62_id_ecPublicKey: c_int = 408; ++pub const NID_X9_62_c2pnb163v1: c_int = 684; ++pub const NID_X9_62_c2pnb163v2: c_int = 685; ++pub const NID_X9_62_c2pnb163v3: c_int = 686; ++pub const NID_X9_62_c2pnb176v1: c_int = 687; ++pub const NID_X9_62_c2tnb191v1: c_int = 688; ++pub const NID_X9_62_c2tnb191v2: c_int = 689; ++pub const NID_X9_62_c2tnb191v3: c_int = 690; ++pub const NID_X9_62_c2onb191v4: c_int = 691; ++pub const NID_X9_62_c2onb191v5: c_int = 692; ++pub const NID_X9_62_c2pnb208w1: c_int = 693; ++pub const NID_X9_62_c2tnb239v1: c_int = 694; ++pub const NID_X9_62_c2tnb239v2: c_int = 695; ++pub const NID_X9_62_c2tnb239v3: c_int = 696; ++pub const NID_X9_62_c2onb239v4: c_int = 697; ++pub const NID_X9_62_c2onb239v5: c_int = 698; ++pub const NID_X9_62_c2pnb272w1: c_int = 699; ++pub const NID_X9_62_c2pnb304w1: c_int = 700; ++pub const NID_X9_62_c2tnb359v1: c_int = 701; ++pub const NID_X9_62_c2pnb368w1: c_int = 702; ++pub const NID_X9_62_c2tnb431r1: c_int = 703; ++pub const NID_X9_62_prime192v1: c_int = 409; ++pub const NID_X9_62_prime192v2: c_int = 410; ++pub const NID_X9_62_prime192v3: c_int = 411; ++pub const NID_X9_62_prime239v1: c_int = 412; ++pub const NID_X9_62_prime239v2: c_int = 413; ++pub const NID_X9_62_prime239v3: c_int = 414; ++pub const NID_X9_62_prime256v1: c_int = 415; ++pub const NID_ecdsa_with_SHA1: c_int = 416; ++pub const NID_ecdsa_with_Recommended: c_int = 791; ++pub const NID_ecdsa_with_Specified: c_int = 792; ++pub const NID_ecdsa_with_SHA224: c_int = 793; ++pub const NID_ecdsa_with_SHA256: c_int = 794; ++pub const NID_ecdsa_with_SHA384: c_int = 795; ++pub const NID_ecdsa_with_SHA512: c_int = 796; ++pub const NID_secp112r1: c_int = 704; ++pub const NID_secp112r2: c_int = 705; ++pub const NID_secp128r1: c_int = 706; ++pub const NID_secp128r2: c_int = 707; ++pub const NID_secp160k1: c_int = 708; ++pub const NID_secp160r1: c_int = 709; ++pub const NID_secp160r2: c_int = 710; ++pub const NID_secp192k1: c_int = 711; ++pub const NID_secp224k1: c_int = 712; ++pub const NID_secp224r1: c_int = 713; ++pub const NID_secp256k1: c_int = 714; ++pub const NID_secp384r1: c_int = 715; ++pub const NID_secp521r1: c_int = 716; ++pub const NID_sect113r1: c_int = 717; ++pub const NID_sect113r2: c_int = 718; ++pub const NID_sect131r1: c_int = 719; ++pub const NID_sect131r2: c_int = 720; ++pub const NID_sect163k1: c_int = 721; ++pub const NID_sect163r1: c_int = 722; ++pub const NID_sect163r2: c_int = 723; ++pub const NID_sect193r1: c_int = 724; ++pub const NID_sect193r2: c_int = 725; ++pub const NID_sect233k1: c_int = 726; ++pub const NID_sect233r1: c_int = 727; ++pub const NID_sect239k1: c_int = 728; ++pub const NID_sect283k1: c_int = 729; ++pub const NID_sect283r1: c_int = 730; ++pub const NID_sect409k1: c_int = 731; ++pub const NID_sect409r1: c_int = 732; ++pub const NID_sect571k1: c_int = 733; ++pub const NID_sect571r1: c_int = 734; ++pub const NID_wap_wsg_idm_ecid_wtls1: c_int = 735; ++pub const NID_wap_wsg_idm_ecid_wtls3: c_int = 736; ++pub const NID_wap_wsg_idm_ecid_wtls4: c_int = 737; ++pub const NID_wap_wsg_idm_ecid_wtls5: c_int = 738; ++pub const NID_wap_wsg_idm_ecid_wtls6: c_int = 739; ++pub const NID_wap_wsg_idm_ecid_wtls7: c_int = 740; ++pub const NID_wap_wsg_idm_ecid_wtls8: c_int = 741; ++pub const NID_wap_wsg_idm_ecid_wtls9: c_int = 742; ++pub const NID_wap_wsg_idm_ecid_wtls10: c_int = 743; ++pub const NID_wap_wsg_idm_ecid_wtls11: c_int = 744; ++pub const NID_wap_wsg_idm_ecid_wtls12: c_int = 745; ++pub const NID_cast5_cbc: c_int = 108; ++pub const NID_cast5_ecb: c_int = 109; ++pub const NID_cast5_cfb64: c_int = 110; ++pub const NID_cast5_ofb64: c_int = 111; ++pub const NID_pbeWithMD5AndCast5_CBC: c_int = 112; ++pub const NID_id_PasswordBasedMAC: c_int = 782; ++pub const NID_id_DHBasedMac: c_int = 783; ++pub const NID_rsadsi: c_int = 1; ++pub const NID_pkcs: c_int = 2; ++pub const NID_pkcs1: c_int = 186; ++pub const NID_rsaEncryption: c_int = 6; ++pub const NID_md2WithRSAEncryption: c_int = 7; ++pub const NID_md4WithRSAEncryption: c_int = 396; ++pub const NID_md5WithRSAEncryption: c_int = 8; ++pub const NID_sha1WithRSAEncryption: c_int = 65; ++pub const NID_rsaesOaep: c_int = 919; ++pub const NID_mgf1: c_int = 911; ++pub const NID_rsassaPss: c_int = 912; ++pub const NID_sha256WithRSAEncryption: c_int = 668; ++pub const NID_sha384WithRSAEncryption: c_int = 669; ++pub const NID_sha512WithRSAEncryption: c_int = 670; ++pub const NID_sha224WithRSAEncryption: c_int = 671; ++pub const NID_pkcs3: c_int = 27; ++pub const NID_dhKeyAgreement: c_int = 28; ++pub const NID_pkcs5: c_int = 187; ++pub const NID_pbeWithMD2AndDES_CBC: c_int = 9; ++pub const NID_pbeWithMD5AndDES_CBC: c_int = 10; ++pub const NID_pbeWithMD2AndRC2_CBC: c_int = 168; ++pub const NID_pbeWithMD5AndRC2_CBC: c_int = 169; ++pub const NID_pbeWithSHA1AndDES_CBC: c_int = 170; ++pub const NID_pbeWithSHA1AndRC2_CBC: c_int = 68; ++pub const NID_id_pbkdf2: c_int = 69; ++pub const NID_pbes2: c_int = 161; ++pub const NID_pbmac1: c_int = 162; ++pub const NID_pkcs7: c_int = 20; ++pub const NID_pkcs7_data: c_int = 21; ++pub const NID_pkcs7_signed: c_int = 22; ++pub const NID_pkcs7_enveloped: c_int = 23; ++pub const NID_pkcs7_signedAndEnveloped: c_int = 24; ++pub const NID_pkcs7_digest: c_int = 25; ++pub const NID_pkcs7_encrypted: c_int = 26; ++pub const NID_pkcs9: c_int = 47; ++pub const NID_pkcs9_emailAddress: c_int = 48; ++pub const NID_pkcs9_unstructuredName: c_int = 49; ++pub const NID_pkcs9_contentType: c_int = 50; ++pub const NID_pkcs9_messageDigest: c_int = 51; ++pub const NID_pkcs9_signingTime: c_int = 52; ++pub const NID_pkcs9_countersignature: c_int = 53; ++pub const NID_pkcs9_challengePassword: c_int = 54; ++pub const NID_pkcs9_unstructuredAddress: c_int = 55; ++pub const NID_pkcs9_extCertAttributes: c_int = 56; ++pub const NID_ext_req: c_int = 172; ++pub const NID_SMIMECapabilities: c_int = 167; ++pub const NID_SMIME: c_int = 188; ++pub const NID_id_smime_mod: c_int = 189; ++pub const NID_id_smime_ct: c_int = 190; ++pub const NID_id_smime_aa: c_int = 191; ++pub const NID_id_smime_alg: c_int = 192; ++pub const NID_id_smime_cd: c_int = 193; ++pub const NID_id_smime_spq: c_int = 194; ++pub const NID_id_smime_cti: c_int = 195; ++pub const NID_id_smime_mod_cms: c_int = 196; ++pub const NID_id_smime_mod_ess: c_int = 197; ++pub const NID_id_smime_mod_oid: c_int = 198; ++pub const NID_id_smime_mod_msg_v3: c_int = 199; ++pub const NID_id_smime_mod_ets_eSignature_88: c_int = 200; ++pub const NID_id_smime_mod_ets_eSignature_97: c_int = 201; ++pub const NID_id_smime_mod_ets_eSigPolicy_88: c_int = 202; ++pub const NID_id_smime_mod_ets_eSigPolicy_97: c_int = 203; ++pub const NID_id_smime_ct_receipt: c_int = 204; ++pub const NID_id_smime_ct_authData: c_int = 205; ++pub const NID_id_smime_ct_publishCert: c_int = 206; ++pub const NID_id_smime_ct_TSTInfo: c_int = 207; ++pub const NID_id_smime_ct_TDTInfo: c_int = 208; ++pub const NID_id_smime_ct_contentInfo: c_int = 209; ++pub const NID_id_smime_ct_DVCSRequestData: c_int = 210; ++pub const NID_id_smime_ct_DVCSResponseData: c_int = 211; ++pub const NID_id_smime_ct_compressedData: c_int = 786; ++pub const NID_id_ct_asciiTextWithCRLF: c_int = 787; ++pub const NID_id_smime_aa_receiptRequest: c_int = 212; ++pub const NID_id_smime_aa_securityLabel: c_int = 213; ++pub const NID_id_smime_aa_mlExpandHistory: c_int = 214; ++pub const NID_id_smime_aa_contentHint: c_int = 215; ++pub const NID_id_smime_aa_msgSigDigest: c_int = 216; ++pub const NID_id_smime_aa_encapContentType: c_int = 217; ++pub const NID_id_smime_aa_contentIdentifier: c_int = 218; ++pub const NID_id_smime_aa_macValue: c_int = 219; ++pub const NID_id_smime_aa_equivalentLabels: c_int = 220; ++pub const NID_id_smime_aa_contentReference: c_int = 221; ++pub const NID_id_smime_aa_encrypKeyPref: c_int = 222; ++pub const NID_id_smime_aa_signingCertificate: c_int = 223; ++pub const NID_id_smime_aa_smimeEncryptCerts: c_int = 224; ++pub const NID_id_smime_aa_timeStampToken: c_int = 225; ++pub const NID_id_smime_aa_ets_sigPolicyId: c_int = 226; ++pub const NID_id_smime_aa_ets_commitmentType: c_int = 227; ++pub const NID_id_smime_aa_ets_signerLocation: c_int = 228; ++pub const NID_id_smime_aa_ets_signerAttr: c_int = 229; ++pub const NID_id_smime_aa_ets_otherSigCert: c_int = 230; ++pub const NID_id_smime_aa_ets_contentTimestamp: c_int = 231; ++pub const NID_id_smime_aa_ets_CertificateRefs: c_int = 232; ++pub const NID_id_smime_aa_ets_RevocationRefs: c_int = 233; ++pub const NID_id_smime_aa_ets_certValues: c_int = 234; ++pub const NID_id_smime_aa_ets_revocationValues: c_int = 235; ++pub const NID_id_smime_aa_ets_escTimeStamp: c_int = 236; ++pub const NID_id_smime_aa_ets_certCRLTimestamp: c_int = 237; ++pub const NID_id_smime_aa_ets_archiveTimeStamp: c_int = 238; ++pub const NID_id_smime_aa_signatureType: c_int = 239; ++pub const NID_id_smime_aa_dvcs_dvc: c_int = 240; ++pub const NID_id_smime_alg_ESDHwith3DES: c_int = 241; ++pub const NID_id_smime_alg_ESDHwithRC2: c_int = 242; ++pub const NID_id_smime_alg_3DESwrap: c_int = 243; ++pub const NID_id_smime_alg_RC2wrap: c_int = 244; ++pub const NID_id_smime_alg_ESDH: c_int = 245; ++pub const NID_id_smime_alg_CMS3DESwrap: c_int = 246; ++pub const NID_id_smime_alg_CMSRC2wrap: c_int = 247; ++pub const NID_id_alg_PWRI_KEK: c_int = 893; ++pub const NID_id_smime_cd_ldap: c_int = 248; ++pub const NID_id_smime_spq_ets_sqt_uri: c_int = 249; ++pub const NID_id_smime_spq_ets_sqt_unotice: c_int = 250; ++pub const NID_id_smime_cti_ets_proofOfOrigin: c_int = 251; ++pub const NID_id_smime_cti_ets_proofOfReceipt: c_int = 252; ++pub const NID_id_smime_cti_ets_proofOfDelivery: c_int = 253; ++pub const NID_id_smime_cti_ets_proofOfSender: c_int = 254; ++pub const NID_id_smime_cti_ets_proofOfApproval: c_int = 255; ++pub const NID_id_smime_cti_ets_proofOfCreation: c_int = 256; ++pub const NID_friendlyName: c_int = 156; ++pub const NID_localKeyID: c_int = 157; ++pub const NID_ms_csp_name: c_int = 417; ++pub const NID_LocalKeySet: c_int = 856; ++pub const NID_x509Certificate: c_int = 158; ++pub const NID_sdsiCertificate: c_int = 159; ++pub const NID_x509Crl: c_int = 160; ++pub const NID_pbe_WithSHA1And128BitRC4: c_int = 144; ++pub const NID_pbe_WithSHA1And40BitRC4: c_int = 145; ++pub const NID_pbe_WithSHA1And3_Key_TripleDES_CBC: c_int = 146; ++pub const NID_pbe_WithSHA1And2_Key_TripleDES_CBC: c_int = 147; ++pub const NID_pbe_WithSHA1And128BitRC2_CBC: c_int = 148; ++pub const NID_pbe_WithSHA1And40BitRC2_CBC: c_int = 149; ++pub const NID_keyBag: c_int = 150; ++pub const NID_pkcs8ShroudedKeyBag: c_int = 151; ++pub const NID_certBag: c_int = 152; ++pub const NID_crlBag: c_int = 153; ++pub const NID_secretBag: c_int = 154; ++pub const NID_safeContentsBag: c_int = 155; ++pub const NID_md2: c_int = 3; ++pub const NID_md4: c_int = 257; ++pub const NID_md5: c_int = 4; ++pub const NID_md5_sha1: c_int = 114; ++pub const NID_hmacWithMD5: c_int = 797; ++pub const NID_hmacWithSHA1: c_int = 163; ++pub const NID_hmacWithSHA224: c_int = 798; ++pub const NID_hmacWithSHA256: c_int = 799; ++pub const NID_hmacWithSHA384: c_int = 800; ++pub const NID_hmacWithSHA512: c_int = 801; ++pub const NID_rc2_cbc: c_int = 37; ++pub const NID_rc2_ecb: c_int = 38; ++pub const NID_rc2_cfb64: c_int = 39; ++pub const NID_rc2_ofb64: c_int = 40; ++pub const NID_rc2_40_cbc: c_int = 98; ++pub const NID_rc2_64_cbc: c_int = 166; ++pub const NID_rc4: c_int = 5; ++pub const NID_rc4_40: c_int = 97; ++pub const NID_des_ede3_cbc: c_int = 44; ++pub const NID_rc5_cbc: c_int = 120; ++pub const NID_rc5_ecb: c_int = 121; ++pub const NID_rc5_cfb64: c_int = 122; ++pub const NID_rc5_ofb64: c_int = 123; ++pub const NID_ms_ext_req: c_int = 171; ++pub const NID_ms_code_ind: c_int = 134; ++pub const NID_ms_code_com: c_int = 135; ++pub const NID_ms_ctl_sign: c_int = 136; ++pub const NID_ms_sgc: c_int = 137; ++pub const NID_ms_efs: c_int = 138; ++pub const NID_ms_smartcard_login: c_int = 648; ++pub const NID_ms_upn: c_int = 649; ++pub const NID_idea_cbc: c_int = 34; ++pub const NID_idea_ecb: c_int = 36; ++pub const NID_idea_cfb64: c_int = 35; ++pub const NID_idea_ofb64: c_int = 46; ++pub const NID_bf_cbc: c_int = 91; ++pub const NID_bf_ecb: c_int = 92; ++pub const NID_bf_cfb64: c_int = 93; ++pub const NID_bf_ofb64: c_int = 94; ++pub const NID_id_pkix: c_int = 127; ++pub const NID_id_pkix_mod: c_int = 258; ++pub const NID_id_pe: c_int = 175; ++pub const NID_id_qt: c_int = 259; ++pub const NID_id_kp: c_int = 128; ++pub const NID_id_it: c_int = 260; ++pub const NID_id_pkip: c_int = 261; ++pub const NID_id_alg: c_int = 262; ++pub const NID_id_cmc: c_int = 263; ++pub const NID_id_on: c_int = 264; ++pub const NID_id_pda: c_int = 265; ++pub const NID_id_aca: c_int = 266; ++pub const NID_id_qcs: c_int = 267; ++pub const NID_id_cct: c_int = 268; ++pub const NID_id_ppl: c_int = 662; ++pub const NID_id_ad: c_int = 176; ++pub const NID_id_pkix1_explicit_88: c_int = 269; ++pub const NID_id_pkix1_implicit_88: c_int = 270; ++pub const NID_id_pkix1_explicit_93: c_int = 271; ++pub const NID_id_pkix1_implicit_93: c_int = 272; ++pub const NID_id_mod_crmf: c_int = 273; ++pub const NID_id_mod_cmc: c_int = 274; ++pub const NID_id_mod_kea_profile_88: c_int = 275; ++pub const NID_id_mod_kea_profile_93: c_int = 276; ++pub const NID_id_mod_cmp: c_int = 277; ++pub const NID_id_mod_qualified_cert_88: c_int = 278; ++pub const NID_id_mod_qualified_cert_93: c_int = 279; ++pub const NID_id_mod_attribute_cert: c_int = 280; ++pub const NID_id_mod_timestamp_protocol: c_int = 281; ++pub const NID_id_mod_ocsp: c_int = 282; ++pub const NID_id_mod_dvcs: c_int = 283; ++pub const NID_id_mod_cmp2000: c_int = 284; ++pub const NID_info_access: c_int = 177; ++pub const NID_biometricInfo: c_int = 285; ++pub const NID_qcStatements: c_int = 286; ++pub const NID_ac_auditEntity: c_int = 287; ++pub const NID_ac_targeting: c_int = 288; ++pub const NID_aaControls: c_int = 289; ++pub const NID_sbgp_ipAddrBlock: c_int = 290; ++pub const NID_sbgp_autonomousSysNum: c_int = 291; ++pub const NID_sbgp_routerIdentifier: c_int = 292; ++pub const NID_ac_proxying: c_int = 397; ++pub const NID_sinfo_access: c_int = 398; ++pub const NID_proxyCertInfo: c_int = 663; ++pub const NID_id_qt_cps: c_int = 164; ++pub const NID_id_qt_unotice: c_int = 165; ++pub const NID_textNotice: c_int = 293; ++pub const NID_server_auth: c_int = 129; ++pub const NID_client_auth: c_int = 130; ++pub const NID_code_sign: c_int = 131; ++pub const NID_email_protect: c_int = 132; ++pub const NID_ipsecEndSystem: c_int = 294; ++pub const NID_ipsecTunnel: c_int = 295; ++pub const NID_ipsecUser: c_int = 296; ++pub const NID_time_stamp: c_int = 133; ++pub const NID_OCSP_sign: c_int = 180; ++pub const NID_dvcs: c_int = 297; ++pub const NID_id_it_caProtEncCert: c_int = 298; ++pub const NID_id_it_signKeyPairTypes: c_int = 299; ++pub const NID_id_it_encKeyPairTypes: c_int = 300; ++pub const NID_id_it_preferredSymmAlg: c_int = 301; ++pub const NID_id_it_caKeyUpdateInfo: c_int = 302; ++pub const NID_id_it_currentCRL: c_int = 303; ++pub const NID_id_it_unsupportedOIDs: c_int = 304; ++pub const NID_id_it_subscriptionRequest: c_int = 305; ++pub const NID_id_it_subscriptionResponse: c_int = 306; ++pub const NID_id_it_keyPairParamReq: c_int = 307; ++pub const NID_id_it_keyPairParamRep: c_int = 308; ++pub const NID_id_it_revPassphrase: c_int = 309; ++pub const NID_id_it_implicitConfirm: c_int = 310; ++pub const NID_id_it_confirmWaitTime: c_int = 311; ++pub const NID_id_it_origPKIMessage: c_int = 312; ++pub const NID_id_it_suppLangTags: c_int = 784; ++pub const NID_id_regCtrl: c_int = 313; ++pub const NID_id_regInfo: c_int = 314; ++pub const NID_id_regCtrl_regToken: c_int = 315; ++pub const NID_id_regCtrl_authenticator: c_int = 316; ++pub const NID_id_regCtrl_pkiPublicationInfo: c_int = 317; ++pub const NID_id_regCtrl_pkiArchiveOptions: c_int = 318; ++pub const NID_id_regCtrl_oldCertID: c_int = 319; ++pub const NID_id_regCtrl_protocolEncrKey: c_int = 320; ++pub const NID_id_regInfo_utf8Pairs: c_int = 321; ++pub const NID_id_regInfo_certReq: c_int = 322; ++pub const NID_id_alg_des40: c_int = 323; ++pub const NID_id_alg_noSignature: c_int = 324; ++pub const NID_id_alg_dh_sig_hmac_sha1: c_int = 325; ++pub const NID_id_alg_dh_pop: c_int = 326; ++pub const NID_id_cmc_statusInfo: c_int = 327; ++pub const NID_id_cmc_identification: c_int = 328; ++pub const NID_id_cmc_identityProof: c_int = 329; ++pub const NID_id_cmc_dataReturn: c_int = 330; ++pub const NID_id_cmc_transactionId: c_int = 331; ++pub const NID_id_cmc_senderNonce: c_int = 332; ++pub const NID_id_cmc_recipientNonce: c_int = 333; ++pub const NID_id_cmc_addExtensions: c_int = 334; ++pub const NID_id_cmc_encryptedPOP: c_int = 335; ++pub const NID_id_cmc_decryptedPOP: c_int = 336; ++pub const NID_id_cmc_lraPOPWitness: c_int = 337; ++pub const NID_id_cmc_getCert: c_int = 338; ++pub const NID_id_cmc_getCRL: c_int = 339; ++pub const NID_id_cmc_revokeRequest: c_int = 340; ++pub const NID_id_cmc_regInfo: c_int = 341; ++pub const NID_id_cmc_responseInfo: c_int = 342; ++pub const NID_id_cmc_queryPending: c_int = 343; ++pub const NID_id_cmc_popLinkRandom: c_int = 344; ++pub const NID_id_cmc_popLinkWitness: c_int = 345; ++pub const NID_id_cmc_confirmCertAcceptance: c_int = 346; ++pub const NID_id_on_personalData: c_int = 347; ++pub const NID_id_on_permanentIdentifier: c_int = 858; ++pub const NID_id_pda_dateOfBirth: c_int = 348; ++pub const NID_id_pda_placeOfBirth: c_int = 349; ++pub const NID_id_pda_gender: c_int = 351; ++pub const NID_id_pda_countryOfCitizenship: c_int = 352; ++pub const NID_id_pda_countryOfResidence: c_int = 353; ++pub const NID_id_aca_authenticationInfo: c_int = 354; ++pub const NID_id_aca_accessIdentity: c_int = 355; ++pub const NID_id_aca_chargingIdentity: c_int = 356; ++pub const NID_id_aca_group: c_int = 357; ++pub const NID_id_aca_role: c_int = 358; ++pub const NID_id_aca_encAttrs: c_int = 399; ++pub const NID_id_qcs_pkixQCSyntax_v1: c_int = 359; ++pub const NID_id_cct_crs: c_int = 360; ++pub const NID_id_cct_PKIData: c_int = 361; ++pub const NID_id_cct_PKIResponse: c_int = 362; ++pub const NID_id_ppl_anyLanguage: c_int = 664; ++pub const NID_id_ppl_inheritAll: c_int = 665; ++pub const NID_Independent: c_int = 667; ++pub const NID_ad_OCSP: c_int = 178; ++pub const NID_ad_ca_issuers: c_int = 179; ++pub const NID_ad_timeStamping: c_int = 363; ++pub const NID_ad_dvcs: c_int = 364; ++pub const NID_caRepository: c_int = 785; ++pub const NID_id_pkix_OCSP_basic: c_int = 365; ++pub const NID_id_pkix_OCSP_Nonce: c_int = 366; ++pub const NID_id_pkix_OCSP_CrlID: c_int = 367; ++pub const NID_id_pkix_OCSP_acceptableResponses: c_int = 368; ++pub const NID_id_pkix_OCSP_noCheck: c_int = 369; ++pub const NID_id_pkix_OCSP_archiveCutoff: c_int = 370; ++pub const NID_id_pkix_OCSP_serviceLocator: c_int = 371; ++pub const NID_id_pkix_OCSP_extendedStatus: c_int = 372; ++pub const NID_id_pkix_OCSP_valid: c_int = 373; ++pub const NID_id_pkix_OCSP_path: c_int = 374; ++pub const NID_id_pkix_OCSP_trustRoot: c_int = 375; ++pub const NID_algorithm: c_int = 376; ++pub const NID_md5WithRSA: c_int = 104; ++pub const NID_des_ecb: c_int = 29; ++pub const NID_des_cbc: c_int = 31; ++pub const NID_des_ofb64: c_int = 45; ++pub const NID_des_cfb64: c_int = 30; ++pub const NID_rsaSignature: c_int = 377; ++pub const NID_dsa_2: c_int = 67; ++pub const NID_dsaWithSHA: c_int = 66; ++pub const NID_shaWithRSAEncryption: c_int = 42; ++pub const NID_des_ede_ecb: c_int = 32; ++pub const NID_des_ede3_ecb: c_int = 33; ++pub const NID_des_ede_cbc: c_int = 43; ++pub const NID_des_ede_cfb64: c_int = 60; ++pub const NID_des_ede3_cfb64: c_int = 61; ++pub const NID_des_ede_ofb64: c_int = 62; ++pub const NID_des_ede3_ofb64: c_int = 63; ++pub const NID_desx_cbc: c_int = 80; ++pub const NID_sha: c_int = 41; ++pub const NID_sha1: c_int = 64; ++pub const NID_dsaWithSHA1_2: c_int = 70; ++pub const NID_sha1WithRSA: c_int = 115; ++pub const NID_ripemd160: c_int = 117; ++pub const NID_ripemd160WithRSA: c_int = 119; ++pub const NID_sxnet: c_int = 143; ++pub const NID_X500: c_int = 11; ++pub const NID_X509: c_int = 12; ++pub const NID_commonName: c_int = 13; ++pub const NID_surname: c_int = 100; ++pub const NID_serialNumber: c_int = 105; ++pub const NID_countryName: c_int = 14; ++pub const NID_localityName: c_int = 15; ++pub const NID_stateOrProvinceName: c_int = 16; ++pub const NID_streetAddress: c_int = 660; ++pub const NID_organizationName: c_int = 17; ++pub const NID_organizationalUnitName: c_int = 18; ++pub const NID_title: c_int = 106; ++pub const NID_description: c_int = 107; ++pub const NID_searchGuide: c_int = 859; ++pub const NID_businessCategory: c_int = 860; ++pub const NID_postalAddress: c_int = 861; ++pub const NID_postalCode: c_int = 661; ++pub const NID_postOfficeBox: c_int = 862; ++pub const NID_physicalDeliveryOfficeName: c_int = 863; ++pub const NID_telephoneNumber: c_int = 864; ++pub const NID_telexNumber: c_int = 865; ++pub const NID_teletexTerminalIdentifier: c_int = 866; ++pub const NID_facsimileTelephoneNumber: c_int = 867; ++pub const NID_x121Address: c_int = 868; ++pub const NID_internationaliSDNNumber: c_int = 869; ++pub const NID_registeredAddress: c_int = 870; ++pub const NID_destinationIndicator: c_int = 871; ++pub const NID_preferredDeliveryMethod: c_int = 872; ++pub const NID_presentationAddress: c_int = 873; ++pub const NID_supportedApplicationContext: c_int = 874; ++pub const NID_member: c_int = 875; ++pub const NID_owner: c_int = 876; ++pub const NID_roleOccupant: c_int = 877; ++pub const NID_seeAlso: c_int = 878; ++pub const NID_userPassword: c_int = 879; ++pub const NID_userCertificate: c_int = 880; ++pub const NID_cACertificate: c_int = 881; ++pub const NID_authorityRevocationList: c_int = 882; ++pub const NID_certificateRevocationList: c_int = 883; ++pub const NID_crossCertificatePair: c_int = 884; ++pub const NID_name: c_int = 173; ++pub const NID_givenName: c_int = 99; ++pub const NID_initials: c_int = 101; ++pub const NID_generationQualifier: c_int = 509; ++pub const NID_x500UniqueIdentifier: c_int = 503; ++pub const NID_dnQualifier: c_int = 174; ++pub const NID_enhancedSearchGuide: c_int = 885; ++pub const NID_protocolInformation: c_int = 886; ++pub const NID_distinguishedName: c_int = 887; ++pub const NID_uniqueMember: c_int = 888; ++pub const NID_houseIdentifier: c_int = 889; ++pub const NID_supportedAlgorithms: c_int = 890; ++pub const NID_deltaRevocationList: c_int = 891; ++pub const NID_dmdName: c_int = 892; ++pub const NID_pseudonym: c_int = 510; ++pub const NID_role: c_int = 400; ++pub const NID_X500algorithms: c_int = 378; ++pub const NID_rsa: c_int = 19; ++pub const NID_mdc2WithRSA: c_int = 96; ++pub const NID_mdc2: c_int = 95; ++pub const NID_id_ce: c_int = 81; ++pub const NID_subject_directory_attributes: c_int = 769; ++pub const NID_subject_key_identifier: c_int = 82; ++pub const NID_key_usage: c_int = 83; ++pub const NID_private_key_usage_period: c_int = 84; ++pub const NID_subject_alt_name: c_int = 85; ++pub const NID_issuer_alt_name: c_int = 86; ++pub const NID_basic_constraints: c_int = 87; ++pub const NID_crl_number: c_int = 88; ++pub const NID_crl_reason: c_int = 141; ++pub const NID_invalidity_date: c_int = 142; ++pub const NID_delta_crl: c_int = 140; ++pub const NID_issuing_distribution_point: c_int = 770; ++pub const NID_certificate_issuer: c_int = 771; ++pub const NID_name_constraints: c_int = 666; ++pub const NID_crl_distribution_points: c_int = 103; ++pub const NID_certificate_policies: c_int = 89; ++pub const NID_any_policy: c_int = 746; ++pub const NID_policy_mappings: c_int = 747; ++pub const NID_authority_key_identifier: c_int = 90; ++pub const NID_policy_constraints: c_int = 401; ++pub const NID_ext_key_usage: c_int = 126; ++pub const NID_freshest_crl: c_int = 857; ++pub const NID_inhibit_any_policy: c_int = 748; ++pub const NID_target_information: c_int = 402; ++pub const NID_no_rev_avail: c_int = 403; ++pub const NID_anyExtendedKeyUsage: c_int = 910; ++pub const NID_netscape: c_int = 57; ++pub const NID_netscape_cert_extension: c_int = 58; ++pub const NID_netscape_data_type: c_int = 59; ++pub const NID_netscape_cert_type: c_int = 71; ++pub const NID_netscape_base_url: c_int = 72; ++pub const NID_netscape_revocation_url: c_int = 73; ++pub const NID_netscape_ca_revocation_url: c_int = 74; ++pub const NID_netscape_renewal_url: c_int = 75; ++pub const NID_netscape_ca_policy_url: c_int = 76; ++pub const NID_netscape_ssl_server_name: c_int = 77; ++pub const NID_netscape_comment: c_int = 78; ++pub const NID_netscape_cert_sequence: c_int = 79; ++pub const NID_ns_sgc: c_int = 139; ++pub const NID_org: c_int = 379; ++pub const NID_dod: c_int = 380; ++pub const NID_iana: c_int = 381; ++pub const NID_Directory: c_int = 382; ++pub const NID_Management: c_int = 383; ++pub const NID_Experimental: c_int = 384; ++pub const NID_Private: c_int = 385; ++pub const NID_Security: c_int = 386; ++pub const NID_SNMPv2: c_int = 387; ++pub const NID_Mail: c_int = 388; ++pub const NID_Enterprises: c_int = 389; ++pub const NID_dcObject: c_int = 390; ++pub const NID_mime_mhs: c_int = 504; ++pub const NID_mime_mhs_headings: c_int = 505; ++pub const NID_mime_mhs_bodies: c_int = 506; ++pub const NID_id_hex_partial_message: c_int = 507; ++pub const NID_id_hex_multipart_message: c_int = 508; ++pub const NID_zlib_compression: c_int = 125; ++pub const NID_aes_128_ecb: c_int = 418; ++pub const NID_aes_128_cbc: c_int = 419; ++pub const NID_aes_128_ofb128: c_int = 420; ++pub const NID_aes_128_cfb128: c_int = 421; ++pub const NID_id_aes128_wrap: c_int = 788; ++pub const NID_aes_128_gcm: c_int = 895; ++pub const NID_aes_128_ccm: c_int = 896; ++pub const NID_id_aes128_wrap_pad: c_int = 897; ++pub const NID_aes_192_ecb: c_int = 422; ++pub const NID_aes_192_cbc: c_int = 423; ++pub const NID_aes_192_ofb128: c_int = 424; ++pub const NID_aes_192_cfb128: c_int = 425; ++pub const NID_id_aes192_wrap: c_int = 789; ++pub const NID_aes_192_gcm: c_int = 898; ++pub const NID_aes_192_ccm: c_int = 899; ++pub const NID_id_aes192_wrap_pad: c_int = 900; ++pub const NID_aes_256_ecb: c_int = 426; ++pub const NID_aes_256_cbc: c_int = 427; ++pub const NID_aes_256_ofb128: c_int = 428; ++pub const NID_aes_256_cfb128: c_int = 429; ++pub const NID_id_aes256_wrap: c_int = 790; ++pub const NID_aes_256_gcm: c_int = 901; ++pub const NID_aes_256_ccm: c_int = 902; ++pub const NID_id_aes256_wrap_pad: c_int = 903; ++pub const NID_aes_128_cfb1: c_int = 650; ++pub const NID_aes_192_cfb1: c_int = 651; ++pub const NID_aes_256_cfb1: c_int = 652; ++pub const NID_aes_128_cfb8: c_int = 653; ++pub const NID_aes_192_cfb8: c_int = 654; ++pub const NID_aes_256_cfb8: c_int = 655; ++pub const NID_aes_128_ctr: c_int = 904; ++pub const NID_aes_192_ctr: c_int = 905; ++pub const NID_aes_256_ctr: c_int = 906; ++pub const NID_aes_128_xts: c_int = 913; ++pub const NID_aes_256_xts: c_int = 914; ++pub const NID_des_cfb1: c_int = 656; ++pub const NID_des_cfb8: c_int = 657; ++pub const NID_des_ede3_cfb1: c_int = 658; ++pub const NID_des_ede3_cfb8: c_int = 659; ++pub const NID_sha256: c_int = 672; ++pub const NID_sha384: c_int = 673; ++pub const NID_sha512: c_int = 674; ++pub const NID_sha224: c_int = 675; ++pub const NID_dsa_with_SHA224: c_int = 802; ++pub const NID_dsa_with_SHA256: c_int = 803; ++pub const NID_hold_instruction_code: c_int = 430; ++pub const NID_hold_instruction_none: c_int = 431; ++pub const NID_hold_instruction_call_issuer: c_int = 432; ++pub const NID_hold_instruction_reject: c_int = 433; ++pub const NID_data: c_int = 434; ++pub const NID_pss: c_int = 435; ++pub const NID_ucl: c_int = 436; ++pub const NID_pilot: c_int = 437; ++pub const NID_pilotAttributeType: c_int = 438; ++pub const NID_pilotAttributeSyntax: c_int = 439; ++pub const NID_pilotObjectClass: c_int = 440; ++pub const NID_pilotGroups: c_int = 441; ++pub const NID_iA5StringSyntax: c_int = 442; ++pub const NID_caseIgnoreIA5StringSyntax: c_int = 443; ++pub const NID_pilotObject: c_int = 444; ++pub const NID_pilotPerson: c_int = 445; ++pub const NID_account: c_int = 446; ++pub const NID_document: c_int = 447; ++pub const NID_room: c_int = 448; ++pub const NID_documentSeries: c_int = 449; ++pub const NID_Domain: c_int = 392; ++pub const NID_rFC822localPart: c_int = 450; ++pub const NID_dNSDomain: c_int = 451; ++pub const NID_domainRelatedObject: c_int = 452; ++pub const NID_friendlyCountry: c_int = 453; ++pub const NID_simpleSecurityObject: c_int = 454; ++pub const NID_pilotOrganization: c_int = 455; ++pub const NID_pilotDSA: c_int = 456; ++pub const NID_qualityLabelledData: c_int = 457; ++pub const NID_userId: c_int = 458; ++pub const NID_textEncodedORAddress: c_int = 459; ++pub const NID_rfc822Mailbox: c_int = 460; ++pub const NID_info: c_int = 461; ++pub const NID_favouriteDrink: c_int = 462; ++pub const NID_roomNumber: c_int = 463; ++pub const NID_photo: c_int = 464; ++pub const NID_userClass: c_int = 465; ++pub const NID_host: c_int = 466; ++pub const NID_manager: c_int = 467; ++pub const NID_documentIdentifier: c_int = 468; ++pub const NID_documentTitle: c_int = 469; ++pub const NID_documentVersion: c_int = 470; ++pub const NID_documentAuthor: c_int = 471; ++pub const NID_documentLocation: c_int = 472; ++pub const NID_homeTelephoneNumber: c_int = 473; ++pub const NID_secretary: c_int = 474; ++pub const NID_otherMailbox: c_int = 475; ++pub const NID_lastModifiedTime: c_int = 476; ++pub const NID_lastModifiedBy: c_int = 477; ++pub const NID_domainComponent: c_int = 391; ++pub const NID_aRecord: c_int = 478; ++pub const NID_pilotAttributeType27: c_int = 479; ++pub const NID_mXRecord: c_int = 480; ++pub const NID_nSRecord: c_int = 481; ++pub const NID_sOARecord: c_int = 482; ++pub const NID_cNAMERecord: c_int = 483; ++pub const NID_associatedDomain: c_int = 484; ++pub const NID_associatedName: c_int = 485; ++pub const NID_homePostalAddress: c_int = 486; ++pub const NID_personalTitle: c_int = 487; ++pub const NID_mobileTelephoneNumber: c_int = 488; ++pub const NID_pagerTelephoneNumber: c_int = 489; ++pub const NID_friendlyCountryName: c_int = 490; ++pub const NID_organizationalStatus: c_int = 491; ++pub const NID_janetMailbox: c_int = 492; ++pub const NID_mailPreferenceOption: c_int = 493; ++pub const NID_buildingName: c_int = 494; ++pub const NID_dSAQuality: c_int = 495; ++pub const NID_singleLevelQuality: c_int = 496; ++pub const NID_subtreeMinimumQuality: c_int = 497; ++pub const NID_subtreeMaximumQuality: c_int = 498; ++pub const NID_personalSignature: c_int = 499; ++pub const NID_dITRedirect: c_int = 500; ++pub const NID_audio: c_int = 501; ++pub const NID_documentPublisher: c_int = 502; ++pub const NID_id_set: c_int = 512; ++pub const NID_set_ctype: c_int = 513; ++pub const NID_set_msgExt: c_int = 514; ++pub const NID_set_attr: c_int = 515; ++pub const NID_set_policy: c_int = 516; ++pub const NID_set_certExt: c_int = 517; ++pub const NID_set_brand: c_int = 518; ++pub const NID_setct_PANData: c_int = 519; ++pub const NID_setct_PANToken: c_int = 520; ++pub const NID_setct_PANOnly: c_int = 521; ++pub const NID_setct_OIData: c_int = 522; ++pub const NID_setct_PI: c_int = 523; ++pub const NID_setct_PIData: c_int = 524; ++pub const NID_setct_PIDataUnsigned: c_int = 525; ++pub const NID_setct_HODInput: c_int = 526; ++pub const NID_setct_AuthResBaggage: c_int = 527; ++pub const NID_setct_AuthRevReqBaggage: c_int = 528; ++pub const NID_setct_AuthRevResBaggage: c_int = 529; ++pub const NID_setct_CapTokenSeq: c_int = 530; ++pub const NID_setct_PInitResData: c_int = 531; ++pub const NID_setct_PI_TBS: c_int = 532; ++pub const NID_setct_PResData: c_int = 533; ++pub const NID_setct_AuthReqTBS: c_int = 534; ++pub const NID_setct_AuthResTBS: c_int = 535; ++pub const NID_setct_AuthResTBSX: c_int = 536; ++pub const NID_setct_AuthTokenTBS: c_int = 537; ++pub const NID_setct_CapTokenData: c_int = 538; ++pub const NID_setct_CapTokenTBS: c_int = 539; ++pub const NID_setct_AcqCardCodeMsg: c_int = 540; ++pub const NID_setct_AuthRevReqTBS: c_int = 541; ++pub const NID_setct_AuthRevResData: c_int = 542; ++pub const NID_setct_AuthRevResTBS: c_int = 543; ++pub const NID_setct_CapReqTBS: c_int = 544; ++pub const NID_setct_CapReqTBSX: c_int = 545; ++pub const NID_setct_CapResData: c_int = 546; ++pub const NID_setct_CapRevReqTBS: c_int = 547; ++pub const NID_setct_CapRevReqTBSX: c_int = 548; ++pub const NID_setct_CapRevResData: c_int = 549; ++pub const NID_setct_CredReqTBS: c_int = 550; ++pub const NID_setct_CredReqTBSX: c_int = 551; ++pub const NID_setct_CredResData: c_int = 552; ++pub const NID_setct_CredRevReqTBS: c_int = 553; ++pub const NID_setct_CredRevReqTBSX: c_int = 554; ++pub const NID_setct_CredRevResData: c_int = 555; ++pub const NID_setct_PCertReqData: c_int = 556; ++pub const NID_setct_PCertResTBS: c_int = 557; ++pub const NID_setct_BatchAdminReqData: c_int = 558; ++pub const NID_setct_BatchAdminResData: c_int = 559; ++pub const NID_setct_CardCInitResTBS: c_int = 560; ++pub const NID_setct_MeAqCInitResTBS: c_int = 561; ++pub const NID_setct_RegFormResTBS: c_int = 562; ++pub const NID_setct_CertReqData: c_int = 563; ++pub const NID_setct_CertReqTBS: c_int = 564; ++pub const NID_setct_CertResData: c_int = 565; ++pub const NID_setct_CertInqReqTBS: c_int = 566; ++pub const NID_setct_ErrorTBS: c_int = 567; ++pub const NID_setct_PIDualSignedTBE: c_int = 568; ++pub const NID_setct_PIUnsignedTBE: c_int = 569; ++pub const NID_setct_AuthReqTBE: c_int = 570; ++pub const NID_setct_AuthResTBE: c_int = 571; ++pub const NID_setct_AuthResTBEX: c_int = 572; ++pub const NID_setct_AuthTokenTBE: c_int = 573; ++pub const NID_setct_CapTokenTBE: c_int = 574; ++pub const NID_setct_CapTokenTBEX: c_int = 575; ++pub const NID_setct_AcqCardCodeMsgTBE: c_int = 576; ++pub const NID_setct_AuthRevReqTBE: c_int = 577; ++pub const NID_setct_AuthRevResTBE: c_int = 578; ++pub const NID_setct_AuthRevResTBEB: c_int = 579; ++pub const NID_setct_CapReqTBE: c_int = 580; ++pub const NID_setct_CapReqTBEX: c_int = 581; ++pub const NID_setct_CapResTBE: c_int = 582; ++pub const NID_setct_CapRevReqTBE: c_int = 583; ++pub const NID_setct_CapRevReqTBEX: c_int = 584; ++pub const NID_setct_CapRevResTBE: c_int = 585; ++pub const NID_setct_CredReqTBE: c_int = 586; ++pub const NID_setct_CredReqTBEX: c_int = 587; ++pub const NID_setct_CredResTBE: c_int = 588; ++pub const NID_setct_CredRevReqTBE: c_int = 589; ++pub const NID_setct_CredRevReqTBEX: c_int = 590; ++pub const NID_setct_CredRevResTBE: c_int = 591; ++pub const NID_setct_BatchAdminReqTBE: c_int = 592; ++pub const NID_setct_BatchAdminResTBE: c_int = 593; ++pub const NID_setct_RegFormReqTBE: c_int = 594; ++pub const NID_setct_CertReqTBE: c_int = 595; ++pub const NID_setct_CertReqTBEX: c_int = 596; ++pub const NID_setct_CertResTBE: c_int = 597; ++pub const NID_setct_CRLNotificationTBS: c_int = 598; ++pub const NID_setct_CRLNotificationResTBS: c_int = 599; ++pub const NID_setct_BCIDistributionTBS: c_int = 600; ++pub const NID_setext_genCrypt: c_int = 601; ++pub const NID_setext_miAuth: c_int = 602; ++pub const NID_setext_pinSecure: c_int = 603; ++pub const NID_setext_pinAny: c_int = 604; ++pub const NID_setext_track2: c_int = 605; ++pub const NID_setext_cv: c_int = 606; ++pub const NID_set_policy_root: c_int = 607; ++pub const NID_setCext_hashedRoot: c_int = 608; ++pub const NID_setCext_certType: c_int = 609; ++pub const NID_setCext_merchData: c_int = 610; ++pub const NID_setCext_cCertRequired: c_int = 611; ++pub const NID_setCext_tunneling: c_int = 612; ++pub const NID_setCext_setExt: c_int = 613; ++pub const NID_setCext_setQualf: c_int = 614; ++pub const NID_setCext_PGWYcapabilities: c_int = 615; ++pub const NID_setCext_TokenIdentifier: c_int = 616; ++pub const NID_setCext_Track2Data: c_int = 617; ++pub const NID_setCext_TokenType: c_int = 618; ++pub const NID_setCext_IssuerCapabilities: c_int = 619; ++pub const NID_setAttr_Cert: c_int = 620; ++pub const NID_setAttr_PGWYcap: c_int = 621; ++pub const NID_setAttr_TokenType: c_int = 622; ++pub const NID_setAttr_IssCap: c_int = 623; ++pub const NID_set_rootKeyThumb: c_int = 624; ++pub const NID_set_addPolicy: c_int = 625; ++pub const NID_setAttr_Token_EMV: c_int = 626; ++pub const NID_setAttr_Token_B0Prime: c_int = 627; ++pub const NID_setAttr_IssCap_CVM: c_int = 628; ++pub const NID_setAttr_IssCap_T2: c_int = 629; ++pub const NID_setAttr_IssCap_Sig: c_int = 630; ++pub const NID_setAttr_GenCryptgrm: c_int = 631; ++pub const NID_setAttr_T2Enc: c_int = 632; ++pub const NID_setAttr_T2cleartxt: c_int = 633; ++pub const NID_setAttr_TokICCsig: c_int = 634; ++pub const NID_setAttr_SecDevSig: c_int = 635; ++pub const NID_set_brand_IATA_ATA: c_int = 636; ++pub const NID_set_brand_Diners: c_int = 637; ++pub const NID_set_brand_AmericanExpress: c_int = 638; ++pub const NID_set_brand_JCB: c_int = 639; ++pub const NID_set_brand_Visa: c_int = 640; ++pub const NID_set_brand_MasterCard: c_int = 641; ++pub const NID_set_brand_Novus: c_int = 642; ++pub const NID_des_cdmf: c_int = 643; ++pub const NID_rsaOAEPEncryptionSET: c_int = 644; ++pub const NID_ipsec3: c_int = 749; ++pub const NID_ipsec4: c_int = 750; ++pub const NID_whirlpool: c_int = 804; ++pub const NID_cryptopro: c_int = 805; ++pub const NID_cryptocom: c_int = 806; ++pub const NID_id_GostR3411_94_with_GostR3410_2001: c_int = 807; ++pub const NID_id_GostR3411_94_with_GostR3410_94: c_int = 808; ++pub const NID_id_GostR3411_94: c_int = 809; ++pub const NID_id_HMACGostR3411_94: c_int = 810; ++pub const NID_id_GostR3410_2001: c_int = 811; ++pub const NID_id_GostR3410_94: c_int = 812; ++pub const NID_id_Gost28147_89: c_int = 813; ++pub const NID_gost89_cnt: c_int = 814; ++pub const NID_id_Gost28147_89_MAC: c_int = 815; ++pub const NID_id_GostR3411_94_prf: c_int = 816; ++pub const NID_id_GostR3410_2001DH: c_int = 817; ++pub const NID_id_GostR3410_94DH: c_int = 818; ++pub const NID_id_Gost28147_89_CryptoPro_KeyMeshing: c_int = 819; ++pub const NID_id_Gost28147_89_None_KeyMeshing: c_int = 820; ++pub const NID_id_GostR3411_94_TestParamSet: c_int = 821; ++pub const NID_id_GostR3411_94_CryptoProParamSet: c_int = 822; ++pub const NID_id_Gost28147_89_TestParamSet: c_int = 823; ++pub const NID_id_Gost28147_89_CryptoPro_A_ParamSet: c_int = 824; ++pub const NID_id_Gost28147_89_CryptoPro_B_ParamSet: c_int = 825; ++pub const NID_id_Gost28147_89_CryptoPro_C_ParamSet: c_int = 826; ++pub const NID_id_Gost28147_89_CryptoPro_D_ParamSet: c_int = 827; ++pub const NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet: c_int = 828; ++pub const NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet: c_int = 829; ++pub const NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet: c_int = 830; ++pub const NID_id_GostR3410_94_TestParamSet: c_int = 831; ++pub const NID_id_GostR3410_94_CryptoPro_A_ParamSet: c_int = 832; ++pub const NID_id_GostR3410_94_CryptoPro_B_ParamSet: c_int = 833; ++pub const NID_id_GostR3410_94_CryptoPro_C_ParamSet: c_int = 834; ++pub const NID_id_GostR3410_94_CryptoPro_D_ParamSet: c_int = 835; ++pub const NID_id_GostR3410_94_CryptoPro_XchA_ParamSet: c_int = 836; ++pub const NID_id_GostR3410_94_CryptoPro_XchB_ParamSet: c_int = 837; ++pub const NID_id_GostR3410_94_CryptoPro_XchC_ParamSet: c_int = 838; ++pub const NID_id_GostR3410_2001_TestParamSet: c_int = 839; ++pub const NID_id_GostR3410_2001_CryptoPro_A_ParamSet: c_int = 840; ++pub const NID_id_GostR3410_2001_CryptoPro_B_ParamSet: c_int = 841; ++pub const NID_id_GostR3410_2001_CryptoPro_C_ParamSet: c_int = 842; ++pub const NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet: c_int = 843; ++pub const NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet: c_int = 844; ++pub const NID_id_GostR3410_94_a: c_int = 845; ++pub const NID_id_GostR3410_94_aBis: c_int = 846; ++pub const NID_id_GostR3410_94_b: c_int = 847; ++pub const NID_id_GostR3410_94_bBis: c_int = 848; ++pub const NID_id_Gost28147_89_cc: c_int = 849; ++pub const NID_id_GostR3410_94_cc: c_int = 850; ++pub const NID_id_GostR3410_2001_cc: c_int = 851; ++pub const NID_id_GostR3411_94_with_GostR3410_94_cc: c_int = 852; ++pub const NID_id_GostR3411_94_with_GostR3410_2001_cc: c_int = 853; ++pub const NID_id_GostR3410_2001_ParamSet_cc: c_int = 854; ++pub const NID_camellia_128_cbc: c_int = 751; ++pub const NID_camellia_192_cbc: c_int = 752; ++pub const NID_camellia_256_cbc: c_int = 753; ++pub const NID_id_camellia128_wrap: c_int = 907; ++pub const NID_id_camellia192_wrap: c_int = 908; ++pub const NID_id_camellia256_wrap: c_int = 909; ++pub const NID_camellia_128_ecb: c_int = 754; ++pub const NID_camellia_128_ofb128: c_int = 766; ++pub const NID_camellia_128_cfb128: c_int = 757; ++pub const NID_camellia_192_ecb: c_int = 755; ++pub const NID_camellia_192_ofb128: c_int = 767; ++pub const NID_camellia_192_cfb128: c_int = 758; ++pub const NID_camellia_256_ecb: c_int = 756; ++pub const NID_camellia_256_ofb128: c_int = 768; ++pub const NID_camellia_256_cfb128: c_int = 759; ++pub const NID_camellia_128_cfb1: c_int = 760; ++pub const NID_camellia_192_cfb1: c_int = 761; ++pub const NID_camellia_256_cfb1: c_int = 762; ++pub const NID_camellia_128_cfb8: c_int = 763; ++pub const NID_camellia_192_cfb8: c_int = 764; ++pub const NID_camellia_256_cfb8: c_int = 765; ++pub const NID_kisa: c_int = 773; ++pub const NID_seed_ecb: c_int = 776; ++pub const NID_seed_cbc: c_int = 777; ++pub const NID_seed_cfb128: c_int = 779; ++pub const NID_seed_ofb128: c_int = 778; ++pub const NID_hmac: c_int = 855; ++pub const NID_cmac: c_int = 894; ++pub const NID_rc4_hmac_md5: c_int = 915; ++pub const NID_aes_128_cbc_hmac_sha1: c_int = 916; ++pub const NID_aes_192_cbc_hmac_sha1: c_int = 917; ++pub const NID_aes_256_cbc_hmac_sha1: c_int = 918; ++ ++pub const OCSP_NOCERTS: c_ulong = 0x1; ++pub const OCSP_NOINTERN: c_ulong = 0x2; ++pub const OCSP_NOSIGS: c_ulong = 0x4; ++pub const OCSP_NOCHAIN: c_ulong = 0x8; ++pub const OCSP_NOVERIFY: c_ulong = 0x10; ++pub const OCSP_NOEXPLICIT: c_ulong = 0x20; ++pub const OCSP_NOCASIGN: c_ulong = 0x40; ++pub const OCSP_NODELEGATED: c_ulong = 0x80; ++pub const OCSP_NOCHECKS: c_ulong = 0x100; ++pub const OCSP_TRUSTOTHER: c_ulong = 0x200; ++pub const OCSP_RESPID_KEY: c_ulong = 0x400; ++pub const OCSP_NOTIME: c_ulong = 0x800; ++ ++pub const V_OCSP_CERTSTATUS_GOOD: c_int = 0; ++pub const V_OCSP_CERTSTATUS_REVOKED: c_int = 1; ++pub const V_OCSP_CERTSTATUS_UNKNOWN: c_int = 2; ++ ++pub const OCSP_REVOKED_STATUS_NOSTATUS: c_int = -1; ++pub const OCSP_REVOKED_STATUS_UNSPECIFIED: c_int = 0; ++pub const OCSP_REVOKED_STATUS_KEYCOMPROMISE: c_int = 1; ++pub const OCSP_REVOKED_STATUS_CACOMPROMISE: c_int = 2; ++pub const OCSP_REVOKED_STATUS_AFFILIATIONCHANGED: c_int = 3; ++pub const OCSP_REVOKED_STATUS_SUPERSEDED: c_int = 4; ++pub const OCSP_REVOKED_STATUS_CESSATIONOFOPERATION: c_int = 5; ++pub const OCSP_REVOKED_STATUS_CERTIFICATEHOLD: c_int = 6; ++pub const OCSP_REVOKED_STATUS_REMOVEFROMCRL: c_int = 8; ++ ++pub const OCSP_RESPONSE_STATUS_SUCCESSFUL: c_int = 0; ++pub const OCSP_RESPONSE_STATUS_MALFORMEDREQUEST: c_int = 1; ++pub const OCSP_RESPONSE_STATUS_INTERNALERROR: c_int = 2; ++pub const OCSP_RESPONSE_STATUS_TRYLATER: c_int = 3; ++pub const OCSP_RESPONSE_STATUS_SIGREQUIRED: c_int = 5; ++pub const OCSP_RESPONSE_STATUS_UNAUTHORIZED: c_int = 6; ++ ++pub const OPENSSL_EC_NAMED_CURVE: c_int = 1; ++ ++pub const PKCS5_SALT_LEN: c_int = 8; ++pub const PKCS12_DEFAULT_ITER: c_int = 2048; ++ ++pub const RSA_F4: c_long = 0x10001; ++ ++pub const RSA_PKCS1_PADDING: c_int = 1; ++pub const RSA_SSLV23_PADDING: c_int = 2; ++pub const RSA_NO_PADDING: c_int = 3; ++pub const RSA_PKCS1_OAEP_PADDING: c_int = 4; ++pub const RSA_X931_PADDING: c_int = 5; ++ ++pub const SHA_LBLOCK: c_int = 16; ++ ++pub const SSL_CTRL_SET_TMP_DH: c_int = 3; ++pub const SSL_CTRL_SET_TMP_ECDH: c_int = 4; ++pub const SSL_CTRL_EXTRA_CHAIN_CERT: c_int = 14; ++pub const SSL_CTRL_MODE: c_int = 33; ++pub const SSL_CTRL_SET_READ_AHEAD: c_int = 41; ++pub const SSL_CTRL_SET_TLSEXT_SERVERNAME_CB: c_int = 53; ++pub const SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG: c_int = 54; ++pub const SSL_CTRL_SET_TLSEXT_HOSTNAME: c_int = 55; ++pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB: c_int = 63; ++pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG: c_int = 64; ++pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE: c_int = 65; ++pub const SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP: c_int = 70; ++pub const SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP: c_int = 71; ++pub const SSL_CTRL_GET_EXTRA_CHAIN_CERTS: c_int = 82; ++#[cfg(not(any(ossl101, libressl)))] ++pub const SSL_CTRL_SET_VERIFY_CERT_STORE: c_int = 106; ++ ++pub const SSL_MODE_ENABLE_PARTIAL_WRITE: c_long = 0x1; ++pub const SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER: c_long = 0x2; ++pub const SSL_MODE_AUTO_RETRY: c_long = 0x4; ++pub const SSL_MODE_NO_AUTO_CHAIN: c_long = 0x8; ++pub const SSL_MODE_RELEASE_BUFFERS: c_long = 0x10; ++#[cfg(not(libressl))] ++pub const SSL_MODE_SEND_CLIENTHELLO_TIME: c_long = 0x20; ++#[cfg(not(libressl))] ++pub const SSL_MODE_SEND_SERVERHELLO_TIME: c_long = 0x40; ++#[cfg(not(libressl))] ++pub const SSL_MODE_SEND_FALLBACK_SCSV: c_long = 0x80; ++ ++pub const SSL_ERROR_NONE: c_int = 0; ++pub const SSL_ERROR_SSL: c_int = 1; ++pub const SSL_ERROR_SYSCALL: c_int = 5; ++pub const SSL_ERROR_WANT_ACCEPT: c_int = 8; ++pub const SSL_ERROR_WANT_CONNECT: c_int = 7; ++pub const SSL_ERROR_WANT_READ: c_int = 2; ++pub const SSL_ERROR_WANT_WRITE: c_int = 3; ++pub const SSL_ERROR_WANT_X509_LOOKUP: c_int = 4; ++pub const SSL_ERROR_ZERO_RETURN: c_int = 6; ++pub const SSL_VERIFY_NONE: c_int = 0; ++pub const SSL_VERIFY_PEER: c_int = 1; ++pub const SSL_VERIFY_FAIL_IF_NO_PEER_CERT: c_int = 2; ++ ++#[cfg(not(any(libressl261, ossl101)))] ++pub const SSL_OP_TLSEXT_PADDING: c_ulong = 0x00000010; ++#[cfg(libressl261)] ++pub const SSL_OP_TLSEXT_PADDING: c_ulong = 0x0; ++pub const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: c_ulong = 0x00000800; ++#[cfg(not(libressl261))] ++pub const SSL_OP_CRYPTOPRO_TLSEXT_BUG: c_ulong = 0x80000000; ++#[cfg(libressl261)] ++pub const SSL_OP_CRYPTOPRO_TLSEXT_BUG: c_ulong = 0x0; ++pub const SSL_OP_LEGACY_SERVER_CONNECT: c_ulong = 0x00000004; ++#[cfg(not(libressl))] ++pub const SSL_OP_SAFARI_ECDHE_ECDSA_BUG: c_ulong = 0x00000040; ++#[cfg(not(any(libressl, ossl110f)))] ++pub const SSL_OP_ALL: c_ulong = 0x80000BFF; ++#[cfg(ossl110f)] ++pub const SSL_OP_ALL: c_ulong = SSL_OP_CRYPTOPRO_TLSEXT_BUG | SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS | ++ SSL_OP_LEGACY_SERVER_CONNECT | SSL_OP_TLSEXT_PADDING | ++ SSL_OP_SAFARI_ECDHE_ECDSA_BUG; ++pub const SSL_OP_NO_QUERY_MTU: c_ulong = 0x00001000; ++pub const SSL_OP_COOKIE_EXCHANGE: c_ulong = 0x00002000; ++pub const SSL_OP_NO_TICKET: c_ulong = 0x00004000; ++#[cfg(not(libressl))] ++pub const SSL_OP_CISCO_ANYCONNECT: c_ulong = 0x00008000; ++pub const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: c_ulong = 0x00010000; ++#[cfg(not(libressl))] ++pub const SSL_OP_NO_COMPRESSION: c_ulong = 0x00020000; ++#[cfg(not(libressl))] ++pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: c_ulong = 0x00040000; ++pub const SSL_OP_CIPHER_SERVER_PREFERENCE: c_ulong = 0x00400000; ++pub const SSL_OP_TLS_ROLLBACK_BUG: c_ulong = 0x00800000; ++#[cfg(not(libressl))] ++pub const SSL_OP_NO_SSLv3: c_ulong = 0x02000000; ++pub const SSL_OP_NO_TLSv1: c_ulong = 0x04000000; ++pub const SSL_OP_NO_TLSv1_2: c_ulong = 0x08000000; ++pub const SSL_OP_NO_TLSv1_1: c_ulong = 0x10000000; ++ ++#[cfg(not(any(ossl101, libressl)))] ++pub const SSL_OP_NO_DTLSv1: c_ulong = 0x04000000; ++#[cfg(not(any(ossl101, libressl)))] ++pub const SSL_OP_NO_DTLSv1_2: c_ulong = 0x08000000; ++#[cfg(not(any(ossl101, libressl)))] ++pub const SSL_OP_NO_SSL_MASK: c_ulong = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | ++ SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2; ++ ++pub const TLSEXT_NAMETYPE_host_name: c_int = 0; ++ ++pub const TLSEXT_STATUSTYPE_ocsp: c_int = 1; ++ ++pub const SSL_TLSEXT_ERR_OK: c_int = 0; ++pub const SSL_TLSEXT_ERR_ALERT_WARNING: c_int = 1; ++pub const SSL_TLSEXT_ERR_ALERT_FATAL: c_int = 2; ++pub const SSL_TLSEXT_ERR_NOACK: c_int = 3; ++ ++pub const OPENSSL_NPN_UNSUPPORTED: c_int = 0; ++pub const OPENSSL_NPN_NEGOTIATED: c_int = 1; ++pub const OPENSSL_NPN_NO_OVERLAP: c_int = 2; ++ ++pub const V_ASN1_GENERALIZEDTIME: c_int = 24; ++pub const V_ASN1_UTCTIME: c_int = 23; ++ ++pub const X509_FILETYPE_ASN1: c_int = 2; ++pub const X509_FILETYPE_DEFAULT: c_int = 3; ++pub const X509_FILETYPE_PEM: c_int = 1; ++pub const X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: c_int = 31; ++pub const X509_V_ERR_AKID_SKID_MISMATCH: c_int = 30; ++pub const X509_V_ERR_APPLICATION_VERIFICATION: c_int = 50; ++pub const X509_V_ERR_CERT_CHAIN_TOO_LONG: c_int = 22; ++pub const X509_V_ERR_CERT_HAS_EXPIRED: c_int = 10; ++pub const X509_V_ERR_CERT_NOT_YET_VALID: c_int = 9; ++pub const X509_V_ERR_CERT_REJECTED: c_int = 28; ++pub const X509_V_ERR_CERT_REVOKED: c_int = 23; ++pub const X509_V_ERR_CERT_SIGNATURE_FAILURE: c_int = 7; ++pub const X509_V_ERR_CERT_UNTRUSTED: c_int = 27; ++pub const X509_V_ERR_CRL_HAS_EXPIRED: c_int = 12; ++pub const X509_V_ERR_CRL_NOT_YET_VALID: c_int = 11; ++pub const X509_V_ERR_CRL_PATH_VALIDATION_ERROR: c_int = 54; ++pub const X509_V_ERR_CRL_SIGNATURE_FAILURE: c_int = 8; ++pub const X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: c_int = 18; ++pub const X509_V_ERR_DIFFERENT_CRL_SCOPE: c_int = 44; ++pub const X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: c_int = 14; ++pub const X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: c_int = 13; ++pub const X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: c_int = 15; ++pub const X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: c_int = 16; ++pub const X509_V_ERR_EXCLUDED_VIOLATION: c_int = 48; ++pub const X509_V_ERR_INVALID_CA: c_int = 24; ++pub const X509_V_ERR_INVALID_EXTENSION: c_int = 41; ++pub const X509_V_ERR_INVALID_NON_CA: c_int = 37; ++pub const X509_V_ERR_INVALID_POLICY_EXTENSION: c_int = 42; ++pub const X509_V_ERR_INVALID_PURPOSE: c_int = 26; ++pub const X509_V_ERR_KEYUSAGE_NO_CERTSIGN: c_int = 32; ++pub const X509_V_ERR_KEYUSAGE_NO_CRL_SIGN: c_int = 35; ++pub const X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE: c_int = 39; ++pub const X509_V_ERR_NO_EXPLICIT_POLICY: c_int = 43; ++pub const X509_V_ERR_OUT_OF_MEM: c_int = 17; ++pub const X509_V_ERR_PATH_LENGTH_EXCEEDED: c_int = 25; ++pub const X509_V_ERR_PERMITTED_VIOLATION: c_int = 47; ++pub const X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED: c_int = 40; ++pub const X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED: c_int = 38; ++pub const X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: c_int = 19; ++pub const X509_V_ERR_SUBJECT_ISSUER_MISMATCH: c_int = 29; ++pub const X509_V_ERR_SUBTREE_MINMAX: c_int = 49; ++pub const X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: c_int = 6; ++pub const X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: c_int = 4; ++pub const X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: c_int = 5; ++pub const X509_V_ERR_UNABLE_TO_GET_CRL: c_int = 3; ++pub const X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER: c_int = 33; ++pub const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: c_int = 2; ++pub const X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: c_int = 20; ++pub const X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: c_int = 21; ++pub const X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION: c_int = 36; ++pub const X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION: c_int = 34; ++pub const X509_V_ERR_UNNESTED_RESOURCE: c_int = 46; ++pub const X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: c_int = 52; ++pub const X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: c_int = 51; ++pub const X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: c_int = 45; ++pub const X509_V_ERR_UNSUPPORTED_NAME_SYNTAX: c_int = 53; ++pub const X509_V_OK: c_int = 0; ++ ++#[cfg(not(any(ossl101, libressl)))] ++pub const X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT: c_uint = 0x1; ++#[cfg(not(any(ossl101, libressl)))] ++pub const X509_CHECK_FLAG_NO_WILDCARDS: c_uint = 0x2; ++#[cfg(not(any(ossl101, libressl)))] ++pub const X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS: c_uint = 0x4; ++#[cfg(not(any(ossl101, libressl)))] ++pub const X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS: c_uint = 0x8; ++#[cfg(not(any(ossl101, libressl)))] ++pub const X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS: c_uint = 0x10; ++ ++pub const GEN_OTHERNAME: c_int = 0; ++pub const GEN_EMAIL: c_int = 1; ++pub const GEN_DNS: c_int = 2; ++pub const GEN_X400: c_int = 3; ++pub const GEN_DIRNAME: c_int = 4; ++pub const GEN_EDIPARTY: c_int = 5; ++pub const GEN_URI: c_int = 6; ++pub const GEN_IPADD: c_int = 7; ++pub const GEN_RID: c_int = 8; ++ ++// macros ++pub unsafe fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long { ++ BIO_ctrl(b, BIO_CTRL_INFO, 0, pp as *mut c_void) ++} ++ ++pub unsafe fn BIO_clear_retry_flags(b: *mut BIO) { ++ BIO_clear_flags(b, BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY) ++} ++ ++pub unsafe fn BIO_set_retry_read(b: *mut BIO) { ++ BIO_set_flags(b, BIO_FLAGS_READ | BIO_FLAGS_SHOULD_RETRY) ++} ++ ++pub unsafe fn BIO_set_retry_write(b: *mut BIO) { ++ BIO_set_flags(b, BIO_FLAGS_WRITE | BIO_FLAGS_SHOULD_RETRY) ++} ++ ++// EVP_PKEY_CTX_ctrl macros ++pub unsafe fn EVP_PKEY_CTX_set_rsa_padding(ctx: *mut EVP_PKEY_CTX, pad: c_int) -> c_int { ++ EVP_PKEY_CTX_ctrl( ++ ctx, ++ EVP_PKEY_RSA, ++ -1, ++ EVP_PKEY_CTRL_RSA_PADDING, ++ pad, ++ ptr::null_mut(), ++ ) ++} ++ ++pub unsafe fn EVP_PKEY_CTX_get_rsa_padding(ctx: *mut EVP_PKEY_CTX, ppad: *mut c_int) -> c_int { ++ EVP_PKEY_CTX_ctrl( ++ ctx, ++ EVP_PKEY_RSA, ++ -1, ++ EVP_PKEY_CTRL_GET_RSA_PADDING, ++ 0, ++ ppad as *mut c_void, ++ ) ++} ++ ++pub unsafe fn SSL_CTX_set_mode(ctx: *mut SSL_CTX, op: c_long) -> c_long { ++ SSL_CTX_ctrl(ctx, SSL_CTRL_MODE, op, ptr::null_mut()) ++} ++ ++pub unsafe fn SSL_CTX_set_read_ahead(ctx: *mut SSL_CTX, m: c_long) -> c_long { ++ SSL_CTX_ctrl(ctx, SSL_CTRL_SET_READ_AHEAD, m, ptr::null_mut()) ++} ++ ++pub unsafe fn SSL_CTX_set_tmp_dh(ctx: *mut SSL_CTX, dh: *mut DH) -> c_long { ++ SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_DH, 0, dh as *mut c_void) ++} ++ ++pub unsafe fn SSL_CTX_set_tmp_ecdh(ctx: *mut SSL_CTX, key: *mut EC_KEY) -> c_long { ++ SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TMP_ECDH, 0, key as *mut c_void) ++} ++ ++pub unsafe fn SSL_set_tmp_dh(ssl: *mut SSL, dh: *mut DH) -> c_long { ++ SSL_ctrl(ssl, SSL_CTRL_SET_TMP_DH, 0, dh as *mut c_void) ++} ++ ++pub unsafe fn SSL_set_tmp_ecdh(ssl: *mut SSL, key: *mut EC_KEY) -> c_long { ++ SSL_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH, 0, key as *mut c_void) ++} ++ ++pub unsafe fn SSL_CTX_add_extra_chain_cert(ctx: *mut SSL_CTX, x509: *mut X509) -> c_long { ++ SSL_CTX_ctrl(ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0, x509 as *mut c_void) ++} ++ ++#[cfg(not(any(ossl101, libressl)))] ++pub unsafe fn SSL_CTX_set0_verify_cert_store(ctx: *mut SSL_CTX, st: *mut X509_STORE) -> c_long { ++ SSL_CTX_ctrl(ctx, SSL_CTRL_SET_VERIFY_CERT_STORE, 0, st as *mut c_void) ++} ++ ++pub unsafe fn SSL_CTX_set_tlsext_servername_callback( ++ ctx: *mut SSL_CTX, ++ cb: Option, ++) -> c_long { ++ SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TLSEXT_SERVERNAME_CB, cb) ++} ++ ++pub unsafe fn SSL_set_tlsext_host_name(s: *mut SSL, name: *mut c_char) -> c_long { ++ SSL_ctrl( ++ s, ++ SSL_CTRL_SET_TLSEXT_HOSTNAME, ++ TLSEXT_NAMETYPE_host_name as c_long, ++ name as *mut c_void, ++ ) ++} ++ ++pub unsafe fn SSL_set_tlsext_status_type(s: *mut SSL, type_: c_int) -> c_long { ++ SSL_ctrl( ++ s, ++ SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE, ++ type_ as c_long, ++ ptr::null_mut(), ++ ) ++} ++ ++pub unsafe fn SSL_CTX_set_tlsext_status_cb( ++ ctx: *mut SSL_CTX, ++ cb: Option c_int>, ++) -> c_long { ++ SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB, mem::transmute(cb)) ++} ++ ++pub unsafe fn SSL_CTX_set_tlsext_status_arg(ctx: *mut SSL_CTX, arg: *mut c_void) -> c_long { ++ SSL_CTX_ctrl(ctx, SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG, 0, arg) ++} ++ ++pub unsafe fn SSL_CTX_get_extra_chain_certs( ++ ctx: *mut SSL_CTX, ++ chain: *mut *mut stack_st_X509, ++) -> c_long { ++ SSL_CTX_ctrl(ctx, SSL_CTRL_GET_EXTRA_CHAIN_CERTS, 0, chain as *mut c_void) ++} ++ ++pub unsafe fn SSL_get_tlsext_status_ocsp_resp(ssl: *mut SSL, resp: *mut *mut c_uchar) -> c_long { ++ SSL_ctrl( ++ ssl, ++ SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP, ++ 0, ++ resp as *mut c_void, ++ ) ++} ++ ++pub unsafe fn SSL_set_tlsext_status_ocsp_resp( ++ ssl: *mut SSL, ++ resp: *mut c_uchar, ++ len: c_long, ++) -> c_long { ++ SSL_ctrl( ++ ssl, ++ SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP, ++ len, ++ resp as *mut c_void, ++ ) ++} ++ ++pub fn ERR_GET_LIB(l: c_ulong) -> c_int { ++ ((l >> 24) & 0x0FF) as c_int ++} ++ ++pub fn ERR_GET_FUNC(l: c_ulong) -> c_int { ++ ((l >> 12) & 0xFFF) as c_int ++} ++ ++pub fn ERR_GET_REASON(l: c_ulong) -> c_int { ++ (l & 0xFFF) as c_int ++} ++ ++extern "C" { ++ pub fn AES_set_encrypt_key(userKey: *const c_uchar, bits: c_int, key: *mut AES_KEY) -> c_int; ++ pub fn AES_set_decrypt_key(userKey: *const c_uchar, bits: c_int, key: *mut AES_KEY) -> c_int; ++ pub fn AES_ige_encrypt( ++ in_: *const c_uchar, ++ out: *mut c_uchar, ++ length: size_t, ++ key: *const AES_KEY, ++ ivec: *mut c_uchar, ++ enc: c_int, ++ ); ++ ++ pub fn ASN1_INTEGER_get(dest: *const ASN1_INTEGER) -> c_long; ++ pub fn ASN1_INTEGER_set(dest: *mut ASN1_INTEGER, value: c_long) -> c_int; ++ pub fn ASN1_GENERALIZEDTIME_free(tm: *mut ASN1_GENERALIZEDTIME); ++ pub fn ASN1_GENERALIZEDTIME_print(b: *mut BIO, tm: *const ASN1_GENERALIZEDTIME) -> c_int; ++ pub fn ASN1_STRING_type_new(ty: c_int) -> *mut ASN1_STRING; ++ pub fn ASN1_TIME_free(tm: *mut ASN1_TIME); ++ pub fn ASN1_TIME_print(b: *mut BIO, tm: *const ASN1_TIME) -> c_int; ++ pub fn ASN1_BIT_STRING_free(x: *mut ASN1_BIT_STRING); ++ pub fn ASN1_OBJECT_free(x: *mut ASN1_OBJECT); ++ ++ pub fn BIO_ctrl(b: *mut BIO, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long; ++ pub fn BIO_free_all(b: *mut BIO); ++ pub fn BIO_new_fp(stream: *mut FILE, close_flag: c_int) -> *mut BIO; ++ pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO; ++ pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int; ++ pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int; ++ #[cfg(any(ossl101, libressl))] ++ pub fn BIO_new_mem_buf(buf: *mut c_void, len: c_int) -> *mut BIO; ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn BIO_new_mem_buf(buf: *const c_void, len: c_int) -> *mut BIO; ++ pub fn BIO_set_flags(b: *mut BIO, flags: c_int); ++ pub fn BIO_clear_flags(b: *mut BIO, flags: c_int); ++ ++ pub fn BN_CTX_new() -> *mut BN_CTX; ++ pub fn BN_CTX_free(ctx: *mut BN_CTX); ++ ++ pub fn BN_new() -> *mut BIGNUM; ++ pub fn BN_dup(n: *const BIGNUM) -> *mut BIGNUM; ++ pub fn BN_clear(bn: *mut BIGNUM); ++ pub fn BN_free(bn: *mut BIGNUM); ++ pub fn BN_clear_free(bn: *mut BIGNUM); ++ pub fn BN_num_bits(bn: *const BIGNUM) -> c_int; ++ pub fn BN_set_negative(bn: *mut BIGNUM, n: c_int); ++ pub fn BN_set_word(bn: *mut BIGNUM, n: BN_ULONG) -> c_int; ++ pub fn BN_add(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int; ++ pub fn BN_div( ++ dv: *mut BIGNUM, ++ rem: *mut BIGNUM, ++ a: *const BIGNUM, ++ b: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn BN_exp(r: *mut BIGNUM, a: *const BIGNUM, p: *const BIGNUM, ctx: *mut BN_CTX) -> c_int; ++ pub fn BN_gcd(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int; ++ pub fn BN_mod_add( ++ r: *mut BIGNUM, ++ a: *const BIGNUM, ++ b: *const BIGNUM, ++ m: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn BN_mod_exp( ++ r: *mut BIGNUM, ++ a: *const BIGNUM, ++ p: *const BIGNUM, ++ m: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn BN_mod_inverse( ++ r: *mut BIGNUM, ++ a: *const BIGNUM, ++ n: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> *mut BIGNUM; ++ pub fn BN_mod_mul( ++ r: *mut BIGNUM, ++ a: *const BIGNUM, ++ b: *const BIGNUM, ++ m: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn BN_mod_sqr( ++ r: *mut BIGNUM, ++ a: *const BIGNUM, ++ m: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn BN_mod_sub( ++ r: *mut BIGNUM, ++ a: *const BIGNUM, ++ b: *const BIGNUM, ++ m: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn BN_mul(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int; ++ pub fn BN_nnmod( ++ rem: *mut BIGNUM, ++ a: *const BIGNUM, ++ m: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn BN_add_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int; ++ pub fn BN_sub_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int; ++ pub fn BN_mul_word(r: *mut BIGNUM, w: BN_ULONG) -> c_int; ++ pub fn BN_div_word(r: *mut BIGNUM, w: BN_ULONG) -> BN_ULONG; ++ pub fn BN_mod_word(r: *const BIGNUM, w: BN_ULONG) -> BN_ULONG; ++ pub fn BN_sqr(r: *mut BIGNUM, a: *const BIGNUM, ctx: *mut BN_CTX) -> c_int; ++ pub fn BN_sub(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int; ++ pub fn BN_clear_bit(a: *mut BIGNUM, n: c_int) -> c_int; ++ pub fn BN_is_bit_set(a: *const BIGNUM, n: c_int) -> c_int; ++ pub fn BN_lshift(r: *mut BIGNUM, a: *const BIGNUM, n: c_int) -> c_int; ++ pub fn BN_lshift1(r: *mut BIGNUM, a: *const BIGNUM) -> c_int; ++ pub fn BN_mask_bits(a: *mut BIGNUM, n: c_int) -> c_int; ++ pub fn BN_rshift(r: *mut BIGNUM, a: *const BIGNUM, n: c_int) -> c_int; ++ pub fn BN_set_bit(a: *mut BIGNUM, n: c_int) -> c_int; ++ pub fn BN_rshift1(r: *mut BIGNUM, a: *const BIGNUM) -> c_int; ++ pub fn BN_cmp(a: *const BIGNUM, b: *const BIGNUM) -> c_int; ++ pub fn BN_ucmp(a: *const BIGNUM, b: *const BIGNUM) -> c_int; ++ pub fn BN_generate_prime_ex( ++ r: *mut BIGNUM, ++ bits: c_int, ++ safe: c_int, ++ add: *const BIGNUM, ++ rem: *const BIGNUM, ++ cb: *mut BN_GENCB, ++ ) -> c_int; ++ pub fn BN_is_prime_ex( ++ p: *const BIGNUM, ++ checks: c_int, ++ ctx: *mut BN_CTX, ++ cb: *mut BN_GENCB, ++ ) -> c_int; ++ pub fn BN_is_prime_fasttest_ex( ++ p: *const BIGNUM, ++ checks: c_int, ++ ctx: *mut BN_CTX, ++ do_trial_division: c_int, ++ cb: *mut BN_GENCB, ++ ) -> c_int; ++ pub fn BN_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int; ++ pub fn BN_pseudo_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int; ++ pub fn BN_rand_range(r: *mut BIGNUM, range: *const BIGNUM) -> c_int; ++ pub fn BN_pseudo_rand_range(r: *mut BIGNUM, range: *const BIGNUM) -> c_int; ++ pub fn BN_bin2bn(s: *const u8, size: c_int, ret: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn BN_bn2bin(a: *const BIGNUM, to: *mut u8) -> c_int; ++ pub fn BN_dec2bn(a: *mut *mut BIGNUM, s: *const c_char) -> c_int; ++ pub fn BN_bn2dec(a: *const BIGNUM) -> *mut c_char; ++ pub fn BN_hex2bn(a: *mut *mut BIGNUM, s: *const c_char) -> c_int; ++ pub fn BN_bn2hex(a: *const BIGNUM) -> *mut c_char; ++ pub fn BN_to_ASN1_INTEGER(bn: *const BIGNUM, ai: *mut ASN1_INTEGER) -> *mut ASN1_INTEGER; ++ ++ pub fn NCONF_default() -> *mut CONF_METHOD; ++ pub fn NCONF_new(meth: *mut CONF_METHOD) -> *mut CONF; ++ pub fn NCONF_free(conf: *mut CONF); ++ ++ pub fn CRYPTO_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; ++ ++ pub fn DH_new() -> *mut DH; ++ pub fn DH_free(dh: *mut DH); ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn DH_get_1024_160() -> *mut DH; ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn DH_get_2048_224() -> *mut DH; ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn DH_get_2048_256() -> *mut DH; ++ ++ pub fn EC_KEY_new() -> *mut EC_KEY; ++ pub fn EC_KEY_new_by_curve_name(nid: c_int) -> *mut EC_KEY; ++ pub fn EC_KEY_dup(key: *const EC_KEY) -> *mut EC_KEY; ++ pub fn EC_KEY_set_group(key: *mut EC_KEY, group: *const EC_GROUP) -> c_int; ++ pub fn EC_KEY_get0_group(key: *const EC_KEY) -> *const EC_GROUP; ++ pub fn EC_KEY_set_public_key(key: *mut EC_KEY, key: *const EC_POINT) -> c_int; ++ pub fn EC_KEY_get0_public_key(key: *const EC_KEY) -> *const EC_POINT; ++ pub fn EC_KEY_set_private_key(key: *mut EC_KEY, key: *const BIGNUM) -> c_int; ++ pub fn EC_KEY_get0_private_key(key: *const EC_KEY) -> *const BIGNUM; ++ pub fn EC_KEY_generate_key(key: *mut EC_KEY) -> c_int; ++ pub fn EC_KEY_check_key(key: *const EC_KEY) -> c_int; ++ pub fn EC_KEY_free(key: *mut EC_KEY); ++ pub fn EC_KEY_set_public_key_affine_coordinates( ++ key: *mut EC_KEY, ++ x: *mut BIGNUM, ++ y: *mut BIGNUM, ++ ) -> c_int; ++ ++ #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] ++ pub fn EC_GF2m_simple_method() -> *const EC_METHOD; ++ ++ pub fn EC_GROUP_new(meth: *const EC_METHOD) -> *mut EC_GROUP; ++ pub fn EC_GROUP_new_curve_GFp( ++ p: *const BIGNUM, ++ a: *const BIGNUM, ++ b: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> *mut EC_GROUP; ++ #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] ++ pub fn EC_GROUP_new_curve_GF2m( ++ p: *const BIGNUM, ++ a: *const BIGNUM, ++ b: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> *mut EC_GROUP; ++ pub fn EC_GROUP_new_by_curve_name(nid: c_int) -> *mut EC_GROUP; ++ pub fn EC_GROUP_get_curve_GFp( ++ group: *const EC_GROUP, ++ p: *mut BIGNUM, ++ a: *mut BIGNUM, ++ b: *mut BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] ++ pub fn EC_GROUP_get_curve_GF2m( ++ group: *const EC_GROUP, ++ p: *mut BIGNUM, ++ a: *mut BIGNUM, ++ b: *mut BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn EC_GROUP_get_degree(group: *const EC_GROUP) -> c_int; ++ pub fn EC_GROUP_get_order( ++ group: *const EC_GROUP, ++ order: *mut BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn EC_GROUP_set_asn1_flag(key: *mut EC_GROUP, flag: c_int); ++ ++ pub fn EC_GROUP_free(group: *mut EC_GROUP); ++ ++ pub fn EC_POINT_new(group: *const EC_GROUP) -> *mut EC_POINT; ++ pub fn EC_POINT_add( ++ group: *const EC_GROUP, ++ r: *mut EC_POINT, ++ a: *const EC_POINT, ++ b: *const EC_POINT, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn EC_POINT_mul( ++ group: *const EC_GROUP, ++ r: *mut EC_POINT, ++ n: *const BIGNUM, ++ q: *const EC_POINT, ++ m: *const BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn EC_POINT_invert(group: *const EC_GROUP, r: *mut EC_POINT, ctx: *mut BN_CTX) -> c_int; ++ pub fn EC_POINT_point2oct( ++ group: *const EC_GROUP, ++ p: *const EC_POINT, ++ form: point_conversion_form_t, ++ buf: *mut c_uchar, ++ len: size_t, ++ ctx: *mut BN_CTX, ++ ) -> size_t; ++ pub fn EC_POINT_oct2point( ++ group: *const EC_GROUP, ++ p: *mut EC_POINT, ++ buf: *const c_uchar, ++ len: size_t, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn EC_POINT_cmp( ++ group: *const EC_GROUP, ++ a: *const EC_POINT, ++ b: *const EC_POINT, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ pub fn EC_POINT_free(point: *mut EC_POINT); ++ pub fn EC_POINT_get_affine_coordinates_GFp( ++ group: *const EC_GROUP, ++ p: *const EC_POINT, ++ x: *mut BIGNUM, ++ y: *mut BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] ++ pub fn EC_POINT_get_affine_coordinates_GF2m( ++ group: *const EC_GROUP, ++ p: *const EC_POINT, ++ x: *mut BIGNUM, ++ y: *mut BIGNUM, ++ ctx: *mut BN_CTX, ++ ) -> c_int; ++ ++ pub fn ERR_peek_last_error() -> c_ulong; ++ pub fn ERR_get_error() -> c_ulong; ++ pub fn ERR_get_error_line_data( ++ file: *mut *const c_char, ++ line: *mut c_int, ++ data: *mut *const c_char, ++ flags: *mut c_int, ++ ) -> c_ulong; ++ pub fn ERR_lib_error_string(err: c_ulong) -> *const c_char; ++ pub fn ERR_func_error_string(err: c_ulong) -> *const c_char; ++ pub fn ERR_reason_error_string(err: c_ulong) -> *const c_char; ++ pub fn ERR_clear_error(); ++ ++ pub fn EVP_md5() -> *const EVP_MD; ++ pub fn EVP_ripemd160() -> *const EVP_MD; ++ pub fn EVP_sha1() -> *const EVP_MD; ++ pub fn EVP_sha224() -> *const EVP_MD; ++ pub fn EVP_sha256() -> *const EVP_MD; ++ pub fn EVP_sha384() -> *const EVP_MD; ++ pub fn EVP_sha512() -> *const EVP_MD; ++ ++ pub fn EVP_aes_128_cbc() -> *const EVP_CIPHER; ++ pub fn EVP_aes_128_ecb() -> *const EVP_CIPHER; ++ pub fn EVP_aes_128_xts() -> *const EVP_CIPHER; ++ pub fn EVP_aes_128_ctr() -> *const EVP_CIPHER; ++ pub fn EVP_aes_128_gcm() -> *const EVP_CIPHER; ++ pub fn EVP_aes_128_cfb1() -> *const EVP_CIPHER; ++ pub fn EVP_aes_128_cfb128() -> *const EVP_CIPHER; ++ pub fn EVP_aes_128_cfb8() -> *const EVP_CIPHER; ++ pub fn EVP_aes_256_cbc() -> *const EVP_CIPHER; ++ pub fn EVP_aes_256_ecb() -> *const EVP_CIPHER; ++ pub fn EVP_aes_256_xts() -> *const EVP_CIPHER; ++ pub fn EVP_aes_256_ctr() -> *const EVP_CIPHER; ++ pub fn EVP_aes_256_gcm() -> *const EVP_CIPHER; ++ pub fn EVP_aes_256_cfb1() -> *const EVP_CIPHER; ++ pub fn EVP_aes_256_cfb128() -> *const EVP_CIPHER; ++ pub fn EVP_aes_256_cfb8() -> *const EVP_CIPHER; ++ pub fn EVP_bf_cbc() -> *const EVP_CIPHER; ++ pub fn EVP_bf_ecb() -> *const EVP_CIPHER; ++ pub fn EVP_bf_cfb64() -> *const EVP_CIPHER; ++ pub fn EVP_bf_ofb() -> *const EVP_CIPHER; ++ pub fn EVP_rc4() -> *const EVP_CIPHER; ++ ++ pub fn EVP_des_cbc() -> *const EVP_CIPHER; ++ pub fn EVP_des_ecb() -> *const EVP_CIPHER; ++ ++ pub fn EVP_BytesToKey( ++ typ: *const EVP_CIPHER, ++ md: *const EVP_MD, ++ salt: *const u8, ++ data: *const u8, ++ datalen: c_int, ++ count: c_int, ++ key: *mut u8, ++ iv: *mut u8, ++ ) -> c_int; ++ ++ pub fn EVP_CIPHER_CTX_new() -> *mut EVP_CIPHER_CTX; ++ pub fn EVP_CIPHER_CTX_set_padding(ctx: *mut EVP_CIPHER_CTX, padding: c_int) -> c_int; ++ pub fn EVP_CIPHER_CTX_set_key_length(ctx: *mut EVP_CIPHER_CTX, keylen: c_int) -> c_int; ++ pub fn EVP_CIPHER_CTX_ctrl( ++ ctx: *mut EVP_CIPHER_CTX, ++ type_: c_int, ++ arg: c_int, ++ ptr: *mut c_void, ++ ) -> c_int; ++ pub fn EVP_CIPHER_CTX_free(ctx: *mut EVP_CIPHER_CTX); ++ ++ pub fn EVP_CipherInit( ++ ctx: *mut EVP_CIPHER_CTX, ++ evp: *const EVP_CIPHER, ++ key: *const u8, ++ iv: *const u8, ++ mode: c_int, ++ ) -> c_int; ++ pub fn EVP_CipherInit_ex( ++ ctx: *mut EVP_CIPHER_CTX, ++ type_: *const EVP_CIPHER, ++ impl_: *mut ENGINE, ++ key: *const c_uchar, ++ iv: *const c_uchar, ++ enc: c_int, ++ ) -> c_int; ++ pub fn EVP_CipherUpdate( ++ ctx: *mut EVP_CIPHER_CTX, ++ outbuf: *mut u8, ++ outlen: *mut c_int, ++ inbuf: *const u8, ++ inlen: c_int, ++ ) -> c_int; ++ pub fn EVP_CipherFinal(ctx: *mut EVP_CIPHER_CTX, res: *mut u8, len: *mut c_int) -> c_int; ++ ++ pub fn EVP_DigestInit(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD) -> c_int; ++ pub fn EVP_DigestInit_ex(ctx: *mut EVP_MD_CTX, typ: *const EVP_MD, imple: *mut ENGINE) ++ -> c_int; ++ pub fn EVP_DigestUpdate(ctx: *mut EVP_MD_CTX, data: *const c_void, n: size_t) -> c_int; ++ pub fn EVP_DigestFinal(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int; ++ pub fn EVP_DigestFinal_ex(ctx: *mut EVP_MD_CTX, res: *mut u8, n: *mut u32) -> c_int; ++ ++ pub fn EVP_DigestSignInit( ++ ctx: *mut EVP_MD_CTX, ++ pctx: *mut *mut EVP_PKEY_CTX, ++ type_: *const EVP_MD, ++ e: *mut ENGINE, ++ pkey: *mut EVP_PKEY, ++ ) -> c_int; ++ pub fn EVP_DigestSignFinal( ++ ctx: *mut EVP_MD_CTX, ++ sig: *mut c_uchar, ++ siglen: *mut size_t, ++ ) -> c_int; ++ pub fn EVP_DigestVerifyInit( ++ ctx: *mut EVP_MD_CTX, ++ pctx: *mut *mut EVP_PKEY_CTX, ++ type_: *const EVP_MD, ++ e: *mut ENGINE, ++ pkey: *mut EVP_PKEY, ++ ) -> c_int; ++ #[cfg(any(ossl101, libressl))] ++ pub fn EVP_DigestVerifyFinal( ++ ctx: *mut EVP_MD_CTX, ++ sigret: *mut c_uchar, ++ siglen: size_t, ++ ) -> c_int; ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn EVP_DigestVerifyFinal( ++ ctx: *mut EVP_MD_CTX, ++ sigret: *const c_uchar, ++ siglen: size_t, ++ ) -> c_int; ++ ++ pub fn EVP_MD_CTX_copy_ex(dst: *mut EVP_MD_CTX, src: *const EVP_MD_CTX) -> c_int; ++ ++ pub fn EVP_PKEY_new() -> *mut EVP_PKEY; ++ pub fn EVP_PKEY_free(k: *mut EVP_PKEY); ++ pub fn EVP_PKEY_assign(pkey: *mut EVP_PKEY, typ: c_int, key: *mut c_void) -> c_int; ++ pub fn EVP_PKEY_copy_parameters(to: *mut EVP_PKEY, from: *const EVP_PKEY) -> c_int; ++ pub fn EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA; ++ pub fn EVP_PKEY_set1_RSA(k: *mut EVP_PKEY, r: *mut RSA) -> c_int; ++ pub fn EVP_PKEY_get1_DSA(k: *mut EVP_PKEY) -> *mut DSA; ++ pub fn EVP_PKEY_get1_DH(k: *mut EVP_PKEY) -> *mut DH; ++ pub fn EVP_PKEY_get1_EC_KEY(k: *mut EVP_PKEY) -> *mut EC_KEY; ++ pub fn EVP_PKEY_cmp(a: *const EVP_PKEY, b: *const EVP_PKEY) -> c_int; ++ pub fn EVP_PKEY_new_mac_key( ++ type_: c_int, ++ e: *mut ENGINE, ++ key: *const c_uchar, ++ keylen: c_int, ++ ) -> *mut EVP_PKEY; ++ pub fn EVP_PKEY_derive_init(ctx: *mut EVP_PKEY_CTX) -> c_int; ++ pub fn EVP_PKEY_derive_set_peer(ctx: *mut EVP_PKEY_CTX, peer: *mut EVP_PKEY) -> c_int; ++ pub fn EVP_PKEY_derive(ctx: *mut EVP_PKEY_CTX, key: *mut c_uchar, size: *mut size_t) -> c_int; ++ pub fn d2i_PKCS8PrivateKey_bio( ++ bp: *mut BIO, ++ x: *mut *mut EVP_PKEY, ++ cb: Option, ++ u: *mut c_void, ++ ) -> *mut EVP_PKEY; ++ ++ pub fn EVP_PKEY_CTX_new(k: *mut EVP_PKEY, e: *mut ENGINE) -> *mut EVP_PKEY_CTX; ++ pub fn EVP_PKEY_CTX_free(ctx: *mut EVP_PKEY_CTX); ++ pub fn EVP_PKEY_CTX_ctrl( ++ ctx: *mut EVP_PKEY_CTX, ++ keytype: c_int, ++ optype: c_int, ++ cmd: c_int, ++ p1: c_int, ++ p2: *mut c_void, ++ ) -> c_int; ++ ++ pub fn HMAC_CTX_copy(dst: *mut HMAC_CTX, src: *mut HMAC_CTX) -> c_int; ++ ++ pub fn OBJ_obj2nid(o: *const ASN1_OBJECT) -> c_int; ++ pub fn OBJ_obj2txt( ++ buf: *mut c_char, ++ buf_len: c_int, ++ a: *const ASN1_OBJECT, ++ no_name: c_int, ++ ) -> c_int; ++ ++ pub fn OCSP_BASICRESP_new() -> *mut OCSP_BASICRESP; ++ pub fn OCSP_BASICRESP_free(r: *mut OCSP_BASICRESP); ++ pub fn OCSP_basic_verify( ++ bs: *mut OCSP_BASICRESP, ++ certs: *mut stack_st_X509, ++ st: *mut X509_STORE, ++ flags: c_ulong, ++ ) -> c_int; ++ pub fn OCSP_resp_find_status( ++ bs: *mut OCSP_BASICRESP, ++ id: *mut OCSP_CERTID, ++ status: *mut c_int, ++ reason: *mut c_int, ++ revtime: *mut *mut ASN1_GENERALIZEDTIME, ++ thisupd: *mut *mut ASN1_GENERALIZEDTIME, ++ nextupd: *mut *mut ASN1_GENERALIZEDTIME, ++ ) -> c_int; ++ pub fn OCSP_check_validity( ++ thisupd: *mut ASN1_GENERALIZEDTIME, ++ nextupd: *mut ASN1_GENERALIZEDTIME, ++ sec: c_long, ++ maxsec: c_long, ++ ) -> c_int; ++ ++ pub fn OCSP_CERTID_free(id: *mut OCSP_CERTID); ++ ++ pub fn OCSP_RESPONSE_new() -> *mut OCSP_RESPONSE; ++ pub fn OCSP_RESPONSE_free(r: *mut OCSP_RESPONSE); ++ pub fn i2d_OCSP_RESPONSE(a: *mut OCSP_RESPONSE, pp: *mut *mut c_uchar) -> c_int; ++ pub fn d2i_OCSP_RESPONSE( ++ a: *mut *mut OCSP_RESPONSE, ++ pp: *mut *const c_uchar, ++ length: c_long, ++ ) -> *mut OCSP_RESPONSE; ++ pub fn OCSP_response_create(status: c_int, bs: *mut OCSP_BASICRESP) -> *mut OCSP_RESPONSE; ++ pub fn OCSP_response_status(resp: *mut OCSP_RESPONSE) -> c_int; ++ pub fn OCSP_response_get1_basic(resp: *mut OCSP_RESPONSE) -> *mut OCSP_BASICRESP; ++ ++ pub fn OCSP_REQUEST_new() -> *mut OCSP_REQUEST; ++ pub fn OCSP_REQUEST_free(r: *mut OCSP_REQUEST); ++ pub fn i2d_OCSP_REQUEST(a: *mut OCSP_REQUEST, pp: *mut *mut c_uchar) -> c_int; ++ pub fn d2i_OCSP_REQUEST( ++ a: *mut *mut OCSP_REQUEST, ++ pp: *mut *const c_uchar, ++ length: c_long, ++ ) -> *mut OCSP_REQUEST; ++ pub fn OCSP_request_add0_id(r: *mut OCSP_REQUEST, id: *mut OCSP_CERTID) -> *mut OCSP_ONEREQ; ++ ++ pub fn OCSP_ONEREQ_free(r: *mut OCSP_ONEREQ); ++ ++ pub fn PEM_read_bio_DHparams( ++ bio: *mut BIO, ++ out: *mut *mut DH, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> *mut DH; ++ pub fn PEM_read_bio_X509( ++ bio: *mut BIO, ++ out: *mut *mut X509, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> *mut X509; ++ pub fn PEM_read_bio_X509_REQ( ++ bio: *mut BIO, ++ out: *mut *mut X509_REQ, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> *mut X509_REQ; ++ pub fn PEM_read_bio_PrivateKey( ++ bio: *mut BIO, ++ out: *mut *mut EVP_PKEY, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> *mut EVP_PKEY; ++ pub fn PEM_read_bio_PUBKEY( ++ bio: *mut BIO, ++ out: *mut *mut EVP_PKEY, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> *mut EVP_PKEY; ++ ++ pub fn PEM_read_bio_RSAPrivateKey( ++ bio: *mut BIO, ++ rsa: *mut *mut RSA, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> *mut RSA; ++ pub fn PEM_read_bio_RSA_PUBKEY( ++ bio: *mut BIO, ++ rsa: *mut *mut RSA, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> *mut RSA; ++ ++ pub fn PEM_write_bio_DHparams(bio: *mut BIO, x: *const DH) -> c_int; ++ pub fn PEM_write_bio_PrivateKey( ++ bio: *mut BIO, ++ pkey: *mut EVP_PKEY, ++ cipher: *const EVP_CIPHER, ++ kstr: *mut c_uchar, ++ klen: c_int, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> c_int; ++ pub fn PEM_write_bio_PKCS8PrivateKey( ++ bio: *mut BIO, ++ pkey: *mut EVP_PKEY, ++ cipher: *const EVP_CIPHER, ++ kstr: *mut c_char, ++ klen: c_int, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> c_int; ++ pub fn PEM_write_bio_PUBKEY(bp: *mut BIO, x: *mut EVP_PKEY) -> c_int; ++ pub fn PEM_write_bio_RSAPrivateKey( ++ bp: *mut BIO, ++ rsa: *mut RSA, ++ cipher: *const EVP_CIPHER, ++ kstr: *mut c_uchar, ++ klen: c_int, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> c_int; ++ pub fn PEM_write_bio_RSAPublicKey(bp: *mut BIO, rsa: *const RSA) -> c_int; ++ pub fn PEM_write_bio_RSA_PUBKEY(bp: *mut BIO, rsa: *mut RSA) -> c_int; ++ ++ pub fn PEM_read_bio_DSAPrivateKey( ++ bp: *mut BIO, ++ dsa: *mut *mut DSA, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> *mut DSA; ++ pub fn PEM_read_bio_DSA_PUBKEY( ++ bp: *mut BIO, ++ dsa: *mut *mut DSA, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> *mut DSA; ++ pub fn PEM_write_bio_DSAPrivateKey( ++ bp: *mut BIO, ++ dsa: *mut DSA, ++ cipher: *const EVP_CIPHER, ++ kstr: *mut c_uchar, ++ klen: c_int, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> c_int; ++ pub fn PEM_write_bio_DSA_PUBKEY(bp: *mut BIO, dsa: *mut DSA) -> c_int; ++ ++ pub fn PEM_write_bio_X509(bio: *mut BIO, x509: *mut X509) -> c_int; ++ pub fn PEM_write_bio_X509_REQ(bio: *mut BIO, x509: *mut X509_REQ) -> c_int; ++ ++ pub fn PEM_write_bio_ECPrivateKey( ++ bio: *mut BIO, ++ key: *mut EC_KEY, ++ cipher: *const EVP_CIPHER, ++ kstr: *mut c_uchar, ++ klen: c_int, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> c_int; ++ pub fn PEM_read_bio_ECPrivateKey( ++ bio: *mut BIO, ++ key: *mut *mut EC_KEY, ++ callback: Option, ++ user_data: *mut c_void, ++ ) -> *mut EC_KEY; ++ ++ pub fn PKCS5_PBKDF2_HMAC_SHA1( ++ pass: *const c_char, ++ passlen: c_int, ++ salt: *const u8, ++ saltlen: c_int, ++ iter: c_int, ++ keylen: c_int, ++ out: *mut u8, ++ ) -> c_int; ++ pub fn PKCS5_PBKDF2_HMAC( ++ pass: *const c_char, ++ passlen: c_int, ++ salt: *const c_uchar, ++ saltlen: c_int, ++ iter: c_int, ++ digest: *const EVP_MD, ++ keylen: c_int, ++ out: *mut u8, ++ ) -> c_int; ++ ++ pub fn RAND_bytes(buf: *mut u8, num: c_int) -> c_int; ++ pub fn RAND_status() -> c_int; ++ ++ pub fn RSA_new() -> *mut RSA; ++ pub fn RSA_free(rsa: *mut RSA); ++ pub fn RSA_generate_key_ex( ++ rsa: *mut RSA, ++ bits: c_int, ++ e: *mut BIGNUM, ++ cb: *mut BN_GENCB, ++ ) -> c_int; ++ pub fn RSA_private_decrypt( ++ flen: c_int, ++ from: *const u8, ++ to: *mut u8, ++ k: *mut RSA, ++ pad: c_int, ++ ) -> c_int; ++ pub fn RSA_public_decrypt( ++ flen: c_int, ++ from: *const u8, ++ to: *mut u8, ++ k: *mut RSA, ++ pad: c_int, ++ ) -> c_int; ++ pub fn RSA_private_encrypt( ++ flen: c_int, ++ from: *const u8, ++ to: *mut u8, ++ k: *mut RSA, ++ pad: c_int, ++ ) -> c_int; ++ pub fn RSA_public_encrypt( ++ flen: c_int, ++ from: *const u8, ++ to: *mut u8, ++ k: *mut RSA, ++ pad: c_int, ++ ) -> c_int; ++ pub fn RSA_sign( ++ t: c_int, ++ m: *const u8, ++ mlen: c_uint, ++ sig: *mut u8, ++ siglen: *mut c_uint, ++ k: *mut RSA, ++ ) -> c_int; ++ pub fn RSA_size(k: *const RSA) -> c_int; ++ pub fn RSA_verify( ++ t: c_int, ++ m: *const u8, ++ mlen: c_uint, ++ sig: *const u8, ++ siglen: c_uint, ++ k: *mut RSA, ++ ) -> c_int; ++ ++ pub fn DSA_new() -> *mut DSA; ++ pub fn DSA_free(dsa: *mut DSA); ++ pub fn DSA_size(dsa: *const DSA) -> c_int; ++ pub fn DSA_generate_parameters_ex( ++ dsa: *mut DSA, ++ bits: c_int, ++ seed: *const c_uchar, ++ seed_len: c_int, ++ counter_ref: *mut c_int, ++ h_ret: *mut c_ulong, ++ cb: *mut BN_GENCB, ++ ) -> c_int; ++ pub fn DSA_generate_key(dsa: *mut DSA) -> c_int; ++ pub fn DSA_sign( ++ dummy: c_int, ++ dgst: *const c_uchar, ++ len: c_int, ++ sigret: *mut c_uchar, ++ siglen: *mut c_uint, ++ dsa: *mut DSA, ++ ) -> c_int; ++ pub fn DSA_verify( ++ dummy: c_int, ++ dgst: *const c_uchar, ++ len: c_int, ++ sigbuf: *const c_uchar, ++ siglen: c_int, ++ dsa: *mut DSA, ++ ) -> c_int; ++ ++ pub fn SHA1(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar; ++ pub fn SHA224(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar; ++ pub fn SHA256(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar; ++ pub fn SHA384(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar; ++ pub fn SHA512(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar; ++ ++ pub fn SHA1_Init(c: *mut SHA_CTX) -> c_int; ++ pub fn SHA1_Update(c: *mut SHA_CTX, data: *const c_void, len: size_t) -> c_int; ++ pub fn SHA1_Final(md: *mut c_uchar, c: *mut SHA_CTX) -> c_int; ++ pub fn SHA256_Init(c: *mut SHA256_CTX) -> c_int; ++ pub fn SHA256_Update(c: *mut SHA256_CTX, data: *const c_void, len: size_t) -> c_int; ++ pub fn SHA256_Final(md: *mut c_uchar, c: *mut SHA256_CTX) -> c_int; ++ pub fn SHA224_Init(c: *mut SHA256_CTX) -> c_int; ++ pub fn SHA224_Update(c: *mut SHA256_CTX, data: *const c_void, len: size_t) -> c_int; ++ pub fn SHA224_Final(md: *mut c_uchar, c: *mut SHA256_CTX) -> c_int; ++ pub fn SHA384_Init(c: *mut SHA512_CTX) -> c_int; ++ pub fn SHA384_Update(c: *mut SHA512_CTX, data: *const c_void, len: size_t) -> c_int; ++ pub fn SHA384_Final(md: *mut c_uchar, c: *mut SHA512_CTX) -> c_int; ++ pub fn SHA512_Init(c: *mut SHA512_CTX) -> c_int; ++ pub fn SHA512_Update(c: *mut SHA512_CTX, data: *const c_void, len: size_t) -> c_int; ++ pub fn SHA512_Final(md: *mut c_uchar, c: *mut SHA512_CTX) -> c_int; ++ ++ pub fn SSL_new(ctx: *mut SSL_CTX) -> *mut SSL; ++ pub fn SSL_pending(ssl: *const SSL) -> c_int; ++ pub fn SSL_free(ssl: *mut SSL); ++ pub fn SSL_set_bio(ssl: *mut SSL, rbio: *mut BIO, wbio: *mut BIO); ++ pub fn SSL_get_rbio(ssl: *const SSL) -> *mut BIO; ++ pub fn SSL_get_wbio(ssl: *const SSL) -> *mut BIO; ++ pub fn SSL_accept(ssl: *mut SSL) -> c_int; ++ pub fn SSL_connect(ssl: *mut SSL) -> c_int; ++ pub fn SSL_do_handshake(ssl: *mut SSL) -> c_int; ++ pub fn SSL_ctrl(ssl: *mut SSL, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long; ++ pub fn SSL_get_error(ssl: *const SSL, ret: c_int) -> c_int; ++ pub fn SSL_read(ssl: *mut SSL, buf: *mut c_void, num: c_int) -> c_int; ++ pub fn SSL_write(ssl: *mut SSL, buf: *const c_void, num: c_int) -> c_int; ++ pub fn SSL_get_ex_data_X509_STORE_CTX_idx() -> c_int; ++ pub fn SSL_get_SSL_CTX(ssl: *const SSL) -> *mut SSL_CTX; ++ pub fn SSL_set_SSL_CTX(ssl: *mut SSL, ctx: *mut SSL_CTX) -> *mut SSL_CTX; ++ #[cfg(not(any(osslconf = "OPENSSL_NO_COMP", libressl)))] ++ pub fn SSL_get_current_compression(ssl: *mut SSL) -> *const COMP_METHOD; ++ #[cfg(libressl)] ++ pub fn SSL_get_current_compression(ssl: *mut SSL) -> *const libc::c_void; ++ pub fn SSL_get_peer_certificate(ssl: *const SSL) -> *mut X509; ++ pub fn SSL_get_peer_cert_chain(ssl: *const SSL) -> *mut stack_st_X509; ++ pub fn SSL_get_ssl_method(ssl: *mut SSL) -> *const SSL_METHOD; ++ pub fn SSL_get_version(ssl: *const SSL) -> *const c_char; ++ pub fn SSL_state_string(ssl: *const SSL) -> *const c_char; ++ pub fn SSL_state_string_long(ssl: *const SSL) -> *const c_char; ++ pub fn SSL_set_verify( ++ ssl: *mut SSL, ++ mode: c_int, ++ verify_callback: Option c_int>, ++ ); ++ pub fn SSL_set_ex_data(ssl: *mut SSL, idx: c_int, data: *mut c_void) -> c_int; ++ pub fn SSL_get_ex_data(ssl: *const SSL, idx: c_int) -> *mut c_void; ++ pub fn SSL_get_servername(ssl: *const SSL, name_type: c_int) -> *const c_char; ++ pub fn SSL_get_current_cipher(ssl: *const SSL) -> *const SSL_CIPHER; ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn SSL_get0_param(ssl: *mut SSL) -> *mut X509_VERIFY_PARAM; ++ pub fn SSL_get_verify_result(ssl: *const SSL) -> c_long; ++ pub fn SSL_shutdown(ssl: *mut SSL) -> c_int; ++ pub fn SSL_get_certificate(ssl: *const SSL) -> *mut X509; ++ #[cfg(any(ossl101, libressl))] ++ pub fn SSL_get_privatekey(ssl: *mut SSL) -> *mut EVP_PKEY; ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn SSL_get_privatekey(ssl: *const SSL) -> *mut EVP_PKEY; ++ pub fn SSL_load_client_CA_file(file: *const c_char) -> *mut stack_st_X509_NAME; ++ pub fn SSL_set_tmp_dh_callback( ++ ctx: *mut SSL, ++ dh: unsafe extern "C" fn(ssl: *mut SSL, is_export: c_int, keylength: c_int) -> *mut DH, ++ ); ++ ++ #[cfg(not(any(osslconf = "OPENSSL_NO_COMP", libressl)))] ++ pub fn SSL_COMP_get_name(comp: *const COMP_METHOD) -> *const c_char; ++ #[cfg(libressl)] ++ pub fn SSL_COMP_get_name(comp: *const libc::c_void) -> *const c_char; ++ ++ pub fn SSL_CIPHER_get_name(cipher: *const SSL_CIPHER) -> *const c_char; ++ pub fn SSL_CIPHER_get_bits(cipher: *const SSL_CIPHER, alg_bits: *mut c_int) -> c_int; ++ pub fn SSL_CIPHER_description( ++ cipher: *const SSL_CIPHER, ++ buf: *mut c_char, ++ size: c_int, ++ ) -> *mut c_char; ++ ++ pub fn SSL_CTX_new(method: *const SSL_METHOD) -> *mut SSL_CTX; ++ pub fn SSL_CTX_free(ctx: *mut SSL_CTX); ++ pub fn SSL_CTX_ctrl(ctx: *mut SSL_CTX, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long; ++ pub fn SSL_CTX_callback_ctrl( ++ ctx: *mut SSL_CTX, ++ cmd: c_int, ++ fp: Option, ++ ) -> c_long; ++ pub fn SSL_CTX_set_verify( ++ ctx: *mut SSL_CTX, ++ mode: c_int, ++ verify_callback: Option c_int>, ++ ); ++ pub fn SSL_CTX_set_verify_depth(ctx: *mut SSL_CTX, depth: c_int); ++ pub fn SSL_CTX_load_verify_locations( ++ ctx: *mut SSL_CTX, ++ CAfile: *const c_char, ++ CApath: *const c_char, ++ ) -> c_int; ++ pub fn SSL_CTX_set_default_verify_paths(ctx: *mut SSL_CTX) -> c_int; ++ pub fn SSL_CTX_set_ex_data(ctx: *mut SSL_CTX, idx: c_int, data: *mut c_void) -> c_int; ++ pub fn SSL_CTX_get_ex_data(ctx: *const SSL_CTX, idx: c_int) -> *mut c_void; ++ pub fn SSL_CTX_set_session_id_context( ++ ssl: *mut SSL_CTX, ++ sid_ctx: *const c_uchar, ++ sid_ctx_len: c_uint, ++ ) -> c_int; ++ ++ pub fn SSL_CTX_use_certificate_file( ++ ctx: *mut SSL_CTX, ++ cert_file: *const c_char, ++ file_type: c_int, ++ ) -> c_int; ++ pub fn SSL_CTX_use_certificate_chain_file( ++ ctx: *mut SSL_CTX, ++ cert_chain_file: *const c_char, ++ ) -> c_int; ++ pub fn SSL_CTX_use_certificate(ctx: *mut SSL_CTX, cert: *mut X509) -> c_int; ++ ++ pub fn SSL_CTX_use_PrivateKey_file( ++ ctx: *mut SSL_CTX, ++ key_file: *const c_char, ++ file_type: c_int, ++ ) -> c_int; ++ pub fn SSL_CTX_use_PrivateKey(ctx: *mut SSL_CTX, key: *mut EVP_PKEY) -> c_int; ++ pub fn SSL_CTX_check_private_key(ctx: *const SSL_CTX) -> c_int; ++ pub fn SSL_CTX_set_client_CA_list(ctx: *mut SSL_CTX, list: *mut stack_st_X509_NAME); ++ pub fn SSL_CTX_get_cert_store(ctx: *const SSL_CTX) -> *mut X509_STORE; ++ pub fn SSL_CTX_set_tmp_dh_callback( ++ ctx: *mut SSL_CTX, ++ dh: unsafe extern "C" fn(ssl: *mut SSL, is_export: c_int, keylength: c_int) -> *mut DH, ++ ); ++ ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn SSL_CTX_get0_certificate(ctx: *const SSL_CTX) -> *mut X509; ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn SSL_CTX_get0_privatekey(ctx: *const SSL_CTX) -> *mut EVP_PKEY; ++ ++ pub fn SSL_CTX_set_cipher_list(ssl: *mut SSL_CTX, s: *const c_char) -> c_int; ++ ++ pub fn SSL_CTX_set_next_protos_advertised_cb( ++ ssl: *mut SSL_CTX, ++ cb: extern "C" fn(ssl: *mut SSL, ++ out: *mut *const c_uchar, ++ outlen: *mut c_uint, ++ arg: *mut c_void) ++ -> c_int, ++ arg: *mut c_void, ++ ); ++ pub fn SSL_CTX_set_next_proto_select_cb( ++ ssl: *mut SSL_CTX, ++ cb: extern "C" fn(ssl: *mut SSL, ++ out: *mut *mut c_uchar, ++ outlen: *mut c_uchar, ++ inbuf: *const c_uchar, ++ inlen: c_uint, ++ arg: *mut c_void) ++ -> c_int, ++ arg: *mut c_void, ++ ); ++ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))] ++ pub fn SSL_CTX_set_psk_client_callback( ++ ssl: *mut SSL_CTX, ++ psk_client_cb: Option< ++ extern "C" fn(*mut SSL, ++ *const c_char, ++ *mut c_char, ++ c_uint, ++ *mut c_uchar, ++ c_uint) ++ -> c_uint, ++ >, ++ ); ++ pub fn SSL_select_next_proto( ++ out: *mut *mut c_uchar, ++ outlen: *mut c_uchar, ++ inbuf: *const c_uchar, ++ inlen: c_uint, ++ client: *const c_uchar, ++ client_len: c_uint, ++ ) -> c_int; ++ pub fn SSL_get0_next_proto_negotiated( ++ s: *const SSL, ++ data: *mut *const c_uchar, ++ len: *mut c_uint, ++ ); ++ pub fn SSL_get_session(s: *const SSL) -> *mut SSL_SESSION; ++ pub fn SSL_set_session(ssl: *mut SSL, session: *mut SSL_SESSION) -> c_int; ++ #[cfg(not(any(ossl101, libressl, ossl110f)))] ++ pub fn SSL_is_server(s: *mut SSL) -> c_int; ++ #[cfg(ossl110f)] ++ pub fn SSL_is_server(s: *const SSL) -> c_int; ++ ++ pub fn SSL_SESSION_free(s: *mut SSL_SESSION); ++ pub fn SSL_SESSION_get_id(s: *const SSL_SESSION, len: *mut c_uint) -> *const c_uchar; ++ ++ #[cfg(not(ossl101))] ++ pub fn SSL_CTX_set_alpn_protos(s: *mut SSL_CTX, data: *const c_uchar, len: c_uint) -> c_int; ++ ++ #[cfg(not(ossl101))] ++ pub fn SSL_set_alpn_protos(s: *mut SSL, data: *const c_uchar, len: c_uint) -> c_int; ++ ++ #[cfg(not(ossl101))] ++ pub fn SSL_CTX_set_alpn_select_cb( ++ ssl: *mut SSL_CTX, ++ cb: extern "C" fn(ssl: *mut SSL, ++ out: *mut *const c_uchar, ++ outlen: *mut c_uchar, ++ inbuf: *const c_uchar, ++ inlen: c_uint, ++ arg: *mut c_void) ++ -> c_int, ++ arg: *mut c_void, ++ ); ++ #[cfg(not(ossl101))] ++ pub fn SSL_get0_alpn_selected(s: *const SSL, data: *mut *const c_uchar, len: *mut c_uint); ++ ++ pub fn X509_add_ext(x: *mut X509, ext: *mut X509_EXTENSION, loc: c_int) -> c_int; ++ pub fn X509_digest( ++ x: *const X509, ++ digest: *const EVP_MD, ++ buf: *mut c_uchar, ++ len: *mut c_uint, ++ ) -> c_int; ++ pub fn X509_free(x: *mut X509); ++ pub fn X509_REQ_free(x: *mut X509_REQ); ++ pub fn X509_get_serialNumber(x: *mut X509) -> *mut ASN1_INTEGER; ++ pub fn X509_gmtime_adj(time: *mut ASN1_TIME, adj: c_long) -> *mut ASN1_TIME; ++ pub fn X509_new() -> *mut X509; ++ pub fn X509_set_issuer_name(x: *mut X509, name: *mut X509_NAME) -> c_int; ++ pub fn X509_set_subject_name(x: *mut X509, name: *mut X509_NAME) -> c_int; ++ pub fn X509_set_serialNumber(x: *mut X509, sn: *mut ASN1_INTEGER) -> c_int; ++ pub fn X509_set_version(x: *mut X509, version: c_long) -> c_int; ++ pub fn X509_set_pubkey(x: *mut X509, pkey: *mut EVP_PKEY) -> c_int; ++ pub fn X509_sign(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int; ++ pub fn X509_get_pubkey(x: *mut X509) -> *mut EVP_PKEY; ++ pub fn X509_to_X509_REQ(x: *mut X509, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> *mut X509_REQ; ++ pub fn X509_verify_cert_error_string(n: c_long) -> *const c_char; ++ pub fn X509_get1_ocsp(x: *mut X509) -> *mut stack_st_OPENSSL_STRING; ++ pub fn X509_check_issued(issuer: *mut X509, subject: *mut X509) -> c_int; ++ ++ pub fn X509_ALGOR_free(x: *mut X509_ALGOR); ++ ++ pub fn X509_EXTENSION_free(ext: *mut X509_EXTENSION); ++ ++ pub fn X509_NAME_new() -> *mut X509_NAME; ++ pub fn X509_NAME_free(x: *mut X509_NAME); ++ pub fn X509_NAME_add_entry_by_txt( ++ x: *mut X509_NAME, ++ field: *const c_char, ++ ty: c_int, ++ bytes: *const c_uchar, ++ len: c_int, ++ loc: c_int, ++ set: c_int, ++ ) -> c_int; ++ pub fn X509_NAME_get_index_by_NID(n: *mut X509_NAME, nid: c_int, last_pos: c_int) -> c_int; ++ ++ pub fn X509_NAME_ENTRY_free(x: *mut X509_NAME_ENTRY); ++ ++ pub fn ASN1_STRING_free(x: *mut ASN1_STRING); ++ pub fn ASN1_STRING_length(x: *const ASN1_STRING) -> c_int; ++ ++ pub fn ASN1_INTEGER_free(x: *mut ASN1_INTEGER); ++ ++ pub fn X509_STORE_new() -> *mut X509_STORE; ++ pub fn X509_STORE_free(store: *mut X509_STORE); ++ pub fn X509_STORE_add_cert(store: *mut X509_STORE, x: *mut X509) -> c_int; ++ pub fn X509_STORE_set_default_paths(store: *mut X509_STORE) -> c_int; ++ ++ pub fn X509_STORE_CTX_free(ctx: *mut X509_STORE_CTX); ++ pub fn X509_STORE_CTX_get_current_cert(ctx: *mut X509_STORE_CTX) -> *mut X509; ++ pub fn X509_STORE_CTX_get_error(ctx: *mut X509_STORE_CTX) -> c_int; ++ pub fn X509_STORE_CTX_get_ex_data(ctx: *mut X509_STORE_CTX, idx: c_int) -> *mut c_void; ++ pub fn X509_STORE_CTX_get_error_depth(ctx: *mut X509_STORE_CTX) -> c_int; ++ ++ pub fn X509V3_set_ctx( ++ ctx: *mut X509V3_CTX, ++ issuer: *mut X509, ++ subject: *mut X509, ++ req: *mut X509_REQ, ++ crl: *mut X509_CRL, ++ flags: c_int, ++ ); ++ pub fn X509V3_set_nconf(ctx: *mut X509V3_CTX, conf: *mut CONF); ++ ++ pub fn X509_REQ_new() -> *mut X509_REQ; ++ pub fn X509_REQ_set_version(req: *mut X509_REQ, version: c_long) -> c_int; ++ pub fn X509_REQ_set_subject_name(req: *mut X509_REQ, name: *mut X509_NAME) -> c_int; ++ pub fn X509_REQ_set_pubkey(req: *mut X509_REQ, pkey: *mut EVP_PKEY) -> c_int; ++ pub fn X509_REQ_add_extensions(req: *mut X509_REQ, exts: *mut stack_st_X509_EXTENSION) ++ -> c_int; ++ pub fn X509_REQ_sign(x: *mut X509_REQ, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int; ++ ++ #[cfg(not(ossl101))] ++ pub fn X509_VERIFY_PARAM_free(param: *mut X509_VERIFY_PARAM); ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn X509_VERIFY_PARAM_set_hostflags(param: *mut X509_VERIFY_PARAM, flags: c_uint); ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn X509_VERIFY_PARAM_set1_host( ++ param: *mut X509_VERIFY_PARAM, ++ name: *const c_char, ++ namelen: size_t, ++ ) -> c_int; ++ #[cfg(not(any(ossl101, libressl)))] ++ pub fn X509_VERIFY_PARAM_set1_ip( ++ param: *mut X509_VERIFY_PARAM, ++ ip: *const c_uchar, ++ iplen: size_t, ++ ) -> c_int; ++ ++ pub fn d2i_DHparams(k: *mut *mut DH, pp: *mut *const c_uchar, length: c_long) -> *mut DH; ++ pub fn i2d_DHparams(dh: *const DH, pp: *mut *mut c_uchar) -> c_int; ++ ++ pub fn d2i_DSAPublicKey(a: *mut *mut DSA, pp: *mut *const c_uchar, length: c_long) -> *mut DSA; ++ pub fn i2d_DSAPublicKey(a: *const DSA, pp: *mut *mut c_uchar) -> c_int; ++ pub fn d2i_DSAPrivateKey(a: *mut *mut DSA, pp: *mut *const c_uchar, length: c_long) ++ -> *mut DSA; ++ pub fn i2d_DSAPrivateKey(a: *const DSA, pp: *mut *mut c_uchar) -> c_int; ++ ++ pub fn d2i_ECPrivateKey( ++ k: *mut *mut EC_KEY, ++ pp: *mut *const c_uchar, ++ length: c_long, ++ ) -> *mut EC_KEY; ++ pub fn i2d_ECPrivateKey(ec_key: *mut EC_KEY, pp: *mut *mut c_uchar) -> c_int; ++ ++ pub fn d2i_X509(a: *mut *mut X509, pp: *mut *const c_uchar, length: c_long) -> *mut X509; ++ pub fn d2i_X509_REQ( ++ a: *mut *mut X509_REQ, ++ pp: *mut *const c_uchar, ++ length: c_long, ++ ) -> *mut X509_REQ; ++ pub fn i2d_X509_bio(b: *mut BIO, x: *mut X509) -> c_int; ++ pub fn i2d_X509(x: *mut X509, buf: *mut *mut u8) -> c_int; ++ pub fn i2d_X509_REQ_bio(b: *mut BIO, x: *mut X509_REQ) -> c_int; ++ pub fn i2d_X509_REQ(x: *mut X509_REQ, buf: *mut *mut u8) -> c_int; ++ ++ pub fn d2i_AutoPrivateKey( ++ a: *mut *mut EVP_PKEY, ++ pp: *mut *const c_uchar, ++ length: c_long, ++ ) -> *mut EVP_PKEY; ++ pub fn d2i_PUBKEY(k: *mut *mut EVP_PKEY, buf: *mut *const u8, len: c_long) -> *mut EVP_PKEY; ++ pub fn i2d_PUBKEY_bio(b: *mut BIO, x: *mut EVP_PKEY) -> c_int; ++ pub fn i2d_PrivateKey_bio(b: *mut BIO, x: *mut EVP_PKEY) -> c_int; ++ pub fn i2d_PUBKEY(k: *mut EVP_PKEY, buf: *mut *mut u8) -> c_int; ++ pub fn i2d_PrivateKey(k: *mut EVP_PKEY, buf: *mut *mut u8) -> c_int; ++ ++ pub fn i2d_RSA_PUBKEY(k: *mut RSA, buf: *mut *mut u8) -> c_int; ++ pub fn d2i_RSA_PUBKEY(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA; ++ pub fn i2d_RSAPublicKey(k: *const RSA, buf: *mut *mut u8) -> c_int; ++ pub fn d2i_RSAPublicKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA; ++ pub fn i2d_RSAPrivateKey(k: *const RSA, buf: *mut *mut u8) -> c_int; ++ pub fn d2i_RSAPrivateKey(k: *mut *mut RSA, buf: *mut *const u8, len: c_long) -> *mut RSA; ++ ++ pub fn i2d_PKCS12_bio(b: *mut BIO, a: *mut PKCS12) -> c_int; ++ pub fn i2d_PKCS12(a: *mut PKCS12, buf: *mut *mut u8) -> c_int; ++ pub fn d2i_PKCS12(a: *mut *mut PKCS12, pp: *mut *const u8, length: c_long) -> *mut PKCS12; ++ pub fn PKCS12_parse( ++ p12: *mut PKCS12, ++ pass: *const c_char, ++ pkey: *mut *mut EVP_PKEY, ++ cert: *mut *mut X509, ++ ca: *mut *mut stack_st_X509, ++ ) -> c_int; ++ pub fn PKCS12_free(p12: *mut PKCS12); ++ ++ pub fn GENERAL_NAME_free(name: *mut GENERAL_NAME); ++ ++ pub fn HMAC_Init_ex( ++ ctx: *mut HMAC_CTX, ++ key: *const c_void, ++ len: c_int, ++ md: *const EVP_MD, ++ impl_: *mut ENGINE, ++ ) -> c_int; ++ pub fn HMAC_Update(ctx: *mut HMAC_CTX, data: *const c_uchar, len: size_t) -> c_int; ++ pub fn HMAC_Final(ctx: *mut HMAC_CTX, md: *mut c_uchar, len: *mut c_uint) -> c_int; ++ ++ #[cfg(not(libressl))] ++ pub fn CMS_decrypt( ++ cms: *mut CMS_ContentInfo, ++ pkey: *mut EVP_PKEY, ++ cert: *mut X509, ++ dcont: *mut BIO, ++ out: *mut BIO, ++ flags: c_uint, ++ ) -> c_int; ++ #[cfg(not(libressl))] ++ pub fn SMIME_read_CMS(bio: *mut BIO, bcont: *mut *mut BIO) -> *mut CMS_ContentInfo; ++ #[cfg(not(libressl))] ++ pub fn CMS_ContentInfo_free(cms: *mut CMS_ContentInfo); ++} diff --cc vendor/openssl-sys-0.9.19/src/libressl/mod.rs index 000000000,000000000..f4806e8a9 new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/src/libressl/mod.rs @@@ -1,0 -1,0 +1,600 @@@ ++use std::sync::{Mutex, MutexGuard}; ++use std::sync::{Once, ONCE_INIT}; ++use std::mem; ++use std::ptr; ++ ++#[cfg(libressl250)] ++pub use libressl::v250::*; ++#[cfg(not(libressl250))] ++pub use libressl::v25x::*; ++ ++use libc::{c_int, c_char, c_void, c_long, c_uchar, size_t, c_uint, c_ulong}; ++ ++#[cfg(libressl250)] ++mod v250; ++#[cfg(not(libressl250))] ++mod v25x; ++ ++#[repr(C)] ++pub struct stack_st_ASN1_OBJECT { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_X509 { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_X509_NAME { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_X509_ATTRIBUTE { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_X509_EXTENSION { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_GENERAL_NAME { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_void { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_SSL_CIPHER { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_OPENSSL_STRING { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct _STACK { ++ pub num: c_int, ++ pub data: *mut *mut c_char, ++ pub sorted: c_int, ++ pub num_alloc: c_int, ++ pub comp: Option c_int>, ++} ++ ++#[repr(C)] ++pub struct BIO_METHOD { ++ pub type_: c_int, ++ pub name: *const c_char, ++ pub bwrite: Option c_int>, ++ pub bread: Option c_int>, ++ pub bputs: Option c_int>, ++ pub bgets: Option c_int>, ++ pub ctrl: Option c_long>, ++ pub create: Option c_int>, ++ pub destroy: Option c_int>, ++ pub callback_ctrl: Option c_long>, ++} ++ ++#[repr(C)] ++pub struct RSA { ++ pub pad: c_int, ++ pub version: c_long, ++ pub meth: *const ::RSA_METHOD, ++ ++ pub engine: *mut ::ENGINE, ++ pub n: *mut ::BIGNUM, ++ pub e: *mut ::BIGNUM, ++ pub d: *mut ::BIGNUM, ++ pub p: *mut ::BIGNUM, ++ pub q: *mut ::BIGNUM, ++ pub dmp1: *mut ::BIGNUM, ++ pub dmq1: *mut ::BIGNUM, ++ pub iqmp: *mut ::BIGNUM, ++ ++ pub ex_data: ::CRYPTO_EX_DATA, ++ pub references: c_int, ++ pub flags: c_int, ++ ++ pub _method_mod_n: *mut ::BN_MONT_CTX, ++ pub _method_mod_p: *mut ::BN_MONT_CTX, ++ pub _method_mod_q: *mut ::BN_MONT_CTX, ++ ++ pub blinding: *mut ::BN_BLINDING, ++ pub mt_blinding: *mut ::BN_BLINDING, ++} ++ ++#[repr(C)] ++pub struct DSA { ++ pub pad: c_int, ++ pub version: c_long, ++ pub write_params: c_int, ++ ++ pub p: *mut ::BIGNUM, ++ pub q: *mut ::BIGNUM, ++ pub g: *mut ::BIGNUM, ++ pub pub_key: *mut ::BIGNUM, ++ pub priv_key: *mut ::BIGNUM, ++ pub kinv: *mut ::BIGNUM, ++ pub r: *mut ::BIGNUM, ++ ++ pub flags: c_int, ++ pub method_mont_p: *mut ::BN_MONT_CTX, ++ pub references: c_int, ++ pub ex_data: ::CRYPTO_EX_DATA, ++ pub meth: *const ::DSA_METHOD, ++ pub engine: *mut ::ENGINE, ++} ++ ++#[repr(C)] ++pub struct EVP_PKEY { ++ pub type_: c_int, ++ pub save_type: c_int, ++ pub references: c_int, ++ pub ameth: *const ::EVP_PKEY_ASN1_METHOD, ++ pub engine: *mut ::ENGINE, ++ pub pkey: *mut c_void, ++ pub save_parameters: c_int, ++ pub attributes: *mut stack_st_X509_ATTRIBUTE, ++} ++ ++#[repr(C)] ++pub struct BIO { ++ pub method: *mut ::BIO_METHOD, ++ pub callback: Option< ++ unsafe extern "C" fn(*mut ::BIO, ++ c_int, ++ *const c_char, ++ c_int, ++ c_long, ++ c_long) ++ -> c_long, ++ >, ++ pub cb_arg: *mut c_char, ++ pub init: c_int, ++ pub shutdown: c_int, ++ pub flags: c_int, ++ pub retry_reason: c_int, ++ pub num: c_int, ++ pub ptr: *mut c_void, ++ pub next_bio: *mut ::BIO, ++ pub prev_bio: *mut ::BIO, ++ pub references: c_int, ++ pub num_read: c_ulong, ++ pub num_write: c_ulong, ++ pub ex_data: ::CRYPTO_EX_DATA, ++} ++ ++#[repr(C)] ++pub struct CRYPTO_EX_DATA { ++ pub sk: *mut ::stack_st_void, ++} ++ ++#[repr(C)] ++pub struct EVP_MD_CTX { ++ digest: *mut ::EVP_MD, ++ engine: *mut ::ENGINE, ++ flags: c_ulong, ++ md_data: *mut c_void, ++ pctx: *mut ::EVP_PKEY_CTX, ++ update: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct EVP_CIPHER { ++ pub nid: c_int, ++ pub block_size: c_int, ++ pub key_len: c_int, ++ pub iv_len: c_int, ++ pub flags: c_ulong, ++ pub init: Option< ++ unsafe extern "C" fn(*mut ::EVP_CIPHER_CTX, ++ *const c_uchar, ++ *const c_uchar, ++ c_int) ++ -> c_int, ++ >, ++ pub do_cipher: Option< ++ unsafe extern "C" fn(*mut ::EVP_CIPHER_CTX, ++ *mut c_uchar, ++ *const c_uchar, ++ size_t) ++ -> c_int, ++ >, ++ pub cleanup: Option c_int>, ++ pub ctx_size: c_int, ++ pub set_asn1_parameters: ++ Option c_int>, ++ pub get_asn1_parameters: ++ Option c_int>, ++ pub ctrl: ++ Option c_int>, ++ pub app_data: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct HMAC_CTX { ++ md: *mut ::EVP_MD, ++ md_ctx: ::EVP_MD_CTX, ++ i_ctx: ::EVP_MD_CTX, ++ o_ctx: ::EVP_MD_CTX, ++ key_length: c_uint, ++ key: [c_uchar; 128], ++} ++ ++#[repr(C)] ++pub struct BIGNUM { ++ pub d: *mut ::BN_ULONG, ++ pub top: c_int, ++ pub dmax: c_int, ++ pub neg: c_int, ++ pub flags: c_int, ++} ++ ++#[repr(C)] ++pub struct DH { ++ pub pad: c_int, ++ pub version: c_int, ++ pub p: *mut ::BIGNUM, ++ pub g: *mut ::BIGNUM, ++ pub length: c_long, ++ pub pub_key: *mut ::BIGNUM, ++ pub priv_key: *mut ::BIGNUM, ++ pub flags: c_int, ++ pub method_mont_p: *mut ::BN_MONT_CTX, ++ pub q: *mut ::BIGNUM, ++ pub j: *mut ::BIGNUM, ++ pub seed: *mut c_uchar, ++ pub seedlen: c_int, ++ pub counter: *mut ::BIGNUM, ++ pub references: c_int, ++ pub ex_data: ::CRYPTO_EX_DATA, ++ pub meth: *const ::DH_METHOD, ++ pub engine: *mut ::ENGINE, ++} ++ ++#[repr(C)] ++pub struct X509 { ++ pub cert_info: *mut X509_CINF, ++ pub sig_alg: *mut ::X509_ALGOR, ++ pub signature: *mut ::ASN1_BIT_STRING, ++ pub valid: c_int, ++ pub references: c_int, ++ pub name: *mut c_char, ++ pub ex_data: ::CRYPTO_EX_DATA, ++ pub ex_pathlen: c_long, ++ pub ex_pcpathlen: c_long, ++ pub ex_flags: c_ulong, ++ pub ex_kusage: c_ulong, ++ pub ex_xkusage: c_ulong, ++ pub ex_nscert: c_ulong, ++ skid: *mut c_void, ++ akid: *mut c_void, ++ policy_cache: *mut c_void, ++ crldp: *mut c_void, ++ altname: *mut c_void, ++ nc: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_SHA"))] ++ sha1_hash: [c_uchar; 20], ++ aux: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct X509_CINF { ++ version: *mut c_void, ++ serialNumber: *mut c_void, ++ signature: *mut c_void, ++ issuer: *mut c_void, ++ pub validity: *mut X509_VAL, ++ subject: *mut c_void, ++ key: *mut c_void, ++ issuerUID: *mut c_void, ++ subjectUID: *mut c_void, ++ pub extensions: *mut stack_st_X509_EXTENSION, ++ enc: ASN1_ENCODING, ++} ++ ++#[repr(C)] ++pub struct X509_ALGOR { ++ pub algorithm: *mut ::ASN1_OBJECT, ++ parameter: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct ASN1_ENCODING { ++ pub enc: *mut c_uchar, ++ pub len: c_long, ++ pub modified: c_int, ++} ++ ++#[repr(C)] ++pub struct X509_VAL { ++ pub notBefore: *mut ::ASN1_TIME, ++ pub notAfter: *mut ::ASN1_TIME, ++} ++ ++#[repr(C)] ++pub struct X509_REQ_INFO { ++ pub enc: ASN1_ENCODING, ++ pub version: *mut ::ASN1_INTEGER, ++ pub subject: *mut ::X509_NAME, ++ pubkey: *mut c_void, ++ pub attributes: *mut stack_st_X509_ATTRIBUTE, ++} ++ ++#[repr(C)] ++pub struct X509_REQ { ++ pub req_info: *mut X509_REQ_INFO, ++ sig_alg: *mut c_void, ++ signature: *mut c_void, ++ references: c_int, ++} ++ ++pub enum X509_VERIFY_PARAM_ID {} ++pub enum PKCS12 {} ++ ++pub const SSL_CTRL_GET_SESSION_REUSED: c_int = 8; ++pub const SSL_CTRL_OPTIONS: c_int = 32; ++pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77; ++pub const SSL_CTRL_SET_ECDH_AUTO: c_int = 94; ++ ++#[cfg(libressl261)] ++pub const SSL_OP_ALL: c_ulong = 0x4; ++#[cfg(not(libressl261))] ++pub const SSL_OP_ALL: c_ulong = 0x80000014; ++pub const SSL_OP_CISCO_ANYCONNECT: c_ulong = 0x0; ++pub const SSL_OP_NO_COMPRESSION: c_ulong = 0x0; ++pub const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: c_ulong = 0x0; ++pub const SSL_OP_NO_SSLv3: c_ulong = 0x0; ++pub const SSL_OP_MICROSOFT_SESS_ID_BUG: c_ulong = 0x0; ++pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: c_ulong = 0x0; ++pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: c_ulong = 0x0; ++pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: c_ulong = 0x0; ++pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: c_ulong = 0x0; ++pub const SSL_OP_TLS_D5_BUG: c_ulong = 0x0; ++pub const SSL_OP_TLS_BLOCK_PADDING_BUG: c_ulong = 0x0; ++#[cfg(libressl261)] ++pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x0; ++#[cfg(not(libressl261))] ++pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x00080000; ++pub const SSL_OP_SINGLE_DH_USE: c_ulong = 0x00100000; ++pub const SSL_OP_NO_SSLv2: c_ulong = 0x0; ++ ++pub const SSL_MAX_SSL_SESSION_ID_LENGTH: c_int = 32; ++pub const SSL_MAX_SID_CTX_LENGTH: c_int = 32; ++pub const SSL_MAX_MASTER_KEY_LENGTH: c_int = 48; ++ ++pub const SSLEAY_VERSION: c_int = 0; ++pub const SSLEAY_CFLAGS: c_int = 2; ++pub const SSLEAY_BUILT_ON: c_int = 3; ++pub const SSLEAY_PLATFORM: c_int = 4; ++pub const SSLEAY_DIR: c_int = 5; ++ ++pub const CRYPTO_LOCK_X509: c_int = 3; ++pub const CRYPTO_LOCK_SSL_CTX: c_int = 12; ++pub const CRYPTO_LOCK_SSL_SESSION: c_int = 14; ++ ++static mut MUTEXES: *mut Vec> = 0 as *mut Vec>; ++static mut GUARDS: *mut Vec>> = 0 as ++ *mut Vec>>; ++ ++unsafe extern "C" fn locking_function(mode: c_int, n: c_int, _file: *const c_char, _line: c_int) { ++ let mutex = &(*MUTEXES)[n as usize]; ++ ++ if mode & ::CRYPTO_LOCK != 0 { ++ (*GUARDS)[n as usize] = Some(mutex.lock().unwrap()); ++ } else { ++ &(*GUARDS)[n as usize].take().expect("lock already unlocked"); ++ } ++} ++ ++pub fn init() { ++ static INIT: Once = ONCE_INIT; ++ ++ INIT.call_once(|| unsafe { ++ SSL_library_init(); ++ SSL_load_error_strings(); ++ OPENSSL_add_all_algorithms_noconf(); ++ ++ let num_locks = ::CRYPTO_num_locks(); ++ let mut mutexes = Box::new(Vec::new()); ++ for _ in 0..num_locks { ++ mutexes.push(Mutex::new(())); ++ } ++ MUTEXES = mem::transmute(mutexes); ++ let guards: Box>>> = ++ Box::new((0..num_locks).map(|_| None).collect()); ++ GUARDS = mem::transmute(guards); ++ ++ CRYPTO_set_locking_callback(locking_function); ++ set_id_callback(); ++ }) ++} ++ ++#[cfg(unix)] ++fn set_id_callback() { ++ unsafe extern "C" fn thread_id() -> c_ulong { ++ ::libc::pthread_self() as c_ulong ++ } ++ ++ unsafe { ++ CRYPTO_set_id_callback(thread_id); ++ } ++} ++ ++#[cfg(not(unix))] ++fn set_id_callback() {} ++ ++// macros ++ ++pub unsafe fn SSL_CTX_set_ecdh_auto(ctx: *mut SSL_CTX, onoff: c_int) -> c_int { ++ ::SSL_CTX_ctrl( ++ ctx, ++ SSL_CTRL_SET_ECDH_AUTO, ++ onoff as c_long, ++ ptr::null_mut(), ++ ) as c_int ++} ++ ++pub unsafe fn SSL_set_ecdh_auto(ssl: *mut ::SSL, onoff: c_int) -> c_int { ++ ::SSL_ctrl( ++ ssl, ++ SSL_CTRL_SET_ECDH_AUTO, ++ onoff as c_long, ++ ptr::null_mut(), ++ ) as c_int ++} ++ ++pub unsafe fn SSL_session_reused(ssl: *mut ::SSL) -> c_int { ++ ::SSL_ctrl(ssl, SSL_CTRL_GET_SESSION_REUSED, 0, ptr::null_mut()) as c_int ++} ++ ++extern "C" { ++ pub fn BIO_new(type_: *mut BIO_METHOD) -> *mut BIO; ++ pub fn BIO_s_file() -> *mut BIO_METHOD; ++ pub fn BIO_s_mem() -> *mut BIO_METHOD; ++ ++ pub fn get_rfc2409_prime_768(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc2409_prime_1024(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_1536(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_2048(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_3072(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_4096(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_6144(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_8192(bn: *mut BIGNUM) -> *mut BIGNUM; ++ ++ pub fn CRYPTO_malloc(num: c_int, file: *const c_char, line: c_int) -> *mut c_void; ++ pub fn CRYPTO_free(buf: *mut c_void); ++ pub fn CRYPTO_num_locks() -> c_int; ++ pub fn CRYPTO_set_locking_callback( ++ func: unsafe extern "C" fn(mode: c_int, n: c_int, file: *const c_char, line: c_int), ++ ); ++ pub fn CRYPTO_set_id_callback(func: unsafe extern "C" fn() -> c_ulong); ++ ++ pub fn ERR_load_crypto_strings(); ++ ++ pub fn RSA_generate_key( ++ modsz: c_int, ++ e: c_ulong, ++ cb: Option, ++ cbarg: *mut c_void, ++ ) -> *mut RSA; ++ ++ pub fn OCSP_cert_to_id( ++ dgst: *const ::EVP_MD, ++ subject: *mut ::X509, ++ issuer: *mut ::X509, ++ ) -> *mut ::OCSP_CERTID; ++ ++ pub fn PKCS12_create( ++ pass: *mut c_char, ++ friendly_name: *mut c_char, ++ pkey: *mut EVP_PKEY, ++ cert: *mut X509, ++ ca: *mut stack_st_X509, ++ nid_key: c_int, ++ nid_cert: c_int, ++ iter: c_int, ++ mac_iter: c_int, ++ keytype: c_int, ++ ) -> *mut PKCS12; ++ ++ pub fn SSL_library_init() -> c_int; ++ pub fn SSL_load_error_strings(); ++ pub fn OPENSSL_add_all_algorithms_noconf(); ++ pub fn HMAC_CTX_init(ctx: *mut ::HMAC_CTX); ++ pub fn HMAC_CTX_cleanup(ctx: *mut ::HMAC_CTX); ++ pub fn TLSv1_method() -> *const ::SSL_METHOD; ++ pub fn SSLv23_method() -> *const ::SSL_METHOD; ++ pub fn TLSv1_1_method() -> *const ::SSL_METHOD; ++ pub fn TLSv1_2_method() -> *const ::SSL_METHOD; ++ pub fn DTLSv1_method() -> *const ::SSL_METHOD; ++ pub fn SSL_get_ex_new_index( ++ argl: c_long, ++ argp: *mut c_void, ++ new_func: Option<::CRYPTO_EX_new>, ++ dup_func: Option<::CRYPTO_EX_dup>, ++ free_func: Option<::CRYPTO_EX_free>, ++ ) -> c_int; ++ pub fn SSL_set_tmp_ecdh_callback( ++ ssl: *mut ::SSL, ++ ecdh: unsafe extern "C" fn(ssl: *mut ::SSL, is_export: c_int, keylength: c_int) ++ -> *mut ::EC_KEY, ++ ); ++ pub fn SSL_CIPHER_get_version(cipher: *const ::SSL_CIPHER) -> *mut c_char; ++ pub fn SSL_CTX_get_ex_new_index( ++ argl: c_long, ++ argp: *mut c_void, ++ new_func: Option<::CRYPTO_EX_new>, ++ dup_func: Option<::CRYPTO_EX_dup>, ++ free_func: Option<::CRYPTO_EX_free>, ++ ) -> c_int; ++ pub fn SSL_CTX_set_tmp_ecdh_callback( ++ ctx: *mut ::SSL_CTX, ++ ecdh: unsafe extern "C" fn(ssl: *mut ::SSL, is_export: c_int, keylength: c_int) ++ -> *mut ::EC_KEY, ++ ); ++ pub fn X509_get_subject_name(x: *mut ::X509) -> *mut ::X509_NAME; ++ pub fn X509_set_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int; ++ pub fn X509_set_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int; ++ pub fn X509_get_ext_d2i( ++ x: *mut ::X509, ++ nid: c_int, ++ crit: *mut c_int, ++ idx: *mut c_int, ++ ) -> *mut c_void; ++ pub fn X509_NAME_add_entry_by_NID( ++ x: *mut ::X509_NAME, ++ field: c_int, ++ ty: c_int, ++ bytes: *mut c_uchar, ++ len: c_int, ++ loc: c_int, ++ set: c_int, ++ ) -> c_int; ++ pub fn X509_NAME_get_entry(n: *mut ::X509_NAME, loc: c_int) -> *mut ::X509_NAME_ENTRY; ++ pub fn X509_NAME_ENTRY_get_data(ne: *mut ::X509_NAME_ENTRY) -> *mut ::ASN1_STRING; ++ pub fn X509_STORE_CTX_get_chain(ctx: *mut ::X509_STORE_CTX) -> *mut stack_st_X509; ++ pub fn X509V3_EXT_nconf_nid( ++ conf: *mut ::CONF, ++ ctx: *mut ::X509V3_CTX, ++ ext_nid: c_int, ++ value: *mut c_char, ++ ) -> *mut ::X509_EXTENSION; ++ pub fn X509V3_EXT_nconf( ++ conf: *mut ::CONF, ++ ctx: *mut ::X509V3_CTX, ++ name: *mut c_char, ++ value: *mut c_char, ++ ) -> *mut ::X509_EXTENSION; ++ pub fn ASN1_STRING_to_UTF8(out: *mut *mut c_uchar, s: *mut ::ASN1_STRING) -> c_int; ++ pub fn ASN1_STRING_data(x: *mut ::ASN1_STRING) -> *mut c_uchar; ++ pub fn CRYPTO_add_lock( ++ pointer: *mut c_int, ++ amount: c_int, ++ type_: c_int, ++ file: *const c_char, ++ line: c_int, ++ ) -> c_int; ++ pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX; ++ pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX); ++ pub fn EVP_PKEY_bits(key: *mut EVP_PKEY) -> c_int; ++ ++ pub fn sk_new_null() -> *mut _STACK; ++ pub fn sk_num(st: *const _STACK) -> c_int; ++ pub fn sk_value(st: *const _STACK, n: c_int) -> *mut c_void; ++ pub fn sk_free(st: *mut _STACK); ++ pub fn sk_push(st: *mut _STACK, data: *mut c_void) -> c_int; ++ pub fn sk_pop_free(st: *mut _STACK, free: Option); ++ pub fn sk_pop(st: *mut _STACK) -> *mut c_void; ++ ++ pub fn SSLeay() -> c_ulong; ++ pub fn SSLeay_version(key: c_int) -> *const c_char; ++} diff --cc vendor/openssl-sys-0.9.19/src/libressl/v250.rs index 000000000,000000000..e844ffed7 new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/src/libressl/v250.rs @@@ -1,0 -1,0 +1,221 @@@ ++use libc::{c_int, c_char, c_void, c_long, c_uchar, size_t, c_uint, c_ulong, time_t}; ++ ++use super::*; ++ ++#[repr(C)] ++pub struct SSL { ++ version: c_int, ++ type_: c_int, ++ method: *const ::SSL_METHOD, ++ rbio: *mut c_void, ++ wbio: *mut c_void, ++ bbio: *mut c_void, ++ rwstate: c_int, ++ in_handshake: c_int, ++ handshake_func: Option c_int>, ++ pub server: c_int, ++ new_session: c_int, ++ quiet_shutdown: c_int, ++ shutdown: c_int, ++ state: c_int, ++ rstate: c_int, ++ init_buf: *mut c_void, ++ init_msg: *mut c_void, ++ init_num: c_int, ++ init_off: c_int, ++ packet: *mut c_uchar, ++ packet_length: c_uint, ++ s3: *mut c_void, ++ d1: *mut c_void, ++ read_ahead: c_int, ++ msg_callback: Option< ++ unsafe extern "C" fn(c_int, ++ c_int, ++ c_int, ++ *const c_void, ++ size_t, ++ *mut SSL, ++ *mut c_void), ++ >, ++ msg_callback_arg: *mut c_void, ++ hit: c_int, ++ param: *mut c_void, ++ cipher_list: *mut stack_st_SSL_CIPHER, ++ cipher_list_by_id: *mut stack_st_SSL_CIPHER, ++ mac_flags: c_int, ++ aead_read_ctx: *mut c_void, ++ enc_read_ctx: *mut ::EVP_CIPHER_CTX, ++ read_hash: *mut ::EVP_MD_CTX, ++ aead_write_ctx: *mut c_void, ++ enc_write_ctx: *mut ::EVP_CIPHER_CTX, ++ write_hash: *mut ::EVP_MD_CTX, ++ cert: *mut c_void, ++ sid_ctx_length: c_uint, ++ sid_ctx: [c_uchar; ::SSL_MAX_SID_CTX_LENGTH as usize], ++ session: *mut ::SSL_SESSION, ++ generate_session_id: ::GEN_SESSION_CB, ++ verify_mode: c_int, ++ verify_callback: Option c_int>, ++ info_callback: Option, ++ error: c_int, ++ error_code: c_int, ++ ctx: *mut ::SSL_CTX, ++ debug: c_int, ++ verify_result: c_long, ++ ex_data: ::CRYPTO_EX_DATA, ++ client_CA: *mut stack_st_X509_NAME, ++ references: c_int, ++ options: c_ulong, ++ mode: c_ulong, ++ max_cert_list: c_long, ++ first_packet: c_int, ++ client_version: c_int, ++ max_send_fragment: c_uint, ++ tlsext_debug_cb: ++ Option, ++ tlsext_debug_arg: *mut c_void, ++ tlsext_hostname: *mut c_char, ++ servername_done: c_int, ++ tlsext_status_type: c_int, ++ tlsext_status_expected: c_int, ++ tlsext_ocsp_ids: *mut c_void, ++ tlsext_ocsp_exts: *mut c_void, ++ tlsext_ocsp_resp: *mut c_uchar, ++ tlsext_ocsp_resplen: c_int, ++ tlsext_ticket_expected: c_int, ++ tlsext_ecpointformatlist_length: size_t, ++ tlsext_ecpointformatlist: *mut c_uchar, ++ tlsext_ellipticcurvelist_length: size_t, ++ tlsext_ellipticcurvelist: *mut c_uchar, ++ tlsext_session_ticket: *mut c_void, ++ tlsext_session_ticket_ext_cb: ::tls_session_ticket_ext_cb_fn, ++ tls_session_ticket_ext_cb_arg: *mut c_void, ++ tls_session_secret_cb: ::tls_session_secret_cb_fn, ++ tls_session_secret_cb_arg: *mut c_void, ++ initial_ctx: *mut ::SSL_CTX, ++ next_proto_negotiated: *mut c_uchar, ++ next_proto_negotiated_len: c_uchar, ++ srtp_profiles: *mut c_void, ++ srtp_profile: *mut c_void, ++ tlsext_heartbeat: c_uint, ++ tlsext_hb_pending: c_uint, ++ tlsext_hb_seq: c_uint, ++ alpn_client_proto_list: *mut c_uchar, ++ alpn_client_proto_list_len: c_uint, ++ renegotiate: c_int, ++} ++ ++#[repr(C)] ++pub struct SSL_CTX { ++ method: *mut c_void, ++ cipher_list: *mut c_void, ++ cipher_list_by_id: *mut c_void, ++ cert_store: *mut c_void, ++ sessions: *mut c_void, ++ session_cache_size: c_ulong, ++ session_cache_head: *mut c_void, ++ session_cache_tail: *mut c_void, ++ session_cache_mode: c_int, ++ session_timeout: c_long, ++ new_session_cb: *mut c_void, ++ remove_session_cb: *mut c_void, ++ get_session_cb: *mut c_void, ++ stats: [c_int; 11], ++ pub references: c_int, ++ app_verify_callback: *mut c_void, ++ app_verify_arg: *mut c_void, ++ default_passwd_callback: *mut c_void, ++ default_passwd_callback_userdata: *mut c_void, ++ client_cert_cb: *mut c_void, ++ app_gen_cookie_cb: *mut c_void, ++ app_verify_cookie_cb: *mut c_void, ++ ex_dat: ::CRYPTO_EX_DATA, ++ rsa_md5: *mut c_void, ++ md5: *mut c_void, ++ sha1: *mut c_void, ++ extra_certs: *mut c_void, ++ comp_methods: *mut c_void, ++ info_callback: *mut c_void, ++ client_CA: *mut c_void, ++ options: c_ulong, ++ mode: c_ulong, ++ max_cert_list: c_long, ++ cert: *mut c_void, ++ read_ahead: c_int, ++ msg_callback: *mut c_void, ++ msg_callback_arg: *mut c_void, ++ verify_mode: c_int, ++ sid_ctx_length: c_uint, ++ sid_ctx: [c_uchar; 32], ++ default_verify_callback: *mut c_void, ++ generate_session_id: *mut c_void, ++ param: *mut c_void, ++ quiet_shutdown: c_int, ++ max_send_fragment: c_uint, ++ ++ #[cfg(not(osslconf = "OPENSSL_NO_ENGINE"))] ++ client_cert_engine: *mut c_void, ++ ++ tlsext_servername_callback: *mut c_void, ++ tlsect_servername_arg: *mut c_void, ++ tlsext_tick_key_name: [c_uchar; 16], ++ tlsext_tick_hmac_key: [c_uchar; 16], ++ tlsext_tick_aes_key: [c_uchar; 16], ++ tlsext_ticket_key_cb: *mut c_void, ++ tlsext_status_cb: *mut c_void, ++ tlsext_status_arg: *mut c_void, ++ tlsext_opaque_prf_input_callback: *mut c_void, ++ tlsext_opaque_prf_input_callback_arg: *mut c_void, ++ ++ next_protos_advertised_cb: *mut c_void, ++ next_protos_advertised_cb_arg: *mut c_void, ++ next_proto_select_cb: *mut c_void, ++ next_proto_select_cb_arg: *mut c_void, ++ ++ srtp_profiles: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct SSL_SESSION { ++ ssl_version: c_int, ++ pub master_key_length: c_int, ++ pub master_key: [c_uchar; 48], ++ session_id_length: c_uint, ++ session_id: [c_uchar; SSL_MAX_SSL_SESSION_ID_LENGTH as usize], ++ sid_ctx_length: c_uint, ++ sid_ctx: [c_uchar; SSL_MAX_SID_CTX_LENGTH as usize], ++ not_resumable: c_int, ++ sess_cert: *mut c_void, ++ peer: *mut X509, ++ verify_result: c_long, ++ timeout: c_long, ++ time: time_t, ++ pub references: c_int, ++ cipher: *const c_void, ++ cipher_id: c_ulong, ++ ciphers: *mut c_void, ++ ex_data: ::CRYPTO_EX_DATA, ++ prev: *mut c_void, ++ next: *mut c_void, ++ tlsext_hostname: *mut c_char, ++ tlsext_ecpointformatlist_length: size_t, ++ tlsext_ecpointformatlist: *mut u8, ++ tlsext_ellipticcurvelist_length: size_t, ++ tlsext_ellipticcurvelist: *mut u16, ++ tlsext_tick: *mut c_uchar, ++ tlsext_ticklen: size_t, ++ tlsext_tick_lifetime_hint: c_long, ++} ++ ++#[repr(C)] ++pub struct X509_VERIFY_PARAM { ++ pub name: *mut c_char, ++ pub check_time: time_t, ++ pub inh_flags: c_ulong, ++ pub flags: c_ulong, ++ pub purpose: c_int, ++ pub trust: c_int, ++ pub depth: c_int, ++ pub policies: *mut stack_st_ASN1_OBJECT, ++ //pub id: *mut X509_VERIFY_PARAM_ID, ++} diff --cc vendor/openssl-sys-0.9.19/src/libressl/v25x.rs index 000000000,000000000..7e7023ec5 new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/src/libressl/v25x.rs @@@ -1,0 -1,0 +1,89 @@@ ++use libc::{c_int, c_char, c_void, c_long, c_uchar, size_t, c_uint, c_ulong, time_t}; ++ ++use super::*; ++ ++#[repr(C)] ++pub struct SSL { ++ version: c_int, ++ method: *const ::SSL_METHOD, ++ rbio: *mut ::BIO, ++ wbio: *mut ::BIO, ++ bbio: *mut ::BIO, ++ pub server: c_int, ++ s3: *mut c_void, ++ d1: *mut c_void, ++ param: *mut c_void, ++ cipher_list: *mut stack_st_SSL_CIPHER, ++ cert: *mut c_void, ++ sid_ctx_length: c_uint, ++ sid_ctx: [c_uchar; ::SSL_MAX_SID_CTX_LENGTH as usize], ++ session: *mut ::SSL_SESSION, ++ verify_mode: c_int, ++ error: c_int, ++ error_code: c_int, ++ ctx: *mut ::SSL_CTX, ++ verify_result: c_long, ++ references: c_int, ++ client_version: c_int, ++ max_send_fragment: c_uint, ++ tlsext_hostname: *mut c_char, ++ tlsext_status_type: c_int, ++ initial_ctx: *mut ::SSL_CTX, ++ enc_read_ctx: *mut ::EVP_CIPHER_CTX, ++ read_hash: *mut EVP_MD_CTX, ++ internal: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct SSL_CTX { ++ method: *const ::SSL_METHOD, ++ cipher_list: *mut stack_st_SSL_CIPHER, ++ cert_store: *mut c_void, ++ session_timeout: c_long, ++ pub references: c_int, ++ extra_certs: *mut stack_st_X509, ++ verify_mode: c_int, ++ sid_ctx_length: c_uint, ++ sid_ctx: [c_uchar; ::SSL_MAX_SID_CTX_LENGTH as usize], ++ param: *mut ::X509_VERIFY_PARAM, ++ default_passwd_callback: *mut c_void, ++ default_passwd_callback_userdata: *mut c_void, ++ internal: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct SSL_SESSION { ++ ssl_version: c_int, ++ pub master_key_length: c_int, ++ pub master_key: [c_uchar; 48], ++ session_id_length: c_uint, ++ session_id: [c_uchar; ::SSL_MAX_SSL_SESSION_ID_LENGTH as usize], ++ sid_ctx_length: c_uint, ++ sid_ctx: [c_uchar; ::SSL_MAX_SID_CTX_LENGTH as usize], ++ peer: *mut ::X509, ++ verify_result: c_long, ++ timeout: c_long, ++ time: time_t, ++ pub references: c_int, ++ cipher: *const ::SSL_CIPHER, ++ cipher_id: c_long, ++ ciphers: *mut stack_st_SSL_CIPHER, ++ tlsext_hostname: *mut c_char, ++ tlsext_tick: *mut c_uchar, ++ tlsext_ticklen: size_t, ++ tlsext_tick_lifetime_int: c_long, ++ internal: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct X509_VERIFY_PARAM { ++ pub name: *mut c_char, ++ pub check_time: time_t, ++ pub inh_flags: c_ulong, ++ pub flags: c_ulong, ++ pub purpose: c_int, ++ pub trust: c_int, ++ pub depth: c_int, ++ policies: *mut stack_st_ASN1_OBJECT, ++ id: *mut c_void, ++} diff --cc vendor/openssl-sys-0.9.19/src/ossl10x.rs index 000000000,000000000..b5adb8282 new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/src/ossl10x.rs @@@ -1,0 -1,0 +1,985 @@@ ++use std::sync::{Mutex, MutexGuard}; ++use std::sync::{Once, ONCE_INIT}; ++use std::mem; ++use std::ptr; ++use std::process; ++use std::io::{self, Write}; ++ ++use libc::{c_int, c_char, c_void, c_long, c_uchar, size_t, c_uint, c_ulong}; ++#[cfg(not(ossl101))] ++use libc::time_t; ++ ++#[repr(C)] ++pub struct stack_st_ASN1_OBJECT { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_X509 { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_X509_NAME { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_X509_ATTRIBUTE { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_X509_EXTENSION { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_GENERAL_NAME { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_void { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_SSL_CIPHER { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct stack_st_OPENSSL_STRING { ++ pub stack: _STACK, ++} ++ ++#[repr(C)] ++pub struct _STACK { ++ pub num: c_int, ++ pub data: *mut *mut c_char, ++ pub sorted: c_int, ++ pub num_alloc: c_int, ++ pub comp: Option c_int>, ++} ++ ++#[repr(C)] ++pub struct BIO_METHOD { ++ pub type_: c_int, ++ pub name: *const c_char, ++ pub bwrite: Option c_int>, ++ pub bread: Option c_int>, ++ pub bputs: Option c_int>, ++ pub bgets: Option c_int>, ++ pub ctrl: Option c_long>, ++ pub create: Option c_int>, ++ pub destroy: Option c_int>, ++ pub callback_ctrl: Option c_long>, ++} ++ ++#[repr(C)] ++pub struct RSA { ++ pub pad: c_int, ++ pub version: c_long, ++ pub meth: *const ::RSA_METHOD, ++ ++ pub engine: *mut ::ENGINE, ++ pub n: *mut ::BIGNUM, ++ pub e: *mut ::BIGNUM, ++ pub d: *mut ::BIGNUM, ++ pub p: *mut ::BIGNUM, ++ pub q: *mut ::BIGNUM, ++ pub dmp1: *mut ::BIGNUM, ++ pub dmq1: *mut ::BIGNUM, ++ pub iqmp: *mut ::BIGNUM, ++ ++ pub ex_data: ::CRYPTO_EX_DATA, ++ pub references: c_int, ++ pub flags: c_int, ++ ++ pub _method_mod_n: *mut ::BN_MONT_CTX, ++ pub _method_mod_p: *mut ::BN_MONT_CTX, ++ pub _method_mod_q: *mut ::BN_MONT_CTX, ++ ++ pub bignum_data: *mut c_char, ++ pub blinding: *mut ::BN_BLINDING, ++ pub mt_blinding: *mut ::BN_BLINDING, ++} ++ ++#[repr(C)] ++pub struct DSA { ++ pub pad: c_int, ++ pub version: c_long, ++ pub write_params: c_int, ++ ++ pub p: *mut ::BIGNUM, ++ pub q: *mut ::BIGNUM, ++ pub g: *mut ::BIGNUM, ++ pub pub_key: *mut ::BIGNUM, ++ pub priv_key: *mut ::BIGNUM, ++ pub kinv: *mut ::BIGNUM, ++ pub r: *mut ::BIGNUM, ++ ++ pub flags: c_int, ++ pub method_mont_p: *mut ::BN_MONT_CTX, ++ pub references: c_int, ++ pub ex_data: ::CRYPTO_EX_DATA, ++ pub meth: *const ::DSA_METHOD, ++ pub engine: *mut ::ENGINE, ++} ++ ++#[repr(C)] ++pub struct EVP_PKEY { ++ pub type_: c_int, ++ pub save_type: c_int, ++ pub references: c_int, ++ pub ameth: *const ::EVP_PKEY_ASN1_METHOD, ++ pub engine: *mut ::ENGINE, ++ pub pkey: *mut c_void, ++ pub save_parameters: c_int, ++ pub attributes: *mut stack_st_X509_ATTRIBUTE, ++} ++ ++#[repr(C)] ++pub struct BIO { ++ pub method: *mut ::BIO_METHOD, ++ pub callback: Option< ++ unsafe extern "C" fn(*mut ::BIO, ++ c_int, ++ *const c_char, ++ c_int, ++ c_long, ++ c_long) ++ -> c_long, ++ >, ++ pub cb_arg: *mut c_char, ++ pub init: c_int, ++ pub shutdown: c_int, ++ pub flags: c_int, ++ pub retry_reason: c_int, ++ pub num: c_int, ++ pub ptr: *mut c_void, ++ pub next_bio: *mut ::BIO, ++ pub prev_bio: *mut ::BIO, ++ pub references: c_int, ++ pub num_read: c_ulong, ++ pub num_write: c_ulong, ++ pub ex_data: ::CRYPTO_EX_DATA, ++} ++ ++#[repr(C)] ++pub struct CRYPTO_EX_DATA { ++ pub sk: *mut ::stack_st_void, ++ pub dummy: c_int, ++} ++ ++#[repr(C)] ++pub struct EVP_MD_CTX { ++ digest: *mut ::EVP_MD, ++ engine: *mut ::ENGINE, ++ flags: c_ulong, ++ md_data: *mut c_void, ++ pctx: *mut ::EVP_PKEY_CTX, ++ update: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct EVP_CIPHER { ++ pub nid: c_int, ++ pub block_size: c_int, ++ pub key_len: c_int, ++ pub iv_len: c_int, ++ pub flags: c_ulong, ++ pub init: Option< ++ unsafe extern "C" fn(*mut ::EVP_CIPHER_CTX, ++ *const c_uchar, ++ *const c_uchar, ++ c_int) ++ -> c_int, ++ >, ++ pub do_cipher: Option< ++ unsafe extern "C" fn(*mut ::EVP_CIPHER_CTX, ++ *mut c_uchar, ++ *const c_uchar, ++ size_t) ++ -> c_int, ++ >, ++ pub cleanup: Option c_int>, ++ pub ctx_size: c_int, ++ pub set_asn1_parameters: ++ Option c_int>, ++ pub get_asn1_parameters: ++ Option c_int>, ++ pub ctrl: ++ Option c_int>, ++ pub app_data: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct HMAC_CTX { ++ md: *mut ::EVP_MD, ++ md_ctx: ::EVP_MD_CTX, ++ i_ctx: ::EVP_MD_CTX, ++ o_ctx: ::EVP_MD_CTX, ++ key_length: c_uint, ++ key: [c_uchar; 128], ++} ++ ++#[repr(C)] ++pub struct BIGNUM { ++ pub d: *mut ::BN_ULONG, ++ pub top: c_int, ++ pub dmax: c_int, ++ pub neg: c_int, ++ pub flags: c_int, ++} ++ ++#[repr(C)] ++pub struct DH { ++ pub pad: c_int, ++ pub version: c_int, ++ pub p: *mut ::BIGNUM, ++ pub g: *mut ::BIGNUM, ++ pub length: c_long, ++ pub pub_key: *mut ::BIGNUM, ++ pub priv_key: *mut ::BIGNUM, ++ pub flags: c_int, ++ pub method_mont_p: *mut ::BN_MONT_CTX, ++ pub q: *mut ::BIGNUM, ++ pub j: *mut ::BIGNUM, ++ pub seed: *mut c_uchar, ++ pub seedlen: c_int, ++ pub counter: *mut ::BIGNUM, ++ pub references: c_int, ++ pub ex_data: ::CRYPTO_EX_DATA, ++ pub meth: *const ::DH_METHOD, ++ pub engine: *mut ::ENGINE, ++} ++ ++#[repr(C)] ++pub struct X509 { ++ pub cert_info: *mut X509_CINF, ++ pub sig_alg: *mut ::X509_ALGOR, ++ pub signature: *mut ::ASN1_BIT_STRING, ++ pub valid: c_int, ++ pub references: c_int, ++ pub name: *mut c_char, ++ pub ex_data: ::CRYPTO_EX_DATA, ++ pub ex_pathlen: c_long, ++ pub ex_pcpathlen: c_long, ++ pub ex_flags: c_ulong, ++ pub ex_kusage: c_ulong, ++ pub ex_xkusage: c_ulong, ++ pub ex_nscert: c_ulong, ++ skid: *mut c_void, ++ akid: *mut c_void, ++ policy_cache: *mut c_void, ++ crldp: *mut c_void, ++ altname: *mut c_void, ++ nc: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_RFC3779"))] ++ rfc3779_addr: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_RFC3779"))] ++ rfc3779_asid: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_SHA"))] ++ sha1_hash: [c_uchar; 20], ++ aux: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct X509_CINF { ++ version: *mut c_void, ++ serialNumber: *mut c_void, ++ signature: *mut c_void, ++ issuer: *mut c_void, ++ pub validity: *mut X509_VAL, ++ subject: *mut c_void, ++ key: *mut c_void, ++ issuerUID: *mut c_void, ++ subjectUID: *mut c_void, ++ pub extensions: *mut stack_st_X509_EXTENSION, ++ enc: ASN1_ENCODING, ++} ++ ++#[repr(C)] ++pub struct X509_ALGOR { ++ pub algorithm: *mut ::ASN1_OBJECT, ++ parameter: *mut c_void, ++} ++ ++#[repr(C)] ++pub struct ASN1_ENCODING { ++ pub enc: *mut c_uchar, ++ pub len: c_long, ++ pub modified: c_int, ++} ++ ++#[repr(C)] ++pub struct X509_VAL { ++ pub notBefore: *mut ::ASN1_TIME, ++ pub notAfter: *mut ::ASN1_TIME, ++} ++ ++#[repr(C)] ++pub struct X509_REQ_INFO { ++ pub enc: ASN1_ENCODING, ++ pub version: *mut ::ASN1_INTEGER, ++ pub subject: *mut ::X509_NAME, ++ pubkey: *mut c_void, ++ pub attributes: *mut stack_st_X509_ATTRIBUTE, ++} ++ ++#[repr(C)] ++pub struct X509_REQ { ++ pub req_info: *mut X509_REQ_INFO, ++ sig_alg: *mut c_void, ++ signature: *mut c_void, ++ references: c_int, ++} ++ ++#[repr(C)] ++pub struct SSL { ++ version: c_int, ++ type_: c_int, ++ method: *const ::SSL_METHOD, ++ rbio: *mut c_void, ++ wbio: *mut c_void, ++ bbio: *mut c_void, ++ rwstate: c_int, ++ in_handshake: c_int, ++ handshake_func: Option c_int>, ++ pub server: c_int, ++ new_session: c_int, ++ quiet_session: c_int, ++ shutdown: c_int, ++ state: c_int, ++ rstate: c_int, ++ init_buf: *mut c_void, ++ init_msg: *mut c_void, ++ init_num: c_int, ++ init_off: c_int, ++ packet: *mut c_uchar, ++ packet_length: c_uint, ++ s2: *mut c_void, ++ s3: *mut c_void, ++ d1: *mut c_void, ++ read_ahead: c_int, ++ msg_callback: Option< ++ unsafe extern "C" fn(c_int, ++ c_int, ++ c_int, ++ *const c_void, ++ size_t, ++ *mut SSL, ++ *mut c_void), ++ >, ++ msg_callback_arg: *mut c_void, ++ hit: c_int, ++ param: *mut c_void, ++ cipher_list: *mut stack_st_SSL_CIPHER, ++ cipher_list_by_id: *mut stack_st_SSL_CIPHER, ++ mac_flags: c_int, ++ enc_read_ctx: *mut ::EVP_CIPHER_CTX, ++ read_hash: *mut ::EVP_MD_CTX, ++ expand: *mut c_void, ++ enc_write_ctx: *mut ::EVP_CIPHER_CTX, ++ write_hash: *mut ::EVP_MD_CTX, ++ compress: *mut c_void, ++ cert: *mut c_void, ++ sid_ctx_length: c_uint, ++ sid_ctx: [c_uchar; ::SSL_MAX_SID_CTX_LENGTH as usize], ++ session: *mut ::SSL_SESSION, ++ generate_session_id: ::GEN_SESSION_CB, ++ verify_mode: c_int, ++ verify_callback: Option c_int>, ++ info_callback: Option, ++ error: c_int, ++ error_code: c_int, ++ #[cfg(not(osslconf = "OPENSSL_NO_KRB5"))] ++ kssl_ctx: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))] ++ psk_client_callback: Option< ++ unsafe extern "C" fn(*mut SSL, ++ *const c_char, ++ *mut c_char, ++ c_uint, ++ *mut c_uchar, ++ c_uint) ++ -> c_uint, ++ >, ++ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))] ++ psk_server_callback: ++ Option c_uint>, ++ ctx: *mut ::SSL_CTX, ++ debug: c_int, ++ verify_result: c_long, ++ ex_data: ::CRYPTO_EX_DATA, ++ client_CA: *mut stack_st_X509_NAME, ++ references: c_int, ++ options: c_ulong, ++ mode: c_ulong, ++ max_cert_list: c_long, ++ first_packet: c_int, ++ client_version: c_int, ++ max_send_fragment: c_uint, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_debug_cb: ++ Option, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_debug_arg: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_hostname: *mut c_char, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ servername_done: c_int, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_status_type: c_int, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_status_expected: c_int, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_ocsp_ids: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_ocsp_exts: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_ocsp_resp: *mut c_uchar, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_ocsp_resplen: c_int, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_ticket_expected: c_int, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC")))] ++ tlsext_ecpointformatlist_length: size_t, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC")))] ++ tlsext_ecpointformatlist: *mut c_uchar, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC")))] ++ tlsext_ellipticcurvelist_length: size_t, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC")))] ++ tlsext_ellipticcurvelist: *mut c_uchar, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_opaque_prf_input: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_opaque_prf_input_len: size_t, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_session_ticket: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_session_ticket_ext_cb: ::tls_session_ticket_ext_cb_fn, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tls_session_ticket_ext_cb_arg: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tls_session_secret_cb: ::tls_session_secret_cb_fn, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tls_session_secret_cb_arg: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ initial_ctx: *mut ::SSL_CTX, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_NEXTPROTONEG")))] ++ next_proto_negotiated: *mut c_uchar, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_NEXTPROTONEG")))] ++ next_proto_negotiated_len: c_uchar, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ srtp_profiles: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ srtp_profile: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_heartbeat: c_uint, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_hb_pending: c_uint, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_hb_seq: c_uint, ++ renegotiate: c_int, ++ #[cfg(not(osslconf = "OPENSSL_NO_SRP"))] ++ srp_ctx: ::SRP_CTX, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), ossl102))] ++ alpn_client_proto_list: *mut c_uchar, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), ossl102))] ++ alpn_client_proto_list_len: c_uint, ++} ++ ++#[repr(C)] ++pub struct SSL_CTX { ++ method: *mut c_void, ++ cipher_list: *mut c_void, ++ cipher_list_by_id: *mut c_void, ++ cert_store: *mut c_void, ++ sessions: *mut c_void, ++ session_cache_size: c_ulong, ++ session_cache_head: *mut c_void, ++ session_cache_tail: *mut c_void, ++ session_cache_mode: c_int, ++ session_timeout: c_long, ++ new_session_cb: *mut c_void, ++ remove_session_cb: *mut c_void, ++ get_session_cb: *mut c_void, ++ stats: [c_int; 11], ++ pub references: c_int, ++ app_verify_callback: *mut c_void, ++ app_verify_arg: *mut c_void, ++ default_passwd_callback: *mut c_void, ++ default_passwd_callback_userdata: *mut c_void, ++ client_cert_cb: *mut c_void, ++ app_gen_cookie_cb: *mut c_void, ++ app_verify_cookie_cb: *mut c_void, ++ ex_dat: ::CRYPTO_EX_DATA, ++ rsa_md5: *mut c_void, ++ md5: *mut c_void, ++ sha1: *mut c_void, ++ extra_certs: *mut c_void, ++ comp_methods: *mut c_void, ++ info_callback: *mut c_void, ++ client_CA: *mut c_void, ++ options: c_ulong, ++ mode: c_ulong, ++ max_cert_list: c_long, ++ cert: *mut c_void, ++ read_ahead: c_int, ++ msg_callback: *mut c_void, ++ msg_callback_arg: *mut c_void, ++ verify_mode: c_int, ++ sid_ctx_length: c_uint, ++ sid_ctx: [c_uchar; 32], ++ default_verify_callback: *mut c_void, ++ generate_session_id: *mut c_void, ++ param: *mut c_void, ++ quiet_shutdown: c_int, ++ max_send_fragment: c_uint, ++ ++ #[cfg(not(osslconf = "OPENSSL_NO_ENGINE"))] ++ client_cert_engine: *mut c_void, ++ ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_servername_callback: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsect_servername_arg: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_tick_key_name: [c_uchar; 16], ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_tick_hmac_key: [c_uchar; 16], ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_tick_aes_key: [c_uchar; 16], ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_ticket_key_cb: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_status_cb: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_status_arg: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_opaque_prf_input_callback: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_opaque_prf_input_callback_arg: *mut c_void, ++ ++ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))] ++ psk_identity_hint: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))] ++ psk_client_callback: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))] ++ psk_server_callback: *mut c_void, ++ ++ #[cfg(not(osslconf = "OPENSSL_NO_BUF_FREELISTS"))] ++ freelist_max_len: c_uint, ++ #[cfg(not(osslconf = "OPENSSL_NO_BUF_FREELISTS"))] ++ wbuf_freelist: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_BUF_FREELISTS"))] ++ rbuf_freelist: *mut c_void, ++ ++ #[cfg(not(osslconf = "OPENSSL_NO_SRP"))] ++ srp_ctx: SRP_CTX, ++ ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_NEXTPROTONEG")))] ++ next_protos_advertised_cb: *mut c_void, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_NEXTPROTONEG")))] ++ next_protos_advertised_cb_arg: *mut c_void, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_NEXTPROTONEG")))] ++ next_proto_select_cb: *mut c_void, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_NEXTPROTONEG")))] ++ next_proto_select_cb_arg: *mut c_void, ++ ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), ossl101))] ++ srtp_profiles: *mut c_void, ++ ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), ossl102))] ++ srtp_profiles: *mut c_void, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), ossl102))] ++ alpn_select_cb: *mut c_void, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), ossl102))] ++ alpn_select_cb_arg: *mut c_void, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), ossl102))] ++ alpn_client_proto_list: *mut c_void, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), ossl102))] ++ alpn_client_proto_list_len: c_uint, ++ ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC"), ossl102))] ++ tlsext_ecpointformatlist_length: size_t, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC"), ossl102))] ++ tlsext_ecpointformatlist: *mut c_uchar, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC"), ossl102))] ++ tlsext_ellipticcurvelist_length: size_t, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC"), ossl102))] ++ tlsext_ellipticcurvelist: *mut c_uchar, ++} ++ ++#[repr(C)] ++pub struct SSL_SESSION { ++ ssl_version: c_int, ++ key_arg_length: c_uint, ++ key_arg: [c_uchar; SSL_MAX_KEY_ARG_LENGTH as usize], ++ pub master_key_length: c_int, ++ pub master_key: [c_uchar; 48], ++ session_id_length: c_uint, ++ session_id: [c_uchar; SSL_MAX_SSL_SESSION_ID_LENGTH as usize], ++ sid_ctx_length: c_uint, ++ sid_ctx: [c_uchar; SSL_MAX_SID_CTX_LENGTH as usize], ++ #[cfg(not(osslconf = "OPENSSL_NO_KRB5"))] ++ krb5_client_princ_len: c_uint, ++ #[cfg(not(osslconf = "OPENSSL_NO_KRB5"))] ++ krb5_client_princ: [c_uchar; SSL_MAX_KRB5_PRINCIPAL_LENGTH as usize], ++ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))] ++ psk_identity_hint: *mut c_char, ++ #[cfg(not(osslconf = "OPENSSL_NO_PSK"))] ++ psk_identity: *mut c_char, ++ not_resumable: c_int, ++ sess_cert: *mut c_void, ++ peer: *mut X509, ++ verify_result: c_long, ++ pub references: c_int, ++ timeout: c_long, ++ time: c_long, ++ compress_meth: c_uint, ++ cipher: *const c_void, ++ cipher_id: c_ulong, ++ ciphers: *mut c_void, ++ ex_data: ::CRYPTO_EX_DATA, ++ prev: *mut c_void, ++ next: *mut c_void, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_hostname: *mut c_char, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC")))] ++ tlsext_ecpointformatlist_length: size_t, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC")))] ++ tlsext_ecpointformatlist: *mut c_uchar, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC")))] ++ tlsext_ellipticcurvelist_length: size_t, ++ #[cfg(all(not(osslconf = "OPENSSL_NO_TLSEXT"), not(osslconf = "OPENSSL_NO_EC")))] ++ tlsext_ellipticcurvelist: *mut c_uchar, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_tick: *mut c_uchar, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_ticklen: size_t, ++ #[cfg(not(osslconf = "OPENSSL_NO_TLSEXT"))] ++ tlsext_tick_lifetime_hint: c_long, ++ #[cfg(not(osslconf = "OPENSSL_NO_SRP"))] ++ srp_username: *mut c_char, ++} ++ ++#[repr(C)] ++pub struct SRP_CTX { ++ SRP_cb_arg: *mut c_void, ++ TLS_ext_srp_username_callback: *mut c_void, ++ SRP_verify_param_callback: *mut c_void, ++ SRP_give_srp_client_pwd_callback: *mut c_void, ++ login: *mut c_void, ++ N: *mut c_void, ++ g: *mut c_void, ++ s: *mut c_void, ++ B: *mut c_void, ++ A: *mut c_void, ++ a: *mut c_void, ++ b: *mut c_void, ++ v: *mut c_void, ++ info: *mut c_void, ++ stringth: c_int, ++ srp_Mask: c_ulong, ++} ++ ++#[repr(C)] ++#[cfg(not(ossl101))] ++pub struct X509_VERIFY_PARAM { ++ pub name: *mut c_char, ++ pub check_time: time_t, ++ pub inh_flags: c_ulong, ++ pub flags: c_ulong, ++ pub purpose: c_int, ++ pub trust: c_int, ++ pub depth: c_int, ++ pub policies: *mut stack_st_ASN1_OBJECT, ++ pub id: *mut X509_VERIFY_PARAM_ID, ++} ++ ++#[cfg(not(ossl101))] ++pub enum X509_VERIFY_PARAM_ID {} ++pub enum PKCS12 {} ++ ++pub const SSL_CTRL_GET_SESSION_REUSED: c_int = 8; ++pub const SSL_CTRL_OPTIONS: c_int = 32; ++pub const SSL_CTRL_CLEAR_OPTIONS: c_int = 77; ++#[cfg(ossl102)] ++pub const SSL_CTRL_SET_ECDH_AUTO: c_int = 94; ++ ++pub const SSL_OP_MICROSOFT_SESS_ID_BUG: c_ulong = 0x00000001; ++pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: c_ulong = 0x00000002; ++pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: c_ulong = 0x00000008; ++pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: c_ulong = 0x00000020; ++pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: c_ulong = 0x00000080; ++pub const SSL_OP_TLS_D5_BUG: c_ulong = 0x00000100; ++pub const SSL_OP_TLS_BLOCK_PADDING_BUG: c_ulong = 0x00000200; ++pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x00080000; ++pub const SSL_OP_SINGLE_DH_USE: c_ulong = 0x00100000; ++pub const SSL_OP_NO_SSLv2: c_ulong = 0x01000000; ++ ++pub const SSL_MAX_SSL_SESSION_ID_LENGTH: c_int = 32; ++pub const SSL_MAX_SID_CTX_LENGTH: c_int = 32; ++pub const SSL_MAX_KEY_ARG_LENGTH: c_int = 8; ++pub const SSL_MAX_MASTER_KEY_LENGTH: c_int = 48; ++pub const SSL_MAX_KRB5_PRINCIPAL_LENGTH: c_int = 256; ++ ++pub const SSLEAY_VERSION: c_int = 0; ++pub const SSLEAY_CFLAGS: c_int = 2; ++pub const SSLEAY_BUILT_ON: c_int = 3; ++pub const SSLEAY_PLATFORM: c_int = 4; ++pub const SSLEAY_DIR: c_int = 5; ++ ++pub const CRYPTO_LOCK_X509: c_int = 3; ++pub const CRYPTO_LOCK_SSL_CTX: c_int = 12; ++pub const CRYPTO_LOCK_SSL_SESSION: c_int = 14; ++ ++static mut MUTEXES: *mut Vec> = 0 as *mut Vec>; ++static mut GUARDS: *mut Vec>> = 0 as ++ *mut Vec>>; ++ ++unsafe extern "C" fn locking_function(mode: c_int, n: c_int, _file: *const c_char, _line: c_int) { ++ let mutex = &(*MUTEXES)[n as usize]; ++ ++ if mode & ::CRYPTO_LOCK != 0 { ++ (*GUARDS)[n as usize] = Some(mutex.lock().unwrap()); ++ } else { ++ if let None = (*GUARDS)[n as usize].take() { ++ let _ = writeln!( ++ io::stderr(), ++ "BUG: rust-openssl lock {} already unlocked, aborting", ++ n ++ ); ++ process::abort(); ++ } ++ } ++} ++ ++pub fn init() { ++ static INIT: Once = ONCE_INIT; ++ ++ INIT.call_once(|| unsafe { ++ SSL_library_init(); ++ SSL_load_error_strings(); ++ OPENSSL_add_all_algorithms_noconf(); ++ ++ let num_locks = ::CRYPTO_num_locks(); ++ let mut mutexes = Box::new(Vec::new()); ++ for _ in 0..num_locks { ++ mutexes.push(Mutex::new(())); ++ } ++ MUTEXES = mem::transmute(mutexes); ++ let guards: Box>>> = ++ Box::new((0..num_locks).map(|_| None).collect()); ++ GUARDS = mem::transmute(guards); ++ ++ CRYPTO_set_locking_callback(locking_function); ++ set_id_callback(); ++ }) ++} ++ ++#[cfg(unix)] ++fn set_id_callback() { ++ unsafe extern "C" fn thread_id() -> c_ulong { ++ ::libc::pthread_self() as c_ulong ++ } ++ ++ unsafe { ++ CRYPTO_set_id_callback(thread_id); ++ } ++} ++ ++#[cfg(not(unix))] ++fn set_id_callback() {} ++ ++// macros ++ ++#[cfg(ossl102)] ++pub unsafe fn SSL_CTX_set_ecdh_auto(ctx: *mut SSL_CTX, onoff: c_int) -> c_int { ++ ::SSL_CTX_ctrl( ++ ctx, ++ SSL_CTRL_SET_ECDH_AUTO, ++ onoff as c_long, ++ ptr::null_mut(), ++ ) as c_int ++} ++ ++#[cfg(ossl102)] ++pub unsafe fn SSL_set_ecdh_auto(ssl: *mut ::SSL, onoff: c_int) -> c_int { ++ ::SSL_ctrl( ++ ssl, ++ SSL_CTRL_SET_ECDH_AUTO, ++ onoff as c_long, ++ ptr::null_mut(), ++ ) as c_int ++} ++ ++pub unsafe fn SSL_session_reused(ssl: *mut ::SSL) -> c_int { ++ ::SSL_ctrl(ssl, SSL_CTRL_GET_SESSION_REUSED, 0, ptr::null_mut()) as c_int ++} ++ ++extern "C" { ++ pub fn BIO_new(type_: *mut BIO_METHOD) -> *mut BIO; ++ pub fn BIO_s_file() -> *mut BIO_METHOD; ++ pub fn BIO_s_mem() -> *mut BIO_METHOD; ++ ++ pub fn get_rfc2409_prime_768(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc2409_prime_1024(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_1536(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_2048(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_3072(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_4096(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_6144(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn get_rfc3526_prime_8192(bn: *mut BIGNUM) -> *mut BIGNUM; ++ ++ pub fn CRYPTO_malloc(num: c_int, file: *const c_char, line: c_int) -> *mut c_void; ++ pub fn CRYPTO_free(buf: *mut c_void); ++ pub fn CRYPTO_num_locks() -> c_int; ++ pub fn CRYPTO_set_locking_callback( ++ func: unsafe extern "C" fn(mode: c_int, n: c_int, file: *const c_char, line: c_int), ++ ); ++ pub fn CRYPTO_set_id_callback(func: unsafe extern "C" fn() -> c_ulong); ++ ++ pub fn ERR_load_crypto_strings(); ++ ++ pub fn RSA_generate_key( ++ modsz: c_int, ++ e: c_ulong, ++ cb: Option, ++ cbarg: *mut c_void, ++ ) -> *mut RSA; ++ ++ pub fn OCSP_cert_to_id( ++ dgst: *const ::EVP_MD, ++ subject: *mut ::X509, ++ issuer: *mut ::X509, ++ ) -> *mut ::OCSP_CERTID; ++ ++ pub fn PKCS12_create( ++ pass: *mut c_char, ++ friendly_name: *mut c_char, ++ pkey: *mut EVP_PKEY, ++ cert: *mut X509, ++ ca: *mut stack_st_X509, ++ nid_key: c_int, ++ nid_cert: c_int, ++ iter: c_int, ++ mac_iter: c_int, ++ keytype: c_int, ++ ) -> *mut PKCS12; ++ ++ pub fn SSL_library_init() -> c_int; ++ pub fn SSL_load_error_strings(); ++ pub fn OPENSSL_add_all_algorithms_noconf(); ++ pub fn HMAC_CTX_init(ctx: *mut ::HMAC_CTX); ++ pub fn HMAC_CTX_cleanup(ctx: *mut ::HMAC_CTX); ++ #[cfg(not(osslconf = "OPENSSL_NO_SSL3_METHOD"))] ++ pub fn SSLv3_method() -> *const ::SSL_METHOD; ++ pub fn TLSv1_method() -> *const ::SSL_METHOD; ++ pub fn SSLv23_method() -> *const ::SSL_METHOD; ++ pub fn TLSv1_1_method() -> *const ::SSL_METHOD; ++ pub fn TLSv1_2_method() -> *const ::SSL_METHOD; ++ pub fn DTLSv1_method() -> *const ::SSL_METHOD; ++ #[cfg(ossl102)] ++ pub fn DTLSv1_2_method() -> *const ::SSL_METHOD; ++ pub fn SSL_get_ex_new_index( ++ argl: c_long, ++ argp: *mut c_void, ++ new_func: Option<::CRYPTO_EX_new>, ++ dup_func: Option<::CRYPTO_EX_dup>, ++ free_func: Option<::CRYPTO_EX_free>, ++ ) -> c_int; ++ pub fn SSL_set_tmp_ecdh_callback( ++ ssl: *mut ::SSL, ++ ecdh: unsafe extern "C" fn(ssl: *mut ::SSL, is_export: c_int, keylength: c_int) ++ -> *mut ::EC_KEY, ++ ); ++ pub fn SSL_CIPHER_get_version(cipher: *const ::SSL_CIPHER) -> *mut c_char; ++ pub fn SSL_CTX_get_ex_new_index( ++ argl: c_long, ++ argp: *mut c_void, ++ new_func: Option<::CRYPTO_EX_new>, ++ dup_func: Option<::CRYPTO_EX_dup>, ++ free_func: Option<::CRYPTO_EX_free>, ++ ) -> c_int; ++ pub fn SSL_CTX_set_tmp_ecdh_callback( ++ ctx: *mut ::SSL_CTX, ++ ecdh: unsafe extern "C" fn(ssl: *mut ::SSL, is_export: c_int, keylength: c_int) ++ -> *mut ::EC_KEY, ++ ); ++ pub fn X509_get_subject_name(x: *mut ::X509) -> *mut ::X509_NAME; ++ pub fn X509_set_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int; ++ pub fn X509_set_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int; ++ pub fn X509_get_ext_d2i( ++ x: *mut ::X509, ++ nid: c_int, ++ crit: *mut c_int, ++ idx: *mut c_int, ++ ) -> *mut c_void; ++ pub fn X509_NAME_add_entry_by_NID( ++ x: *mut ::X509_NAME, ++ field: c_int, ++ ty: c_int, ++ bytes: *mut c_uchar, ++ len: c_int, ++ loc: c_int, ++ set: c_int, ++ ) -> c_int; ++ #[cfg(not(ossl101))] ++ pub fn X509_get0_signature( ++ psig: *mut *mut ::ASN1_BIT_STRING, ++ palg: *mut *mut ::X509_ALGOR, ++ x: *const ::X509, ++ ); ++ #[cfg(not(ossl101))] ++ pub fn X509_get_signature_nid(x: *const X509) -> c_int; ++ #[cfg(not(ossl101))] ++ pub fn X509_ALGOR_get0( ++ paobj: *mut *mut ::ASN1_OBJECT, ++ pptype: *mut c_int, ++ ppval: *mut *mut c_void, ++ alg: *mut ::X509_ALGOR, ++ ); ++ pub fn X509_NAME_get_entry(n: *mut ::X509_NAME, loc: c_int) -> *mut ::X509_NAME_ENTRY; ++ pub fn X509_NAME_ENTRY_get_data(ne: *mut ::X509_NAME_ENTRY) -> *mut ::ASN1_STRING; ++ pub fn X509_STORE_CTX_get_chain(ctx: *mut ::X509_STORE_CTX) -> *mut stack_st_X509; ++ pub fn X509V3_EXT_nconf_nid( ++ conf: *mut ::CONF, ++ ctx: *mut ::X509V3_CTX, ++ ext_nid: c_int, ++ value: *mut c_char, ++ ) -> *mut ::X509_EXTENSION; ++ pub fn X509V3_EXT_nconf( ++ conf: *mut ::CONF, ++ ctx: *mut ::X509V3_CTX, ++ name: *mut c_char, ++ value: *mut c_char, ++ ) -> *mut ::X509_EXTENSION; ++ pub fn ASN1_STRING_to_UTF8(out: *mut *mut c_uchar, s: *mut ::ASN1_STRING) -> c_int; ++ pub fn ASN1_STRING_data(x: *mut ::ASN1_STRING) -> *mut c_uchar; ++ pub fn CRYPTO_add_lock( ++ pointer: *mut c_int, ++ amount: c_int, ++ type_: c_int, ++ file: *const c_char, ++ line: c_int, ++ ) -> c_int; ++ pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX; ++ pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX); ++ pub fn EVP_PKEY_bits(key: *mut EVP_PKEY) -> c_int; ++ ++ pub fn sk_new_null() -> *mut _STACK; ++ pub fn sk_num(st: *const _STACK) -> c_int; ++ pub fn sk_value(st: *const _STACK, n: c_int) -> *mut c_void; ++ pub fn sk_free(st: *mut _STACK); ++ pub fn sk_push(st: *mut _STACK, data: *mut c_void) -> c_int; ++ pub fn sk_pop_free(st: *mut _STACK, free: Option); ++ pub fn sk_pop(st: *mut _STACK) -> *mut c_void; ++ ++ pub fn SSLeay() -> c_ulong; ++ pub fn SSLeay_version(key: c_int) -> *const c_char; ++} diff --cc vendor/openssl-sys-0.9.19/src/ossl110.rs index 000000000,000000000..ff1e0c7ca new file mode 100644 --- /dev/null +++ b/vendor/openssl-sys-0.9.19/src/ossl110.rs @@@ -1,0 -1,0 +1,285 @@@ ++use libc::{c_int, c_void, c_char, c_uchar, c_ulong, c_long, c_uint, size_t}; ++use std::sync::{Once, ONCE_INIT}; ++use std::ptr; ++ ++pub enum BIGNUM {} ++pub enum BIO {} ++pub enum BIO_METHOD {} ++pub enum CRYPTO_EX_DATA {} ++pub enum DH {} ++pub enum DSA {} ++pub enum EVP_CIPHER {} ++pub enum EVP_MD_CTX {} ++pub enum EVP_PKEY {} ++pub enum HMAC_CTX {} ++pub enum OPENSSL_STACK {} ++pub enum PKCS12 {} ++pub enum RSA {} ++pub enum SSL {} ++pub enum SSL_CTX {} ++pub enum SSL_SESSION {} ++pub enum stack_st_ASN1_OBJECT {} ++pub enum stack_st_GENERAL_NAME {} ++pub enum stack_st_OPENSSL_STRING {} ++pub enum stack_st_void {} ++pub enum stack_st_X509 {} ++pub enum stack_st_X509_NAME {} ++pub enum stack_st_X509_ATTRIBUTE {} ++pub enum stack_st_X509_EXTENSION {} ++pub enum stack_st_SSL_CIPHER {} ++pub enum OPENSSL_INIT_SETTINGS {} ++pub enum X509 {} ++pub enum X509_ALGOR {} ++pub enum X509_VERIFY_PARAM {} ++pub enum X509_REQ {} ++ ++pub const SSL_OP_MICROSOFT_SESS_ID_BUG: c_ulong = 0x00000000; ++pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: c_ulong = 0x00000000; ++pub const SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: c_ulong = 0x00000000; ++pub const SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: c_ulong = 0x00000000; ++pub const SSL_OP_SSLEAY_080_CLIENT_DH_BUG: c_ulong = 0x00000000; ++pub const SSL_OP_TLS_D5_BUG: c_ulong = 0x00000000; ++pub const SSL_OP_TLS_BLOCK_PADDING_BUG: c_ulong = 0x00000000; ++pub const SSL_OP_SINGLE_ECDH_USE: c_ulong = 0x00000000; ++pub const SSL_OP_SINGLE_DH_USE: c_ulong = 0x00000000; ++pub const SSL_OP_NO_SSLv2: c_ulong = 0x00000000; ++ ++pub const OPENSSL_VERSION: c_int = 0; ++pub const OPENSSL_CFLAGS: c_int = 1; ++pub const OPENSSL_BUILT_ON: c_int = 2; ++pub const OPENSSL_PLATFORM: c_int = 3; ++pub const OPENSSL_DIR: c_int = 4; ++ ++pub const CRYPTO_EX_INDEX_SSL: c_int = 0; ++pub const CRYPTO_EX_INDEX_SSL_CTX: c_int = 1; ++ ++pub const OPENSSL_INIT_LOAD_SSL_STRINGS: u64 = 0x00200000; ++ ++pub const X509_CHECK_FLAG_NEVER_CHECK_SUBJECT: c_uint = 0x20; ++ ++pub fn init() { ++ // explicitly initialize to work around https://github.com/openssl/openssl/issues/3505 ++ static INIT: Once = ONCE_INIT; ++ ++ INIT.call_once(|| unsafe { ++ OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, ptr::null_mut()); ++ }) ++} ++ ++extern "C" { ++ pub fn BIO_new(type_: *const BIO_METHOD) -> *mut BIO; ++ pub fn BIO_s_file() -> *const BIO_METHOD; ++ pub fn BIO_s_mem() -> *const BIO_METHOD; ++ ++ pub fn BN_get_rfc2409_prime_768(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn BN_get_rfc2409_prime_1024(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn BN_get_rfc3526_prime_1536(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn BN_get_rfc3526_prime_2048(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn BN_get_rfc3526_prime_3072(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn BN_get_rfc3526_prime_4096(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn BN_get_rfc3526_prime_6144(bn: *mut BIGNUM) -> *mut BIGNUM; ++ pub fn BN_get_rfc3526_prime_8192(bn: *mut BIGNUM) -> *mut BIGNUM; ++ ++ pub fn CRYPTO_malloc(num: size_t, file: *const c_char, line: c_int) -> *mut c_void; ++ pub fn CRYPTO_free(buf: *mut c_void, file: *const c_char, line: c_int); ++ ++ pub fn EVP_chacha20() -> *const ::EVP_CIPHER; ++ pub fn EVP_chacha20_poly1305() -> *const ::EVP_CIPHER; ++ ++ pub fn HMAC_CTX_new() -> *mut HMAC_CTX; ++ pub fn HMAC_CTX_free(ctx: *mut HMAC_CTX); ++ ++ pub fn OCSP_cert_to_id( ++ dgst: *const ::EVP_MD, ++ subject: *const ::X509, ++ issuer: *const ::X509, ++ ) -> *mut ::OCSP_CERTID; ++ ++ pub fn TLS_method() -> *const ::SSL_METHOD; ++ pub fn DTLS_method() -> *const ::SSL_METHOD; ++ pub fn SSL_CIPHER_get_version(cipher: *const ::SSL_CIPHER) -> *const c_char; ++ pub fn X509_get_subject_name(x: *const ::X509) -> *mut ::X509_NAME; ++ pub fn X509_set1_notAfter(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int; ++ pub fn X509_set1_notBefore(x: *mut ::X509, tm: *const ::ASN1_TIME) -> c_int; ++ pub fn X509_get_ext_d2i( ++ x: *const ::X509, ++ nid: c_int, ++ crit: *mut c_int, ++ idx: *mut c_int, ++ ) -> *mut c_void; ++ pub fn X509_NAME_add_entry_by_NID( ++ x: *mut ::X509_NAME, ++ field: c_int, ++ ty: c_int, ++ bytes: *const c_uchar, ++ len: c_int, ++ loc: c_int, ++ set: c_int, ++ ) -> c_int; ++ pub fn X509_get_signature_nid(x: *const X509) -> c_int; ++ pub fn X509_ALGOR_get0( ++ paobj: *mut *const ::ASN1_OBJECT, ++ pptype: *mut c_int, ++ ppval: *mut *const c_void, ++ alg: *const ::X509_ALGOR, ++ ); ++ pub fn X509_NAME_get_entry(n: *const ::X509_NAME, loc: c_int) -> *mut ::X509_NAME_ENTRY; ++ pub fn X509_NAME_ENTRY_get_data(ne: *const ::X509_NAME_ENTRY) -> *mut ::ASN1_STRING; ++ pub fn X509V3_EXT_nconf_nid( ++ conf: *mut ::CONF, ++ ctx: *mut ::X509V3_CTX, ++ ext_nid: c_int, ++ value: *const c_char, ++ ) -> *mut ::X509_EXTENSION; ++ pub fn X509V3_EXT_nconf( ++ conf: *mut ::CONF, ++ ctx: *mut ::X509V3_CTX, ++ name: *const c_char, ++ value: *const c_char, ++ ) -> *mut ::X509_EXTENSION; ++ pub fn ASN1_STRING_to_UTF8(out: *mut *mut c_uchar, s: *const ::ASN1_STRING) -> c_int; ++ pub fn BN_is_negative(b: *const ::BIGNUM) -> c_int; ++ pub fn EVP_CIPHER_key_length(cipher: *const EVP_CIPHER) -> c_int; ++ pub fn EVP_CIPHER_block_size(cipher: *const EVP_CIPHER) -> c_int; ++ pub fn EVP_CIPHER_iv_length(cipher: *const EVP_CIPHER) -> c_int; ++ pub fn EVP_PBE_scrypt( ++ pass: *const c_char, ++ passlen: size_t, ++ salt: *const c_uchar, ++ saltlen: size_t, ++ N: u64, ++ r: u64, ++ p: u64, ++ maxmem: u64, ++ key: *mut c_uchar, ++ keylen: size_t, ++ ) -> c_int; ++ pub fn DSA_get0_pqg( ++ d: *const ::DSA, ++ p: *mut *const ::BIGNUM, ++ q: *mut *const ::BIGNUM, ++ q: *mut *const ::BIGNUM, ++ ); ++ pub fn DSA_get0_key( ++ d: *const ::DSA, ++ pub_key: *mut *const ::BIGNUM, ++ priv_key: *mut *const ::BIGNUM, ++ ); ++ pub fn RSA_get0_key( ++ r: *const ::RSA, ++ n: *mut *const ::BIGNUM, ++ e: *mut *const ::BIGNUM, ++ d: *mut *const ::BIGNUM, ++ ); ++ pub fn RSA_get0_factors(r: *const ::RSA, p: *mut *const ::BIGNUM, q: *mut *const ::BIGNUM); ++ pub fn RSA_set0_key( ++ r: *mut ::RSA, ++ n: *mut ::BIGNUM, ++ e: *mut ::BIGNUM, ++ d: *mut ::BIGNUM, ++ ) -> c_int; ++ pub fn RSA_set0_factors(r: *mut ::RSA, p: *mut ::BIGNUM, q: *mut ::BIGNUM) -> c_int; ++ pub fn RSA_set0_crt_params( ++ r: *mut ::RSA, ++ dmp1: *mut ::BIGNUM, ++ dmq1: *mut ::BIGNUM, ++ iqmp: *mut ::BIGNUM, ++ ) -> c_int; ++ pub fn ASN1_STRING_get0_data(x: *const ::ASN1_STRING) -> *const c_uchar; ++ pub fn OPENSSL_sk_num(stack: *const ::OPENSSL_STACK) -> c_int; ++ pub fn OPENSSL_sk_value(stack: *const ::OPENSSL_STACK, idx: c_int) -> *mut c_void; ++ pub fn SSL_CTX_get_options(ctx: *const ::SSL_CTX) -> c_ulong; ++ pub fn SSL_CTX_set_options(ctx: *mut ::SSL_CTX, op: c_ulong) -> c_ulong; ++ pub fn SSL_CTX_clear_options(ctx: *mut ::SSL_CTX, op: c_ulong) -> c_ulong; ++ pub fn X509_getm_notAfter(x: *const ::X509) -> *mut ::ASN1_TIME; ++ pub fn X509_getm_notBefore(x: *const ::X509) -> *mut ::ASN1_TIME; ++ pub fn X509_get0_signature( ++ psig: *mut *const ::ASN1_BIT_STRING, ++ palg: *mut *const ::X509_ALGOR, ++ x: *const ::X509, ++ ); ++ pub fn DH_set0_pqg( ++ dh: *mut ::DH, ++ p: *mut ::BIGNUM, ++ q: *mut ::BIGNUM, ++ g: *mut ::BIGNUM, ++ ) -> c_int; ++ pub fn BIO_set_init(a: *mut ::BIO, init: c_int); ++ pub fn BIO_set_data(a: *mut ::BIO, data: *mut c_void); ++ pub fn BIO_get_data(a: *mut ::BIO) -> *mut c_void; ++ pub fn BIO_meth_new(type_: c_int, name: *const c_char) -> *mut ::BIO_METHOD; ++ pub fn BIO_meth_free(biom: *mut ::BIO_METHOD); ++ pub fn BIO_meth_set_write( ++ biom: *mut ::BIO_METHOD, ++ write: unsafe extern "C" fn(*mut ::BIO, *const c_char, c_int) -> c_int, ++ ) -> c_int; ++ pub fn BIO_meth_set_read( ++ biom: *mut ::BIO_METHOD, ++ read: unsafe extern "C" fn(*mut ::BIO, *mut c_char, c_int) -> c_int, ++ ) -> c_int; ++ pub fn BIO_meth_set_puts( ++ biom: *mut ::BIO_METHOD, ++ read: unsafe extern "C" fn(*mut ::BIO, *const c_char) -> c_int, ++ ) -> c_int; ++ pub fn BIO_meth_set_ctrl( ++ biom: *mut ::BIO_METHOD, ++ read: unsafe extern "C" fn(*mut ::BIO, c_int, c_long, *mut c_void) -> c_long, ++ ) -> c_int; ++ pub fn BIO_meth_set_create( ++ biom: *mut ::BIO_METHOD, ++ create: unsafe extern "C" fn(*mut ::BIO) -> c_int, ++ ) -> c_int; ++ pub fn BIO_meth_set_destroy( ++ biom: *mut ::BIO_METHOD, ++ destroy: unsafe extern "C" fn(*mut ::BIO) -> c_int, ++ ) -> c_int; ++ pub fn CRYPTO_get_ex_new_index( ++ class_index: c_int, ++ argl: c_long, ++ argp: *mut c_void, ++ new_func: Option<::CRYPTO_EX_new>, ++ dup_func: Option<::CRYPTO_EX_dup>, ++ free_func: Option<::CRYPTO_EX_free>, ++ ) -> c_int; ++ pub fn X509_up_ref(x: *mut X509) -> c_int; ++ pub fn SSL_CTX_up_ref(x: *mut SSL_CTX) -> c_int; ++ pub fn SSL_session_reused(ssl: *mut SSL) -> c_int; ++ pub fn SSL_SESSION_get_master_key( ++ session: *const SSL_SESSION, ++ out: *mut c_uchar, ++ outlen: size_t, ++ ) -> size_t; ++ pub fn SSL_SESSION_up_ref(ses: *mut SSL_SESSION) -> c_int; ++ pub fn X509_get0_extensions(req: *const ::X509) -> *const stack_st_X509_EXTENSION; ++ pub fn X509_STORE_CTX_get0_chain(ctx: *mut ::X509_STORE_CTX) -> *mut stack_st_X509; ++ pub fn EVP_MD_CTX_new() -> *mut EVP_MD_CTX; ++ pub fn EVP_MD_CTX_free(ctx: *mut EVP_MD_CTX); ++ pub fn EVP_PKEY_bits(key: *const EVP_PKEY) -> c_int; ++ ++ pub fn OpenSSL_version_num() -> c_ulong; ++ pub fn OpenSSL_version(key: c_int) -> *const c_char; ++ pub fn OPENSSL_init_ssl(opts: u64, settings: *const OPENSSL_INIT_SETTINGS) -> c_int; ++ pub fn OPENSSL_sk_new_null() -> *mut ::OPENSSL_STACK; ++ pub fn OPENSSL_sk_free(st: *mut ::OPENSSL_STACK); ++ pub fn OPENSSL_sk_pop_free( ++ st: *mut ::OPENSSL_STACK, ++ free: Option, ++ ); ++ pub fn OPENSSL_sk_push(st: *mut ::OPENSSL_STACK, data: *const c_void) -> c_int; ++ pub fn OPENSSL_sk_pop(st: *mut ::OPENSSL_STACK) -> *mut c_void; ++ ++ pub fn PKCS12_create( ++ pass: *const c_char, ++ friendly_name: *const c_char, ++ pkey: *mut EVP_PKEY, ++ cert: *mut X509, ++ ca: *mut stack_st_X509, ++ nid_key: c_int, ++ nid_cert: c_int, ++ iter: c_int, ++ mac_iter: c_int, ++ keytype: c_int, ++ ) -> *mut PKCS12; ++ pub fn X509_REQ_get_version(req: *const X509_REQ) -> c_long; ++ pub fn X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut ::X509_NAME; ++} diff --cc vendor/redox_syscall-0.1.31/.cargo-checksum.json index 000000000,000000000..beb61d35e new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509"} diff --cc vendor/redox_syscall-0.1.31/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/.cargo-ok diff --cc vendor/redox_syscall-0.1.31/Cargo.toml index 000000000,000000000..6b6523f61 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/Cargo.toml @@@ -1,0 -1,0 +1,23 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "redox_syscall" ++version = "0.1.31" ++authors = ["Jeremy Soller "] ++description = "A Rust library to access raw Redox system calls" ++documentation = "https://docs.rs/redox_syscall" ++license = "MIT" ++repository = "https://github.com/redox-os/syscall" ++ ++[lib] ++name = "syscall" diff --cc vendor/redox_syscall-0.1.31/LICENSE index 000000000,000000000..1292bb7fb new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/LICENSE @@@ -1,0 -1,0 +1,22 @@@ ++Copyright (c) 2017 Redox OS Developers ++ ++MIT License ++ ++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 --cc vendor/redox_syscall-0.1.31/README.md index 000000000,000000000..d45ec258c new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/README.md @@@ -1,0 -1,0 +1,7 @@@ ++[Redox OS][1]'s syscall API ++ ++[Documentation][2] ++ ++[1]: https://github.com/redox-os/redox ++[2]: https://docs.rs/redox_syscall ++ diff --cc vendor/redox_syscall-0.1.31/src/arch/arm.rs index 000000000,000000000..e640f7ed3 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/arch/arm.rs @@@ -1,0 -1,0 +1,73 @@@ ++use super::error::{Error, Result}; ++ ++pub unsafe fn syscall0(mut a: usize) -> Result { ++ asm!("swi $$0" ++ : "={r0}"(a) ++ : "{r7}"(a) ++ : "memory" ++ : "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall1(mut a: usize, b: usize) -> Result { ++ asm!("swi $$0" ++ : "={r0}"(a) ++ : "{r7}"(a), "{r0}"(b) ++ : "memory" ++ : "volatile"); ++ ++ Error::demux(a) ++} ++ ++// Clobbers all registers - special for clone ++pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result { ++ asm!("swi $$0" ++ : "={r0}"(a) ++ : "{r7}"(a), "{r0}"(b) ++ : "memory", "r0", "r1", "r2", "r3", "r4" ++ : "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result { ++ asm!("swi $$0" ++ : "={r0}"(a) ++ : "{r7}"(a), "{r0}"(b), "{r1}"(c) ++ : "memory" ++ : "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result { ++ asm!("swi $$0" ++ : "={r0}"(a) ++ : "{r7}"(a), "{r0}"(b), "{r1}"(c), "{r2}"(d) ++ : "memory" ++ : "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result { ++ asm!("swi $$0" ++ : "={r0}"(a) ++ : "{r7}"(a), "{r0}"(b), "{r1}"(c), "{r2}"(d), "{r3}"(e) ++ : "memory" ++ : "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) ++ -> Result { ++ asm!("swi $$0" ++ : "={r0}"(a) ++ : "{r7}"(a), "{r0}"(b), "{r1}"(c), "{r2}"(d), "{r3}"(e), "{r4}"(f) ++ : "memory" ++ : "volatile"); ++ ++ Error::demux(a) ++} diff --cc vendor/redox_syscall-0.1.31/src/arch/x86.rs index 000000000,000000000..0cd6409bb new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/arch/x86.rs @@@ -1,0 -1,0 +1,73 @@@ ++use super::error::{Error, Result}; ++ ++pub unsafe fn syscall0(mut a: usize) -> Result { ++ asm!("int 0x80" ++ : "={eax}"(a) ++ : "{eax}"(a) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall1(mut a: usize, b: usize) -> Result { ++ asm!("int 0x80" ++ : "={eax}"(a) ++ : "{eax}"(a), "{ebx}"(b) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++// Clobbers all registers - special for clone ++pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result { ++ asm!("int 0x80" ++ : "={eax}"(a) ++ : "{eax}"(a), "{ebx}"(b) ++ : "memory", "ebx", "ecx", "edx", "esi", "edi" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result { ++ asm!("int 0x80" ++ : "={eax}"(a) ++ : "{eax}"(a), "{ebx}"(b), "{ecx}"(c) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result { ++ asm!("int 0x80" ++ : "={eax}"(a) ++ : "{eax}"(a), "{ebx}"(b), "{ecx}"(c), "{edx}"(d) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result { ++ asm!("int 0x80" ++ : "={eax}"(a) ++ : "{eax}"(a), "{ebx}"(b), "{ecx}"(c), "{edx}"(d), "{esi}"(e) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) ++ -> Result { ++ asm!("int 0x80" ++ : "={eax}"(a) ++ : "{eax}"(a), "{ebx}"(b), "{ecx}"(c), "{edx}"(d), "{esi}"(e), "{edi}"(f) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} diff --cc vendor/redox_syscall-0.1.31/src/arch/x86_64.rs index 000000000,000000000..52ad01bd4 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/arch/x86_64.rs @@@ -1,0 -1,0 +1,74 @@@ ++use super::error::{Error, Result}; ++ ++pub unsafe fn syscall0(mut a: usize) -> Result { ++ asm!("int 0x80" ++ : "={rax}"(a) ++ : "{rax}"(a) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall1(mut a: usize, b: usize) -> Result { ++ asm!("int 0x80" ++ : "={rax}"(a) ++ : "{rax}"(a), "{rbx}"(b) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++// Clobbers all registers - special for clone ++pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result { ++ asm!("int 0x80" ++ : "={rax}"(a) ++ : "{rax}"(a), "{rbx}"(b) ++ : "memory", "rbx", "rcx", "rdx", "rsi", "rdi", "r8", ++ "r9", "r10", "r11", "r12", "r13", "r14", "r15" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result { ++ asm!("int 0x80" ++ : "={rax}"(a) ++ : "{rax}"(a), "{rbx}"(b), "{rcx}"(c) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result { ++ asm!("int 0x80" ++ : "={rax}"(a) ++ : "{rax}"(a), "{rbx}"(b), "{rcx}"(c), "{rdx}"(d) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result { ++ asm!("int 0x80" ++ : "={rax}"(a) ++ : "{rax}"(a), "{rbx}"(b), "{rcx}"(c), "{rdx}"(d), "{rsi}"(e) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} ++ ++pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) ++ -> Result { ++ asm!("int 0x80" ++ : "={rax}"(a) ++ : "{rax}"(a), "{rbx}"(b), "{rcx}"(c), "{rdx}"(d), "{rsi}"(e), "{rdi}"(f) ++ : "memory" ++ : "intel", "volatile"); ++ ++ Error::demux(a) ++} diff --cc vendor/redox_syscall-0.1.31/src/call.rs index 000000000,000000000..9dd081a77 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/call.rs @@@ -1,0 -1,0 +1,334 @@@ ++use super::arch::*; ++use super::data::{SigAction, Stat, StatVfs, TimeSpec}; ++use super::error::Result; ++use super::number::*; ++ ++use core::{mem, ptr}; ++ ++// Signal restorer ++extern "C" fn restorer() -> ! { ++ sigreturn().unwrap(); ++ unreachable!(); ++} ++ ++/// Set the end of the process's heap ++/// ++/// When `addr` is `0`, this function will return the current break. ++/// ++/// When `addr` is nonzero, this function will attempt to set the end of the process's ++/// heap to `addr` and return the new program break. The new program break should be ++/// checked by the allocator, it may not be exactly `addr`, as it may be aligned to a page ++/// boundary. ++/// ++/// On error, `Err(ENOMEM)` will be returned indicating that no memory is available ++pub unsafe fn brk(addr: usize) -> Result { ++ syscall1(SYS_BRK, addr) ++} ++ ++/// Change the process's working directory ++/// ++/// This function will attempt to set the process's working directory to `path`, which can be ++/// either a relative, scheme relative, or absolute path. ++/// ++/// On success, `Ok(0)` will be returned. On error, one of the following errors will be returned. ++/// ++/// # Errors ++/// ++/// * `EACCES` - permission is denied for one of the components of `path`, or `path` ++/// * `EFAULT` - `path` does not point to the process's addressible memory ++/// * `EIO` - an I/O error occurred ++/// * `ENOENT` - `path` does not exit ++/// * `ENOTDIR` - `path` is not a directory ++pub fn chdir>(path: T) -> Result { ++ unsafe { syscall2(SYS_CHDIR, path.as_ref().as_ptr() as usize, path.as_ref().len()) } ++} ++ ++pub fn chmod>(path: T, mode: usize) -> Result { ++ unsafe { syscall3(SYS_CHMOD, path.as_ref().as_ptr() as usize, path.as_ref().len(), mode) } ++} ++ ++/// Produce a fork of the current process, or a new process thread ++pub unsafe fn clone(flags: usize) -> Result { ++ syscall1_clobber(SYS_CLONE, flags) ++} ++ ++/// Close a file ++pub fn close(fd: usize) -> Result { ++ unsafe { syscall1(SYS_CLOSE, fd) } ++} ++ ++/// Get the current system time ++pub fn clock_gettime(clock: usize, tp: &mut TimeSpec) -> Result { ++ unsafe { syscall2(SYS_CLOCK_GETTIME, clock, tp as *mut TimeSpec as usize) } ++} ++ ++/// Copy and transform a file descriptor ++pub fn dup(fd: usize, buf: &[u8]) -> Result { ++ unsafe { syscall3(SYS_DUP, fd, buf.as_ptr() as usize, buf.len()) } ++} ++ ++/// Copy and transform a file descriptor ++pub fn dup2(fd: usize, newfd: usize, buf: &[u8]) -> Result { ++ unsafe { syscall4(SYS_DUP2, fd, newfd, buf.as_ptr() as usize, buf.len()) } ++} ++ ++/// Replace the current process with a new executable ++pub fn execve>(path: T, args: &[[usize; 2]]) -> Result { ++ unsafe { syscall4(SYS_EXECVE, path.as_ref().as_ptr() as usize, ++ path.as_ref().len(), args.as_ptr() as usize, args.len()) } ++} ++ ++/// Exit the current process ++pub fn exit(status: usize) -> Result { ++ unsafe { syscall1(SYS_EXIT, status) } ++} ++ ++/// Register a file for event-based I/O ++pub fn fcntl(fd: usize, cmd: usize, arg: usize) -> Result { ++ unsafe { syscall3(SYS_FCNTL, fd, cmd, arg) } ++} ++ ++/// Register a file for event-based I/O ++pub fn fevent(fd: usize, flags: usize) -> Result { ++ unsafe { syscall2(SYS_FEVENT, fd, flags) } ++} ++ ++/// Map a file into memory ++pub unsafe fn fmap(fd: usize, offset: usize, size: usize) -> Result { ++ syscall3(SYS_FMAP, fd, offset, size) ++} ++ ++/// Unmap a memory-mapped file ++pub unsafe fn funmap(addr: usize) -> Result { ++ syscall1(SYS_FUNMAP, addr) ++} ++ ++/// Retrieve the canonical path of a file ++pub fn fpath(fd: usize, buf: &mut [u8]) -> Result { ++ unsafe { syscall3(SYS_FPATH, fd, buf.as_mut_ptr() as usize, buf.len()) } ++} ++ ++/// Get metadata about a file ++pub fn fstat(fd: usize, stat: &mut Stat) -> Result { ++ unsafe { syscall3(SYS_FSTAT, fd, stat as *mut Stat as usize, mem::size_of::()) } ++} ++ ++/// Get metadata about a filesystem ++pub fn fstatvfs(fd: usize, stat: &mut StatVfs) -> Result { ++ unsafe { syscall3(SYS_FSTATVFS, fd, stat as *mut StatVfs as usize, mem::size_of::()) } ++} ++ ++/// Sync a file descriptor to its underlying medium ++pub fn fsync(fd: usize) -> Result { ++ unsafe { syscall1(SYS_FSYNC, fd) } ++} ++ ++/// Truncate or extend a file to a specified length ++pub fn ftruncate(fd: usize, len: usize) -> Result { ++ unsafe { syscall2(SYS_FTRUNCATE, fd, len) } ++} ++ ++// Change modify and/or access times ++pub fn futimens(fd: usize, times: &[TimeSpec]) -> Result { ++ unsafe { syscall3(SYS_FUTIMENS, fd, times.as_ptr() as usize, times.len() * mem::size_of::()) } ++} ++ ++/// Fast userspace mutex ++pub unsafe fn futex(addr: *mut i32, op: usize, val: i32, val2: usize, addr2: *mut i32) ++ -> Result { ++ syscall5(SYS_FUTEX, addr as usize, op, (val as isize) as usize, val2, addr2 as usize) ++} ++ ++/// Get the current working directory ++pub fn getcwd(buf: &mut [u8]) -> Result { ++ unsafe { syscall2(SYS_GETCWD, buf.as_mut_ptr() as usize, buf.len()) } ++} ++ ++/// Get the effective group ID ++pub fn getegid() -> Result { ++ unsafe { syscall0(SYS_GETEGID) } ++} ++ ++/// Get the effective namespace ++pub fn getens() -> Result { ++ unsafe { syscall0(SYS_GETENS) } ++} ++ ++/// Get the effective user ID ++pub fn geteuid() -> Result { ++ unsafe { syscall0(SYS_GETEUID) } ++} ++ ++/// Get the current group ID ++pub fn getgid() -> Result { ++ unsafe { syscall0(SYS_GETGID) } ++} ++ ++/// Get the current namespace ++pub fn getns() -> Result { ++ unsafe { syscall0(SYS_GETNS) } ++} ++ ++/// Get the current process ID ++pub fn getpid() -> Result { ++ unsafe { syscall0(SYS_GETPID) } ++} ++ ++/// Get the process group ID ++pub fn getpgid(pid: usize) -> Result { ++ unsafe { syscall1(SYS_GETPGID, pid) } ++} ++ ++/// Get the parent process ID ++pub fn getppid() -> Result { ++ unsafe { syscall0(SYS_GETPPID) } ++} ++ ++/// Get the current user ID ++pub fn getuid() -> Result { ++ unsafe { syscall0(SYS_GETUID) } ++} ++ ++/// Set the I/O privilege level ++pub unsafe fn iopl(level: usize) -> Result { ++ syscall1(SYS_IOPL, level) ++} ++ ++/// Send a signal `sig` to the process identified by `pid` ++pub fn kill(pid: usize, sig: usize) -> Result { ++ unsafe { syscall2(SYS_KILL, pid, sig) } ++} ++ ++/// Create a link to a file ++pub unsafe fn link(old: *const u8, new: *const u8) -> Result { ++ syscall2(SYS_LINK, old as usize, new as usize) ++} ++ ++/// Seek to `offset` bytes in a file descriptor ++pub fn lseek(fd: usize, offset: isize, whence: usize) -> Result { ++ unsafe { syscall3(SYS_LSEEK, fd, offset as usize, whence) } ++} ++ ++/// Make a new scheme namespace ++pub fn mkns(schemes: &[[usize; 2]]) -> Result { ++ unsafe { syscall2(SYS_MKNS, schemes.as_ptr() as usize, schemes.len()) } ++} ++ ++/// Sleep for the time specified in `req` ++pub fn nanosleep(req: &TimeSpec, rem: &mut TimeSpec) -> Result { ++ unsafe { syscall2(SYS_NANOSLEEP, req as *const TimeSpec as usize, ++ rem as *mut TimeSpec as usize) } ++} ++ ++/// Open a file ++pub fn open>(path: T, flags: usize) -> Result { ++ unsafe { syscall3(SYS_OPEN, path.as_ref().as_ptr() as usize, path.as_ref().len(), flags) } ++} ++ ++/// Allocate pages, linearly in physical memory ++pub unsafe fn physalloc(size: usize) -> Result { ++ syscall1(SYS_PHYSALLOC, size) ++} ++ ++/// Free physically allocated pages ++pub unsafe fn physfree(physical_address: usize, size: usize) -> Result { ++ syscall2(SYS_PHYSFREE, physical_address, size) ++} ++ ++/// Map physical memory to virtual memory ++pub unsafe fn physmap(physical_address: usize, size: usize, flags: usize) -> Result { ++ syscall3(SYS_PHYSMAP, physical_address, size, flags) ++} ++ ++/// Unmap previously mapped physical memory ++pub unsafe fn physunmap(virtual_address: usize) -> Result { ++ syscall1(SYS_PHYSUNMAP, virtual_address) ++} ++ ++/// Create a pair of file descriptors referencing the read and write ends of a pipe ++pub fn pipe2(fds: &mut [usize; 2], flags: usize) -> Result { ++ unsafe { syscall2(SYS_PIPE2, fds.as_ptr() as usize, flags) } ++} ++ ++/// Read from a file descriptor into a buffer ++pub fn read(fd: usize, buf: &mut [u8]) -> Result { ++ unsafe { syscall3(SYS_READ, fd, buf.as_mut_ptr() as usize, buf.len()) } ++} ++ ++/// Remove a directory ++pub fn rmdir>(path: T) -> Result { ++ unsafe { syscall2(SYS_RMDIR, path.as_ref().as_ptr() as usize, path.as_ref().len()) } ++} ++ ++/// Set the process group ID ++pub fn setpgid(pid: usize, pgid: usize) -> Result { ++ unsafe { syscall2(SYS_SETPGID, pid, pgid) } ++} ++ ++/// Set the current process group IDs ++pub fn setregid(rgid: usize, egid: usize) -> Result { ++ unsafe { syscall2(SYS_SETREGID, rgid, egid) } ++} ++ ++/// Make a new scheme namespace ++pub fn setrens(rns: usize, ens: usize) -> Result { ++ unsafe { syscall2(SYS_SETRENS, rns, ens) } ++} ++ ++/// Set the current process user IDs ++pub fn setreuid(ruid: usize, euid: usize) -> Result { ++ unsafe { syscall2(SYS_SETREUID, ruid, euid) } ++} ++ ++/// Set up a signal handler ++pub fn sigaction(sig: usize, act: Option<&SigAction>, oldact: Option<&mut SigAction>) -> Result { ++ unsafe { syscall4(SYS_SIGACTION, sig, ++ act.map(|x| x as *const _).unwrap_or_else(ptr::null) as usize, ++ oldact.map(|x| x as *mut _).unwrap_or_else(ptr::null_mut) as usize, ++ restorer as usize) } ++} ++ ++// Return from signal handler ++pub fn sigreturn() -> Result { ++ unsafe { syscall0(SYS_SIGRETURN) } ++} ++ ++/// Remove a file ++pub fn unlink>(path: T) -> Result { ++ unsafe { syscall2(SYS_UNLINK, path.as_ref().as_ptr() as usize, path.as_ref().len()) } ++} ++ ++/// Convert a virtual address to a physical one ++pub unsafe fn virttophys(virtual_address: usize) -> Result { ++ syscall1(SYS_VIRTTOPHYS, virtual_address) ++} ++ ++/// Check if a child process has exited or received a signal ++pub fn waitpid(pid: usize, status: &mut usize, options: usize) -> Result { ++ unsafe { syscall3(SYS_WAITPID, pid, status as *mut usize as usize, options) } ++} ++ ++/// Write a buffer to a file descriptor ++/// ++/// The kernel will attempt to write the bytes in `buf` to the file descriptor `fd`, returning ++/// either an `Err`, explained below, or `Ok(count)` where `count` is the number of bytes which ++/// were written. ++/// ++/// # Errors ++/// ++/// * `EAGAIN` - the file descriptor was opened with `O_NONBLOCK` and writing would block ++/// * `EBADF` - the file descriptor is not valid or is not open for writing ++/// * `EFAULT` - `buf` does not point to the process's addressible memory ++/// * `EIO` - an I/O error occurred ++/// * `ENOSPC` - the device containing the file descriptor has no room for data ++/// * `EPIPE` - the file descriptor refers to a pipe or socket whose reading end is closed ++pub fn write(fd: usize, buf: &[u8]) -> Result { ++ unsafe { syscall3(SYS_WRITE, fd, buf.as_ptr() as usize, buf.len()) } ++} ++ ++/// Yield the process's time slice to the kernel ++/// ++/// This function will return Ok(0) on success ++pub fn sched_yield() -> Result { ++ unsafe { syscall0(SYS_YIELD) } ++} diff --cc vendor/redox_syscall-0.1.31/src/data.rs index 000000000,000000000..8e0cff43f new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/data.rs @@@ -1,0 -1,0 +1,167 @@@ ++use core::ops::{Deref, DerefMut}; ++use core::{mem, slice}; ++ ++#[derive(Copy, Clone, Debug, Default)] ++pub struct Event { ++ pub id: usize, ++ pub flags: usize, ++ pub data: usize ++} ++ ++impl Deref for Event { ++ type Target = [u8]; ++ fn deref(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts(self as *const Event as *const u8, mem::size_of::()) as &[u8] ++ } ++ } ++} ++ ++impl DerefMut for Event { ++ fn deref_mut(&mut self) -> &mut [u8] { ++ unsafe { ++ slice::from_raw_parts_mut(self as *mut Event as *mut u8, mem::size_of::()) as &mut [u8] ++ } ++ } ++} ++ ++#[derive(Copy, Clone, Debug, Default)] ++#[repr(C)] ++pub struct Packet { ++ pub id: u64, ++ pub pid: usize, ++ pub uid: u32, ++ pub gid: u32, ++ pub a: usize, ++ pub b: usize, ++ pub c: usize, ++ pub d: usize ++} ++ ++impl Deref for Packet { ++ type Target = [u8]; ++ fn deref(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts(self as *const Packet as *const u8, mem::size_of::()) as &[u8] ++ } ++ } ++} ++ ++impl DerefMut for Packet { ++ fn deref_mut(&mut self) -> &mut [u8] { ++ unsafe { ++ slice::from_raw_parts_mut(self as *mut Packet as *mut u8, mem::size_of::()) as &mut [u8] ++ } ++ } ++} ++ ++#[derive(Copy, Clone, Debug)] ++#[repr(C)] ++pub struct SigAction { ++ pub sa_handler: extern "C" fn(usize), ++ pub sa_mask: [u64; 2], ++ pub sa_flags: usize, ++} ++ ++impl Default for SigAction { ++ fn default() -> Self { ++ Self { ++ sa_handler: unsafe { mem::transmute(0usize) }, ++ sa_mask: [0; 2], ++ sa_flags: 0, ++ } ++ } ++} ++ ++#[derive(Copy, Clone, Debug, Default)] ++#[repr(C)] ++pub struct Stat { ++ pub st_dev: u64, ++ pub st_ino: u64, ++ pub st_mode: u16, ++ pub st_nlink: u32, ++ pub st_uid: u32, ++ pub st_gid: u32, ++ pub st_size: u64, ++ pub st_blksize: u32, ++ pub st_blocks: u64, ++ pub st_mtime: u64, ++ pub st_mtime_nsec: u32, ++ pub st_atime: u64, ++ pub st_atime_nsec: u32, ++ pub st_ctime: u64, ++ pub st_ctime_nsec: u32, ++} ++ ++impl Deref for Stat { ++ type Target = [u8]; ++ fn deref(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts(self as *const Stat as *const u8, ++ mem::size_of::()) as &[u8] ++ } ++ } ++} ++ ++impl DerefMut for Stat { ++ fn deref_mut(&mut self) -> &mut [u8] { ++ unsafe { ++ slice::from_raw_parts_mut(self as *mut Stat as *mut u8, ++ mem::size_of::()) as &mut [u8] ++ } ++ } ++} ++ ++#[derive(Copy, Clone, Debug, Default)] ++#[repr(C)] ++pub struct StatVfs { ++ pub f_bsize: u32, ++ pub f_blocks: u64, ++ pub f_bfree: u64, ++ pub f_bavail: u64, ++} ++ ++impl Deref for StatVfs { ++ type Target = [u8]; ++ fn deref(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts(self as *const StatVfs as *const u8, ++ mem::size_of::()) as &[u8] ++ } ++ } ++} ++ ++impl DerefMut for StatVfs { ++ fn deref_mut(&mut self) -> &mut [u8] { ++ unsafe { ++ slice::from_raw_parts_mut(self as *mut StatVfs as *mut u8, ++ mem::size_of::()) as &mut [u8] ++ } ++ } ++} ++ ++#[derive(Copy, Clone, Debug, Default)] ++#[repr(C)] ++pub struct TimeSpec { ++ pub tv_sec: i64, ++ pub tv_nsec: i32, ++} ++ ++impl Deref for TimeSpec { ++ type Target = [u8]; ++ fn deref(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts(self as *const TimeSpec as *const u8, ++ mem::size_of::()) as &[u8] ++ } ++ } ++} ++ ++impl DerefMut for TimeSpec { ++ fn deref_mut(&mut self) -> &mut [u8] { ++ unsafe { ++ slice::from_raw_parts_mut(self as *mut TimeSpec as *mut u8, ++ mem::size_of::()) as &mut [u8] ++ } ++ } ++} diff --cc vendor/redox_syscall-0.1.31/src/error.rs index 000000000,000000000..7cbcbe987 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/error.rs @@@ -1,0 -1,0 +1,315 @@@ ++use core::{fmt, result}; ++ ++#[derive(Eq, PartialEq)] ++pub struct Error { ++ pub errno: i32, ++} ++ ++pub type Result = result::Result; ++ ++impl Error { ++ pub fn new(errno: i32) -> Error { ++ Error { errno: errno } ++ } ++ ++ pub fn mux(result: Result) -> usize { ++ match result { ++ Ok(value) => value, ++ Err(error) => -error.errno as usize, ++ } ++ } ++ ++ pub fn demux(value: usize) -> Result { ++ let errno = -(value as i32); ++ if errno >= 1 && errno < STR_ERROR.len() as i32 { ++ Err(Error::new(errno)) ++ } else { ++ Ok(value) ++ } ++ } ++ ++ pub fn text(&self) -> &str { ++ if let Some(description) = STR_ERROR.get(self.errno as usize) { ++ description ++ } else { ++ "Unknown Error" ++ } ++ } ++} ++ ++impl fmt::Debug for Error { ++ fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> { ++ f.write_str(self.text()) ++ } ++} ++ ++impl fmt::Display for Error { ++ fn fmt(&self, f: &mut fmt::Formatter) -> result::Result<(), fmt::Error> { ++ f.write_str(self.text()) ++ } ++} ++ ++pub const EPERM: i32 = 1; /* Operation not permitted */ ++pub const ENOENT: i32 = 2; /* No such file or directory */ ++pub const ESRCH: i32 = 3; /* No such process */ ++pub const EINTR: i32 = 4; /* Interrupted system call */ ++pub const EIO: i32 = 5; /* I/O error */ ++pub const ENXIO: i32 = 6; /* No such device or address */ ++pub const E2BIG: i32 = 7; /* Argument list too long */ ++pub const ENOEXEC: i32 = 8; /* Exec format error */ ++pub const EBADF: i32 = 9; /* Bad file number */ ++pub const ECHILD: i32 = 10; /* No child processes */ ++pub const EAGAIN: i32 = 11; /* Try again */ ++pub const ENOMEM: i32 = 12; /* Out of memory */ ++pub const EACCES: i32 = 13; /* Permission denied */ ++pub const EFAULT: i32 = 14; /* Bad address */ ++pub const ENOTBLK: i32 = 15; /* Block device required */ ++pub const EBUSY: i32 = 16; /* Device or resource busy */ ++pub const EEXIST: i32 = 17; /* File exists */ ++pub const EXDEV: i32 = 18; /* Cross-device link */ ++pub const ENODEV: i32 = 19; /* No such device */ ++pub const ENOTDIR: i32 = 20; /* Not a directory */ ++pub const EISDIR: i32 = 21; /* Is a directory */ ++pub const EINVAL: i32 = 22; /* Invalid argument */ ++pub const ENFILE: i32 = 23; /* File table overflow */ ++pub const EMFILE: i32 = 24; /* Too many open files */ ++pub const ENOTTY: i32 = 25; /* Not a typewriter */ ++pub const ETXTBSY: i32 = 26; /* Text file busy */ ++pub const EFBIG: i32 = 27; /* File too large */ ++pub const ENOSPC: i32 = 28; /* No space left on device */ ++pub const ESPIPE: i32 = 29; /* Illegal seek */ ++pub const EROFS: i32 = 30; /* Read-only file system */ ++pub const EMLINK: i32 = 31; /* Too many links */ ++pub const EPIPE: i32 = 32; /* Broken pipe */ ++pub const EDOM: i32 = 33; /* Math argument out of domain of func */ ++pub const ERANGE: i32 = 34; /* Math result not representable */ ++pub const EDEADLK: i32 = 35; /* Resource deadlock would occur */ ++pub const ENAMETOOLONG: i32 = 36; /* File name too long */ ++pub const ENOLCK: i32 = 37; /* No record locks available */ ++pub const ENOSYS: i32 = 38; /* Function not implemented */ ++pub const ENOTEMPTY: i32 = 39; /* Directory not empty */ ++pub const ELOOP: i32 = 40; /* Too many symbolic links encountered */ ++pub const EWOULDBLOCK: i32 = 41; /* Operation would block */ ++pub const ENOMSG: i32 = 42; /* No message of desired type */ ++pub const EIDRM: i32 = 43; /* Identifier removed */ ++pub const ECHRNG: i32 = 44; /* Channel number out of range */ ++pub const EL2NSYNC: i32 = 45; /* Level 2 not synchronized */ ++pub const EL3HLT: i32 = 46; /* Level 3 halted */ ++pub const EL3RST: i32 = 47; /* Level 3 reset */ ++pub const ELNRNG: i32 = 48; /* Link number out of range */ ++pub const EUNATCH: i32 = 49; /* Protocol driver not attached */ ++pub const ENOCSI: i32 = 50; /* No CSI structure available */ ++pub const EL2HLT: i32 = 51; /* Level 2 halted */ ++pub const EBADE: i32 = 52; /* Invalid exchange */ ++pub const EBADR: i32 = 53; /* Invalid request descriptor */ ++pub const EXFULL: i32 = 54; /* Exchange full */ ++pub const ENOANO: i32 = 55; /* No anode */ ++pub const EBADRQC: i32 = 56; /* Invalid request code */ ++pub const EBADSLT: i32 = 57; /* Invalid slot */ ++pub const EDEADLOCK: i32 = 58; /* Resource deadlock would occur */ ++pub const EBFONT: i32 = 59; /* Bad font file format */ ++pub const ENOSTR: i32 = 60; /* Device not a stream */ ++pub const ENODATA: i32 = 61; /* No data available */ ++pub const ETIME: i32 = 62; /* Timer expired */ ++pub const ENOSR: i32 = 63; /* Out of streams resources */ ++pub const ENONET: i32 = 64; /* Machine is not on the network */ ++pub const ENOPKG: i32 = 65; /* Package not installed */ ++pub const EREMOTE: i32 = 66; /* Object is remote */ ++pub const ENOLINK: i32 = 67; /* Link has been severed */ ++pub const EADV: i32 = 68; /* Advertise error */ ++pub const ESRMNT: i32 = 69; /* Srmount error */ ++pub const ECOMM: i32 = 70; /* Communication error on send */ ++pub const EPROTO: i32 = 71; /* Protocol error */ ++pub const EMULTIHOP: i32 = 72; /* Multihop attempted */ ++pub const EDOTDOT: i32 = 73; /* RFS specific error */ ++pub const EBADMSG: i32 = 74; /* Not a data message */ ++pub const EOVERFLOW: i32 = 75; /* Value too large for defined data type */ ++pub const ENOTUNIQ: i32 = 76; /* Name not unique on network */ ++pub const EBADFD: i32 = 77; /* File descriptor in bad state */ ++pub const EREMCHG: i32 = 78; /* Remote address changed */ ++pub const ELIBACC: i32 = 79; /* Can not access a needed shared library */ ++pub const ELIBBAD: i32 = 80; /* Accessing a corrupted shared library */ ++pub const ELIBSCN: i32 = 81; /* .lib section in a.out corrupted */ ++pub const ELIBMAX: i32 = 82; /* Attempting to link in too many shared libraries */ ++pub const ELIBEXEC: i32 = 83; /* Cannot exec a shared library directly */ ++pub const EILSEQ: i32 = 84; /* Illegal byte sequence */ ++pub const ERESTART: i32 = 85; /* Interrupted system call should be restarted */ ++pub const ESTRPIPE: i32 = 86; /* Streams pipe error */ ++pub const EUSERS: i32 = 87; /* Too many users */ ++pub const ENOTSOCK: i32 = 88; /* Socket operation on non-socket */ ++pub const EDESTADDRREQ: i32 = 89; /* Destination address required */ ++pub const EMSGSIZE: i32 = 90; /* Message too long */ ++pub const EPROTOTYPE: i32 = 91; /* Protocol wrong type for socket */ ++pub const ENOPROTOOPT: i32 = 92; /* Protocol not available */ ++pub const EPROTONOSUPPORT: i32 = 93; /* Protocol not supported */ ++pub const ESOCKTNOSUPPORT: i32 = 94; /* Socket type not supported */ ++pub const EOPNOTSUPP: i32 = 95; /* Operation not supported on transport endpoint */ ++pub const EPFNOSUPPORT: i32 = 96; /* Protocol family not supported */ ++pub const EAFNOSUPPORT: i32 = 97; /* Address family not supported by protocol */ ++pub const EADDRINUSE: i32 = 98; /* Address already in use */ ++pub const EADDRNOTAVAIL: i32 = 99; /* Cannot assign requested address */ ++pub const ENETDOWN: i32 = 100; /* Network is down */ ++pub const ENETUNREACH: i32 = 101; /* Network is unreachable */ ++pub const ENETRESET: i32 = 102; /* Network dropped connection because of reset */ ++pub const ECONNABORTED: i32 = 103; /* Software caused connection abort */ ++pub const ECONNRESET: i32 = 104; /* Connection reset by peer */ ++pub const ENOBUFS: i32 = 105; /* No buffer space available */ ++pub const EISCONN: i32 = 106; /* Transport endpoint is already connected */ ++pub const ENOTCONN: i32 = 107; /* Transport endpoint is not connected */ ++pub const ESHUTDOWN: i32 = 108; /* Cannot send after transport endpoint shutdown */ ++pub const ETOOMANYREFS: i32 = 109; /* Too many references: cannot splice */ ++pub const ETIMEDOUT: i32 = 110; /* Connection timed out */ ++pub const ECONNREFUSED: i32 = 111; /* Connection refused */ ++pub const EHOSTDOWN: i32 = 112; /* Host is down */ ++pub const EHOSTUNREACH: i32 = 113; /* No route to host */ ++pub const EALREADY: i32 = 114; /* Operation already in progress */ ++pub const EINPROGRESS: i32 = 115; /* Operation now in progress */ ++pub const ESTALE: i32 = 116; /* Stale NFS file handle */ ++pub const EUCLEAN: i32 = 117; /* Structure needs cleaning */ ++pub const ENOTNAM: i32 = 118; /* Not a XENIX named type file */ ++pub const ENAVAIL: i32 = 119; /* No XENIX semaphores available */ ++pub const EISNAM: i32 = 120; /* Is a named type file */ ++pub const EREMOTEIO: i32 = 121; /* Remote I/O error */ ++pub const EDQUOT: i32 = 122; /* Quota exceeded */ ++pub const ENOMEDIUM: i32 = 123; /* No medium found */ ++pub const EMEDIUMTYPE: i32 = 124; /* Wrong medium type */ ++pub const ECANCELED: i32 = 125; /* Operation Canceled */ ++pub const ENOKEY: i32 = 126; /* Required key not available */ ++pub const EKEYEXPIRED: i32 = 127; /* Key has expired */ ++pub const EKEYREVOKED: i32 = 128; /* Key has been revoked */ ++pub const EKEYREJECTED: i32 = 129; /* Key was rejected by service */ ++pub const EOWNERDEAD: i32 = 130; /* Owner died */ ++pub const ENOTRECOVERABLE: i32 = 131; /* State not recoverable */ ++ ++pub static STR_ERROR: [&'static str; 132] = ["Success", ++ "Operation not permitted", ++ "No such file or directory", ++ "No such process", ++ "Interrupted system call", ++ "I/O error", ++ "No such device or address", ++ "Argument list too long", ++ "Exec format error", ++ "Bad file number", ++ "No child processes", ++ "Try again", ++ "Out of memory", ++ "Permission denied", ++ "Bad address", ++ "Block device required", ++ "Device or resource busy", ++ "File exists", ++ "Cross-device link", ++ "No such device", ++ "Not a directory", ++ "Is a directory", ++ "Invalid argument", ++ "File table overflow", ++ "Too many open files", ++ "Not a typewriter", ++ "Text file busy", ++ "File too large", ++ "No space left on device", ++ "Illegal seek", ++ "Read-only file system", ++ "Too many links", ++ "Broken pipe", ++ "Math argument out of domain of func", ++ "Math result not representable", ++ "Resource deadlock would occur", ++ "File name too long", ++ "No record locks available", ++ "Function not implemented", ++ "Directory not empty", ++ "Too many symbolic links encountered", ++ "Operation would block", ++ "No message of desired type", ++ "Identifier removed", ++ "Channel number out of range", ++ "Level 2 not synchronized", ++ "Level 3 halted", ++ "Level 3 reset", ++ "Link number out of range", ++ "Protocol driver not attached", ++ "No CSI structure available", ++ "Level 2 halted", ++ "Invalid exchange", ++ "Invalid request descriptor", ++ "Exchange full", ++ "No anode", ++ "Invalid request code", ++ "Invalid slot", ++ "Resource deadlock would occur", ++ "Bad font file format", ++ "Device not a stream", ++ "No data available", ++ "Timer expired", ++ "Out of streams resources", ++ "Machine is not on the network", ++ "Package not installed", ++ "Object is remote", ++ "Link has been severed", ++ "Advertise error", ++ "Srmount error", ++ "Communication error on send", ++ "Protocol error", ++ "Multihop attempted", ++ "RFS specific error", ++ "Not a data message", ++ "Value too large for defined data type", ++ "Name not unique on network", ++ "File descriptor in bad state", ++ "Remote address changed", ++ "Can not access a needed shared library", ++ "Accessing a corrupted shared library", ++ ".lib section in a.out corrupted", ++ "Attempting to link in too many shared libraries", ++ "Cannot exec a shared library directly", ++ "Illegal byte sequence", ++ "Interrupted system call should be restarted", ++ "Streams pipe error", ++ "Too many users", ++ "Socket operation on non-socket", ++ "Destination address required", ++ "Message too long", ++ "Protocol wrong type for socket", ++ "Protocol not available", ++ "Protocol not supported", ++ "Socket type not supported", ++ "Operation not supported on transport endpoint", ++ "Protocol family not supported", ++ "Address family not supported by protocol", ++ "Address already in use", ++ "Cannot assign requested address", ++ "Network is down", ++ "Network is unreachable", ++ "Network dropped connection because of reset", ++ "Software caused connection abort", ++ "Connection reset by peer", ++ "No buffer space available", ++ "Transport endpoint is already connected", ++ "Transport endpoint is not connected", ++ "Cannot send after transport endpoint shutdown", ++ "Too many references: cannot splice", ++ "Connection timed out", ++ "Connection refused", ++ "Host is down", ++ "No route to host", ++ "Operation already in progress", ++ "Operation now in progress", ++ "Stale NFS file handle", ++ "Structure needs cleaning", ++ "Not a XENIX named type file", ++ "No XENIX semaphores available", ++ "Is a named type file", ++ "Remote I/O error", ++ "Quota exceeded", ++ "No medium found", ++ "Wrong medium type", ++ "Operation Canceled", ++ "Required key not available", ++ "Key has expired", ++ "Key has been revoked", ++ "Key was rejected by service", ++ "Owner died", ++ "State not recoverable"]; diff --cc vendor/redox_syscall-0.1.31/src/flag.rs index 000000000,000000000..6cb22bc65 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/flag.rs @@@ -1,0 -1,0 +1,106 @@@ ++pub const CLONE_VM: usize = 0x100; ++pub const CLONE_FS: usize = 0x200; ++pub const CLONE_FILES: usize = 0x400; ++pub const CLONE_SIGHAND: usize = 0x800; ++pub const CLONE_VFORK: usize = 0x4000; ++pub const CLONE_THREAD: usize = 0x10000; ++ ++pub const CLOCK_REALTIME: usize = 1; ++pub const CLOCK_MONOTONIC: usize = 4; ++ ++pub const EVENT_NONE: usize = 0; ++pub const EVENT_READ: usize = 1; ++pub const EVENT_WRITE: usize = 2; ++ ++pub const F_DUPFD: usize = 0; ++pub const F_GETFD: usize = 1; ++pub const F_SETFD: usize = 2; ++pub const F_GETFL: usize = 3; ++pub const F_SETFL: usize = 4; ++ ++pub const FUTEX_WAIT: usize = 0; ++pub const FUTEX_WAKE: usize = 1; ++pub const FUTEX_REQUEUE: usize = 2; ++ ++pub const MAP_WRITE: usize = 1; ++pub const MAP_WRITE_COMBINE: usize = 2; ++ ++pub const MODE_TYPE: u16 = 0xF000; ++pub const MODE_DIR: u16 = 0x4000; ++pub const MODE_FILE: u16 = 0x8000; ++pub const MODE_SYMLINK: u16 = 0xA000; ++pub const MODE_FIFO: u16 = 0x1000; ++pub const MODE_CHR: u16 = 0x2000; ++ ++pub const MODE_PERM: u16 = 0x0FFF; ++pub const MODE_SETUID: u16 = 0o4000; ++pub const MODE_SETGID: u16 = 0o2000; ++ ++pub const O_RDONLY: usize = 0x0001_0000; ++pub const O_WRONLY: usize = 0x0002_0000; ++pub const O_RDWR: usize = 0x0003_0000; ++pub const O_NONBLOCK: usize = 0x0004_0000; ++pub const O_APPEND: usize = 0x0008_0000; ++pub const O_SHLOCK: usize = 0x0010_0000; ++pub const O_EXLOCK: usize = 0x0020_0000; ++pub const O_ASYNC: usize = 0x0040_0000; ++pub const O_FSYNC: usize = 0x0080_0000; ++pub const O_CLOEXEC: usize = 0x0100_0000; ++pub const O_CREAT: usize = 0x0200_0000; ++pub const O_TRUNC: usize = 0x0400_0000; ++pub const O_EXCL: usize = 0x0800_0000; ++pub const O_DIRECTORY: usize = 0x1000_0000; ++pub const O_STAT: usize = 0x2000_0000; ++pub const O_SYMLINK: usize = 0x4000_0000; ++pub const O_NOFOLLOW: usize = 0x8000_0000; ++pub const O_ACCMODE: usize = O_RDONLY | O_WRONLY | O_RDWR; ++ ++pub const SEEK_SET: usize = 0; ++pub const SEEK_CUR: usize = 1; ++pub const SEEK_END: usize = 2; ++ ++pub const SIGHUP: usize = 1; ++pub const SIGINT: usize = 2; ++pub const SIGQUIT: usize = 3; ++pub const SIGILL: usize = 4; ++pub const SIGTRAP: usize = 5; ++pub const SIGABRT: usize = 6; ++pub const SIGBUS: usize = 7; ++pub const SIGFPE: usize = 8; ++pub const SIGKILL: usize = 9; ++pub const SIGUSR1: usize = 10; ++pub const SIGSEGV: usize = 11; ++pub const SIGUSR2: usize = 12; ++pub const SIGPIPE: usize = 13; ++pub const SIGALRM: usize = 14; ++pub const SIGTERM: usize = 15; ++pub const SIGSTKFLT: usize= 16; ++pub const SIGCHLD: usize = 17; ++pub const SIGCONT: usize = 18; ++pub const SIGSTOP: usize = 19; ++pub const SIGTSTP: usize = 20; ++pub const SIGTTIN: usize = 21; ++pub const SIGTTOU: usize = 22; ++pub const SIGURG: usize = 23; ++pub const SIGXCPU: usize = 24; ++pub const SIGXFSZ: usize = 25; ++pub const SIGVTALRM: usize= 26; ++pub const SIGPROF: usize = 27; ++pub const SIGWINCH: usize = 28; ++pub const SIGIO: usize = 29; ++pub const SIGPWR: usize = 30; ++pub const SIGSYS: usize = 31; ++ ++pub const SIG_DFL: usize = 0; ++pub const SIG_IGN: usize = 1; ++ ++pub const SA_NOCLDSTOP: usize = 0x00000001; ++pub const SA_NOCLDWAIT: usize = 0x00000002; ++pub const SA_SIGINFO: usize = 0x00000004; ++pub const SA_RESTORER: usize = 0x04000000; ++pub const SA_ONSTACK: usize = 0x08000000; ++pub const SA_RESTART: usize = 0x10000000; ++pub const SA_NODEFER: usize = 0x40000000; ++pub const SA_RESETHAND: usize = 0x80000000; ++ ++pub const WNOHANG: usize = 1; diff --cc vendor/redox_syscall-0.1.31/src/io/dma.rs index 000000000,000000000..200beae74 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/io/dma.rs @@@ -1,0 -1,0 +1,76 @@@ ++use core::{mem, ptr}; ++use core::ops::{Deref, DerefMut}; ++ ++use Result; ++ ++struct PhysBox { ++ address: usize, ++ size: usize ++} ++ ++impl PhysBox { ++ fn new(size: usize) -> Result { ++ let address = unsafe { ::physalloc(size)? }; ++ Ok(PhysBox { ++ address: address, ++ size: size ++ }) ++ } ++} ++ ++impl Drop for PhysBox { ++ fn drop(&mut self) { ++ let _ = unsafe { ::physfree(self.address, self.size) }; ++ } ++} ++ ++pub struct Dma { ++ phys: PhysBox, ++ virt: *mut T ++} ++ ++impl Dma { ++ pub fn new(value: T) -> Result> { ++ let phys = PhysBox::new(mem::size_of::())?; ++ let virt = unsafe { ::physmap(phys.address, phys.size, ::MAP_WRITE)? } as *mut T; ++ unsafe { ptr::write(virt, value); } ++ Ok(Dma { ++ phys: phys, ++ virt: virt ++ }) ++ } ++ ++ pub fn zeroed() -> Result> { ++ let phys = PhysBox::new(mem::size_of::())?; ++ let virt = unsafe { ::physmap(phys.address, phys.size, ::MAP_WRITE)? } as *mut T; ++ unsafe { ptr::write_bytes(virt as *mut u8, 0, phys.size); } ++ Ok(Dma { ++ phys: phys, ++ virt: virt ++ }) ++ } ++ ++ pub fn physical(&self) -> usize { ++ self.phys.address ++ } ++} ++ ++impl Deref for Dma { ++ type Target = T; ++ fn deref(&self) -> &T { ++ unsafe { &*self.virt } ++ } ++} ++ ++impl DerefMut for Dma { ++ fn deref_mut(&mut self) -> &mut T { ++ unsafe { &mut *self.virt } ++ } ++} ++ ++impl Drop for Dma { ++ fn drop(&mut self) { ++ unsafe { drop(ptr::read(self.virt)); } ++ let _ = unsafe { ::physunmap(self.virt as usize) }; ++ } ++} diff --cc vendor/redox_syscall-0.1.31/src/io/io.rs index 000000000,000000000..fb866b581 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/io/io.rs @@@ -1,0 -1,0 +1,67 @@@ ++use core::cmp::PartialEq; ++use core::ops::{BitAnd, BitOr, Not}; ++ ++pub trait Io { ++ type Value: Copy + PartialEq + BitAnd + BitOr + Not; ++ ++ fn read(&self) -> Self::Value; ++ fn write(&mut self, value: Self::Value); ++ ++ #[inline(always)] ++ fn readf(&self, flags: Self::Value) -> bool { ++ (self.read() & flags) as Self::Value == flags ++ } ++ ++ #[inline(always)] ++ fn writef(&mut self, flags: Self::Value, value: bool) { ++ let tmp: Self::Value = match value { ++ true => self.read() | flags, ++ false => self.read() & !flags, ++ }; ++ self.write(tmp); ++ } ++} ++ ++pub struct ReadOnly { ++ inner: I ++} ++ ++impl ReadOnly { ++ pub const fn new(inner: I) -> ReadOnly { ++ ReadOnly { ++ inner: inner ++ } ++ } ++ ++ #[inline(always)] ++ pub fn read(&self) -> I::Value { ++ self.inner.read() ++ } ++ ++ #[inline(always)] ++ pub fn readf(&self, flags: I::Value) -> bool { ++ self.inner.readf(flags) ++ } ++} ++ ++pub struct WriteOnly { ++ inner: I ++} ++ ++impl WriteOnly { ++ pub const fn new(inner: I) -> WriteOnly { ++ WriteOnly { ++ inner: inner ++ } ++ } ++ ++ #[inline(always)] ++ pub fn write(&mut self, value: I::Value) { ++ self.inner.write(value) ++ } ++ ++ #[inline(always)] ++ pub fn writef(&mut self, flags: I::Value, value: bool) { ++ self.inner.writef(flags, value) ++ } ++} diff --cc vendor/redox_syscall-0.1.31/src/io/mmio.rs index 000000000,000000000..1a1d1996d new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/io/mmio.rs @@@ -1,0 -1,0 +1,31 @@@ ++use core::intrinsics::{volatile_load, volatile_store}; ++use core::mem::uninitialized; ++use core::ops::{BitAnd, BitOr, Not}; ++ ++use super::io::Io; ++ ++#[repr(packed)] ++pub struct Mmio { ++ value: T, ++} ++ ++impl Mmio { ++ /// Create a new Mmio without initializing ++ pub fn new() -> Self { ++ Mmio { ++ value: unsafe { uninitialized() } ++ } ++ } ++} ++ ++impl Io for Mmio where T: Copy + PartialEq + BitAnd + BitOr + Not { ++ type Value = T; ++ ++ fn read(&self) -> T { ++ unsafe { volatile_load(&self.value) } ++ } ++ ++ fn write(&mut self, value: T) { ++ unsafe { volatile_store(&mut self.value, value) }; ++ } ++} diff --cc vendor/redox_syscall-0.1.31/src/io/mod.rs index 000000000,000000000..a35456e30 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/io/mod.rs @@@ -1,0 -1,0 +1,11 @@@ ++//! I/O functions ++ ++pub use self::dma::*; ++pub use self::io::*; ++pub use self::mmio::*; ++pub use self::pio::*; ++ ++mod dma; ++mod io; ++mod mmio; ++mod pio; diff --cc vendor/redox_syscall-0.1.31/src/io/pio.rs index 000000000,000000000..91ae310b6 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/io/pio.rs @@@ -1,0 -1,0 +1,89 @@@ ++use core::marker::PhantomData; ++ ++use super::io::Io; ++ ++/// Generic PIO ++#[derive(Copy, Clone)] ++pub struct Pio { ++ port: u16, ++ value: PhantomData, ++} ++ ++impl Pio { ++ /// Create a PIO from a given port ++ pub const fn new(port: u16) -> Self { ++ Pio:: { ++ port: port, ++ value: PhantomData, ++ } ++ } ++} ++ ++/// Read/Write for byte PIO ++impl Io for Pio { ++ type Value = u8; ++ ++ /// Read ++ #[inline(always)] ++ fn read(&self) -> u8 { ++ let value: u8; ++ unsafe { ++ asm!("in $0, $1" : "={al}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile"); ++ } ++ value ++ } ++ ++ /// Write ++ #[inline(always)] ++ fn write(&mut self, value: u8) { ++ unsafe { ++ asm!("out $1, $0" : : "{al}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile"); ++ } ++ } ++} ++ ++/// Read/Write for word PIO ++impl Io for Pio { ++ type Value = u16; ++ ++ /// Read ++ #[inline(always)] ++ fn read(&self) -> u16 { ++ let value: u16; ++ unsafe { ++ asm!("in $0, $1" : "={ax}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile"); ++ } ++ value ++ } ++ ++ /// Write ++ #[inline(always)] ++ fn write(&mut self, value: u16) { ++ unsafe { ++ asm!("out $1, $0" : : "{ax}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile"); ++ } ++ } ++} ++ ++/// Read/Write for doubleword PIO ++impl Io for Pio { ++ type Value = u32; ++ ++ /// Read ++ #[inline(always)] ++ fn read(&self) -> u32 { ++ let value: u32; ++ unsafe { ++ asm!("in $0, $1" : "={eax}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile"); ++ } ++ value ++ } ++ ++ /// Write ++ #[inline(always)] ++ fn write(&mut self, value: u32) { ++ unsafe { ++ asm!("out $1, $0" : : "{eax}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile"); ++ } ++ } ++} diff --cc vendor/redox_syscall-0.1.31/src/lib.rs index 000000000,000000000..d7b96ed1a new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/lib.rs @@@ -1,0 -1,0 +1,47 @@@ ++#![deny(warnings)] ++#![feature(asm)] ++#![feature(const_fn)] ++#![feature(core_intrinsics)] ++#![no_std] ++ ++pub use self::arch::*; ++pub use self::call::*; ++pub use self::data::*; ++pub use self::error::*; ++pub use self::flag::*; ++pub use self::io::*; ++pub use self::number::*; ++pub use self::scheme::*; ++ ++#[cfg(target_arch = "arm")] ++#[path="arch/arm.rs"] ++mod arch; ++ ++#[cfg(target_arch = "x86")] ++#[path="arch/x86.rs"] ++mod arch; ++ ++#[cfg(target_arch = "x86_64")] ++#[path="arch/x86_64.rs"] ++mod arch; ++ ++/// Function definitions ++pub mod call; ++ ++/// Complex structures that are used for some system calls ++pub mod data; ++ ++/// All errors that can be generated by a system call ++pub mod error; ++ ++/// Flags used as an argument to many system calls ++pub mod flag; ++ ++/// Functions for low level hardware control ++pub mod io; ++ ++/// Call numbers used by each system call ++pub mod number; ++ ++/// A trait useful for scheme handlers ++pub mod scheme; diff --cc vendor/redox_syscall-0.1.31/src/number.rs index 000000000,000000000..bf0ca5720 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/number.rs @@@ -1,0 -1,0 +1,70 @@@ ++pub const SYS_CLASS: usize = 0xF000_0000; ++pub const SYS_CLASS_PATH: usize=0x1000_0000; ++pub const SYS_CLASS_FILE: usize=0x2000_0000; ++ ++pub const SYS_ARG: usize = 0x0F00_0000; ++pub const SYS_ARG_SLICE: usize =0x0100_0000; ++pub const SYS_ARG_MSLICE: usize=0x0200_0000; ++pub const SYS_ARG_PATH: usize = 0x0300_0000; ++ ++pub const SYS_RET: usize = 0x00F0_0000; ++pub const SYS_RET_FILE: usize = 0x0010_0000; ++ ++pub const SYS_LINK: usize = SYS_CLASS_PATH | SYS_ARG_PATH | 9; ++pub const SYS_OPEN: usize = SYS_CLASS_PATH | SYS_RET_FILE | 5; ++pub const SYS_CHMOD: usize = SYS_CLASS_PATH | 15; ++pub const SYS_RMDIR: usize = SYS_CLASS_PATH | 84; ++pub const SYS_UNLINK: usize = SYS_CLASS_PATH | 10; ++ ++pub const SYS_CLOSE: usize = SYS_CLASS_FILE | 6; ++pub const SYS_DUP: usize = SYS_CLASS_FILE | SYS_RET_FILE | 41; ++pub const SYS_DUP2: usize = SYS_CLASS_FILE | SYS_RET_FILE | 63; ++pub const SYS_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3; ++pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4; ++pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19; ++pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55; ++pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927; ++pub const SYS_FMAP: usize = SYS_CLASS_FILE | 90; ++pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 91; ++pub const SYS_FPATH: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 928; ++pub const SYS_FSTAT: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 28; ++pub const SYS_FSTATVFS: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 100; ++pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118; ++pub const SYS_FTRUNCATE: usize =SYS_CLASS_FILE | 93; ++pub const SYS_FUTIMENS: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 320; ++ ++pub const SYS_BRK: usize = 45; ++pub const SYS_CHDIR: usize = 12; ++pub const SYS_CLOCK_GETTIME: usize = 265; ++pub const SYS_CLONE: usize = 120; ++pub const SYS_EXECVE: usize = 11; ++pub const SYS_EXIT: usize = 1; ++pub const SYS_FUTEX: usize = 240; ++pub const SYS_GETCWD: usize = 183; ++pub const SYS_GETEGID: usize = 202; ++pub const SYS_GETENS: usize = 951; ++pub const SYS_GETEUID: usize = 201; ++pub const SYS_GETGID: usize = 200; ++pub const SYS_GETNS: usize = 950; ++pub const SYS_GETPID: usize = 20; ++pub const SYS_GETPGID: usize = 132; ++pub const SYS_GETPPID: usize = 64; ++pub const SYS_GETUID: usize = 199; ++pub const SYS_IOPL: usize = 110; ++pub const SYS_KILL: usize = 37; ++pub const SYS_MKNS: usize = 984; ++pub const SYS_NANOSLEEP: usize =162; ++pub const SYS_PHYSALLOC: usize =945; ++pub const SYS_PHYSFREE: usize = 946; ++pub const SYS_PHYSMAP: usize = 947; ++pub const SYS_PHYSUNMAP: usize =948; ++pub const SYS_VIRTTOPHYS: usize=949; ++pub const SYS_PIPE2: usize = 331; ++pub const SYS_SETPGID: usize = 57; ++pub const SYS_SETREGID: usize = 204; ++pub const SYS_SETRENS: usize = 952; ++pub const SYS_SETREUID: usize = 203; ++pub const SYS_SIGACTION: usize =67; ++pub const SYS_SIGRETURN: usize =119; ++pub const SYS_WAITPID: usize = 7; ++pub const SYS_YIELD: usize = 158; diff --cc vendor/redox_syscall-0.1.31/src/scheme.rs index 000000000,000000000..d58bd2900 new file mode 100644 --- /dev/null +++ b/vendor/redox_syscall-0.1.31/src/scheme.rs @@@ -1,0 -1,0 +1,266 @@@ ++use core::{mem, slice}; ++ ++use super::*; ++ ++pub trait Scheme { ++ fn handle(&self, packet: &mut Packet) { ++ packet.a = Error::mux(match packet.a { ++ SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid), ++ SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid), ++ SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), ++ SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), ++ ++ SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), ++ SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), ++ SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), ++ SYS_LSEEK => self.seek(packet.b, packet.c, packet.d), ++ SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d), ++ SYS_FEVENT => self.fevent(packet.b, packet.c), ++ SYS_FMAP => self.fmap(packet.b, packet.c, packet.d), ++ SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), ++ SYS_FSTAT => if packet.d >= mem::size_of::() { ++ self.fstat(packet.b, unsafe { &mut *(packet.c as *mut Stat) }) ++ } else { ++ Err(Error::new(EFAULT)) ++ }, ++ SYS_FSTATVFS => if packet.d >= mem::size_of::() { ++ self.fstatvfs(packet.b, unsafe { &mut *(packet.c as *mut StatVfs) }) ++ } else { ++ Err(Error::new(EFAULT)) ++ }, ++ SYS_FSYNC => self.fsync(packet.b), ++ SYS_FTRUNCATE => self.ftruncate(packet.b, packet.c), ++ SYS_FUTIMENS => if packet.d >= mem::size_of::() { ++ self.futimens(packet.b, unsafe { slice::from_raw_parts(packet.c as *const TimeSpec, packet.d / mem::size_of::()) }) ++ } else { ++ Err(Error::new(EFAULT)) ++ }, ++ SYS_CLOSE => self.close(packet.b), ++ _ => Err(Error::new(ENOSYS)) ++ }); ++ } ++ ++ /* Scheme operations */ ++ ++ #[allow(unused_variables)] ++ fn open(&self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result { ++ Err(Error::new(ENOENT)) ++ } ++ ++ #[allow(unused_variables)] ++ fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result { ++ Err(Error::new(ENOENT)) ++ } ++ ++ #[allow(unused_variables)] ++ fn rmdir(&self, path: &[u8], uid: u32, gid: u32) -> Result { ++ Err(Error::new(ENOENT)) ++ } ++ ++ #[allow(unused_variables)] ++ fn unlink(&self, path: &[u8], uid: u32, gid: u32) -> Result { ++ Err(Error::new(ENOENT)) ++ } ++ ++ /* Resource operations */ ++ #[allow(unused_variables)] ++ fn dup(&self, old_id: usize, buf: &[u8]) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn read(&self, id: usize, buf: &mut [u8]) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn write(&self, id: usize, buf: &[u8]) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn seek(&self, id: usize, pos: usize, whence: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fcntl(&self, id: usize, cmd: usize, arg: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fevent(&self, id: usize, flags: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fmap(&self, id: usize, offset: usize, size: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fpath(&self, id: usize, buf: &mut [u8]) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fstat(&self, id: usize, stat: &mut Stat) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fstatvfs(&self, id: usize, stat: &mut StatVfs) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fsync(&self, id: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn ftruncate(&self, id: usize, len: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn futimens(&self, id: usize, times: &[TimeSpec]) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn close(&self, id: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++} ++ ++pub trait SchemeMut { ++ fn handle(&mut self, packet: &mut Packet) { ++ packet.a = Error::mux(match packet.a { ++ SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid), ++ SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid), ++ SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), ++ SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), ++ ++ SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), ++ SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), ++ SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), ++ SYS_LSEEK => self.seek(packet.b, packet.c, packet.d), ++ SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d), ++ SYS_FEVENT => self.fevent(packet.b, packet.c), ++ SYS_FMAP => self.fmap(packet.b, packet.c, packet.d), ++ SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), ++ SYS_FSTAT => if packet.d >= mem::size_of::() { ++ self.fstat(packet.b, unsafe { &mut *(packet.c as *mut Stat) }) ++ } else { ++ Err(Error::new(EFAULT)) ++ }, ++ SYS_FSTATVFS => if packet.d >= mem::size_of::() { ++ self.fstatvfs(packet.b, unsafe { &mut *(packet.c as *mut StatVfs) }) ++ } else { ++ Err(Error::new(EFAULT)) ++ }, ++ SYS_FSYNC => self.fsync(packet.b), ++ SYS_FTRUNCATE => self.ftruncate(packet.b, packet.c), ++ SYS_FUTIMENS => if packet.d >= mem::size_of::() { ++ self.futimens(packet.b, unsafe { slice::from_raw_parts(packet.c as *const TimeSpec, packet.d / mem::size_of::()) }) ++ } else { ++ Err(Error::new(EFAULT)) ++ }, ++ SYS_CLOSE => self.close(packet.b), ++ _ => Err(Error::new(ENOSYS)) ++ }); ++ } ++ ++ /* Scheme operations */ ++ #[allow(unused_variables)] ++ fn open(&mut self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result { ++ Err(Error::new(ENOENT)) ++ } ++ ++ #[allow(unused_variables)] ++ fn chmod(&mut self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result { ++ Err(Error::new(ENOENT)) ++ } ++ ++ #[allow(unused_variables)] ++ fn rmdir(&mut self, path: &[u8], uid: u32, gid: u32) -> Result { ++ Err(Error::new(ENOENT)) ++ } ++ ++ #[allow(unused_variables)] ++ fn unlink(&mut self, path: &[u8], uid: u32, gid: u32) -> Result { ++ Err(Error::new(ENOENT)) ++ } ++ ++ /* Resource operations */ ++ #[allow(unused_variables)] ++ fn dup(&mut self, old_id: usize, buf: &[u8]) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn read(&mut self, id: usize, buf: &mut [u8]) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn write(&mut self, id: usize, buf: &[u8]) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn seek(&mut self, id: usize, pos: usize, whence: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fcntl(&mut self, id: usize, cmd: usize, arg: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fevent(&mut self, id: usize, flags: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fmap(&mut self, id: usize, offset: usize, size: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fstat(&mut self, id: usize, stat: &mut Stat) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fstatvfs(&self, id: usize, stat: &mut StatVfs) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn fsync(&mut self, id: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn ftruncate(&mut self, id: usize, len: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn futimens(&mut self, id: usize, times: &[TimeSpec]) -> Result { ++ Err(Error::new(EBADF)) ++ } ++ ++ #[allow(unused_variables)] ++ fn close(&mut self, id: usize) -> Result { ++ Err(Error::new(EBADF)) ++ } ++} diff --cc vendor/redox_termios-0.1.1/.cargo-checksum.json index 000000000,000000000..125ed39f9 new file mode 100644 --- /dev/null +++ b/vendor/redox_termios-0.1.1/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"} diff --cc vendor/redox_termios-0.1.1/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/redox_termios-0.1.1/.cargo-ok diff --cc vendor/redox_termios-0.1.1/Cargo.toml index 000000000,000000000..a89b0e89c new file mode 100644 --- /dev/null +++ b/vendor/redox_termios-0.1.1/Cargo.toml @@@ -1,0 -1,0 +1,26 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "redox_termios" ++version = "0.1.1" ++authors = ["Jeremy Soller "] ++description = "A Rust library to access Redox termios functions" ++documentation = "https://docs.rs/redox_termios" ++license = "MIT" ++repository = "https://github.com/redox-os/termios" ++ ++[lib] ++name = "redox_termios" ++path = "src/lib.rs" ++[dependencies.redox_syscall] ++version = "0.1" diff --cc vendor/redox_termios-0.1.1/LICENSE index 000000000,000000000..5deeece4f new file mode 100644 --- /dev/null +++ b/vendor/redox_termios-0.1.1/LICENSE @@@ -1,0 -1,0 +1,21 @@@ ++MIT License ++ ++Copyright (c) 2017 Redox OS ++ ++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 --cc vendor/redox_termios-0.1.1/README.md index 000000000,000000000..24156cb95 new file mode 100644 --- /dev/null +++ b/vendor/redox_termios-0.1.1/README.md @@@ -1,0 -1,0 +1,2 @@@ ++# termios ++Redox Rust termios library diff --cc vendor/redox_termios-0.1.1/src/lib.rs index 000000000,000000000..b1c904502 new file mode 100644 --- /dev/null +++ b/vendor/redox_termios-0.1.1/src/lib.rs @@@ -1,0 -1,0 +1,218 @@@ ++#![allow(non_camel_case_types)] ++#![no_std] ++ ++extern crate syscall; ++ ++use core::{mem, slice}; ++use core::ops::{Deref, DerefMut}; ++ ++pub type tcflag_t = u32; ++pub type cc_t = u8; ++ ++/* c_cc { */ ++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 VSWTC: usize = 7; ++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 NCCS: usize = 32; ++/* } c_cc */ ++ ++/* c_iflag { */ ++pub const IGNBRK: tcflag_t = 0o000001; ++pub const BRKINT: tcflag_t = 0o000002; ++pub const IGNPAR: tcflag_t = 0o000004; ++pub const PARMRK: tcflag_t = 0o000010; ++pub const INPCK: tcflag_t = 0o000020; ++pub const ISTRIP: tcflag_t = 0o000040; ++pub const INLCR: tcflag_t = 0o000100; ++pub const IGNCR: tcflag_t = 0o000200; ++pub const ICRNL: tcflag_t = 0o000400; ++pub const IXON: tcflag_t = 0o001000; ++pub const IXOFF: tcflag_t = 0o002000; ++/* } c_iflag */ ++ ++/* c_oflag { */ ++pub const OPOST: tcflag_t = 0o000001; ++pub const ONLCR: tcflag_t = 0o000002; ++pub const OLCUC: tcflag_t = 0o000004; ++ ++pub const OCRNL: tcflag_t = 0o000010; ++pub const ONOCR: tcflag_t = 0o000020; ++pub const ONLRET: tcflag_t = 0o000040; ++ ++pub const OFILL: tcflag_t = 0o0000100; ++pub const OFDEL: tcflag_t = 0o0000200; ++/* } c_oflag */ ++ ++/* c_cflag { */ ++pub const B0: tcflag_t = 0o000000; ++pub const B50: tcflag_t = 0o000001; ++pub const B75: tcflag_t = 0o000002; ++pub const B110: tcflag_t = 0o000003; ++pub const B134: tcflag_t = 0o000004; ++pub const B150: tcflag_t = 0o000005; ++pub const B200: tcflag_t = 0o000006; ++pub const B300: tcflag_t = 0o000007; ++pub const B600: tcflag_t = 0o000010; ++pub const B1200: tcflag_t = 0o000011; ++pub const B1800: tcflag_t = 0o000012; ++pub const B2400: tcflag_t = 0o000013; ++pub const B4800: tcflag_t = 0o000014; ++pub const B9600: tcflag_t = 0o000015; ++pub const B19200: tcflag_t = 0o000016; ++pub const B38400: tcflag_t = 0o000017; ++pub const B57600: tcflag_t = 0o0020; ++pub const B115200: tcflag_t = 0o0021; ++pub const B230400: tcflag_t = 0o0022; ++pub const B460800: tcflag_t = 0o0023; ++pub const B500000: tcflag_t = 0o0024; ++pub const B576000: tcflag_t = 0o0025; ++pub const B921600: tcflag_t = 0o0026; ++pub const B1000000: tcflag_t = 0o0027; ++pub const B1152000: tcflag_t = 0o0030; ++pub const B1500000: tcflag_t = 0o0031; ++pub const B2000000: tcflag_t = 0o0032; ++pub const B2500000: tcflag_t = 0o0033; ++pub const B3000000: tcflag_t = 0o0034; ++pub const B3500000: tcflag_t = 0o0035; ++pub const B4000000: tcflag_t = 0o0036; ++ ++pub const __MAX_BAUD: tcflag_t = B4000000; ++ ++pub const CSIZE: tcflag_t = 0o0001400; ++pub const CS5: tcflag_t = 0o0000000; ++pub const CS6: tcflag_t = 0o0000400; ++pub const CS7: tcflag_t = 0o0001000; ++pub const CS8: tcflag_t = 0o0001400; ++ ++pub const CSTOPB: tcflag_t = 0o0002000; ++pub const CREAD: tcflag_t = 0o0004000; ++pub const PARENB: tcflag_t = 0o0010000; ++pub const PARODD: tcflag_t = 0o0020000; ++pub const HUPCL: tcflag_t = 0o0040000; ++ ++pub const CLOCAL: tcflag_t = 0o0100000; ++/* } c_clfag */ ++ ++/* c_lflag { */ ++pub const ISIG: tcflag_t = 0x00000080; ++pub const ICANON: tcflag_t = 0x00000100; ++pub const ECHO: tcflag_t = 0x00000008; ++pub const ECHOE: tcflag_t = 0x00000002; ++pub const ECHOK: tcflag_t = 0x00000004; ++pub const ECHONL: tcflag_t = 0x00000010; ++pub const NOFLSH: tcflag_t = 0x80000000; ++pub const TOSTOP: tcflag_t = 0x00400000; ++pub const IEXTEN: tcflag_t = 0x00000400; ++/* } c_lflag */ ++ ++#[derive(Clone, Copy, Debug)] ++#[repr(C)] ++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; 32] ++} ++ ++impl Default for Termios { ++ fn default() -> Termios { ++ let mut termios = Termios { ++ c_iflag: ICRNL | IXON, ++ c_oflag: OPOST | ONLCR, ++ c_cflag: B38400 | CS8 | CREAD | HUPCL, ++ c_lflag: ISIG | ICANON | ECHO | ECHOE | ECHOK | IEXTEN, ++ c_cc: [0; 32] ++ }; ++ ++ { ++ let mut cc = |i: usize, b: cc_t| { ++ termios.c_cc[i] = b; ++ }; ++ ++ cc(VEOF, 0o004); // CTRL-D ++ cc(VEOL, 0o000); // NUL ++ cc(VEOL2, 0o000); // NUL ++ cc(VERASE, 0o177); // DEL ++ cc(VWERASE, 0o027); // CTRL-W ++ cc(VKILL, 0o025); // CTRL-U ++ cc(VREPRINT, 0o022);// CTRL-R ++ cc(VINTR, 0o003); // CTRL-C ++ cc(VQUIT, 0o034); // CTRL-\ ++ cc(VSUSP, 0o032); // CTRL-Z ++ cc(VSTART, 0o021); // CTRL-Q ++ cc(VSTOP, 0o023); // CTRL-S ++ cc(VLNEXT, 0o026); // CTRL-V ++ cc(VDISCARD, 0o017);// CTRL-U ++ cc(VMIN, 1); ++ cc(VTIME, 0); ++ } ++ ++ termios ++ } ++} ++ ++impl Termios { ++ pub fn make_raw(&mut self) { ++ self.c_iflag &= !(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); ++ self.c_oflag &= !OPOST; ++ self.c_cflag &= !(CSIZE | PARENB); ++ self.c_cflag |= CS8; ++ self.c_lflag &= !(ECHO | ECHONL | ICANON | ISIG | IEXTEN); ++ } ++} ++ ++impl Deref for Termios { ++ type Target = [u8]; ++ fn deref(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts(self as *const Termios as *const u8, mem::size_of::()) as &[u8] ++ } ++ } ++} ++ ++impl DerefMut for Termios { ++ fn deref_mut(&mut self) -> &mut [u8] { ++ unsafe { ++ slice::from_raw_parts_mut(self as *mut Termios as *mut u8, mem::size_of::()) as &mut [u8] ++ } ++ } ++} ++ ++#[derive(Clone, Copy, Debug, Default)] ++#[repr(C)] ++pub struct Winsize { ++ pub ws_row: u16, ++ pub ws_col: u16 ++} ++ ++impl Deref for Winsize { ++ type Target = [u8]; ++ fn deref(&self) -> &[u8] { ++ unsafe { ++ slice::from_raw_parts(self as *const Winsize as *const u8, mem::size_of::()) as &[u8] ++ } ++ } ++} ++ ++impl DerefMut for Winsize { ++ fn deref_mut(&mut self) -> &mut [u8] { ++ unsafe { ++ slice::from_raw_parts_mut(self as *mut Winsize as *mut u8, mem::size_of::()) as &mut [u8] ++ } ++ } ++} diff --cc vendor/rustc-demangle-0.1.5/.cargo-checksum.json index 000000000,000000000..1a84740b3 new file mode 100644 --- /dev/null +++ b/vendor/rustc-demangle-0.1.5/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e"} diff --cc vendor/rustc-demangle-0.1.5/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/rustc-demangle-0.1.5/.cargo-ok diff --cc vendor/rustc-demangle-0.1.5/.travis.yml index 000000000,000000000..15ec25ec5 new file mode 100644 --- /dev/null +++ b/vendor/rustc-demangle-0.1.5/.travis.yml @@@ -1,0 -1,0 +1,20 @@@ ++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 ++ - cargo test ++ - cargo doc ++after_success: ++ - travis-cargo --only nightly doc-upload ++notifications: ++ email: ++ on_success: never ++env: ++ global: ++ secure: "VWE8DaftZLOj34USRPiq2jyFV1xWrPJP0lgMVWPGF52soyWV6L5FyMlbk00GvKH8y5h0urtuVFmInsLKz1E96eTLbD7Efa2snjSlOWMsTaWy3yq0NNuPraMWiXUkjDBxW3DTV47HN9thYA7TbrM35A0XGr7fXKl4CPT/UKEo2nNZPb2Y2XYaD6RID1sXMOvemOERGu7Lnq8dQ/PdGWWkpTV4FVsmq2wTyyZnzsEFsK0r/wqEPPHSl8r3NH6Rid9kCMw3h1d9s1eYSqzP09/fYfjy+X/6iGV9dL5WUQFL7xG7WjfZZG/e87lAxbXx+jXTlncdvXjm4BmIOYHeEMK9N5D3qE5C1gIIU+tk6ZuVKBLWMQJnAIDJKCsVdUhAXtWqbFK4djvNJUml1rIOF/CVUeynBVtacJ8nlxyh61XvDHbZGSBFBR2odEkhUaLzw/t/zqOIYd0u+mjtM4pX1nZ+ZFIMqVFsNTfVWWMDLyRVBNiAoHCdn/ug+mJJaYE3mZ2q1wPPqJVFffyaZVyg97zFO0y9v5ASHjb/7nYlIPoDGDPDUuoscuw5IYf+6CoCi7EgGqg5v7X1BsBXSYK+XfzOvrAqP31ixNGyVJEcBjAaJXwopx6KVIqWe71eHJDX68VeI0ncfCPDDQIReKA7MBhq5PzRDzr4iRHZAhNyuKgo+Fo=" diff --cc vendor/rustc-demangle-0.1.5/Cargo.toml index 000000000,000000000..bb9d48199 new file mode 100644 --- /dev/null +++ b/vendor/rustc-demangle-0.1.5/Cargo.toml @@@ -1,0 -1,0 +1,22 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "rustc-demangle" ++version = "0.1.5" ++authors = ["Alex Crichton "] ++description = "Rust compiler symbol demangling.\n" ++homepage = "https://github.com/alexcrichton/rustc-demangle" ++documentation = "http://alexcrichton.com/rustc-demangle" ++readme = "README.md" ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/rustc-demangle" diff --cc vendor/rustc-demangle-0.1.5/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/rustc-demangle-0.1.5/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/rustc-demangle-0.1.5/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/rustc-demangle-0.1.5/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/rustc-demangle-0.1.5/README.md index 000000000,000000000..d2cb46726 new file mode 100644 --- /dev/null +++ b/vendor/rustc-demangle-0.1.5/README.md @@@ -1,0 -1,0 +1,15 @@@ ++# rustc-demangle ++ ++Symbol demangling for Rust ++ ++[![Build Status](https://travis-ci.org/alexcrichton/rustc-demangle.svg?branch=master)](https://travis-ci.org/alexcrichton/rustc-demangle) ++ ++[Documentation](http://alexcrichton.com/rustc-demangle) ++ ++# License ++ ++`rustc-demangle` 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 --cc vendor/rustc-demangle-0.1.5/src/lib.rs index 000000000,000000000..eb873bd7d new file mode 100644 --- /dev/null +++ b/vendor/rustc-demangle-0.1.5/src/lib.rs @@@ -1,0 -1,0 +1,361 @@@ ++//! Demangle Rust compiler symbol names. ++//! ++//! This crate provides a `demangle` function which will return a `Demangle` ++//! sentinel value that can be used to learn about the demangled version of a ++//! symbol name. The demangled representation will be the same as the original ++//! if it doesn't look like a mangled symbol name. ++//! ++//! `Demangle` can be formatted with the `Display` trait. The alternate ++//! modifier (`#`) can be used to format the symbol name without the ++//! trailing hash value. ++//! ++//! # Examples ++//! ++//! ``` ++//! use rustc_demangle::demangle; ++//! ++//! assert_eq!(demangle("_ZN4testE").to_string(), "test"); ++//! assert_eq!(demangle("_ZN3foo3barE").to_string(), "foo::bar"); ++//! assert_eq!(demangle("foo").to_string(), "foo"); ++//! // With hash ++//! assert_eq!(format!("{}", demangle("_ZN3foo17h05af221e174051e9E")), "foo::h05af221e174051e9"); ++//! // Without hash ++//! assert_eq!(format!("{:#}", demangle("_ZN3foo17h05af221e174051e9E")), "foo"); ++//! ``` ++ ++#![no_std] ++#![deny(missing_docs)] ++ ++#[cfg(test)] ++#[macro_use] ++extern crate std; ++ ++use core::fmt; ++ ++/// Representation of a demangled symbol name. ++pub struct Demangle<'a> { ++ original: &'a str, ++ inner: &'a str, ++ valid: bool, ++ /// The number of ::-separated elements in the original name. ++ elements: usize, ++} ++ ++/// De-mangles a Rust symbol into a more readable version ++/// ++/// All rust symbols by default are mangled as they contain characters that ++/// cannot be represented in all object files. The mangling mechanism is similar ++/// to C++'s, but Rust has a few specifics to handle items like lifetimes in ++/// symbols. ++/// ++/// This function will take a **mangled** symbol (typically acquired from a ++/// `Symbol` which is in turn resolved from a `Frame`) and then writes the ++/// de-mangled version into the given `writer`. If the symbol does not look like ++/// a mangled symbol, it is still written to `writer`. ++/// ++/// # Examples ++/// ++/// ``` ++/// use rustc_demangle::demangle; ++/// ++/// assert_eq!(demangle("_ZN4testE").to_string(), "test"); ++/// assert_eq!(demangle("_ZN3foo3barE").to_string(), "foo::bar"); ++/// assert_eq!(demangle("foo").to_string(), "foo"); ++/// ``` ++ ++// All rust symbols are in theory lists of "::"-separated identifiers. Some ++// assemblers, however, can't handle these characters in symbol names. To get ++// around this, we use C++-style mangling. The mangling method is: ++// ++// 1. Prefix the symbol with "_ZN" ++// 2. For each element of the path, emit the length plus the element ++// 3. End the path with "E" ++// ++// For example, "_ZN4testE" => "test" and "_ZN3foo3barE" => "foo::bar". ++// ++// We're the ones printing our backtraces, so we can't rely on anything else to ++// demangle our symbols. It's *much* nicer to look at demangled symbols, so ++// this function is implemented to give us nice pretty output. ++// ++// Note that this demangler isn't quite as fancy as it could be. We have lots ++// of other information in our symbols like hashes, version, type information, ++// etc. Additionally, this doesn't handle glue symbols at all. ++pub fn demangle(s: &str) -> Demangle { ++ // First validate the symbol. If it doesn't look like anything we're ++ // expecting, we just print it literally. Note that we must handle non-rust ++ // symbols because we could have any function in the backtrace. ++ let mut valid = true; ++ let mut inner = s; ++ if s.len() > 4 && s.starts_with("_ZN") && s.ends_with('E') { ++ inner = &s[3..s.len() - 1]; ++ } else if s.len() > 3 && s.starts_with("ZN") && s.ends_with('E') { ++ // On Windows, dbghelp strips leading underscores, so we accept "ZN...E" ++ // form too. ++ inner = &s[2..s.len() - 1]; ++ } else if s.len() > 5 && s.starts_with("__ZN") && s.ends_with('E') { ++ // On OSX, symbols are prefixed with an extra _ ++ inner = &s[4..s.len() - 1]; ++ } else { ++ valid = false; ++ } ++ ++ let mut elements = 0; ++ if valid { ++ let mut chars = inner.chars(); ++ while valid { ++ let mut i = 0; ++ for c in chars.by_ref() { ++ if c.is_digit(10) { ++ i = i * 10 + c as usize - '0' as usize; ++ } else { ++ break; ++ } ++ } ++ if i == 0 { ++ valid = chars.next().is_none(); ++ break; ++ } else if chars.by_ref().take(i - 1).count() != i - 1 { ++ valid = false; ++ } else { ++ elements += 1; ++ } ++ } ++ } ++ ++ Demangle { ++ inner: inner, ++ valid: valid, ++ elements: elements, ++ original: s, ++ } ++} ++ ++/// Error returned from the `try_demangle` function below when demangling fails. ++#[derive(Debug, Clone)] ++pub struct TryDemangleError { ++ _priv: (), ++} ++ ++/// The same as `demangle`, except return an `Err` if the string does not appear ++/// to be a Rust symbol, rather than "demangling" the given string as a no-op. ++/// ++/// ``` ++/// extern crate rustc_demangle; ++/// ++/// let not_a_rust_symbol = "la la la"; ++/// ++/// // The `try_demangle` function will reject strings which are not Rust symbols. ++/// assert!(rustc_demangle::try_demangle(not_a_rust_symbol).is_err()); ++/// ++/// // While `demangle` will just pass the non-symbol through as a no-op. ++/// assert_eq!(rustc_demangle::demangle(not_a_rust_symbol).as_str(), not_a_rust_symbol); ++/// ``` ++pub fn try_demangle(s: &str) -> Result { ++ let sym = demangle(s); ++ if sym.valid { ++ Ok(sym) ++ } else { ++ Err(TryDemangleError { _priv: () }) ++ } ++} ++ ++impl<'a> Demangle<'a> { ++ /// Returns the underlying string that's being demangled. ++ pub fn as_str(&self) -> &'a str { ++ self.original ++ } ++} ++ ++// Rust hashes are hex digits with an `h` prepended. ++fn is_rust_hash(s: &str) -> bool { ++ s.starts_with('h') && s[1..].chars().all(|c| c.is_digit(16)) ++} ++ ++impl<'a> fmt::Display for Demangle<'a> { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ // Alright, let's do this. ++ if !self.valid { ++ return f.write_str(self.inner); ++ } ++ ++ let mut inner = self.inner; ++ for element in 0..self.elements { ++ let mut rest = inner; ++ while rest.chars().next().unwrap().is_digit(10) { ++ rest = &rest[1..]; ++ } ++ let i: usize = inner[..(inner.len() - rest.len())].parse().unwrap(); ++ inner = &rest[i..]; ++ rest = &rest[..i]; ++ // Skip printing the hash if alternate formatting ++ // was requested. ++ if f.alternate() && element+1 == self.elements && is_rust_hash(&rest) { ++ break; ++ } ++ if element != 0 { ++ try!(f.write_str("::")); ++ } ++ if rest.starts_with("_$") { ++ rest = &rest[1..]; ++ } ++ while !rest.is_empty() { ++ if rest.starts_with('.') { ++ if let Some('.') = rest[1..].chars().next() { ++ try!(f.write_str("::")); ++ rest = &rest[2..]; ++ } else { ++ try!(f.write_str(".")); ++ rest = &rest[1..]; ++ } ++ } else if rest.starts_with('$') { ++ macro_rules! demangle { ++ ($($pat:expr => $demangled:expr),*) => ({ ++ $(if rest.starts_with($pat) { ++ try!(f.write_str($demangled)); ++ rest = &rest[$pat.len()..]; ++ } else)* ++ { ++ try!(f.write_str(rest)); ++ break; ++ } ++ ++ }) ++ } ++ ++ // see src/librustc/back/link.rs for these mappings ++ demangle! { ++ "$SP$" => "@", ++ "$BP$" => "*", ++ "$RF$" => "&", ++ "$LT$" => "<", ++ "$GT$" => ">", ++ "$LP$" => "(", ++ "$RP$" => ")", ++ "$C$" => ",", ++ ++ // in theory we can demangle any Unicode code point, but ++ // for simplicity we just catch the common ones. ++ "$u7e$" => "~", ++ "$u20$" => " ", ++ "$u27$" => "'", ++ "$u5b$" => "[", ++ "$u5d$" => "]", ++ "$u7b$" => "{", ++ "$u7d$" => "}", ++ "$u3b$" => ";", ++ "$u2b$" => "+", ++ "$u22$" => "\"" ++ } ++ } else { ++ let idx = match rest.char_indices().find(|&(_, c)| c == '$' || c == '.') { ++ None => rest.len(), ++ Some((i, _)) => i, ++ }; ++ try!(f.write_str(&rest[..idx])); ++ rest = &rest[idx..]; ++ } ++ } ++ } ++ ++ Ok(()) ++ } ++} ++ ++impl<'a> fmt::Debug for Demangle<'a> { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ fmt::Display::fmt(self, f) ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::prelude::v1::*; ++ ++ macro_rules! t { ++ ($a:expr, $b:expr) => ({ ++ assert_eq!(super::demangle($a).to_string(), $b); ++ }) ++ } ++ ++ macro_rules! t_nohash { ++ ($a:expr, $b:expr) => ({ ++ assert_eq!(format!("{:#}", super::demangle($a)), $b); ++ }) ++ } ++ ++ #[test] ++ fn demangle() { ++ t!("test", "test"); ++ t!("_ZN4testE", "test"); ++ t!("_ZN4test", "_ZN4test"); ++ t!("_ZN4test1a2bcE", "test::a::bc"); ++ } ++ ++ #[test] ++ fn demangle_dollars() { ++ t!("_ZN4$RP$E", ")"); ++ t!("_ZN8$RF$testE", "&test"); ++ t!("_ZN8$BP$test4foobE", "*test::foob"); ++ t!("_ZN9$u20$test4foobE", " test::foob"); ++ t!("_ZN35Bar$LT$$u5b$u32$u3b$$u20$4$u5d$$GT$E", "Bar<[u32; 4]>"); ++ } ++ ++ #[test] ++ fn demangle_many_dollars() { ++ t!("_ZN13test$u20$test4foobE", "test test::foob"); ++ t!("_ZN12test$BP$test4foobE", "test*test::foob"); ++ } ++ ++ ++ #[test] ++ fn demangle_osx() { ++ t!("__ZN5alloc9allocator6Layout9for_value17h02a996811f781011E", "alloc::allocator::Layout::for_value::h02a996811f781011"); ++ t!("__ZN38_$LT$core..option..Option$LT$T$GT$$GT$6unwrap18_MSG_FILE_LINE_COL17haf7cb8d5824ee659E", ">::unwrap::_MSG_FILE_LINE_COL::haf7cb8d5824ee659"); ++ t!("__ZN4core5slice89_$LT$impl$u20$core..iter..traits..IntoIterator$u20$for$u20$$RF$$u27$a$u20$$u5b$T$u5d$$GT$9into_iter17h450e234d27262170E", "core::slice::::into_iter::h450e234d27262170"); ++ } ++ ++ #[test] ++ fn demangle_windows() { ++ t!("ZN4testE", "test"); ++ t!("ZN13test$u20$test4foobE", "test test::foob"); ++ t!("ZN12test$RF$test4foobE", "test&test::foob"); ++ } ++ ++ #[test] ++ fn demangle_elements_beginning_with_underscore() { ++ t!("_ZN13_$LT$test$GT$E", ""); ++ t!("_ZN28_$u7b$$u7b$closure$u7d$$u7d$E", "{{closure}}"); ++ t!("_ZN15__STATIC_FMTSTRE", "__STATIC_FMTSTR"); ++ } ++ ++ #[test] ++ fn demangle_trait_impls() { ++ t!("_ZN71_$LT$Test$u20$$u2b$$u20$$u27$static$u20$as$u20$foo..Bar$LT$Test$GT$$GT$3barE", ++ ">::bar"); ++ } ++ ++ #[test] ++ fn demangle_without_hash() { ++ let s = "_ZN3foo17h05af221e174051e9E"; ++ t!(s, "foo::h05af221e174051e9"); ++ t_nohash!(s, "foo"); ++ } ++ ++ #[test] ++ fn demangle_without_hash_edgecases() { ++ // One element, no hash. ++ t_nohash!("_ZN3fooE", "foo"); ++ // Two elements, no hash. ++ t_nohash!("_ZN3foo3barE", "foo::bar"); ++ // Longer-than-normal hash. ++ t_nohash!("_ZN3foo20h05af221e174051e9abcE", "foo"); ++ // Shorter-than-normal hash. ++ t_nohash!("_ZN3foo5h05afE", "foo"); ++ // Valid hash, but not at the end. ++ t_nohash!("_ZN17h05af221e174051e93fooE", "h05af221e174051e9::foo"); ++ // Not a valid hash, missing the 'h'. ++ t_nohash!("_ZN3foo16ffaf221e174051e9E", "foo::ffaf221e174051e9"); ++ // Not a valid hash, has a non-hex-digit. ++ t_nohash!("_ZN3foo17hg5af221e174051e9E", "foo::hg5af221e174051e9"); ++ } ++} diff --cc vendor/semver-0.8.0/.cargo-checksum.json index 000000000,000000000..4688e6f62 new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"bee2bc909ab2d8d60dab26e8cad85b25d795b14603a0dcb627b78b9d30b6454b"} diff --cc vendor/semver-0.8.0/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/.cargo-ok diff --cc vendor/semver-0.8.0/.travis.yml index 000000000,000000000..bb4ba27f0 new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/.travis.yml @@@ -1,0 -1,0 +1,18 @@@ ++language: rust ++rust: ++ - nightly ++ - beta ++ - stable ++sudo: false ++script: ++ - cargo build --verbose ++ - cargo test --verbose --features ci ++addons: ++ apt: ++ sources: ++ - kalakris-cmake ++ packages: ++ - cmake ++notifications: ++ email: ++ on_success: never diff --cc vendor/semver-0.8.0/Cargo.toml index 000000000,000000000..b8a77beea new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/Cargo.toml @@@ -1,0 -1,0 +1,45 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "semver" ++version = "0.8.0" ++authors = ["Steve Klabnik ", "The Rust Project Developers"] ++description = "Semantic version parsing and comparison.\n" ++homepage = "https://docs.rs/crate/semver/" ++documentation = "https://docs.rs/crate/semver/" ++readme = "README.md" ++license = "MIT/Apache-2.0" ++repository = "https://github.com/steveklabnik/semver" ++[dependencies.serde] ++version = "1.0" ++optional = true ++ ++[dependencies.semver-parser] ++version = "0.7.0" ++[dev-dependencies.serde_derive] ++version = "1.0" ++ ++[dev-dependencies.serde_json] ++version = "1.0" ++ ++[dev-dependencies.crates-index] ++version = "0.5.0" ++ ++[dev-dependencies.tempdir] ++version = "0.3.4" ++ ++[features] ++default = [] ++ci = ["serde"] ++[badges.travis-ci] ++repository = "steveklabnik/semver" diff --cc vendor/semver-0.8.0/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/semver-0.8.0/LICENSE-MIT index 000000000,000000000..39d4bdb5a new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/semver-0.8.0/README.md index 000000000,000000000..2a5306d4c new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/README.md @@@ -1,0 -1,0 +1,103 @@@ ++semver ++====== ++ ++Semantic version parsing and comparison. ++ ++[![Build Status](https://api.travis-ci.org/steveklabnik/semver.svg?branch=master)](https://travis-ci.org/steveklabnik/semver) ++ ++[Documentation](https://steveklabnik.github.io/semver) ++ ++Semantic versioning (see http://semver.org/) is a set of rules for ++assigning version numbers. ++ ++## SemVer and the Rust ecosystem ++ ++Rust itself follows the SemVer specification, as does its standard libraries. The two are ++not tied together. ++ ++[Cargo](https://crates.io), Rust's package manager, uses SemVer to determine which versions of ++packages you need installed. ++ ++## Installation ++ ++To use `semver`, add this to your `[dependencies]` section: ++ ++```toml ++semver = "0.7.0" ++``` ++ ++And this to your crate root: ++ ++```rust ++extern crate semver; ++``` ++ ++## Versions ++ ++At its simplest, the `semver` crate allows you to construct `Version` objects using the `parse` ++method: ++ ++```rust ++use semver::Version; ++ ++assert!(Version::parse("1.2.3") == Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec!(), ++ build: vec!(), ++})); ++``` ++ ++If you have multiple `Version`s, you can use the usual comparison operators to compare them: ++ ++```rust ++use semver::Version; ++ ++assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); ++assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); ++``` ++ ++## Requirements ++ ++The `semver` crate also provides the ability to compare requirements, which are more complex ++comparisons. ++ ++For example, creating a requirement that only matches versions greater than or ++equal to 1.0.0: ++ ++```rust ++use semver::Version; ++use semver::VersionReq; ++ ++let r = VersionReq::parse(">= 1.0.0").unwrap(); ++let v = Version::parse("1.0.0").unwrap(); ++ ++assert!(r.to_string() == ">= 1.0.0".to_string()); ++assert!(r.matches(&v)) ++``` ++ ++It also allows parsing of `~x.y.z` and `^x.y.z` requirements as defined at ++https://www.npmjs.org/doc/misc/semver.html ++ ++**Tilde requirements** specify a minimal version with some updates: ++ ++```notrust ++~1.2.3 := >=1.2.3 <1.3.0 ++~1.2 := >=1.2.0 <1.3.0 ++~1 := >=1.0.0 <2.0.0 ++``` ++ ++**Caret requirements** allow SemVer compatible updates to a specified version, ++`0.x` and `0.x+1` are not considered compatible, but `1.x` and `1.x+1` are. ++ ++`0.0.x` is not considered compatible with any other version. ++Missing minor and patch versions are desugared to `0` but allow flexibility for that value. ++ ++```notrust ++^1.2.3 := >=1.2.3 <2.0.0 ++^0.2.3 := >=0.2.3 <0.3.0 ++^0.0.3 := >=0.0.3 <0.0.4 ++^0.0 := >=0.0.0 <0.1.0 ++^0 := >=0.0.0 <1.0.0 ++``` diff --cc vendor/semver-0.8.0/src/lib.rs index 000000000,000000000..a38aae0e1 new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/src/lib.rs @@@ -1,0 -1,0 +1,182 @@@ ++// Copyright 2012-2013 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! Semantic version parsing and comparison. ++//! ++//! Semantic versioning (see http://semver.org/) is a set of rules for ++//! assigning version numbers. ++//! ++//! ## SemVer overview ++//! ++//! Given a version number MAJOR.MINOR.PATCH, increment the: ++//! ++//! 1. MAJOR version when you make incompatible API changes, ++//! 2. MINOR version when you add functionality in a backwards-compatible ++//! manner, and ++//! 3. PATCH version when you make backwards-compatible bug fixes. ++//! ++//! Additional labels for pre-release and build metadata are available as ++//! extensions to the MAJOR.MINOR.PATCH format. ++//! ++//! Any references to 'the spec' in this documentation refer to [version 2.0 of ++//! the SemVer spec](http://semver.org/spec/v2.0.0.html). ++//! ++//! ## SemVer and the Rust ecosystem ++//! ++//! Rust itself follows the SemVer specification, as does its standard ++//! libraries. The two are not tied together. ++//! ++//! [Cargo](http://crates.io), Rust's package manager, uses SemVer to determine ++//! which versions of packages you need installed. ++//! ++//! ## Versions ++//! ++//! At its simplest, the `semver` crate allows you to construct `Version` ++//! objects using the `parse` method: ++//! ++//! ```{rust} ++//! use semver::Version; ++//! ++//! assert!(Version::parse("1.2.3") == Ok(Version { ++//! major: 1, ++//! minor: 2, ++//! patch: 3, ++//! pre: vec!(), ++//! build: vec!(), ++//! })); ++//! ``` ++//! ++//! If you have multiple `Version`s, you can use the usual comparison operators ++//! to compare them: ++//! ++//! ```{rust} ++//! use semver::Version; ++//! ++//! assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); ++//! assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); ++//! ``` ++//! ++//! If you explicitly need to modify a Version, SemVer also allows you to ++//! increment the major, minor, and patch numbers in accordance with the spec. ++//! ++//! Please note that in order to do this, you must use a mutable Version: ++//! ++//! ```{rust} ++//! use semver::Version; ++//! ++//! let mut bugfix_release = Version::parse("1.0.0").unwrap(); ++//! bugfix_release.increment_patch(); ++//! ++//! assert_eq!(Ok(bugfix_release), Version::parse("1.0.1")); ++//! ``` ++//! ++//! When incrementing the minor version number, the patch number resets to zero ++//! (in accordance with section 7 of the spec) ++//! ++//! ```{rust} ++//! use semver::Version; ++//! ++//! let mut feature_release = Version::parse("1.4.6").unwrap(); ++//! feature_release.increment_minor(); ++//! ++//! assert_eq!(Ok(feature_release), Version::parse("1.5.0")); ++//! ``` ++//! ++//! Similarly, when incrementing the major version number, the patch and minor ++//! numbers reset to zero (in accordance with section 8 of the spec) ++//! ++//! ```{rust} ++//! use semver::Version; ++//! ++//! let mut chrome_release = Version::parse("41.5.5377").unwrap(); ++//! chrome_release.increment_major(); ++//! ++//! assert_eq!(Ok(chrome_release), Version::parse("42.0.0")); ++//! ``` ++//! ++//! ## Requirements ++//! ++//! The `semver` crate also provides the ability to compare requirements, which ++//! are more complex comparisons. ++//! ++//! For example, creating a requirement that only matches versions greater than ++//! or equal to 1.0.0: ++//! ++//! ```{rust} ++//! # #![allow(unstable)] ++//! use semver::Version; ++//! use semver::VersionReq; ++//! ++//! let r = VersionReq::parse(">= 1.0.0").unwrap(); ++//! let v = Version::parse("1.0.0").unwrap(); ++//! ++//! assert!(r.to_string() == ">= 1.0.0".to_string()); ++//! assert!(r.matches(&v)) ++//! ``` ++//! ++//! It also allows parsing of `~x.y.z` and `^x.y.z` requirements as defined at ++//! https://www.npmjs.org/doc/misc/semver.html ++//! ++//! **Tilde requirements** specify a minimal version with some updates: ++//! ++//! ```notrust ++//! ~1.2.3 := >=1.2.3 <1.3.0 ++//! ~1.2 := >=1.2.0 <1.3.0 ++//! ~1 := >=1.0.0 <2.0.0 ++//! ``` ++//! ++//! **Caret requirements** allow SemVer compatible updates to a specified ++//! verion, `0.x` and `0.x+1` are not considered compatible, but `1.x` and ++//! `1.x+1` are. ++//! ++//! `0.0.x` is not considered compatible with any other version. ++//! Missing minor and patch versions are desugared to `0` but allow flexibility ++//! for that value. ++//! ++//! ```notrust ++//! ^1.2.3 := >=1.2.3 <2.0.0 ++//! ^0.2.3 := >=0.2.3 <0.3.0 ++//! ^0.0.3 := >=0.0.3 <0.0.4 ++//! ^0.0 := >=0.0.0 <0.1.0 ++//! ^0 := >=0.0.0 <1.0.0 ++//! ``` ++//! ++//! **Wildcard requirements** allows parsing of version requirements of the ++//! formats `*`, `x.*` and `x.y.*`. ++//! ++//! ```notrust ++//! * := >=0.0.0 ++//! 1.* := >=1.0.0 <2.0.0 ++//! 1.2.* := >=1.2.0 <1.3.0 ++//! ``` ++ ++#![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")] ++#![deny(missing_docs)] ++#![cfg_attr(test, deny(warnings))] ++ ++extern crate semver_parser; ++ ++// Serialization and deserialization support for version numbers ++#[cfg(feature = "serde")] ++extern crate serde; ++ ++// We take the common approach of keeping our own module system private, and ++// just re-exporting the interface that we want. ++ ++pub use version::{Version, Identifier, SemVerError}; ++pub use version::Identifier::{Numeric, AlphaNumeric}; ++pub use version_req::{VersionReq, ReqParseError}; ++ ++// SemVer-compliant versions. ++mod version; ++ ++// advanced version comparisons ++mod version_req; diff --cc vendor/semver-0.8.0/src/version.rs index 000000000,000000000..38de13319 new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/src/version.rs @@@ -1,0 -1,0 +1,759 @@@ ++// Copyright 2012-2013 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! The `version` module gives you tools to create and compare SemVer-compliant ++//! versions. ++ ++use std::cmp::{self, Ordering}; ++use std::fmt; ++use std::hash; ++use std::error::Error; ++ ++use std::result; ++use std::str; ++ ++use semver_parser; ++ ++#[cfg(feature = "serde")] ++use serde::ser::{Serialize, Serializer}; ++#[cfg(feature = "serde")] ++use serde::de::{self, Deserialize, Deserializer, Visitor}; ++ ++/// An identifier in the pre-release or build metadata. ++/// ++/// See sections 9 and 10 of the spec for more about pre-release identifers and ++/// build metadata. ++#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] ++pub enum Identifier { ++ /// An identifier that's solely numbers. ++ Numeric(u64), ++ /// An identifier with letters and numbers. ++ AlphaNumeric(String), ++} ++ ++impl From for Identifier { ++ fn from(other: semver_parser::version::Identifier) -> Identifier { ++ match other { ++ semver_parser::version::Identifier::Numeric(n) => Identifier::Numeric(n), ++ semver_parser::version::Identifier::AlphaNumeric(s) => Identifier::AlphaNumeric(s), ++ } ++ } ++} ++ ++impl fmt::Display for Identifier { ++ #[inline] ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ match *self { ++ Identifier::Numeric(ref n) => fmt::Display::fmt(n, f), ++ Identifier::AlphaNumeric(ref s) => fmt::Display::fmt(s, f), ++ } ++ } ++} ++ ++#[cfg(feature = "serde")] ++impl Serialize for Identifier { ++ fn serialize(&self, serializer: S) -> result::Result ++ where S: Serializer ++ { ++ // Serialize Identifier as a number or string. ++ match *self { ++ Identifier::Numeric(n) => serializer.serialize_u64(n), ++ Identifier::AlphaNumeric(ref s) => serializer.serialize_str(s), ++ } ++ } ++} ++ ++#[cfg(feature = "serde")] ++impl<'de> Deserialize<'de> for Identifier { ++ fn deserialize(deserializer: D) -> result::Result ++ where D: Deserializer<'de> ++ { ++ struct IdentifierVisitor; ++ ++ // Deserialize Identifier from a number or string. ++ impl<'de> Visitor<'de> for IdentifierVisitor { ++ type Value = Identifier; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a SemVer pre-release or build identifier") ++ } ++ ++ fn visit_u64(self, numeric: u64) -> result::Result ++ where E: de::Error ++ { ++ Ok(Identifier::Numeric(numeric)) ++ } ++ ++ fn visit_str(self, alphanumeric: &str) -> result::Result ++ where E: de::Error ++ { ++ Ok(Identifier::AlphaNumeric(alphanumeric.to_owned())) ++ } ++ } ++ ++ deserializer.deserialize_any(IdentifierVisitor) ++ } ++} ++ ++/// Represents a version number conforming to the semantic versioning scheme. ++#[derive(Clone, Eq, Debug)] ++pub struct Version { ++ /// The major version, to be incremented on incompatible changes. ++ pub major: u64, ++ /// The minor version, to be incremented when functionality is added in a ++ /// backwards-compatible manner. ++ pub minor: u64, ++ /// The patch version, to be incremented when backwards-compatible bug ++ /// fixes are made. ++ pub patch: u64, ++ /// The pre-release version identifier, if one exists. ++ pub pre: Vec, ++ /// The build metadata, ignored when determining version precedence. ++ pub build: Vec, ++} ++ ++impl From for Version { ++ fn from(other: semver_parser::version::Version) -> Version { ++ Version { ++ major: other.major, ++ minor: other.minor, ++ patch: other.patch, ++ pre: other.pre.into_iter().map(From::from).collect(), ++ build: other.build.into_iter().map(From::from).collect(), ++ } ++ } ++} ++ ++#[cfg(feature = "serde")] ++impl Serialize for Version { ++ fn serialize(&self, serializer: S) -> result::Result ++ where S: Serializer ++ { ++ // Serialize Version as a string. ++ serializer.collect_str(self) ++ } ++} ++ ++#[cfg(feature = "serde")] ++impl<'de> Deserialize<'de> for Version { ++ fn deserialize(deserializer: D) -> result::Result ++ where D: Deserializer<'de> ++ { ++ struct VersionVisitor; ++ ++ // Deserialize Version from a string. ++ impl<'de> Visitor<'de> for VersionVisitor { ++ type Value = Version; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a SemVer version as a string") ++ } ++ ++ fn visit_str(self, v: &str) -> result::Result ++ where E: de::Error ++ { ++ Version::parse(v).map_err(de::Error::custom) ++ } ++ } ++ ++ deserializer.deserialize_str(VersionVisitor) ++ } ++} ++ ++/// An error type for this crate ++/// ++/// Currently, just a generic error. Will make this nicer later. ++#[derive(Clone,PartialEq,Debug,PartialOrd)] ++pub enum SemVerError { ++ /// An error ocurred while parsing. ++ ParseError(String), ++} ++ ++impl fmt::Display for SemVerError { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ match self { ++ &SemVerError::ParseError(ref m) => write!(f, "{}", m), ++ } ++ } ++} ++ ++impl Error for SemVerError { ++ fn description(&self) -> &str { ++ match self { ++ &SemVerError::ParseError(ref m) => m, ++ } ++ } ++} ++ ++/// A Result type for errors ++pub type Result = result::Result; ++ ++impl Version { ++ ++ /// Contructs the simple case without pre or build. ++ pub fn new(major: u64, minor: u64, patch: u64) -> Version { ++ Version { ++ major: major, ++ minor: minor, ++ patch: patch, ++ pre: Vec::new(), ++ build: Vec::new() ++ } ++ } ++ ++ /// Parse a string into a semver object. ++ pub fn parse(version: &str) -> Result { ++ let res = semver_parser::version::parse(version); ++ ++ match res { ++ // Convert plain String error into proper ParseError ++ Err(e) => Err(SemVerError::ParseError(e)), ++ Ok(v) => Ok(From::from(v)), ++ } ++ } ++ ++ /// Clears the build metadata ++ fn clear_metadata(&mut self) { ++ self.build = Vec::new(); ++ self.pre = Vec::new(); ++ } ++ ++ /// Increments the patch number for this Version (Must be mutable) ++ pub fn increment_patch(&mut self) { ++ self.patch += 1; ++ self.clear_metadata(); ++ } ++ ++ /// Increments the minor version number for this Version (Must be mutable) ++ /// ++ /// As instructed by section 7 of the spec, the patch number is reset to 0. ++ pub fn increment_minor(&mut self) { ++ self.minor += 1; ++ self.patch = 0; ++ self.clear_metadata(); ++ } ++ ++ /// Increments the major version number for this Version (Must be mutable) ++ /// ++ /// As instructed by section 8 of the spec, the minor and patch numbers are ++ /// reset to 0 ++ pub fn increment_major(&mut self) { ++ self.major += 1; ++ self.minor = 0; ++ self.patch = 0; ++ self.clear_metadata(); ++ } ++ ++ /// Checks to see if the current Version is in pre-release status ++ pub fn is_prerelease(&self) -> bool { ++ !self.pre.is_empty() ++ } ++} ++ ++impl str::FromStr for Version { ++ type Err = SemVerError; ++ ++ fn from_str(s: &str) -> Result { ++ Version::parse(s) ++ } ++} ++ ++impl fmt::Display for Version { ++ #[inline] ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ try!(write!(f, "{}.{}.{}", self.major, self.minor, self.patch)); ++ if !self.pre.is_empty() { ++ try!(write!(f, "-")); ++ for (i, x) in self.pre.iter().enumerate() { ++ if i != 0 { ++ try!(write!(f, ".")) ++ } ++ try!(write!(f, "{}", x)); ++ } ++ } ++ if !self.build.is_empty() { ++ try!(write!(f, "+")); ++ for (i, x) in self.build.iter().enumerate() { ++ if i != 0 { ++ try!(write!(f, ".")) ++ } ++ try!(write!(f, "{}", x)); ++ } ++ } ++ Ok(()) ++ } ++} ++ ++impl cmp::PartialEq for Version { ++ #[inline] ++ fn eq(&self, other: &Version) -> bool { ++ // We should ignore build metadata here, otherwise versions v1 and v2 ++ // can exist such that !(v1 < v2) && !(v1 > v2) && v1 != v2, which ++ // violate strict total ordering rules. ++ self.major == other.major && self.minor == other.minor && self.patch == other.patch && ++ self.pre == other.pre ++ } ++} ++ ++impl cmp::PartialOrd for Version { ++ fn partial_cmp(&self, other: &Version) -> Option { ++ Some(self.cmp(other)) ++ } ++} ++ ++impl cmp::Ord for Version { ++ fn cmp(&self, other: &Version) -> Ordering { ++ match self.major.cmp(&other.major) { ++ Ordering::Equal => {} ++ r => return r, ++ } ++ ++ match self.minor.cmp(&other.minor) { ++ Ordering::Equal => {} ++ r => return r, ++ } ++ ++ match self.patch.cmp(&other.patch) { ++ Ordering::Equal => {} ++ r => return r, ++ } ++ ++ // NB: semver spec says 0.0.0-pre < 0.0.0 ++ // but the version of ord defined for vec ++ // says that [] < [pre] so we alter it here ++ match (self.pre.len(), other.pre.len()) { ++ (0, 0) => Ordering::Equal, ++ (0, _) => Ordering::Greater, ++ (_, 0) => Ordering::Less, ++ (_, _) => self.pre.cmp(&other.pre), ++ } ++ } ++} ++ ++impl hash::Hash for Version { ++ fn hash(&self, into: &mut H) { ++ self.major.hash(into); ++ self.minor.hash(into); ++ self.patch.hash(into); ++ self.pre.hash(into); ++ } ++} ++ ++impl From<(u64,u64,u64)> for Version { ++ fn from(tuple: (u64,u64,u64)) -> Version { ++ let (major, minor, patch) = tuple; ++ Version::new(major, minor, patch) ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use std::result; ++ use super::Version; ++ use super::Identifier; ++ use super::SemVerError; ++ ++ #[test] ++ fn test_parse() { ++ fn parse_error(e: &str) -> result::Result { ++ return Err(SemVerError::ParseError(e.to_string())); ++ } ++ ++ assert_eq!(Version::parse(""), ++ parse_error("Error parsing major identifier")); ++ assert_eq!(Version::parse(" "), ++ parse_error("Error parsing major identifier")); ++ assert_eq!(Version::parse("1"), ++ parse_error("Expected dot")); ++ assert_eq!(Version::parse("1.2"), ++ parse_error("Expected dot")); ++ assert_eq!(Version::parse("1.2.3-"), ++ parse_error("Error parsing prerelease")); ++ assert_eq!(Version::parse("a.b.c"), ++ parse_error("Error parsing major identifier")); ++ assert_eq!(Version::parse("1.2.3 abc"), ++ parse_error("Extra junk after valid version: abc")); ++ ++ assert_eq!(Version::parse("1.2.3"), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: Vec::new(), ++ build: Vec::new(), ++ })); ++ ++ assert_eq!(Version::parse("1.2.3"), ++ Ok(Version::new(1,2,3))); ++ ++ assert_eq!(Version::parse(" 1.2.3 "), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: Vec::new(), ++ build: Vec::new(), ++ })); ++ assert_eq!(Version::parse("1.2.3-alpha1"), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], ++ build: Vec::new(), ++ })); ++ assert_eq!(Version::parse(" 1.2.3-alpha1 "), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], ++ build: Vec::new(), ++ })); ++ assert_eq!(Version::parse("1.2.3+build5"), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: Vec::new(), ++ build: vec![Identifier::AlphaNumeric(String::from("build5"))], ++ })); ++ assert_eq!(Version::parse(" 1.2.3+build5 "), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: Vec::new(), ++ build: vec![Identifier::AlphaNumeric(String::from("build5"))], ++ })); ++ assert_eq!(Version::parse("1.2.3-alpha1+build5"), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], ++ build: vec![Identifier::AlphaNumeric(String::from("build5"))], ++ })); ++ assert_eq!(Version::parse(" 1.2.3-alpha1+build5 "), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], ++ build: vec![Identifier::AlphaNumeric(String::from("build5"))], ++ })); ++ assert_eq!(Version::parse("1.2.3-1.alpha1.9+build5.7.3aedf "), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec![Identifier::Numeric(1), ++ Identifier::AlphaNumeric(String::from("alpha1")), ++ Identifier::Numeric(9), ++ ], ++ build: vec![Identifier::AlphaNumeric(String::from("build5")), ++ Identifier::Numeric(7), ++ Identifier::AlphaNumeric(String::from("3aedf")), ++ ], ++ })); ++ assert_eq!(Version::parse("0.4.0-beta.1+0851523"), ++ Ok(Version { ++ major: 0, ++ minor: 4, ++ patch: 0, ++ pre: vec![Identifier::AlphaNumeric(String::from("beta")), ++ Identifier::Numeric(1), ++ ], ++ build: vec![Identifier::AlphaNumeric(String::from("0851523"))], ++ })); ++ ++ } ++ ++ #[test] ++ fn test_increment_patch() { ++ let mut buggy_release = Version::parse("0.1.0").unwrap(); ++ buggy_release.increment_patch(); ++ assert_eq!(buggy_release, Version::parse("0.1.1").unwrap()); ++ } ++ ++ #[test] ++ fn test_increment_minor() { ++ let mut feature_release = Version::parse("1.4.6").unwrap(); ++ feature_release.increment_minor(); ++ assert_eq!(feature_release, Version::parse("1.5.0").unwrap()); ++ } ++ ++ #[test] ++ fn test_increment_major() { ++ let mut chrome_release = Version::parse("46.1.246773").unwrap(); ++ chrome_release.increment_major(); ++ assert_eq!(chrome_release, Version::parse("47.0.0").unwrap()); ++ } ++ ++ #[test] ++ fn test_increment_keep_prerelease() { ++ let mut release = Version::parse("1.0.0-alpha").unwrap(); ++ release.increment_patch(); ++ ++ assert_eq!(release, Version::parse("1.0.1").unwrap()); ++ ++ release.increment_minor(); ++ ++ assert_eq!(release, Version::parse("1.1.0").unwrap()); ++ ++ release.increment_major(); ++ ++ assert_eq!(release, Version::parse("2.0.0").unwrap()); ++ } ++ ++ ++ #[test] ++ fn test_increment_clear_metadata() { ++ let mut release = Version::parse("1.0.0+4442").unwrap(); ++ release.increment_patch(); ++ ++ assert_eq!(release, Version::parse("1.0.1").unwrap()); ++ release = Version::parse("1.0.1+hello").unwrap(); ++ ++ release.increment_minor(); ++ ++ assert_eq!(release, Version::parse("1.1.0").unwrap()); ++ release = Version::parse("1.1.3747+hello").unwrap(); ++ ++ release.increment_major(); ++ ++ assert_eq!(release, Version::parse("2.0.0").unwrap()); ++ } ++ ++ #[test] ++ fn test_eq() { ++ assert_eq!(Version::parse("1.2.3"), Version::parse("1.2.3")); ++ assert_eq!(Version::parse("1.2.3-alpha1"), ++ Version::parse("1.2.3-alpha1")); ++ assert_eq!(Version::parse("1.2.3+build.42"), ++ Version::parse("1.2.3+build.42")); ++ assert_eq!(Version::parse("1.2.3-alpha1+42"), ++ Version::parse("1.2.3-alpha1+42")); ++ assert_eq!(Version::parse("1.2.3+23"), Version::parse("1.2.3+42")); ++ } ++ ++ #[test] ++ fn test_ne() { ++ assert!(Version::parse("0.0.0") != Version::parse("0.0.1")); ++ assert!(Version::parse("0.0.0") != Version::parse("0.1.0")); ++ assert!(Version::parse("0.0.0") != Version::parse("1.0.0")); ++ assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta")); ++ } ++ ++ #[test] ++ fn test_show() { ++ assert_eq!(format!("{}", Version::parse("1.2.3").unwrap()), ++ "1.2.3".to_string()); ++ assert_eq!(format!("{}", Version::parse("1.2.3-alpha1").unwrap()), ++ "1.2.3-alpha1".to_string()); ++ assert_eq!(format!("{}", Version::parse("1.2.3+build.42").unwrap()), ++ "1.2.3+build.42".to_string()); ++ assert_eq!(format!("{}", Version::parse("1.2.3-alpha1+42").unwrap()), ++ "1.2.3-alpha1+42".to_string()); ++ } ++ ++ #[test] ++ fn test_to_string() { ++ assert_eq!(Version::parse("1.2.3").unwrap().to_string(), ++ "1.2.3".to_string()); ++ assert_eq!(Version::parse("1.2.3-alpha1").unwrap().to_string(), ++ "1.2.3-alpha1".to_string()); ++ assert_eq!(Version::parse("1.2.3+build.42").unwrap().to_string(), ++ "1.2.3+build.42".to_string()); ++ assert_eq!(Version::parse("1.2.3-alpha1+42").unwrap().to_string(), ++ "1.2.3-alpha1+42".to_string()); ++ } ++ ++ #[test] ++ fn test_lt() { ++ assert!(Version::parse("0.0.0") < Version::parse("1.2.3-alpha2")); ++ assert!(Version::parse("1.0.0") < Version::parse("1.2.3-alpha2")); ++ assert!(Version::parse("1.2.0") < Version::parse("1.2.3-alpha2")); ++ assert!(Version::parse("1.2.3-alpha1") < Version::parse("1.2.3")); ++ assert!(Version::parse("1.2.3-alpha1") < Version::parse("1.2.3-alpha2")); ++ assert!(!(Version::parse("1.2.3-alpha2") < Version::parse("1.2.3-alpha2"))); ++ assert!(!(Version::parse("1.2.3+23") < Version::parse("1.2.3+42"))); ++ } ++ ++ #[test] ++ fn test_le() { ++ assert!(Version::parse("0.0.0") <= Version::parse("1.2.3-alpha2")); ++ assert!(Version::parse("1.0.0") <= Version::parse("1.2.3-alpha2")); ++ assert!(Version::parse("1.2.0") <= Version::parse("1.2.3-alpha2")); ++ assert!(Version::parse("1.2.3-alpha1") <= Version::parse("1.2.3-alpha2")); ++ assert!(Version::parse("1.2.3-alpha2") <= Version::parse("1.2.3-alpha2")); ++ assert!(Version::parse("1.2.3+23") <= Version::parse("1.2.3+42")); ++ } ++ ++ #[test] ++ fn test_gt() { ++ assert!(Version::parse("1.2.3-alpha2") > Version::parse("0.0.0")); ++ assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.0.0")); ++ assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0")); ++ assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.3-alpha1")); ++ assert!(Version::parse("1.2.3") > Version::parse("1.2.3-alpha2")); ++ assert!(!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.3-alpha2"))); ++ assert!(!(Version::parse("1.2.3+23") > Version::parse("1.2.3+42"))); ++ } ++ ++ #[test] ++ fn test_ge() { ++ assert!(Version::parse("1.2.3-alpha2") >= Version::parse("0.0.0")); ++ assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.0.0")); ++ assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.0")); ++ assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha1")); ++ assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha2")); ++ assert!(Version::parse("1.2.3+23") >= Version::parse("1.2.3+42")); ++ } ++ ++ #[test] ++ fn test_prerelease_check() { ++ assert!(Version::parse("1.0.0").unwrap().is_prerelease() == false); ++ assert!(Version::parse("0.0.1").unwrap().is_prerelease() == false); ++ assert!(Version::parse("4.1.4-alpha").unwrap().is_prerelease()); ++ assert!(Version::parse("1.0.0-beta294296").unwrap().is_prerelease()); ++ } ++ ++ #[test] ++ fn test_spec_order() { ++ let vs = ["1.0.0-alpha", ++ "1.0.0-alpha.1", ++ "1.0.0-alpha.beta", ++ "1.0.0-beta", ++ "1.0.0-beta.2", ++ "1.0.0-beta.11", ++ "1.0.0-rc.1", ++ "1.0.0"]; ++ let mut i = 1; ++ while i < vs.len() { ++ let a = Version::parse(vs[i - 1]); ++ let b = Version::parse(vs[i]); ++ assert!(a < b, "nope {:?} < {:?}", a, b); ++ i += 1; ++ } ++ } ++ ++ #[test] ++ fn test_from_str() { ++ assert_eq!("1.2.3".parse(), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: Vec::new(), ++ build: Vec::new(), ++ })); ++ assert_eq!(" 1.2.3 ".parse(), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: Vec::new(), ++ build: Vec::new(), ++ })); ++ assert_eq!("1.2.3-alpha1".parse(), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], ++ build: Vec::new(), ++ })); ++ assert_eq!(" 1.2.3-alpha1 ".parse(), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], ++ build: Vec::new(), ++ })); ++ assert_eq!("1.2.3+build5".parse(), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: Vec::new(), ++ build: vec![Identifier::AlphaNumeric(String::from("build5"))], ++ })); ++ assert_eq!(" 1.2.3+build5 ".parse(), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: Vec::new(), ++ build: vec![Identifier::AlphaNumeric(String::from("build5"))], ++ })); ++ assert_eq!("1.2.3-alpha1+build5".parse(), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], ++ build: vec![Identifier::AlphaNumeric(String::from("build5"))], ++ })); ++ assert_eq!(" 1.2.3-alpha1+build5 ".parse(), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))], ++ build: vec![Identifier::AlphaNumeric(String::from("build5"))], ++ })); ++ assert_eq!("1.2.3-1.alpha1.9+build5.7.3aedf ".parse(), ++ Ok(Version { ++ major: 1, ++ minor: 2, ++ patch: 3, ++ pre: vec![Identifier::Numeric(1), ++ Identifier::AlphaNumeric(String::from("alpha1")), ++ Identifier::Numeric(9), ++ ], ++ build: vec![Identifier::AlphaNumeric(String::from("build5")), ++ Identifier::Numeric(7), ++ Identifier::AlphaNumeric(String::from("3aedf")), ++ ], ++ })); ++ assert_eq!("0.4.0-beta.1+0851523".parse(), ++ Ok(Version { ++ major: 0, ++ minor: 4, ++ patch: 0, ++ pre: vec![Identifier::AlphaNumeric(String::from("beta")), ++ Identifier::Numeric(1), ++ ], ++ build: vec![Identifier::AlphaNumeric(String::from("0851523"))], ++ })); ++ ++ } ++ ++ #[test] ++ fn test_from_str_errors() { ++ fn parse_error(e: &str) -> result::Result { ++ return Err(SemVerError::ParseError(e.to_string())); ++ } ++ ++ assert_eq!("".parse(), parse_error("Error parsing major identifier")); ++ assert_eq!(" ".parse(), parse_error("Error parsing major identifier")); ++ assert_eq!("1".parse(), parse_error("Expected dot")); ++ assert_eq!("1.2".parse(), ++ parse_error("Expected dot")); ++ assert_eq!("1.2.3-".parse(), ++ parse_error("Error parsing prerelease")); ++ assert_eq!("a.b.c".parse(), ++ parse_error("Error parsing major identifier")); ++ assert_eq!("1.2.3 abc".parse(), ++ parse_error("Extra junk after valid version: abc")); ++ } ++} diff --cc vendor/semver-0.8.0/src/version_req.rs index 000000000,000000000..df58a62a9 new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/src/version_req.rs @@@ -1,0 -1,0 +1,867 @@@ ++// Copyright 2012-2013 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::error::Error; ++use std::fmt; ++use std::result; ++use std::str; ++ ++use Version; ++use version::Identifier; ++use semver_parser; ++ ++#[cfg(feature = "serde")] ++use serde::ser::{Serialize, Serializer}; ++#[cfg(feature = "serde")] ++use serde::de::{self, Deserialize, Deserializer, Visitor}; ++ ++use self::Op::{Ex, Gt, GtEq, Lt, LtEq, Tilde, Compatible, Wildcard}; ++use self::WildcardVersion::{Major, Minor, Patch}; ++use self::ReqParseError::*; ++ ++/// A `VersionReq` is a struct containing a list of predicates that can apply to ranges of version ++/// numbers. Matching operations can then be done with the `VersionReq` against a particular ++/// version to see if it satisfies some or all of the constraints. ++#[derive(PartialEq,Clone,Debug)] ++pub struct VersionReq { ++ predicates: Vec, ++} ++ ++impl From for VersionReq { ++ fn from(other: semver_parser::range::VersionReq) -> VersionReq { ++ VersionReq { predicates: other.predicates.into_iter().map(From::from).collect() } ++ } ++} ++ ++#[cfg(feature = "serde")] ++impl Serialize for VersionReq { ++ fn serialize(&self, serializer: S) -> result::Result ++ where S: Serializer ++ { ++ // Serialize VersionReq as a string. ++ serializer.collect_str(self) ++ } ++} ++ ++#[cfg(feature = "serde")] ++impl<'de> Deserialize<'de> for VersionReq { ++ fn deserialize(deserializer: D) -> result::Result ++ where D: Deserializer<'de> ++ { ++ struct VersionReqVisitor; ++ ++ /// Deserialize `VersionReq` from a string. ++ impl<'de> Visitor<'de> for VersionReqVisitor { ++ type Value = VersionReq; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a SemVer version requirement as a string") ++ } ++ ++ fn visit_str(self, v: &str) -> result::Result ++ where E: de::Error ++ { ++ VersionReq::parse(v).map_err(de::Error::custom) ++ } ++ } ++ ++ deserializer.deserialize_str(VersionReqVisitor) ++ } ++} ++ ++#[derive(Clone, PartialEq, Debug)] ++enum WildcardVersion { ++ Major, ++ Minor, ++ Patch, ++} ++ ++#[derive(PartialEq,Clone,Debug)] ++enum Op { ++ Ex, // Exact ++ Gt, // Greater than ++ GtEq, // Greater than or equal to ++ Lt, // Less than ++ LtEq, // Less than or equal to ++ Tilde, // e.g. ~1.0.0 ++ Compatible, // compatible by definition of semver, indicated by ^ ++ Wildcard(WildcardVersion), // x.y.*, x.*, * ++} ++ ++impl From for Op { ++ fn from(other: semver_parser::range::Op) -> Op { ++ use semver_parser::range; ++ match other { ++ range::Op::Ex => Op::Ex, ++ range::Op::Gt => Op::Gt, ++ range::Op::GtEq => Op::GtEq, ++ range::Op::Lt => Op::Lt, ++ range::Op::LtEq => Op::LtEq, ++ range::Op::Tilde => Op::Tilde, ++ range::Op::Compatible => Op::Compatible, ++ range::Op::Wildcard(version) => { ++ match version { ++ range::WildcardVersion::Major => Op::Wildcard(WildcardVersion::Major), ++ range::WildcardVersion::Minor => Op::Wildcard(WildcardVersion::Minor), ++ range::WildcardVersion::Patch => Op::Wildcard(WildcardVersion::Patch), ++ } ++ } ++ } ++ } ++} ++ ++#[derive(PartialEq,Clone,Debug)] ++struct Predicate { ++ op: Op, ++ major: u64, ++ minor: Option, ++ patch: Option, ++ pre: Vec, ++} ++ ++impl From for Predicate { ++ fn from(other: semver_parser::range::Predicate) -> Predicate { ++ Predicate { ++ op: From::from(other.op), ++ major: other.major, ++ minor: other.minor, ++ patch: other.patch, ++ pre: other.pre.into_iter().map(From::from).collect(), ++ } ++ } ++} ++ ++/// A `ReqParseError` is returned from methods which parse a string into a `VersionReq`. Each ++/// enumeration is one of the possible errors that can occur. ++#[derive(Clone, Debug, PartialEq)] ++pub enum ReqParseError { ++ /// The given version requirement is invalid. ++ InvalidVersionRequirement, ++ /// You have already provided an operation, such as `=`, `~`, or `^`. Only use one. ++ OpAlreadySet, ++ /// The sigil you have written is not correct. ++ InvalidSigil, ++ /// All components of a version must be numeric. ++ VersionComponentsMustBeNumeric, ++ /// There was an error parsing an identifier. ++ InvalidIdentifier, ++ /// At least a major version is required. ++ MajorVersionRequired, ++ /// An unimplemented version requirement. ++ UnimplementedVersionRequirement, ++ /// This form of requirement is deprecated. ++ DeprecatedVersionRequirement(VersionReq), ++} ++ ++impl fmt::Display for ReqParseError { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ self.description().fmt(f) ++ } ++} ++ ++impl Error for ReqParseError { ++ fn description(&self) -> &str { ++ match self { ++ &InvalidVersionRequirement => "the given version requirement is invalid", ++ &OpAlreadySet => { ++ "you have already provided an operation, such as =, ~, or ^; only use one" ++ }, ++ &InvalidSigil => "the sigil you have written is not correct", ++ &VersionComponentsMustBeNumeric => "version components must be numeric", ++ &InvalidIdentifier => "invalid identifier", ++ &MajorVersionRequired => "at least a major version number is required", ++ &UnimplementedVersionRequirement => { ++ "the given version requirement is not implemented, yet" ++ }, ++ &DeprecatedVersionRequirement(_) => "This requirement is deprecated", ++ } ++ } ++} ++ ++impl From for ReqParseError { ++ fn from(other: String) -> ReqParseError { ++ match &*other { ++ "Null is not a valid VersionReq" => ReqParseError::InvalidVersionRequirement, ++ "VersionReq did not parse properly." => ReqParseError::OpAlreadySet, ++ _ => ReqParseError::InvalidVersionRequirement, ++ } ++ } ++} ++ ++impl VersionReq { ++ /// `any()` is a factory method which creates a `VersionReq` with no constraints. In other ++ /// words, any version will match against it. ++ /// ++ /// # Examples ++ /// ++ /// ``` ++ /// use semver::VersionReq; ++ /// ++ /// let anything = VersionReq::any(); ++ /// ``` ++ pub fn any() -> VersionReq { ++ VersionReq { predicates: vec![] } ++ } ++ ++ /// `parse()` is the main constructor of a `VersionReq`. It takes a string like `"^1.2.3"` ++ /// and turns it into a `VersionReq` that matches that particular constraint. ++ /// ++ /// A `Result` is returned which contains a `ReqParseError` if there was a problem parsing the ++ /// `VersionReq`. ++ /// ++ /// # Examples ++ /// ++ /// ``` ++ /// use semver::VersionReq; ++ /// ++ /// let version = VersionReq::parse("=1.2.3"); ++ /// let version = VersionReq::parse(">1.2.3"); ++ /// let version = VersionReq::parse("<1.2.3"); ++ /// let version = VersionReq::parse("~1.2.3"); ++ /// let version = VersionReq::parse("^1.2.3"); ++ /// let version = VersionReq::parse("1.2.3"); // synonym for ^1.2.3 ++ /// let version = VersionReq::parse("<=1.2.3"); ++ /// let version = VersionReq::parse(">=1.2.3"); ++ /// ``` ++ /// ++ /// This example demonstrates error handling, and will panic. ++ /// ++ /// ```should-panic ++ /// use semver::VersionReq; ++ /// ++ /// let version = match VersionReq::parse("not a version") { ++ /// Ok(version) => version, ++ /// Err(e) => panic!("There was a problem parsing: {}", e), ++ /// } ++ /// ``` ++ pub fn parse(input: &str) -> Result { ++ let res = semver_parser::range::parse(input); ++ ++ if let Ok(v) = res { ++ return Ok(From::from(v)); ++ } ++ ++ return match VersionReq::parse_deprecated(input) { ++ Some(v) => { ++ Err(ReqParseError::DeprecatedVersionRequirement(v)) ++ } ++ None => Err(From::from(res.err().unwrap())), ++ } ++ } ++ ++ fn parse_deprecated(version: &str) -> Option { ++ return match version { ++ ".*" => Some(VersionReq::any()), ++ "0.1.0." => Some(VersionReq::parse("0.1.0").unwrap()), ++ "0.3.1.3" => Some(VersionReq::parse("0.3.13").unwrap()), ++ "0.2*" => Some(VersionReq::parse("0.2.*").unwrap()), ++ "*.0" => Some(VersionReq::any()), ++ _ => None, ++ } ++ } ++ ++ /// `exact()` is a factory method which creates a `VersionReq` with one exact constraint. ++ /// ++ /// # Examples ++ /// ++ /// ``` ++ /// use semver::VersionReq; ++ /// use semver::Version; ++ /// ++ /// let version = Version { major: 1, minor: 1, patch: 1, pre: vec![], build: vec![] }; ++ /// let exact = VersionReq::exact(&version); ++ /// ``` ++ pub fn exact(version: &Version) -> VersionReq { ++ VersionReq { predicates: vec![Predicate::exact(version)] } ++ } ++ ++ /// `matches()` matches a given `Version` against this `VersionReq`. ++ /// ++ /// # Examples ++ /// ++ /// ``` ++ /// use semver::VersionReq; ++ /// use semver::Version; ++ /// ++ /// let version = Version { major: 1, minor: 1, patch: 1, pre: vec![], build: vec![] }; ++ /// let exact = VersionReq::exact(&version); ++ /// ++ /// assert!(exact.matches(&version)); ++ /// ``` ++ pub fn matches(&self, version: &Version) -> bool { ++ // no predicates means anything matches ++ if self.predicates.is_empty() { ++ return true; ++ } ++ ++ self.predicates.iter().all(|p| p.matches(version)) && ++ self.predicates.iter().any(|p| p.pre_tag_is_compatible(version)) ++ } ++} ++ ++impl str::FromStr for VersionReq { ++ type Err = ReqParseError; ++ ++ fn from_str(s: &str) -> Result { ++ VersionReq::parse(s) ++ } ++} ++ ++impl Predicate { ++ fn exact(version: &Version) -> Predicate { ++ Predicate { ++ op: Ex, ++ major: version.major, ++ minor: Some(version.minor), ++ patch: Some(version.patch), ++ pre: version.pre.clone(), ++ } ++ } ++ ++ /// `matches()` takes a `Version` and determines if it matches this particular `Predicate`. ++ pub fn matches(&self, ver: &Version) -> bool { ++ match self.op { ++ Ex => self.is_exact(ver), ++ Gt => self.is_greater(ver), ++ GtEq => self.is_exact(ver) || self.is_greater(ver), ++ Lt => !self.is_exact(ver) && !self.is_greater(ver), ++ LtEq => !self.is_greater(ver), ++ Tilde => self.matches_tilde(ver), ++ Compatible => self.is_compatible(ver), ++ Wildcard(_) => self.matches_wildcard(ver), ++ } ++ } ++ ++ fn is_exact(&self, ver: &Version) -> bool { ++ if self.major != ver.major { ++ return false; ++ } ++ ++ match self.minor { ++ Some(minor) => { ++ if minor != ver.minor { ++ return false; ++ } ++ } ++ None => return true, ++ } ++ ++ match self.patch { ++ Some(patch) => { ++ if patch != ver.patch { ++ return false; ++ } ++ } ++ None => return true, ++ } ++ ++ if self.pre != ver.pre { ++ return false; ++ } ++ ++ true ++ } ++ ++ // https://docs.npmjs.com/misc/semver#prerelease-tags ++ fn pre_tag_is_compatible(&self, ver: &Version) -> bool { ++ // If a version has a prerelease tag (for example, 1.2.3-alpha.3) then it will ++ // only be ++ // allowed to satisfy comparator sets if at least one comparator with the same ++ // [major, ++ // minor, patch] tuple also has a prerelease tag. ++ !ver.is_prerelease() || ++ (self.major == ver.major && self.minor == Some(ver.minor) && ++ self.patch == Some(ver.patch) && !self.pre.is_empty()) ++ } ++ ++ fn is_greater(&self, ver: &Version) -> bool { ++ if self.major != ver.major { ++ return ver.major > self.major; ++ } ++ ++ match self.minor { ++ Some(minor) => { ++ if minor != ver.minor { ++ return ver.minor > minor; ++ } ++ } ++ None => return false, ++ } ++ ++ match self.patch { ++ Some(patch) => { ++ if patch != ver.patch { ++ return ver.patch > patch; ++ } ++ } ++ None => return false, ++ } ++ ++ if !self.pre.is_empty() { ++ return ver.pre.is_empty() || ver.pre > self.pre; ++ } ++ ++ false ++ } ++ ++ // see https://www.npmjs.org/doc/misc/semver.html for behavior ++ fn matches_tilde(&self, ver: &Version) -> bool { ++ let minor = match self.minor { ++ Some(n) => n, ++ None => return self.major == ver.major, ++ }; ++ ++ match self.patch { ++ Some(patch) => { ++ self.major == ver.major && minor == ver.minor && ++ (ver.patch > patch || (ver.patch == patch && self.pre_is_compatible(ver))) ++ } ++ None => self.major == ver.major && minor == ver.minor, ++ } ++ } ++ ++ // see https://www.npmjs.org/doc/misc/semver.html for behavior ++ fn is_compatible(&self, ver: &Version) -> bool { ++ if self.major != ver.major { ++ return false; ++ } ++ ++ let minor = match self.minor { ++ Some(n) => n, ++ None => return self.major == ver.major, ++ }; ++ ++ match self.patch { ++ Some(patch) => { ++ if self.major == 0 { ++ if minor == 0 { ++ ver.minor == minor && ver.patch == patch && self.pre_is_compatible(ver) ++ } else { ++ ver.minor == minor && ++ (ver.patch > patch || (ver.patch == patch && self.pre_is_compatible(ver))) ++ } ++ } else { ++ ver.minor > minor || ++ (ver.minor == minor && ++ (ver.patch > patch || (ver.patch == patch && self.pre_is_compatible(ver)))) ++ } ++ } ++ None => { ++ if self.major == 0 { ++ ver.minor == minor ++ } else { ++ ver.minor >= minor ++ } ++ } ++ } ++ } ++ ++ fn pre_is_compatible(&self, ver: &Version) -> bool { ++ ver.pre.is_empty() || ver.pre >= self.pre ++ } ++ ++ // see https://www.npmjs.org/doc/misc/semver.html for behavior ++ fn matches_wildcard(&self, ver: &Version) -> bool { ++ match self.op { ++ Wildcard(Major) => true, ++ Wildcard(Minor) => self.major == ver.major, ++ Wildcard(Patch) => { ++ match self.minor { ++ Some(minor) => self.major == ver.major && minor == ver.minor, ++ None => { ++ // minor and patch version astericks mean match on major ++ self.major == ver.major ++ } ++ } ++ } ++ _ => false, // unreachable ++ } ++ } ++} ++ ++impl fmt::Display for VersionReq { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ if self.predicates.is_empty() { ++ try!(write!(fmt, "*")); ++ } else { ++ for (i, ref pred) in self.predicates.iter().enumerate() { ++ if i == 0 { ++ try!(write!(fmt, "{}", pred)); ++ } else { ++ try!(write!(fmt, ", {}", pred)); ++ } ++ } ++ } ++ ++ Ok(()) ++ } ++} ++ ++impl fmt::Display for Predicate { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ match self.op { ++ Wildcard(Major) => try!(write!(fmt, "*")), ++ Wildcard(Minor) => try!(write!(fmt, "{}.*", self.major)), ++ Wildcard(Patch) => { ++ if let Some(minor) = self.minor { ++ try!(write!(fmt, "{}.{}.*", self.major, minor)) ++ } else { ++ try!(write!(fmt, "{}.*.*", self.major)) ++ } ++ } ++ _ => { ++ try!(write!(fmt, "{}{}", self.op, self.major)); ++ ++ match self.minor { ++ Some(v) => try!(write!(fmt, ".{}", v)), ++ None => (), ++ } ++ ++ match self.patch { ++ Some(v) => try!(write!(fmt, ".{}", v)), ++ None => (), ++ } ++ ++ if !self.pre.is_empty() { ++ try!(write!(fmt, "-")); ++ for (i, x) in self.pre.iter().enumerate() { ++ if i != 0 { ++ try!(write!(fmt, ".")) ++ } ++ try!(write!(fmt, "{}", x)); ++ } ++ } ++ } ++ } ++ ++ Ok(()) ++ } ++} ++ ++impl fmt::Display for Op { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ match *self { ++ Ex => try!(write!(fmt, "= ")), ++ Gt => try!(write!(fmt, "> ")), ++ GtEq => try!(write!(fmt, ">= ")), ++ Lt => try!(write!(fmt, "< ")), ++ LtEq => try!(write!(fmt, "<= ")), ++ Tilde => try!(write!(fmt, "~")), ++ Compatible => try!(write!(fmt, "^")), ++ // gets handled specially in Predicate::fmt ++ Wildcard(_) => try!(write!(fmt, "")), ++ } ++ Ok(()) ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use super::{VersionReq, Op}; ++ use super::super::version::Version; ++ ++ fn req(s: &str) -> VersionReq { ++ VersionReq::parse(s).unwrap() ++ } ++ ++ fn version(s: &str) -> Version { ++ match Version::parse(s) { ++ Ok(v) => v, ++ Err(e) => panic!("`{}` is not a valid version. Reason: {:?}", s, e), ++ } ++ } ++ ++ fn assert_match(req: &VersionReq, vers: &[&str]) { ++ for ver in vers.iter() { ++ assert!(req.matches(&version(*ver)), "did not match {}", ver); ++ } ++ } ++ ++ fn assert_not_match(req: &VersionReq, vers: &[&str]) { ++ for ver in vers.iter() { ++ assert!(!req.matches(&version(*ver)), "matched {}", ver); ++ } ++ } ++ ++ #[test] ++ fn test_parsing_default() { ++ let r = req("1.0.0"); ++ ++ assert_eq!(r.to_string(), "^1.0.0".to_string()); ++ ++ assert_match(&r, &["1.0.0", "1.0.1"]); ++ assert_not_match(&r, &["0.9.9", "0.10.0", "0.1.0"]); ++ } ++ ++ #[test] ++ fn test_parsing_exact() { ++ let r = req("=1.0.0"); ++ ++ assert!(r.to_string() == "= 1.0.0".to_string()); ++ assert_eq!(r.to_string(), "= 1.0.0".to_string()); ++ ++ assert_match(&r, &["1.0.0"]); ++ assert_not_match(&r, &["1.0.1", "0.9.9", "0.10.0", "0.1.0", "1.0.0-pre"]); ++ ++ let r = req("=0.9.0"); ++ ++ assert_eq!(r.to_string(), "= 0.9.0".to_string()); ++ ++ assert_match(&r, &["0.9.0"]); ++ assert_not_match(&r, &["0.9.1", "1.9.0", "0.0.9"]); ++ ++ let r = req("=0.1.0-beta2.a"); ++ ++ assert_eq!(r.to_string(), "= 0.1.0-beta2.a".to_string()); ++ ++ assert_match(&r, &["0.1.0-beta2.a"]); ++ assert_not_match(&r, &["0.9.1", "0.1.0", "0.1.1-beta2.a", "0.1.0-beta2"]); ++ } ++ ++ #[test] ++ fn test_parse_metadata_see_issue_88_see_issue_88() { ++ for op in &[Op::Compatible, Op::Ex, Op::Gt, Op::GtEq, Op::Lt, Op::LtEq, Op::Tilde] { ++ req(&format!("{} 1.2.3+meta", op)); ++ } ++ } ++ ++ #[test] ++ pub fn test_parsing_greater_than() { ++ let r = req(">= 1.0.0"); ++ ++ assert_eq!(r.to_string(), ">= 1.0.0".to_string()); ++ ++ assert_match(&r, &["1.0.0", "2.0.0"]); ++ assert_not_match(&r, &["0.1.0", "0.0.1", "1.0.0-pre", "2.0.0-pre"]); ++ ++ let r = req(">= 2.1.0-alpha2"); ++ ++ assert_match(&r, &["2.1.0-alpha2", "2.1.0-alpha3", "2.1.0", "3.0.0"]); ++ assert_not_match(&r, ++ &["2.0.0", "2.1.0-alpha1", "2.0.0-alpha2", "3.0.0-alpha2"]); ++ } ++ ++ #[test] ++ pub fn test_parsing_less_than() { ++ let r = req("< 1.0.0"); ++ ++ assert_eq!(r.to_string(), "< 1.0.0".to_string()); ++ ++ assert_match(&r, &["0.1.0", "0.0.1"]); ++ assert_not_match(&r, &["1.0.0", "1.0.0-beta", "1.0.1", "0.9.9-alpha"]); ++ ++ let r = req("<= 2.1.0-alpha2"); ++ ++ assert_match(&r, &["2.1.0-alpha2", "2.1.0-alpha1", "2.0.0", "1.0.0"]); ++ assert_not_match(&r, ++ &["2.1.0", "2.2.0-alpha1", "2.0.0-alpha2", "1.0.0-alpha2"]); ++ } ++ ++ #[test] ++ pub fn test_multiple() { ++ let r = req("> 0.0.9, <= 2.5.3"); ++ assert_eq!(r.to_string(), "> 0.0.9, <= 2.5.3".to_string()); ++ assert_match(&r, &["0.0.10", "1.0.0", "2.5.3"]); ++ assert_not_match(&r, &["0.0.8", "2.5.4"]); ++ ++ let r = req("0.3.0, 0.4.0"); ++ assert_eq!(r.to_string(), "^0.3.0, ^0.4.0".to_string()); ++ assert_not_match(&r, &["0.0.8", "0.3.0", "0.4.0"]); ++ ++ let r = req("<= 0.2.0, >= 0.5.0"); ++ assert_eq!(r.to_string(), "<= 0.2.0, >= 0.5.0".to_string()); ++ assert_not_match(&r, &["0.0.8", "0.3.0", "0.5.1"]); ++ ++ let r = req("0.1.0, 0.1.4, 0.1.6"); ++ assert_eq!(r.to_string(), "^0.1.0, ^0.1.4, ^0.1.6".to_string()); ++ assert_match(&r, &["0.1.6", "0.1.9"]); ++ assert_not_match(&r, &["0.1.0", "0.1.4", "0.2.0"]); ++ ++ assert!(VersionReq::parse("> 0.1.0,").is_err()); ++ assert!(VersionReq::parse("> 0.3.0, ,").is_err()); ++ ++ let r = req(">=0.5.1-alpha3, <0.6"); ++ assert_eq!(r.to_string(), ">= 0.5.1-alpha3, < 0.6".to_string()); ++ assert_match(&r, ++ &["0.5.1-alpha3", "0.5.1-alpha4", "0.5.1-beta", "0.5.1", "0.5.5"]); ++ assert_not_match(&r, ++ &["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre"]); ++ assert_not_match(&r, &["0.6.0", "0.6.0-pre"]); ++ } ++ ++ #[test] ++ pub fn test_parsing_tilde() { ++ let r = req("~1"); ++ assert_match(&r, &["1.0.0", "1.0.1", "1.1.1"]); ++ assert_not_match(&r, &["0.9.1", "2.9.0", "0.0.9"]); ++ ++ let r = req("~1.2"); ++ assert_match(&r, &["1.2.0", "1.2.1"]); ++ assert_not_match(&r, &["1.1.1", "1.3.0", "0.0.9"]); ++ ++ let r = req("~1.2.2"); ++ assert_match(&r, &["1.2.2", "1.2.4"]); ++ assert_not_match(&r, &["1.2.1", "1.9.0", "1.0.9", "2.0.1", "0.1.3"]); ++ ++ let r = req("~1.2.3-beta.2"); ++ assert_match(&r, &["1.2.3", "1.2.4", "1.2.3-beta.2", "1.2.3-beta.4"]); ++ assert_not_match(&r, &["1.3.3", "1.1.4", "1.2.3-beta.1", "1.2.4-beta.2"]); ++ } ++ ++ #[test] ++ pub fn test_parsing_compatible() { ++ let r = req("^1"); ++ assert_match(&r, &["1.1.2", "1.1.0", "1.2.1", "1.0.1"]); ++ assert_not_match(&r, &["0.9.1", "2.9.0", "0.1.4"]); ++ assert_not_match(&r, &["1.0.0-beta1", "0.1.0-alpha", "1.0.1-pre"]); ++ ++ let r = req("^1.1"); ++ assert_match(&r, &["1.1.2", "1.1.0", "1.2.1"]); ++ assert_not_match(&r, &["0.9.1", "2.9.0", "1.0.1", "0.1.4"]); ++ ++ let r = req("^1.1.2"); ++ assert_match(&r, &["1.1.2", "1.1.4", "1.2.1"]); ++ assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]); ++ assert_not_match(&r, &["1.1.2-alpha1", "1.1.3-alpha1", "2.9.0-alpha1"]); ++ ++ let r = req("^0.1.2"); ++ assert_match(&r, &["0.1.2", "0.1.4"]); ++ assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]); ++ assert_not_match(&r, &["0.1.2-beta", "0.1.3-alpha", "0.2.0-pre"]); ++ ++ let r = req("^0.5.1-alpha3"); ++ assert_match(&r, ++ &["0.5.1-alpha3", "0.5.1-alpha4", "0.5.1-beta", "0.5.1", "0.5.5"]); ++ assert_not_match(&r, ++ &["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre", "0.6.0"]); ++ ++ let r = req("^0.0.2"); ++ assert_match(&r, &["0.0.2"]); ++ assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.4"]); ++ ++ let r = req("^0.0"); ++ assert_match(&r, &["0.0.2", "0.0.0"]); ++ assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.1.4"]); ++ ++ let r = req("^0"); ++ assert_match(&r, &["0.9.1", "0.0.2", "0.0.0"]); ++ assert_not_match(&r, &["2.9.0", "1.1.1"]); ++ ++ let r = req("^1.4.2-beta.5"); ++ assert_match(&r, ++ &["1.4.2", "1.4.3", "1.4.2-beta.5", "1.4.2-beta.6", "1.4.2-c"]); ++ assert_not_match(&r, ++ &["0.9.9", "2.0.0", "1.4.2-alpha", "1.4.2-beta.4", "1.4.3-beta.5"]); ++ } ++ ++ #[test] ++ pub fn test_parsing_wildcard() { ++ let r = req(""); ++ assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]); ++ assert_not_match(&r, &[]); ++ let r = req("*"); ++ assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]); ++ assert_not_match(&r, &[]); ++ let r = req("x"); ++ assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]); ++ assert_not_match(&r, &[]); ++ let r = req("X"); ++ assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]); ++ assert_not_match(&r, &[]); ++ ++ let r = req("1.*"); ++ assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]); ++ assert_not_match(&r, &["0.0.9"]); ++ let r = req("1.x"); ++ assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]); ++ assert_not_match(&r, &["0.0.9"]); ++ let r = req("1.X"); ++ assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]); ++ assert_not_match(&r, &["0.0.9"]); ++ ++ let r = req("1.2.*"); ++ assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]); ++ assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]); ++ let r = req("1.2.x"); ++ assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]); ++ assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]); ++ let r = req("1.2.X"); ++ assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]); ++ assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]); ++ } ++ ++ #[test] ++ pub fn test_any() { ++ let r = VersionReq::any(); ++ assert_match(&r, &["0.0.1", "0.1.0", "1.0.0"]); ++ } ++ ++ #[test] ++ pub fn test_pre() { ++ let r = req("=2.1.1-really.0"); ++ assert_match(&r, &["2.1.1-really.0"]); ++ } ++ ++ // #[test] ++ // pub fn test_parse_errors() { ++ // assert_eq!(Err(InvalidVersionRequirement), VersionReq::parse("\0")); ++ // assert_eq!(Err(OpAlreadySet), VersionReq::parse(">= >= 0.0.2")); ++ // assert_eq!(Err(InvalidSigil), VersionReq::parse(">== 0.0.2")); ++ // assert_eq!(Err(VersionComponentsMustBeNumeric), ++ // VersionReq::parse("a.0.0")); ++ // assert_eq!(Err(InvalidIdentifier), VersionReq::parse("1.0.0-")); ++ // assert_eq!(Err(MajorVersionRequired), VersionReq::parse(">=")); ++ // } ++ ++ #[test] ++ pub fn test_from_str() { ++ assert_eq!("1.0.0".parse::().unwrap().to_string(), ++ "^1.0.0".to_string()); ++ assert_eq!("=1.0.0".parse::().unwrap().to_string(), ++ "= 1.0.0".to_string()); ++ assert_eq!("~1".parse::().unwrap().to_string(), ++ "~1".to_string()); ++ assert_eq!("~1.2".parse::().unwrap().to_string(), ++ "~1.2".to_string()); ++ assert_eq!("^1".parse::().unwrap().to_string(), ++ "^1".to_string()); ++ assert_eq!("^1.1".parse::().unwrap().to_string(), ++ "^1.1".to_string()); ++ assert_eq!("*".parse::().unwrap().to_string(), ++ "*".to_string()); ++ assert_eq!("1.*".parse::().unwrap().to_string(), ++ "1.*".to_string()); ++ assert_eq!("< 1.0.0".parse::().unwrap().to_string(), ++ "< 1.0.0".to_string()); ++ } ++ ++ // #[test] ++ // pub fn test_from_str_errors() { ++ // assert_eq!(Err(InvalidVersionRequirement), "\0".parse::()); ++ // assert_eq!(Err(OpAlreadySet), ">= >= 0.0.2".parse::()); ++ // assert_eq!(Err(InvalidSigil), ">== 0.0.2".parse::()); ++ // assert_eq!(Err(VersionComponentsMustBeNumeric), ++ // "a.0.0".parse::()); ++ // assert_eq!(Err(InvalidIdentifier), "1.0.0-".parse::()); ++ // assert_eq!(Err(MajorVersionRequired), ">=".parse::()); ++ // } ++ ++ #[test] ++ fn test_cargo3202() { ++ let v = "0.*.*".parse::().unwrap(); ++ assert_eq!("0.*.*", format!("{}", v.predicates[0])); ++ ++ let v = "0.0.*".parse::().unwrap(); ++ assert_eq!("0.0.*", format!("{}", v.predicates[0])); ++ ++ let r = req("0.*.*"); ++ assert_match(&r, &["0.5.0"]); ++ } ++} diff --cc vendor/semver-0.8.0/tests/deprecation.rs index 000000000,000000000..a5f533a34 new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/tests/deprecation.rs @@@ -1,0 -1,0 +1,22 @@@ ++extern crate semver; ++ ++#[test] ++fn test_regressions() { ++ use semver::VersionReq; ++ use semver::ReqParseError; ++ ++ let versions = vec![ ++ (".*", VersionReq::any()), ++ ("0.1.0.", VersionReq::parse("0.1.0").unwrap()), ++ ("0.3.1.3", VersionReq::parse("0.3.13").unwrap()), ++ ("0.2*", VersionReq::parse("0.2.*").unwrap()), ++ ("*.0", VersionReq::any()), ++ ]; ++ ++ for (version, requirement) in versions.into_iter() { ++ let parsed = VersionReq::parse(version); ++ let error = parsed.err().unwrap(); ++ ++ assert_eq!(ReqParseError::DeprecatedVersionRequirement(requirement), error); ++ } ++} diff --cc vendor/semver-0.8.0/tests/regression.rs index 000000000,000000000..ef568a7d3 new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/tests/regression.rs @@@ -1,0 -1,0 +1,25 @@@ ++extern crate semver; ++extern crate crates_index; ++extern crate tempdir; ++ ++// This test checks to see if every existing crate parses successfully. Important to not break the ++// Rust universe! ++ ++#[cfg(feature = "ci")] ++#[test] ++fn test_regressions() { ++ use tempdir::TempDir; ++ use crates_index::Index; ++ use semver::Version; ++ ++ let dir = TempDir::new("semver").unwrap(); ++ let index = Index::new(dir.into_path()); ++ index.clone().unwrap(); ++ ++ for krate in index.crates() { ++ for version in krate.versions() { ++ let v = version.version(); ++ assert!(Version::parse(v).is_ok(), "failed: {} ({})", version.name(), v); ++ } ++ } ++} diff --cc vendor/semver-0.8.0/tests/serde.rs index 000000000,000000000..bcb92643c new file mode 100644 --- /dev/null +++ b/vendor/semver-0.8.0/tests/serde.rs @@@ -1,0 -1,0 +1,90 @@@ ++#![cfg(feature = "serde")] ++ ++#[macro_use] ++extern crate serde_derive; ++ ++extern crate semver; ++extern crate serde_json; ++ ++use semver::{Identifier, Version, VersionReq}; ++ ++#[derive(Serialize, Deserialize, PartialEq, Debug)] ++struct Identified { ++ name: String, ++ identifier: Identifier, ++} ++ ++#[derive(Serialize, Deserialize, PartialEq, Debug)] ++struct Versioned { ++ name: String, ++ vers: Version, ++} ++ ++#[test] ++fn serialize_identifier() { ++ let id = Identified { ++ name: "serde".to_owned(), ++ identifier: Identifier::Numeric(100), ++ }; ++ let j = serde_json::to_string(&id).unwrap(); ++ assert_eq!(j, r#"{"name":"serde","identifier":100}"#); ++ ++ let id = Identified { ++ name: "serde".to_owned(), ++ identifier: Identifier::AlphaNumeric("b100".to_owned()), ++ }; ++ let j = serde_json::to_string(&id).unwrap(); ++ assert_eq!(j, r#"{"name":"serde","identifier":"b100"}"#); ++} ++ ++#[test] ++fn deserialize_identifier() { ++ let j = r#"{"name":"serde","identifier":100}"#; ++ let id = serde_json::from_str::(j).unwrap(); ++ let expected = Identified { ++ name: "serde".to_owned(), ++ identifier: Identifier::Numeric(100), ++ }; ++ assert_eq!(id, expected); ++ ++ let j = r#"{"name":"serde","identifier":"b100"}"#; ++ let id = serde_json::from_str::(j).unwrap(); ++ let expected = Identified { ++ name: "serde".to_owned(), ++ identifier: Identifier::AlphaNumeric("b100".to_owned()), ++ }; ++ assert_eq!(id, expected); ++} ++ ++#[test] ++fn serialize_version() { ++ let v = Versioned { ++ name: "serde".to_owned(), ++ vers: Version::parse("1.0.0").unwrap(), ++ }; ++ let j = serde_json::to_string(&v).unwrap(); ++ assert_eq!(j, r#"{"name":"serde","vers":"1.0.0"}"#); ++} ++ ++#[test] ++fn deserialize_version() { ++ let j = r#"{"name":"serde","vers":"1.0.0"}"#; ++ let v = serde_json::from_str::(j).unwrap(); ++ let expected = Versioned { ++ name: "serde".to_owned(), ++ vers: Version::parse("1.0.0").unwrap(), ++ }; ++ assert_eq!(v, expected); ++} ++ ++#[test] ++fn serialize_versionreq() { ++ let v = VersionReq::exact(&Version::parse("1.0.0").unwrap()); ++ ++ assert_eq!(serde_json::to_string(&v).unwrap(), r#""= 1.0.0""#); ++} ++ ++#[test] ++fn deserialize_versionreq() { ++ assert_eq!("1.0.0".parse::().unwrap(), serde_json::from_str(r#""1.0.0""#).unwrap()); ++} diff --cc vendor/serde-1.0.15/.cargo-checksum.json index 000000000,000000000..85b53c522 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"6a7046c9d4c6c522d10b2d098f9bebe2bef227e0e74044d8c1bfcf6b476af799"} diff --cc vendor/serde-1.0.15/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/.cargo-ok diff --cc vendor/serde-1.0.15/Cargo.toml index 000000000,000000000..3622845dc new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/Cargo.toml @@@ -1,0 -1,0 +1,44 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "serde" ++version = "1.0.15" ++authors = ["Erick Tryzelaar ", "David Tolnay "] ++include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] ++description = "A generic serialization/deserialization framework" ++homepage = "https://serde.rs" ++documentation = "https://docs.serde.rs/serde/" ++readme = "README.md" ++keywords = ["serde", "serialization", "no_std"] ++categories = ["encoding"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/serde-rs/serde" ++[dependencies.serde_derive] ++version = "1.0" ++optional = true ++[dev-dependencies.serde_derive] ++version = "1.0" ++ ++[features] ++alloc = ["unstable"] ++default = ["std"] ++std = [] ++playground = ["serde_derive"] ++unstable = [] ++derive = ["serde_derive"] ++rc = [] ++[badges.travis-ci] ++repository = "serde-rs/serde" ++ ++[badges.appveyor] ++repository = "serde-rs/serde" diff --cc vendor/serde-1.0.15/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/serde-1.0.15/LICENSE-MIT index 000000000,000000000..39d4bdb5a new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/serde-1.0.15/README.md index 000000000,000000000..c2f35e9cd new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/README.md @@@ -1,0 -1,0 +1,81 @@@ ++# Serde   [![Build Status]][travis] [![Latest Version]][crates.io] ++ ++[Build Status]: https://api.travis-ci.org/serde-rs/serde.svg?branch=master ++[travis]: https://travis-ci.org/serde-rs/serde ++[Latest Version]: https://img.shields.io/crates/v/serde.svg ++[crates.io]: https://crates.io/crates/serde ++ ++**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.** ++ ++--- ++ ++You may be looking for: ++ ++- [An overview of Serde](https://serde.rs/) ++- [Data formats supported by Serde](https://serde.rs/#data-formats) ++- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html) ++- [Examples](https://serde.rs/examples.html) ++- [API documentation](https://docs.serde.rs/serde/) ++- [Release notes](https://github.com/serde-rs/serde/releases) ++ ++## Serde in action ++ ++ ++ ++ ++ ++```rust ++#[macro_use] ++extern crate serde_derive; ++ ++extern crate serde; ++extern crate serde_json; ++ ++#[derive(Serialize, Deserialize, Debug)] ++struct Point { ++ x: i32, ++ y: i32, ++} ++ ++fn main() { ++ let point = Point { x: 1, y: 2 }; ++ ++ // Convert the Point to a JSON string. ++ let serialized = serde_json::to_string(&point).unwrap(); ++ ++ // Prints serialized = {"x":1,"y":2} ++ println!("serialized = {}", serialized); ++ ++ // Convert the JSON string back to a Point. ++ let deserialized: Point = serde_json::from_str(&serialized).unwrap(); ++ ++ // Prints deserialized = Point { x: 1, y: 2 } ++ println!("deserialized = {:?}", deserialized); ++} ++``` ++ ++## Getting help ++ ++Serde developers live in the #serde channel on ++[`irc.mozilla.org`](https://wiki.mozilla.org/IRC). The #rust channel is also a ++good resource with generally faster response time but less specific knowledge ++about Serde. If IRC is not your thing or you don't get a good response, we are ++happy to respond to [GitHub issues](https://github.com/serde-rs/serde/issues/new) ++as well. ++ ++## License ++ ++Serde is licensed under either of ++ ++ * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ++ http://www.apache.org/licenses/LICENSE-2.0) ++ * MIT license ([LICENSE-MIT](LICENSE-MIT) or ++ http://opensource.org/licenses/MIT) ++ ++at your option. ++ ++### Contribution ++ ++Unless you explicitly state otherwise, any contribution intentionally submitted ++for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be ++dual licensed as above, without any additional terms or conditions. diff --cc vendor/serde-1.0.15/src/de/from_primitive.rs index 000000000,000000000..ae2939529 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/de/from_primitive.rs @@@ -1,0 -1,0 +1,116 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use lib::*; ++ ++macro_rules! int_to_int { ++ ($dst:ident, $n:ident) => ( ++ if $dst::MIN as i64 <= $n as i64 && $n as i64 <= $dst::MAX as i64 { ++ Some($n as $dst) ++ } else { ++ None ++ } ++ ) ++} ++ ++macro_rules! int_to_uint { ++ ($dst:ident, $n:ident) => ( ++ if 0 <= $n && $n as u64 <= $dst::MAX as u64 { ++ Some($n as $dst) ++ } else { ++ None ++ } ++ ) ++} ++ ++macro_rules! uint_to { ++ ($dst:ident, $n:ident) => ( ++ if $n as u64 <= $dst::MAX as u64 { ++ Some($n as $dst) ++ } else { ++ None ++ } ++ ) ++} ++ ++pub trait FromPrimitive: Sized { ++ fn from_isize(n: isize) -> Option; ++ fn from_i8(n: i8) -> Option; ++ fn from_i16(n: i16) -> Option; ++ fn from_i32(n: i32) -> Option; ++ fn from_i64(n: i64) -> Option; ++ fn from_usize(n: usize) -> Option; ++ fn from_u8(n: u8) -> Option; ++ fn from_u16(n: u16) -> Option; ++ fn from_u32(n: u32) -> Option; ++ fn from_u64(n: u64) -> Option; ++} ++ ++macro_rules! impl_from_primitive_for_int { ++ ($t:ident) => ( ++ impl FromPrimitive for $t { ++ #[inline] fn from_isize(n: isize) -> Option { int_to_int!($t, n) } ++ #[inline] fn from_i8(n: i8) -> Option { int_to_int!($t, n) } ++ #[inline] fn from_i16(n: i16) -> Option { int_to_int!($t, n) } ++ #[inline] fn from_i32(n: i32) -> Option { int_to_int!($t, n) } ++ #[inline] fn from_i64(n: i64) -> Option { int_to_int!($t, n) } ++ #[inline] fn from_usize(n: usize) -> Option { uint_to!($t, n) } ++ #[inline] fn from_u8(n: u8) -> Option { uint_to!($t, n) } ++ #[inline] fn from_u16(n: u16) -> Option { uint_to!($t, n) } ++ #[inline] fn from_u32(n: u32) -> Option { uint_to!($t, n) } ++ #[inline] fn from_u64(n: u64) -> Option { uint_to!($t, n) } ++ } ++ ) ++} ++ ++macro_rules! impl_from_primitive_for_uint { ++ ($t:ident) => ( ++ impl FromPrimitive for $t { ++ #[inline] fn from_isize(n: isize) -> Option { int_to_uint!($t, n) } ++ #[inline] fn from_i8(n: i8) -> Option { int_to_uint!($t, n) } ++ #[inline] fn from_i16(n: i16) -> Option { int_to_uint!($t, n) } ++ #[inline] fn from_i32(n: i32) -> Option { int_to_uint!($t, n) } ++ #[inline] fn from_i64(n: i64) -> Option { int_to_uint!($t, n) } ++ #[inline] fn from_usize(n: usize) -> Option { uint_to!($t, n) } ++ #[inline] fn from_u8(n: u8) -> Option { uint_to!($t, n) } ++ #[inline] fn from_u16(n: u16) -> Option { uint_to!($t, n) } ++ #[inline] fn from_u32(n: u32) -> Option { uint_to!($t, n) } ++ #[inline] fn from_u64(n: u64) -> Option { uint_to!($t, n) } ++ } ++ ) ++} ++ ++macro_rules! impl_from_primitive_for_float { ++ ($t:ident) => ( ++ impl FromPrimitive for $t { ++ #[inline] fn from_isize(n: isize) -> Option { Some(n as Self) } ++ #[inline] fn from_i8(n: i8) -> Option { Some(n as Self) } ++ #[inline] fn from_i16(n: i16) -> Option { Some(n as Self) } ++ #[inline] fn from_i32(n: i32) -> Option { Some(n as Self) } ++ #[inline] fn from_i64(n: i64) -> Option { Some(n as Self) } ++ #[inline] fn from_usize(n: usize) -> Option { Some(n as Self) } ++ #[inline] fn from_u8(n: u8) -> Option { Some(n as Self) } ++ #[inline] fn from_u16(n: u16) -> Option { Some(n as Self) } ++ #[inline] fn from_u32(n: u32) -> Option { Some(n as Self) } ++ #[inline] fn from_u64(n: u64) -> Option { Some(n as Self) } ++ } ++ ) ++} ++ ++impl_from_primitive_for_int!(isize); ++impl_from_primitive_for_int!(i8); ++impl_from_primitive_for_int!(i16); ++impl_from_primitive_for_int!(i32); ++impl_from_primitive_for_int!(i64); ++impl_from_primitive_for_uint!(usize); ++impl_from_primitive_for_uint!(u8); ++impl_from_primitive_for_uint!(u16); ++impl_from_primitive_for_uint!(u32); ++impl_from_primitive_for_uint!(u64); ++impl_from_primitive_for_float!(f32); ++impl_from_primitive_for_float!(f64); diff --cc vendor/serde-1.0.15/src/de/ignored_any.rs index 000000000,000000000..a4f3abe26 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/de/ignored_any.rs @@@ -1,0 -1,0 +1,215 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use lib::*; ++ ++use de::{Deserialize, Deserializer, Visitor, SeqAccess, MapAccess, Error}; ++ ++/// An efficient way of discarding data from a deserializer. ++/// ++/// Think of this like `serde_json::Value` in that it can be deserialized from ++/// any type, except that it does not store any information about the data that ++/// gets deserialized. ++/// ++/// ```rust ++/// use std::fmt; ++/// use std::marker::PhantomData; ++/// ++/// use serde::de::{self, Deserialize, DeserializeSeed, Deserializer, Visitor, SeqAccess, IgnoredAny}; ++/// ++/// /// A seed that can be used to deserialize only the `n`th element of a sequence ++/// /// while efficiently discarding elements of any type before or after index `n`. ++/// /// ++/// /// For example to deserialize only the element at index 3: ++/// /// ++/// /// ```rust ++/// /// NthElement::new(3).deserialize(deserializer) ++/// /// ``` ++/// pub struct NthElement { ++/// n: usize, ++/// marker: PhantomData, ++/// } ++/// ++/// impl NthElement { ++/// pub fn new(n: usize) -> Self { ++/// NthElement { ++/// n: n, ++/// marker: PhantomData, ++/// } ++/// } ++/// } ++/// ++/// impl<'de, T> Visitor<'de> for NthElement ++/// where T: Deserialize<'de> ++/// { ++/// type Value = T; ++/// ++/// fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++/// write!(formatter, "a sequence in which we care about element {}", self.n) ++/// } ++/// ++/// fn visit_seq(self, mut seq: A) -> Result ++/// where A: SeqAccess<'de> ++/// { ++/// // Skip over the first `n` elements. ++/// for i in 0..self.n { ++/// // It is an error if the sequence ends before we get to element `n`. ++/// if seq.next_element::()?.is_none() { ++/// return Err(de::Error::invalid_length(i, &self)); ++/// } ++/// } ++/// ++/// // Deserialize the one we care about. ++/// let nth = match seq.next_element()? { ++/// Some(nth) => nth, ++/// None => { ++/// return Err(de::Error::invalid_length(self.n, &self)); ++/// } ++/// }; ++/// ++/// // Skip over any remaining elements in the sequence after `n`. ++/// while let Some(IgnoredAny) = seq.next_element()? { ++/// // ignore ++/// } ++/// ++/// Ok(nth) ++/// } ++/// } ++/// ++/// impl<'de, T> DeserializeSeed<'de> for NthElement ++/// where T: Deserialize<'de> ++/// { ++/// type Value = T; ++/// ++/// fn deserialize(self, deserializer: D) -> Result ++/// where D: Deserializer<'de> ++/// { ++/// deserializer.deserialize_seq(self) ++/// } ++/// } ++/// ++/// # fn example<'de, D>(deserializer: D) -> Result<(), D::Error> ++/// # where D: Deserializer<'de> ++/// # { ++/// // Deserialize only the sequence element at index 3 from this deserializer. ++/// // The element at index 3 is required to be a string. Elements before and ++/// // after index 3 are allowed to be of any type. ++/// let s: String = NthElement::new(3).deserialize(deserializer)?; ++/// # Ok(()) ++/// # } ++/// ``` ++#[derive(Copy, Clone, Debug, Default)] ++pub struct IgnoredAny; ++ ++impl<'de> Visitor<'de> for IgnoredAny { ++ type Value = IgnoredAny; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("anything at all") ++ } ++ ++ #[inline] ++ fn visit_bool(self, x: bool) -> Result { ++ let _ = x; ++ Ok(IgnoredAny) ++ } ++ ++ #[inline] ++ fn visit_i64(self, x: i64) -> Result { ++ let _ = x; ++ Ok(IgnoredAny) ++ } ++ ++ #[inline] ++ fn visit_u64(self, x: u64) -> Result { ++ let _ = x; ++ Ok(IgnoredAny) ++ } ++ ++ #[inline] ++ fn visit_f64(self, x: f64) -> Result { ++ let _ = x; ++ Ok(IgnoredAny) ++ } ++ ++ #[inline] ++ fn visit_str(self, s: &str) -> Result ++ where ++ E: Error, ++ { ++ let _ = s; ++ Ok(IgnoredAny) ++ } ++ ++ #[inline] ++ fn visit_none(self) -> Result { ++ Ok(IgnoredAny) ++ } ++ ++ #[inline] ++ fn visit_some(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ IgnoredAny::deserialize(deserializer) ++ } ++ ++ #[inline] ++ fn visit_newtype_struct(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ IgnoredAny::deserialize(deserializer) ++ } ++ ++ #[inline] ++ fn visit_unit(self) -> Result { ++ Ok(IgnoredAny) ++ } ++ ++ #[inline] ++ fn visit_seq(self, mut seq: A) -> Result ++ where ++ A: SeqAccess<'de>, ++ { ++ while let Some(IgnoredAny) = try!(seq.next_element()) { ++ // Gobble ++ } ++ Ok(IgnoredAny) ++ } ++ ++ #[inline] ++ fn visit_map(self, mut map: A) -> Result ++ where ++ A: MapAccess<'de>, ++ { ++ while let Some((IgnoredAny, IgnoredAny)) = try!(map.next_entry()) { ++ // Gobble ++ } ++ Ok(IgnoredAny) ++ } ++ ++ #[inline] ++ fn visit_bytes(self, bytes: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ let _ = bytes; ++ Ok(IgnoredAny) ++ } ++} ++ ++impl<'de> Deserialize<'de> for IgnoredAny { ++ #[inline] ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_ignored_any(IgnoredAny) ++ } ++} diff --cc vendor/serde-1.0.15/src/de/impls.rs index 000000000,000000000..ef3e20e6a new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/de/impls.rs @@@ -1,0 -1,0 +1,1718 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use lib::*; ++ ++use de::{Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess, ++ Visitor}; ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++use de::MapAccess; ++ ++use de::from_primitive::FromPrimitive; ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++use private::de::size_hint; ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++struct UnitVisitor; ++ ++impl<'de> Visitor<'de> for UnitVisitor { ++ type Value = (); ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("unit") ++ } ++ ++ fn visit_unit(self) -> Result<(), E> ++ where ++ E: Error, ++ { ++ Ok(()) ++ } ++} ++ ++impl<'de> Deserialize<'de> for () { ++ fn deserialize(deserializer: D) -> Result<(), D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_unit(UnitVisitor) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++struct BoolVisitor; ++ ++impl<'de> Visitor<'de> for BoolVisitor { ++ type Value = bool; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a boolean") ++ } ++ ++ fn visit_bool(self, v: bool) -> Result ++ where ++ E: Error, ++ { ++ Ok(v) ++ } ++} ++ ++impl<'de> Deserialize<'de> for bool { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_bool(BoolVisitor) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++macro_rules! visit_integer_method { ++ ($src_ty:ident, $method:ident, $from_method:ident, $group:ident, $group_ty:ident) => { ++ #[inline] ++ fn $method(self, v: $src_ty) -> Result ++ where ++ E: Error, ++ { ++ match FromPrimitive::$from_method(v) { ++ Some(v) => Ok(v), ++ None => Err(Error::invalid_value(Unexpected::$group(v as $group_ty), &self)), ++ } ++ } ++ } ++} ++ ++macro_rules! visit_float_method { ++ ($src_ty:ident, $method:ident) => { ++ #[inline] ++ fn $method(self, v: $src_ty) -> Result ++ where ++ E: Error, ++ { ++ Ok(v as Self::Value) ++ } ++ } ++} ++ ++macro_rules! impl_deserialize_num { ++ ($ty:ident, $method:ident, $($visit:ident),*) => { ++ impl<'de> Deserialize<'de> for $ty { ++ #[inline] ++ fn deserialize(deserializer: D) -> Result<$ty, D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ struct PrimitiveVisitor; ++ ++ impl<'de> Visitor<'de> for PrimitiveVisitor { ++ type Value = $ty; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str(stringify!($ty)) ++ } ++ ++ $( ++ impl_deserialize_num!($visit $ty); ++ )* ++ } ++ ++ deserializer.$method(PrimitiveVisitor) ++ } ++ } ++ }; ++ ++ (integer $ty:ident) => { ++ visit_integer_method!(i8, visit_i8, from_i8, Signed, i64); ++ visit_integer_method!(i16, visit_i16, from_i16, Signed, i64); ++ visit_integer_method!(i32, visit_i32, from_i32, Signed, i64); ++ visit_integer_method!(i64, visit_i64, from_i64, Signed, i64); ++ ++ visit_integer_method!(u8, visit_u8, from_u8, Unsigned, u64); ++ visit_integer_method!(u16, visit_u16, from_u16, Unsigned, u64); ++ visit_integer_method!(u32, visit_u32, from_u32, Unsigned, u64); ++ visit_integer_method!(u64, visit_u64, from_u64, Unsigned, u64); ++ }; ++ ++ (float $ty:ident) => { ++ visit_float_method!(f32, visit_f32); ++ visit_float_method!(f64, visit_f64); ++ }; ++} ++ ++impl_deserialize_num!(i8, deserialize_i8, integer); ++impl_deserialize_num!(i16, deserialize_i16, integer); ++impl_deserialize_num!(i32, deserialize_i32, integer); ++impl_deserialize_num!(i64, deserialize_i64, integer); ++impl_deserialize_num!(isize, deserialize_i64, integer); ++ ++impl_deserialize_num!(u8, deserialize_u8, integer); ++impl_deserialize_num!(u16, deserialize_u16, integer); ++impl_deserialize_num!(u32, deserialize_u32, integer); ++impl_deserialize_num!(u64, deserialize_u64, integer); ++impl_deserialize_num!(usize, deserialize_u64, integer); ++ ++impl_deserialize_num!(f32, deserialize_f32, integer, float); ++impl_deserialize_num!(f64, deserialize_f64, integer, float); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++struct CharVisitor; ++ ++impl<'de> Visitor<'de> for CharVisitor { ++ type Value = char; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a character") ++ } ++ ++ #[inline] ++ fn visit_char(self, v: char) -> Result ++ where ++ E: Error, ++ { ++ Ok(v) ++ } ++ ++ #[inline] ++ fn visit_str(self, v: &str) -> Result ++ where ++ E: Error, ++ { ++ let mut iter = v.chars(); ++ match (iter.next(), iter.next()) { ++ (Some(c), None) => Ok(c), ++ _ => Err(Error::invalid_value(Unexpected::Str(v), &self)), ++ } ++ } ++} ++ ++impl<'de> Deserialize<'de> for char { ++ #[inline] ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_char(CharVisitor) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++struct StringVisitor; ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de> Visitor<'de> for StringVisitor { ++ type Value = String; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a string") ++ } ++ ++ fn visit_str(self, v: &str) -> Result ++ where ++ E: Error, ++ { ++ Ok(v.to_owned()) ++ } ++ ++ fn visit_string(self, v: String) -> Result ++ where ++ E: Error, ++ { ++ Ok(v) ++ } ++ ++ fn visit_bytes(self, v: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ match str::from_utf8(v) { ++ Ok(s) => Ok(s.to_owned()), ++ Err(_) => Err(Error::invalid_value(Unexpected::Bytes(v), &self)), ++ } ++ } ++ ++ fn visit_byte_buf(self, v: Vec) -> Result ++ where ++ E: Error, ++ { ++ match String::from_utf8(v) { ++ Ok(s) => Ok(s), ++ Err(e) => Err(Error::invalid_value(Unexpected::Bytes(&e.into_bytes()), &self),), ++ } ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de> Deserialize<'de> for String { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_string(StringVisitor) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++struct StrVisitor; ++ ++impl<'a> Visitor<'a> for StrVisitor { ++ type Value = &'a str; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a borrowed string") ++ } ++ ++ fn visit_borrowed_str(self, v: &'a str) -> Result ++ where ++ E: Error, ++ { ++ Ok(v) // so easy ++ } ++ ++ fn visit_borrowed_bytes(self, v: &'a [u8]) -> Result ++ where ++ E: Error, ++ { ++ str::from_utf8(v).map_err(|_| Error::invalid_value(Unexpected::Bytes(v), &self)) ++ } ++} ++ ++impl<'de: 'a, 'a> Deserialize<'de> for &'a str { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_str(StrVisitor) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++struct BytesVisitor; ++ ++impl<'a> Visitor<'a> for BytesVisitor { ++ type Value = &'a [u8]; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a borrowed byte array") ++ } ++ ++ fn visit_borrowed_bytes(self, v: &'a [u8]) -> Result ++ where ++ E: Error, ++ { ++ Ok(v) ++ } ++ ++ fn visit_borrowed_str(self, v: &'a str) -> Result ++ where ++ E: Error, ++ { ++ Ok(v.as_bytes()) ++ } ++} ++ ++impl<'de: 'a, 'a> Deserialize<'de> for &'a [u8] { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_bytes(BytesVisitor) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "std")] ++struct CStringVisitor; ++ ++#[cfg(feature = "std")] ++impl<'de> Visitor<'de> for CStringVisitor { ++ type Value = CString; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("byte array") ++ } ++ ++ fn visit_seq(self, mut seq: A) -> Result ++ where ++ A: SeqAccess<'de>, ++ { ++ let len = size_hint::cautious(seq.size_hint()); ++ let mut values = Vec::with_capacity(len); ++ ++ while let Some(value) = try!(seq.next_element()) { ++ values.push(value); ++ } ++ ++ CString::new(values).map_err(Error::custom) ++ } ++ ++ fn visit_bytes(self, v: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ CString::new(v).map_err(Error::custom) ++ } ++ ++ fn visit_byte_buf(self, v: Vec) -> Result ++ where ++ E: Error, ++ { ++ CString::new(v).map_err(Error::custom) ++ } ++ ++ fn visit_str(self, v: &str) -> Result ++ where ++ E: Error, ++ { ++ CString::new(v).map_err(Error::custom) ++ } ++ ++ fn visit_string(self, v: String) -> Result ++ where ++ E: Error, ++ { ++ CString::new(v).map_err(Error::custom) ++ } ++} ++ ++#[cfg(feature = "std")] ++impl<'de> Deserialize<'de> for CString { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_byte_buf(CStringVisitor) ++ } ++} ++ ++macro_rules! forwarded_impl { ++ (( $($id: ident),* ), $ty: ty, $func: expr) => { ++ impl<'de $(, $id : Deserialize<'de>,)*> Deserialize<'de> for $ty { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ Deserialize::deserialize(deserializer).map($func) ++ } ++ } ++ } ++} ++ ++#[cfg(all(feature = "std", feature = "unstable"))] ++forwarded_impl!((), Box, CString::into_boxed_c_str); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++struct OptionVisitor { ++ marker: PhantomData, ++} ++ ++impl<'de, T> Visitor<'de> for OptionVisitor ++where ++ T: Deserialize<'de>, ++{ ++ type Value = Option; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("option") ++ } ++ ++ #[inline] ++ fn visit_unit(self) -> Result, E> ++ where ++ E: Error, ++ { ++ Ok(None) ++ } ++ ++ #[inline] ++ fn visit_none(self) -> Result, E> ++ where ++ E: Error, ++ { ++ Ok(None) ++ } ++ ++ #[inline] ++ fn visit_some(self, deserializer: D) -> Result, D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ T::deserialize(deserializer).map(Some) ++ } ++} ++ ++impl<'de, T> Deserialize<'de> for Option ++where ++ T: Deserialize<'de>, ++{ ++ fn deserialize(deserializer: D) -> Result, D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_option(OptionVisitor { marker: PhantomData }) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++struct PhantomDataVisitor { ++ marker: PhantomData, ++} ++ ++impl<'de, T> Visitor<'de> for PhantomDataVisitor { ++ type Value = PhantomData; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("unit") ++ } ++ ++ #[inline] ++ fn visit_unit(self) -> Result, E> ++ where ++ E: Error, ++ { ++ Ok(PhantomData) ++ } ++} ++ ++impl<'de, T> Deserialize<'de> for PhantomData { ++ fn deserialize(deserializer: D) -> Result, D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ let visitor = PhantomDataVisitor { marker: PhantomData }; ++ deserializer.deserialize_unit_struct("PhantomData", visitor) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++macro_rules! seq_impl { ++ ( ++ $ty:ident < T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound1:ident $(+ $bound2:ident)*)* >, ++ $access:ident, ++ $ctor:expr, ++ $with_capacity:expr, ++ $insert:expr ++ ) => { ++ impl<'de, T $(, $typaram)*> Deserialize<'de> for $ty ++ where ++ T: Deserialize<'de> $(+ $tbound1 $(+ $tbound2)*)*, ++ $($typaram: $bound1 $(+ $bound2)*,)* ++ { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ struct SeqVisitor { ++ marker: PhantomData<$ty>, ++ } ++ ++ impl<'de, T $(, $typaram)*> Visitor<'de> for SeqVisitor ++ where ++ T: Deserialize<'de> $(+ $tbound1 $(+ $tbound2)*)*, ++ $($typaram: $bound1 $(+ $bound2)*,)* ++ { ++ type Value = $ty; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a sequence") ++ } ++ ++ #[inline] ++ fn visit_seq(self, mut $access: A) -> Result ++ where ++ A: SeqAccess<'de>, ++ { ++ let mut values = $with_capacity; ++ ++ while let Some(value) = try!($access.next_element()) { ++ $insert(&mut values, value); ++ } ++ ++ Ok(values) ++ } ++ } ++ ++ let visitor = SeqVisitor { marker: PhantomData }; ++ deserializer.deserialize_seq(visitor) ++ } ++ } ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++seq_impl!( ++ BinaryHeap, ++ seq, ++ BinaryHeap::new(), ++ BinaryHeap::with_capacity(size_hint::cautious(seq.size_hint())), ++ BinaryHeap::push); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++seq_impl!( ++ BTreeSet, ++ seq, ++ BTreeSet::new(), ++ BTreeSet::new(), ++ BTreeSet::insert); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++seq_impl!( ++ LinkedList, ++ seq, ++ LinkedList::new(), ++ LinkedList::new(), ++ LinkedList::push_back); ++ ++#[cfg(feature = "std")] ++seq_impl!( ++ HashSet, ++ seq, ++ HashSet::with_hasher(S::default()), ++ HashSet::with_capacity_and_hasher(size_hint::cautious(seq.size_hint()), S::default()), ++ HashSet::insert); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++seq_impl!( ++ Vec, ++ seq, ++ Vec::new(), ++ Vec::with_capacity(size_hint::cautious(seq.size_hint())), ++ Vec::push); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++seq_impl!( ++ VecDeque, ++ seq, ++ VecDeque::new(), ++ VecDeque::with_capacity(size_hint::cautious(seq.size_hint())), ++ VecDeque::push_back); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++struct ArrayVisitor { ++ marker: PhantomData, ++} ++ ++impl ArrayVisitor { ++ fn new() -> Self { ++ ArrayVisitor { marker: PhantomData } ++ } ++} ++ ++impl<'de, T> Visitor<'de> for ArrayVisitor<[T; 0]> { ++ type Value = [T; 0]; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("an empty array") ++ } ++ ++ #[inline] ++ fn visit_seq(self, _: A) -> Result<[T; 0], A::Error> ++ where ++ A: SeqAccess<'de>, ++ { ++ Ok([]) ++ } ++} ++ ++// Does not require T: Deserialize<'de>. ++impl<'de, T> Deserialize<'de> for [T; 0] { ++ fn deserialize(deserializer: D) -> Result<[T; 0], D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_tuple(0, ArrayVisitor::<[T; 0]>::new()) ++ } ++} ++ ++macro_rules! array_impls { ++ ($($len:expr => ($($n:tt $name:ident)+))+) => { ++ $( ++ impl<'de, T> Visitor<'de> for ArrayVisitor<[T; $len]> ++ where ++ T: Deserialize<'de>, ++ { ++ type Value = [T; $len]; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str(concat!("an array of length ", $len)) ++ } ++ ++ #[inline] ++ fn visit_seq(self, mut seq: A) -> Result<[T; $len], A::Error> ++ where ++ A: SeqAccess<'de>, ++ { ++ $( ++ let $name = match try!(seq.next_element()) { ++ Some(val) => val, ++ None => return Err(Error::invalid_length($n, &self)), ++ }; ++ )+ ++ ++ Ok([$($name),+]) ++ } ++ } ++ ++ impl<'de, T> Deserialize<'de> for [T; $len] ++ where ++ T: Deserialize<'de>, ++ { ++ fn deserialize(deserializer: D) -> Result<[T; $len], D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_tuple($len, ArrayVisitor::<[T; $len]>::new()) ++ } ++ } ++ )+ ++ } ++} ++ ++array_impls! { ++ 1 => (0 a) ++ 2 => (0 a 1 b) ++ 3 => (0 a 1 b 2 c) ++ 4 => (0 a 1 b 2 c 3 d) ++ 5 => (0 a 1 b 2 c 3 d 4 e) ++ 6 => (0 a 1 b 2 c 3 d 4 e 5 f) ++ 7 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g) ++ 8 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h) ++ 9 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i) ++ 10 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j) ++ 11 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k) ++ 12 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l) ++ 13 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m) ++ 14 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n) ++ 15 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o) ++ 16 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p) ++ 17 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q) ++ 18 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r) ++ 19 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s) ++ 20 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t) ++ 21 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u) ++ 22 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v) ++ 23 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w) ++ 24 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x) ++ 25 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y) ++ 26 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z) ++ 27 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa) ++ 28 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab) ++ 29 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac) ++ 30 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac 29 ad) ++ 31 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac 29 ad 30 ae) ++ 32 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac 29 ad 30 ae 31 af) ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++macro_rules! tuple_impls { ++ ($($len:tt $visitor:ident => ($($n:tt $name:ident)+))+) => { ++ $( ++ struct $visitor<$($name,)+> { ++ marker: PhantomData<($($name,)+)>, ++ } ++ ++ impl<$($name,)+> $visitor<$($name,)+> { ++ fn new() -> Self { ++ $visitor { marker: PhantomData } ++ } ++ } ++ ++ impl<'de, $($name: Deserialize<'de>),+> Visitor<'de> for $visitor<$($name,)+> { ++ type Value = ($($name,)+); ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str(concat!("a tuple of size ", $len)) ++ } ++ ++ #[inline] ++ #[allow(non_snake_case)] ++ fn visit_seq(self, mut seq: A) -> Result<($($name,)+), A::Error> ++ where ++ A: SeqAccess<'de>, ++ { ++ $( ++ let $name = match try!(seq.next_element()) { ++ Some(value) => value, ++ None => return Err(Error::invalid_length($n, &self)), ++ }; ++ )+ ++ ++ Ok(($($name,)+)) ++ } ++ } ++ ++ impl<'de, $($name: Deserialize<'de>),+> Deserialize<'de> for ($($name,)+) { ++ #[inline] ++ fn deserialize(deserializer: D) -> Result<($($name,)+), D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_tuple($len, $visitor::new()) ++ } ++ } ++ )+ ++ } ++} ++ ++tuple_impls! { ++ 1 TupleVisitor1 => (0 T0) ++ 2 TupleVisitor2 => (0 T0 1 T1) ++ 3 TupleVisitor3 => (0 T0 1 T1 2 T2) ++ 4 TupleVisitor4 => (0 T0 1 T1 2 T2 3 T3) ++ 5 TupleVisitor5 => (0 T0 1 T1 2 T2 3 T3 4 T4) ++ 6 TupleVisitor6 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5) ++ 7 TupleVisitor7 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6) ++ 8 TupleVisitor8 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7) ++ 9 TupleVisitor9 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8) ++ 10 TupleVisitor10 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9) ++ 11 TupleVisitor11 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10) ++ 12 TupleVisitor12 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11) ++ 13 TupleVisitor13 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12) ++ 14 TupleVisitor14 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13) ++ 15 TupleVisitor15 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14) ++ 16 TupleVisitor16 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14 15 T15) ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++macro_rules! map_impl { ++ ( ++ $ty:ident < K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound1:ident $(+ $bound2:ident)*)* >, ++ $access:ident, ++ $ctor:expr, ++ $with_capacity:expr ++ ) => { ++ impl<'de, K, V $(, $typaram)*> Deserialize<'de> for $ty ++ where ++ K: Deserialize<'de> $(+ $kbound1 $(+ $kbound2)*)*, ++ V: Deserialize<'de>, ++ $($typaram: $bound1 $(+ $bound2)*),* ++ { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ struct MapVisitor { ++ marker: PhantomData<$ty>, ++ } ++ ++ impl<'de, K, V $(, $typaram)*> Visitor<'de> for MapVisitor ++ where ++ K: Deserialize<'de> $(+ $kbound1 $(+ $kbound2)*)*, ++ V: Deserialize<'de>, ++ $($typaram: $bound1 $(+ $bound2)*),* ++ { ++ type Value = $ty; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a map") ++ } ++ ++ #[inline] ++ fn visit_map(self, mut $access: A) -> Result ++ where ++ A: MapAccess<'de>, ++ { ++ let mut values = $with_capacity; ++ ++ while let Some((key, value)) = try!($access.next_entry()) { ++ values.insert(key, value); ++ } ++ ++ Ok(values) ++ } ++ } ++ ++ let visitor = MapVisitor { marker: PhantomData }; ++ deserializer.deserialize_map(visitor) ++ } ++ } ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++map_impl!( ++ BTreeMap, ++ map, ++ BTreeMap::new(), ++ BTreeMap::new()); ++ ++#[cfg(feature = "std")] ++map_impl!( ++ HashMap, ++ map, ++ HashMap::with_hasher(S::default()), ++ HashMap::with_capacity_and_hasher(size_hint::cautious(map.size_hint()), S::default())); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "std")] ++macro_rules! parse_impl { ++ ($ty:ty) => { ++ impl<'de> Deserialize<'de> for $ty { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ let s = try!(String::deserialize(deserializer)); ++ s.parse().map_err(Error::custom) ++ } ++ } ++ } ++} ++ ++#[cfg(feature = "std")] ++parse_impl!(net::IpAddr); ++ ++#[cfg(feature = "std")] ++parse_impl!(net::Ipv4Addr); ++ ++#[cfg(feature = "std")] ++parse_impl!(net::Ipv6Addr); ++ ++#[cfg(feature = "std")] ++parse_impl!(net::SocketAddr); ++ ++#[cfg(feature = "std")] ++parse_impl!(net::SocketAddrV4); ++ ++#[cfg(feature = "std")] ++parse_impl!(net::SocketAddrV6); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "std")] ++struct PathVisitor; ++ ++#[cfg(feature = "std")] ++impl<'a> Visitor<'a> for PathVisitor { ++ type Value = &'a Path; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a borrowed path") ++ } ++ ++ fn visit_borrowed_str(self, v: &'a str) -> Result ++ where ++ E: Error, ++ { ++ Ok(v.as_ref()) ++ } ++ ++ fn visit_borrowed_bytes(self, v: &'a [u8]) -> Result ++ where ++ E: Error, ++ { ++ str::from_utf8(v) ++ .map(AsRef::as_ref) ++ .map_err(|_| Error::invalid_value(Unexpected::Bytes(v), &self)) ++ } ++} ++ ++#[cfg(feature = "std")] ++impl<'de: 'a, 'a> Deserialize<'de> for &'a Path { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_str(PathVisitor) ++ } ++} ++ ++#[cfg(feature = "std")] ++struct PathBufVisitor; ++ ++#[cfg(feature = "std")] ++impl<'de> Visitor<'de> for PathBufVisitor { ++ type Value = PathBuf; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("path string") ++ } ++ ++ fn visit_str(self, v: &str) -> Result ++ where ++ E: Error, ++ { ++ Ok(From::from(v)) ++ } ++ ++ fn visit_string(self, v: String) -> Result ++ where ++ E: Error, ++ { ++ Ok(From::from(v)) ++ } ++} ++ ++#[cfg(feature = "std")] ++impl<'de> Deserialize<'de> for PathBuf { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_string(PathBufVisitor) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++// If this were outside of the serde crate, it would just use: ++// ++// #[derive(Deserialize)] ++// #[serde(variant_identifier)] ++#[cfg(all(feature = "std", any(unix, windows)))] ++enum OsStringKind { ++ Unix, ++ Windows, ++} ++ ++#[cfg(all(feature = "std", any(unix, windows)))] ++static OSSTR_VARIANTS: &'static [&'static str] = &["Unix", "Windows"]; ++ ++#[cfg(all(feature = "std", any(unix, windows)))] ++impl<'de> Deserialize<'de> for OsStringKind { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ struct KindVisitor; ++ ++ impl<'de> Visitor<'de> for KindVisitor { ++ type Value = OsStringKind; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("`Unix` or `Windows`") ++ } ++ ++ fn visit_u32(self, value: u32) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ 0 => Ok(OsStringKind::Unix), ++ 1 => Ok(OsStringKind::Windows), ++ _ => Err(Error::invalid_value(Unexpected::Unsigned(value as u64), &self),), ++ } ++ } ++ ++ fn visit_str(self, value: &str) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ "Unix" => Ok(OsStringKind::Unix), ++ "Windows" => Ok(OsStringKind::Windows), ++ _ => Err(Error::unknown_variant(value, OSSTR_VARIANTS)), ++ } ++ } ++ ++ fn visit_bytes(self, value: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ b"Unix" => Ok(OsStringKind::Unix), ++ b"Windows" => Ok(OsStringKind::Windows), ++ _ => { ++ match str::from_utf8(value) { ++ Ok(value) => Err(Error::unknown_variant(value, OSSTR_VARIANTS)), ++ Err(_) => Err(Error::invalid_value(Unexpected::Bytes(value), &self)), ++ } ++ } ++ } ++ } ++ } ++ ++ deserializer.deserialize_identifier(KindVisitor) ++ } ++} ++ ++#[cfg(all(feature = "std", any(unix, windows)))] ++struct OsStringVisitor; ++ ++#[cfg(all(feature = "std", any(unix, windows)))] ++impl<'de> Visitor<'de> for OsStringVisitor { ++ type Value = OsString; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("os string") ++ } ++ ++ #[cfg(unix)] ++ fn visit_enum(self, data: A) -> Result ++ where ++ A: EnumAccess<'de>, ++ { ++ use std::os::unix::ffi::OsStringExt; ++ ++ match try!(data.variant()) { ++ (OsStringKind::Unix, v) => v.newtype_variant().map(OsString::from_vec), ++ (OsStringKind::Windows, _) => Err(Error::custom("cannot deserialize Windows OS string on Unix",),), ++ } ++ } ++ ++ #[cfg(windows)] ++ fn visit_enum(self, data: A) -> Result ++ where ++ A: EnumAccess<'de>, ++ { ++ use std::os::windows::ffi::OsStringExt; ++ ++ match try!(data.variant()) { ++ (OsStringKind::Windows, v) => { ++ v.newtype_variant::>() ++ .map(|vec| OsString::from_wide(&vec)) ++ } ++ (OsStringKind::Unix, _) => Err(Error::custom("cannot deserialize Unix OS string on Windows",),), ++ } ++ } ++} ++ ++#[cfg(all(feature = "std", any(unix, windows)))] ++impl<'de> Deserialize<'de> for OsString { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_enum("OsString", OSSTR_VARIANTS, OsStringVisitor) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++forwarded_impl!((T), Box, Box::new); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++forwarded_impl!((T), Box<[T]>, Vec::into_boxed_slice); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++forwarded_impl!((), Box, String::into_boxed_str); ++ ++#[cfg(all(not(feature = "unstable"), feature = "rc", any(feature = "std", feature = "alloc")))] ++forwarded_impl!((T), Arc, Arc::new); ++ ++#[cfg(all(not(feature = "unstable"), feature = "rc", any(feature = "std", feature = "alloc")))] ++forwarded_impl!((T), Rc, Rc::new); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de, 'a, T: ?Sized> Deserialize<'de> for Cow<'a, T> ++where ++ T: ToOwned, ++ T::Owned: Deserialize<'de>, ++{ ++ #[inline] ++ fn deserialize(deserializer: D) -> Result, D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ T::Owned::deserialize(deserializer).map(Cow::Owned) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(all(feature = "unstable", feature = "rc", any(feature = "std", feature = "alloc")))] ++macro_rules! box_forwarded_impl { ++ ($t:ident) => { ++ impl<'de, T: ?Sized> Deserialize<'de> for $t ++ where ++ Box: Deserialize<'de>, ++ { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ Box::deserialize(deserializer).map(Into::into) ++ } ++ } ++ } ++} ++ ++#[cfg(all(feature = "unstable", feature = "rc", any(feature = "std", feature = "alloc")))] ++box_forwarded_impl!(Rc); ++ ++#[cfg(all(feature = "unstable", feature = "rc", any(feature = "std", feature = "alloc")))] ++box_forwarded_impl!(Arc); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++impl<'de, T> Deserialize<'de> for Cell ++where ++ T: Deserialize<'de> + Copy, ++{ ++ fn deserialize(deserializer: D) -> Result, D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ T::deserialize(deserializer).map(Cell::new) ++ } ++} ++ ++forwarded_impl!((T), RefCell, RefCell::new); ++ ++#[cfg(feature = "std")] ++forwarded_impl!((T), Mutex, Mutex::new); ++ ++#[cfg(feature = "std")] ++forwarded_impl!((T), RwLock, RwLock::new); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++// This is a cleaned-up version of the impl generated by: ++// ++// #[derive(Deserialize)] ++// #[serde(deny_unknown_fields)] ++// struct Duration { ++// secs: u64, ++// nanos: u32, ++// } ++#[cfg(feature = "std")] ++impl<'de> Deserialize<'de> for Duration { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ // If this were outside of the serde crate, it would just use: ++ // ++ // #[derive(Deserialize)] ++ // #[serde(field_identifier, rename_all = "lowercase")] ++ enum Field { ++ Secs, ++ Nanos, ++ }; ++ ++ impl<'de> Deserialize<'de> for Field { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ struct FieldVisitor; ++ ++ impl<'de> Visitor<'de> for FieldVisitor { ++ type Value = Field; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("`secs` or `nanos`") ++ } ++ ++ fn visit_str(self, value: &str) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ "secs" => Ok(Field::Secs), ++ "nanos" => Ok(Field::Nanos), ++ _ => Err(Error::unknown_field(value, FIELDS)), ++ } ++ } ++ ++ fn visit_bytes(self, value: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ b"secs" => Ok(Field::Secs), ++ b"nanos" => Ok(Field::Nanos), ++ _ => { ++ let value = String::from_utf8_lossy(value); ++ Err(Error::unknown_field(&value, FIELDS)) ++ } ++ } ++ } ++ } ++ ++ deserializer.deserialize_identifier(FieldVisitor) ++ } ++ } ++ ++ struct DurationVisitor; ++ ++ impl<'de> Visitor<'de> for DurationVisitor { ++ type Value = Duration; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("struct Duration") ++ } ++ ++ fn visit_seq(self, mut seq: A) -> Result ++ where ++ A: SeqAccess<'de>, ++ { ++ let secs: u64 = match try!(seq.next_element()) { ++ Some(value) => value, ++ None => { ++ return Err(Error::invalid_length(0, &self)); ++ } ++ }; ++ let nanos: u32 = match try!(seq.next_element()) { ++ Some(value) => value, ++ None => { ++ return Err(Error::invalid_length(1, &self)); ++ } ++ }; ++ Ok(Duration::new(secs, nanos)) ++ } ++ ++ fn visit_map(self, mut map: A) -> Result ++ where ++ A: MapAccess<'de>, ++ { ++ let mut secs: Option = None; ++ let mut nanos: Option = None; ++ while let Some(key) = try!(map.next_key()) { ++ match key { ++ Field::Secs => { ++ if secs.is_some() { ++ return Err(::duplicate_field("secs")); ++ } ++ secs = Some(try!(map.next_value())); ++ } ++ Field::Nanos => { ++ if nanos.is_some() { ++ return Err(::duplicate_field("nanos")); ++ } ++ nanos = Some(try!(map.next_value())); ++ } ++ } ++ } ++ let secs = match secs { ++ Some(secs) => secs, ++ None => return Err(::missing_field("secs")), ++ }; ++ let nanos = match nanos { ++ Some(nanos) => nanos, ++ None => return Err(::missing_field("nanos")), ++ }; ++ Ok(Duration::new(secs, nanos)) ++ } ++ } ++ ++ const FIELDS: &'static [&'static str] = &["secs", "nanos"]; ++ deserializer.deserialize_struct("Duration", FIELDS, DurationVisitor) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "std")] ++impl<'de> Deserialize<'de> for SystemTime { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ // Reuse duration ++ enum Field { ++ Secs, ++ Nanos, ++ }; ++ ++ impl<'de> Deserialize<'de> for Field { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ struct FieldVisitor; ++ ++ impl<'de> Visitor<'de> for FieldVisitor { ++ type Value = Field; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("`secs_since_epoch` or `nanos_since_epoch`") ++ } ++ ++ fn visit_str(self, value: &str) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ "secs_since_epoch" => Ok(Field::Secs), ++ "nanos_since_epoch" => Ok(Field::Nanos), ++ _ => Err(Error::unknown_field(value, FIELDS)), ++ } ++ } ++ ++ fn visit_bytes(self, value: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ b"secs_since_epoch" => Ok(Field::Secs), ++ b"nanos_since_epoch" => Ok(Field::Nanos), ++ _ => { ++ let value = String::from_utf8_lossy(value); ++ Err(Error::unknown_field(&value, FIELDS)) ++ } ++ } ++ } ++ } ++ ++ deserializer.deserialize_identifier(FieldVisitor) ++ } ++ } ++ ++ struct DurationVisitor; ++ ++ impl<'de> Visitor<'de> for DurationVisitor { ++ type Value = Duration; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("struct SystemTime") ++ } ++ ++ fn visit_seq(self, mut seq: A) -> Result ++ where ++ A: SeqAccess<'de>, ++ { ++ let secs: u64 = match try!(seq.next_element()) { ++ Some(value) => value, ++ None => { ++ return Err(Error::invalid_length(0, &self)); ++ } ++ }; ++ let nanos: u32 = match try!(seq.next_element()) { ++ Some(value) => value, ++ None => { ++ return Err(Error::invalid_length(1, &self)); ++ } ++ }; ++ Ok(Duration::new(secs, nanos)) ++ } ++ ++ fn visit_map(self, mut map: A) -> Result ++ where ++ A: MapAccess<'de>, ++ { ++ let mut secs: Option = None; ++ let mut nanos: Option = None; ++ while let Some(key) = try!(map.next_key()) { ++ match key { ++ Field::Secs => { ++ if secs.is_some() { ++ return Err(::duplicate_field("secs_since_epoch")); ++ } ++ secs = Some(try!(map.next_value())); ++ } ++ Field::Nanos => { ++ if nanos.is_some() { ++ return Err(::duplicate_field("nanos_since_epoch")); ++ } ++ nanos = Some(try!(map.next_value())); ++ } ++ } ++ } ++ let secs = match secs { ++ Some(secs) => secs, ++ None => return Err(::missing_field("secs_since_epoch")), ++ }; ++ let nanos = match nanos { ++ Some(nanos) => nanos, ++ None => return Err(::missing_field("nanos_since_epoch")), ++ }; ++ Ok(Duration::new(secs, nanos)) ++ } ++ } ++ ++ const FIELDS: &'static [&'static str] = &["secs_since_epoch", "nanos_since_epoch"]; ++ let duration = try!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor)); ++ Ok(UNIX_EPOCH + duration) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++// Similar to: ++// ++// #[derive(Deserialize)] ++// #[serde(deny_unknown_fields)] ++// struct Range { ++// start: u64, ++// end: u32, ++// } ++#[cfg(feature = "std")] ++impl<'de, Idx> Deserialize<'de> for ops::Range ++where ++ Idx: Deserialize<'de>, ++{ ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ // If this were outside of the serde crate, it would just use: ++ // ++ // #[derive(Deserialize)] ++ // #[serde(field_identifier, rename_all = "lowercase")] ++ enum Field { ++ Start, ++ End, ++ }; ++ ++ impl<'de> Deserialize<'de> for Field { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ struct FieldVisitor; ++ ++ impl<'de> Visitor<'de> for FieldVisitor { ++ type Value = Field; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("`start` or `end`") ++ } ++ ++ fn visit_str(self, value: &str) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ "start" => Ok(Field::Start), ++ "end" => Ok(Field::End), ++ _ => Err(Error::unknown_field(value, FIELDS)), ++ } ++ } ++ ++ fn visit_bytes(self, value: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ b"start" => Ok(Field::Start), ++ b"end" => Ok(Field::End), ++ _ => { ++ let value = String::from_utf8_lossy(value); ++ Err(Error::unknown_field(&value, FIELDS)) ++ } ++ } ++ } ++ } ++ ++ deserializer.deserialize_identifier(FieldVisitor) ++ } ++ } ++ ++ struct RangeVisitor { ++ phantom: PhantomData, ++ } ++ ++ impl<'de, Idx> Visitor<'de> for RangeVisitor ++ where ++ Idx: Deserialize<'de>, ++ { ++ type Value = ops::Range; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("struct Range") ++ } ++ ++ fn visit_seq(self, mut seq: A) -> Result, A::Error> ++ where ++ A: SeqAccess<'de>, ++ { ++ let start: Idx = match try!(seq.next_element()) { ++ Some(value) => value, ++ None => { ++ return Err(Error::invalid_length(0, &self)); ++ } ++ }; ++ let end: Idx = match try!(seq.next_element()) { ++ Some(value) => value, ++ None => { ++ return Err(Error::invalid_length(1, &self)); ++ } ++ }; ++ Ok(start..end) ++ } ++ ++ fn visit_map(self, mut map: A) -> Result, A::Error> ++ where ++ A: MapAccess<'de>, ++ { ++ let mut start: Option = None; ++ let mut end: Option = None; ++ while let Some(key) = try!(map.next_key()) { ++ match key { ++ Field::Start => { ++ if start.is_some() { ++ return Err(::duplicate_field("start")); ++ } ++ start = Some(try!(map.next_value())); ++ } ++ Field::End => { ++ if end.is_some() { ++ return Err(::duplicate_field("end")); ++ } ++ end = Some(try!(map.next_value())); ++ } ++ } ++ } ++ let start = match start { ++ Some(start) => start, ++ None => return Err(::missing_field("start")), ++ }; ++ let end = match end { ++ Some(end) => end, ++ None => return Err(::missing_field("end")), ++ }; ++ Ok(start..end) ++ } ++ } ++ ++ const FIELDS: &'static [&'static str] = &["start", "end"]; ++ deserializer.deserialize_struct("Range", FIELDS, RangeVisitor { phantom: PhantomData }) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "unstable")] ++impl<'de, T> Deserialize<'de> for NonZero ++where ++ T: Deserialize<'de> + Zeroable, ++{ ++ fn deserialize(deserializer: D) -> Result, D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ let value = try!(Deserialize::deserialize(deserializer)); ++ match NonZero::new(value) { ++ Some(nonzero) => Ok(nonzero), ++ None => Err(Error::custom("expected a non-zero value")), ++ } ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++impl<'de, T, E> Deserialize<'de> for Result ++where ++ T: Deserialize<'de>, ++ E: Deserialize<'de>, ++{ ++ fn deserialize(deserializer: D) -> Result, D::Error> ++ where ++ D: Deserializer<'de>, ++ { ++ // If this were outside of the serde crate, it would just use: ++ // ++ // #[derive(Deserialize)] ++ // #[serde(variant_identifier)] ++ enum Field { ++ Ok, ++ Err, ++ } ++ ++ impl<'de> Deserialize<'de> for Field { ++ #[inline] ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ struct FieldVisitor; ++ ++ impl<'de> Visitor<'de> for FieldVisitor { ++ type Value = Field; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("`Ok` or `Err`") ++ } ++ ++ fn visit_u32(self, value: u32) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ 0 => Ok(Field::Ok), ++ 1 => Ok(Field::Err), ++ _ => { ++ Err(Error::invalid_value(Unexpected::Unsigned(value as u64), &self),) ++ } ++ } ++ } ++ ++ fn visit_str(self, value: &str) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ "Ok" => Ok(Field::Ok), ++ "Err" => Ok(Field::Err), ++ _ => Err(Error::unknown_variant(value, VARIANTS)), ++ } ++ } ++ ++ fn visit_bytes(self, value: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ match value { ++ b"Ok" => Ok(Field::Ok), ++ b"Err" => Ok(Field::Err), ++ _ => { ++ match str::from_utf8(value) { ++ Ok(value) => Err(Error::unknown_variant(value, VARIANTS)), ++ Err(_) => { ++ Err(Error::invalid_value(Unexpected::Bytes(value), &self)) ++ } ++ } ++ } ++ } ++ } ++ } ++ ++ deserializer.deserialize_identifier(FieldVisitor) ++ } ++ } ++ ++ struct ResultVisitor(PhantomData>); ++ ++ impl<'de, T, E> Visitor<'de> for ResultVisitor ++ where ++ T: Deserialize<'de>, ++ E: Deserialize<'de>, ++ { ++ type Value = Result; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("enum Result") ++ } ++ ++ fn visit_enum(self, data: A) -> Result, A::Error> ++ where ++ A: EnumAccess<'de>, ++ { ++ match try!(data.variant()) { ++ (Field::Ok, v) => v.newtype_variant().map(Ok), ++ (Field::Err, v) => v.newtype_variant().map(Err), ++ } ++ } ++ } ++ ++ const VARIANTS: &'static [&'static str] = &["Ok", "Err"]; ++ ++ deserializer.deserialize_enum("Result", VARIANTS, ResultVisitor(PhantomData)) ++ } ++} diff --cc vendor/serde-1.0.15/src/de/mod.rs index 000000000,000000000..eb100951a new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/de/mod.rs @@@ -1,0 -1,0 +1,1945 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! Generic data structure deserialization framework. ++//! ++//! The two most important traits in this module are [`Deserialize`] and ++//! [`Deserializer`]. ++//! ++//! - **A type that implements `Deserialize` is a data structure** that can be ++//! deserialized from any data format supported by Serde, and conversely ++//! - **A type that implements `Deserializer` is a data format** that can ++//! deserialize any data structure supported by Serde. ++//! ++//! # The Deserialize trait ++//! ++//! Serde provides [`Deserialize`] implementations for many Rust primitive and ++//! standard library types. The complete list is below. All of these can be ++//! deserialized using Serde out of the box. ++//! ++//! Additionally, Serde provides a procedural macro called [`serde_derive`] to ++//! automatically generate [`Deserialize`] implementations for structs and enums ++//! in your program. See the [codegen section of the manual] for how to use ++//! this. ++//! ++//! In rare cases it may be necessary to implement [`Deserialize`] manually for ++//! some type in your program. See the [Implementing `Deserialize`] section of ++//! the manual for more about this. ++//! ++//! Third-party crates may provide [`Deserialize`] implementations for types ++//! that they expose. For example the [`linked-hash-map`] crate provides a ++//! [`LinkedHashMap`] type that is deserializable by Serde because the ++//! crate provides an implementation of [`Deserialize`] for it. ++//! ++//! # The Deserializer trait ++//! ++//! [`Deserializer`] implementations are provided by third-party crates, for ++//! example [`serde_json`], [`serde_yaml`] and [`bincode`]. ++//! ++//! A partial list of well-maintained formats is given on the [Serde ++//! website][data formats]. ++//! ++//! # Implementations of Deserialize provided by Serde ++//! ++//! This is a slightly different set of types than what is supported for ++//! serialization. Some types can be serialized by Serde but not deserialized. ++//! One example is `OsStr`. ++//! ++//! - **Primitive types**: ++//! - bool ++//! - i8, i16, i32, i64, isize ++//! - u8, u16, u32, u64, usize ++//! - f32, f64 ++//! - char ++//! - **Compound types**: ++//! - [T; 0] through [T; 32] ++//! - tuples up to size 16 ++//! - **Common standard library types**: ++//! - String ++//! - Option\ ++//! - Result\ ++//! - PhantomData\ ++//! - **Wrapper types**: ++//! - Box\ ++//! - Box\<[T]\> ++//! - Box\ ++//! - Rc\ ++//! - Arc\ ++//! - Cow\<'a, T\> ++//! - Cell\ ++//! - RefCell\ ++//! - Mutex\ ++//! - RwLock\ ++//! - **Collection types**: ++//! - BTreeMap\ ++//! - BTreeSet\ ++//! - BinaryHeap\ ++//! - HashMap\ ++//! - HashSet\ ++//! - LinkedList\ ++//! - VecDeque\ ++//! - Vec\ ++//! - EnumSet\ (unstable) ++//! - **Zero-copy types**: ++//! - &str ++//! - &[u8] ++//! - **FFI types**: ++//! - CString ++//! - Box\ ++//! - OsString ++//! - **Miscellaneous standard library types**: ++//! - Duration ++//! - SystemTime ++//! - Path ++//! - PathBuf ++//! - Range\ ++//! - NonZero\ (unstable) ++//! - **Net types**: ++//! - IpAddr ++//! - Ipv4Addr ++//! - Ipv6Addr ++//! - SocketAddr ++//! - SocketAddrV4 ++//! - SocketAddrV6 ++//! ++//! [Implementing `Deserialize`]: https://serde.rs/impl-deserialize.html ++//! [`Deserialize`]: ../trait.Deserialize.html ++//! [`Deserializer`]: ../trait.Deserializer.html ++//! [`LinkedHashMap`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html ++//! [`bincode`]: https://github.com/TyOverby/bincode ++//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map ++//! [`serde_derive`]: https://crates.io/crates/serde_derive ++//! [`serde_json`]: https://github.com/serde-rs/json ++//! [`serde_yaml`]: https://github.com/dtolnay/serde-yaml ++//! [codegen section of the manual]: https://serde.rs/codegen.html ++//! [data formats]: https://serde.rs/#data-formats ++ ++use lib::*; ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++pub mod value; ++ ++mod from_primitive; ++mod ignored_any; ++mod impls; ++mod utf8; ++ ++pub use self::ignored_any::IgnoredAny; ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++macro_rules! declare_error_trait { ++ (Error: Sized $(+ $($supertrait:ident)::+)*) => { ++ /// The `Error` trait allows `Deserialize` implementations to create descriptive ++ /// error messages belonging to the `Deserializer` against which they are ++ /// currently running. ++ /// ++ /// Every `Deserializer` declares an `Error` type that encompasses both ++ /// general-purpose deserialization errors as well as errors specific to the ++ /// particular deserialization format. For example the `Error` type of ++ /// `serde_json` can represent errors like an invalid JSON escape sequence or an ++ /// unterminated string literal, in addition to the error cases that are part of ++ /// this trait. ++ /// ++ /// Most deserializers should only need to provide the `Error::custom` method ++ /// and inherit the default behavior for the other methods. ++ pub trait Error: Sized $(+ $($supertrait)::+)* { ++ /// Raised when there is general error when deserializing a type. ++ /// ++ /// The message should not be capitalized and should not end with a period. ++ /// ++ /// ```rust ++ /// # use std::str::FromStr; ++ /// # ++ /// # struct IpAddr; ++ /// # ++ /// # impl FromStr for IpAddr { ++ /// # type Err = String; ++ /// # ++ /// # fn from_str(_: &str) -> Result { ++ /// # unimplemented!() ++ /// # } ++ /// # } ++ /// # ++ /// use serde::de::{self, Deserialize, Deserializer}; ++ /// ++ /// impl<'de> Deserialize<'de> for IpAddr { ++ /// fn deserialize(deserializer: D) -> Result ++ /// where D: Deserializer<'de> ++ /// { ++ /// let s = try!(String::deserialize(deserializer)); ++ /// s.parse().map_err(de::Error::custom) ++ /// } ++ /// } ++ /// ``` ++ fn custom(msg: T) -> Self ++ where ++ T: Display; ++ ++ /// Raised when a `Deserialize` receives a type different from what it was ++ /// expecting. ++ /// ++ /// The `unexp` argument provides information about what type was received. ++ /// This is the type that was present in the input file or other source data ++ /// of the Deserializer. ++ /// ++ /// The `exp` argument provides information about what type was being ++ /// expected. This is the type that is written in the program. ++ /// ++ /// For example if we try to deserialize a String out of a JSON file ++ /// containing an integer, the unexpected type is the integer and the ++ /// expected type is the string. ++ fn invalid_type(unexp: Unexpected, exp: &Expected) -> Self { ++ Error::custom(format_args!("invalid type: {}, expected {}", unexp, exp)) ++ } ++ ++ /// Raised when a `Deserialize` receives a value of the right type but that ++ /// is wrong for some other reason. ++ /// ++ /// The `unexp` argument provides information about what value was received. ++ /// This is the value that was present in the input file or other source ++ /// data of the Deserializer. ++ /// ++ /// The `exp` argument provides information about what value was being ++ /// expected. This is the type that is written in the program. ++ /// ++ /// For example if we try to deserialize a String out of some binary data ++ /// that is not valid UTF-8, the unexpected value is the bytes and the ++ /// expected value is a string. ++ fn invalid_value(unexp: Unexpected, exp: &Expected) -> Self { ++ Error::custom(format_args!("invalid value: {}, expected {}", unexp, exp)) ++ } ++ ++ /// Raised when deserializing a sequence or map and the input data contains ++ /// too many or too few elements. ++ /// ++ /// The `len` argument is the number of elements encountered. The sequence ++ /// or map may have expected more arguments or fewer arguments. ++ /// ++ /// The `exp` argument provides information about what data was being ++ /// expected. For example `exp` might say that a tuple of size 6 was ++ /// expected. ++ fn invalid_length(len: usize, exp: &Expected) -> Self { ++ Error::custom(format_args!("invalid length {}, expected {}", len, exp)) ++ } ++ ++ /// Raised when a `Deserialize` enum type received a variant with an ++ /// unrecognized name. ++ fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self { ++ if expected.is_empty() { ++ Error::custom(format_args!("unknown variant `{}`, there are no variants", ++ variant)) ++ } else { ++ Error::custom(format_args!("unknown variant `{}`, expected {}", ++ variant, ++ OneOf { names: expected })) ++ } ++ } ++ ++ /// Raised when a `Deserialize` struct type received a field with an ++ /// unrecognized name. ++ fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self { ++ if expected.is_empty() { ++ Error::custom(format_args!("unknown field `{}`, there are no fields", ++ field)) ++ } else { ++ Error::custom(format_args!("unknown field `{}`, expected {}", ++ field, ++ OneOf { names: expected })) ++ } ++ } ++ ++ /// Raised when a `Deserialize` struct type expected to receive a required ++ /// field with a particular name but that field was not present in the ++ /// input. ++ fn missing_field(field: &'static str) -> Self { ++ Error::custom(format_args!("missing field `{}`", field)) ++ } ++ ++ /// Raised when a `Deserialize` struct type received more than one of the ++ /// same field. ++ fn duplicate_field(field: &'static str) -> Self { ++ Error::custom(format_args!("duplicate field `{}`", field)) ++ } ++ } ++ } ++} ++ ++#[cfg(feature = "std")] ++declare_error_trait!(Error: Sized + error::Error); ++ ++#[cfg(not(feature = "std"))] ++declare_error_trait!(Error: Sized + Debug + Display); ++ ++/// `Unexpected` represents an unexpected invocation of any one of the `Visitor` ++/// trait methods. ++/// ++/// This is used as an argument to the `invalid_type`, `invalid_value`, and ++/// `invalid_length` methods of the `Error` trait to build error messages. ++/// ++/// ```rust ++/// # use std::fmt; ++/// # ++/// # use serde::de::{self, Unexpected, Visitor}; ++/// # ++/// # struct Example; ++/// # ++/// # impl<'de> Visitor<'de> for Example { ++/// # type Value = (); ++/// # ++/// # fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++/// # write!(formatter, "definitely not a boolean") ++/// # } ++/// # ++/// fn visit_bool(self, v: bool) -> Result ++/// where E: de::Error ++/// { ++/// Err(de::Error::invalid_type(Unexpected::Bool(v), &self)) ++/// } ++/// # } ++/// ``` ++#[derive(Copy, Clone, PartialEq, Debug)] ++pub enum Unexpected<'a> { ++ /// The input contained a boolean value that was not expected. ++ Bool(bool), ++ ++ /// The input contained an unsigned integer `u8`, `u16`, `u32` or `u64` that ++ /// was not expected. ++ Unsigned(u64), ++ ++ /// The input contained a signed integer `i8`, `i16`, `i32` or `i64` that ++ /// was not expected. ++ Signed(i64), ++ ++ /// The input contained a floating point `f32` or `f64` that was not ++ /// expected. ++ Float(f64), ++ ++ /// The input contained a `char` that was not expected. ++ Char(char), ++ ++ /// The input contained a `&str` or `String` that was not expected. ++ Str(&'a str), ++ ++ /// The input contained a `&[u8]` or `Vec` that was not expected. ++ Bytes(&'a [u8]), ++ ++ /// The input contained a unit `()` that was not expected. ++ Unit, ++ ++ /// The input contained an `Option` that was not expected. ++ Option, ++ ++ /// The input contained a newtype struct that was not expected. ++ NewtypeStruct, ++ ++ /// The input contained a sequence that was not expected. ++ Seq, ++ ++ /// The input contained a map that was not expected. ++ Map, ++ ++ /// The input contained an enum that was not expected. ++ Enum, ++ ++ /// The input contained a unit variant that was not expected. ++ UnitVariant, ++ ++ /// The input contained a newtype variant that was not expected. ++ NewtypeVariant, ++ ++ /// The input contained a tuple variant that was not expected. ++ TupleVariant, ++ ++ /// The input contained a struct variant that was not expected. ++ StructVariant, ++ ++ /// A message stating what uncategorized thing the input contained that was ++ /// not expected. ++ /// ++ /// The message should be a noun or noun phrase, not capitalized and without ++ /// a period. An example message is "unoriginal superhero". ++ Other(&'a str), ++} ++ ++impl<'a> fmt::Display for Unexpected<'a> { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { ++ use self::Unexpected::*; ++ match *self { ++ Bool(b) => write!(formatter, "boolean `{}`", b), ++ Unsigned(i) => write!(formatter, "integer `{}`", i), ++ Signed(i) => write!(formatter, "integer `{}`", i), ++ Float(f) => write!(formatter, "floating point `{}`", f), ++ Char(c) => write!(formatter, "character `{}`", c), ++ Str(s) => write!(formatter, "string {:?}", s), ++ Bytes(_) => write!(formatter, "byte array"), ++ Unit => write!(formatter, "unit value"), ++ Option => write!(formatter, "Option value"), ++ NewtypeStruct => write!(formatter, "newtype struct"), ++ Seq => write!(formatter, "sequence"), ++ Map => write!(formatter, "map"), ++ Enum => write!(formatter, "enum"), ++ UnitVariant => write!(formatter, "unit variant"), ++ NewtypeVariant => write!(formatter, "newtype variant"), ++ TupleVariant => write!(formatter, "tuple variant"), ++ StructVariant => write!(formatter, "struct variant"), ++ Other(other) => formatter.write_str(other), ++ } ++ } ++} ++ ++/// `Expected` represents an explanation of what data a `Visitor` was expecting ++/// to receive. ++/// ++/// This is used as an argument to the `invalid_type`, `invalid_value`, and ++/// `invalid_length` methods of the `Error` trait to build error messages. The ++/// message should be a noun or noun phrase that completes the sentence "This ++/// Visitor expects to receive ...", for example the message could be "an ++/// integer between 0 and 64". The message should not be capitalized and should ++/// not end with a period. ++/// ++/// Within the context of a `Visitor` implementation, the `Visitor` itself ++/// (`&self`) is an implementation of this trait. ++/// ++/// ```rust ++/// # use std::fmt; ++/// # ++/// # use serde::de::{self, Unexpected, Visitor}; ++/// # ++/// # struct Example; ++/// # ++/// # impl<'de> Visitor<'de> for Example { ++/// # type Value = (); ++/// # ++/// # fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++/// # write!(formatter, "definitely not a boolean") ++/// # } ++/// # ++/// fn visit_bool(self, v: bool) -> Result ++/// where E: de::Error ++/// { ++/// Err(de::Error::invalid_type(Unexpected::Bool(v), &self)) ++/// } ++/// # } ++/// ``` ++/// ++/// Outside of a `Visitor`, `&"..."` can be used. ++/// ++/// ```rust ++/// # use serde::de::{self, Unexpected}; ++/// # ++/// # fn example() -> Result<(), E> ++/// # where E: de::Error ++/// # { ++/// # let v = true; ++/// return Err(de::Error::invalid_type(Unexpected::Bool(v), &"a negative integer")); ++/// # } ++/// ``` ++pub trait Expected { ++ /// Format an explanation of what data was being expected. Same signature as ++ /// the `Display` and `Debug` traits. ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result; ++} ++ ++impl<'de, T> Expected for T ++where ++ T: Visitor<'de>, ++{ ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ self.expecting(formatter) ++ } ++} ++ ++impl<'a> Expected for &'a str { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str(self) ++ } ++} ++ ++impl<'a> Display for Expected + 'a { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ Expected::fmt(self, formatter) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A **data structure** that can be deserialized from any data format supported ++/// by Serde. ++/// ++/// Serde provides `Deserialize` implementations for many Rust primitive and ++/// standard library types. The complete list is [here][de]. All of these can ++/// be deserialized using Serde out of the box. ++/// ++/// Additionally, Serde provides a procedural macro called `serde_derive` to ++/// automatically generate `Deserialize` implementations for structs and enums ++/// in your program. See the [codegen section of the manual][codegen] for how to ++/// use this. ++/// ++/// In rare cases it may be necessary to implement `Deserialize` manually for ++/// some type in your program. See the [Implementing ++/// `Deserialize`][impl-deserialize] section of the manual for more about this. ++/// ++/// Third-party crates may provide `Deserialize` implementations for types that ++/// they expose. For example the `linked-hash-map` crate provides a ++/// `LinkedHashMap` type that is deserializable by Serde because the crate ++/// provides an implementation of `Deserialize` for it. ++/// ++/// [de]: https://docs.serde.rs/serde/de/index.html ++/// [codegen]: https://serde.rs/codegen.html ++/// [impl-deserialize]: https://serde.rs/impl-deserialize.html ++pub trait Deserialize<'de>: Sized { ++ /// Deserialize this value from the given Serde deserializer. ++ /// ++ /// See the [Implementing `Deserialize`][impl-deserialize] section of the ++ /// manual for more information about how to implement this method. ++ /// ++ /// [impl-deserialize]: https://serde.rs/impl-deserialize.html ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>; ++} ++ ++/// A data structure that can be deserialized without borrowing any data from ++/// the deserializer. ++/// ++/// This is primarily useful for trait bounds on functions. For example a ++/// `from_str` function may be able to deserialize a data structure that borrows ++/// from the input string, but a `from_reader` function may only deserialize ++/// owned data. ++/// ++/// ```rust ++/// # use serde::de::{Deserialize, DeserializeOwned}; ++/// # use std::io::{Read, Result}; ++/// # ++/// # trait Ignore { ++/// fn from_str<'a, T>(s: &'a str) -> Result ++/// where T: Deserialize<'a>; ++/// ++/// fn from_reader(rdr: R) -> Result ++/// where R: Read, ++/// T: DeserializeOwned; ++/// # } ++/// ``` ++pub trait DeserializeOwned: for<'de> Deserialize<'de> {} ++impl DeserializeOwned for T ++where ++ T: for<'de> Deserialize<'de>, ++{ ++} ++ ++/// `DeserializeSeed` is the stateful form of the `Deserialize` trait. If you ++/// ever find yourself looking for a way to pass data into a `Deserialize` impl, ++/// this trait is the way to do it. ++/// ++/// As one example of stateful deserialization consider deserializing a JSON ++/// array into an existing buffer. Using the `Deserialize` trait we could ++/// deserialize a JSON array into a `Vec` but it would be a freshly allocated ++/// `Vec`; there is no way for `Deserialize` to reuse a previously allocated ++/// buffer. Using `DeserializeSeed` instead makes this possible as in the ++/// example code below. ++/// ++/// The canonical API for stateless deserialization looks like this: ++/// ++/// ```rust ++/// # use serde::Deserialize; ++/// # ++/// # enum Error {} ++/// # ++/// fn func<'de, T: Deserialize<'de>>() -> Result ++/// # { ++/// # unimplemented!() ++/// # } ++/// ``` ++/// ++/// Adjusting an API like this to support stateful deserialization is a matter ++/// of accepting a seed as input: ++/// ++/// ```rust ++/// # use serde::de::DeserializeSeed; ++/// # ++/// # enum Error {} ++/// # ++/// fn func_seed<'de, T: DeserializeSeed<'de>>(seed: T) -> Result ++/// # { ++/// # let _ = seed; ++/// # unimplemented!() ++/// # } ++/// ``` ++/// ++/// In practice the majority of deserialization is stateless. An API expecting a ++/// seed can be appeased by passing `std::marker::PhantomData` as a seed in the ++/// case of stateless deserialization. ++/// ++/// # Example ++/// ++/// Suppose we have JSON that looks like `[[1, 2], [3, 4, 5], [6]]` and we need ++/// to deserialize it into a flat representation like `vec![1, 2, 3, 4, 5, 6]`. ++/// Allocating a brand new `Vec` for each subarray would be slow. Instead we ++/// would like to allocate a single `Vec` and then deserialize each subarray ++/// into it. This requires stateful deserialization using the `DeserializeSeed` ++/// trait. ++/// ++/// ```rust ++/// use std::fmt; ++/// use std::marker::PhantomData; ++/// ++/// use serde::de::{Deserialize, DeserializeSeed, Deserializer, Visitor, SeqAccess}; ++/// ++/// // A DeserializeSeed implementation that uses stateful deserialization to ++/// // append array elements onto the end of an existing vector. The preexisting ++/// // state ("seed") in this case is the Vec. The `deserialize` method of ++/// // `ExtendVec` will be traversing the inner arrays of the JSON input and ++/// // appending each integer into the existing Vec. ++/// struct ExtendVec<'a, T: 'a>(&'a mut Vec); ++/// ++/// impl<'de, 'a, T> DeserializeSeed<'de> for ExtendVec<'a, T> ++/// where T: Deserialize<'de> ++/// { ++/// // The return type of the `deserialize` method. This implementation ++/// // appends onto an existing vector but does not create any new data ++/// // structure, so the return type is (). ++/// type Value = (); ++/// ++/// fn deserialize(self, deserializer: D) -> Result ++/// where D: Deserializer<'de> ++/// { ++/// // Visitor implementation that will walk an inner array of the JSON ++/// // input. ++/// struct ExtendVecVisitor<'a, T: 'a>(&'a mut Vec); ++/// ++/// impl<'de, 'a, T> Visitor<'de> for ExtendVecVisitor<'a, T> ++/// where T: Deserialize<'de> ++/// { ++/// type Value = (); ++/// ++/// fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++/// write!(formatter, "an array of integers") ++/// } ++/// ++/// fn visit_seq(self, mut seq: A) -> Result<(), A::Error> ++/// where A: SeqAccess<'de> ++/// { ++/// // Visit each element in the inner array and push it onto ++/// // the existing vector. ++/// while let Some(elem) = seq.next_element()? { ++/// self.0.push(elem); ++/// } ++/// Ok(()) ++/// } ++/// } ++/// ++/// deserializer.deserialize_seq(ExtendVecVisitor(self.0)) ++/// } ++/// } ++/// ++/// // Visitor implementation that will walk the outer array of the JSON input. ++/// struct FlattenedVecVisitor(PhantomData); ++/// ++/// impl<'de, T> Visitor<'de> for FlattenedVecVisitor ++/// where T: Deserialize<'de> ++/// { ++/// // This Visitor constructs a single Vec to hold the flattened ++/// // contents of the inner arrays. ++/// type Value = Vec; ++/// ++/// fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++/// write!(formatter, "an array of arrays") ++/// } ++/// ++/// fn visit_seq(self, mut seq: A) -> Result, A::Error> ++/// where A: SeqAccess<'de> ++/// { ++/// // Create a single Vec to hold the flattened contents. ++/// let mut vec = Vec::new(); ++/// ++/// // Each iteration through this loop is one inner array. ++/// while let Some(()) = seq.next_element_seed(ExtendVec(&mut vec))? { ++/// // Nothing to do; inner array has been appended into `vec`. ++/// } ++/// ++/// // Return the finished vec. ++/// Ok(vec) ++/// } ++/// } ++/// ++/// # fn example<'de, D>(deserializer: D) -> Result<(), D::Error> ++/// # where D: Deserializer<'de> ++/// # { ++/// let visitor = FlattenedVecVisitor(PhantomData); ++/// let flattened: Vec = deserializer.deserialize_seq(visitor)?; ++/// # Ok(()) ++/// # } ++/// ``` ++pub trait DeserializeSeed<'de>: Sized { ++ /// The type produced by using this seed. ++ type Value; ++ ++ /// Equivalent to the more common `Deserialize::deserialize` method, except ++ /// with some initial piece of data (the seed) passed in. ++ fn deserialize(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>; ++} ++ ++impl<'de, T> DeserializeSeed<'de> for PhantomData ++where ++ T: Deserialize<'de>, ++{ ++ type Value = T; ++ ++ #[inline] ++ fn deserialize(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ T::deserialize(deserializer) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A **data format** that can deserialize any data structure supported by ++/// Serde. ++/// ++/// The role of this trait is to define the deserialization half of the Serde ++/// data model, which is a way to categorize every Rust data type into one of 27 ++/// possible types. Each method of the `Serializer` trait corresponds to one of ++/// the types of the data model. ++/// ++/// Implementations of `Deserialize` map themselves into this data model by ++/// passing to the `Deserializer` a `Visitor` implementation that can receive ++/// these various types. ++/// ++/// The types that make up the Serde data model are: ++/// ++/// - **12 primitive types** ++/// - bool ++/// - i8, i16, i32, i64 ++/// - u8, u16, u32, u64 ++/// - f32, f64 ++/// - char ++/// - **string** ++/// - UTF-8 bytes with a length and no null terminator. ++/// - When serializing, all strings are handled equally. When deserializing, ++/// there are three flavors of strings: transient, owned, and borrowed. ++/// - **byte array** - [u8] ++/// - Similar to strings, during deserialization byte arrays can be transient, ++/// owned, or borrowed. ++/// - **option** ++/// - Either none or some value. ++/// - **unit** ++/// - The type of `()` in Rust. It represents an anonymous value containing no ++/// data. ++/// - **unit_struct** ++/// - For example `struct Unit` or `PhantomData`. It represents a named value ++/// containing no data. ++/// - **unit_variant** ++/// - For example the `E::A` and `E::B` in `enum E { A, B }`. ++/// - **newtype_struct** ++/// - For example `struct Millimeters(u8)`. ++/// - **newtype_variant** ++/// - For example the `E::N` in `enum E { N(u8) }`. ++/// - **seq** ++/// - A variably sized heterogeneous sequence of values, for example `Vec` or ++/// `HashSet`. When serializing, the length may or may not be known before ++/// iterating through all the data. When deserializing, the length is determined ++/// by looking at the serialized data. ++/// - **tuple** ++/// - A statically sized heterogeneous sequence of values for which the length ++/// will be known at deserialization time without looking at the serialized ++/// data, for example `(u8,)` or `(String, u64, Vec)` or `[u64; 10]`. ++/// - **tuple_struct** ++/// - A named tuple, for example `struct Rgb(u8, u8, u8)`. ++/// - **tuple_variant** ++/// - For example the `E::T` in `enum E { T(u8, u8) }`. ++/// - **map** ++/// - A heterogeneous key-value pairing, for example `BTreeMap`. ++/// - **struct** ++/// - A heterogeneous key-value pairing in which the keys are strings and will be ++/// known at deserialization time without looking at the serialized data, for ++/// example `struct S { r: u8, g: u8, b: u8 }`. ++/// - **struct_variant** ++/// - For example the `E::S` in `enum E { S { r: u8, g: u8, b: u8 } }`. ++/// ++/// The `Deserializer` trait supports two entry point styles which enables ++/// different kinds of deserialization. ++/// ++/// 1. The `deserialize` method. Self-describing data formats like JSON are able ++/// to look at the serialized data and tell what it represents. For example ++/// the JSON deserializer may see an opening curly brace (`{`) and know that ++/// it is seeing a map. If the data format supports ++/// `Deserializer::deserialize_any`, it will drive the Visitor using whatever ++/// type it sees in the input. JSON uses this approach when deserializing ++/// `serde_json::Value` which is an enum that can represent any JSON ++/// document. Without knowing what is in a JSON document, we can deserialize ++/// it to `serde_json::Value` by going through `Deserializer::deserialize_any`. ++/// ++/// 2. The various `deserialize_*` methods. Non-self-describing formats like ++/// Bincode need to be told what is in the input in order to deserialize it. ++/// The `deserialize_*` methods are hints to the deserializer for how to ++/// interpret the next piece of input. Non-self-describing formats are not ++/// able to deserialize something like `serde_json::Value` which relies on ++/// `Deserializer::deserialize_any`. ++/// ++/// When implementing `Deserialize`, you should avoid relying on ++/// `Deserializer::deserialize_any` unless you need to be told by the Deserializer ++/// what type is in the input. Know that relying on `Deserializer::deserialize_any` ++/// means your data type will be able to deserialize from self-describing ++/// formats only, ruling out Bincode and many others. ++pub trait Deserializer<'de>: Sized { ++ /// The error type that can be returned if some error occurs during ++ /// deserialization. ++ type Error: Error; ++ ++ /// Require the `Deserializer` to figure out how to drive the visitor based ++ /// on what data type is in the input. ++ /// ++ /// When implementing `Deserialize`, you should avoid relying on ++ /// `Deserializer::deserialize_any` unless you need to be told by the ++ /// Deserializer what type is in the input. Know that relying on ++ /// `Deserializer::deserialize_any` means your data type will be able to ++ /// deserialize from self-describing formats only, ruling out Bincode and ++ /// many others. ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a `bool` value. ++ fn deserialize_bool(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting an `i8` value. ++ fn deserialize_i8(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting an `i16` value. ++ fn deserialize_i16(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting an `i32` value. ++ fn deserialize_i32(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting an `i64` value. ++ fn deserialize_i64(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a `u8` value. ++ fn deserialize_u8(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a `u16` value. ++ fn deserialize_u16(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a `u32` value. ++ fn deserialize_u32(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a `u64` value. ++ fn deserialize_u64(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a `f32` value. ++ fn deserialize_f32(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a `f64` value. ++ fn deserialize_f64(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a `char` value. ++ fn deserialize_char(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a string value and does ++ /// not benefit from taking ownership of buffered data owned by the ++ /// `Deserializer`. ++ /// ++ /// If the `Visitor` would benefit from taking ownership of `String` data, ++ /// indiciate this to the `Deserializer` by using `deserialize_string` ++ /// instead. ++ fn deserialize_str(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a string value and would ++ /// benefit from taking ownership of buffered data owned by the ++ /// `Deserializer`. ++ /// ++ /// If the `Visitor` would not benefit from taking ownership of `String` ++ /// data, indicate that to the `Deserializer` by using `deserialize_str` ++ /// instead. ++ fn deserialize_string(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a byte array and does not ++ /// benefit from taking ownership of buffered data owned by the ++ /// `Deserializer`. ++ /// ++ /// If the `Visitor` would benefit from taking ownership of `Vec` data, ++ /// indicate this to the `Deserializer` by using `deserialize_byte_buf` ++ /// instead. ++ fn deserialize_bytes(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a byte array and would ++ /// benefit from taking ownership of buffered data owned by the ++ /// `Deserializer`. ++ /// ++ /// If the `Visitor` would not benefit from taking ownership of `Vec` ++ /// data, indicate that to the `Deserializer` by using `deserialize_bytes` ++ /// instead. ++ fn deserialize_byte_buf(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting an optional value. ++ /// ++ /// This allows deserializers that encode an optional value as a nullable ++ /// value to convert the null value into `None` and a regular value into ++ /// `Some(value)`. ++ fn deserialize_option(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a unit value. ++ fn deserialize_unit(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a unit struct with a ++ /// particular name. ++ fn deserialize_unit_struct( ++ self, ++ name: &'static str, ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a newtype struct with a ++ /// particular name. ++ fn deserialize_newtype_struct( ++ self, ++ name: &'static str, ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a sequence of values. ++ fn deserialize_seq(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a sequence of values and ++ /// knows how many values there are without looking at the serialized data. ++ fn deserialize_tuple(self, len: usize, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a tuple struct with a ++ /// particular name and number of fields. ++ fn deserialize_tuple_struct( ++ self, ++ name: &'static str, ++ len: usize, ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a map of key-value pairs. ++ fn deserialize_map(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting a struct with a particular ++ /// name and fields. ++ fn deserialize_struct( ++ self, ++ name: &'static str, ++ fields: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting an enum value with a ++ /// particular name and possible variants. ++ fn deserialize_enum( ++ self, ++ name: &'static str, ++ variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type is expecting the name of a struct ++ /// field or the discriminant of an enum variant. ++ fn deserialize_identifier(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Hint that the `Deserialize` type needs to deserialize a value whose type ++ /// doesn't matter because it is ignored. ++ /// ++ /// Deserializers for non-self-describing formats may not support this mode. ++ fn deserialize_ignored_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// This trait represents a visitor that walks through a deserializer. ++/// ++/// ```rust ++/// # use std::fmt; ++/// # ++/// # use serde::de::{self, Unexpected, Visitor}; ++/// # ++/// /// A visitor that deserializes a long string - a string containing at least ++/// /// some minimum number of bytes. ++/// struct LongString { ++/// min: usize, ++/// } ++/// ++/// impl<'de> Visitor<'de> for LongString { ++/// type Value = String; ++/// ++/// fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++/// write!(formatter, "a string containing at least {} bytes", self.min) ++/// } ++/// ++/// fn visit_str(self, s: &str) -> Result ++/// where E: de::Error ++/// { ++/// if s.len() >= self.min { ++/// Ok(s.to_owned()) ++/// } else { ++/// Err(de::Error::invalid_value(Unexpected::Str(s), &self)) ++/// } ++/// } ++/// } ++/// ``` ++pub trait Visitor<'de>: Sized { ++ /// The value produced by this visitor. ++ type Value; ++ ++ /// Format a message stating what data this Visitor expects to receive. ++ /// ++ /// This is used in error messages. The message should complete the sentence ++ /// "This Visitor expects to receive ...", for example the message could be ++ /// "an integer between 0 and 64". The message should not be capitalized and ++ /// should not end with a period. ++ /// ++ /// ```rust ++ /// # use std::fmt; ++ /// # ++ /// # struct S { ++ /// # max: usize, ++ /// # } ++ /// # ++ /// # impl<'de> serde::de::Visitor<'de> for S { ++ /// # type Value = (); ++ /// # ++ /// fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ /// write!(formatter, "an integer between 0 and {}", self.max) ++ /// } ++ /// # } ++ /// ``` ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result; ++ ++ /// The input contains a boolean. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_bool(self, v: bool) -> Result ++ where ++ E: Error, ++ { ++ Err(Error::invalid_type(Unexpected::Bool(v), &self)) ++ } ++ ++ /// The input contains an `i8`. ++ /// ++ /// The default implementation forwards to [`visit_i64`]. ++ /// ++ /// [`visit_i64`]: #method.visit_i64 ++ fn visit_i8(self, v: i8) -> Result ++ where ++ E: Error, ++ { ++ self.visit_i64(v as i64) ++ } ++ ++ /// The input contains an `i16`. ++ /// ++ /// The default implementation forwards to [`visit_i64`]. ++ /// ++ /// [`visit_i64`]: #method.visit_i64 ++ fn visit_i16(self, v: i16) -> Result ++ where ++ E: Error, ++ { ++ self.visit_i64(v as i64) ++ } ++ ++ /// The input contains an `i32`. ++ /// ++ /// The default implementation forwards to [`visit_i64`]. ++ /// ++ /// [`visit_i64`]: #method.visit_i64 ++ fn visit_i32(self, v: i32) -> Result ++ where ++ E: Error, ++ { ++ self.visit_i64(v as i64) ++ } ++ ++ /// The input contains an `i64`. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_i64(self, v: i64) -> Result ++ where ++ E: Error, ++ { ++ Err(Error::invalid_type(Unexpected::Signed(v), &self)) ++ } ++ ++ /// The input contains a `u8`. ++ /// ++ /// The default implementation forwards to [`visit_u64`]. ++ /// ++ /// [`visit_u64`]: #method.visit_u64 ++ fn visit_u8(self, v: u8) -> Result ++ where ++ E: Error, ++ { ++ self.visit_u64(v as u64) ++ } ++ ++ /// The input contains a `u16`. ++ /// ++ /// The default implementation forwards to [`visit_u64`]. ++ /// ++ /// [`visit_u64`]: #method.visit_u64 ++ fn visit_u16(self, v: u16) -> Result ++ where ++ E: Error, ++ { ++ self.visit_u64(v as u64) ++ } ++ ++ /// The input contains a `u32`. ++ /// ++ /// The default implementation forwards to [`visit_u64`]. ++ /// ++ /// [`visit_u64`]: #method.visit_u64 ++ fn visit_u32(self, v: u32) -> Result ++ where ++ E: Error, ++ { ++ self.visit_u64(v as u64) ++ } ++ ++ /// The input contains a `u64`. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_u64(self, v: u64) -> Result ++ where ++ E: Error, ++ { ++ Err(Error::invalid_type(Unexpected::Unsigned(v), &self)) ++ } ++ ++ /// The input contains an `f32`. ++ /// ++ /// The default implementation forwards to [`visit_f64`]. ++ /// ++ /// [`visit_f64`]: #method.visit_f64 ++ fn visit_f32(self, v: f32) -> Result ++ where ++ E: Error, ++ { ++ self.visit_f64(v as f64) ++ } ++ ++ /// The input contains an `f64`. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_f64(self, v: f64) -> Result ++ where ++ E: Error, ++ { ++ Err(Error::invalid_type(Unexpected::Float(v), &self)) ++ } ++ ++ /// The input contains a `char`. ++ /// ++ /// The default implementation forwards to [`visit_str`] as a one-character ++ /// string. ++ /// ++ /// [`visit_str`]: #method.visit_str ++ #[inline] ++ fn visit_char(self, v: char) -> Result ++ where ++ E: Error, ++ { ++ self.visit_str(utf8::encode(v).as_str()) ++ } ++ ++ /// The input contains a string. The lifetime of the string is ephemeral and ++ /// it may be destroyed after this method returns. ++ /// ++ /// This method allows the `Deserializer` to avoid a copy by retaining ++ /// ownership of any buffered data. `Deserialize` implementations that do ++ /// not benefit from taking ownership of `String` data should indicate that ++ /// to the deserializer by using `Deserializer::deserialize_str` rather than ++ /// `Deserializer::deserialize_string`. ++ /// ++ /// It is never correct to implement `visit_string` without implementing ++ /// `visit_str`. Implement neither, both, or just `visit_str`. ++ fn visit_str(self, v: &str) -> Result ++ where ++ E: Error, ++ { ++ Err(Error::invalid_type(Unexpected::Str(v), &self)) ++ } ++ ++ /// The input contains a string that lives at least as long as the ++ /// `Deserializer`. ++ /// ++ /// This enables zero-copy deserialization of strings in some formats. For ++ /// example JSON input containing the JSON string `"borrowed"` can be ++ /// deserialized with zero copying into a `&'a str` as long as the input ++ /// data outlives `'a`. ++ /// ++ /// The default implementation forwards to `visit_str`. ++ #[inline] ++ fn visit_borrowed_str(self, v: &'de str) -> Result ++ where ++ E: Error, ++ { ++ self.visit_str(v) ++ } ++ ++ /// The input contains a string and ownership of the string is being given ++ /// to the `Visitor`. ++ /// ++ /// This method allows the `Visitor` to avoid a copy by taking ownership of ++ /// a string created by the `Deserializer`. `Deserialize` implementations ++ /// that benefit from taking ownership of `String` data should indicate that ++ /// to the deserializer by using `Deserializer::deserialize_string` rather ++ /// than `Deserializer::deserialize_str`, although not every deserializer ++ /// will honor such a request. ++ /// ++ /// It is never correct to implement `visit_string` without implementing ++ /// `visit_str`. Implement neither, both, or just `visit_str`. ++ /// ++ /// The default implementation forwards to `visit_str` and then drops the ++ /// `String`. ++ #[inline] ++ #[cfg(any(feature = "std", feature = "alloc"))] ++ fn visit_string(self, v: String) -> Result ++ where ++ E: Error, ++ { ++ self.visit_str(&v) ++ } ++ ++ /// The input contains a byte array. The lifetime of the byte array is ++ /// ephemeral and it may be destroyed after this method returns. ++ /// ++ /// This method allows the `Deserializer` to avoid a copy by retaining ++ /// ownership of any buffered data. `Deserialize` implementations that do ++ /// not benefit from taking ownership of `Vec` data should indicate that ++ /// to the deserializer by using `Deserializer::deserialize_bytes` rather ++ /// than `Deserializer::deserialize_byte_buf`. ++ /// ++ /// It is never correct to implement `visit_byte_buf` without implementing ++ /// `visit_bytes`. Implement neither, both, or just `visit_bytes`. ++ fn visit_bytes(self, v: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ let _ = v; ++ Err(Error::invalid_type(Unexpected::Bytes(v), &self)) ++ } ++ ++ /// The input contains a byte array that lives at least as long as the ++ /// `Deserializer`. ++ /// ++ /// This enables zero-copy deserialization of bytes in some formats. For ++ /// example Bincode data containing bytes can be deserialized with zero ++ /// copying into a `&'a [u8]` as long as the input data outlives `'a`. ++ /// ++ /// The default implementation forwards to `visit_bytes`. ++ #[inline] ++ fn visit_borrowed_bytes(self, v: &'de [u8]) -> Result ++ where ++ E: Error, ++ { ++ self.visit_bytes(v) ++ } ++ ++ /// The input contains a byte array and ownership of the byte array is being ++ /// given to the `Visitor`. ++ /// ++ /// This method allows the `Visitor` to avoid a copy by taking ownership of ++ /// a byte buffer created by the `Deserializer`. `Deserialize` ++ /// implementations that benefit from taking ownership of `Vec` data ++ /// should indicate that to the deserializer by using ++ /// `Deserializer::deserialize_byte_buf` rather than ++ /// `Deserializer::deserialize_bytes`, although not every deserializer will ++ /// honor such a request. ++ /// ++ /// It is never correct to implement `visit_byte_buf` without implementing ++ /// `visit_bytes`. Implement neither, both, or just `visit_bytes`. ++ /// ++ /// The default implementation forwards to `visit_bytes` and then drops the ++ /// `Vec`. ++ #[cfg(any(feature = "std", feature = "alloc"))] ++ fn visit_byte_buf(self, v: Vec) -> Result ++ where ++ E: Error, ++ { ++ self.visit_bytes(&v) ++ } ++ ++ /// The input contains an optional that is absent. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_none(self) -> Result ++ where ++ E: Error, ++ { ++ Err(Error::invalid_type(Unexpected::Option, &self)) ++ } ++ ++ /// The input contains an optional that is present. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_some(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ let _ = deserializer; ++ Err(Error::invalid_type(Unexpected::Option, &self)) ++ } ++ ++ /// The input contains a unit `()`. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_unit(self) -> Result ++ where ++ E: Error, ++ { ++ Err(Error::invalid_type(Unexpected::Unit, &self)) ++ } ++ ++ /// The input contains a newtype struct. ++ /// ++ /// The content of the newtype struct may be read from the given ++ /// `Deserializer`. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_newtype_struct(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ let _ = deserializer; ++ Err(Error::invalid_type(Unexpected::NewtypeStruct, &self)) ++ } ++ ++ /// The input contains a sequence of elements. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_seq(self, seq: A) -> Result ++ where ++ A: SeqAccess<'de>, ++ { ++ let _ = seq; ++ Err(Error::invalid_type(Unexpected::Seq, &self)) ++ } ++ ++ /// The input contains a key-value map. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_map(self, map: A) -> Result ++ where ++ A: MapAccess<'de>, ++ { ++ let _ = map; ++ Err(Error::invalid_type(Unexpected::Map, &self)) ++ } ++ ++ /// The input contains an enum. ++ /// ++ /// The default implementation fails with a type error. ++ fn visit_enum(self, data: A) -> Result ++ where ++ A: EnumAccess<'de>, ++ { ++ let _ = data; ++ Err(Error::invalid_type(Unexpected::Enum, &self)) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// Provides a `Visitor` access to each element of a sequence in the input. ++/// ++/// This is a trait that a `Deserializer` passes to a `Visitor` implementation, ++/// which deserializes each item in a sequence. ++pub trait SeqAccess<'de> { ++ /// The error type that can be returned if some error occurs during ++ /// deserialization. ++ type Error: Error; ++ ++ /// This returns `Ok(Some(value))` for the next value in the sequence, or ++ /// `Ok(None)` if there are no more remaining items. ++ /// ++ /// `Deserialize` implementations should typically use ++ /// `SeqAccess::next_element` instead. ++ fn next_element_seed(&mut self, seed: T) -> Result, Self::Error> ++ where ++ T: DeserializeSeed<'de>; ++ ++ /// This returns `Ok(Some(value))` for the next value in the sequence, or ++ /// `Ok(None)` if there are no more remaining items. ++ /// ++ /// This method exists as a convenience for `Deserialize` implementations. ++ /// `SeqAccess` implementations should not override the default behavior. ++ #[inline] ++ fn next_element(&mut self) -> Result, Self::Error> ++ where ++ T: Deserialize<'de>, ++ { ++ self.next_element_seed(PhantomData) ++ } ++ ++ /// Returns the number of elements remaining in the sequence, if known. ++ #[inline] ++ fn size_hint(&self) -> Option { ++ None ++ } ++} ++ ++impl<'de, 'a, A> SeqAccess<'de> for &'a mut A ++where ++ A: SeqAccess<'de>, ++{ ++ type Error = A::Error; ++ ++ #[inline] ++ fn next_element_seed(&mut self, seed: T) -> Result, Self::Error> ++ where ++ T: DeserializeSeed<'de>, ++ { ++ (**self).next_element_seed(seed) ++ } ++ ++ #[inline] ++ fn next_element(&mut self) -> Result, Self::Error> ++ where ++ T: Deserialize<'de>, ++ { ++ (**self).next_element() ++ } ++ ++ #[inline] ++ fn size_hint(&self) -> Option { ++ (**self).size_hint() ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// Provides a `Visitor` access to each entry of a map in the input. ++/// ++/// This is a trait that a `Deserializer` passes to a `Visitor` implementation. ++pub trait MapAccess<'de> { ++ /// The error type that can be returned if some error occurs during ++ /// deserialization. ++ type Error: Error; ++ ++ /// This returns `Ok(Some(key))` for the next key in the map, or `Ok(None)` ++ /// if there are no more remaining entries. ++ /// ++ /// `Deserialize` implementations should typically use ++ /// `MapAccess::next_key` or `MapAccess::next_entry` instead. ++ fn next_key_seed(&mut self, seed: K) -> Result, Self::Error> ++ where ++ K: DeserializeSeed<'de>; ++ ++ /// This returns a `Ok(value)` for the next value in the map. ++ /// ++ /// `Deserialize` implementations should typically use ++ /// `MapAccess::next_value` instead. ++ /// ++ /// # Panics ++ /// ++ /// Calling `next_value_seed` before `next_key_seed` is incorrect and is ++ /// allowed to panic or return bogus results. ++ fn next_value_seed(&mut self, seed: V) -> Result ++ where ++ V: DeserializeSeed<'de>; ++ ++ /// This returns `Ok(Some((key, value)))` for the next (key-value) pair in ++ /// the map, or `Ok(None)` if there are no more remaining items. ++ /// ++ /// `MapAccess` implementations should override the default behavior if a ++ /// more efficient implementation is possible. ++ /// ++ /// `Deserialize` implementations should typically use ++ /// `MapAccess::next_entry` instead. ++ #[inline] ++ fn next_entry_seed( ++ &mut self, ++ kseed: K, ++ vseed: V, ++ ) -> Result, Self::Error> ++ where ++ K: DeserializeSeed<'de>, ++ V: DeserializeSeed<'de>, ++ { ++ match try!(self.next_key_seed(kseed)) { ++ Some(key) => { ++ let value = try!(self.next_value_seed(vseed)); ++ Ok(Some((key, value))) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ /// This returns `Ok(Some(key))` for the next key in the map, or `Ok(None)` ++ /// if there are no more remaining entries. ++ /// ++ /// This method exists as a convenience for `Deserialize` implementations. ++ /// `MapAccess` implementations should not override the default behavior. ++ #[inline] ++ fn next_key(&mut self) -> Result, Self::Error> ++ where ++ K: Deserialize<'de>, ++ { ++ self.next_key_seed(PhantomData) ++ } ++ ++ /// This returns a `Ok(value)` for the next value in the map. ++ /// ++ /// This method exists as a convenience for `Deserialize` implementations. ++ /// `MapAccess` implementations should not override the default behavior. ++ /// ++ /// # Panics ++ /// ++ /// Calling `next_value` before `next_key` is incorrect and is allowed to ++ /// panic or return bogus results. ++ #[inline] ++ fn next_value(&mut self) -> Result ++ where ++ V: Deserialize<'de>, ++ { ++ self.next_value_seed(PhantomData) ++ } ++ ++ /// This returns `Ok(Some((key, value)))` for the next (key-value) pair in ++ /// the map, or `Ok(None)` if there are no more remaining items. ++ /// ++ /// This method exists as a convenience for `Deserialize` implementations. ++ /// `MapAccess` implementations should not override the default behavior. ++ #[inline] ++ fn next_entry(&mut self) -> Result, Self::Error> ++ where ++ K: Deserialize<'de>, ++ V: Deserialize<'de>, ++ { ++ self.next_entry_seed(PhantomData, PhantomData) ++ } ++ ++ /// Returns the number of entries remaining in the map, if known. ++ #[inline] ++ fn size_hint(&self) -> Option { ++ None ++ } ++} ++ ++impl<'de, 'a, A> MapAccess<'de> for &'a mut A ++where ++ A: MapAccess<'de>, ++{ ++ type Error = A::Error; ++ ++ #[inline] ++ fn next_key_seed(&mut self, seed: K) -> Result, Self::Error> ++ where ++ K: DeserializeSeed<'de>, ++ { ++ (**self).next_key_seed(seed) ++ } ++ ++ #[inline] ++ fn next_value_seed(&mut self, seed: V) -> Result ++ where ++ V: DeserializeSeed<'de>, ++ { ++ (**self).next_value_seed(seed) ++ } ++ ++ #[inline] ++ fn next_entry_seed( ++ &mut self, ++ kseed: K, ++ vseed: V, ++ ) -> Result, Self::Error> ++ where ++ K: DeserializeSeed<'de>, ++ V: DeserializeSeed<'de>, ++ { ++ (**self).next_entry_seed(kseed, vseed) ++ } ++ ++ #[inline] ++ fn next_entry(&mut self) -> Result, Self::Error> ++ where ++ K: Deserialize<'de>, ++ V: Deserialize<'de>, ++ { ++ (**self).next_entry() ++ } ++ ++ #[inline] ++ fn next_key(&mut self) -> Result, Self::Error> ++ where ++ K: Deserialize<'de>, ++ { ++ (**self).next_key() ++ } ++ ++ #[inline] ++ fn next_value(&mut self) -> Result ++ where ++ V: Deserialize<'de>, ++ { ++ (**self).next_value() ++ } ++ ++ #[inline] ++ fn size_hint(&self) -> Option { ++ (**self).size_hint() ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// Provides a `Visitor` access to the data of an enum in the input. ++/// ++/// `EnumAccess` is created by the `Deserializer` and passed to the ++/// `Visitor` in order to identify which variant of an enum to deserialize. ++pub trait EnumAccess<'de>: Sized { ++ /// The error type that can be returned if some error occurs during ++ /// deserialization. ++ type Error: Error; ++ /// The `Visitor` that will be used to deserialize the content of the enum ++ /// variant. ++ type Variant: VariantAccess<'de, Error = Self::Error>; ++ ++ /// `variant` is called to identify which variant to deserialize. ++ /// ++ /// `Deserialize` implementations should typically use `EnumAccess::variant` ++ /// instead. ++ fn variant_seed(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error> ++ where ++ V: DeserializeSeed<'de>; ++ ++ /// `variant` is called to identify which variant to deserialize. ++ /// ++ /// This method exists as a convenience for `Deserialize` implementations. ++ /// `EnumAccess` implementations should not override the default behavior. ++ #[inline] ++ fn variant(self) -> Result<(V, Self::Variant), Self::Error> ++ where ++ V: Deserialize<'de>, ++ { ++ self.variant_seed(PhantomData) ++ } ++} ++ ++/// `VariantAccess` is a visitor that is created by the `Deserializer` and ++/// passed to the `Deserialize` to deserialize the content of a particular enum ++/// variant. ++pub trait VariantAccess<'de>: Sized { ++ /// The error type that can be returned if some error occurs during ++ /// deserialization. Must match the error type of our `EnumAccess`. ++ type Error: Error; ++ ++ /// Called when deserializing a variant with no values. ++ /// ++ /// If the data contains a different type of variant, the following ++ /// `invalid_type` error should be constructed: ++ /// ++ /// ```rust ++ /// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected}; ++ /// # ++ /// # struct X; ++ /// # ++ /// # impl<'de> VariantAccess<'de> for X { ++ /// # type Error = value::Error; ++ /// # ++ /// fn unit_variant(self) -> Result<(), Self::Error> { ++ /// // What the data actually contained; suppose it is a tuple variant. ++ /// let unexp = Unexpected::TupleVariant; ++ /// Err(de::Error::invalid_type(unexp, &"unit variant")) ++ /// } ++ /// # ++ /// # fn newtype_variant_seed(self, _: T) -> Result ++ /// # where T: DeserializeSeed<'de> ++ /// # { unimplemented!() } ++ /// # ++ /// # fn tuple_variant(self, _: usize, _: V) -> Result ++ /// # where V: Visitor<'de> ++ /// # { unimplemented!() } ++ /// # ++ /// # fn struct_variant(self, _: &[&str], _: V) -> Result ++ /// # where V: Visitor<'de> ++ /// # { unimplemented!() } ++ /// # } ++ /// ``` ++ fn unit_variant(self) -> Result<(), Self::Error>; ++ ++ /// Called when deserializing a variant with a single value. ++ /// ++ /// `Deserialize` implementations should typically use ++ /// `VariantAccess::newtype_variant` instead. ++ /// ++ /// If the data contains a different type of variant, the following ++ /// `invalid_type` error should be constructed: ++ /// ++ /// ```rust ++ /// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected}; ++ /// # ++ /// # struct X; ++ /// # ++ /// # impl<'de> VariantAccess<'de> for X { ++ /// # type Error = value::Error; ++ /// # ++ /// # fn unit_variant(self) -> Result<(), Self::Error> { ++ /// # unimplemented!() ++ /// # } ++ /// # ++ /// fn newtype_variant_seed(self, _seed: T) -> Result ++ /// where T: DeserializeSeed<'de> ++ /// { ++ /// // What the data actually contained; suppose it is a unit variant. ++ /// let unexp = Unexpected::UnitVariant; ++ /// Err(de::Error::invalid_type(unexp, &"newtype variant")) ++ /// } ++ /// # ++ /// # fn tuple_variant(self, _: usize, _: V) -> Result ++ /// # where V: Visitor<'de> ++ /// # { unimplemented!() } ++ /// # ++ /// # fn struct_variant(self, _: &[&str], _: V) -> Result ++ /// # where V: Visitor<'de> ++ /// # { unimplemented!() } ++ /// # } ++ /// ``` ++ fn newtype_variant_seed(self, seed: T) -> Result ++ where ++ T: DeserializeSeed<'de>; ++ ++ /// Called when deserializing a variant with a single value. ++ /// ++ /// This method exists as a convenience for `Deserialize` implementations. ++ /// `VariantAccess` implementations should not override the default ++ /// behavior. ++ #[inline] ++ fn newtype_variant(self) -> Result ++ where ++ T: Deserialize<'de>, ++ { ++ self.newtype_variant_seed(PhantomData) ++ } ++ ++ /// Called when deserializing a tuple-like variant. ++ /// ++ /// The `len` is the number of fields expected in the tuple variant. ++ /// ++ /// If the data contains a different type of variant, the following ++ /// `invalid_type` error should be constructed: ++ /// ++ /// ```rust ++ /// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected}; ++ /// # ++ /// # struct X; ++ /// # ++ /// # impl<'de> VariantAccess<'de> for X { ++ /// # type Error = value::Error; ++ /// # ++ /// # fn unit_variant(self) -> Result<(), Self::Error> { ++ /// # unimplemented!() ++ /// # } ++ /// # ++ /// # fn newtype_variant_seed(self, _: T) -> Result ++ /// # where T: DeserializeSeed<'de> ++ /// # { unimplemented!() } ++ /// # ++ /// fn tuple_variant(self, ++ /// _len: usize, ++ /// _visitor: V) -> Result ++ /// where V: Visitor<'de> ++ /// { ++ /// // What the data actually contained; suppose it is a unit variant. ++ /// let unexp = Unexpected::UnitVariant; ++ /// Err(de::Error::invalid_type(unexp, &"tuple variant")) ++ /// } ++ /// # ++ /// # fn struct_variant(self, _: &[&str], _: V) -> Result ++ /// # where V: Visitor<'de> ++ /// # { unimplemented!() } ++ /// # } ++ /// ``` ++ fn tuple_variant(self, len: usize, visitor: V) -> Result ++ where ++ V: Visitor<'de>; ++ ++ /// Called when deserializing a struct-like variant. ++ /// ++ /// The `fields` are the names of the fields of the struct variant. ++ /// ++ /// If the data contains a different type of variant, the following ++ /// `invalid_type` error should be constructed: ++ /// ++ /// ```rust ++ /// # use serde::de::{self, value, DeserializeSeed, Visitor, VariantAccess, Unexpected}; ++ /// # ++ /// # struct X; ++ /// # ++ /// # impl<'de> VariantAccess<'de> for X { ++ /// # type Error = value::Error; ++ /// # ++ /// # fn unit_variant(self) -> Result<(), Self::Error> { ++ /// # unimplemented!() ++ /// # } ++ /// # ++ /// # fn newtype_variant_seed(self, _: T) -> Result ++ /// # where T: DeserializeSeed<'de> ++ /// # { unimplemented!() } ++ /// # ++ /// # fn tuple_variant(self, _: usize, _: V) -> Result ++ /// # where V: Visitor<'de> ++ /// # { unimplemented!() } ++ /// # ++ /// fn struct_variant(self, ++ /// _fields: &'static [&'static str], ++ /// _visitor: V) -> Result ++ /// where V: Visitor<'de> ++ /// { ++ /// // What the data actually contained; suppose it is a unit variant. ++ /// let unexp = Unexpected::UnitVariant; ++ /// Err(de::Error::invalid_type(unexp, &"struct variant")) ++ /// } ++ /// # } ++ /// ``` ++ fn struct_variant( ++ self, ++ fields: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>; ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// Converts an existing value into a `Deserializer` from which other values can ++/// be deserialized. ++/// ++/// ```rust ++/// #[macro_use] ++/// extern crate serde_derive; ++/// ++/// extern crate serde; ++/// ++/// use std::str::FromStr; ++/// use serde::de::{value, Deserialize, IntoDeserializer}; ++/// ++/// #[derive(Deserialize)] ++/// enum Setting { ++/// On, ++/// Off, ++/// } ++/// ++/// impl FromStr for Setting { ++/// type Err = value::Error; ++/// ++/// fn from_str(s: &str) -> Result { ++/// Self::deserialize(s.into_deserializer()) ++/// } ++/// } ++/// # ++/// # fn main() {} ++/// ``` ++pub trait IntoDeserializer<'de, E: Error = value::Error> { ++ /// The type of the deserializer being converted into. ++ type Deserializer: Deserializer<'de, Error = E>; ++ ++ /// Convert this value into a deserializer. ++ fn into_deserializer(self) -> Self::Deserializer; ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// Used in error messages. ++/// ++/// - expected `a` ++/// - expected `a` or `b` ++/// - expected one of `a`, `b`, `c` ++/// ++/// The slice of names must not be empty. ++struct OneOf { ++ names: &'static [&'static str], ++} ++ ++impl Display for OneOf { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ match self.names.len() { ++ 0 => panic!(), // special case elsewhere ++ 1 => write!(formatter, "`{}`", self.names[0]), ++ 2 => write!(formatter, "`{}` or `{}`", self.names[0], self.names[1]), ++ _ => { ++ try!(write!(formatter, "one of ")); ++ for (i, alt) in self.names.iter().enumerate() { ++ if i > 0 { ++ try!(write!(formatter, ", ")); ++ } ++ try!(write!(formatter, "`{}`", alt)); ++ } ++ Ok(()) ++ } ++ } ++ } ++} diff --cc vendor/serde-1.0.15/src/de/utf8.rs index 000000000,000000000..37221a1e6 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/de/utf8.rs @@@ -1,0 -1,0 +1,54 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use lib::*; ++ ++const TAG_CONT: u8 = 0b1000_0000; ++const TAG_TWO_B: u8 = 0b1100_0000; ++const TAG_THREE_B: u8 = 0b1110_0000; ++const TAG_FOUR_B: u8 = 0b1111_0000; ++const MAX_ONE_B: u32 = 0x80; ++const MAX_TWO_B: u32 = 0x800; ++const MAX_THREE_B: u32 = 0x10000; ++ ++#[inline] ++pub fn encode(c: char) -> Encode { ++ let code = c as u32; ++ let mut buf = [0; 4]; ++ let pos = if code < MAX_ONE_B { ++ buf[3] = code as u8; ++ 3 ++ } else if code < MAX_TWO_B { ++ buf[2] = (code >> 6 & 0x1F) as u8 | TAG_TWO_B; ++ buf[3] = (code & 0x3F) as u8 | TAG_CONT; ++ 2 ++ } else if code < MAX_THREE_B { ++ buf[1] = (code >> 12 & 0x0F) as u8 | TAG_THREE_B; ++ buf[2] = (code >> 6 & 0x3F) as u8 | TAG_CONT; ++ buf[3] = (code & 0x3F) as u8 | TAG_CONT; ++ 1 ++ } else { ++ buf[0] = (code >> 18 & 0x07) as u8 | TAG_FOUR_B; ++ buf[1] = (code >> 12 & 0x3F) as u8 | TAG_CONT; ++ buf[2] = (code >> 6 & 0x3F) as u8 | TAG_CONT; ++ buf[3] = (code & 0x3F) as u8 | TAG_CONT; ++ 0 ++ }; ++ Encode { buf: buf, pos: pos } ++} ++ ++pub struct Encode { ++ buf: [u8; 4], ++ pos: usize, ++} ++ ++impl Encode { ++ pub fn as_str(&self) -> &str { ++ str::from_utf8(&self.buf[self.pos..]).unwrap() ++ } ++} diff --cc vendor/serde-1.0.15/src/de/value.rs index 000000000,000000000..3575c53d8 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/de/value.rs @@@ -1,0 -1,0 +1,1281 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! Building blocks for deserializing basic values using the `IntoDeserializer` ++//! trait. ++//! ++//! ```rust ++//! #[macro_use] ++//! extern crate serde_derive; ++//! ++//! extern crate serde; ++//! ++//! use std::str::FromStr; ++//! use serde::de::{value, Deserialize, IntoDeserializer}; ++//! ++//! #[derive(Deserialize)] ++//! enum Setting { ++//! On, ++//! Off, ++//! } ++//! ++//! impl FromStr for Setting { ++//! type Err = value::Error; ++//! ++//! fn from_str(s: &str) -> Result { ++//! Self::deserialize(s.into_deserializer()) ++//! } ++//! } ++//! # ++//! # fn main() {} ++//! ``` ++ ++use lib::*; ++ ++use de::{self, IntoDeserializer, Expected, SeqAccess}; ++use private::de::size_hint; ++use ser; ++use self::private::{First, Second}; ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A minimal representation of all possible errors that can occur using the ++/// `IntoDeserializer` trait. ++#[derive(Clone, Debug, PartialEq)] ++pub struct Error { ++ err: ErrorImpl, ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++type ErrorImpl = Box; ++#[cfg(not(any(feature = "std", feature = "alloc")))] ++type ErrorImpl = (); ++ ++impl de::Error for Error { ++ #[cfg(any(feature = "std", feature = "alloc"))] ++ fn custom(msg: T) -> Self ++ where ++ T: Display, ++ { ++ Error { err: msg.to_string().into_boxed_str() } ++ } ++ ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ fn custom(msg: T) -> Self ++ where ++ T: Display, ++ { ++ let _ = msg; ++ Error { err: () } ++ } ++} ++ ++impl ser::Error for Error { ++ fn custom(msg: T) -> Self ++ where ++ T: Display, ++ { ++ de::Error::custom(msg) ++ } ++} ++ ++impl Display for Error { ++ #[cfg(any(feature = "std", feature = "alloc"))] ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { ++ formatter.write_str(&self.err) ++ } ++ ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { ++ formatter.write_str("Serde deserialization error") ++ } ++} ++ ++#[cfg(feature = "std")] ++impl error::Error for Error { ++ fn description(&self) -> &str { ++ &self.err ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++impl<'de, E> IntoDeserializer<'de, E> for () ++where ++ E: de::Error, ++{ ++ type Deserializer = UnitDeserializer; ++ ++ fn into_deserializer(self) -> UnitDeserializer { ++ UnitDeserializer { marker: PhantomData } ++ } ++} ++ ++/// A deserializer holding a `()`. ++#[derive(Clone, Debug)] ++pub struct UnitDeserializer { ++ marker: PhantomData, ++} ++ ++impl<'de, E> de::Deserializer<'de> for UnitDeserializer ++where ++ E: de::Error, ++{ ++ type Error = E; ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf unit unit_struct newtype_struct seq tuple tuple_struct map ++ struct enum identifier ignored_any ++ } ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_unit() ++ } ++ ++ fn deserialize_option(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_none() ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++macro_rules! primitive_deserializer { ++ ($ty:ty, $doc:tt, $name:ident, $method:ident $($cast:tt)*) => { ++ #[doc = "A deserializer holding"] ++ #[doc = $doc] ++ #[derive(Clone, Debug)] ++ pub struct $name { ++ value: $ty, ++ marker: PhantomData ++ } ++ ++ impl<'de, E> IntoDeserializer<'de, E> for $ty ++ where ++ E: de::Error, ++ { ++ type Deserializer = $name; ++ ++ fn into_deserializer(self) -> $name { ++ $name { ++ value: self, ++ marker: PhantomData, ++ } ++ } ++ } ++ ++ impl<'de, E> de::Deserializer<'de> for $name ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.$method(self.value $($cast)*) ++ } ++ } ++ } ++} ++ ++primitive_deserializer!(bool, "a `bool`.", BoolDeserializer, visit_bool); ++primitive_deserializer!(i8, "an `i8`.", I8Deserializer, visit_i8); ++primitive_deserializer!(i16, "an `i16`.", I16Deserializer, visit_i16); ++primitive_deserializer!(i32, "an `i32`.", I32Deserializer, visit_i32); ++primitive_deserializer!(i64, "an `i64`.", I64Deserializer, visit_i64); ++primitive_deserializer!(isize, "an `isize`.", IsizeDeserializer, visit_i64 as i64); ++primitive_deserializer!(u8, "a `u8`.", U8Deserializer, visit_u8); ++primitive_deserializer!(u16, "a `u16`.", U16Deserializer, visit_u16); ++primitive_deserializer!(u64, "a `u64`.", U64Deserializer, visit_u64); ++primitive_deserializer!(usize, "a `usize`.", UsizeDeserializer, visit_u64 as u64); ++primitive_deserializer!(f32, "an `f32`.", F32Deserializer, visit_f32); ++primitive_deserializer!(f64, "an `f64`.", F64Deserializer, visit_f64); ++primitive_deserializer!(char, "a `char`.", CharDeserializer, visit_char); ++ ++/// A deserializer holding a `u32`. ++#[derive(Clone, Debug)] ++pub struct U32Deserializer { ++ value: u32, ++ marker: PhantomData, ++} ++ ++impl<'de, E> IntoDeserializer<'de, E> for u32 ++where ++ E: de::Error, ++{ ++ type Deserializer = U32Deserializer; ++ ++ fn into_deserializer(self) -> U32Deserializer { ++ U32Deserializer { ++ value: self, ++ marker: PhantomData, ++ } ++ } ++} ++ ++impl<'de, E> de::Deserializer<'de> for U32Deserializer ++where ++ E: de::Error, ++{ ++ type Error = E; ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct identifier ignored_any ++ } ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_u32(self.value) ++ } ++ ++ fn deserialize_enum( ++ self, ++ name: &str, ++ variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let _ = name; ++ let _ = variants; ++ visitor.visit_enum(self) ++ } ++} ++ ++impl<'de, E> de::EnumAccess<'de> for U32Deserializer ++where ++ E: de::Error, ++{ ++ type Error = E; ++ type Variant = private::UnitOnly; ++ ++ fn variant_seed(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ seed.deserialize(self).map(private::unit_only) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A deserializer holding a `&str`. ++#[derive(Clone, Debug)] ++pub struct StrDeserializer<'a, E> { ++ value: &'a str, ++ marker: PhantomData, ++} ++ ++impl<'de, 'a, E> IntoDeserializer<'de, E> for &'a str ++where ++ E: de::Error, ++{ ++ type Deserializer = StrDeserializer<'a, E>; ++ ++ fn into_deserializer(self) -> StrDeserializer<'a, E> { ++ StrDeserializer { ++ value: self, ++ marker: PhantomData, ++ } ++ } ++} ++ ++impl<'de, 'a, E> de::Deserializer<'de> for StrDeserializer<'a, E> ++where ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_str(self.value) ++ } ++ ++ fn deserialize_enum( ++ self, ++ name: &str, ++ variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let _ = name; ++ let _ = variants; ++ visitor.visit_enum(self) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct identifier ignored_any ++ } ++} ++ ++impl<'de, 'a, E> de::EnumAccess<'de> for StrDeserializer<'a, E> ++where ++ E: de::Error, ++{ ++ type Error = E; ++ type Variant = private::UnitOnly; ++ ++ fn variant_seed(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ seed.deserialize(self).map(private::unit_only) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A deserializer holding a `&str` with a lifetime tied to another ++/// deserializer. ++#[derive(Clone, Debug)] ++pub struct BorrowedStrDeserializer<'de, E> { ++ value: &'de str, ++ marker: PhantomData, ++} ++ ++impl<'de, E> BorrowedStrDeserializer<'de, E> { ++ /// Create a new borrowed deserializer from the given string. ++ pub fn new(value: &'de str) -> BorrowedStrDeserializer<'de, E> { ++ BorrowedStrDeserializer { ++ value: value, ++ marker: PhantomData, ++ } ++ } ++} ++ ++impl<'de, E> de::Deserializer<'de> for BorrowedStrDeserializer<'de, E> ++where ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_borrowed_str(self.value) ++ } ++ ++ fn deserialize_enum( ++ self, ++ name: &str, ++ variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let _ = name; ++ let _ = variants; ++ visitor.visit_enum(self) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct identifier ignored_any ++ } ++} ++ ++impl<'de, E> de::EnumAccess<'de> for BorrowedStrDeserializer<'de, E> ++where ++ E: de::Error, ++{ ++ type Error = E; ++ type Variant = private::UnitOnly; ++ ++ fn variant_seed(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ seed.deserialize(self).map(private::unit_only) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A deserializer holding a `String`. ++#[cfg(any(feature = "std", feature = "alloc"))] ++#[derive(Clone, Debug)] ++pub struct StringDeserializer { ++ value: String, ++ marker: PhantomData, ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de, E> IntoDeserializer<'de, E> for String ++where ++ E: de::Error, ++{ ++ type Deserializer = StringDeserializer; ++ ++ fn into_deserializer(self) -> StringDeserializer { ++ StringDeserializer { ++ value: self, ++ marker: PhantomData, ++ } ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de, E> de::Deserializer<'de> for StringDeserializer ++where ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_string(self.value) ++ } ++ ++ fn deserialize_enum( ++ self, ++ name: &str, ++ variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let _ = name; ++ let _ = variants; ++ visitor.visit_enum(self) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct identifier ignored_any ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de, 'a, E> de::EnumAccess<'de> for StringDeserializer ++where ++ E: de::Error, ++{ ++ type Error = E; ++ type Variant = private::UnitOnly; ++ ++ fn variant_seed(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ seed.deserialize(self).map(private::unit_only) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A deserializer holding a `Cow`. ++#[cfg(any(feature = "std", feature = "alloc"))] ++#[derive(Clone, Debug)] ++pub struct CowStrDeserializer<'a, E> { ++ value: Cow<'a, str>, ++ marker: PhantomData, ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de, 'a, E> IntoDeserializer<'de, E> for Cow<'a, str> ++where ++ E: de::Error, ++{ ++ type Deserializer = CowStrDeserializer<'a, E>; ++ ++ fn into_deserializer(self) -> CowStrDeserializer<'a, E> { ++ CowStrDeserializer { ++ value: self, ++ marker: PhantomData, ++ } ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de, 'a, E> de::Deserializer<'de> for CowStrDeserializer<'a, E> ++where ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ match self.value { ++ Cow::Borrowed(string) => visitor.visit_str(string), ++ Cow::Owned(string) => visitor.visit_string(string), ++ } ++ } ++ ++ fn deserialize_enum( ++ self, ++ name: &str, ++ variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let _ = name; ++ let _ = variants; ++ visitor.visit_enum(self) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct identifier ignored_any ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de, 'a, E> de::EnumAccess<'de> for CowStrDeserializer<'a, E> ++where ++ E: de::Error, ++{ ++ type Error = E; ++ type Variant = private::UnitOnly; ++ ++ fn variant_seed(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ seed.deserialize(self).map(private::unit_only) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A deserializer holding a `&[u8]` with a lifetime tied to another ++/// deserializer. ++#[derive(Clone, Debug)] ++pub struct BorrowedBytesDeserializer<'de, E> { ++ value: &'de [u8], ++ marker: PhantomData, ++} ++ ++impl<'de, E> BorrowedBytesDeserializer<'de, E> { ++ /// Create a new borrowed deserializer from the given byte slice. ++ pub fn new(value: &'de [u8]) -> BorrowedBytesDeserializer<'de, E> { ++ BorrowedBytesDeserializer { ++ value: value, ++ marker: PhantomData, ++ } ++ } ++} ++ ++impl<'de, E> de::Deserializer<'de> for BorrowedBytesDeserializer<'de, E> ++where ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_borrowed_bytes(self.value) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct identifier ignored_any enum ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A deserializer that iterates over a sequence. ++#[derive(Clone, Debug)] ++pub struct SeqDeserializer { ++ iter: iter::Fuse, ++ count: usize, ++ marker: PhantomData, ++} ++ ++impl SeqDeserializer ++where ++ I: Iterator, ++{ ++ /// Construct a new `SeqDeserializer`. ++ pub fn new(iter: I) -> Self { ++ SeqDeserializer { ++ iter: iter.fuse(), ++ count: 0, ++ marker: PhantomData, ++ } ++ } ++} ++ ++impl SeqDeserializer ++where ++ I: Iterator, ++ E: de::Error, ++{ ++ /// Check for remaining elements after passing a `SeqDeserializer` to ++ /// `Visitor::visit_seq`. ++ pub fn end(mut self) -> Result<(), E> { ++ let mut remaining = 0; ++ while self.iter.next().is_some() { ++ remaining += 1; ++ } ++ if remaining == 0 { ++ Ok(()) ++ } else { ++ // First argument is the number of elements in the data, second ++ // argument is the number of elements expected by the Deserialize. ++ Err(de::Error::invalid_length(self.count + remaining, &ExpectedInSeq(self.count)),) ++ } ++ } ++} ++ ++impl<'de, I, T, E> de::Deserializer<'de> for SeqDeserializer ++where ++ I: Iterator, ++ T: IntoDeserializer<'de, E>, ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn deserialize_any(mut self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let v = try!(visitor.visit_seq(&mut self)); ++ try!(self.end()); ++ Ok(v) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct enum identifier ignored_any ++ } ++} ++ ++impl<'de, I, T, E> de::SeqAccess<'de> for SeqDeserializer ++where ++ I: Iterator, ++ T: IntoDeserializer<'de, E>, ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn next_element_seed(&mut self, seed: V) -> Result, Self::Error> ++ where ++ V: de::DeserializeSeed<'de>, ++ { ++ match self.iter.next() { ++ Some(value) => { ++ self.count += 1; ++ seed.deserialize(value.into_deserializer()).map(Some) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ size_hint::from_bounds(&self.iter) ++ } ++} ++ ++struct ExpectedInSeq(usize); ++ ++impl Expected for ExpectedInSeq { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ if self.0 == 1 { ++ write!(formatter, "1 element in sequence") ++ } else { ++ write!(formatter, "{} elements in sequence", self.0) ++ } ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de, T, E> IntoDeserializer<'de, E> for Vec ++where ++ T: IntoDeserializer<'de, E>, ++ E: de::Error, ++{ ++ type Deserializer = SeqDeserializer< as IntoIterator>::IntoIter, E>; ++ ++ fn into_deserializer(self) -> Self::Deserializer { ++ SeqDeserializer::new(self.into_iter()) ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de, T, E> IntoDeserializer<'de, E> for BTreeSet ++where ++ T: IntoDeserializer<'de, E> + Eq + Ord, ++ E: de::Error, ++{ ++ type Deserializer = SeqDeserializer< as IntoIterator>::IntoIter, E>; ++ ++ fn into_deserializer(self) -> Self::Deserializer { ++ SeqDeserializer::new(self.into_iter()) ++ } ++} ++ ++#[cfg(feature = "std")] ++impl<'de, T, E> IntoDeserializer<'de, E> for HashSet ++where ++ T: IntoDeserializer<'de, E> + Eq + Hash, ++ E: de::Error, ++{ ++ type Deserializer = SeqDeserializer< as IntoIterator>::IntoIter, E>; ++ ++ fn into_deserializer(self) -> Self::Deserializer { ++ SeqDeserializer::new(self.into_iter()) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A deserializer holding a `SeqAccess`. ++#[derive(Clone, Debug)] ++pub struct SeqAccessDeserializer { ++ seq: A, ++} ++ ++impl SeqAccessDeserializer { ++ /// Construct a new `SeqAccessDeserializer`. ++ pub fn new(seq: A) -> Self { ++ SeqAccessDeserializer { seq: seq } ++ } ++} ++ ++impl<'de, A> de::Deserializer<'de> for SeqAccessDeserializer ++where ++ A: de::SeqAccess<'de>, ++{ ++ type Error = A::Error; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_seq(self.seq) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct enum identifier ignored_any ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A deserializer that iterates over a map. ++pub struct MapDeserializer<'de, I, E> ++where ++ I: Iterator, ++ I::Item: private::Pair, ++{ ++ iter: iter::Fuse, ++ value: Option>, ++ count: usize, ++ lifetime: PhantomData<&'de ()>, ++ error: PhantomData, ++} ++ ++impl<'de, I, E> MapDeserializer<'de, I, E> ++where ++ I: Iterator, ++ I::Item: private::Pair, ++{ ++ /// Construct a new `MapDeserializer`. ++ pub fn new(iter: I) -> Self { ++ MapDeserializer { ++ iter: iter.fuse(), ++ value: None, ++ count: 0, ++ lifetime: PhantomData, ++ error: PhantomData, ++ } ++ } ++} ++ ++impl<'de, I, E> MapDeserializer<'de, I, E> ++where ++ I: Iterator, ++ I::Item: private::Pair, ++ E: de::Error, ++{ ++ /// Check for remaining elements after passing a `MapDeserializer` to ++ /// `Visitor::visit_map`. ++ pub fn end(mut self) -> Result<(), E> { ++ let mut remaining = 0; ++ while self.iter.next().is_some() { ++ remaining += 1; ++ } ++ if remaining == 0 { ++ Ok(()) ++ } else { ++ // First argument is the number of elements in the data, second ++ // argument is the number of elements expected by the Deserialize. ++ Err(de::Error::invalid_length(self.count + remaining, &ExpectedInMap(self.count)),) ++ } ++ } ++} ++ ++impl<'de, I, E> MapDeserializer<'de, I, E> ++where ++ I: Iterator, ++ I::Item: private::Pair, ++{ ++ fn next_pair(&mut self) -> Option<(First, Second)> { ++ match self.iter.next() { ++ Some(kv) => { ++ self.count += 1; ++ Some(private::Pair::split(kv)) ++ } ++ None => None, ++ } ++ } ++} ++ ++impl<'de, I, E> de::Deserializer<'de> for MapDeserializer<'de, I, E> ++where ++ I: Iterator, ++ I::Item: private::Pair, ++ First: IntoDeserializer<'de, E>, ++ Second: IntoDeserializer<'de, E>, ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn deserialize_any(mut self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let value = try!(visitor.visit_map(&mut self)); ++ try!(self.end()); ++ Ok(value) ++ } ++ ++ fn deserialize_seq(mut self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let value = try!(visitor.visit_seq(&mut self)); ++ try!(self.end()); ++ Ok(value) ++ } ++ ++ fn deserialize_tuple( ++ self, ++ len: usize, ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let _ = len; ++ self.deserialize_seq(visitor) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct tuple_struct map struct ++ enum identifier ignored_any ++ } ++} ++ ++impl<'de, I, E> de::MapAccess<'de> for MapDeserializer<'de, I, E> ++where ++ I: Iterator, ++ I::Item: private::Pair, ++ First: IntoDeserializer<'de, E>, ++ Second: IntoDeserializer<'de, E>, ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn next_key_seed(&mut self, seed: T) -> Result, Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match self.next_pair() { ++ Some((key, value)) => { ++ self.value = Some(value); ++ seed.deserialize(key.into_deserializer()).map(Some) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ fn next_value_seed(&mut self, seed: T) -> Result ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ let value = self.value.take(); ++ // Panic because this indicates a bug in the program rather than an ++ // expected failure. ++ let value = value.expect("MapAccess::visit_value called before visit_key"); ++ seed.deserialize(value.into_deserializer()) ++ } ++ ++ fn next_entry_seed( ++ &mut self, ++ kseed: TK, ++ vseed: TV, ++ ) -> Result, Self::Error> ++ where ++ TK: de::DeserializeSeed<'de>, ++ TV: de::DeserializeSeed<'de>, ++ { ++ match self.next_pair() { ++ Some((key, value)) => { ++ let key = try!(kseed.deserialize(key.into_deserializer())); ++ let value = try!(vseed.deserialize(value.into_deserializer())); ++ Ok(Some((key, value))) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ size_hint::from_bounds(&self.iter) ++ } ++} ++ ++impl<'de, I, E> de::SeqAccess<'de> for MapDeserializer<'de, I, E> ++where ++ I: Iterator, ++ I::Item: private::Pair, ++ First: IntoDeserializer<'de, E>, ++ Second: IntoDeserializer<'de, E>, ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn next_element_seed(&mut self, seed: T) -> Result, Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match self.next_pair() { ++ Some((k, v)) => { ++ let de = PairDeserializer(k, v, PhantomData); ++ seed.deserialize(de).map(Some) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ size_hint::from_bounds(&self.iter) ++ } ++} ++ ++// Cannot #[derive(Clone)] because of the bound `Second: Clone`. ++impl<'de, I, E> Clone for MapDeserializer<'de, I, E> ++where ++ I: Iterator + Clone, ++ I::Item: private::Pair, ++ Second: Clone, ++{ ++ fn clone(&self) -> Self { ++ MapDeserializer { ++ iter: self.iter.clone(), ++ value: self.value.clone(), ++ count: self.count, ++ lifetime: self.lifetime, ++ error: self.error, ++ } ++ } ++} ++ ++// Cannot #[derive(Debug)] because of the bound `Second: Debug`. ++impl<'de, I, E> Debug for MapDeserializer<'de, I, E> ++where ++ I: Iterator + Debug, ++ I::Item: private::Pair, ++ Second: Debug, ++{ ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter ++ .debug_struct("MapDeserializer") ++ .field("iter", &self.iter) ++ .field("value", &self.value) ++ .field("count", &self.count) ++ .field("lifetime", &self.lifetime) ++ .field("error", &self.error) ++ .finish() ++ } ++} ++ ++// Used in the `impl SeqAccess for MapDeserializer` to visit the map as a ++// sequence of pairs. ++struct PairDeserializer(A, B, PhantomData); ++ ++impl<'de, A, B, E> de::Deserializer<'de> for PairDeserializer ++where ++ A: IntoDeserializer<'de, E>, ++ B: IntoDeserializer<'de, E>, ++ E: de::Error, ++{ ++ type Error = E; ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct tuple_struct map struct ++ enum identifier ignored_any ++ } ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ self.deserialize_seq(visitor) ++ } ++ ++ fn deserialize_seq(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let mut pair_visitor = PairVisitor(Some(self.0), Some(self.1), PhantomData); ++ let pair = try!(visitor.visit_seq(&mut pair_visitor)); ++ if pair_visitor.1.is_none() { ++ Ok(pair) ++ } else { ++ let remaining = pair_visitor.size_hint().unwrap(); ++ // First argument is the number of elements in the data, second ++ // argument is the number of elements expected by the Deserialize. ++ Err(de::Error::invalid_length(2, &ExpectedInSeq(2 - remaining))) ++ } ++ } ++ ++ fn deserialize_tuple(self, len: usize, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ if len == 2 { ++ self.deserialize_seq(visitor) ++ } else { ++ // First argument is the number of elements in the data, second ++ // argument is the number of elements expected by the Deserialize. ++ Err(de::Error::invalid_length(2, &ExpectedInSeq(len))) ++ } ++ } ++} ++ ++struct PairVisitor(Option, Option, PhantomData); ++ ++impl<'de, A, B, E> de::SeqAccess<'de> for PairVisitor ++where ++ A: IntoDeserializer<'de, E>, ++ B: IntoDeserializer<'de, E>, ++ E: de::Error, ++{ ++ type Error = E; ++ ++ fn next_element_seed(&mut self, seed: T) -> Result, Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ if let Some(k) = self.0.take() { ++ seed.deserialize(k.into_deserializer()).map(Some) ++ } else if let Some(v) = self.1.take() { ++ seed.deserialize(v.into_deserializer()).map(Some) ++ } else { ++ Ok(None) ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ if self.0.is_some() { ++ Some(2) ++ } else if self.1.is_some() { ++ Some(1) ++ } else { ++ Some(0) ++ } ++ } ++} ++ ++struct ExpectedInMap(usize); ++ ++impl Expected for ExpectedInMap { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ if self.0 == 1 { ++ write!(formatter, "1 element in map") ++ } else { ++ write!(formatter, "{} elements in map", self.0) ++ } ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl<'de, K, V, E> IntoDeserializer<'de, E> for BTreeMap ++where ++ K: IntoDeserializer<'de, E> + Eq + Ord, ++ V: IntoDeserializer<'de, E>, ++ E: de::Error, ++{ ++ type Deserializer = MapDeserializer<'de, as IntoIterator>::IntoIter, E>; ++ ++ fn into_deserializer(self) -> Self::Deserializer { ++ MapDeserializer::new(self.into_iter()) ++ } ++} ++ ++#[cfg(feature = "std")] ++impl<'de, K, V, E> IntoDeserializer<'de, E> for HashMap ++where ++ K: IntoDeserializer<'de, E> + Eq + Hash, ++ V: IntoDeserializer<'de, E>, ++ E: de::Error, ++{ ++ type Deserializer = MapDeserializer<'de, as IntoIterator>::IntoIter, E>; ++ ++ fn into_deserializer(self) -> Self::Deserializer { ++ MapDeserializer::new(self.into_iter()) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A deserializer holding a `MapAccess`. ++#[derive(Clone, Debug)] ++pub struct MapAccessDeserializer { ++ map: A, ++} ++ ++impl MapAccessDeserializer { ++ /// Construct a new `MapAccessDeserializer`. ++ pub fn new(map: A) -> Self { ++ MapAccessDeserializer { map: map } ++ } ++} ++ ++impl<'de, A> de::Deserializer<'de> for MapAccessDeserializer ++where ++ A: de::MapAccess<'de>, ++{ ++ type Error = A::Error; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_map(self.map) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct enum identifier ignored_any ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++mod private { ++ use lib::*; ++ ++ use de::{self, Unexpected}; ++ ++ #[derive(Clone, Debug)] ++ pub struct UnitOnly { ++ marker: PhantomData, ++ } ++ ++ pub fn unit_only(t: T) -> (T, UnitOnly) { ++ (t, UnitOnly { marker: PhantomData }) ++ } ++ ++ impl<'de, E> de::VariantAccess<'de> for UnitOnly ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ fn unit_variant(self) -> Result<(), Self::Error> { ++ Ok(()) ++ } ++ ++ fn newtype_variant_seed(self, _seed: T) -> Result ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ Err(de::Error::invalid_type(Unexpected::UnitVariant, &"newtype variant"),) ++ } ++ ++ fn tuple_variant(self, _len: usize, _visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ Err(de::Error::invalid_type(Unexpected::UnitVariant, &"tuple variant"),) ++ } ++ ++ fn struct_variant( ++ self, ++ _fields: &'static [&'static str], ++ _visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ Err(de::Error::invalid_type(Unexpected::UnitVariant, &"struct variant"),) ++ } ++ } ++ ++ /// Avoid having to restate the generic types on `MapDeserializer`. The ++ /// `Iterator::Item` contains enough information to figure out K and V. ++ pub trait Pair { ++ type First; ++ type Second; ++ fn split(self) -> (Self::First, Self::Second); ++ } ++ ++ impl Pair for (A, B) { ++ type First = A; ++ type Second = B; ++ fn split(self) -> (A, B) { ++ self ++ } ++ } ++ ++ pub type First = ::First; ++ pub type Second = ::Second; ++} diff --cc vendor/serde-1.0.15/src/export.rs index 000000000,000000000..cb416d9f0 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/export.rs @@@ -1,0 -1,0 +1,41 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++pub use lib::clone::Clone; ++pub use lib::convert::{From, Into}; ++pub use lib::default::Default; ++pub use lib::fmt::{self, Formatter}; ++pub use lib::marker::PhantomData; ++pub use lib::option::Option::{self, None, Some}; ++pub use lib::result::Result::{self, Ok, Err}; ++ ++pub use self::string::from_utf8_lossy; ++ ++mod string { ++ use lib::*; ++ ++ #[cfg(any(feature = "std", feature = "alloc"))] ++ pub fn from_utf8_lossy(bytes: &[u8]) -> Cow { ++ String::from_utf8_lossy(bytes) ++ } ++ ++ // The generated code calls this like: ++ // ++ // let value = &_serde::export::from_utf8_lossy(bytes); ++ // Err(_serde::de::Error::unknown_variant(value, VARIANTS)) ++ // ++ // so it is okay for the return type to be different from the std case as long ++ // as the above works. ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ pub fn from_utf8_lossy(bytes: &[u8]) -> &str { ++ // Three unicode replacement characters if it fails. They look like a ++ // white-on-black question mark. The user will recognize it as invalid ++ // UTF-8. ++ str::from_utf8(bytes).unwrap_or("\u{fffd}\u{fffd}\u{fffd}") ++ } ++} diff --cc vendor/serde-1.0.15/src/lib.rs index 000000000,000000000..e5e368e53 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/lib.rs @@@ -1,0 -1,0 +1,286 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! # Serde ++//! ++//! Serde is a framework for ***ser***ializing and ***de***serializing Rust data ++//! structures efficiently and generically. ++//! ++//! The Serde ecosystem consists of data structures that know how to serialize ++//! and deserialize themselves along with data formats that know how to ++//! serialize and deserialize other things. Serde provides the layer by which ++//! these two groups interact with each other, allowing any supported data ++//! structure to be serialized and deserialized using any supported data format. ++//! ++//! See the Serde website [https://serde.rs/] for additional documentation and ++//! usage examples. ++//! ++//! [https://serde.rs/]: https://serde.rs/ ++//! ++//! ## Design ++//! ++//! Where many other languages rely on runtime reflection for serializing data, ++//! Serde is instead built on Rust's powerful trait system. A data structure ++//! that knows how to serialize and deserialize itself is one that implements ++//! Serde's `Serialize` and `Deserialize` traits (or uses Serde's derive ++//! attribute to automatically generate implementations at compile time). This ++//! avoids any overhead of reflection or runtime type information. In fact in ++//! many situations the interaction between data structure and data format can ++//! be completely optimized away by the Rust compiler, leaving Serde ++//! serialization to perform the same speed as a handwritten serializer for the ++//! specific selection of data structure and data format. ++//! ++//! ## Data formats ++//! ++//! The following is a partial list of data formats that have been implemented ++//! for Serde by the community. ++//! ++//! - [JSON], the ubiquitous JavaScript Object Notation used by many HTTP APIs. ++//! - [Bincode], a compact binary format ++//! used for IPC within the Servo rendering engine. ++//! - [CBOR], a Concise Binary Object Representation designed for small message ++//! size without the need for version negotiation. ++//! - [YAML], a popular human-friendly configuration language that ain't markup ++//! language. ++//! - [MessagePack], an efficient binary format that resembles a compact JSON. ++//! - [TOML], a minimal configuration format used by [Cargo]. ++//! - [Pickle], a format common in the Python world. ++//! - [Hjson], a variant of JSON designed to be readable and writable by humans. ++//! - [BSON], the data storage and network transfer format used by MongoDB. ++//! - [URL], the x-www-form-urlencoded format. ++//! - [XML], the flexible machine-friendly W3C standard. ++//! *(deserialization only)* ++//! - [Envy], a way to deserialize environment variables into Rust structs. ++//! *(deserialization only)* ++//! - [Redis], deserialize values from Redis when using [redis-rs]. ++//! *(deserialization only)* ++//! ++//! [JSON]: https://github.com/serde-rs/json ++//! [Bincode]: https://github.com/TyOverby/bincode ++//! [CBOR]: https://github.com/pyfisch/cbor ++//! [YAML]: https://github.com/dtolnay/serde-yaml ++//! [MessagePack]: https://github.com/3Hren/msgpack-rust ++//! [TOML]: https://github.com/alexcrichton/toml-rs ++//! [Pickle]: https://github.com/birkenfeld/serde-pickle ++//! [Hjson]: https://github.com/laktak/hjson-rust ++//! [BSON]: https://github.com/zonyitoo/bson-rs ++//! [URL]: https://github.com/nox/serde_urlencoded ++//! [XML]: https://github.com/RReverser/serde-xml-rs ++//! [Envy]: https://github.com/softprops/envy ++//! [Redis]: https://github.com/OneSignal/serde-redis ++//! [Cargo]: http://doc.crates.io/manifest.html ++//! [redis-rs]: https://crates.io/crates/redis ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++// Serde types in rustdoc of other crates get linked to here. ++#![doc(html_root_url = "https://docs.rs/serde/1.0.15")] ++ ++// Support using Serde without the standard library! ++#![cfg_attr(not(feature = "std"), no_std)] ++ ++// Unstable functionality only if the user asks for it. For tracking and ++// discussion of these features please refer to this issue: ++// ++// https://github.com/serde-rs/serde/issues/812 ++#![cfg_attr(feature = "unstable", feature(nonzero, specialization))] ++#![cfg_attr(feature = "alloc", feature(alloc))] ++ ++#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))] ++// Whitelisted clippy lints ++#![cfg_attr(feature = "cargo-clippy", allow( ++ cast_lossless, ++ doc_markdown, ++ linkedlist, ++ type_complexity, ++ unreadable_literal, ++ zero_prefixed_literal, ++))] ++// Whitelisted clippy_pedantic lints ++#![cfg_attr(feature = "cargo-clippy", allow( ++// integer and float ser/de requires these sorts of casts ++ cast_possible_truncation, ++ cast_possible_wrap, ++ cast_precision_loss, ++ cast_sign_loss, ++// simplifies some macros ++ invalid_upcast_comparisons, ++// things are often more readable this way ++ option_unwrap_used, ++ result_unwrap_used, ++ shadow_reuse, ++ single_match_else, ++ stutter, ++ use_self, ++// not practical ++ missing_docs_in_private_items, ++// alternative is not stable ++ empty_enum, ++ use_debug, ++))] ++ ++// Blacklisted Rust lints. ++#![deny(missing_docs, unused_imports)] ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "alloc")] ++extern crate alloc; ++ ++#[cfg(all(feature = "unstable", feature = "std"))] ++extern crate core; ++ ++/// A facade around all the types we need from the `std`, `core`, and `alloc` ++/// crates. This avoids elaborate import wrangling having to happen in every ++/// module. ++mod lib { ++ mod core { ++ #[cfg(feature = "std")] ++ pub use std::*; ++ #[cfg(not(feature = "std"))] ++ pub use core::*; ++ } ++ ++ pub use self::core::{cmp, iter, mem, ops, slice, str}; ++ pub use self::core::{i8, i16, i32, i64, isize}; ++ pub use self::core::{u8, u16, u32, u64, usize}; ++ pub use self::core::{f32, f64}; ++ ++ pub use self::core::cell::{Cell, RefCell}; ++ pub use self::core::clone::{self, Clone}; ++ pub use self::core::convert::{self, From, Into}; ++ pub use self::core::default::{self, Default}; ++ pub use self::core::fmt::{self, Debug, Display}; ++ pub use self::core::marker::{self, PhantomData}; ++ pub use self::core::option::{self, Option}; ++ pub use self::core::result::{self, Result}; ++ ++ #[cfg(feature = "std")] ++ pub use std::borrow::{Cow, ToOwned}; ++ #[cfg(all(feature = "alloc", not(feature = "std")))] ++ pub use alloc::borrow::{Cow, ToOwned}; ++ ++ #[cfg(feature = "std")] ++ pub use std::string::String; ++ #[cfg(all(feature = "alloc", not(feature = "std")))] ++ pub use alloc::string::{String, ToString}; ++ ++ #[cfg(feature = "std")] ++ pub use std::vec::Vec; ++ #[cfg(all(feature = "alloc", not(feature = "std")))] ++ pub use alloc::vec::Vec; ++ ++ #[cfg(feature = "std")] ++ pub use std::boxed::Box; ++ #[cfg(all(feature = "alloc", not(feature = "std")))] ++ pub use alloc::boxed::Box; ++ ++ #[cfg(all(feature = "rc", feature = "std"))] ++ pub use std::rc::Rc; ++ #[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))] ++ pub use alloc::rc::Rc; ++ ++ #[cfg(all(feature = "rc", feature = "std"))] ++ pub use std::sync::Arc; ++ #[cfg(all(feature = "rc", feature = "alloc", not(feature = "std")))] ++ pub use alloc::arc::Arc; ++ ++ #[cfg(feature = "std")] ++ pub use std::collections::{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque}; ++ #[cfg(all(feature = "alloc", not(feature = "std")))] ++ pub use alloc::{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque}; ++ ++ #[cfg(feature = "std")] ++ pub use std::{error, net}; ++ ++ #[cfg(feature = "std")] ++ pub use std::collections::{HashMap, HashSet}; ++ #[cfg(feature = "std")] ++ pub use std::ffi::{CString, CStr, OsString, OsStr}; ++ #[cfg(feature = "std")] ++ pub use std::hash::{Hash, BuildHasher}; ++ #[cfg(feature = "std")] ++ pub use std::io::Write; ++ #[cfg(feature = "std")] ++ pub use std::path::{Path, PathBuf}; ++ #[cfg(feature = "std")] ++ pub use std::time::{Duration, SystemTime, UNIX_EPOCH}; ++ #[cfg(feature = "std")] ++ pub use std::sync::{Mutex, RwLock}; ++ ++ #[cfg(feature = "unstable")] ++ pub use core::nonzero::{NonZero, Zeroable}; ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[macro_use] ++mod macros; ++ ++pub mod ser; ++pub mod de; ++ ++#[doc(inline)] ++pub use ser::{Serialize, Serializer}; ++#[doc(inline)] ++pub use de::{Deserialize, Deserializer}; ++ ++// Generated code uses these to support no_std. Not public API. ++#[doc(hidden)] ++pub mod export; ++ ++// Helpers used by generated code and doc tests. Not public API. ++#[doc(hidden)] ++pub mod private; ++ ++// Re-export #[derive(Serialize, Deserialize)]. ++// ++// This is a workaround for https://github.com/rust-lang/cargo/issues/1286. ++// Without this re-export, crates that put Serde derives behind a cfg_attr would ++// need to use some silly feature name that depends on both serde and ++// serde_derive. ++// ++// [features] ++// serde-impls = ["serde", "serde_derive"] ++// ++// [dependencies] ++// serde = { version = "1.0", optional = true } ++// serde_derive = { version = "1.0", optional = true } ++// ++// # Used like this: ++// # #[cfg(feature = "serde-impls")] ++// # #[macro_use] ++// # extern crate serde_derive; ++// # ++// # #[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] ++// # struct S { /* ... */ } ++// ++// The re-exported derives allow crates to use "serde" as the name of their ++// Serde feature which is more intuitive. ++// ++// [dependencies] ++// serde = { version = "1.0", optional = true, features = ["derive"] } ++// ++// # Used like this: ++// # #[cfg(feature = "serde")] ++// # #[macro_use] ++// # extern crate serde; ++// # ++// # #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] ++// # struct S { /* ... */ } ++// ++// The reason re-exporting is not enabled by default is that disabling it would ++// be annoying for crates that provide handwritten impls or data formats. They ++// would need to disable default features and then explicitly re-enable std. ++#[cfg(feature = "serde_derive")] ++#[allow(unused_imports)] ++#[macro_use] ++extern crate serde_derive; ++#[cfg(feature = "serde_derive")] ++#[doc(hidden)] ++pub use serde_derive::*; diff --cc vendor/serde-1.0.15/src/macros.rs index 000000000,000000000..2a3d08724 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/macros.rs @@@ -1,0 -1,0 +1,242 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++// Super explicit first paragraph because this shows up at the top level and ++// trips up people who are just looking for basic Serialize / Deserialize ++// documentation. ++// ++/// Helper macro when implementing the `Deserializer` part of a new data format ++/// for Serde. ++/// ++/// Some [`Deserializer`] implementations for self-describing formats do not ++/// care what hint the [`Visitor`] gives them, they just want to blindly call ++/// the [`Visitor`] method corresponding to the data they can tell is in the ++/// input. This requires repetitive implementations of all the [`Deserializer`] ++/// trait methods. ++/// ++/// ```rust ++/// # #[macro_use] ++/// # extern crate serde; ++/// # ++/// # use serde::de::{value, Deserializer, Visitor}; ++/// # ++/// # struct MyDeserializer; ++/// # ++/// # impl<'de> Deserializer<'de> for MyDeserializer { ++/// # type Error = value::Error; ++/// # ++/// # fn deserialize_any(self, _: V) -> Result ++/// # where V: Visitor<'de> ++/// # { ++/// # unimplemented!() ++/// # } ++/// # ++/// #[inline] ++/// fn deserialize_bool(self, visitor: V) -> Result ++/// where V: Visitor<'de> ++/// { ++/// self.deserialize_any(visitor) ++/// } ++/// # ++/// # forward_to_deserialize_any! { ++/// # i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++/// # byte_buf option unit unit_struct newtype_struct seq tuple ++/// # tuple_struct map struct enum identifier ignored_any ++/// # } ++/// # } ++/// # ++/// # fn main() {} ++/// ``` ++/// ++/// The `forward_to_deserialize_any!` macro implements these simple forwarding ++/// methods so that they forward directly to [`Deserializer::deserialize_any`]. ++/// You can choose which methods to forward. ++/// ++/// ```rust ++/// # #[macro_use] ++/// # extern crate serde; ++/// # ++/// # use serde::de::{value, Deserializer, Visitor}; ++/// # ++/// # struct MyDeserializer; ++/// # ++/// impl<'de> Deserializer<'de> for MyDeserializer { ++/// # type Error = value::Error; ++/// # ++/// fn deserialize_any(self, visitor: V) -> Result ++/// where V: Visitor<'de> ++/// { ++/// /* ... */ ++/// # let _ = visitor; ++/// # unimplemented!() ++/// } ++/// ++/// forward_to_deserialize_any! { ++/// bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++/// byte_buf option unit unit_struct newtype_struct seq tuple ++/// tuple_struct map struct enum identifier ignored_any ++/// } ++/// } ++/// # ++/// # fn main() {} ++/// ``` ++/// ++/// The macro assumes the convention that your `Deserializer` lifetime parameter ++/// is called `'de` and that the `Visitor` type parameters on each method are ++/// called `V`. A different type parameter and a different lifetime can be ++/// specified explicitly if necessary. ++/// ++/// ```rust ++/// # #[macro_use] ++/// # extern crate serde; ++/// # ++/// # use std::marker::PhantomData; ++/// # ++/// # use serde::de::{value, Deserializer, Visitor}; ++/// # ++/// # struct MyDeserializer(PhantomData); ++/// # ++/// # impl<'q, V> Deserializer<'q> for MyDeserializer { ++/// # type Error = value::Error; ++/// # ++/// # fn deserialize_any(self, visitor: W) -> Result ++/// # where W: Visitor<'q> ++/// # { ++/// # unimplemented!() ++/// # } ++/// # ++/// forward_to_deserialize_any! { ++/// > ++/// bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++/// byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++/// map struct enum identifier ignored_any ++/// } ++/// # } ++/// # ++/// # fn main() {} ++/// ``` ++/// ++/// [`Deserializer`]: trait.Deserializer.html ++/// [`Visitor`]: de/trait.Visitor.html ++/// [`Deserializer::deserialize_any`]: trait.Deserializer.html#tymethod.deserialize_any ++#[macro_export] ++macro_rules! forward_to_deserialize_any { ++ (<$visitor:ident: Visitor<$lifetime:tt>> $($func:ident)*) => { ++ $(forward_to_deserialize_any_helper!{$func<$lifetime, $visitor>})* ++ }; ++ // This case must be after the previous one. ++ ($($func:ident)*) => { ++ $(forward_to_deserialize_any_helper!{$func<'de, V>})* ++ }; ++} ++ ++#[doc(hidden)] ++#[macro_export] ++macro_rules! forward_to_deserialize_any_method { ++ ($func:ident<$l:tt, $v:ident>($($arg:ident : $ty:ty),*)) => { ++ #[inline] ++ fn $func<$v>(self, $($arg: $ty,)* visitor: $v) -> $crate::export::Result<$v::Value, Self::Error> ++ where ++ $v: $crate::de::Visitor<$l>, ++ { ++ $( ++ let _ = $arg; ++ )* ++ self.deserialize_any(visitor) ++ } ++ }; ++} ++ ++#[doc(hidden)] ++#[macro_export] ++macro_rules! forward_to_deserialize_any_helper { ++ (bool<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_bool<$l, $v>()} ++ }; ++ (i8<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_i8<$l, $v>()} ++ }; ++ (i16<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_i16<$l, $v>()} ++ }; ++ (i32<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_i32<$l, $v>()} ++ }; ++ (i64<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_i64<$l, $v>()} ++ }; ++ (u8<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_u8<$l, $v>()} ++ }; ++ (u16<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_u16<$l, $v>()} ++ }; ++ (u32<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_u32<$l, $v>()} ++ }; ++ (u64<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_u64<$l, $v>()} ++ }; ++ (f32<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_f32<$l, $v>()} ++ }; ++ (f64<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_f64<$l, $v>()} ++ }; ++ (char<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_char<$l, $v>()} ++ }; ++ (str<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_str<$l, $v>()} ++ }; ++ (string<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_string<$l, $v>()} ++ }; ++ (bytes<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_bytes<$l, $v>()} ++ }; ++ (byte_buf<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_byte_buf<$l, $v>()} ++ }; ++ (option<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_option<$l, $v>()} ++ }; ++ (unit<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_unit<$l, $v>()} ++ }; ++ (unit_struct<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_unit_struct<$l, $v>(name: &'static str)} ++ }; ++ (newtype_struct<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_newtype_struct<$l, $v>(name: &'static str)} ++ }; ++ (seq<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_seq<$l, $v>()} ++ }; ++ (tuple<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_tuple<$l, $v>(len: usize)} ++ }; ++ (tuple_struct<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_tuple_struct<$l, $v>(name: &'static str, len: usize)} ++ }; ++ (map<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_map<$l, $v>()} ++ }; ++ (struct<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_struct<$l, $v>(name: &'static str, fields: &'static [&'static str])} ++ }; ++ (enum<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_enum<$l, $v>(name: &'static str, variants: &'static [&'static str])} ++ }; ++ (identifier<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_identifier<$l, $v>()} ++ }; ++ (ignored_any<$l:tt, $v:ident>) => { ++ forward_to_deserialize_any_method!{deserialize_ignored_any<$l, $v>()} ++ }; ++} diff --cc vendor/serde-1.0.15/src/private/de.rs index 000000000,000000000..3d8a2ec38 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/private/de.rs @@@ -1,0 -1,0 +1,1976 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use lib::*; ++ ++use de::{Deserialize, Deserializer, IntoDeserializer, Error, Visitor}; ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++use de::Unexpected; ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++pub use self::content::{Content, ContentRefDeserializer, ContentDeserializer, ++ TaggedContentVisitor, TagOrContentField, TagOrContentFieldVisitor, ++ TagContentOtherField, TagContentOtherFieldVisitor, ++ InternallyTaggedUnitVisitor, UntaggedUnitVisitor}; ++ ++/// If the missing field is of type `Option` then treat is as `None`, ++/// otherwise it is an error. ++pub fn missing_field<'de, V, E>(field: &'static str) -> Result ++where ++ V: Deserialize<'de>, ++ E: Error, ++{ ++ struct MissingFieldDeserializer(&'static str, PhantomData); ++ ++ impl<'de, E> Deserializer<'de> for MissingFieldDeserializer ++ where ++ E: Error, ++ { ++ type Error = E; ++ ++ fn deserialize_any(self, _visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ Err(Error::missing_field(self.0)) ++ } ++ ++ fn deserialize_option(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ visitor.visit_none() ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf unit unit_struct newtype_struct seq tuple tuple_struct map ++ struct enum identifier ignored_any ++ } ++ } ++ ++ let deserializer = MissingFieldDeserializer(field, PhantomData); ++ Deserialize::deserialize(deserializer) ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++pub fn borrow_cow_str<'de: 'a, 'a, D>(deserializer: D) -> Result, D::Error> ++where ++ D: Deserializer<'de>, ++{ ++ struct CowStrVisitor; ++ ++ impl<'a> Visitor<'a> for CowStrVisitor { ++ type Value = Cow<'a, str>; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a string") ++ } ++ ++ fn visit_str(self, v: &str) -> Result ++ where ++ E: Error, ++ { ++ Ok(Cow::Owned(v.to_owned())) ++ } ++ ++ fn visit_borrowed_str(self, v: &'a str) -> Result ++ where ++ E: Error, ++ { ++ Ok(Cow::Borrowed(v)) ++ } ++ ++ fn visit_string(self, v: String) -> Result ++ where ++ E: Error, ++ { ++ Ok(Cow::Owned(v)) ++ } ++ ++ fn visit_bytes(self, v: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ match str::from_utf8(v) { ++ Ok(s) => Ok(Cow::Owned(s.to_owned())), ++ Err(_) => Err(Error::invalid_value(Unexpected::Bytes(v), &self)), ++ } ++ } ++ ++ fn visit_borrowed_bytes(self, v: &'a [u8]) -> Result ++ where ++ E: Error, ++ { ++ match str::from_utf8(v) { ++ Ok(s) => Ok(Cow::Borrowed(s)), ++ Err(_) => Err(Error::invalid_value(Unexpected::Bytes(v), &self)), ++ } ++ } ++ ++ fn visit_byte_buf(self, v: Vec) -> Result ++ where ++ E: Error, ++ { ++ match String::from_utf8(v) { ++ Ok(s) => Ok(Cow::Owned(s)), ++ Err(e) => Err(Error::invalid_value(Unexpected::Bytes(&e.into_bytes()), &self),), ++ } ++ } ++ } ++ ++ deserializer.deserialize_str(CowStrVisitor) ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++pub fn borrow_cow_bytes<'de: 'a, 'a, D>(deserializer: D) -> Result, D::Error> ++where ++ D: Deserializer<'de>, ++{ ++ struct CowBytesVisitor; ++ ++ impl<'a> Visitor<'a> for CowBytesVisitor { ++ type Value = Cow<'a, [u8]>; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a byte array") ++ } ++ ++ fn visit_str(self, v: &str) -> Result ++ where ++ E: Error, ++ { ++ Ok(Cow::Owned(v.as_bytes().to_vec())) ++ } ++ ++ fn visit_borrowed_str(self, v: &'a str) -> Result ++ where ++ E: Error, ++ { ++ Ok(Cow::Borrowed(v.as_bytes())) ++ } ++ ++ fn visit_string(self, v: String) -> Result ++ where ++ E: Error, ++ { ++ Ok(Cow::Owned(v.into_bytes())) ++ } ++ ++ fn visit_bytes(self, v: &[u8]) -> Result ++ where ++ E: Error, ++ { ++ Ok(Cow::Owned(v.to_vec())) ++ } ++ ++ fn visit_borrowed_bytes(self, v: &'a [u8]) -> Result ++ where ++ E: Error, ++ { ++ Ok(Cow::Borrowed(v)) ++ } ++ ++ fn visit_byte_buf(self, v: Vec) -> Result ++ where ++ E: Error, ++ { ++ Ok(Cow::Owned(v)) ++ } ++ } ++ ++ deserializer.deserialize_str(CowBytesVisitor) ++} ++ ++pub mod size_hint { ++ use lib::*; ++ ++ pub fn from_bounds(iter: &I) -> Option ++ where ++ I: Iterator, ++ { ++ helper(iter.size_hint()) ++ } ++ ++ pub fn cautious(hint: Option) -> usize { ++ cmp::min(hint.unwrap_or(0), 4096) ++ } ++ ++ fn helper(bounds: (usize, Option)) -> Option { ++ match bounds { ++ (lower, Some(upper)) if lower == upper => Some(upper), ++ _ => None, ++ } ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++mod content { ++ // This module is private and nothing here should be used outside of ++ // generated code. ++ // ++ // We will iterate on the implementation for a few releases and only have to ++ // worry about backward compatibility for the `untagged` and `tag` attributes ++ // rather than for this entire mechanism. ++ // ++ // This issue is tracking making some of this stuff public: ++ // https://github.com/serde-rs/serde/issues/741 ++ ++ use lib::*; ++ ++ use de::{self, Deserialize, DeserializeSeed, Deserializer, Visitor, SeqAccess, MapAccess, ++ EnumAccess, Unexpected}; ++ use super::size_hint; ++ ++ /// Used from generated code to buffer the contents of the Deserializer when ++ /// deserializing untagged enums and internally tagged enums. ++ /// ++ /// Not public API. Use serde-value instead. ++ #[derive(Debug)] ++ pub enum Content<'de> { ++ Bool(bool), ++ ++ U8(u8), ++ U16(u16), ++ U32(u32), ++ U64(u64), ++ ++ I8(i8), ++ I16(i16), ++ I32(i32), ++ I64(i64), ++ ++ F32(f32), ++ F64(f64), ++ ++ Char(char), ++ String(String), ++ Str(&'de str), ++ ByteBuf(Vec), ++ Bytes(&'de [u8]), ++ ++ None, ++ Some(Box>), ++ ++ Unit, ++ Newtype(Box>), ++ Seq(Vec>), ++ Map(Vec<(Content<'de>, Content<'de>)>), ++ } ++ ++ impl<'de> Content<'de> { ++ fn unexpected(&self) -> Unexpected { ++ match *self { ++ Content::Bool(b) => Unexpected::Bool(b), ++ Content::U8(n) => Unexpected::Unsigned(n as u64), ++ Content::U16(n) => Unexpected::Unsigned(n as u64), ++ Content::U32(n) => Unexpected::Unsigned(n as u64), ++ Content::U64(n) => Unexpected::Unsigned(n), ++ Content::I8(n) => Unexpected::Signed(n as i64), ++ Content::I16(n) => Unexpected::Signed(n as i64), ++ Content::I32(n) => Unexpected::Signed(n as i64), ++ Content::I64(n) => Unexpected::Signed(n), ++ Content::F32(f) => Unexpected::Float(f as f64), ++ Content::F64(f) => Unexpected::Float(f), ++ Content::Char(c) => Unexpected::Char(c), ++ Content::String(ref s) => Unexpected::Str(s), ++ Content::Str(s) => Unexpected::Str(s), ++ Content::ByteBuf(ref b) => Unexpected::Bytes(b), ++ Content::Bytes(b) => Unexpected::Bytes(b), ++ Content::None | Content::Some(_) => Unexpected::Option, ++ Content::Unit => Unexpected::Unit, ++ Content::Newtype(_) => Unexpected::NewtypeStruct, ++ Content::Seq(_) => Unexpected::Seq, ++ Content::Map(_) => Unexpected::Map, ++ } ++ } ++ } ++ ++ impl<'de> Deserialize<'de> for Content<'de> { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ // Untagged and internally tagged enums are only supported in ++ // self-describing formats. ++ let visitor = ContentVisitor { value: PhantomData }; ++ deserializer.deserialize_any(visitor) ++ } ++ } ++ ++ struct ContentVisitor<'de> { ++ value: PhantomData>, ++ } ++ ++ impl<'de> ContentVisitor<'de> { ++ fn new() -> Self { ++ ContentVisitor { value: PhantomData } ++ } ++ } ++ ++ impl<'de> Visitor<'de> for ContentVisitor<'de> { ++ type Value = Content<'de>; ++ ++ fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ fmt.write_str("any value") ++ } ++ ++ fn visit_bool(self, value: bool) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::Bool(value)) ++ } ++ ++ fn visit_i8(self, value: i8) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::I8(value)) ++ } ++ ++ fn visit_i16(self, value: i16) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::I16(value)) ++ } ++ ++ fn visit_i32(self, value: i32) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::I32(value)) ++ } ++ ++ fn visit_i64(self, value: i64) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::I64(value)) ++ } ++ ++ fn visit_u8(self, value: u8) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::U8(value)) ++ } ++ ++ fn visit_u16(self, value: u16) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::U16(value)) ++ } ++ ++ fn visit_u32(self, value: u32) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::U32(value)) ++ } ++ ++ fn visit_u64(self, value: u64) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::U64(value)) ++ } ++ ++ fn visit_f32(self, value: f32) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::F32(value)) ++ } ++ ++ fn visit_f64(self, value: f64) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::F64(value)) ++ } ++ ++ fn visit_char(self, value: char) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::Char(value)) ++ } ++ ++ fn visit_str(self, value: &str) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::String(value.into())) ++ } ++ ++ fn visit_borrowed_str(self, value: &'de str) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::Str(value)) ++ } ++ ++ fn visit_string(self, value: String) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::String(value)) ++ } ++ ++ fn visit_bytes(self, value: &[u8]) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::ByteBuf(value.into())) ++ } ++ ++ fn visit_borrowed_bytes(self, value: &'de [u8]) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::Bytes(value)) ++ } ++ ++ fn visit_byte_buf(self, value: Vec) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::ByteBuf(value)) ++ } ++ ++ fn visit_unit(self) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::Unit) ++ } ++ ++ fn visit_none(self) -> Result ++ where ++ F: de::Error, ++ { ++ Ok(Content::None) ++ } ++ ++ fn visit_some(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ Deserialize::deserialize(deserializer).map(|v| Content::Some(Box::new(v))) ++ } ++ ++ fn visit_newtype_struct(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ Deserialize::deserialize(deserializer).map(|v| Content::Newtype(Box::new(v))) ++ } ++ ++ fn visit_seq(self, mut visitor: V) -> Result ++ where ++ V: SeqAccess<'de>, ++ { ++ let mut vec = Vec::with_capacity(size_hint::cautious(visitor.size_hint())); ++ while let Some(e) = try!(visitor.next_element()) { ++ vec.push(e); ++ } ++ Ok(Content::Seq(vec)) ++ } ++ ++ fn visit_map(self, mut visitor: V) -> Result ++ where ++ V: MapAccess<'de>, ++ { ++ let mut vec = Vec::with_capacity(size_hint::cautious(visitor.size_hint())); ++ while let Some(kv) = try!(visitor.next_entry()) { ++ vec.push(kv); ++ } ++ Ok(Content::Map(vec)) ++ } ++ ++ fn visit_enum(self, _visitor: V) -> Result ++ where ++ V: EnumAccess<'de>, ++ { ++ Err(de::Error::custom("untagged and internally tagged enums do not support enum input",),) ++ } ++ } ++ ++ /// This is the type of the map keys in an internally tagged enum. ++ /// ++ /// Not public API. ++ pub enum TagOrContent<'de> { ++ Tag, ++ Content(Content<'de>), ++ } ++ ++ struct TagOrContentVisitor<'de> { ++ name: &'static str, ++ value: PhantomData>, ++ } ++ ++ impl<'de> TagOrContentVisitor<'de> { ++ fn new(name: &'static str) -> Self { ++ TagOrContentVisitor { name: name, value: PhantomData } ++ } ++ } ++ ++ impl<'de> DeserializeSeed<'de> for TagOrContentVisitor<'de> { ++ type Value = TagOrContent<'de>; ++ ++ fn deserialize(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ // Internally tagged enums are only supported in self-describing ++ // formats. ++ deserializer.deserialize_any(self) ++ } ++ } ++ ++ impl<'de> Visitor<'de> for TagOrContentVisitor<'de> { ++ type Value = TagOrContent<'de>; ++ ++ fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ write!(fmt, "a type tag `{}` or any other value", self.name) ++ } ++ ++ fn visit_bool(self, value: bool) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new() ++ .visit_bool(value) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_i8(self, value: i8) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new().visit_i8(value).map(TagOrContent::Content) ++ } ++ ++ fn visit_i16(self, value: i16) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new() ++ .visit_i16(value) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_i32(self, value: i32) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new() ++ .visit_i32(value) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_i64(self, value: i64) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new() ++ .visit_i64(value) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_u8(self, value: u8) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new().visit_u8(value).map(TagOrContent::Content) ++ } ++ ++ fn visit_u16(self, value: u16) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new() ++ .visit_u16(value) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_u32(self, value: u32) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new() ++ .visit_u32(value) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_u64(self, value: u64) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new() ++ .visit_u64(value) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_f32(self, value: f32) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new() ++ .visit_f32(value) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_f64(self, value: f64) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new() ++ .visit_f64(value) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_char(self, value: char) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new() ++ .visit_char(value) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_str(self, value: &str) -> Result ++ where ++ F: de::Error, ++ { ++ if value == self.name { ++ Ok(TagOrContent::Tag) ++ } else { ++ ContentVisitor::new() ++ .visit_str(value) ++ .map(TagOrContent::Content) ++ } ++ } ++ ++ fn visit_borrowed_str(self, value: &'de str) -> Result ++ where ++ F: de::Error, ++ { ++ if value == self.name { ++ Ok(TagOrContent::Tag) ++ } else { ++ ContentVisitor::new() ++ .visit_borrowed_str(value) ++ .map(TagOrContent::Content) ++ } ++ } ++ ++ fn visit_string(self, value: String) -> Result ++ where ++ F: de::Error, ++ { ++ if value == self.name { ++ Ok(TagOrContent::Tag) ++ } else { ++ ContentVisitor::new() ++ .visit_string(value) ++ .map(TagOrContent::Content) ++ } ++ } ++ ++ fn visit_bytes(self, value: &[u8]) -> Result ++ where ++ F: de::Error, ++ { ++ if value == self.name.as_bytes() { ++ Ok(TagOrContent::Tag) ++ } else { ++ ContentVisitor::new() ++ .visit_bytes(value) ++ .map(TagOrContent::Content) ++ } ++ } ++ ++ fn visit_borrowed_bytes(self, value: &'de [u8]) -> Result ++ where ++ F: de::Error, ++ { ++ if value == self.name.as_bytes() { ++ Ok(TagOrContent::Tag) ++ } else { ++ ContentVisitor::new() ++ .visit_borrowed_bytes(value) ++ .map(TagOrContent::Content) ++ } ++ } ++ ++ fn visit_byte_buf(self, value: Vec) -> Result ++ where ++ F: de::Error, ++ { ++ if value == self.name.as_bytes() { ++ Ok(TagOrContent::Tag) ++ } else { ++ ContentVisitor::new() ++ .visit_byte_buf(value) ++ .map(TagOrContent::Content) ++ } ++ } ++ ++ fn visit_unit(self) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new().visit_unit().map(TagOrContent::Content) ++ } ++ ++ fn visit_none(self) -> Result ++ where ++ F: de::Error, ++ { ++ ContentVisitor::new().visit_none().map(TagOrContent::Content) ++ } ++ ++ fn visit_some(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ ContentVisitor::new() ++ .visit_some(deserializer) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_newtype_struct(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ ContentVisitor::new() ++ .visit_newtype_struct(deserializer) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_seq(self, visitor: V) -> Result ++ where ++ V: SeqAccess<'de>, ++ { ++ ContentVisitor::new() ++ .visit_seq(visitor) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_map(self, visitor: V) -> Result ++ where ++ V: MapAccess<'de>, ++ { ++ ContentVisitor::new() ++ .visit_map(visitor) ++ .map(TagOrContent::Content) ++ } ++ ++ fn visit_enum(self, visitor: V) -> Result ++ where ++ V: EnumAccess<'de>, ++ { ++ ContentVisitor::new() ++ .visit_enum(visitor) ++ .map(TagOrContent::Content) ++ } ++ } ++ ++ /// Used by generated code to deserialize an internally tagged enum. ++ /// ++ /// Not public API. ++ pub struct TaggedContent<'de, T> { ++ pub tag: T, ++ pub content: Content<'de>, ++ } ++ ++ /// Not public API. ++ pub struct TaggedContentVisitor<'de, T> { ++ tag_name: &'static str, ++ value: PhantomData>, ++ } ++ ++ impl<'de, T> TaggedContentVisitor<'de, T> { ++ /// Visitor for the content of an internally tagged enum with the given tag ++ /// name. ++ pub fn new(name: &'static str) -> Self { ++ TaggedContentVisitor { ++ tag_name: name, ++ value: PhantomData, ++ } ++ } ++ } ++ ++ impl<'de, T> DeserializeSeed<'de> for TaggedContentVisitor<'de, T> ++ where ++ T: Deserialize<'de>, ++ { ++ type Value = TaggedContent<'de, T>; ++ ++ fn deserialize(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ // Internally tagged enums are only supported in self-describing ++ // formats. ++ deserializer.deserialize_any(self) ++ } ++ } ++ ++ impl<'de, T> Visitor<'de> for TaggedContentVisitor<'de, T> ++ where ++ T: Deserialize<'de>, ++ { ++ type Value = TaggedContent<'de, T>; ++ ++ fn expecting(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ fmt.write_str("internally tagged enum") ++ } ++ ++ fn visit_seq(self, mut seq: S) -> Result ++ where ++ S: SeqAccess<'de>, ++ { ++ let tag = match try!(seq.next_element()) { ++ Some(tag) => tag, ++ None => { ++ return Err(de::Error::missing_field(self.tag_name)); ++ } ++ }; ++ let rest = de::value::SeqAccessDeserializer::new(seq); ++ Ok(TaggedContent { ++ tag: tag, ++ content: try!(Content::deserialize(rest)), ++ }) ++ } ++ ++ fn visit_map(self, mut map: M) -> Result ++ where ++ M: MapAccess<'de>, ++ { ++ let mut tag = None; ++ let mut vec = Vec::with_capacity(size_hint::cautious(map.size_hint())); ++ while let Some(k) = ++ try!(map.next_key_seed(TagOrContentVisitor::new(self.tag_name))) { ++ match k { ++ TagOrContent::Tag => { ++ if tag.is_some() { ++ return Err(de::Error::duplicate_field(self.tag_name)); ++ } ++ tag = Some(try!(map.next_value())); ++ } ++ TagOrContent::Content(k) => { ++ let v = try!(map.next_value()); ++ vec.push((k, v)); ++ } ++ } ++ } ++ match tag { ++ None => Err(de::Error::missing_field(self.tag_name)), ++ Some(tag) => { ++ Ok( ++ TaggedContent { ++ tag: tag, ++ content: Content::Map(vec), ++ }, ++ ) ++ } ++ } ++ } ++ } ++ ++ /// Used by generated code to deserialize an adjacently tagged enum. ++ /// ++ /// Not public API. ++ pub enum TagOrContentField { ++ Tag, ++ Content, ++ } ++ ++ /// Not public API. ++ pub struct TagOrContentFieldVisitor { ++ pub tag: &'static str, ++ pub content: &'static str, ++ } ++ ++ impl<'de> DeserializeSeed<'de> for TagOrContentFieldVisitor { ++ type Value = TagOrContentField; ++ ++ fn deserialize(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_str(self) ++ } ++ } ++ ++ impl<'de> Visitor<'de> for TagOrContentFieldVisitor { ++ type Value = TagOrContentField; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ write!(formatter, "{:?} or {:?}", self.tag, self.content) ++ } ++ ++ fn visit_str(self, field: &str) -> Result ++ where ++ E: de::Error, ++ { ++ if field == self.tag { ++ Ok(TagOrContentField::Tag) ++ } else if field == self.content { ++ Ok(TagOrContentField::Content) ++ } else { ++ Err(de::Error::invalid_value(Unexpected::Str(field), &self)) ++ } ++ } ++ } ++ ++ /// Used by generated code to deserialize an adjacently tagged enum when ++ /// ignoring unrelated fields is allowed. ++ /// ++ /// Not public API. ++ pub enum TagContentOtherField { ++ Tag, ++ Content, ++ Other, ++ } ++ ++ /// Not public API. ++ pub struct TagContentOtherFieldVisitor { ++ pub tag: &'static str, ++ pub content: &'static str, ++ } ++ ++ impl<'de> DeserializeSeed<'de> for TagContentOtherFieldVisitor { ++ type Value = TagContentOtherField; ++ ++ fn deserialize(self, deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ deserializer.deserialize_str(self) ++ } ++ } ++ ++ impl<'de> Visitor<'de> for TagContentOtherFieldVisitor { ++ type Value = TagContentOtherField; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ write!(formatter, "{:?}, {:?}, or other ignored fields", self.tag, self.content) ++ } ++ ++ fn visit_str(self, field: &str) -> Result ++ where ++ E: de::Error, ++ { ++ if field == self.tag { ++ Ok(TagContentOtherField::Tag) ++ } else if field == self.content { ++ Ok(TagContentOtherField::Content) ++ } else { ++ Ok(TagContentOtherField::Other) ++ } ++ } ++ } ++ ++ /// Not public API ++ pub struct ContentDeserializer<'de, E> { ++ content: Content<'de>, ++ err: PhantomData, ++ } ++ ++ /// Used when deserializing an internally tagged enum because the content will ++ /// be used exactly once. ++ impl<'de, E> Deserializer<'de> for ContentDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match self.content { ++ Content::Bool(v) => visitor.visit_bool(v), ++ Content::U8(v) => visitor.visit_u8(v), ++ Content::U16(v) => visitor.visit_u16(v), ++ Content::U32(v) => visitor.visit_u32(v), ++ Content::U64(v) => visitor.visit_u64(v), ++ Content::I8(v) => visitor.visit_i8(v), ++ Content::I16(v) => visitor.visit_i16(v), ++ Content::I32(v) => visitor.visit_i32(v), ++ Content::I64(v) => visitor.visit_i64(v), ++ Content::F32(v) => visitor.visit_f32(v), ++ Content::F64(v) => visitor.visit_f64(v), ++ Content::Char(v) => visitor.visit_char(v), ++ Content::String(v) => visitor.visit_string(v), ++ Content::Str(v) => visitor.visit_borrowed_str(v), ++ Content::ByteBuf(v) => visitor.visit_byte_buf(v), ++ Content::Bytes(v) => visitor.visit_borrowed_bytes(v), ++ Content::Unit => visitor.visit_unit(), ++ Content::None => visitor.visit_none(), ++ Content::Some(v) => visitor.visit_some(ContentDeserializer::new(*v)), ++ Content::Newtype(v) => visitor.visit_newtype_struct(ContentDeserializer::new(*v)), ++ Content::Seq(v) => { ++ let seq = v.into_iter().map(ContentDeserializer::new); ++ let mut seq_visitor = de::value::SeqDeserializer::new(seq); ++ let value = try!(visitor.visit_seq(&mut seq_visitor)); ++ try!(seq_visitor.end()); ++ Ok(value) ++ } ++ Content::Map(v) => { ++ let map = v.into_iter().map(|(k, v)| { ++ (ContentDeserializer::new(k), ++ ContentDeserializer::new(v)) ++ }); ++ let mut map_visitor = de::value::MapDeserializer::new(map); ++ let value = try!(visitor.visit_map(&mut map_visitor)); ++ try!(map_visitor.end()); ++ Ok(value) ++ } ++ } ++ } ++ ++ fn deserialize_option(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match self.content { ++ Content::None => visitor.visit_none(), ++ Content::Some(v) => visitor.visit_some(ContentDeserializer::new(*v)), ++ Content::Unit => visitor.visit_unit(), ++ _ => visitor.visit_some(self), ++ } ++ } ++ ++ fn deserialize_newtype_struct( ++ self, ++ _name: &str, ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ visitor.visit_newtype_struct(self) ++ } ++ ++ fn deserialize_enum( ++ self, ++ _name: &str, ++ _variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ let (variant, value) = match self.content { ++ Content::Map(value) => { ++ let mut iter = value.into_iter(); ++ let (variant, value) = match iter.next() { ++ Some(v) => v, ++ None => { ++ return Err( ++ de::Error::invalid_value( ++ de::Unexpected::Map, ++ &"map with a single key", ++ ), ++ ); ++ } ++ }; ++ // enums are encoded in json as maps with a single key:value pair ++ if iter.next().is_some() { ++ return Err( ++ de::Error::invalid_value( ++ de::Unexpected::Map, ++ &"map with a single key", ++ ), ++ ); ++ } ++ (variant, Some(value)) ++ } ++ s @ Content::String(_) | s @ Content::Str(_) => (s, None), ++ other => { ++ return Err(de::Error::invalid_type(other.unexpected(), &"string or map"),); ++ } ++ }; ++ ++ visitor.visit_enum( ++ EnumDeserializer { ++ variant: variant, ++ value: value, ++ err: PhantomData, ++ }, ++ ) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf unit unit_struct seq tuple tuple_struct map struct ++ identifier ignored_any ++ } ++ } ++ ++ impl<'de, E> ContentDeserializer<'de, E> { ++ /// private API, don't use ++ pub fn new(content: Content<'de>) -> Self { ++ ContentDeserializer { ++ content: content, ++ err: PhantomData, ++ } ++ } ++ } ++ ++ struct EnumDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ variant: Content<'de>, ++ value: Option>, ++ err: PhantomData, ++ } ++ ++ impl<'de, E> de::EnumAccess<'de> for EnumDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ type Variant = VariantDeserializer<'de, Self::Error>; ++ ++ fn variant_seed(self, seed: V) -> Result<(V::Value, Self::Variant), E> ++ where ++ V: de::DeserializeSeed<'de>, ++ { ++ let visitor = VariantDeserializer { ++ value: self.value, ++ err: PhantomData, ++ }; ++ seed.deserialize(ContentDeserializer::new(self.variant)) ++ .map(|v| (v, visitor)) ++ } ++ } ++ ++ struct VariantDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ value: Option>, ++ err: PhantomData, ++ } ++ ++ impl<'de, E> de::VariantAccess<'de> for VariantDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ fn unit_variant(self) -> Result<(), E> { ++ match self.value { ++ Some(value) => de::Deserialize::deserialize(ContentDeserializer::new(value)), ++ None => Ok(()), ++ } ++ } ++ ++ fn newtype_variant_seed(self, seed: T) -> Result ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match self.value { ++ Some(value) => seed.deserialize(ContentDeserializer::new(value)), ++ None => { ++ Err(de::Error::invalid_type(de::Unexpected::UnitVariant, &"newtype variant"),) ++ } ++ } ++ } ++ ++ fn tuple_variant(self, _len: usize, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ match self.value { ++ Some(Content::Seq(v)) => { ++ de::Deserializer::deserialize_any(SeqDeserializer::new(v), visitor) ++ } ++ Some(other) => Err(de::Error::invalid_type(other.unexpected(), &"tuple variant"),), ++ None => Err(de::Error::invalid_type(de::Unexpected::UnitVariant, &"tuple variant"),), ++ } ++ } ++ ++ fn struct_variant( ++ self, ++ _fields: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ match self.value { ++ Some(Content::Map(v)) => { ++ de::Deserializer::deserialize_any(MapDeserializer::new(v), visitor) ++ } ++ Some(other) => Err(de::Error::invalid_type(other.unexpected(), &"struct variant"),), ++ _ => Err(de::Error::invalid_type(de::Unexpected::UnitVariant, &"struct variant"),), ++ } ++ } ++ } ++ ++ struct SeqDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ iter: > as IntoIterator>::IntoIter, ++ err: PhantomData, ++ } ++ ++ impl<'de, E> SeqDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ fn new(vec: Vec>) -> Self { ++ SeqDeserializer { ++ iter: vec.into_iter(), ++ err: PhantomData, ++ } ++ } ++ } ++ ++ impl<'de, E> de::Deserializer<'de> for SeqDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ #[inline] ++ fn deserialize_any(mut self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let len = self.iter.len(); ++ if len == 0 { ++ visitor.visit_unit() ++ } else { ++ let ret = try!(visitor.visit_seq(&mut self)); ++ let remaining = self.iter.len(); ++ if remaining == 0 { ++ Ok(ret) ++ } else { ++ Err(de::Error::invalid_length(len, &"fewer elements in array")) ++ } ++ } ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++ } ++ ++ impl<'de, E> de::SeqAccess<'de> for SeqDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ fn next_element_seed(&mut self, seed: T) -> Result, Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match self.iter.next() { ++ Some(value) => { ++ seed.deserialize(ContentDeserializer::new(value)) ++ .map(Some) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ size_hint::from_bounds(&self.iter) ++ } ++ } ++ ++ struct MapDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ iter: , Content<'de>)> as IntoIterator>::IntoIter, ++ value: Option>, ++ err: PhantomData, ++ } ++ ++ impl<'de, E> MapDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ fn new(map: Vec<(Content<'de>, Content<'de>)>) -> Self { ++ MapDeserializer { ++ iter: map.into_iter(), ++ value: None, ++ err: PhantomData, ++ } ++ } ++ } ++ ++ impl<'de, E> de::MapAccess<'de> for MapDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ fn next_key_seed(&mut self, seed: T) -> Result, Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match self.iter.next() { ++ Some((key, value)) => { ++ self.value = Some(value); ++ seed.deserialize(ContentDeserializer::new(key)).map(Some) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ fn next_value_seed(&mut self, seed: T) -> Result ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match self.value.take() { ++ Some(value) => seed.deserialize(ContentDeserializer::new(value)), ++ None => Err(de::Error::custom("value is missing")), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ size_hint::from_bounds(&self.iter) ++ } ++ } ++ ++ impl<'de, E> de::Deserializer<'de> for MapDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ #[inline] ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_map(self) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++ } ++ ++ /// Not public API. ++ pub struct ContentRefDeserializer<'a, 'de: 'a, E> { ++ content: &'a Content<'de>, ++ err: PhantomData, ++ } ++ ++ /// Used when deserializing an untagged enum because the content may need to be ++ /// used more than once. ++ impl<'de, 'a, E> Deserializer<'de> for ContentRefDeserializer<'a, 'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match *self.content { ++ Content::Bool(v) => visitor.visit_bool(v), ++ Content::U8(v) => visitor.visit_u8(v), ++ Content::U16(v) => visitor.visit_u16(v), ++ Content::U32(v) => visitor.visit_u32(v), ++ Content::U64(v) => visitor.visit_u64(v), ++ Content::I8(v) => visitor.visit_i8(v), ++ Content::I16(v) => visitor.visit_i16(v), ++ Content::I32(v) => visitor.visit_i32(v), ++ Content::I64(v) => visitor.visit_i64(v), ++ Content::F32(v) => visitor.visit_f32(v), ++ Content::F64(v) => visitor.visit_f64(v), ++ Content::Char(v) => visitor.visit_char(v), ++ Content::String(ref v) => visitor.visit_str(v), ++ Content::Str(v) => visitor.visit_borrowed_str(v), ++ Content::ByteBuf(ref v) => visitor.visit_bytes(v), ++ Content::Bytes(v) => visitor.visit_borrowed_bytes(v), ++ Content::Unit => visitor.visit_unit(), ++ Content::None => visitor.visit_none(), ++ Content::Some(ref v) => visitor.visit_some(ContentRefDeserializer::new(v)), ++ Content::Newtype(ref v) => { ++ visitor.visit_newtype_struct(ContentRefDeserializer::new(v)) ++ } ++ Content::Seq(ref v) => { ++ let seq = v.into_iter().map(ContentRefDeserializer::new); ++ let mut seq_visitor = de::value::SeqDeserializer::new(seq); ++ let value = try!(visitor.visit_seq(&mut seq_visitor)); ++ try!(seq_visitor.end()); ++ Ok(value) ++ } ++ Content::Map(ref v) => { ++ let map = v.into_iter() ++ .map( ++ |&(ref k, ref v)| { ++ (ContentRefDeserializer::new(k), ContentRefDeserializer::new(v)) ++ }, ++ ); ++ let mut map_visitor = de::value::MapDeserializer::new(map); ++ let value = try!(visitor.visit_map(&mut map_visitor)); ++ try!(map_visitor.end()); ++ Ok(value) ++ } ++ } ++ } ++ ++ fn deserialize_option(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match *self.content { ++ Content::None => visitor.visit_none(), ++ Content::Some(ref v) => visitor.visit_some(ContentRefDeserializer::new(v)), ++ Content::Unit => visitor.visit_unit(), ++ _ => visitor.visit_some(self), ++ } ++ } ++ ++ fn deserialize_newtype_struct(self, _name: &str, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ visitor.visit_newtype_struct(self) ++ } ++ ++ fn deserialize_enum( ++ self, ++ _name: &str, ++ _variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ let (variant, value) = match *self.content { ++ Content::Map(ref value) => { ++ let mut iter = value.into_iter(); ++ let &(ref variant, ref value) = match iter.next() { ++ Some(v) => v, ++ None => { ++ return Err( ++ de::Error::invalid_value( ++ de::Unexpected::Map, ++ &"map with a single key", ++ ), ++ ); ++ } ++ }; ++ // enums are encoded in json as maps with a single key:value pair ++ if iter.next().is_some() { ++ return Err( ++ de::Error::invalid_value( ++ de::Unexpected::Map, ++ &"map with a single key", ++ ), ++ ); ++ } ++ (variant, Some(value)) ++ } ++ ref s @ Content::String(_) | ref s @ Content::Str(_) => (s, None), ++ ref other => { ++ return Err(de::Error::invalid_type(other.unexpected(), &"string or map"),); ++ } ++ }; ++ ++ visitor.visit_enum( ++ EnumRefDeserializer { ++ variant: variant, ++ value: value, ++ err: PhantomData, ++ }, ++ ) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf unit unit_struct seq tuple tuple_struct map struct ++ identifier ignored_any ++ } ++ } ++ ++ impl<'a, 'de, E> ContentRefDeserializer<'a, 'de, E> { ++ /// private API, don't use ++ pub fn new(content: &'a Content<'de>) -> Self { ++ ContentRefDeserializer { ++ content: content, ++ err: PhantomData, ++ } ++ } ++ } ++ ++ struct EnumRefDeserializer<'a, 'de: 'a, E> ++ where ++ E: de::Error, ++ { ++ variant: &'a Content<'de>, ++ value: Option<&'a Content<'de>>, ++ err: PhantomData, ++ } ++ ++ impl<'de, 'a, E> de::EnumAccess<'de> for EnumRefDeserializer<'a, 'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ type Variant = VariantRefDeserializer<'a, 'de, Self::Error>; ++ ++ fn variant_seed(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error> ++ where ++ V: de::DeserializeSeed<'de>, ++ { ++ let visitor = VariantRefDeserializer { ++ value: self.value, ++ err: PhantomData, ++ }; ++ seed.deserialize(ContentRefDeserializer::new(self.variant)) ++ .map(|v| (v, visitor)) ++ } ++ } ++ ++ struct VariantRefDeserializer<'a, 'de: 'a, E> ++ where ++ E: de::Error, ++ { ++ value: Option<&'a Content<'de>>, ++ err: PhantomData, ++ } ++ ++ impl<'de, 'a, E> de::VariantAccess<'de> for VariantRefDeserializer<'a, 'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ fn unit_variant(self) -> Result<(), E> { ++ match self.value { ++ Some(value) => de::Deserialize::deserialize(ContentRefDeserializer::new(value)), ++ None => Ok(()), ++ } ++ } ++ ++ fn newtype_variant_seed(self, seed: T) -> Result ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match self.value { ++ Some(value) => seed.deserialize(ContentRefDeserializer::new(value)), ++ None => { ++ Err(de::Error::invalid_type(de::Unexpected::UnitVariant, &"newtype variant"),) ++ } ++ } ++ } ++ ++ fn tuple_variant(self, _len: usize, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ match self.value { ++ Some(&Content::Seq(ref v)) => { ++ de::Deserializer::deserialize_any(SeqRefDeserializer::new(v), visitor) ++ } ++ Some(other) => Err(de::Error::invalid_type(other.unexpected(), &"tuple variant"),), ++ None => Err(de::Error::invalid_type(de::Unexpected::UnitVariant, &"tuple variant"),), ++ } ++ } ++ ++ fn struct_variant( ++ self, ++ _fields: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ match self.value { ++ Some(&Content::Map(ref v)) => { ++ de::Deserializer::deserialize_any(MapRefDeserializer::new(v), visitor) ++ } ++ Some(other) => Err(de::Error::invalid_type(other.unexpected(), &"struct variant"),), ++ _ => Err(de::Error::invalid_type(de::Unexpected::UnitVariant, &"struct variant"),), ++ } ++ } ++ } ++ ++ struct SeqRefDeserializer<'a, 'de: 'a, E> ++ where ++ E: de::Error, ++ { ++ iter: <&'a [Content<'de>] as IntoIterator>::IntoIter, ++ err: PhantomData, ++ } ++ ++ impl<'a, 'de, E> SeqRefDeserializer<'a, 'de, E> ++ where ++ E: de::Error, ++ { ++ fn new(vec: &'a [Content<'de>]) -> Self { ++ SeqRefDeserializer { ++ iter: vec.into_iter(), ++ err: PhantomData, ++ } ++ } ++ } ++ ++ impl<'de, 'a, E> de::Deserializer<'de> for SeqRefDeserializer<'a, 'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ #[inline] ++ fn deserialize_any(mut self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let len = self.iter.len(); ++ if len == 0 { ++ visitor.visit_unit() ++ } else { ++ let ret = try!(visitor.visit_seq(&mut self)); ++ let remaining = self.iter.len(); ++ if remaining == 0 { ++ Ok(ret) ++ } else { ++ Err(de::Error::invalid_length(len, &"fewer elements in array")) ++ } ++ } ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++ } ++ ++ impl<'de, 'a, E> de::SeqAccess<'de> for SeqRefDeserializer<'a, 'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ fn next_element_seed(&mut self, seed: T) -> Result, Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match self.iter.next() { ++ Some(value) => { ++ seed.deserialize(ContentRefDeserializer::new(value)) ++ .map(Some) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ size_hint::from_bounds(&self.iter) ++ } ++ } ++ ++ struct MapRefDeserializer<'a, 'de: 'a, E> ++ where ++ E: de::Error, ++ { ++ iter: <&'a [(Content<'de>, Content<'de>)] as IntoIterator>::IntoIter, ++ value: Option<&'a Content<'de>>, ++ err: PhantomData, ++ } ++ ++ impl<'a, 'de, E> MapRefDeserializer<'a, 'de, E> ++ where ++ E: de::Error, ++ { ++ fn new(map: &'a [(Content<'de>, Content<'de>)]) -> Self { ++ MapRefDeserializer { ++ iter: map.into_iter(), ++ value: None, ++ err: PhantomData, ++ } ++ } ++ } ++ ++ impl<'de, 'a, E> de::MapAccess<'de> for MapRefDeserializer<'a, 'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ fn next_key_seed(&mut self, seed: T) -> Result, Self::Error> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match self.iter.next() { ++ Some(&(ref key, ref value)) => { ++ self.value = Some(value); ++ seed.deserialize(ContentRefDeserializer::new(key)) ++ .map(Some) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ fn next_value_seed(&mut self, seed: T) -> Result ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match self.value.take() { ++ Some(value) => seed.deserialize(ContentRefDeserializer::new(value)), ++ None => Err(de::Error::custom("value is missing")), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ size_hint::from_bounds(&self.iter) ++ } ++ } ++ ++ impl<'de, 'a, E> de::Deserializer<'de> for MapRefDeserializer<'a, 'de, E> ++ where ++ E: de::Error, ++ { ++ type Error = E; ++ ++ #[inline] ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_map(self) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++ } ++ ++ impl<'de, E> de::IntoDeserializer<'de, E> for ContentDeserializer<'de, E> ++ where ++ E: de::Error, ++ { ++ type Deserializer = Self; ++ ++ fn into_deserializer(self) -> Self { ++ self ++ } ++ } ++ ++ impl<'de, 'a, E> de::IntoDeserializer<'de, E> for ContentRefDeserializer<'a, 'de, E> ++ where ++ E: de::Error, ++ { ++ type Deserializer = Self; ++ ++ fn into_deserializer(self) -> Self { ++ self ++ } ++ } ++ ++ /// Visitor for deserializing an internally tagged unit variant. ++ /// ++ /// Not public API. ++ pub struct InternallyTaggedUnitVisitor<'a> { ++ type_name: &'a str, ++ variant_name: &'a str, ++ } ++ ++ impl<'a> InternallyTaggedUnitVisitor<'a> { ++ /// Not public API. ++ pub fn new(type_name: &'a str, variant_name: &'a str) -> Self { ++ InternallyTaggedUnitVisitor { ++ type_name: type_name, ++ variant_name: variant_name, ++ } ++ } ++ } ++ ++ impl<'de, 'a> Visitor<'de> for InternallyTaggedUnitVisitor<'a> { ++ type Value = (); ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ write!(formatter, "unit variant {}::{}", self.type_name, self.variant_name) ++ } ++ ++ fn visit_seq(self, _: S) -> Result<(), S::Error> ++ where ++ S: SeqAccess<'de>, ++ { ++ Ok(()) ++ } ++ ++ fn visit_map(self, _: M) -> Result<(), M::Error> ++ where ++ M: MapAccess<'de>, ++ { ++ Ok(()) ++ } ++ } ++ ++ /// Visitor for deserializing an untagged unit variant. ++ /// ++ /// Not public API. ++ pub struct UntaggedUnitVisitor<'a> { ++ type_name: &'a str, ++ variant_name: &'a str, ++ } ++ ++ impl<'a> UntaggedUnitVisitor<'a> { ++ /// Not public API. ++ pub fn new(type_name: &'a str, variant_name: &'a str) -> Self { ++ UntaggedUnitVisitor { ++ type_name: type_name, ++ variant_name: variant_name, ++ } ++ } ++ } ++ ++ impl<'de, 'a> Visitor<'de> for UntaggedUnitVisitor<'a> { ++ type Value = (); ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ write!(formatter, "unit variant {}::{}", self.type_name, self.variant_name) ++ } ++ ++ fn visit_unit(self) -> Result<(), E> ++ where ++ E: de::Error, ++ { ++ Ok(()) ++ } ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++// Like `IntoDeserializer` but also implemented for `&[u8]`. This is used for ++// the newtype fallthrough case of `field_identifier`. ++// ++// #[derive(Deserialize)] ++// #[serde(field_identifier)] ++// enum F { ++// A, ++// B, ++// Other(String), // deserialized using IdentifierDeserializer ++// } ++pub trait IdentifierDeserializer<'de, E: Error> { ++ type Deserializer: Deserializer<'de, Error = E>; ++ ++ fn from(self) -> Self::Deserializer; ++} ++ ++impl<'de, E> IdentifierDeserializer<'de, E> for u32 ++where ++ E: Error, ++{ ++ type Deserializer = >::Deserializer; ++ ++ fn from(self) -> Self::Deserializer { ++ self.into_deserializer() ++ } ++} ++ ++pub struct StrDeserializer<'a, E> { ++ value: &'a str, ++ marker: PhantomData, ++} ++ ++impl<'a, E> IdentifierDeserializer<'a, E> for &'a str ++where ++ E: Error, ++{ ++ type Deserializer = StrDeserializer<'a, E>; ++ ++ fn from(self) -> Self::Deserializer { ++ StrDeserializer { ++ value: self, ++ marker: PhantomData, ++ } ++ } ++} ++ ++impl<'de, 'a, E> Deserializer<'de> for StrDeserializer<'a, E> ++where ++ E: Error, ++{ ++ type Error = E; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ visitor.visit_str(self.value) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct enum identifier ignored_any ++ } ++} ++ ++pub struct BytesDeserializer<'a, E> { ++ value: &'a [u8], ++ marker: PhantomData, ++} ++ ++impl<'a, E> IdentifierDeserializer<'a, E> for &'a [u8] ++where ++ E: Error, ++{ ++ type Deserializer = BytesDeserializer<'a, E>; ++ ++ fn from(self) -> Self::Deserializer { ++ BytesDeserializer { ++ value: self, ++ marker: PhantomData, ++ } ++ } ++} ++ ++impl<'de, 'a, E> Deserializer<'de> for BytesDeserializer<'a, E> ++where ++ E: Error, ++{ ++ type Error = E; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ visitor.visit_bytes(self.value) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple tuple_struct ++ map struct enum identifier ignored_any ++ } ++} diff --cc vendor/serde-1.0.15/src/private/macros.rs index 000000000,000000000..046761385 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/private/macros.rs @@@ -1,0 -1,0 +1,148 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++#[doc(hidden)] ++#[macro_export] ++macro_rules! __private_serialize { ++ () => { ++ trait Serialize { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: $crate::Serializer; ++ } ++ }; ++} ++ ++#[doc(hidden)] ++#[macro_export] ++macro_rules! __private_deserialize { ++ () => { ++ trait Deserialize<'de>: Sized { ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: $crate::Deserializer<'de>; ++ } ++ }; ++} ++ ++/// Used only by Serde doc tests. Not public API. ++#[doc(hidden)] ++#[macro_export] ++macro_rules! __serialize_unimplemented { ++ ($($func:ident)*) => { ++ $( ++ __serialize_unimplemented_helper!($func); ++ )* ++ }; ++} ++ ++#[doc(hidden)] ++#[macro_export] ++macro_rules! __serialize_unimplemented_method { ++ ($func:ident $(<$t:ident>)* ($($arg:ty),*) -> $ret:ident) => { ++ fn $func $(<$t: ?Sized + $crate::Serialize>)* (self $(, _: $arg)*) -> $crate::export::Result { ++ unimplemented!() ++ } ++ }; ++} ++ ++#[doc(hidden)] ++#[macro_export] ++macro_rules! __serialize_unimplemented_helper { ++ (bool) => { ++ __serialize_unimplemented_method!(serialize_bool(bool) -> Ok); ++ }; ++ (i8) => { ++ __serialize_unimplemented_method!(serialize_i8(i8) -> Ok); ++ }; ++ (i16) => { ++ __serialize_unimplemented_method!(serialize_i16(i16) -> Ok); ++ }; ++ (i32) => { ++ __serialize_unimplemented_method!(serialize_i32(i32) -> Ok); ++ }; ++ (i64) => { ++ __serialize_unimplemented_method!(serialize_i64(i64) -> Ok); ++ }; ++ (u8) => { ++ __serialize_unimplemented_method!(serialize_u8(u8) -> Ok); ++ }; ++ (u16) => { ++ __serialize_unimplemented_method!(serialize_u16(u16) -> Ok); ++ }; ++ (u32) => { ++ __serialize_unimplemented_method!(serialize_u32(u32) -> Ok); ++ }; ++ (u64) => { ++ __serialize_unimplemented_method!(serialize_u64(u64) -> Ok); ++ }; ++ (f32) => { ++ __serialize_unimplemented_method!(serialize_f32(f32) -> Ok); ++ }; ++ (f64) => { ++ __serialize_unimplemented_method!(serialize_f64(f64) -> Ok); ++ }; ++ (char) => { ++ __serialize_unimplemented_method!(serialize_char(char) -> Ok); ++ }; ++ (str) => { ++ __serialize_unimplemented_method!(serialize_str(&str) -> Ok); ++ }; ++ (bytes) => { ++ __serialize_unimplemented_method!(serialize_bytes(&[u8]) -> Ok); ++ }; ++ (none) => { ++ __serialize_unimplemented_method!(serialize_none() -> Ok); ++ }; ++ (some) => { ++ __serialize_unimplemented_method!(serialize_some(&T) -> Ok); ++ }; ++ (unit) => { ++ __serialize_unimplemented_method!(serialize_unit() -> Ok); ++ }; ++ (unit_struct) => { ++ __serialize_unimplemented_method!(serialize_unit_struct(&str) -> Ok); ++ }; ++ (unit_variant) => { ++ __serialize_unimplemented_method!(serialize_unit_variant(&str, u32, &str) -> Ok); ++ }; ++ (newtype_struct) => { ++ __serialize_unimplemented_method!(serialize_newtype_struct(&str, &T) -> Ok); ++ }; ++ (newtype_variant) => { ++ __serialize_unimplemented_method!(serialize_newtype_variant(&str, u32, &str, &T) -> Ok); ++ }; ++ (seq) => { ++ type SerializeSeq = $crate::ser::Impossible; ++ __serialize_unimplemented_method!(serialize_seq(Option) -> SerializeSeq); ++ }; ++ (tuple) => { ++ type SerializeTuple = $crate::ser::Impossible; ++ __serialize_unimplemented_method!(serialize_tuple(usize) -> SerializeTuple); ++ }; ++ (tuple_struct) => { ++ type SerializeTupleStruct = $crate::ser::Impossible; ++ __serialize_unimplemented_method!(serialize_tuple_struct(&str, usize) -> SerializeTupleStruct); ++ }; ++ (tuple_variant) => { ++ type SerializeTupleVariant = $crate::ser::Impossible; ++ __serialize_unimplemented_method!(serialize_tuple_variant(&str, u32, &str, usize) -> SerializeTupleVariant); ++ }; ++ (map) => { ++ type SerializeMap = $crate::ser::Impossible; ++ __serialize_unimplemented_method!(serialize_map(Option) -> SerializeMap); ++ }; ++ (struct) => { ++ type SerializeStruct = $crate::ser::Impossible; ++ __serialize_unimplemented_method!(serialize_struct(&str, usize) -> SerializeStruct); ++ }; ++ (struct_variant) => { ++ type SerializeStructVariant = $crate::ser::Impossible; ++ __serialize_unimplemented_method!(serialize_struct_variant(&str, u32, &str, usize) -> SerializeStructVariant); ++ }; ++} diff --cc vendor/serde-1.0.15/src/private/mod.rs index 000000000,000000000..98307c975 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/private/mod.rs @@@ -1,0 -1,0 +1,12 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++mod macros; ++ ++pub mod ser; ++pub mod de; diff --cc vendor/serde-1.0.15/src/private/ser.rs index 000000000,000000000..51db594da new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/private/ser.rs @@@ -1,0 -1,0 +1,1019 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use lib::*; ++ ++use ser::{self, Serialize, Serializer, SerializeMap, SerializeStruct, Impossible}; ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++use self::content::{SerializeTupleVariantAsMapValue, SerializeStructVariantAsMapValue}; ++ ++/// Used to check that serde(getter) attributes return the expected type. ++/// Not public API. ++pub fn constrain(t: &T) -> &T { ++ t ++} ++ ++/// Not public API. ++pub fn serialize_tagged_newtype( ++ serializer: S, ++ type_ident: &'static str, ++ variant_ident: &'static str, ++ tag: &'static str, ++ variant_name: &'static str, ++ value: &T, ++) -> Result ++where ++ S: Serializer, ++ T: Serialize, ++{ ++ value.serialize( ++ TaggedSerializer { ++ type_ident: type_ident, ++ variant_ident: variant_ident, ++ tag: tag, ++ variant_name: variant_name, ++ delegate: serializer, ++ }, ++ ) ++} ++ ++struct TaggedSerializer { ++ type_ident: &'static str, ++ variant_ident: &'static str, ++ tag: &'static str, ++ variant_name: &'static str, ++ delegate: S, ++} ++ ++enum Unsupported { ++ Boolean, ++ Integer, ++ Float, ++ Char, ++ String, ++ ByteArray, ++ Optional, ++ Unit, ++ UnitStruct, ++ Sequence, ++ Tuple, ++ TupleStruct, ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ Enum, ++} ++ ++impl Display for Unsupported { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ match *self { ++ Unsupported::Boolean => formatter.write_str("a boolean"), ++ Unsupported::Integer => formatter.write_str("an integer"), ++ Unsupported::Float => formatter.write_str("a float"), ++ Unsupported::Char => formatter.write_str("a char"), ++ Unsupported::String => formatter.write_str("a string"), ++ Unsupported::ByteArray => formatter.write_str("a byte array"), ++ Unsupported::Optional => formatter.write_str("an optional"), ++ Unsupported::Unit => formatter.write_str("unit"), ++ Unsupported::UnitStruct => formatter.write_str("a unit struct"), ++ Unsupported::Sequence => formatter.write_str("a sequence"), ++ Unsupported::Tuple => formatter.write_str("a tuple"), ++ Unsupported::TupleStruct => formatter.write_str("a tuple struct"), ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ Unsupported::Enum => formatter.write_str("an enum"), ++ } ++ } ++} ++ ++impl TaggedSerializer ++where ++ S: Serializer, ++{ ++ fn bad_type(self, what: Unsupported) -> S::Error { ++ ser::Error::custom( ++ format_args!( ++ "cannot serialize tagged newtype variant {}::{} containing {}", ++ self.type_ident, ++ self.variant_ident, ++ what), ++ ) ++ } ++} ++ ++impl Serializer for TaggedSerializer ++where ++ S: Serializer, ++{ ++ type Ok = S::Ok; ++ type Error = S::Error; ++ ++ type SerializeSeq = Impossible; ++ type SerializeTuple = Impossible; ++ type SerializeTupleStruct = Impossible; ++ type SerializeMap = S::SerializeMap; ++ type SerializeStruct = S::SerializeStruct; ++ ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ type SerializeTupleVariant = Impossible; ++ #[cfg(any(feature = "std", feature = "alloc"))] ++ type SerializeTupleVariant = SerializeTupleVariantAsMapValue; ++ ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ type SerializeStructVariant = Impossible; ++ #[cfg(any(feature = "std", feature = "alloc"))] ++ type SerializeStructVariant = SerializeStructVariantAsMapValue; ++ ++ fn serialize_bool(self, _: bool) -> Result { ++ Err(self.bad_type(Unsupported::Boolean)) ++ } ++ ++ fn serialize_i8(self, _: i8) -> Result { ++ Err(self.bad_type(Unsupported::Integer)) ++ } ++ ++ fn serialize_i16(self, _: i16) -> Result { ++ Err(self.bad_type(Unsupported::Integer)) ++ } ++ ++ fn serialize_i32(self, _: i32) -> Result { ++ Err(self.bad_type(Unsupported::Integer)) ++ } ++ ++ fn serialize_i64(self, _: i64) -> Result { ++ Err(self.bad_type(Unsupported::Integer)) ++ } ++ ++ fn serialize_u8(self, _: u8) -> Result { ++ Err(self.bad_type(Unsupported::Integer)) ++ } ++ ++ fn serialize_u16(self, _: u16) -> Result { ++ Err(self.bad_type(Unsupported::Integer)) ++ } ++ ++ fn serialize_u32(self, _: u32) -> Result { ++ Err(self.bad_type(Unsupported::Integer)) ++ } ++ ++ fn serialize_u64(self, _: u64) -> Result { ++ Err(self.bad_type(Unsupported::Integer)) ++ } ++ ++ fn serialize_f32(self, _: f32) -> Result { ++ Err(self.bad_type(Unsupported::Float)) ++ } ++ ++ fn serialize_f64(self, _: f64) -> Result { ++ Err(self.bad_type(Unsupported::Float)) ++ } ++ ++ fn serialize_char(self, _: char) -> Result { ++ Err(self.bad_type(Unsupported::Char)) ++ } ++ ++ fn serialize_str(self, _: &str) -> Result { ++ Err(self.bad_type(Unsupported::String)) ++ } ++ ++ fn serialize_bytes(self, _: &[u8]) -> Result { ++ Err(self.bad_type(Unsupported::ByteArray)) ++ } ++ ++ fn serialize_none(self) -> Result { ++ Err(self.bad_type(Unsupported::Optional)) ++ } ++ ++ fn serialize_some(self, _: &T) -> Result ++ where ++ T: Serialize, ++ { ++ Err(self.bad_type(Unsupported::Optional)) ++ } ++ ++ fn serialize_unit(self) -> Result { ++ Err(self.bad_type(Unsupported::Unit)) ++ } ++ ++ fn serialize_unit_struct(self, _: &'static str) -> Result { ++ Err(self.bad_type(Unsupported::UnitStruct)) ++ } ++ ++ fn serialize_unit_variant( ++ self, ++ _: &'static str, ++ _: u32, ++ inner_variant: &'static str, ++ ) -> Result { ++ let mut map = try!(self.delegate.serialize_map(Some(2))); ++ try!(map.serialize_entry(self.tag, self.variant_name)); ++ try!(map.serialize_entry(inner_variant, &())); ++ map.end() ++ } ++ ++ fn serialize_newtype_struct( ++ self, ++ _: &'static str, ++ value: &T, ++ ) -> Result ++ where ++ T: Serialize, ++ { ++ value.serialize(self) ++ } ++ ++ fn serialize_newtype_variant( ++ self, ++ _: &'static str, ++ _: u32, ++ inner_variant: &'static str, ++ inner_value: &T, ++ ) -> Result ++ where ++ T: Serialize, ++ { ++ let mut map = try!(self.delegate.serialize_map(Some(2))); ++ try!(map.serialize_entry(self.tag, self.variant_name)); ++ try!(map.serialize_entry(inner_variant, inner_value)); ++ map.end() ++ } ++ ++ fn serialize_seq(self, _: Option) -> Result { ++ Err(self.bad_type(Unsupported::Sequence)) ++ } ++ ++ fn serialize_tuple(self, _: usize) -> Result { ++ Err(self.bad_type(Unsupported::Tuple)) ++ } ++ ++ fn serialize_tuple_struct( ++ self, ++ _: &'static str, ++ _: usize, ++ ) -> Result { ++ Err(self.bad_type(Unsupported::TupleStruct)) ++ } ++ ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ fn serialize_tuple_variant( ++ self, ++ _: &'static str, ++ _: u32, ++ _: &'static str, ++ _: usize, ++ ) -> Result { ++ // Lack of push-based serialization means we need to buffer the content ++ // of the tuple variant, so it requires std. ++ Err(self.bad_type(Unsupported::Enum)) ++ } ++ ++ #[cfg(any(feature = "std", feature = "alloc"))] ++ fn serialize_tuple_variant( ++ self, ++ _: &'static str, ++ _: u32, ++ inner_variant: &'static str, ++ len: usize, ++ ) -> Result { ++ let mut map = try!(self.delegate.serialize_map(Some(2))); ++ try!(map.serialize_entry(self.tag, self.variant_name)); ++ try!(map.serialize_key(inner_variant)); ++ Ok(SerializeTupleVariantAsMapValue::new(map, inner_variant, len),) ++ } ++ ++ fn serialize_map(self, len: Option) -> Result { ++ let mut map = try!(self.delegate.serialize_map(len.map(|len| len + 1))); ++ try!(map.serialize_entry(self.tag, self.variant_name)); ++ Ok(map) ++ } ++ ++ fn serialize_struct( ++ self, ++ name: &'static str, ++ len: usize, ++ ) -> Result { ++ let mut state = try!(self.delegate.serialize_struct(name, len + 1)); ++ try!(state.serialize_field(self.tag, self.variant_name)); ++ Ok(state) ++ } ++ ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ fn serialize_struct_variant( ++ self, ++ _: &'static str, ++ _: u32, ++ _: &'static str, ++ _: usize, ++ ) -> Result { ++ // Lack of push-based serialization means we need to buffer the content ++ // of the struct variant, so it requires std. ++ Err(self.bad_type(Unsupported::Enum)) ++ } ++ ++ #[cfg(any(feature = "std", feature = "alloc"))] ++ fn serialize_struct_variant( ++ self, ++ _: &'static str, ++ _: u32, ++ inner_variant: &'static str, ++ len: usize, ++ ) -> Result { ++ let mut map = try!(self.delegate.serialize_map(Some(2))); ++ try!(map.serialize_entry(self.tag, self.variant_name)); ++ try!(map.serialize_key(inner_variant)); ++ Ok(SerializeStructVariantAsMapValue::new(map, inner_variant, len),) ++ } ++ ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ fn collect_str(self, _: &T) -> Result ++ where ++ T: Display, ++ { ++ Err(self.bad_type(Unsupported::String)) ++ } ++} ++ ++/// Used only by Serde doc tests. Not public API. ++#[doc(hidden)] ++#[derive(Debug)] ++pub struct Error; ++ ++impl ser::Error for Error { ++ fn custom(_: T) -> Self ++ where ++ T: Display, ++ { ++ unimplemented!() ++ } ++} ++ ++#[cfg(feature = "std")] ++impl error::Error for Error { ++ fn description(&self) -> &str { ++ unimplemented!() ++ } ++} ++ ++impl Display for Error { ++ fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { ++ unimplemented!() ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++mod content { ++ use lib::*; ++ ++ use ser::{self, Serialize, Serializer}; ++ ++ pub struct SerializeTupleVariantAsMapValue { ++ map: M, ++ name: &'static str, ++ fields: Vec, ++ } ++ ++ impl SerializeTupleVariantAsMapValue { ++ pub fn new(map: M, name: &'static str, len: usize) -> Self { ++ SerializeTupleVariantAsMapValue { ++ map: map, ++ name: name, ++ fields: Vec::with_capacity(len), ++ } ++ } ++ } ++ ++ impl ser::SerializeTupleVariant for SerializeTupleVariantAsMapValue ++ where ++ M: ser::SerializeMap, ++ { ++ type Ok = M::Ok; ++ type Error = M::Error; ++ ++ fn serialize_field(&mut self, value: &T) -> Result<(), M::Error> ++ where ++ T: Serialize, ++ { ++ let value = try!(value.serialize(ContentSerializer::::new())); ++ self.fields.push(value); ++ Ok(()) ++ } ++ ++ fn end(mut self) -> Result { ++ try!(self.map.serialize_value(&Content::TupleStruct(self.name, self.fields))); ++ self.map.end() ++ } ++ } ++ ++ pub struct SerializeStructVariantAsMapValue { ++ map: M, ++ name: &'static str, ++ fields: Vec<(&'static str, Content)>, ++ } ++ ++ impl SerializeStructVariantAsMapValue { ++ pub fn new(map: M, name: &'static str, len: usize) -> Self { ++ SerializeStructVariantAsMapValue { ++ map: map, ++ name: name, ++ fields: Vec::with_capacity(len), ++ } ++ } ++ } ++ ++ impl ser::SerializeStructVariant for SerializeStructVariantAsMapValue ++ where ++ M: ser::SerializeMap, ++ { ++ type Ok = M::Ok; ++ type Error = M::Error; ++ ++ fn serialize_field( ++ &mut self, ++ key: &'static str, ++ value: &T, ++ ) -> Result<(), M::Error> ++ where ++ T: Serialize, ++ { ++ let value = try!(value.serialize(ContentSerializer::::new())); ++ self.fields.push((key, value)); ++ Ok(()) ++ } ++ ++ fn end(mut self) -> Result { ++ try!(self.map.serialize_value(&Content::Struct(self.name, self.fields))); ++ self.map.end() ++ } ++ } ++ ++ #[derive(Debug)] ++ enum Content { ++ Bool(bool), ++ ++ U8(u8), ++ U16(u16), ++ U32(u32), ++ U64(u64), ++ ++ I8(i8), ++ I16(i16), ++ I32(i32), ++ I64(i64), ++ ++ F32(f32), ++ F64(f64), ++ ++ Char(char), ++ String(String), ++ Bytes(Vec), ++ ++ None, ++ Some(Box), ++ ++ Unit, ++ UnitStruct(&'static str), ++ UnitVariant(&'static str, u32, &'static str), ++ NewtypeStruct(&'static str, Box), ++ NewtypeVariant(&'static str, u32, &'static str, Box), ++ ++ Seq(Vec), ++ Tuple(Vec), ++ TupleStruct(&'static str, Vec), ++ TupleVariant(&'static str, u32, &'static str, Vec), ++ Map(Vec<(Content, Content)>), ++ Struct(&'static str, Vec<(&'static str, Content)>), ++ StructVariant(&'static str, u32, &'static str, Vec<(&'static str, Content)>), ++ } ++ ++ impl Serialize for Content { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ match *self { ++ Content::Bool(b) => serializer.serialize_bool(b), ++ Content::U8(u) => serializer.serialize_u8(u), ++ Content::U16(u) => serializer.serialize_u16(u), ++ Content::U32(u) => serializer.serialize_u32(u), ++ Content::U64(u) => serializer.serialize_u64(u), ++ Content::I8(i) => serializer.serialize_i8(i), ++ Content::I16(i) => serializer.serialize_i16(i), ++ Content::I32(i) => serializer.serialize_i32(i), ++ Content::I64(i) => serializer.serialize_i64(i), ++ Content::F32(f) => serializer.serialize_f32(f), ++ Content::F64(f) => serializer.serialize_f64(f), ++ Content::Char(c) => serializer.serialize_char(c), ++ Content::String(ref s) => serializer.serialize_str(s), ++ Content::Bytes(ref b) => serializer.serialize_bytes(b), ++ Content::None => serializer.serialize_none(), ++ Content::Some(ref c) => serializer.serialize_some(&**c), ++ Content::Unit => serializer.serialize_unit(), ++ Content::UnitStruct(n) => serializer.serialize_unit_struct(n), ++ Content::UnitVariant(n, i, v) => serializer.serialize_unit_variant(n, i, v), ++ Content::NewtypeStruct(n, ref c) => serializer.serialize_newtype_struct(n, &**c), ++ Content::NewtypeVariant(n, i, v, ref c) => { ++ serializer.serialize_newtype_variant(n, i, v, &**c) ++ } ++ Content::Seq(ref elements) => elements.serialize(serializer), ++ Content::Tuple(ref elements) => { ++ use ser::SerializeTuple; ++ let mut tuple = try!(serializer.serialize_tuple(elements.len())); ++ for e in elements { ++ try!(tuple.serialize_element(e)); ++ } ++ tuple.end() ++ } ++ Content::TupleStruct(n, ref fields) => { ++ use ser::SerializeTupleStruct; ++ let mut ts = try!(serializer.serialize_tuple_struct(n, fields.len())); ++ for f in fields { ++ try!(ts.serialize_field(f)); ++ } ++ ts.end() ++ } ++ Content::TupleVariant(n, i, v, ref fields) => { ++ use ser::SerializeTupleVariant; ++ let mut tv = try!(serializer.serialize_tuple_variant(n, i, v, fields.len())); ++ for f in fields { ++ try!(tv.serialize_field(f)); ++ } ++ tv.end() ++ } ++ Content::Map(ref entries) => { ++ use ser::SerializeMap; ++ let mut map = try!(serializer.serialize_map(Some(entries.len()))); ++ for &(ref k, ref v) in entries { ++ try!(map.serialize_entry(k, v)); ++ } ++ map.end() ++ } ++ Content::Struct(n, ref fields) => { ++ use ser::SerializeStruct; ++ let mut s = try!(serializer.serialize_struct(n, fields.len())); ++ for &(k, ref v) in fields { ++ try!(s.serialize_field(k, v)); ++ } ++ s.end() ++ } ++ Content::StructVariant(n, i, v, ref fields) => { ++ use ser::SerializeStructVariant; ++ let mut sv = try!(serializer.serialize_struct_variant(n, i, v, fields.len())); ++ for &(k, ref v) in fields { ++ try!(sv.serialize_field(k, v)); ++ } ++ sv.end() ++ } ++ } ++ } ++ } ++ ++ struct ContentSerializer { ++ error: PhantomData, ++ } ++ ++ impl ContentSerializer { ++ fn new() -> Self { ++ ContentSerializer { error: PhantomData } ++ } ++ } ++ ++ impl Serializer for ContentSerializer ++ where ++ E: ser::Error, ++ { ++ type Ok = Content; ++ type Error = E; ++ ++ type SerializeSeq = SerializeSeq; ++ type SerializeTuple = SerializeTuple; ++ type SerializeTupleStruct = SerializeTupleStruct; ++ type SerializeTupleVariant = SerializeTupleVariant; ++ type SerializeMap = SerializeMap; ++ type SerializeStruct = SerializeStruct; ++ type SerializeStructVariant = SerializeStructVariant; ++ ++ fn serialize_bool(self, v: bool) -> Result { ++ Ok(Content::Bool(v)) ++ } ++ ++ fn serialize_i8(self, v: i8) -> Result { ++ Ok(Content::I8(v)) ++ } ++ ++ fn serialize_i16(self, v: i16) -> Result { ++ Ok(Content::I16(v)) ++ } ++ ++ fn serialize_i32(self, v: i32) -> Result { ++ Ok(Content::I32(v)) ++ } ++ ++ fn serialize_i64(self, v: i64) -> Result { ++ Ok(Content::I64(v)) ++ } ++ ++ fn serialize_u8(self, v: u8) -> Result { ++ Ok(Content::U8(v)) ++ } ++ ++ fn serialize_u16(self, v: u16) -> Result { ++ Ok(Content::U16(v)) ++ } ++ ++ fn serialize_u32(self, v: u32) -> Result { ++ Ok(Content::U32(v)) ++ } ++ ++ fn serialize_u64(self, v: u64) -> Result { ++ Ok(Content::U64(v)) ++ } ++ ++ fn serialize_f32(self, v: f32) -> Result { ++ Ok(Content::F32(v)) ++ } ++ ++ fn serialize_f64(self, v: f64) -> Result { ++ Ok(Content::F64(v)) ++ } ++ ++ fn serialize_char(self, v: char) -> Result { ++ Ok(Content::Char(v)) ++ } ++ ++ fn serialize_str(self, value: &str) -> Result { ++ Ok(Content::String(value.to_owned())) ++ } ++ ++ fn serialize_bytes(self, value: &[u8]) -> Result { ++ Ok(Content::Bytes(value.to_owned())) ++ } ++ ++ fn serialize_none(self) -> Result { ++ Ok(Content::None) ++ } ++ ++ fn serialize_some(self, value: &T) -> Result ++ where ++ T: Serialize, ++ { ++ Ok(Content::Some(Box::new(try!(value.serialize(self))))) ++ } ++ ++ fn serialize_unit(self) -> Result { ++ Ok(Content::Unit) ++ } ++ ++ fn serialize_unit_struct(self, name: &'static str) -> Result { ++ Ok(Content::UnitStruct(name)) ++ } ++ ++ fn serialize_unit_variant( ++ self, ++ name: &'static str, ++ variant_index: u32, ++ variant: &'static str, ++ ) -> Result { ++ Ok(Content::UnitVariant(name, variant_index, variant)) ++ } ++ ++ fn serialize_newtype_struct( ++ self, ++ name: &'static str, ++ value: &T, ++ ) -> Result ++ where ++ T: Serialize, ++ { ++ Ok(Content::NewtypeStruct(name, Box::new(try!(value.serialize(self)))),) ++ } ++ ++ fn serialize_newtype_variant( ++ self, ++ name: &'static str, ++ variant_index: u32, ++ variant: &'static str, ++ value: &T, ++ ) -> Result ++ where ++ T: Serialize, ++ { ++ Ok( ++ Content::NewtypeVariant( ++ name, ++ variant_index, ++ variant, ++ Box::new(try!(value.serialize(self))), ++ ), ++ ) ++ } ++ ++ fn serialize_seq(self, len: Option) -> Result { ++ Ok( ++ SerializeSeq { ++ elements: Vec::with_capacity(len.unwrap_or(0)), ++ error: PhantomData, ++ }, ++ ) ++ } ++ ++ fn serialize_tuple(self, len: usize) -> Result { ++ Ok( ++ SerializeTuple { ++ elements: Vec::with_capacity(len), ++ error: PhantomData, ++ }, ++ ) ++ } ++ ++ fn serialize_tuple_struct( ++ self, ++ name: &'static str, ++ len: usize, ++ ) -> Result { ++ Ok( ++ SerializeTupleStruct { ++ name: name, ++ fields: Vec::with_capacity(len), ++ error: PhantomData, ++ }, ++ ) ++ } ++ ++ fn serialize_tuple_variant( ++ self, ++ name: &'static str, ++ variant_index: u32, ++ variant: &'static str, ++ len: usize, ++ ) -> Result { ++ Ok( ++ SerializeTupleVariant { ++ name: name, ++ variant_index: variant_index, ++ variant: variant, ++ fields: Vec::with_capacity(len), ++ error: PhantomData, ++ }, ++ ) ++ } ++ ++ fn serialize_map(self, len: Option) -> Result { ++ Ok( ++ SerializeMap { ++ entries: Vec::with_capacity(len.unwrap_or(0)), ++ key: None, ++ error: PhantomData, ++ }, ++ ) ++ } ++ ++ fn serialize_struct( ++ self, ++ name: &'static str, ++ len: usize, ++ ) -> Result { ++ Ok( ++ SerializeStruct { ++ name: name, ++ fields: Vec::with_capacity(len), ++ error: PhantomData, ++ }, ++ ) ++ } ++ ++ fn serialize_struct_variant( ++ self, ++ name: &'static str, ++ variant_index: u32, ++ variant: &'static str, ++ len: usize, ++ ) -> Result { ++ Ok( ++ SerializeStructVariant { ++ name: name, ++ variant_index: variant_index, ++ variant: variant, ++ fields: Vec::with_capacity(len), ++ error: PhantomData, ++ }, ++ ) ++ } ++ } ++ ++ struct SerializeSeq { ++ elements: Vec, ++ error: PhantomData, ++ } ++ ++ impl ser::SerializeSeq for SerializeSeq ++ where ++ E: ser::Error, ++ { ++ type Ok = Content; ++ type Error = E; ++ ++ fn serialize_element(&mut self, value: &T) -> Result<(), E> ++ where ++ T: Serialize, ++ { ++ let value = try!(value.serialize(ContentSerializer::::new())); ++ self.elements.push(value); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ Ok(Content::Seq(self.elements)) ++ } ++ } ++ ++ struct SerializeTuple { ++ elements: Vec, ++ error: PhantomData, ++ } ++ ++ impl ser::SerializeTuple for SerializeTuple ++ where ++ E: ser::Error, ++ { ++ type Ok = Content; ++ type Error = E; ++ ++ fn serialize_element(&mut self, value: &T) -> Result<(), E> ++ where ++ T: Serialize, ++ { ++ let value = try!(value.serialize(ContentSerializer::::new())); ++ self.elements.push(value); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ Ok(Content::Tuple(self.elements)) ++ } ++ } ++ ++ struct SerializeTupleStruct { ++ name: &'static str, ++ fields: Vec, ++ error: PhantomData, ++ } ++ ++ impl ser::SerializeTupleStruct for SerializeTupleStruct ++ where ++ E: ser::Error, ++ { ++ type Ok = Content; ++ type Error = E; ++ ++ fn serialize_field(&mut self, value: &T) -> Result<(), E> ++ where ++ T: Serialize, ++ { ++ let value = try!(value.serialize(ContentSerializer::::new())); ++ self.fields.push(value); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ Ok(Content::TupleStruct(self.name, self.fields)) ++ } ++ } ++ ++ struct SerializeTupleVariant { ++ name: &'static str, ++ variant_index: u32, ++ variant: &'static str, ++ fields: Vec, ++ error: PhantomData, ++ } ++ ++ impl ser::SerializeTupleVariant for SerializeTupleVariant ++ where ++ E: ser::Error, ++ { ++ type Ok = Content; ++ type Error = E; ++ ++ fn serialize_field(&mut self, value: &T) -> Result<(), E> ++ where ++ T: Serialize, ++ { ++ let value = try!(value.serialize(ContentSerializer::::new())); ++ self.fields.push(value); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ Ok(Content::TupleVariant(self.name, self.variant_index, self.variant, self.fields),) ++ } ++ } ++ ++ struct SerializeMap { ++ entries: Vec<(Content, Content)>, ++ key: Option, ++ error: PhantomData, ++ } ++ ++ impl ser::SerializeMap for SerializeMap ++ where ++ E: ser::Error, ++ { ++ type Ok = Content; ++ type Error = E; ++ ++ fn serialize_key(&mut self, key: &T) -> Result<(), E> ++ where ++ T: Serialize, ++ { ++ let key = try!(key.serialize(ContentSerializer::::new())); ++ self.key = Some(key); ++ Ok(()) ++ } ++ ++ fn serialize_value(&mut self, value: &T) -> Result<(), E> ++ where ++ T: Serialize, ++ { ++ let key = self.key ++ .take() ++ .expect("serialize_value called before serialize_key"); ++ let value = try!(value.serialize(ContentSerializer::::new())); ++ self.entries.push((key, value)); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ Ok(Content::Map(self.entries)) ++ } ++ ++ fn serialize_entry(&mut self, key: &K, value: &V) -> Result<(), E> ++ where ++ K: Serialize, ++ V: Serialize, ++ { ++ let key = try!(key.serialize(ContentSerializer::::new())); ++ let value = try!(value.serialize(ContentSerializer::::new())); ++ self.entries.push((key, value)); ++ Ok(()) ++ } ++ } ++ ++ struct SerializeStruct { ++ name: &'static str, ++ fields: Vec<(&'static str, Content)>, ++ error: PhantomData, ++ } ++ ++ impl ser::SerializeStruct for SerializeStruct ++ where ++ E: ser::Error, ++ { ++ type Ok = Content; ++ type Error = E; ++ ++ fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<(), E> ++ where ++ T: Serialize, ++ { ++ let value = try!(value.serialize(ContentSerializer::::new())); ++ self.fields.push((key, value)); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ Ok(Content::Struct(self.name, self.fields)) ++ } ++ } ++ ++ struct SerializeStructVariant { ++ name: &'static str, ++ variant_index: u32, ++ variant: &'static str, ++ fields: Vec<(&'static str, Content)>, ++ error: PhantomData, ++ } ++ ++ impl ser::SerializeStructVariant for SerializeStructVariant ++ where ++ E: ser::Error, ++ { ++ type Ok = Content; ++ type Error = E; ++ ++ fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<(), E> ++ where ++ T: Serialize, ++ { ++ let value = try!(value.serialize(ContentSerializer::::new())); ++ self.fields.push((key, value)); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ Ok(Content::StructVariant(self.name, self.variant_index, self.variant, self.fields),) ++ } ++ } ++} diff --cc vendor/serde-1.0.15/src/ser/impls.rs index 000000000,000000000..ea59b78dd new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/ser/impls.rs @@@ -1,0 -1,0 +1,632 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use lib::*; ++ ++use ser::{Serialize, SerializeTuple, Serializer}; ++ ++#[cfg(feature = "std")] ++use ser::Error; ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++macro_rules! primitive_impl { ++ ($ty:ident, $method:ident $($cast:tt)*) => { ++ impl Serialize for $ty { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ serializer.$method(*self $($cast)*) ++ } ++ } ++ } ++} ++ ++primitive_impl!(bool, serialize_bool); ++primitive_impl!(isize, serialize_i64 as i64); ++primitive_impl!(i8, serialize_i8); ++primitive_impl!(i16, serialize_i16); ++primitive_impl!(i32, serialize_i32); ++primitive_impl!(i64, serialize_i64); ++primitive_impl!(usize, serialize_u64 as u64); ++primitive_impl!(u8, serialize_u8); ++primitive_impl!(u16, serialize_u16); ++primitive_impl!(u32, serialize_u32); ++primitive_impl!(u64, serialize_u64); ++primitive_impl!(f32, serialize_f32); ++primitive_impl!(f64, serialize_f64); ++primitive_impl!(char, serialize_char); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++impl Serialize for str { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ serializer.serialize_str(self) ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++impl Serialize for String { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ serializer.serialize_str(self) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "std")] ++impl Serialize for CStr { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ serializer.serialize_bytes(self.to_bytes()) ++ } ++} ++ ++#[cfg(feature = "std")] ++impl Serialize for CString { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ serializer.serialize_bytes(self.to_bytes()) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++impl Serialize for Option ++where ++ T: Serialize, ++{ ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ match *self { ++ Some(ref value) => serializer.serialize_some(value), ++ None => serializer.serialize_none(), ++ } ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++impl Serialize for PhantomData { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ serializer.serialize_unit_struct("PhantomData") ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++// Does not require T: Serialize. ++impl Serialize for [T; 0] { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ try!(serializer.serialize_tuple(0)).end() ++ } ++} ++ ++macro_rules! array_impls { ++ ($($len:tt)+) => { ++ $( ++ impl Serialize for [T; $len] ++ where ++ T: Serialize, ++ { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ let mut seq = try!(serializer.serialize_tuple($len)); ++ for e in self { ++ try!(seq.serialize_element(e)); ++ } ++ seq.end() ++ } ++ } ++ )+ ++ } ++} ++ ++array_impls!(01 02 03 04 05 06 07 08 09 10 ++ 11 12 13 14 15 16 17 18 19 20 ++ 21 22 23 24 25 26 27 28 29 30 ++ 31 32); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++impl Serialize for [T] ++where ++ T: Serialize, ++{ ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ serializer.collect_seq(self) ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++macro_rules! seq_impl { ++ ($ty:ident < T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound:ident)* >) => { ++ impl Serialize for $ty ++ where ++ T: Serialize $(+ $tbound1 $(+ $tbound2)*)*, ++ $($typaram: $bound,)* ++ { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ serializer.collect_seq(self) ++ } ++ } ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++seq_impl!(BinaryHeap); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++seq_impl!(BTreeSet); ++ ++#[cfg(feature = "std")] ++seq_impl!(HashSet); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++seq_impl!(LinkedList); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++seq_impl!(Vec); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++seq_impl!(VecDeque); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "std")] ++impl Serialize for ops::Range ++where ++ Idx: Serialize, ++{ ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ use super::SerializeStruct; ++ let mut state = try!(serializer.serialize_struct("Range", 2)); ++ try!(state.serialize_field("start", &self.start)); ++ try!(state.serialize_field("end", &self.end)); ++ state.end() ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++impl Serialize for () { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ serializer.serialize_unit() ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++macro_rules! tuple_impls { ++ ($($len:expr => ($($n:tt $name:ident)+))+) => { ++ $( ++ impl<$($name),+> Serialize for ($($name,)+) ++ where ++ $($name: Serialize,)+ ++ { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ let mut tuple = try!(serializer.serialize_tuple($len)); ++ $( ++ try!(tuple.serialize_element(&self.$n)); ++ )+ ++ tuple.end() ++ } ++ } ++ )+ ++ } ++} ++ ++tuple_impls! { ++ 1 => (0 T0) ++ 2 => (0 T0 1 T1) ++ 3 => (0 T0 1 T1 2 T2) ++ 4 => (0 T0 1 T1 2 T2 3 T3) ++ 5 => (0 T0 1 T1 2 T2 3 T3 4 T4) ++ 6 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5) ++ 7 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6) ++ 8 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7) ++ 9 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8) ++ 10 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9) ++ 11 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10) ++ 12 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11) ++ 13 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12) ++ 14 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13) ++ 15 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14) ++ 16 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14 15 T15) ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++macro_rules! map_impl { ++ ($ty:ident < K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound:ident)* >) => { ++ impl Serialize for $ty ++ where ++ K: Serialize $(+ $kbound1 $(+ $kbound2)*)*, ++ V: Serialize, ++ $($typaram: $bound,)* ++ { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ serializer.collect_map(self) ++ } ++ } ++ } ++} ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++map_impl!(BTreeMap); ++ ++#[cfg(feature = "std")] ++map_impl!(HashMap); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++macro_rules! deref_impl { ++ ($($desc:tt)+) => { ++ impl $($desc)+ { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ (**self).serialize(serializer) ++ } ++ } ++ }; ++} ++ ++deref_impl!(<'a, T: ?Sized> Serialize for &'a T where T: Serialize); ++deref_impl!(<'a, T: ?Sized> Serialize for &'a mut T where T: Serialize); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++deref_impl!( Serialize for Box where T: Serialize); ++ ++#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))] ++deref_impl!( Serialize for Rc where T: Serialize); ++ ++#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))] ++deref_impl!( Serialize for Arc where T: Serialize); ++ ++#[cfg(any(feature = "std", feature = "alloc"))] ++deref_impl!(<'a, T: ?Sized> Serialize for Cow<'a, T> where T: Serialize + ToOwned); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "unstable")] ++impl Serialize for NonZero ++where ++ T: Serialize + Zeroable + Clone, ++{ ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ self.clone().get().serialize(serializer) ++ } ++} ++ ++impl Serialize for Cell ++where ++ T: Serialize + Copy, ++{ ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ self.get().serialize(serializer) ++ } ++} ++ ++impl Serialize for RefCell ++where ++ T: Serialize, ++{ ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ self.borrow().serialize(serializer) ++ } ++} ++ ++#[cfg(feature = "std")] ++impl Serialize for Mutex ++where ++ T: Serialize, ++{ ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ match self.lock() { ++ Ok(locked) => locked.serialize(serializer), ++ Err(_) => Err(S::Error::custom("lock poison error while serializing")), ++ } ++ } ++} ++ ++#[cfg(feature = "std")] ++impl Serialize for RwLock ++where ++ T: Serialize, ++{ ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ match self.read() { ++ Ok(locked) => locked.serialize(serializer), ++ Err(_) => Err(S::Error::custom("lock poison error while serializing")), ++ } ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++impl Serialize for Result ++where ++ T: Serialize, ++ E: Serialize, ++{ ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ match *self { ++ Result::Ok(ref value) => serializer.serialize_newtype_variant("Result", 0, "Ok", value), ++ Result::Err(ref value) => { ++ serializer.serialize_newtype_variant("Result", 1, "Err", value) ++ } ++ } ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "std")] ++impl Serialize for Duration { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ use super::SerializeStruct; ++ let mut state = try!(serializer.serialize_struct("Duration", 2)); ++ try!(state.serialize_field("secs", &self.as_secs())); ++ try!(state.serialize_field("nanos", &self.subsec_nanos())); ++ state.end() ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "std")] ++impl Serialize for SystemTime { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ use super::SerializeStruct; ++ let duration_since_epoch = self.duration_since(UNIX_EPOCH).expect("SystemTime must be later than UNIX_EPOCH"); ++ let mut state = try!(serializer.serialize_struct("SystemTime", 2)); ++ try!(state.serialize_field("secs_since_epoch", &duration_since_epoch.as_secs())); ++ try!(state.serialize_field("nanos_since_epoch", &duration_since_epoch.subsec_nanos())); ++ state.end() ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// Serialize a value that implements `Display` as a string, when that string is ++/// statically known to never have more than a constant `MAX_LEN` bytes. ++/// ++/// Panics if the `Display` impl tries to write more than `MAX_LEN` bytes. ++#[cfg(feature = "std")] ++macro_rules! serialize_display_bounded_length { ++ ($value:expr, $max:expr, $serializer:expr) => {{ ++ let mut buffer: [u8; $max] = unsafe { mem::uninitialized() }; ++ let remaining_len = { ++ let mut remaining = &mut buffer[..]; ++ write!(remaining, "{}", $value).unwrap(); ++ remaining.len() ++ }; ++ let written_len = buffer.len() - remaining_len; ++ let written = &buffer[..written_len]; ++ ++ // write! only provides fmt::Formatter to Display implementations, which ++ // has methods write_str and write_char but no method to write arbitrary ++ // bytes. Therefore `written` must be valid UTF-8. ++ let written_str = unsafe { ++ str::from_utf8_unchecked(written) ++ }; ++ $serializer.serialize_str(written_str) ++ }} ++} ++ ++#[cfg(feature = "std")] ++impl Serialize for net::IpAddr { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ match *self { ++ net::IpAddr::V4(ref a) => a.serialize(serializer), ++ net::IpAddr::V6(ref a) => a.serialize(serializer), ++ } ++ } ++} ++ ++#[cfg(feature = "std")] ++impl Serialize for net::Ipv4Addr { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ /// "101.102.103.104".len() ++ const MAX_LEN: usize = 15; ++ serialize_display_bounded_length!(self, MAX_LEN, serializer) ++ } ++} ++ ++#[cfg(feature = "std")] ++impl Serialize for net::Ipv6Addr { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ /// "1000:1002:1003:1004:1005:1006:1007:1008".len() ++ const MAX_LEN: usize = 39; ++ serialize_display_bounded_length!(self, MAX_LEN, serializer) ++ } ++} ++ ++#[cfg(feature = "std")] ++impl Serialize for net::SocketAddr { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ match *self { ++ net::SocketAddr::V4(ref addr) => addr.serialize(serializer), ++ net::SocketAddr::V6(ref addr) => addr.serialize(serializer), ++ } ++ } ++} ++ ++#[cfg(feature = "std")] ++impl Serialize for net::SocketAddrV4 { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ /// "101.102.103.104:65000".len() ++ const MAX_LEN: usize = 21; ++ serialize_display_bounded_length!(self, MAX_LEN, serializer) ++ } ++} ++ ++#[cfg(feature = "std")] ++impl Serialize for net::SocketAddrV6 { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ /// "[1000:1002:1003:1004:1005:1006:1007:1008]:65000".len() ++ const MAX_LEN: usize = 47; ++ serialize_display_bounded_length!(self, MAX_LEN, serializer) ++ } ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++#[cfg(feature = "std")] ++impl Serialize for Path { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ match self.to_str() { ++ Some(s) => s.serialize(serializer), ++ None => Err(Error::custom("path contains invalid UTF-8 characters")), ++ } ++ } ++} ++ ++#[cfg(feature = "std")] ++impl Serialize for PathBuf { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ self.as_path().serialize(serializer) ++ } ++} ++ ++#[cfg(all(feature = "std", any(unix, windows)))] ++impl Serialize for OsStr { ++ #[cfg(unix)] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ use std::os::unix::ffi::OsStrExt; ++ serializer.serialize_newtype_variant("OsString", 0, "Unix", self.as_bytes()) ++ } ++ ++ #[cfg(windows)] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ use std::os::windows::ffi::OsStrExt; ++ let val = self.encode_wide().collect::>(); ++ serializer.serialize_newtype_variant("OsString", 1, "Windows", &val) ++ } ++} ++ ++#[cfg(all(feature = "std", any(unix, windows)))] ++impl Serialize for OsString { ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ self.as_os_str().serialize(serializer) ++ } ++} diff --cc vendor/serde-1.0.15/src/ser/impossible.rs index 000000000,000000000..f72748f69 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/ser/impossible.rs @@@ -1,0 -1,0 +1,227 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! This module contains `Impossible` serializer and its implementations. ++ ++use lib::*; ++ ++use ser::{self, Serialize, SerializeSeq, SerializeTuple, SerializeTupleStruct, ++ SerializeTupleVariant, SerializeMap, SerializeStruct, SerializeStructVariant}; ++ ++/// Helper type for implementing a `Serializer` that does not support ++/// serializing one of the compound types. ++/// ++/// This type cannot be instantiated, but implements every one of the traits ++/// corresponding to the [`Serializer`] compound types: [`SerializeSeq`], ++/// [`SerializeTuple`], [`SerializeTupleStruct`], [`SerializeTupleVariant`], ++/// [`SerializeMap`], [`SerializeStruct`], and [`SerializeStructVariant`]. ++/// ++/// ```rust ++/// # #[macro_use] ++/// # extern crate serde; ++/// # ++/// # use serde::ser::{Serializer, Impossible}; ++/// # use serde::private::ser::Error; ++/// # ++/// # struct MySerializer; ++/// # ++/// impl Serializer for MySerializer { ++/// type Ok = (); ++/// type Error = Error; ++/// ++/// type SerializeSeq = Impossible<(), Error>; ++/// /* other associated types */ ++/// ++/// /// This data format does not support serializing sequences. ++/// fn serialize_seq(self, ++/// len: Option) ++/// -> Result { ++/// // Given Impossible cannot be instantiated, the only ++/// // thing we can do here is to return an error. ++/// # stringify! { ++/// Err(...) ++/// # }; ++/// # unimplemented!() ++/// } ++/// ++/// /* other Serializer methods */ ++/// # __serialize_unimplemented! { ++/// # bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str bytes none some ++/// # unit unit_struct unit_variant newtype_struct newtype_variant ++/// # tuple tuple_struct tuple_variant map struct struct_variant ++/// # } ++/// } ++/// # ++/// # fn main() {} ++/// ``` ++/// ++/// [`Serializer`]: trait.Serializer.html ++/// [`SerializeSeq`]: trait.SerializeSeq.html ++/// [`SerializeTuple`]: trait.SerializeTuple.html ++/// [`SerializeTupleStruct`]: trait.SerializeTupleStruct.html ++/// [`SerializeTupleVariant`]: trait.SerializeTupleVariant.html ++/// [`SerializeMap`]: trait.SerializeMap.html ++/// [`SerializeStruct`]: trait.SerializeStruct.html ++/// [`SerializeStructVariant`]: trait.SerializeStructVariant.html ++pub struct Impossible { ++ void: Void, ++ ok: PhantomData, ++ error: PhantomData, ++} ++ ++enum Void {} ++ ++impl SerializeSeq for Impossible ++where ++ Error: ser::Error, ++{ ++ type Ok = Ok; ++ type Error = Error; ++ ++ fn serialize_element(&mut self, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ let _ = value; ++ match self.void {} ++ } ++ ++ fn end(self) -> Result { ++ match self.void {} ++ } ++} ++ ++impl SerializeTuple for Impossible ++where ++ Error: ser::Error, ++{ ++ type Ok = Ok; ++ type Error = Error; ++ ++ fn serialize_element(&mut self, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ let _ = value; ++ match self.void {} ++ } ++ ++ fn end(self) -> Result { ++ match self.void {} ++ } ++} ++ ++impl SerializeTupleStruct for Impossible ++where ++ Error: ser::Error, ++{ ++ type Ok = Ok; ++ type Error = Error; ++ ++ fn serialize_field(&mut self, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ let _ = value; ++ match self.void {} ++ } ++ ++ fn end(self) -> Result { ++ match self.void {} ++ } ++} ++ ++impl SerializeTupleVariant for Impossible ++where ++ Error: ser::Error, ++{ ++ type Ok = Ok; ++ type Error = Error; ++ ++ fn serialize_field(&mut self, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ let _ = value; ++ match self.void {} ++ } ++ ++ fn end(self) -> Result { ++ match self.void {} ++ } ++} ++ ++impl SerializeMap for Impossible ++where ++ Error: ser::Error, ++{ ++ type Ok = Ok; ++ type Error = Error; ++ ++ fn serialize_key(&mut self, key: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ let _ = key; ++ match self.void {} ++ } ++ ++ fn serialize_value(&mut self, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ let _ = value; ++ match self.void {} ++ } ++ ++ fn end(self) -> Result { ++ match self.void {} ++ } ++} ++ ++impl SerializeStruct for Impossible ++where ++ Error: ser::Error, ++{ ++ type Ok = Ok; ++ type Error = Error; ++ ++ fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ let _ = key; ++ let _ = value; ++ match self.void {} ++ } ++ ++ fn end(self) -> Result { ++ match self.void {} ++ } ++} ++ ++impl SerializeStructVariant for Impossible ++where ++ Error: ser::Error, ++{ ++ type Ok = Ok; ++ type Error = Error; ++ ++ fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ let _ = key; ++ let _ = value; ++ match self.void {} ++ } ++ ++ fn end(self) -> Result { ++ match self.void {} ++ } ++} diff --cc vendor/serde-1.0.15/src/ser/mod.rs index 000000000,000000000..e934adb96 new file mode 100644 --- /dev/null +++ b/vendor/serde-1.0.15/src/ser/mod.rs @@@ -1,0 -1,0 +1,1830 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! Generic data structure serialization framework. ++//! ++//! The two most important traits in this module are [`Serialize`] and ++//! [`Serializer`]. ++//! ++//! - **A type that implements `Serialize` is a data structure** that can be ++//! serialized to any data format supported by Serde, and conversely ++//! - **A type that implements `Serializer` is a data format** that can ++//! serialize any data structure supported by Serde. ++//! ++//! # The Serialize trait ++//! ++//! Serde provides [`Serialize`] implementations for many Rust primitive and ++//! standard library types. The complete list is below. All of these can be ++//! serialized using Serde out of the box. ++//! ++//! Additionally, Serde provides a procedural macro called [`serde_derive`] to ++//! automatically generate [`Serialize`] implementations for structs and enums ++//! in your program. See the [codegen section of the manual] for how to use ++//! this. ++//! ++//! In rare cases it may be necessary to implement [`Serialize`] manually for ++//! some type in your program. See the [Implementing `Serialize`] section of the ++//! manual for more about this. ++//! ++//! Third-party crates may provide [`Serialize`] implementations for types that ++//! they expose. For example the [`linked-hash-map`] crate provides a ++//! [`LinkedHashMap`] type that is serializable by Serde because the crate ++//! provides an implementation of [`Serialize`] for it. ++//! ++//! # The Serializer trait ++//! ++//! [`Serializer`] implementations are provided by third-party crates, for ++//! example [`serde_json`], [`serde_yaml`] and [`bincode`]. ++//! ++//! A partial list of well-maintained formats is given on the [Serde ++//! website][data formats]. ++//! ++//! # Implementations of Serialize provided by Serde ++//! ++//! - **Primitive types**: ++//! - bool ++//! - i8, i16, i32, i64, isize ++//! - u8, u16, u32, u64, usize ++//! - f32, f64 ++//! - char ++//! - str ++//! - &T and &mut T ++//! - **Compound types**: ++//! - [T] ++//! - [T; 0] through [T; 32] ++//! - tuples up to size 16 ++//! - **Common standard library types**: ++//! - String ++//! - Option\ ++//! - Result\ ++//! - PhantomData\ ++//! - **Wrapper types**: ++//! - Box\ ++//! - Rc\ ++//! - Arc\ ++//! - Cow\<'a, T\> ++//! - Cell\ ++//! - RefCell\ ++//! - Mutex\ ++//! - RwLock\ ++//! - **Collection types**: ++//! - BTreeMap\ ++//! - BTreeSet\ ++//! - BinaryHeap\ ++//! - HashMap\ ++//! - HashSet\ ++//! - LinkedList\ ++//! - VecDeque\ ++//! - Vec\ ++//! - EnumSet\ (unstable) ++//! - **FFI types**: ++//! - CStr ++//! - CString ++//! - OsStr ++//! - OsString ++//! - **Miscellaneous standard library types**: ++//! - Duration ++//! - SystemTime ++//! - Path ++//! - PathBuf ++//! - Range\ ++//! - NonZero\ (unstable) ++//! - **Net types**: ++//! - IpAddr ++//! - Ipv4Addr ++//! - Ipv6Addr ++//! - SocketAddr ++//! - SocketAddrV4 ++//! - SocketAddrV6 ++//! ++//! [Implementing `Serialize`]: https://serde.rs/impl-serialize.html ++//! [`LinkedHashMap`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html ++//! [`Serialize`]: ../trait.Serialize.html ++//! [`Serializer`]: ../trait.Serializer.html ++//! [`bincode`]: https://github.com/TyOverby/bincode ++//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map ++//! [`serde_derive`]: https://crates.io/crates/serde_derive ++//! [`serde_json`]: https://github.com/serde-rs/json ++//! [`serde_yaml`]: https://github.com/dtolnay/serde-yaml ++//! [codegen section of the manual]: https://serde.rs/codegen.html ++//! [data formats]: https://serde.rs/#data-formats ++ ++use lib::*; ++ ++mod impls; ++mod impossible; ++ ++pub use self::impossible::Impossible; ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++macro_rules! declare_error_trait { ++ (Error: Sized $(+ $($supertrait:ident)::+)*) => { ++ /// Trait used by `Serialize` implementations to generically construct ++ /// errors belonging to the `Serializer` against which they are ++ /// currently running. ++ pub trait Error: Sized $(+ $($supertrait)::+)* { ++ /// Used when a [`Serialize`] implementation encounters any error ++ /// while serializing a type. ++ /// ++ /// The message should not be capitalized and should not end with a ++ /// period. ++ /// ++ /// For example, a filesystem [`Path`] may refuse to serialize ++ /// itself if it contains invalid UTF-8 data. ++ /// ++ /// ```rust ++ /// # struct Path; ++ /// # ++ /// # impl Path { ++ /// # fn to_str(&self) -> Option<&str> { ++ /// # unimplemented!() ++ /// # } ++ /// # } ++ /// # ++ /// use serde::ser::{self, Serialize, Serializer}; ++ /// ++ /// impl Serialize for Path { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// match self.to_str() { ++ /// Some(s) => serializer.serialize_str(s), ++ /// None => Err(ser::Error::custom("path contains invalid UTF-8 characters")), ++ /// } ++ /// } ++ /// } ++ /// ``` ++ /// ++ /// [`Path`]: https://doc.rust-lang.org/std/path/struct.Path.html ++ /// [`Serialize`]: ../trait.Serialize.html ++ fn custom(msg: T) -> Self ++ where ++ T: Display; ++ } ++ } ++} ++ ++#[cfg(feature = "std")] ++declare_error_trait!(Error: Sized + error::Error); ++ ++#[cfg(not(feature = "std"))] ++declare_error_trait!(Error: Sized + Debug + Display); ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A **data structure** that can be serialized into any data format supported ++/// by Serde. ++/// ++/// Serde provides `Serialize` implementations for many Rust primitive and ++/// standard library types. The complete list is [here][ser]. All of these can ++/// be serialized using Serde out of the box. ++/// ++/// Additionally, Serde provides a procedural macro called [`serde_derive`] to ++/// automatically generate `Serialize` implementations for structs and enums in ++/// your program. See the [codegen section of the manual] for how to use this. ++/// ++/// In rare cases it may be necessary to implement `Serialize` manually for some ++/// type in your program. See the [Implementing `Serialize`] section of the ++/// manual for more about this. ++/// ++/// Third-party crates may provide `Serialize` implementations for types that ++/// they expose. For example the [`linked-hash-map`] crate provides a ++/// [`LinkedHashMap`] type that is serializable by Serde because the crate ++/// provides an implementation of `Serialize` for it. ++/// ++/// [Implementing `Serialize`]: https://serde.rs/impl-serialize.html ++/// [`LinkedHashMap`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html ++/// [`linked-hash-map`]: https://crates.io/crates/linked-hash-map ++/// [`serde_derive`]: https://crates.io/crates/serde_derive ++/// [codegen section of the manual]: https://serde.rs/codegen.html ++/// [ser]: https://docs.serde.rs/serde/ser/index.html ++pub trait Serialize { ++ /// Serialize this value into the given Serde serializer. ++ /// ++ /// See the [Implementing `Serialize`] section of the manual for more ++ /// information about how to implement this method. ++ /// ++ /// ```rust ++ /// use serde::ser::{Serialize, Serializer, SerializeStruct}; ++ /// ++ /// struct Person { ++ /// name: String, ++ /// age: u8, ++ /// phones: Vec, ++ /// } ++ /// ++ /// // This is what #[derive(Serialize)] would generate. ++ /// impl Serialize for Person { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// let mut s = serializer.serialize_struct("Person", 3)?; ++ /// s.serialize_field("name", &self.name)?; ++ /// s.serialize_field("age", &self.age)?; ++ /// s.serialize_field("phones", &self.phones)?; ++ /// s.end() ++ /// } ++ /// } ++ /// ``` ++ /// ++ /// [Implementing `Serialize`]: https://serde.rs/impl-serialize.html ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer; ++} ++ ++//////////////////////////////////////////////////////////////////////////////// ++ ++/// A **data format** that can serialize any data structure supported by Serde. ++/// ++/// The role of this trait is to define the serialization half of the Serde data ++/// model, which is a way to categorize every Rust data structure into one of 27 ++/// possible types. Each method of the `Serializer` trait corresponds to one of ++/// the types of the data model. ++/// ++/// Implementations of `Serialize` map themselves into this data model by ++/// invoking exactly one of the `Serializer` methods. ++/// ++/// The types that make up the Serde data model are: ++/// ++/// - **12 primitive types** ++/// - bool ++/// - i8, i16, i32, i64 ++/// - u8, u16, u32, u64 ++/// - f32, f64 ++/// - char ++/// - **string** ++/// - UTF-8 bytes with a length and no null terminator. ++/// - When serializing, all strings are handled equally. When deserializing, ++/// there are three flavors of strings: transient, owned, and borrowed. ++/// - **byte array** - [u8] ++/// - Similar to strings, during deserialization byte arrays can be transient, ++/// owned, or borrowed. ++/// - **option** ++/// - Either none or some value. ++/// - **unit** ++/// - The type of `()` in Rust. It represents an anonymous value containing no ++/// data. ++/// - **unit_struct** ++/// - For example `struct Unit` or `PhantomData`. It represents a named value ++/// containing no data. ++/// - **unit_variant** ++/// - For example the `E::A` and `E::B` in `enum E { A, B }`. ++/// - **newtype_struct** ++/// - For example `struct Millimeters(u8)`. ++/// - **newtype_variant** ++/// - For example the `E::N` in `enum E { N(u8) }`. ++/// - **seq** ++/// - A variably sized heterogeneous sequence of values, for example `Vec` or ++/// `HashSet`. When serializing, the length may or may not be known before ++/// iterating through all the data. When deserializing, the length is determined ++/// by looking at the serialized data. ++/// - **tuple** ++/// - A statically sized heterogeneous sequence of values for which the length ++/// will be known at deserialization time without looking at the serialized ++/// data, for example `(u8,)` or `(String, u64, Vec)` or `[u64; 10]`. ++/// - **tuple_struct** ++/// - A named tuple, for example `struct Rgb(u8, u8, u8)`. ++/// - **tuple_variant** ++/// - For example the `E::T` in `enum E { T(u8, u8) }`. ++/// - **map** ++/// - A heterogeneous key-value pairing, for example `BTreeMap`. ++/// - **struct** ++/// - A heterogeneous key-value pairing in which the keys are strings and will be ++/// known at deserialization time without looking at the serialized data, for ++/// example `struct S { r: u8, g: u8, b: u8 }`. ++/// - **struct_variant** ++/// - For example the `E::S` in `enum E { S { r: u8, g: u8, b: u8 } }`. ++/// ++/// Many Serde serializers produce text or binary data as output, for example ++/// JSON or Bincode. This is not a requirement of the `Serializer` trait, and ++/// there are serializers that do not produce text or binary output. One example ++/// is the `serde_json::value::Serializer` (distinct from the main `serde_json` ++/// serializer) that produces a `serde_json::Value` data structure in memory as ++/// output. ++pub trait Serializer: Sized { ++ /// The output type produced by this `Serializer` during successful ++ /// serialization. Most serializers that produce text or binary output ++ /// should set `Ok = ()` and serialize into an [`io::Write`] or buffer ++ /// contained within the `Serializer` instance. Serializers that build ++ /// in-memory data structures may be simplified by using `Ok` to propagate ++ /// the data structure around. ++ /// ++ /// [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html ++ type Ok; ++ ++ /// The error type when some error occurs during serialization. ++ type Error: Error; ++ ++ /// Type returned from [`serialize_seq`] for serializing the content of the ++ /// sequence. ++ /// ++ /// [`serialize_seq`]: #tymethod.serialize_seq ++ type SerializeSeq: SerializeSeq; ++ ++ /// Type returned from [`serialize_tuple`] for serializing the content of ++ /// the tuple. ++ /// ++ /// [`serialize_tuple`]: #tymethod.serialize_tuple ++ type SerializeTuple: SerializeTuple; ++ ++ /// Type returned from [`serialize_tuple_struct`] for serializing the ++ /// content of the tuple struct. ++ /// ++ /// [`serialize_tuple_struct`]: #tymethod.serialize_tuple_struct ++ type SerializeTupleStruct: SerializeTupleStruct; ++ ++ /// Type returned from [`serialize_tuple_variant`] for serializing the ++ /// content of the tuple variant. ++ /// ++ /// [`serialize_tuple_variant`]: #tymethod.serialize_tuple_variant ++ type SerializeTupleVariant: SerializeTupleVariant; ++ ++ /// Type returned from [`serialize_map`] for serializing the content of the ++ /// map. ++ /// ++ /// [`serialize_map`]: #tymethod.serialize_map ++ type SerializeMap: SerializeMap; ++ ++ /// Type returned from [`serialize_struct`] for serializing the content of ++ /// the struct. ++ /// ++ /// [`serialize_struct`]: #tymethod.serialize_struct ++ type SerializeStruct: SerializeStruct; ++ ++ /// Type returned from [`serialize_struct_variant`] for serializing the ++ /// content of the struct variant. ++ /// ++ /// [`serialize_struct_variant`]: #tymethod.serialize_struct_variant ++ type SerializeStructVariant: SerializeStructVariant; ++ ++ /// Serialize a `bool` value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for bool { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_bool(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_bool(self, v: bool) -> Result; ++ ++ /// Serialize an `i8` value. ++ /// ++ /// If the format does not differentiate between `i8` and `i64`, a ++ /// reasonable implementation would be to cast the value to `i64` and ++ /// forward to `serialize_i64`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for i8 { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_i8(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_i8(self, v: i8) -> Result; ++ ++ /// Serialize an `i16` value. ++ /// ++ /// If the format does not differentiate between `i16` and `i64`, a ++ /// reasonable implementation would be to cast the value to `i64` and ++ /// forward to `serialize_i64`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for i16 { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_i16(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_i16(self, v: i16) -> Result; ++ ++ /// Serialize an `i32` value. ++ /// ++ /// If the format does not differentiate between `i32` and `i64`, a ++ /// reasonable implementation would be to cast the value to `i64` and ++ /// forward to `serialize_i64`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for i32 { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_i32(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_i32(self, v: i32) -> Result; ++ ++ /// Serialize an `i64` value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for i64 { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_i64(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_i64(self, v: i64) -> Result; ++ ++ /// Serialize a `u8` value. ++ /// ++ /// If the format does not differentiate between `u8` and `u64`, a ++ /// reasonable implementation would be to cast the value to `u64` and ++ /// forward to `serialize_u64`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for u8 { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_u8(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_u8(self, v: u8) -> Result; ++ ++ /// Serialize a `u16` value. ++ /// ++ /// If the format does not differentiate between `u16` and `u64`, a ++ /// reasonable implementation would be to cast the value to `u64` and ++ /// forward to `serialize_u64`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for u16 { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_u16(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_u16(self, v: u16) -> Result; ++ ++ /// Serialize a `u32` value. ++ /// ++ /// If the format does not differentiate between `u32` and `u64`, a ++ /// reasonable implementation would be to cast the value to `u64` and ++ /// forward to `serialize_u64`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for u32 { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_u32(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_u32(self, v: u32) -> Result; ++ ++ /// Serialize a `u64` value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for u64 { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_u64(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_u64(self, v: u64) -> Result; ++ ++ /// Serialize an `f32` value. ++ /// ++ /// If the format does not differentiate between `f32` and `f64`, a ++ /// reasonable implementation would be to cast the value to `f64` and ++ /// forward to `serialize_f64`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for f32 { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_f32(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_f32(self, v: f32) -> Result; ++ ++ /// Serialize an `f64` value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for f64 { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_f64(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_f64(self, v: f64) -> Result; ++ ++ /// Serialize a character. ++ /// ++ /// If the format does not support characters, it is reasonable to serialize ++ /// it as a single element `str` or a `u32`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for char { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_char(*self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_char(self, v: char) -> Result; ++ ++ /// Serialize a `&str`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for str { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_str(self) ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_str(self, v: &str) -> Result; ++ ++ /// Serialize a chunk of raw byte data. ++ /// ++ /// Enables serializers to serialize byte slices more compactly or more ++ /// efficiently than other types of slices. If no efficient implementation ++ /// is available, a reasonable implementation would be to forward to ++ /// `serialize_seq`. If forwarded, the implementation looks usually just ++ /// like this: ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::ser::{Serializer, SerializeSeq}; ++ /// # use serde::private::ser::Error; ++ /// # ++ /// # struct MySerializer; ++ /// # ++ /// # impl Serializer for MySerializer { ++ /// # type Ok = (); ++ /// # type Error = Error; ++ /// # ++ /// fn serialize_bytes(self, v: &[u8]) -> Result { ++ /// let mut seq = self.serialize_seq(Some(v.len()))?; ++ /// for b in v { ++ /// seq.serialize_element(b)?; ++ /// } ++ /// seq.end() ++ /// } ++ /// # ++ /// # __serialize_unimplemented! { ++ /// # bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str none some ++ /// # unit unit_struct unit_variant newtype_struct newtype_variant ++ /// # seq tuple tuple_struct tuple_variant map struct struct_variant ++ /// # } ++ /// # } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_bytes(self, v: &[u8]) -> Result; ++ ++ /// Serialize a [`None`] value. ++ /// ++ /// ```rust ++ /// # extern crate serde; ++ /// # ++ /// # use serde::{Serialize, Serializer}; ++ /// # ++ /// # enum Option { ++ /// # Some(T), ++ /// # None, ++ /// # } ++ /// # ++ /// # use Option::{Some, None}; ++ /// # ++ /// impl Serialize for Option ++ /// where T: Serialize ++ /// { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// match *self { ++ /// Some(ref value) => serializer.serialize_some(value), ++ /// None => serializer.serialize_none(), ++ /// } ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ /// ++ /// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None ++ fn serialize_none(self) -> Result; ++ ++ /// Serialize a [`Some(T)`] value. ++ /// ++ /// ```rust ++ /// # extern crate serde; ++ /// # ++ /// # use serde::{Serialize, Serializer}; ++ /// # ++ /// # enum Option { ++ /// # Some(T), ++ /// # None, ++ /// # } ++ /// # ++ /// # use Option::{Some, None}; ++ /// # ++ /// impl Serialize for Option ++ /// where T: Serialize ++ /// { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// match *self { ++ /// Some(ref value) => serializer.serialize_some(value), ++ /// None => serializer.serialize_none(), ++ /// } ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ /// ++ /// [`Some(T)`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.Some ++ fn serialize_some(self, value: &T) -> Result ++ where ++ T: Serialize; ++ ++ /// Serialize a `()` value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde; ++ /// # ++ /// # use serde::Serializer; ++ /// # ++ /// # __private_serialize!(); ++ /// # ++ /// impl Serialize for () { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_unit() ++ /// } ++ /// } ++ /// # ++ /// # fn main() {} ++ /// ``` ++ fn serialize_unit(self) -> Result; ++ ++ /// Serialize a unit struct like `struct Unit` or `PhantomData`. ++ /// ++ /// A reasonable implementation would be to forward to `serialize_unit`. ++ /// ++ /// ```rust ++ /// use serde::{Serialize, Serializer}; ++ /// ++ /// struct Nothing; ++ /// ++ /// impl Serialize for Nothing { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_unit_struct("Nothing") ++ /// } ++ /// } ++ /// ``` ++ fn serialize_unit_struct(self, name: &'static str) -> Result; ++ ++ /// Serialize a unit variant like `E::A` in `enum E { A, B }`. ++ /// ++ /// The `name` is the name of the enum, the `variant_index` is the index of ++ /// this variant within the enum, and the `variant` is the name of the ++ /// variant. ++ /// ++ /// ```rust ++ /// use serde::{Serialize, Serializer}; ++ /// ++ /// enum E { ++ /// A, ++ /// B, ++ /// } ++ /// ++ /// impl Serialize for E { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// match *self { ++ /// E::A => serializer.serialize_unit_variant("E", 0, "A"), ++ /// E::B => serializer.serialize_unit_variant("E", 1, "B"), ++ /// } ++ /// } ++ /// } ++ /// ``` ++ fn serialize_unit_variant( ++ self, ++ name: &'static str, ++ variant_index: u32, ++ variant: &'static str, ++ ) -> Result; ++ ++ /// Serialize a newtype struct like `struct Millimeters(u8)`. ++ /// ++ /// Serializers are encouraged to treat newtype structs as insignificant ++ /// wrappers around the data they contain. A reasonable implementation would ++ /// be to forward to `value.serialize(self)`. ++ /// ++ /// ```rust ++ /// use serde::{Serialize, Serializer}; ++ /// ++ /// struct Millimeters(u8); ++ /// ++ /// impl Serialize for Millimeters { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.serialize_newtype_struct("Millimeters", &self.0) ++ /// } ++ /// } ++ /// ``` ++ fn serialize_newtype_struct( ++ self, ++ name: &'static str, ++ value: &T, ++ ) -> Result ++ where ++ T: Serialize; ++ ++ /// Serialize a newtype variant like `E::N` in `enum E { N(u8) }`. ++ /// ++ /// The `name` is the name of the enum, the `variant_index` is the index of ++ /// this variant within the enum, and the `variant` is the name of the ++ /// variant. The `value` is the data contained within this newtype variant. ++ /// ++ /// ```rust ++ /// use serde::{Serialize, Serializer}; ++ /// ++ /// enum E { ++ /// M(String), ++ /// N(u8), ++ /// } ++ /// ++ /// impl Serialize for E { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// match *self { ++ /// E::M(ref s) => serializer.serialize_newtype_variant("E", 0, "M", s), ++ /// E::N(n) => serializer.serialize_newtype_variant("E", 1, "N", &n), ++ /// } ++ /// } ++ /// } ++ /// ``` ++ fn serialize_newtype_variant( ++ self, ++ name: &'static str, ++ variant_index: u32, ++ variant: &'static str, ++ value: &T, ++ ) -> Result ++ where ++ T: Serialize; ++ ++ /// Begin to serialize a variably sized sequence. This call must be ++ /// followed by zero or more calls to `serialize_element`, then a call to ++ /// `end`. ++ /// ++ /// The argument is the number of elements in the sequence, which may or may ++ /// not be computable before the sequence is iterated. Some serializers only ++ /// support sequences whose length is known up front. ++ /// ++ /// ```rust ++ /// # use std::marker::PhantomData; ++ /// # ++ /// # struct Vec(PhantomData); ++ /// # ++ /// # impl Vec { ++ /// # fn len(&self) -> usize { ++ /// # unimplemented!() ++ /// # } ++ /// # } ++ /// # ++ /// # impl<'a, T> IntoIterator for &'a Vec { ++ /// # type Item = &'a T; ++ /// # type IntoIter = Box>; ++ /// # ++ /// # fn into_iter(self) -> Self::IntoIter { ++ /// # unimplemented!() ++ /// # } ++ /// # } ++ /// # ++ /// use serde::ser::{Serialize, Serializer, SerializeSeq}; ++ /// ++ /// impl Serialize for Vec ++ /// where T: Serialize ++ /// { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// let mut seq = serializer.serialize_seq(Some(self.len()))?; ++ /// for element in self { ++ /// seq.serialize_element(element)?; ++ /// } ++ /// seq.end() ++ /// } ++ /// } ++ /// ``` ++ fn serialize_seq(self, len: Option) -> Result; ++ ++ /// Begin to serialize a statically sized sequence whose length will be ++ /// known at deserialization time without looking at the serialized data. ++ /// This call must be followed by zero or more calls to `serialize_element`, ++ /// then a call to `end`. ++ /// ++ /// ```rust ++ /// use serde::ser::{Serialize, Serializer, SerializeTuple}; ++ /// ++ /// # mod fool { ++ /// # trait Serialize {} ++ /// impl Serialize for (A, B, C) ++ /// # {} ++ /// # } ++ /// # ++ /// # struct Tuple3(A, B, C); ++ /// # ++ /// # impl Serialize for Tuple3 ++ /// where A: Serialize, ++ /// B: Serialize, ++ /// C: Serialize ++ /// { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// let mut tup = serializer.serialize_tuple(3)?; ++ /// tup.serialize_element(&self.0)?; ++ /// tup.serialize_element(&self.1)?; ++ /// tup.serialize_element(&self.2)?; ++ /// tup.end() ++ /// } ++ /// } ++ /// ``` ++ /// ++ /// ```rust ++ /// use serde::ser::{Serialize, Serializer, SerializeTuple}; ++ /// ++ /// const VRAM_SIZE: usize = 386; ++ /// struct Vram([u16; VRAM_SIZE]); ++ /// ++ /// impl Serialize for Vram { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// let mut seq = serializer.serialize_tuple(VRAM_SIZE)?; ++ /// for element in &self.0[..] { ++ /// seq.serialize_element(element)?; ++ /// } ++ /// seq.end() ++ /// } ++ /// } ++ /// ``` ++ fn serialize_tuple(self, len: usize) -> Result; ++ ++ /// Begin to serialize a tuple struct like `struct Rgb(u8, u8, u8)`. This ++ /// call must be followed by zero or more calls to `serialize_field`, then a ++ /// call to `end`. ++ /// ++ /// The `name` is the name of the tuple struct and the `len` is the number ++ /// of data fields that will be serialized. ++ /// ++ /// ```rust ++ /// use serde::ser::{Serialize, Serializer, SerializeTupleStruct}; ++ /// ++ /// struct Rgb(u8, u8, u8); ++ /// ++ /// impl Serialize for Rgb { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// let mut ts = serializer.serialize_tuple_struct("Rgb", 3)?; ++ /// ts.serialize_field(&self.0)?; ++ /// ts.serialize_field(&self.1)?; ++ /// ts.serialize_field(&self.2)?; ++ /// ts.end() ++ /// } ++ /// } ++ /// ``` ++ fn serialize_tuple_struct( ++ self, ++ name: &'static str, ++ len: usize, ++ ) -> Result; ++ ++ /// Begin to serialize a tuple variant like `E::T` in `enum E { T(u8, u8) ++ /// }`. This call must be followed by zero or more calls to ++ /// `serialize_field`, then a call to `end`. ++ /// ++ /// The `name` is the name of the enum, the `variant_index` is the index of ++ /// this variant within the enum, the `variant` is the name of the variant, ++ /// and the `len` is the number of data fields that will be serialized. ++ /// ++ /// ```rust ++ /// use serde::ser::{Serialize, Serializer, SerializeTupleVariant}; ++ /// ++ /// enum E { ++ /// T(u8, u8), ++ /// U(String, u32, u32), ++ /// } ++ /// ++ /// impl Serialize for E { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// match *self { ++ /// E::T(ref a, ref b) => { ++ /// let mut tv = serializer.serialize_tuple_variant("E", 0, "T", 2)?; ++ /// tv.serialize_field(a)?; ++ /// tv.serialize_field(b)?; ++ /// tv.end() ++ /// } ++ /// E::U(ref a, ref b, ref c) => { ++ /// let mut tv = serializer.serialize_tuple_variant("E", 1, "U", 3)?; ++ /// tv.serialize_field(a)?; ++ /// tv.serialize_field(b)?; ++ /// tv.serialize_field(c)?; ++ /// tv.end() ++ /// } ++ /// } ++ /// } ++ /// } ++ /// ``` ++ fn serialize_tuple_variant( ++ self, ++ name: &'static str, ++ variant_index: u32, ++ variant: &'static str, ++ len: usize, ++ ) -> Result; ++ ++ /// Begin to serialize a map. This call must be followed by zero or more ++ /// calls to `serialize_key` and `serialize_value`, then a call to `end`. ++ /// ++ /// The argument is the number of elements in the map, which may or may not ++ /// be computable before the map is iterated. Some serializers only support ++ /// maps whose length is known up front. ++ /// ++ /// ```rust ++ /// # use std::marker::PhantomData; ++ /// # ++ /// # struct HashMap(PhantomData, PhantomData); ++ /// # ++ /// # impl HashMap { ++ /// # fn len(&self) -> usize { ++ /// # unimplemented!() ++ /// # } ++ /// # } ++ /// # ++ /// # impl<'a, K, V> IntoIterator for &'a HashMap { ++ /// # type Item = (&'a K, &'a V); ++ /// # type IntoIter = Box>; ++ /// # ++ /// # fn into_iter(self) -> Self::IntoIter { ++ /// # unimplemented!() ++ /// # } ++ /// # } ++ /// # ++ /// use serde::ser::{Serialize, Serializer, SerializeMap}; ++ /// ++ /// impl Serialize for HashMap ++ /// where K: Serialize, ++ /// V: Serialize ++ /// { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// let mut map = serializer.serialize_map(Some(self.len()))?; ++ /// for (k, v) in self { ++ /// map.serialize_entry(k, v)?; ++ /// } ++ /// map.end() ++ /// } ++ /// } ++ /// ``` ++ fn serialize_map(self, len: Option) -> Result; ++ ++ /// Begin to serialize a struct like `struct Rgb { r: u8, g: u8, b: u8 }`. ++ /// This call must be followed by zero or more calls to `serialize_field`, ++ /// then a call to `end`. ++ /// ++ /// The `name` is the name of the struct and the `len` is the number of ++ /// data fields that will be serialized. ++ /// ++ /// ```rust ++ /// use serde::ser::{Serialize, Serializer, SerializeStruct}; ++ /// ++ /// struct Rgb { ++ /// r: u8, ++ /// g: u8, ++ /// b: u8, ++ /// } ++ /// ++ /// impl Serialize for Rgb { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// let mut rgb = serializer.serialize_struct("Rgb", 3)?; ++ /// rgb.serialize_field("r", &self.r)?; ++ /// rgb.serialize_field("g", &self.g)?; ++ /// rgb.serialize_field("b", &self.b)?; ++ /// rgb.end() ++ /// } ++ /// } ++ /// ``` ++ fn serialize_struct( ++ self, ++ name: &'static str, ++ len: usize, ++ ) -> Result; ++ ++ /// Begin to serialize a struct variant like `E::S` in `enum E { S { r: u8, ++ /// g: u8, b: u8 } }`. This call must be followed by zero or more calls to ++ /// `serialize_field`, then a call to `end`. ++ /// ++ /// The `name` is the name of the enum, the `variant_index` is the index of ++ /// this variant within the enum, the `variant` is the name of the variant, ++ /// and the `len` is the number of data fields that will be serialized. ++ /// ++ /// ```rust ++ /// use serde::ser::{Serialize, Serializer, SerializeStructVariant}; ++ /// ++ /// enum E { ++ /// S { r: u8, g: u8, b: u8 } ++ /// } ++ /// ++ /// impl Serialize for E { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// match *self { ++ /// E::S { ref r, ref g, ref b } => { ++ /// let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?; ++ /// sv.serialize_field("r", r)?; ++ /// sv.serialize_field("g", g)?; ++ /// sv.serialize_field("b", b)?; ++ /// sv.end() ++ /// } ++ /// } ++ /// } ++ /// } ++ /// ``` ++ fn serialize_struct_variant( ++ self, ++ name: &'static str, ++ variant_index: u32, ++ variant: &'static str, ++ len: usize, ++ ) -> Result; ++ ++ /// Collect an iterator as a sequence. ++ /// ++ /// The default implementation serializes each item yielded by the iterator ++ /// using [`serialize_seq`]. Implementors should not need to override this ++ /// method. ++ /// ++ /// ```rust ++ /// use serde::{Serialize, Serializer}; ++ /// ++ /// struct SecretlyOneHigher { ++ /// data: Vec, ++ /// } ++ /// ++ /// impl Serialize for SecretlyOneHigher { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.collect_seq(self.data.iter().map(|x| x + 1)) ++ /// } ++ /// } ++ /// ``` ++ /// ++ /// [`serialize_seq`]: #tymethod.serialize_seq ++ fn collect_seq(self, iter: I) -> Result ++ where ++ I: IntoIterator, ++ ::Item: Serialize, ++ { ++ let iter = iter.into_iter(); ++ let mut serializer = try!(self.serialize_seq(iter.len_hint())); ++ for item in iter { ++ try!(serializer.serialize_element(&item)); ++ } ++ serializer.end() ++ } ++ ++ /// Collect an iterator as a map. ++ /// ++ /// The default implementation serializes each pair yielded by the iterator ++ /// using [`serialize_map`]. Implementors should not need to override this ++ /// method. ++ /// ++ /// ```rust ++ /// use std::collections::BTreeSet; ++ /// use serde::{Serialize, Serializer}; ++ /// ++ /// struct MapToUnit { ++ /// keys: BTreeSet, ++ /// } ++ /// ++ /// // Serializes as a map in which the values are all unit. ++ /// impl Serialize for MapToUnit { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.collect_map(self.keys.iter().map(|k| (k, ()))) ++ /// } ++ /// } ++ /// ``` ++ /// ++ /// [`serialize_map`]: #tymethod.serialize_map ++ fn collect_map(self, iter: I) -> Result ++ where ++ K: Serialize, ++ V: Serialize, ++ I: IntoIterator, ++ { ++ let iter = iter.into_iter(); ++ let mut serializer = try!(self.serialize_map(iter.len_hint())); ++ for (key, value) in iter { ++ try!(serializer.serialize_entry(&key, &value)); ++ } ++ serializer.end() ++ } ++ ++ /// Serialize a string produced by an implementation of `Display`. ++ /// ++ /// The default implementation builds a heap-allocated [`String`] and ++ /// delegates to [`serialize_str`]. Serializers are encouraged to provide a ++ /// more efficient implementation if possible. ++ /// ++ /// ```rust ++ /// # struct DateTime; ++ /// # ++ /// # impl DateTime { ++ /// # fn naive_local(&self) -> () { () } ++ /// # fn offset(&self) -> () { () } ++ /// # } ++ /// # ++ /// use serde::{Serialize, Serializer}; ++ /// ++ /// impl Serialize for DateTime { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.collect_str(&format_args!("{:?}{:?}", ++ /// self.naive_local(), ++ /// self.offset())) ++ /// } ++ /// } ++ /// ``` ++ /// ++ /// [`String`]: https://doc.rust-lang.org/std/string/struct.String.html ++ /// [`serialize_str`]: #tymethod.serialize_str ++ #[cfg(any(feature = "std", feature = "alloc"))] ++ fn collect_str(self, value: &T) -> Result ++ where ++ T: Display, ++ { ++ use lib::fmt::Write; ++ let mut string = String::new(); ++ write!(string, "{}", value).unwrap(); ++ self.serialize_str(&string) ++ } ++ ++ /// Serialize a string produced by an implementation of `Display`. ++ /// ++ /// Serializers that use `no_std` are required to provide an implementation ++ /// of this method. If no more sensible behavior is possible, the ++ /// implementation is expected to return an error. ++ /// ++ /// ```rust ++ /// # struct DateTime; ++ /// # ++ /// # impl DateTime { ++ /// # fn naive_local(&self) -> () { () } ++ /// # fn offset(&self) -> () { () } ++ /// # } ++ /// # ++ /// use serde::{Serialize, Serializer}; ++ /// ++ /// impl Serialize for DateTime { ++ /// fn serialize(&self, serializer: S) -> Result ++ /// where S: Serializer ++ /// { ++ /// serializer.collect_str(&format_args!("{:?}{:?}", ++ /// self.naive_local(), ++ /// self.offset())) ++ /// } ++ /// } ++ /// ``` ++ #[cfg(not(any(feature = "std", feature = "alloc")))] ++ fn collect_str(self, value: &T) -> Result ++ where ++ T: Display; ++} ++ ++/// Returned from `Serializer::serialize_seq`. ++/// ++/// ```rust ++/// # use std::marker::PhantomData; ++/// # ++/// # struct Vec(PhantomData); ++/// # ++/// # impl Vec { ++/// # fn len(&self) -> usize { ++/// # unimplemented!() ++/// # } ++/// # } ++/// # ++/// # impl<'a, T> IntoIterator for &'a Vec { ++/// # type Item = &'a T; ++/// # type IntoIter = Box>; ++/// # fn into_iter(self) -> Self::IntoIter { ++/// # unimplemented!() ++/// # } ++/// # } ++/// # ++/// use serde::ser::{Serialize, Serializer, SerializeSeq}; ++/// ++/// impl Serialize for Vec ++/// where T: Serialize ++/// { ++/// fn serialize(&self, serializer: S) -> Result ++/// where S: Serializer ++/// { ++/// let mut seq = serializer.serialize_seq(Some(self.len()))?; ++/// for element in self { ++/// seq.serialize_element(element)?; ++/// } ++/// seq.end() ++/// } ++/// } ++/// ``` ++pub trait SerializeSeq { ++ /// Must match the `Ok` type of our `Serializer`. ++ type Ok; ++ ++ /// Must match the `Error` type of our `Serializer`. ++ type Error: Error; ++ ++ /// Serialize a sequence element. ++ fn serialize_element(&mut self, value: &T) -> Result<(), Self::Error> ++ where ++ T: Serialize; ++ ++ /// Finish serializing a sequence. ++ fn end(self) -> Result; ++} ++ ++/// Returned from `Serializer::serialize_tuple`. ++/// ++/// ```rust ++/// use serde::ser::{Serialize, Serializer, SerializeTuple}; ++/// ++/// # mod fool { ++/// # trait Serialize {} ++/// impl Serialize for (A, B, C) ++/// # {} ++/// # } ++/// # ++/// # struct Tuple3(A, B, C); ++/// # ++/// # impl Serialize for Tuple3 ++/// where A: Serialize, ++/// B: Serialize, ++/// C: Serialize ++/// { ++/// fn serialize(&self, serializer: S) -> Result ++/// where S: Serializer ++/// { ++/// let mut tup = serializer.serialize_tuple(3)?; ++/// tup.serialize_element(&self.0)?; ++/// tup.serialize_element(&self.1)?; ++/// tup.serialize_element(&self.2)?; ++/// tup.end() ++/// } ++/// } ++/// ``` ++/// ++/// ```rust ++/// # use std::marker::PhantomData; ++/// # ++/// # struct Array(PhantomData); ++/// # ++/// # impl Array { ++/// # fn len(&self) -> usize { ++/// # unimplemented!() ++/// # } ++/// # } ++/// # ++/// # impl<'a, T> IntoIterator for &'a Array { ++/// # type Item = &'a T; ++/// # type IntoIter = Box>; ++/// # fn into_iter(self) -> Self::IntoIter { ++/// # unimplemented!() ++/// # } ++/// # } ++/// # ++/// use serde::ser::{Serialize, Serializer, SerializeTuple}; ++/// ++/// # mod fool { ++/// # trait Serialize {} ++/// impl Serialize for [T; 16] ++/// # {} ++/// # } ++/// # ++/// # impl Serialize for Array ++/// where T: Serialize ++/// { ++/// fn serialize(&self, serializer: S) -> Result ++/// where S: Serializer ++/// { ++/// let mut seq = serializer.serialize_tuple(16)?; ++/// for element in self { ++/// seq.serialize_element(element)?; ++/// } ++/// seq.end() ++/// } ++/// } ++/// ``` ++pub trait SerializeTuple { ++ /// Must match the `Ok` type of our `Serializer`. ++ type Ok; ++ ++ /// Must match the `Error` type of our `Serializer`. ++ type Error: Error; ++ ++ /// Serialize a tuple element. ++ fn serialize_element(&mut self, value: &T) -> Result<(), Self::Error> ++ where ++ T: Serialize; ++ ++ /// Finish serializing a tuple. ++ fn end(self) -> Result; ++} ++ ++/// Returned from `Serializer::serialize_tuple_struct`. ++/// ++/// ```rust ++/// use serde::ser::{Serialize, Serializer, SerializeTupleStruct}; ++/// ++/// struct Rgb(u8, u8, u8); ++/// ++/// impl Serialize for Rgb { ++/// fn serialize(&self, serializer: S) -> Result ++/// where S: Serializer ++/// { ++/// let mut ts = serializer.serialize_tuple_struct("Rgb", 3)?; ++/// ts.serialize_field(&self.0)?; ++/// ts.serialize_field(&self.1)?; ++/// ts.serialize_field(&self.2)?; ++/// ts.end() ++/// } ++/// } ++/// ``` ++pub trait SerializeTupleStruct { ++ /// Must match the `Ok` type of our `Serializer`. ++ type Ok; ++ ++ /// Must match the `Error` type of our `Serializer`. ++ type Error: Error; ++ ++ /// Serialize a tuple struct field. ++ fn serialize_field(&mut self, value: &T) -> Result<(), Self::Error> ++ where ++ T: Serialize; ++ ++ /// Finish serializing a tuple struct. ++ fn end(self) -> Result; ++} ++ ++/// Returned from `Serializer::serialize_tuple_variant`. ++/// ++/// ```rust ++/// use serde::ser::{Serialize, Serializer, SerializeTupleVariant}; ++/// ++/// enum E { ++/// T(u8, u8), ++/// U(String, u32, u32), ++/// } ++/// ++/// impl Serialize for E { ++/// fn serialize(&self, serializer: S) -> Result ++/// where S: Serializer ++/// { ++/// match *self { ++/// E::T(ref a, ref b) => { ++/// let mut tv = serializer.serialize_tuple_variant("E", 0, "T", 2)?; ++/// tv.serialize_field(a)?; ++/// tv.serialize_field(b)?; ++/// tv.end() ++/// } ++/// E::U(ref a, ref b, ref c) => { ++/// let mut tv = serializer.serialize_tuple_variant("E", 1, "U", 3)?; ++/// tv.serialize_field(a)?; ++/// tv.serialize_field(b)?; ++/// tv.serialize_field(c)?; ++/// tv.end() ++/// } ++/// } ++/// } ++/// } ++/// ``` ++pub trait SerializeTupleVariant { ++ /// Must match the `Ok` type of our `Serializer`. ++ type Ok; ++ ++ /// Must match the `Error` type of our `Serializer`. ++ type Error: Error; ++ ++ /// Serialize a tuple variant field. ++ fn serialize_field(&mut self, value: &T) -> Result<(), Self::Error> ++ where ++ T: Serialize; ++ ++ /// Finish serializing a tuple variant. ++ fn end(self) -> Result; ++} ++ ++/// Returned from `Serializer::serialize_map`. ++/// ++/// ```rust ++/// # use std::marker::PhantomData; ++/// # ++/// # struct HashMap(PhantomData, PhantomData); ++/// # ++/// # impl HashMap { ++/// # fn len(&self) -> usize { ++/// # unimplemented!() ++/// # } ++/// # } ++/// # ++/// # impl<'a, K, V> IntoIterator for &'a HashMap { ++/// # type Item = (&'a K, &'a V); ++/// # type IntoIter = Box>; ++/// # ++/// # fn into_iter(self) -> Self::IntoIter { ++/// # unimplemented!() ++/// # } ++/// # } ++/// # ++/// use serde::ser::{Serialize, Serializer, SerializeMap}; ++/// ++/// impl Serialize for HashMap ++/// where K: Serialize, ++/// V: Serialize ++/// { ++/// fn serialize(&self, serializer: S) -> Result ++/// where S: Serializer ++/// { ++/// let mut map = serializer.serialize_map(Some(self.len()))?; ++/// for (k, v) in self { ++/// map.serialize_entry(k, v)?; ++/// } ++/// map.end() ++/// } ++/// } ++/// ``` ++pub trait SerializeMap { ++ /// Must match the `Ok` type of our `Serializer`. ++ type Ok; ++ ++ /// Must match the `Error` type of our `Serializer`. ++ type Error: Error; ++ ++ /// Serialize a map key. ++ /// ++ /// If possible, `Serialize` implementations are encouraged to use ++ /// `serialize_entry` instead as it may be implemented more efficiently in ++ /// some formats compared to a pair of calls to `serialize_key` and ++ /// `serialize_value`. ++ fn serialize_key(&mut self, key: &T) -> Result<(), Self::Error> ++ where ++ T: Serialize; ++ ++ /// Serialize a map value. ++ /// ++ /// # Panics ++ /// ++ /// Calling `serialize_value` before `serialize_key` is incorrect and is ++ /// allowed to panic or produce bogus results. ++ fn serialize_value(&mut self, value: &T) -> Result<(), Self::Error> ++ where ++ T: Serialize; ++ ++ /// Serialize a map entry consisting of a key and a value. ++ /// ++ /// Some [`Serialize`] types are not able to hold a key and value in memory ++ /// at the same time so `SerializeMap` implementations are required to ++ /// support [`serialize_key`] and [`serialize_value`] individually. The ++ /// `serialize_entry` method allows serializers to optimize for the case ++ /// where key and value are both available. [`Serialize`] implementations ++ /// are encouraged to use `serialize_entry` if possible. ++ /// ++ /// The default implementation delegates to [`serialize_key`] and ++ /// [`serialize_value`]. This is appropriate for serializers that do not ++ /// care about performance or are not able to optimize `serialize_entry` any ++ /// better than this. ++ /// ++ /// [`Serialize`]: ../trait.Serialize.html ++ /// [`serialize_key`]: #tymethod.serialize_key ++ /// [`serialize_value`]: #tymethod.serialize_value ++ fn serialize_entry( ++ &mut self, ++ key: &K, ++ value: &V, ++ ) -> Result<(), Self::Error> ++ where ++ K: Serialize, ++ V: Serialize, ++ { ++ try!(self.serialize_key(key)); ++ self.serialize_value(value) ++ } ++ ++ /// Finish serializing a map. ++ fn end(self) -> Result; ++} ++ ++/// Returned from `Serializer::serialize_struct`. ++/// ++/// ```rust ++/// use serde::ser::{Serialize, Serializer, SerializeStruct}; ++/// ++/// struct Rgb { ++/// r: u8, ++/// g: u8, ++/// b: u8, ++/// } ++/// ++/// impl Serialize for Rgb { ++/// fn serialize(&self, serializer: S) -> Result ++/// where S: Serializer ++/// { ++/// let mut rgb = serializer.serialize_struct("Rgb", 3)?; ++/// rgb.serialize_field("r", &self.r)?; ++/// rgb.serialize_field("g", &self.g)?; ++/// rgb.serialize_field("b", &self.b)?; ++/// rgb.end() ++/// } ++/// } ++/// ``` ++pub trait SerializeStruct { ++ /// Must match the `Ok` type of our `Serializer`. ++ type Ok; ++ ++ /// Must match the `Error` type of our `Serializer`. ++ type Error: Error; ++ ++ /// Serialize a struct field. ++ fn serialize_field( ++ &mut self, ++ key: &'static str, ++ value: &T, ++ ) -> Result<(), Self::Error> ++ where ++ T: Serialize; ++ ++ /// Indicate that a struct field has been skipped. ++ #[inline] ++ fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error> { ++ let _ = key; ++ Ok(()) ++ } ++ ++ /// Finish serializing a struct. ++ fn end(self) -> Result; ++} ++ ++/// Returned from `Serializer::serialize_struct_variant`. ++/// ++/// ```rust ++/// use serde::ser::{Serialize, Serializer, SerializeStructVariant}; ++/// ++/// enum E { ++/// S { r: u8, g: u8, b: u8 } ++/// } ++/// ++/// impl Serialize for E { ++/// fn serialize(&self, serializer: S) -> Result ++/// where S: Serializer ++/// { ++/// match *self { ++/// E::S { ref r, ref g, ref b } => { ++/// let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?; ++/// sv.serialize_field("r", r)?; ++/// sv.serialize_field("g", g)?; ++/// sv.serialize_field("b", b)?; ++/// sv.end() ++/// } ++/// } ++/// } ++/// } ++/// ``` ++pub trait SerializeStructVariant { ++ /// Must match the `Ok` type of our `Serializer`. ++ type Ok; ++ ++ /// Must match the `Error` type of our `Serializer`. ++ type Error: Error; ++ ++ /// Serialize a struct variant field. ++ fn serialize_field( ++ &mut self, ++ key: &'static str, ++ value: &T, ++ ) -> Result<(), Self::Error> ++ where ++ T: Serialize; ++ ++ /// Indicate that a struct variant field has been skipped. ++ #[inline] ++ fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error> { ++ let _ = key; ++ Ok(()) ++ } ++ ++ /// Finish serializing a struct variant. ++ fn end(self) -> Result; ++} ++ ++trait LenHint: Iterator { ++ fn len_hint(&self) -> Option; ++} ++ ++impl LenHint for I ++where ++ I: Iterator, ++{ ++ #[cfg(not(feature = "unstable"))] ++ fn len_hint(&self) -> Option { ++ iterator_len_hint(self) ++ } ++ ++ #[cfg(feature = "unstable")] ++ default fn len_hint(&self) -> Option { ++ iterator_len_hint(self) ++ } ++} ++ ++#[cfg(feature = "unstable")] ++impl LenHint for I ++where ++ I: ExactSizeIterator, ++{ ++ fn len_hint(&self) -> Option { ++ Some(self.len()) ++ } ++} ++ ++fn iterator_len_hint(iter: &I) -> Option ++where ++ I: Iterator, ++{ ++ match iter.size_hint() { ++ (lo, Some(hi)) if lo == hi => Some(lo), ++ _ => None, ++ } ++} diff --cc vendor/serde_derive-1.0.15/.cargo-checksum.json index 000000000,000000000..18da4f108 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"1afcaae083fd1c46952a315062326bc9957f182358eb7da03b57ef1c688f7aa9"} diff --cc vendor/serde_derive-1.0.15/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/.cargo-ok diff --cc vendor/serde_derive-1.0.15/Cargo.toml index 000000000,000000000..4e8b5655b new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/Cargo.toml @@@ -1,0 -1,0 +1,40 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "serde_derive" ++version = "1.0.15" ++authors = ["Erick Tryzelaar ", "David Tolnay "] ++include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] ++description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]" ++homepage = "https://serde.rs" ++documentation = "https://serde.rs/codegen.html" ++readme = "README.md" ++keywords = ["serde", "serialization", "no_std"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/serde-rs/serde" ++ ++[lib] ++name = "serde_derive" ++proc-macro = true ++[dependencies.syn] ++version = "0.11" ++features = ["visit"] ++ ++[dependencies.serde_derive_internals] ++version = "=0.16.0" ++default-features = false ++ ++[dependencies.quote] ++version = "0.3.8" ++[badges.travis-ci] ++repository = "serde-rs/serde" diff --cc vendor/serde_derive-1.0.15/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/serde_derive-1.0.15/LICENSE-MIT index 000000000,000000000..39d4bdb5a new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/serde_derive-1.0.15/README.md index 000000000,000000000..c2f35e9cd new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/README.md @@@ -1,0 -1,0 +1,81 @@@ ++# Serde   [![Build Status]][travis] [![Latest Version]][crates.io] ++ ++[Build Status]: https://api.travis-ci.org/serde-rs/serde.svg?branch=master ++[travis]: https://travis-ci.org/serde-rs/serde ++[Latest Version]: https://img.shields.io/crates/v/serde.svg ++[crates.io]: https://crates.io/crates/serde ++ ++**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.** ++ ++--- ++ ++You may be looking for: ++ ++- [An overview of Serde](https://serde.rs/) ++- [Data formats supported by Serde](https://serde.rs/#data-formats) ++- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html) ++- [Examples](https://serde.rs/examples.html) ++- [API documentation](https://docs.serde.rs/serde/) ++- [Release notes](https://github.com/serde-rs/serde/releases) ++ ++## Serde in action ++ ++ ++ ++ ++ ++```rust ++#[macro_use] ++extern crate serde_derive; ++ ++extern crate serde; ++extern crate serde_json; ++ ++#[derive(Serialize, Deserialize, Debug)] ++struct Point { ++ x: i32, ++ y: i32, ++} ++ ++fn main() { ++ let point = Point { x: 1, y: 2 }; ++ ++ // Convert the Point to a JSON string. ++ let serialized = serde_json::to_string(&point).unwrap(); ++ ++ // Prints serialized = {"x":1,"y":2} ++ println!("serialized = {}", serialized); ++ ++ // Convert the JSON string back to a Point. ++ let deserialized: Point = serde_json::from_str(&serialized).unwrap(); ++ ++ // Prints deserialized = Point { x: 1, y: 2 } ++ println!("deserialized = {:?}", deserialized); ++} ++``` ++ ++## Getting help ++ ++Serde developers live in the #serde channel on ++[`irc.mozilla.org`](https://wiki.mozilla.org/IRC). The #rust channel is also a ++good resource with generally faster response time but less specific knowledge ++about Serde. If IRC is not your thing or you don't get a good response, we are ++happy to respond to [GitHub issues](https://github.com/serde-rs/serde/issues/new) ++as well. ++ ++## License ++ ++Serde is licensed under either of ++ ++ * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ++ http://www.apache.org/licenses/LICENSE-2.0) ++ * MIT license ([LICENSE-MIT](LICENSE-MIT) or ++ http://opensource.org/licenses/MIT) ++ ++at your option. ++ ++### Contribution ++ ++Unless you explicitly state otherwise, any contribution intentionally submitted ++for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be ++dual licensed as above, without any additional terms or conditions. diff --cc vendor/serde_derive-1.0.15/src/bound.rs index 000000000,000000000..5f6e94c02 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/src/bound.rs @@@ -1,0 -1,0 +1,266 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::collections::HashSet; ++ ++use syn::{self, visit}; ++ ++use internals::ast::{Body, Container}; ++use internals::attr; ++ ++macro_rules! path { ++ ($($path:tt)+) => { ++ syn::parse_path(quote!($($path)+).as_str()).unwrap() ++ }; ++} ++ ++// Remove the default from every type parameter because in the generated impls ++// they look like associated types: "error: associated type bindings are not ++// allowed here". ++pub fn without_defaults(generics: &syn::Generics) -> syn::Generics { ++ syn::Generics { ++ ty_params: generics ++ .ty_params ++ .iter() ++ .map( ++ |ty_param| { ++ syn::TyParam { ++ default: None, ++ ..ty_param.clone() ++ } ++ }, ++ ) ++ .collect(), ++ ..generics.clone() ++ } ++} ++ ++pub fn with_where_predicates( ++ generics: &syn::Generics, ++ predicates: &[syn::WherePredicate], ++) -> syn::Generics { ++ let mut generics = generics.clone(); ++ generics ++ .where_clause ++ .predicates ++ .extend_from_slice(predicates); ++ generics ++} ++ ++pub fn with_where_predicates_from_fields( ++ cont: &Container, ++ generics: &syn::Generics, ++ from_field: F, ++) -> syn::Generics ++where ++ F: Fn(&attr::Field) -> Option<&[syn::WherePredicate]>, ++{ ++ let predicates = cont.body ++ .all_fields() ++ .flat_map(|field| from_field(&field.attrs)) ++ .flat_map(|predicates| predicates.to_vec()); ++ ++ let mut generics = generics.clone(); ++ generics.where_clause.predicates.extend(predicates); ++ generics ++} ++ ++// Puts the given bound on any generic type parameters that are used in fields ++// for which filter returns true. ++// ++// For example, the following struct needs the bound `A: Serialize, B: Serialize`. ++// ++// struct S<'b, A, B: 'b, C> { ++// a: A, ++// b: Option<&'b B> ++// #[serde(skip_serializing)] ++// c: C, ++// } ++pub fn with_bound( ++ cont: &Container, ++ generics: &syn::Generics, ++ filter: F, ++ bound: &syn::Path, ++) -> syn::Generics ++where ++ F: Fn(&attr::Field, Option<&attr::Variant>) -> bool, ++{ ++ struct FindTyParams { ++ // Set of all generic type parameters on the current struct (A, B, C in ++ // the example). Initialized up front. ++ all_ty_params: HashSet, ++ // Set of generic type parameters used in fields for which filter ++ // returns true (A and B in the example). Filled in as the visitor sees ++ // them. ++ relevant_ty_params: HashSet, ++ } ++ impl visit::Visitor for FindTyParams { ++ fn visit_path(&mut self, path: &syn::Path) { ++ if let Some(seg) = path.segments.last() { ++ if seg.ident == "PhantomData" { ++ // Hardcoded exception, because PhantomData implements ++ // Serialize and Deserialize whether or not T implements it. ++ return; ++ } ++ } ++ if !path.global && path.segments.len() == 1 { ++ let id = path.segments[0].ident.clone(); ++ if self.all_ty_params.contains(&id) { ++ self.relevant_ty_params.insert(id); ++ } ++ } ++ visit::walk_path(self, path); ++ } ++ } ++ ++ let all_ty_params: HashSet<_> = generics ++ .ty_params ++ .iter() ++ .map(|ty_param| ty_param.ident.clone()) ++ .collect(); ++ ++ let mut visitor = FindTyParams { ++ all_ty_params: all_ty_params, ++ relevant_ty_params: HashSet::new(), ++ }; ++ match cont.body { ++ Body::Enum(ref variants) => { ++ for variant in variants.iter() { ++ let relevant_fields = variant ++ .fields ++ .iter() ++ .filter(|field| filter(&field.attrs, Some(&variant.attrs))); ++ for field in relevant_fields { ++ visit::walk_ty(&mut visitor, field.ty); ++ } ++ } ++ } ++ Body::Struct(_, ref fields) => { ++ for field in fields.iter().filter(|field| filter(&field.attrs, None)) { ++ visit::walk_ty(&mut visitor, field.ty); ++ } ++ } ++ } ++ ++ let new_predicates = generics ++ .ty_params ++ .iter() ++ .map(|ty_param| ty_param.ident.clone()) ++ .filter(|id| visitor.relevant_ty_params.contains(id)) ++ .map( ++ |id| { ++ syn::WherePredicate::BoundPredicate( ++ syn::WhereBoundPredicate { ++ bound_lifetimes: Vec::new(), ++ // the type parameter that is being bounded e.g. T ++ bounded_ty: syn::Ty::Path(None, id.into()), ++ // the bound e.g. Serialize ++ bounds: vec![ ++ syn::TyParamBound::Trait( ++ syn::PolyTraitRef { ++ bound_lifetimes: Vec::new(), ++ trait_ref: bound.clone(), ++ }, ++ syn::TraitBoundModifier::None, ++ ), ++ ], ++ }, ++ ) ++ }, ++ ); ++ ++ let mut generics = generics.clone(); ++ generics.where_clause.predicates.extend(new_predicates); ++ generics ++} ++ ++pub fn with_self_bound( ++ cont: &Container, ++ generics: &syn::Generics, ++ bound: &syn::Path, ++) -> syn::Generics { ++ let mut generics = generics.clone(); ++ generics ++ .where_clause ++ .predicates ++ .push( ++ syn::WherePredicate::BoundPredicate( ++ syn::WhereBoundPredicate { ++ bound_lifetimes: Vec::new(), ++ // the type that is being bounded e.g. MyStruct<'a, T> ++ bounded_ty: type_of_item(cont), ++ // the bound e.g. Default ++ bounds: vec![ ++ syn::TyParamBound::Trait( ++ syn::PolyTraitRef { ++ bound_lifetimes: Vec::new(), ++ trait_ref: bound.clone(), ++ }, ++ syn::TraitBoundModifier::None, ++ ), ++ ], ++ }, ++ ), ++ ); ++ generics ++} ++ ++pub fn with_lifetime_bound(generics: &syn::Generics, lifetime: &str) -> syn::Generics { ++ let mut generics = generics.clone(); ++ ++ for lifetime_def in &mut generics.lifetimes { ++ lifetime_def.bounds.push(syn::Lifetime::new(lifetime)); ++ } ++ ++ for ty_param in &mut generics.ty_params { ++ ty_param ++ .bounds ++ .push(syn::TyParamBound::Region(syn::Lifetime::new(lifetime))); ++ } ++ ++ generics ++ .lifetimes ++ .push( ++ syn::LifetimeDef { ++ attrs: Vec::new(), ++ lifetime: syn::Lifetime::new(lifetime), ++ bounds: Vec::new(), ++ }, ++ ); ++ ++ generics ++} ++ ++fn type_of_item(cont: &Container) -> syn::Ty { ++ syn::Ty::Path( ++ None, ++ syn::Path { ++ global: false, ++ segments: vec![ ++ syn::PathSegment { ++ ident: cont.ident.clone(), ++ parameters: syn::PathParameters::AngleBracketed( ++ syn::AngleBracketedParameterData { ++ lifetimes: cont.generics ++ .lifetimes ++ .iter() ++ .map(|def| def.lifetime.clone()) ++ .collect(), ++ types: cont.generics ++ .ty_params ++ .iter() ++ .map(|param| syn::Ty::Path(None, param.ident.clone().into())) ++ .collect(), ++ bindings: Vec::new(), ++ }, ++ ), ++ }, ++ ], ++ }, ++ ) ++} diff --cc vendor/serde_derive-1.0.15/src/de.rs index 000000000,000000000..44ed7fa0e new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/src/de.rs @@@ -1,0 -1,0 +1,1912 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use syn::{self, Ident}; ++use quote::{self, Tokens, ToTokens}; ++ ++use bound; ++use fragment::{Fragment, Expr, Stmts, Match}; ++use internals::ast::{Body, Container, Field, Style, Variant}; ++use internals::{self, attr}; ++ ++use std::collections::BTreeSet; ++ ++pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result { ++ let ctxt = internals::Ctxt::new(); ++ let cont = Container::from_ast(&ctxt, input); ++ try!(ctxt.check()); ++ ++ let ident = &cont.ident; ++ let params = Parameters::new(&cont); ++ let (de_impl_generics, _, ty_generics, where_clause) = split_with_de_lifetime(¶ms); ++ let dummy_const = Ident::new(format!("_IMPL_DESERIALIZE_FOR_{}", ident)); ++ let body = Stmts(deserialize_body(&cont, ¶ms)); ++ let delife = params.borrowed.de_lifetime(); ++ ++ let impl_block = if let Some(remote) = cont.attrs.remote() { ++ let vis = &input.vis; ++ quote! { ++ impl #de_impl_generics #ident #ty_generics #where_clause { ++ #vis fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result<#remote #ty_generics, __D::Error> ++ where __D: _serde::Deserializer<#delife> ++ { ++ #body ++ } ++ } ++ } ++ } else { ++ quote! { ++ #[automatically_derived] ++ impl #de_impl_generics _serde::Deserialize<#delife> for #ident #ty_generics #where_clause { ++ fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result ++ where __D: _serde::Deserializer<#delife> ++ { ++ #body ++ } ++ } ++ } ++ }; ++ ++ let generated = quote! { ++ #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] ++ const #dummy_const: () = { ++ extern crate serde as _serde; ++ #impl_block ++ }; ++ }; ++ Ok(generated) ++} ++ ++struct Parameters { ++ /// Name of the type the `derive` is on. ++ local: syn::Ident, ++ ++ /// Path to the type the impl is for. Either a single `Ident` for local ++ /// types or `some::remote::Ident` for remote types. Does not include ++ /// generic parameters. ++ this: syn::Path, ++ ++ /// Generics including any explicit and inferred bounds for the impl. ++ generics: syn::Generics, ++ ++ /// Lifetimes borrowed from the deserializer. These will become bounds on ++ /// the `'de` lifetime of the deserializer. ++ borrowed: BorrowedLifetimes, ++ ++ /// At least one field has a serde(getter) attribute, implying that the ++ /// remote type has a private field. ++ has_getter: bool, ++} ++ ++impl Parameters { ++ fn new(cont: &Container) -> Self { ++ let local = cont.ident.clone(); ++ let this = match cont.attrs.remote() { ++ Some(remote) => remote.clone(), ++ None => cont.ident.clone().into(), ++ }; ++ let borrowed = borrowed_lifetimes(cont); ++ let generics = build_generics(cont, &borrowed); ++ let has_getter = cont.body.has_getter(); ++ ++ Parameters { ++ local: local, ++ this: this, ++ generics: generics, ++ borrowed: borrowed, ++ has_getter: has_getter, ++ } ++ } ++ ++ /// Type name to use in error messages and `&'static str` arguments to ++ /// various Deserializer methods. ++ fn type_name(&self) -> &str { ++ self.this.segments.last().unwrap().ident.as_ref() ++ } ++} ++ ++// All the generics in the input, plus a bound `T: Deserialize` for each generic ++// field type that will be deserialized by us, plus a bound `T: Default` for ++// each generic field type that will be set to a default value. ++fn build_generics(cont: &Container, borrowed: &BorrowedLifetimes) -> syn::Generics { ++ let generics = bound::without_defaults(cont.generics); ++ ++ let generics = bound::with_where_predicates_from_fields(cont, &generics, attr::Field::de_bound); ++ ++ match cont.attrs.de_bound() { ++ Some(predicates) => bound::with_where_predicates(&generics, predicates), ++ None => { ++ let generics = match *cont.attrs.default() { ++ attr::Default::Default => { ++ bound::with_self_bound(cont, &generics, &path!(_serde::export::Default)) ++ } ++ attr::Default::None | ++ attr::Default::Path(_) => generics, ++ }; ++ ++ let delife = borrowed.de_lifetime(); ++ let generics = bound::with_bound( ++ cont, ++ &generics, ++ needs_deserialize_bound, ++ &path!(_serde::Deserialize<#delife>), ++ ); ++ ++ bound::with_bound( ++ cont, ++ &generics, ++ requires_default, ++ &path!(_serde::export::Default), ++ ) ++ } ++ } ++} ++ ++// Fields with a `skip_deserializing` or `deserialize_with` attribute are not ++// deserialized by us so we do not generate a bound. Fields with a `bound` ++// attribute specify their own bound so we do not generate one. All other fields ++// may need a `T: Deserialize` bound where T is the type of the field. ++fn needs_deserialize_bound(field: &attr::Field, variant: Option<&attr::Variant>) -> bool { ++ !field.skip_deserializing() && ++ field.deserialize_with().is_none() && ++ field.de_bound().is_none() && ++ variant.map_or(true, |variant| variant.deserialize_with().is_none()) ++} ++ ++// Fields with a `default` attribute (not `default=...`), and fields with a ++// `skip_deserializing` attribute that do not also have `default=...`. ++fn requires_default(field: &attr::Field, _variant: Option<&attr::Variant>) -> bool { ++ field.default() == &attr::Default::Default ++} ++ ++enum BorrowedLifetimes { ++ Borrowed(BTreeSet), ++ Static, ++} ++ ++impl BorrowedLifetimes { ++ fn de_lifetime(&self) -> syn::Lifetime { ++ match *self { ++ BorrowedLifetimes::Borrowed(_) => syn::Lifetime::new("'de"), ++ BorrowedLifetimes::Static => syn::Lifetime::new("'static"), ++ } ++ } ++ ++ fn de_lifetime_def(&self) -> Option { ++ match *self { ++ BorrowedLifetimes::Borrowed(ref bounds) => { ++ Some(syn::LifetimeDef { ++ attrs: Vec::new(), ++ lifetime: syn::Lifetime::new("'de"), ++ bounds: bounds.iter().cloned().collect(), ++ }) ++ } ++ BorrowedLifetimes::Static => None, ++ } ++ } ++} ++ ++// The union of lifetimes borrowed by each field of the container. ++// ++// These turn into bounds on the `'de` lifetime of the Deserialize impl. If ++// lifetimes `'a` and `'b` are borrowed but `'c` is not, the impl is: ++// ++// impl<'de: 'a + 'b, 'a, 'b, 'c> Deserialize<'de> for S<'a, 'b, 'c> ++// ++// If any borrowed lifetime is `'static`, then `'de: 'static` would be redundant ++// and we use plain `'static` instead of `'de`. ++fn borrowed_lifetimes(cont: &Container) -> BorrowedLifetimes { ++ let mut lifetimes = BTreeSet::new(); ++ for field in cont.body.all_fields() { ++ lifetimes.extend(field.attrs.borrowed_lifetimes().iter().cloned()); ++ } ++ if lifetimes.iter().any(|b| b.ident == "'static") { ++ BorrowedLifetimes::Static ++ } else { ++ BorrowedLifetimes::Borrowed(lifetimes) ++ } ++} ++ ++fn deserialize_body(cont: &Container, params: &Parameters) -> Fragment { ++ if let Some(from_type) = cont.attrs.from_type() { ++ deserialize_from(from_type) ++ } else if let attr::Identifier::No = cont.attrs.identifier() { ++ match cont.body { ++ Body::Enum(ref variants) => deserialize_enum(params, variants, &cont.attrs), ++ Body::Struct(Style::Struct, ref fields) => { ++ if fields.iter().any(|field| field.ident.is_none()) { ++ panic!("struct has unnamed fields"); ++ } ++ deserialize_struct(None, params, fields, &cont.attrs, None, Untagged::No) ++ } ++ Body::Struct(Style::Tuple, ref fields) | ++ Body::Struct(Style::Newtype, ref fields) => { ++ if fields.iter().any(|field| field.ident.is_some()) { ++ panic!("tuple struct has named fields"); ++ } ++ deserialize_tuple(None, params, fields, &cont.attrs, None) ++ } ++ Body::Struct(Style::Unit, _) => deserialize_unit_struct(params, &cont.attrs), ++ } ++ } else { ++ match cont.body { ++ Body::Enum(ref variants) => { ++ deserialize_custom_identifier(params, variants, &cont.attrs) ++ } ++ Body::Struct(_, _) => unreachable!("checked in serde_derive_internals"), ++ } ++ } ++} ++ ++fn deserialize_from(from_type: &syn::Ty) -> Fragment { ++ quote_block! { ++ _serde::export::Result::map( ++ <#from_type as _serde::Deserialize>::deserialize(__deserializer), ++ _serde::export::From::from) ++ } ++} ++ ++fn deserialize_unit_struct(params: &Parameters, cattrs: &attr::Container) -> Fragment { ++ let this = ¶ms.this; ++ let type_name = cattrs.name().deserialize_name(); ++ ++ let expecting = format!("unit struct {}", params.type_name()); ++ ++ quote_block! { ++ struct __Visitor; ++ ++ impl<'de> _serde::de::Visitor<'de> for __Visitor { ++ type Value = #this; ++ ++ fn expecting(&self, formatter: &mut _serde::export::Formatter) -> _serde::export::fmt::Result { ++ _serde::export::Formatter::write_str(formatter, #expecting) ++ } ++ ++ #[inline] ++ fn visit_unit<__E>(self) -> _serde::export::Result ++ where __E: _serde::de::Error ++ { ++ _serde::export::Ok(#this) ++ } ++ } ++ ++ _serde::Deserializer::deserialize_unit_struct(__deserializer, #type_name, __Visitor) ++ } ++} ++ ++fn deserialize_tuple( ++ variant_ident: Option<&syn::Ident>, ++ params: &Parameters, ++ fields: &[Field], ++ cattrs: &attr::Container, ++ deserializer: Option, ++) -> Fragment { ++ let this = ¶ms.this; ++ let (de_impl_generics, de_ty_generics, ty_generics, where_clause) = split_with_de_lifetime(params,); ++ let delife = params.borrowed.de_lifetime(); ++ ++ // If there are getters (implying private fields), construct the local type ++ // and use an `Into` conversion to get the remote type. If there are no ++ // getters then construct the target type directly. ++ let construct = if params.has_getter { ++ let local = ¶ms.local; ++ quote!(#local) ++ } else { ++ quote!(#this) ++ }; ++ ++ let is_enum = variant_ident.is_some(); ++ let type_path = match variant_ident { ++ Some(variant_ident) => quote!(#construct::#variant_ident), ++ None => construct, ++ }; ++ let expecting = match variant_ident { ++ Some(variant_ident) => format!("tuple variant {}::{}", params.type_name(), variant_ident), ++ None => format!("tuple struct {}", params.type_name()), ++ }; ++ ++ let nfields = fields.len(); ++ ++ let visit_newtype_struct = if !is_enum && nfields == 1 { ++ Some(deserialize_newtype_struct(&type_path, params, &fields[0])) ++ } else { ++ None ++ }; ++ ++ let visit_seq = Stmts(deserialize_seq(&type_path, params, fields, false, cattrs)); ++ ++ let visitor_expr = quote! { ++ __Visitor { ++ marker: _serde::export::PhantomData::<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData, ++ } ++ }; ++ let dispatch = if let Some(deserializer) = deserializer { ++ quote!(_serde::Deserializer::deserialize_tuple(#deserializer, #nfields, #visitor_expr)) ++ } else if is_enum { ++ quote!(_serde::de::VariantAccess::tuple_variant(__variant, #nfields, #visitor_expr)) ++ } else if nfields == 1 { ++ let type_name = cattrs.name().deserialize_name(); ++ quote!(_serde::Deserializer::deserialize_newtype_struct(__deserializer, #type_name, #visitor_expr)) ++ } else { ++ let type_name = cattrs.name().deserialize_name(); ++ quote!(_serde::Deserializer::deserialize_tuple_struct(__deserializer, #type_name, #nfields, #visitor_expr)) ++ }; ++ ++ let all_skipped = fields ++ .iter() ++ .all(|field| field.attrs.skip_deserializing()); ++ let visitor_var = if all_skipped { ++ quote!(_) ++ } else { ++ quote!(mut __seq) ++ }; ++ ++ quote_block! { ++ struct __Visitor #de_impl_generics #where_clause { ++ marker: _serde::export::PhantomData<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData<&#delife ()>, ++ } ++ ++ impl #de_impl_generics _serde::de::Visitor<#delife> for __Visitor #de_ty_generics #where_clause { ++ type Value = #this #ty_generics; ++ ++ fn expecting(&self, formatter: &mut _serde::export::Formatter) -> _serde::export::fmt::Result { ++ _serde::export::Formatter::write_str(formatter, #expecting) ++ } ++ ++ #visit_newtype_struct ++ ++ #[inline] ++ fn visit_seq<__A>(self, #visitor_var: __A) -> _serde::export::Result ++ where __A: _serde::de::SeqAccess<#delife> ++ { ++ #visit_seq ++ } ++ } ++ ++ #dispatch ++ } ++} ++ ++fn deserialize_seq( ++ type_path: &Tokens, ++ params: &Parameters, ++ fields: &[Field], ++ is_struct: bool, ++ cattrs: &attr::Container, ++) -> Fragment { ++ let vars = (0..fields.len()).map(field_i as fn(_) -> _); ++ ++ let deserialized_count = fields ++ .iter() ++ .filter(|field| !field.attrs.skip_deserializing()) ++ .count(); ++ let expecting = format!("tuple of {} elements", deserialized_count); ++ ++ let mut index_in_seq = 0usize; ++ let let_values = vars.clone().zip(fields) ++ .map(|(var, field)| { ++ if field.attrs.skip_deserializing() { ++ let default = Expr(expr_is_missing(&field, cattrs)); ++ quote! { ++ let #var = #default; ++ } ++ } else { ++ let visit = match field.attrs.deserialize_with() { ++ None => { ++ let field_ty = &field.ty; ++ quote!(try!(_serde::de::SeqAccess::next_element::<#field_ty>(&mut __seq))) ++ } ++ Some(path) => { ++ let (wrapper, wrapper_ty) = wrap_deserialize_field_with( ++ params, field.ty, path); ++ quote!({ ++ #wrapper ++ _serde::export::Option::map( ++ try!(_serde::de::SeqAccess::next_element::<#wrapper_ty>(&mut __seq)), ++ |__wrap| __wrap.value) ++ }) ++ } ++ }; ++ let assign = quote! { ++ let #var = match #visit { ++ Some(__value) => __value, ++ None => { ++ return _serde::export::Err(_serde::de::Error::invalid_length(#index_in_seq, &#expecting)); ++ } ++ }; ++ }; ++ index_in_seq += 1; ++ assign ++ } ++ }); ++ ++ let mut result = if is_struct { ++ let names = fields.iter().map(|f| &f.ident); ++ quote! { ++ #type_path { #( #names: #vars ),* } ++ } ++ } else { ++ quote! { ++ #type_path ( #(#vars),* ) ++ } ++ }; ++ ++ if params.has_getter { ++ let this = ¶ms.this; ++ result = quote! { ++ _serde::export::Into::<#this>::into(#result) ++ }; ++ } ++ ++ quote_block! { ++ #(#let_values)* ++ _serde::export::Ok(#result) ++ } ++} ++ ++fn deserialize_newtype_struct(type_path: &Tokens, params: &Parameters, field: &Field) -> Tokens { ++ let delife = params.borrowed.de_lifetime(); ++ ++ let value = match field.attrs.deserialize_with() { ++ None => { ++ let field_ty = &field.ty; ++ quote! { ++ try!(<#field_ty as _serde::Deserialize>::deserialize(__e)) ++ } ++ } ++ Some(path) => { ++ let (wrapper, wrapper_ty) = wrap_deserialize_field_with(params, field.ty, path); ++ quote!({ ++ #wrapper ++ try!(<#wrapper_ty as _serde::Deserialize>::deserialize(__e)).value ++ }) ++ } ++ }; ++ ++ let mut result = quote!(#type_path(#value)); ++ if params.has_getter { ++ let this = ¶ms.this; ++ result = quote! { ++ _serde::export::Into::<#this>::into(#result) ++ }; ++ } ++ ++ quote! { ++ #[inline] ++ fn visit_newtype_struct<__E>(self, __e: __E) -> _serde::export::Result ++ where __E: _serde::Deserializer<#delife> ++ { ++ _serde::export::Ok(#result) ++ } ++ } ++} ++ ++enum Untagged { ++ Yes, ++ No, ++} ++ ++fn deserialize_struct( ++ variant_ident: Option<&syn::Ident>, ++ params: &Parameters, ++ fields: &[Field], ++ cattrs: &attr::Container, ++ deserializer: Option, ++ untagged: Untagged, ++) -> Fragment { ++ let is_enum = variant_ident.is_some(); ++ ++ let this = ¶ms.this; ++ let (de_impl_generics, de_ty_generics, ty_generics, where_clause) = split_with_de_lifetime(params,); ++ let delife = params.borrowed.de_lifetime(); ++ ++ // If there are getters (implying private fields), construct the local type ++ // and use an `Into` conversion to get the remote type. If there are no ++ // getters then construct the target type directly. ++ let construct = if params.has_getter { ++ let local = ¶ms.local; ++ quote!(#local) ++ } else { ++ quote!(#this) ++ }; ++ ++ let type_path = match variant_ident { ++ Some(variant_ident) => quote!(#construct::#variant_ident), ++ None => construct, ++ }; ++ let expecting = match variant_ident { ++ Some(variant_ident) => format!("struct variant {}::{}", params.type_name(), variant_ident), ++ None => format!("struct {}", params.type_name()), ++ }; ++ ++ let visit_seq = Stmts(deserialize_seq(&type_path, params, fields, true, cattrs)); ++ ++ let (field_visitor, fields_stmt, visit_map) = ++ deserialize_struct_visitor(type_path, params, fields, cattrs); ++ let field_visitor = Stmts(field_visitor); ++ let fields_stmt = Stmts(fields_stmt); ++ let visit_map = Stmts(visit_map); ++ ++ let visitor_expr = quote! { ++ __Visitor { ++ marker: _serde::export::PhantomData::<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData, ++ } ++ }; ++ let dispatch = if let Some(deserializer) = deserializer { ++ quote! { ++ _serde::Deserializer::deserialize_any(#deserializer, #visitor_expr) ++ } ++ } else if is_enum { ++ quote! { ++ _serde::de::VariantAccess::struct_variant(__variant, FIELDS, #visitor_expr) ++ } ++ } else { ++ let type_name = cattrs.name().deserialize_name(); ++ quote! { ++ _serde::Deserializer::deserialize_struct(__deserializer, #type_name, FIELDS, #visitor_expr) ++ } ++ }; ++ ++ let all_skipped = fields ++ .iter() ++ .all(|field| field.attrs.skip_deserializing()); ++ let visitor_var = if all_skipped { ++ quote!(_) ++ } else { ++ quote!(mut __seq) ++ }; ++ ++ // untagged struct variants do not get a visit_seq method ++ let visit_seq = match untagged { ++ Untagged::Yes => None, ++ Untagged::No => { ++ Some(quote! { ++ #[inline] ++ fn visit_seq<__A>(self, #visitor_var: __A) -> _serde::export::Result ++ where __A: _serde::de::SeqAccess<#delife> ++ { ++ #visit_seq ++ } ++ }) ++ } ++ }; ++ ++ quote_block! { ++ #field_visitor ++ ++ struct __Visitor #de_impl_generics #where_clause { ++ marker: _serde::export::PhantomData<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData<&#delife ()>, ++ } ++ ++ impl #de_impl_generics _serde::de::Visitor<#delife> for __Visitor #de_ty_generics #where_clause { ++ type Value = #this #ty_generics; ++ ++ fn expecting(&self, formatter: &mut _serde::export::Formatter) -> _serde::export::fmt::Result { ++ _serde::export::Formatter::write_str(formatter, #expecting) ++ } ++ ++ #visit_seq ++ ++ #[inline] ++ fn visit_map<__A>(self, mut __map: __A) -> _serde::export::Result ++ where __A: _serde::de::MapAccess<#delife> ++ { ++ #visit_map ++ } ++ } ++ ++ #fields_stmt ++ ++ #dispatch ++ } ++} ++ ++fn deserialize_enum( ++ params: &Parameters, ++ variants: &[Variant], ++ cattrs: &attr::Container, ++) -> Fragment { ++ match *cattrs.tag() { ++ attr::EnumTag::External => deserialize_externally_tagged_enum(params, variants, cattrs), ++ attr::EnumTag::Internal { ref tag } => { ++ deserialize_internally_tagged_enum(params, variants, cattrs, tag) ++ } ++ attr::EnumTag::Adjacent { ++ ref tag, ++ ref content, ++ } => deserialize_adjacently_tagged_enum(params, variants, cattrs, tag, content), ++ attr::EnumTag::None => deserialize_untagged_enum(params, variants, cattrs), ++ } ++} ++ ++fn deserialize_externally_tagged_enum( ++ params: &Parameters, ++ variants: &[Variant], ++ cattrs: &attr::Container, ++) -> Fragment { ++ let this = ¶ms.this; ++ let (de_impl_generics, de_ty_generics, ty_generics, where_clause) = split_with_de_lifetime(params,); ++ let delife = params.borrowed.de_lifetime(); ++ ++ let type_name = cattrs.name().deserialize_name(); ++ ++ let expecting = format!("enum {}", params.type_name()); ++ ++ let variant_names_idents: Vec<_> = variants ++ .iter() ++ .enumerate() ++ .filter(|&(_, variant)| !variant.attrs.skip_deserializing()) ++ .map(|(i, variant)| (variant.attrs.name().deserialize_name(), field_i(i)),) ++ .collect(); ++ ++ let variants_stmt = { ++ let variant_names = variant_names_idents.iter().map(|&(ref name, _)| name); ++ quote! { ++ const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ]; ++ } ++ }; ++ ++ let variant_visitor = Stmts(deserialize_generated_identifier(variant_names_idents, cattrs, true),); ++ ++ // Match arms to extract a variant from a string ++ let variant_arms = variants ++ .iter() ++ .enumerate() ++ .filter(|&(_, variant)| !variant.attrs.skip_deserializing()) ++ .map( ++ |(i, variant)| { ++ let variant_name = field_i(i); ++ ++ let block = Match(deserialize_externally_tagged_variant(params, variant, cattrs),); ++ ++ quote! { ++ (__Field::#variant_name, __variant) => #block ++ } ++ }, ++ ); ++ ++ let all_skipped = variants ++ .iter() ++ .all(|variant| variant.attrs.skip_deserializing()); ++ let match_variant = if all_skipped { ++ // This is an empty enum like `enum Impossible {}` or an enum in which ++ // all variants have `#[serde(skip_deserializing)]`. ++ quote! { ++ // FIXME: Once we drop support for Rust 1.15: ++ // let _serde::export::Err(__err) = _serde::de::EnumAccess::variant::<__Field>(__data); ++ // _serde::export::Err(__err) ++ _serde::export::Result::map( ++ _serde::de::EnumAccess::variant::<__Field>(__data), ++ |(__impossible, _)| match __impossible {}) ++ } ++ } else { ++ quote! { ++ match try!(_serde::de::EnumAccess::variant(__data)) { ++ #(#variant_arms)* ++ } ++ } ++ }; ++ ++ quote_block! { ++ #variant_visitor ++ ++ struct __Visitor #de_impl_generics #where_clause { ++ marker: _serde::export::PhantomData<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData<&#delife ()>, ++ } ++ ++ impl #de_impl_generics _serde::de::Visitor<#delife> for __Visitor #de_ty_generics #where_clause { ++ type Value = #this #ty_generics; ++ ++ fn expecting(&self, formatter: &mut _serde::export::Formatter) -> _serde::export::fmt::Result { ++ _serde::export::Formatter::write_str(formatter, #expecting) ++ } ++ ++ fn visit_enum<__A>(self, __data: __A) -> _serde::export::Result ++ where __A: _serde::de::EnumAccess<#delife> ++ { ++ #match_variant ++ } ++ } ++ ++ #variants_stmt ++ ++ _serde::Deserializer::deserialize_enum(__deserializer, #type_name, VARIANTS, ++ __Visitor { ++ marker: _serde::export::PhantomData::<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData, ++ }) ++ } ++} ++ ++fn deserialize_internally_tagged_enum( ++ params: &Parameters, ++ variants: &[Variant], ++ cattrs: &attr::Container, ++ tag: &str, ++) -> Fragment { ++ let variant_names_idents: Vec<_> = variants ++ .iter() ++ .enumerate() ++ .filter(|&(_, variant)| !variant.attrs.skip_deserializing()) ++ .map(|(i, variant)| (variant.attrs.name().deserialize_name(), field_i(i)),) ++ .collect(); ++ ++ let variants_stmt = { ++ let variant_names = variant_names_idents.iter().map(|&(ref name, _)| name); ++ quote! { ++ const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ]; ++ } ++ }; ++ ++ let variant_visitor = Stmts(deserialize_generated_identifier(variant_names_idents, cattrs, true),); ++ ++ // Match arms to extract a variant from a string ++ let variant_arms = variants.iter() ++ .enumerate() ++ .filter(|&(_, variant)| !variant.attrs.skip_deserializing()) ++ .map(|(i, variant)| { ++ let variant_name = field_i(i); ++ ++ let block = Match(deserialize_internally_tagged_variant( ++ params, ++ variant, ++ cattrs, ++ quote!(_serde::private::de::ContentDeserializer::<__D::Error>::new(__tagged.content)), ++ )); ++ ++ quote! { ++ __Field::#variant_name => #block ++ } ++ }); ++ ++ quote_block! { ++ #variant_visitor ++ ++ #variants_stmt ++ ++ let __tagged = try!(_serde::Deserializer::deserialize_any( ++ __deserializer, ++ _serde::private::de::TaggedContentVisitor::<__Field>::new(#tag))); ++ ++ match __tagged.tag { ++ #(#variant_arms)* ++ } ++ } ++} ++ ++fn deserialize_adjacently_tagged_enum( ++ params: &Parameters, ++ variants: &[Variant], ++ cattrs: &attr::Container, ++ tag: &str, ++ content: &str, ++) -> Fragment { ++ let this = ¶ms.this; ++ let (de_impl_generics, de_ty_generics, ty_generics, where_clause) = split_with_de_lifetime(params,); ++ let delife = params.borrowed.de_lifetime(); ++ ++ let variant_names_idents: Vec<_> = variants ++ .iter() ++ .enumerate() ++ .filter(|&(_, variant)| !variant.attrs.skip_deserializing()) ++ .map(|(i, variant)| (variant.attrs.name().deserialize_name(), field_i(i)),) ++ .collect(); ++ ++ let variants_stmt = { ++ let variant_names = variant_names_idents.iter().map(|&(ref name, _)| name); ++ quote! { ++ const VARIANTS: &'static [&'static str] = &[ #(#variant_names),* ]; ++ } ++ }; ++ ++ let variant_visitor = Stmts(deserialize_generated_identifier(variant_names_idents, cattrs, true),); ++ ++ let ref variant_arms: Vec<_> = variants ++ .iter() ++ .enumerate() ++ .filter(|&(_, variant)| !variant.attrs.skip_deserializing()) ++ .map( ++ |(i, variant)| { ++ let variant_index = field_i(i); ++ ++ let block = Match( ++ deserialize_untagged_variant( ++ params, ++ variant, ++ cattrs, ++ quote!(__deserializer), ++ ), ++ ); ++ ++ quote! { ++ __Field::#variant_index => #block ++ } ++ }, ++ ) ++ .collect(); ++ ++ let expecting = format!("adjacently tagged enum {}", params.type_name()); ++ let type_name = cattrs.name().deserialize_name(); ++ let deny_unknown_fields = cattrs.deny_unknown_fields(); ++ ++ // If unknown fields are allowed, we pick the visitor that can step over ++ // those. Otherwise we pick the visitor that fails on unknown keys. ++ let field_visitor_ty = if deny_unknown_fields { ++ quote! { _serde::private::de::TagOrContentFieldVisitor } ++ } else { ++ quote! { _serde::private::de::TagContentOtherFieldVisitor } ++ }; ++ ++ let tag_or_content = quote! { ++ #field_visitor_ty { ++ tag: #tag, ++ content: #content, ++ } ++ }; ++ ++ fn is_unit(variant: &Variant) -> bool { ++ match variant.style { ++ Style::Unit => true, ++ Style::Struct | Style::Tuple | Style::Newtype => false, ++ } ++ } ++ ++ let mut missing_content = quote! { ++ _serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#content)) ++ }; ++ if variants.iter().any(is_unit) { ++ let fallthrough = if variants.iter().all(is_unit) { ++ None ++ } else { ++ Some( ++ quote! { ++ _ => #missing_content ++ }, ++ ) ++ }; ++ let arms = variants ++ .iter() ++ .enumerate() ++ .filter(|&(_, variant)| !variant.attrs.skip_deserializing() && is_unit(variant),) ++ .map( ++ |(i, variant)| { ++ let variant_index = field_i(i); ++ let variant_ident = &variant.ident; ++ quote! { ++ __Field::#variant_index => _serde::export::Ok(#this::#variant_ident), ++ } ++ }, ++ ); ++ missing_content = quote! { ++ match __field { ++ #(#arms)* ++ #fallthrough ++ } ++ }; ++ } ++ ++ // Advance the map by one key, returning early in case of error. ++ let next_key = quote! { ++ try!(_serde::de::MapAccess::next_key_seed(&mut __map, #tag_or_content)) ++ }; ++ ++ // When allowing unknown fields, we want to transparently step through keys ++ // we don't care about until we find `tag`, `content`, or run out of keys. ++ let next_relevant_key = if deny_unknown_fields { ++ next_key ++ } else { ++ quote! { ++ { ++ let mut __rk : _serde::export::Option<_serde::private::de::TagOrContentField> = _serde::export::None; ++ while let _serde::export::Some(__k) = #next_key { ++ match __k { ++ _serde::private::de::TagContentOtherField::Other => { ++ try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map)); ++ continue; ++ }, ++ _serde::private::de::TagContentOtherField::Tag => { ++ __rk = _serde::export::Some(_serde::private::de::TagOrContentField::Tag); ++ break; ++ } ++ _serde::private::de::TagContentOtherField::Content => { ++ __rk = _serde::export::Some(_serde::private::de::TagOrContentField::Content); ++ break; ++ } ++ } ++ } ++ ++ __rk ++ } ++ } ++ }; ++ ++ // Step through remaining keys, looking for duplicates of previously-seen ++ // keys. When unknown fields are denied, any key that isn't a duplicate will ++ // at this point immediately produce an error. ++ let visit_remaining_keys = quote! { ++ match #next_relevant_key { ++ _serde::export::Some(_serde::private::de::TagOrContentField::Tag) => { ++ _serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#tag)) ++ } ++ _serde::export::Some(_serde::private::de::TagOrContentField::Content) => { ++ _serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#content)) ++ } ++ _serde::export::None => _serde::export::Ok(__ret), ++ } ++ }; ++ ++ quote_block! { ++ #variant_visitor ++ ++ #variants_stmt ++ ++ struct __Seed #de_impl_generics #where_clause { ++ field: __Field, ++ marker: _serde::export::PhantomData<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData<&#delife ()>, ++ } ++ ++ impl #de_impl_generics _serde::de::DeserializeSeed<#delife> for __Seed #de_ty_generics #where_clause { ++ type Value = #this #ty_generics; ++ ++ fn deserialize<__D>(self, __deserializer: __D) -> _serde::export::Result ++ where __D: _serde::Deserializer<#delife> ++ { ++ match self.field { ++ #(#variant_arms)* ++ } ++ } ++ } ++ ++ struct __Visitor #de_impl_generics #where_clause { ++ marker: _serde::export::PhantomData<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData<&#delife ()>, ++ } ++ ++ impl #de_impl_generics _serde::de::Visitor<#delife> for __Visitor #de_ty_generics #where_clause { ++ type Value = #this #ty_generics; ++ ++ fn expecting(&self, formatter: &mut _serde::export::Formatter) -> _serde::export::fmt::Result { ++ _serde::export::Formatter::write_str(formatter, #expecting) ++ } ++ ++ fn visit_map<__A>(self, mut __map: __A) -> _serde::export::Result ++ where __A: _serde::de::MapAccess<#delife> ++ { ++ // Visit the first relevant key. ++ match #next_relevant_key { ++ // First key is the tag. ++ _serde::export::Some(_serde::private::de::TagOrContentField::Tag) => { ++ // Parse the tag. ++ let __field = try!(_serde::de::MapAccess::next_value(&mut __map)); ++ // Visit the second key. ++ match #next_relevant_key { ++ // Second key is a duplicate of the tag. ++ _serde::export::Some(_serde::private::de::TagOrContentField::Tag) => { ++ _serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#tag)) ++ } ++ // Second key is the content. ++ _serde::export::Some(_serde::private::de::TagOrContentField::Content) => { ++ let __ret = try!(_serde::de::MapAccess::next_value_seed(&mut __map, ++ __Seed { ++ field: __field, ++ marker: _serde::export::PhantomData, ++ lifetime: _serde::export::PhantomData, ++ })); ++ // Visit remaining keys, looking for duplicates. ++ #visit_remaining_keys ++ } ++ // There is no second key; might be okay if the we have a unit variant. ++ _serde::export::None => #missing_content ++ } ++ } ++ // First key is the content. ++ _serde::export::Some(_serde::private::de::TagOrContentField::Content) => { ++ // Buffer up the content. ++ let __content = try!(_serde::de::MapAccess::next_value::<_serde::private::de::Content>(&mut __map)); ++ // Visit the second key. ++ match #next_relevant_key { ++ // Second key is the tag. ++ _serde::export::Some(_serde::private::de::TagOrContentField::Tag) => { ++ let __deserializer = _serde::private::de::ContentDeserializer::<__A::Error>::new(__content); ++ // Parse the tag. ++ let __ret = try!(match try!(_serde::de::MapAccess::next_value(&mut __map)) { ++ // Deserialize the buffered content now that we know the variant. ++ #(#variant_arms)* ++ }); ++ // Visit remaining keys, looking for duplicates. ++ #visit_remaining_keys ++ } ++ // Second key is a duplicate of the content. ++ _serde::export::Some(_serde::private::de::TagOrContentField::Content) => { ++ _serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#content)) ++ } ++ // There is no second key. ++ _serde::export::None => { ++ _serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#tag)) ++ } ++ } ++ } ++ // There is no first key. ++ _serde::export::None => { ++ _serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#tag)) ++ } ++ } ++ } ++ ++ fn visit_seq<__A>(self, mut __seq: __A) -> _serde::export::Result ++ where __A: _serde::de::SeqAccess<#delife> ++ { ++ // Visit the first element - the tag. ++ match try!(_serde::de::SeqAccess::next_element(&mut __seq)) { ++ _serde::export::Some(__field) => { ++ // Visit the second element - the content. ++ match try!(_serde::de::SeqAccess::next_element_seed(&mut __seq, ++ __Seed { ++ field: __field, ++ marker: _serde::export::PhantomData, ++ lifetime: _serde::export::PhantomData, ++ })) { ++ _serde::export::Some(__ret) => _serde::export::Ok(__ret), ++ // There is no second element. ++ _serde::export::None => { ++ _serde::export::Err(_serde::de::Error::invalid_length(1, &self)) ++ } ++ } ++ } ++ // There is no first element. ++ _serde::export::None => { ++ _serde::export::Err(_serde::de::Error::invalid_length(0, &self)) ++ } ++ } ++ } ++ } ++ ++ const FIELDS: &'static [&'static str] = &[#tag, #content]; ++ _serde::Deserializer::deserialize_struct(__deserializer, #type_name, FIELDS, ++ __Visitor { ++ marker: _serde::export::PhantomData::<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData, ++ }) ++ } ++} ++ ++fn deserialize_untagged_enum( ++ params: &Parameters, ++ variants: &[Variant], ++ cattrs: &attr::Container, ++) -> Fragment { ++ let attempts = variants ++ .iter() ++ .filter(|variant| !variant.attrs.skip_deserializing()) ++ .map( ++ |variant| { ++ Expr(deserialize_untagged_variant( ++ params, ++ variant, ++ cattrs, ++ quote!(_serde::private::de::ContentRefDeserializer::<__D::Error>::new(&__content)), ++ )) ++ }, ++ ); ++ ++ // TODO this message could be better by saving the errors from the failed ++ // attempts. The heuristic used by TOML was to count the number of fields ++ // processed before an error, and use the error that happened after the ++ // largest number of fields. I'm not sure I like that. Maybe it would be ++ // better to save all the errors and combine them into one message that ++ // explains why none of the variants matched. ++ let fallthrough_msg = ++ format!("data did not match any variant of untagged enum {}", params.type_name()); ++ ++ quote_block! { ++ let __content = try!(<_serde::private::de::Content as _serde::Deserialize>::deserialize(__deserializer)); ++ ++ #( ++ if let _serde::export::Ok(__ok) = #attempts { ++ return _serde::export::Ok(__ok); ++ } ++ )* ++ ++ _serde::export::Err(_serde::de::Error::custom(#fallthrough_msg)) ++ } ++} ++ ++fn deserialize_externally_tagged_variant( ++ params: &Parameters, ++ variant: &Variant, ++ cattrs: &attr::Container, ++) -> Fragment { ++ if let Some(path) = variant.attrs.deserialize_with() { ++ let (wrapper, wrapper_ty, unwrap_fn) = ++ wrap_deserialize_variant_with(params, &variant, path); ++ return quote_block! { ++ #wrapper ++ _serde::export::Result::map( ++ _serde::de::VariantAccess::newtype_variant::<#wrapper_ty>(__variant), #unwrap_fn) ++ }; ++ } ++ ++ let variant_ident = &variant.ident; ++ ++ match variant.style { ++ Style::Unit => { ++ let this = ¶ms.this; ++ quote_block! { ++ try!(_serde::de::VariantAccess::unit_variant(__variant)); ++ _serde::export::Ok(#this::#variant_ident) ++ } ++ } ++ Style::Newtype => { ++ deserialize_externally_tagged_newtype_variant(variant_ident, params, &variant.fields[0]) ++ } ++ Style::Tuple => { ++ deserialize_tuple(Some(variant_ident), params, &variant.fields, cattrs, None) ++ } ++ Style::Struct => { ++ deserialize_struct(Some(variant_ident), params, &variant.fields, cattrs, None, Untagged::No) ++ } ++ } ++} ++ ++fn deserialize_internally_tagged_variant( ++ params: &Parameters, ++ variant: &Variant, ++ cattrs: &attr::Container, ++ deserializer: Tokens, ++) -> Fragment { ++ if variant.attrs.deserialize_with().is_some() { ++ return deserialize_untagged_variant(params, variant, cattrs, deserializer); ++ } ++ ++ let variant_ident = &variant.ident; ++ ++ match variant.style { ++ Style::Unit => { ++ let this = ¶ms.this; ++ let type_name = params.type_name(); ++ let variant_name = variant.ident.as_ref(); ++ quote_block! { ++ try!(_serde::Deserializer::deserialize_any(#deserializer, _serde::private::de::InternallyTaggedUnitVisitor::new(#type_name, #variant_name))); ++ _serde::export::Ok(#this::#variant_ident) ++ } ++ } ++ Style::Newtype => { ++ deserialize_untagged_newtype_variant( ++ variant_ident, ++ params, ++ &variant.fields[0], ++ deserializer, ++ ) ++ } ++ Style::Struct => { ++ deserialize_struct( ++ Some(variant_ident), ++ params, ++ &variant.fields, ++ cattrs, ++ Some(deserializer), ++ Untagged::No, ++ ) ++ } ++ Style::Tuple => unreachable!("checked in serde_derive_internals"), ++ } ++} ++ ++fn deserialize_untagged_variant( ++ params: &Parameters, ++ variant: &Variant, ++ cattrs: &attr::Container, ++ deserializer: Tokens, ++) -> Fragment { ++ if let Some(path) = variant.attrs.deserialize_with() { ++ let (wrapper, wrapper_ty, unwrap_fn) = ++ wrap_deserialize_variant_with(params, &variant, path); ++ return quote_block! { ++ #wrapper ++ _serde::export::Result::map( ++ <#wrapper_ty as _serde::Deserialize>::deserialize(#deserializer), #unwrap_fn) ++ }; ++ } ++ ++ let variant_ident = &variant.ident; ++ ++ match variant.style { ++ Style::Unit => { ++ let this = ¶ms.this; ++ let type_name = params.type_name(); ++ let variant_name = variant.ident.as_ref(); ++ quote_expr! { ++ _serde::export::Result::map( ++ _serde::Deserializer::deserialize_any( ++ #deserializer, ++ _serde::private::de::UntaggedUnitVisitor::new(#type_name, #variant_name) ++ ), ++ |()| #this::#variant_ident) ++ } ++ } ++ Style::Newtype => { ++ deserialize_untagged_newtype_variant( ++ variant_ident, ++ params, ++ &variant.fields[0], ++ deserializer, ++ ) ++ } ++ Style::Tuple => { ++ deserialize_tuple( ++ Some(variant_ident), ++ params, ++ &variant.fields, ++ cattrs, ++ Some(deserializer), ++ ) ++ } ++ Style::Struct => { ++ deserialize_struct( ++ Some(variant_ident), ++ params, ++ &variant.fields, ++ cattrs, ++ Some(deserializer), ++ Untagged::Yes, ++ ) ++ } ++ } ++} ++ ++fn deserialize_externally_tagged_newtype_variant( ++ variant_ident: &syn::Ident, ++ params: &Parameters, ++ field: &Field, ++) -> Fragment { ++ let this = ¶ms.this; ++ match field.attrs.deserialize_with() { ++ None => { ++ let field_ty = &field.ty; ++ quote_expr! { ++ _serde::export::Result::map( ++ _serde::de::VariantAccess::newtype_variant::<#field_ty>(__variant), ++ #this::#variant_ident) ++ } ++ } ++ Some(path) => { ++ let (wrapper, wrapper_ty) = wrap_deserialize_field_with(params, field.ty, path); ++ quote_block! { ++ #wrapper ++ _serde::export::Result::map( ++ _serde::de::VariantAccess::newtype_variant::<#wrapper_ty>(__variant), ++ |__wrapper| #this::#variant_ident(__wrapper.value)) ++ } ++ } ++ } ++} ++ ++fn deserialize_untagged_newtype_variant( ++ variant_ident: &syn::Ident, ++ params: &Parameters, ++ field: &Field, ++ deserializer: Tokens, ++) -> Fragment { ++ let this = ¶ms.this; ++ match field.attrs.deserialize_with() { ++ None => { ++ let field_ty = &field.ty; ++ quote_expr! { ++ _serde::export::Result::map( ++ <#field_ty as _serde::Deserialize>::deserialize(#deserializer), ++ #this::#variant_ident) ++ } ++ } ++ Some(path) => { ++ let (wrapper, wrapper_ty) = wrap_deserialize_field_with(params, field.ty, path); ++ quote_block! { ++ #wrapper ++ _serde::export::Result::map( ++ <#wrapper_ty as _serde::Deserialize>::deserialize(#deserializer), ++ |__wrapper| #this::#variant_ident(__wrapper.value)) ++ } ++ } ++ } ++} ++ ++fn deserialize_generated_identifier( ++ fields: Vec<(String, Ident)>, ++ cattrs: &attr::Container, ++ is_variant: bool, ++) -> Fragment { ++ let this = quote!(__Field); ++ let field_idents: &Vec<_> = &fields.iter().map(|&(_, ref ident)| ident).collect(); ++ ++ let (ignore_variant, fallthrough) = if is_variant || cattrs.deny_unknown_fields() { ++ (None, None) ++ } else { ++ let ignore_variant = quote!(__ignore,); ++ let fallthrough = quote!(_serde::export::Ok(__Field::__ignore)); ++ (Some(ignore_variant), Some(fallthrough)) ++ }; ++ ++ let visitor_impl = Stmts(deserialize_identifier(this, &fields, is_variant, fallthrough),); ++ ++ quote_block! { ++ #[allow(non_camel_case_types)] ++ enum __Field { ++ #(#field_idents,)* ++ #ignore_variant ++ } ++ ++ struct __FieldVisitor; ++ ++ impl<'de> _serde::de::Visitor<'de> for __FieldVisitor { ++ type Value = __Field; ++ ++ #visitor_impl ++ } ++ ++ impl<'de> _serde::Deserialize<'de> for __Field { ++ #[inline] ++ fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result ++ where __D: _serde::Deserializer<'de> ++ { ++ _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) ++ } ++ } ++ } ++} ++ ++fn deserialize_custom_identifier( ++ params: &Parameters, ++ variants: &[Variant], ++ cattrs: &attr::Container, ++) -> Fragment { ++ let is_variant = match cattrs.identifier() { ++ attr::Identifier::Variant => true, ++ attr::Identifier::Field => false, ++ attr::Identifier::No => unreachable!(), ++ }; ++ ++ let this = ¶ms.this; ++ let this = quote!(#this); ++ ++ let (ordinary, fallthrough) = if let Some(last) = variants.last() { ++ let last_ident = &last.ident; ++ if last.attrs.other() { ++ let ordinary = &variants[..variants.len() - 1]; ++ let fallthrough = quote!(_serde::export::Ok(#this::#last_ident)); ++ (ordinary, Some(fallthrough)) ++ } else if let Style::Newtype = last.style { ++ let ordinary = &variants[..variants.len() - 1]; ++ let deserializer = quote!(_serde::private::de::IdentifierDeserializer::from(__value)); ++ let fallthrough = quote! { ++ _serde::export::Result::map( ++ _serde::Deserialize::deserialize(#deserializer), ++ #this::#last_ident) ++ }; ++ (ordinary, Some(fallthrough)) ++ } else { ++ (variants, None) ++ } ++ } else { ++ (variants, None) ++ }; ++ ++ let names_idents: Vec<_> = ordinary ++ .iter() ++ .map(|variant| (variant.attrs.name().deserialize_name(), variant.ident.clone()),) ++ .collect(); ++ ++ let names = names_idents.iter().map(|&(ref name, _)| name); ++ ++ let names_const = if fallthrough.is_some() { ++ None ++ } else if is_variant { ++ let variants = quote! { ++ const VARIANTS: &'static [&'static str] = &[ #(#names),* ]; ++ }; ++ Some(variants) ++ } else { ++ let fields = quote! { ++ const FIELDS: &'static [&'static str] = &[ #(#names),* ]; ++ }; ++ Some(fields) ++ }; ++ ++ let (de_impl_generics, de_ty_generics, ty_generics, where_clause) = split_with_de_lifetime(params,); ++ let delife = params.borrowed.de_lifetime(); ++ let visitor_impl = ++ Stmts(deserialize_identifier(this.clone(), &names_idents, is_variant, fallthrough),); ++ ++ quote_block! { ++ #names_const ++ ++ struct __FieldVisitor #de_impl_generics #where_clause { ++ marker: _serde::export::PhantomData<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData<&#delife ()>, ++ } ++ ++ impl #de_impl_generics _serde::de::Visitor<#delife> for __FieldVisitor #de_ty_generics #where_clause { ++ type Value = #this #ty_generics; ++ ++ #visitor_impl ++ } ++ ++ let __visitor = __FieldVisitor { ++ marker: _serde::export::PhantomData::<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData, ++ }; ++ _serde::Deserializer::deserialize_identifier(__deserializer, __visitor) ++ } ++} ++ ++fn deserialize_identifier( ++ this: Tokens, ++ fields: &[(String, Ident)], ++ is_variant: bool, ++ fallthrough: Option, ++) -> Fragment { ++ let field_strs = fields.iter().map(|&(ref name, _)| name); ++ let field_bytes = fields.iter().map(|&(ref name, _)| quote::ByteStr(name)); ++ ++ let constructors: &Vec<_> = &fields ++ .iter() ++ .map(|&(_, ref ident)| quote!(#this::#ident)) ++ .collect(); ++ ++ let expecting = if is_variant { ++ "variant identifier" ++ } else { ++ "field identifier" ++ }; ++ ++ let index_expecting = if is_variant { ++ "variant" ++ } else { ++ "field" ++ }; ++ ++ let variant_indices = 0u64..; ++ let fallthrough_msg = format!("{} index 0 <= i < {}", index_expecting, fields.len()); ++ let visit_index = quote! { ++ fn visit_u64<__E>(self, __value: u64) -> _serde::export::Result ++ where __E: _serde::de::Error ++ { ++ match __value { ++ #( ++ #variant_indices => _serde::export::Ok(#constructors), ++ )* ++ _ => _serde::export::Err(_serde::de::Error::invalid_value( ++ _serde::de::Unexpected::Unsigned(__value), ++ &#fallthrough_msg)) ++ } ++ } ++ }; ++ ++ let bytes_to_str = if fallthrough.is_some() { ++ None ++ } else { ++ let conversion = quote! { ++ let __value = &_serde::export::from_utf8_lossy(__value); ++ }; ++ Some(conversion) ++ }; ++ ++ let fallthrough_arm = if let Some(fallthrough) = fallthrough { ++ fallthrough ++ } else if is_variant { ++ quote! { ++ _serde::export::Err(_serde::de::Error::unknown_variant(__value, VARIANTS)) ++ } ++ } else { ++ quote! { ++ _serde::export::Err(_serde::de::Error::unknown_field(__value, FIELDS)) ++ } ++ }; ++ ++ quote_block! { ++ fn expecting(&self, formatter: &mut _serde::export::Formatter) -> _serde::export::fmt::Result { ++ _serde::export::Formatter::write_str(formatter, #expecting) ++ } ++ ++ #visit_index ++ ++ fn visit_str<__E>(self, __value: &str) -> _serde::export::Result ++ where __E: _serde::de::Error ++ { ++ match __value { ++ #( ++ #field_strs => _serde::export::Ok(#constructors), ++ )* ++ _ => #fallthrough_arm ++ } ++ } ++ ++ fn visit_bytes<__E>(self, __value: &[u8]) -> _serde::export::Result ++ where __E: _serde::de::Error ++ { ++ match __value { ++ #( ++ #field_bytes => _serde::export::Ok(#constructors), ++ )* ++ _ => { ++ #bytes_to_str ++ #fallthrough_arm ++ } ++ } ++ } ++ } ++} ++ ++fn deserialize_struct_visitor( ++ struct_path: Tokens, ++ params: &Parameters, ++ fields: &[Field], ++ cattrs: &attr::Container, ++) -> (Fragment, Fragment, Fragment) { ++ let field_names_idents: Vec<_> = fields ++ .iter() ++ .enumerate() ++ .filter(|&(_, field)| !field.attrs.skip_deserializing()) ++ .map(|(i, field)| (field.attrs.name().deserialize_name(), field_i(i)),) ++ .collect(); ++ ++ let fields_stmt = { ++ let field_names = field_names_idents.iter().map(|&(ref name, _)| name); ++ quote_block! { ++ const FIELDS: &'static [&'static str] = &[ #(#field_names),* ]; ++ } ++ }; ++ ++ let field_visitor = deserialize_generated_identifier(field_names_idents, cattrs, false); ++ ++ let visit_map = deserialize_map(struct_path, params, fields, cattrs); ++ ++ (field_visitor, fields_stmt, visit_map) ++} ++ ++fn deserialize_map( ++ struct_path: Tokens, ++ params: &Parameters, ++ fields: &[Field], ++ cattrs: &attr::Container, ++) -> Fragment { ++ // Create the field names for the fields. ++ let fields_names: Vec<_> = fields ++ .iter() ++ .enumerate() ++ .map(|(i, field)| (field, field_i(i))) ++ .collect(); ++ ++ // Declare each field that will be deserialized. ++ let let_values = fields_names ++ .iter() ++ .filter(|&&(field, _)| !field.attrs.skip_deserializing()) ++ .map( ++ |&(field, ref name)| { ++ let field_ty = &field.ty; ++ quote! { ++ let mut #name: _serde::export::Option<#field_ty> = _serde::export::None; ++ } ++ }, ++ ); ++ ++ // Match arms to extract a value for a field. ++ let value_arms = fields_names.iter() ++ .filter(|&&(field, _)| !field.attrs.skip_deserializing()) ++ .map(|&(field, ref name)| { ++ let deser_name = field.attrs.name().deserialize_name(); ++ ++ let visit = match field.attrs.deserialize_with() { ++ None => { ++ let field_ty = &field.ty; ++ quote! { ++ try!(_serde::de::MapAccess::next_value::<#field_ty>(&mut __map)) ++ } ++ } ++ Some(path) => { ++ let (wrapper, wrapper_ty) = wrap_deserialize_field_with( ++ params, field.ty, path); ++ quote!({ ++ #wrapper ++ try!(_serde::de::MapAccess::next_value::<#wrapper_ty>(&mut __map)).value ++ }) ++ } ++ }; ++ quote! { ++ __Field::#name => { ++ if _serde::export::Option::is_some(&#name) { ++ return _serde::export::Err(<__A::Error as _serde::de::Error>::duplicate_field(#deser_name)); ++ } ++ #name = _serde::export::Some(#visit); ++ } ++ } ++ }); ++ ++ // Visit ignored values to consume them ++ let ignored_arm = if cattrs.deny_unknown_fields() { ++ None ++ } else { ++ Some(quote! { ++ _ => { let _ = try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map)); } ++ }) ++ }; ++ ++ let all_skipped = fields ++ .iter() ++ .all(|field| field.attrs.skip_deserializing()); ++ let match_keys = if cattrs.deny_unknown_fields() && all_skipped { ++ quote! { ++ // FIXME: Once we drop support for Rust 1.15: ++ // let _serde::export::None::<__Field> = try!(_serde::de::MapAccess::next_key(&mut __map)); ++ _serde::export::Option::map( ++ try!(_serde::de::MapAccess::next_key::<__Field>(&mut __map)), ++ |__impossible| match __impossible {}); ++ } ++ } else { ++ quote! { ++ while let _serde::export::Some(__key) = try!(_serde::de::MapAccess::next_key::<__Field>(&mut __map)) { ++ match __key { ++ #(#value_arms)* ++ #ignored_arm ++ } ++ } ++ } ++ }; ++ ++ let extract_values = fields_names ++ .iter() ++ .filter(|&&(field, _)| !field.attrs.skip_deserializing()) ++ .map( ++ |&(field, ref name)| { ++ let missing_expr = Match(expr_is_missing(&field, cattrs)); ++ ++ quote! { ++ let #name = match #name { ++ _serde::export::Some(#name) => #name, ++ _serde::export::None => #missing_expr ++ }; ++ } ++ }, ++ ); ++ ++ let result = fields_names ++ .iter() ++ .map( ++ |&(field, ref name)| { ++ let ident = field ++ .ident ++ .clone() ++ .expect("struct contains unnamed fields"); ++ if field.attrs.skip_deserializing() { ++ let value = Expr(expr_is_missing(&field, cattrs)); ++ quote!(#ident: #value) ++ } else { ++ quote!(#ident: #name) ++ } ++ }, ++ ); ++ ++ let let_default = match *cattrs.default() { ++ attr::Default::Default => { ++ Some( ++ quote!( ++ let __default: Self::Value = _serde::export::Default::default(); ++ ), ++ ) ++ } ++ attr::Default::Path(ref path) => { ++ Some( ++ quote!( ++ let __default: Self::Value = #path(); ++ ), ++ ) ++ } ++ attr::Default::None => { ++ // We don't need the default value, to prevent an unused variable warning ++ // we'll leave the line empty. ++ None ++ } ++ }; ++ ++ let mut result = quote!(#struct_path { #(#result),* }); ++ if params.has_getter { ++ let this = ¶ms.this; ++ result = quote! { ++ _serde::export::Into::<#this>::into(#result) ++ }; ++ } ++ ++ quote_block! { ++ #(#let_values)* ++ ++ #match_keys ++ ++ #let_default ++ ++ #(#extract_values)* ++ ++ _serde::export::Ok(#result) ++ } ++} ++ ++fn field_i(i: usize) -> Ident { ++ Ident::new(format!("__field{}", i)) ++} ++ ++/// This function wraps the expression in `#[serde(deserialize_with = "...")]` ++/// in a trait to prevent it from accessing the internal `Deserialize` state. ++fn wrap_deserialize_with( ++ params: &Parameters, ++ value_ty: Tokens, ++ deserialize_with: &syn::Path, ++) -> (Tokens, Tokens) { ++ let this = ¶ms.this; ++ let (de_impl_generics, de_ty_generics, ty_generics, where_clause) = split_with_de_lifetime(params,); ++ let delife = params.borrowed.de_lifetime(); ++ ++ let wrapper = quote! { ++ struct __DeserializeWith #de_impl_generics #where_clause { ++ value: #value_ty, ++ phantom: _serde::export::PhantomData<#this #ty_generics>, ++ lifetime: _serde::export::PhantomData<&#delife ()>, ++ } ++ ++ impl #de_impl_generics _serde::Deserialize<#delife> for __DeserializeWith #de_ty_generics #where_clause { ++ fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result ++ where __D: _serde::Deserializer<#delife> ++ { ++ _serde::export::Ok(__DeserializeWith { ++ value: try!(#deserialize_with(__deserializer)), ++ phantom: _serde::export::PhantomData, ++ lifetime: _serde::export::PhantomData, ++ }) ++ } ++ } ++ }; ++ ++ let wrapper_ty = quote!(__DeserializeWith #de_ty_generics); ++ ++ (wrapper, wrapper_ty) ++} ++ ++fn wrap_deserialize_field_with( ++ params: &Parameters, ++ field_ty: &syn::Ty, ++ deserialize_with: &syn::Path, ++) -> (Tokens, Tokens) { ++ wrap_deserialize_with(params, quote!(#field_ty), deserialize_with) ++} ++ ++fn wrap_deserialize_variant_with( ++ params: &Parameters, ++ variant: &Variant, ++ deserialize_with: &syn::Path, ++) -> (Tokens, Tokens, Tokens) { ++ let this = ¶ms.this; ++ let variant_ident = &variant.ident; ++ ++ let field_tys = variant.fields.iter().map(|field| field.ty); ++ let (wrapper, wrapper_ty) = ++ wrap_deserialize_with(params, quote!((#(#field_tys),*)), deserialize_with); ++ ++ let field_access = (0..variant.fields.len()).map(|n| Ident::new(format!("{}", n))); ++ let unwrap_fn = match variant.style { ++ Style::Struct => { ++ let field_idents = variant.fields.iter().map(|field| field.ident.as_ref().unwrap()); ++ quote! { ++ { ++ |__wrap| { ++ #this::#variant_ident { #(#field_idents: __wrap.value.#field_access),* } ++ } ++ } ++ } ++ } ++ Style::Tuple => { ++ quote! { ++ { ++ |__wrap| { ++ #this::#variant_ident(#(__wrap.value.#field_access),*) ++ } ++ } ++ } ++ } ++ Style::Newtype => { ++ quote! { ++ { ++ |__wrap| { ++ #this::#variant_ident(__wrap.value) ++ } ++ } ++ } ++ } ++ Style::Unit => { ++ quote! { ++ { ++ |__wrap| { #this::#variant_ident } ++ } ++ } ++ } ++ }; ++ ++ (wrapper, wrapper_ty, unwrap_fn) ++} ++ ++fn expr_is_missing(field: &Field, cattrs: &attr::Container) -> Fragment { ++ match *field.attrs.default() { ++ attr::Default::Default => { ++ return quote_expr!(_serde::export::Default::default()); ++ } ++ attr::Default::Path(ref path) => { ++ return quote_expr!(#path()); ++ } ++ attr::Default::None => { /* below */ } ++ } ++ ++ match *cattrs.default() { ++ attr::Default::Default | ++ attr::Default::Path(_) => { ++ let ident = &field.ident; ++ return quote_expr!(__default.#ident); ++ } ++ attr::Default::None => { /* below */ } ++ } ++ ++ let name = field.attrs.name().deserialize_name(); ++ match field.attrs.deserialize_with() { ++ None => { ++ quote_expr! { ++ try!(_serde::private::de::missing_field(#name)) ++ } ++ } ++ Some(_) => { ++ quote_expr! { ++ return _serde::export::Err(<__A::Error as _serde::de::Error>::missing_field(#name)) ++ } ++ } ++ } ++} ++ ++struct DeImplGenerics<'a>(&'a Parameters); ++ ++impl<'a> ToTokens for DeImplGenerics<'a> { ++ fn to_tokens(&self, tokens: &mut Tokens) { ++ let mut generics = self.0.generics.clone(); ++ if let Some(de_lifetime) = self.0.borrowed.de_lifetime_def() { ++ generics.lifetimes.insert(0, de_lifetime); ++ } ++ let (impl_generics, _, _) = generics.split_for_impl(); ++ impl_generics.to_tokens(tokens); ++ } ++} ++ ++struct DeTyGenerics<'a>(&'a Parameters); ++ ++impl<'a> ToTokens for DeTyGenerics<'a> { ++ fn to_tokens(&self, tokens: &mut Tokens) { ++ let mut generics = self.0.generics.clone(); ++ if self.0.borrowed.de_lifetime_def().is_some() { ++ generics ++ .lifetimes ++ .insert(0, syn::LifetimeDef::new("'de")); ++ } ++ let (_, ty_generics, _) = generics.split_for_impl(); ++ ty_generics.to_tokens(tokens); ++ } ++} ++ ++fn split_with_de_lifetime(params: &Parameters,) ++ -> (DeImplGenerics, DeTyGenerics, syn::TyGenerics, &syn::WhereClause) { ++ let de_impl_generics = DeImplGenerics(¶ms); ++ let de_ty_generics = DeTyGenerics(¶ms); ++ let (_, ty_generics, where_clause) = params.generics.split_for_impl(); ++ (de_impl_generics, de_ty_generics, ty_generics, where_clause) ++} diff --cc vendor/serde_derive-1.0.15/src/fragment.rs index 000000000,000000000..58cf0a2ca new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/src/fragment.rs @@@ -1,0 -1,0 +1,75 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use quote::{Tokens, ToTokens}; ++ ++pub enum Fragment { ++ /// Tokens that can be used as an expression. ++ Expr(Tokens), ++ /// Tokens that can be used inside a block. The surrounding curly braces are ++ /// not part of these tokens. ++ Block(Tokens), ++} ++ ++macro_rules! quote_expr { ++ ($($tt:tt)*) => { ++ $crate::fragment::Fragment::Expr(quote!($($tt)*)) ++ } ++} ++ ++macro_rules! quote_block { ++ ($($tt:tt)*) => { ++ $crate::fragment::Fragment::Block(quote!($($tt)*)) ++ } ++} ++ ++/// Interpolate a fragment in place of an expression. This involves surrounding ++/// Block fragments in curly braces. ++pub struct Expr(pub Fragment); ++impl ToTokens for Expr { ++ fn to_tokens(&self, out: &mut Tokens) { ++ match self.0 { ++ Fragment::Expr(ref expr) => expr.to_tokens(out), ++ Fragment::Block(ref block) => { ++ out.append("{"); ++ block.to_tokens(out); ++ out.append("}"); ++ } ++ } ++ } ++} ++ ++/// Interpolate a fragment as the statements of a block. ++pub struct Stmts(pub Fragment); ++impl ToTokens for Stmts { ++ fn to_tokens(&self, out: &mut Tokens) { ++ match self.0 { ++ Fragment::Expr(ref expr) => expr.to_tokens(out), ++ Fragment::Block(ref block) => block.to_tokens(out), ++ } ++ } ++} ++ ++/// Interpolate a fragment as the value part of a `match` expression. This ++/// involves putting a comma after expressions and curly braces around blocks. ++pub struct Match(pub Fragment); ++impl ToTokens for Match { ++ fn to_tokens(&self, out: &mut Tokens) { ++ match self.0 { ++ Fragment::Expr(ref expr) => { ++ expr.to_tokens(out); ++ out.append(","); ++ } ++ Fragment::Block(ref block) => { ++ out.append("{"); ++ block.to_tokens(out); ++ out.append("}"); ++ } ++ } ++ } ++} diff --cc vendor/serde_derive-1.0.15/src/lib.rs index 000000000,000000000..cc6d41312 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/src/lib.rs @@@ -1,0 -1,0 +1,60 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! This crate provides Serde's two derive macros. ++//! ++//! ```rust,ignore ++//! #[derive(Serialize, Deserialize)] ++//! ``` ++//! ++//! Please refer to [https://serde.rs/derive.html] for how to set this up. ++//! ++//! [https://serde.rs/derive.html]: https://serde.rs/derive.html ++ ++#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.15")] ++ ++#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] ++#![cfg_attr(feature = "cargo-clippy", allow(used_underscore_binding))] ++ ++// The `quote!` macro requires deep recursion. ++#![recursion_limit = "192"] ++ ++extern crate syn; ++#[macro_use] ++extern crate quote; ++ ++extern crate serde_derive_internals as internals; ++ ++extern crate proc_macro; ++use proc_macro::TokenStream; ++ ++#[macro_use] ++mod bound; ++#[macro_use] ++mod fragment; ++ ++mod ser; ++mod de; ++ ++#[proc_macro_derive(Serialize, attributes(serde))] ++pub fn derive_serialize(input: TokenStream) -> TokenStream { ++ let input = syn::parse_derive_input(&input.to_string()).unwrap(); ++ match ser::expand_derive_serialize(&input) { ++ Ok(expanded) => expanded.parse().unwrap(), ++ Err(msg) => panic!(msg), ++ } ++} ++ ++#[proc_macro_derive(Deserialize, attributes(serde))] ++pub fn derive_deserialize(input: TokenStream) -> TokenStream { ++ let input = syn::parse_derive_input(&input.to_string()).unwrap(); ++ match de::expand_derive_deserialize(&input) { ++ Ok(expanded) => expanded.parse().unwrap(), ++ Err(msg) => panic!(msg), ++ } ++} diff --cc vendor/serde_derive-1.0.15/src/ser.rs index 000000000,000000000..aa4891931 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive-1.0.15/src/ser.rs @@@ -1,0 -1,0 +1,1043 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use syn::{self, Ident}; ++use quote::Tokens; ++ ++use bound; ++use fragment::{Fragment, Stmts, Match}; ++use internals::ast::{Body, Container, Field, Style, Variant}; ++use internals::{attr, Ctxt}; ++ ++use std::u32; ++ ++pub fn expand_derive_serialize(input: &syn::DeriveInput) -> Result { ++ let ctxt = Ctxt::new(); ++ let cont = Container::from_ast(&ctxt, input); ++ precondition(&ctxt, &cont); ++ try!(ctxt.check()); ++ ++ let ident = &cont.ident; ++ let params = Parameters::new(&cont); ++ let (impl_generics, ty_generics, where_clause) = params.generics.split_for_impl(); ++ let dummy_const = Ident::new(format!("_IMPL_SERIALIZE_FOR_{}", ident)); ++ let body = Stmts(serialize_body(&cont, ¶ms)); ++ ++ let impl_block = if let Some(remote) = cont.attrs.remote() { ++ let vis = &input.vis; ++ quote! { ++ impl #impl_generics #ident #ty_generics #where_clause { ++ #vis fn serialize<__S>(__self: &#remote #ty_generics, __serializer: __S) -> _serde::export::Result<__S::Ok, __S::Error> ++ where __S: _serde::Serializer ++ { ++ #body ++ } ++ } ++ } ++ } else { ++ quote! { ++ #[automatically_derived] ++ impl #impl_generics _serde::Serialize for #ident #ty_generics #where_clause { ++ fn serialize<__S>(&self, __serializer: __S) -> _serde::export::Result<__S::Ok, __S::Error> ++ where __S: _serde::Serializer ++ { ++ #body ++ } ++ } ++ } ++ }; ++ ++ let generated = quote! { ++ #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] ++ const #dummy_const: () = { ++ extern crate serde as _serde; ++ #impl_block ++ }; ++ }; ++ Ok(generated) ++} ++ ++fn precondition(cx: &Ctxt, cont: &Container) { ++ match cont.attrs.identifier() { ++ attr::Identifier::No => {} ++ attr::Identifier::Field => { ++ cx.error("field identifiers cannot be serialized"); ++ } ++ attr::Identifier::Variant => { ++ cx.error("variant identifiers cannot be serialized"); ++ } ++ } ++} ++ ++struct Parameters { ++ /// Variable holding the value being serialized. Either `self` for local ++ /// types or `__self` for remote types. ++ self_var: Ident, ++ ++ /// Path to the type the impl is for. Either a single `Ident` for local ++ /// types or `some::remote::Ident` for remote types. Does not include ++ /// generic parameters. ++ this: syn::Path, ++ ++ /// Generics including any explicit and inferred bounds for the impl. ++ generics: syn::Generics, ++ ++ /// Type has a `serde(remote = "...")` attribute. ++ is_remote: bool, ++} ++ ++impl Parameters { ++ fn new(cont: &Container) -> Self { ++ let is_remote = cont.attrs.remote().is_some(); ++ let self_var = if is_remote { ++ Ident::new("__self") ++ } else { ++ Ident::new("self") ++ }; ++ ++ let this = match cont.attrs.remote() { ++ Some(remote) => remote.clone(), ++ None => cont.ident.clone().into(), ++ }; ++ ++ let generics = build_generics(cont); ++ ++ Parameters { ++ self_var: self_var, ++ this: this, ++ generics: generics, ++ is_remote: is_remote, ++ } ++ } ++ ++ /// Type name to use in error messages and `&'static str` arguments to ++ /// various Serializer methods. ++ fn type_name(&self) -> &str { ++ self.this.segments.last().unwrap().ident.as_ref() ++ } ++} ++ ++// All the generics in the input, plus a bound `T: Serialize` for each generic ++// field type that will be serialized by us. ++fn build_generics(cont: &Container) -> syn::Generics { ++ let generics = bound::without_defaults(cont.generics); ++ ++ let generics = ++ bound::with_where_predicates_from_fields(cont, &generics, attr::Field::ser_bound); ++ ++ match cont.attrs.ser_bound() { ++ Some(predicates) => bound::with_where_predicates(&generics, predicates), ++ None => { ++ bound::with_bound( ++ cont, ++ &generics, ++ needs_serialize_bound, ++ &path!(_serde::Serialize), ++ ) ++ } ++ } ++} ++ ++// Fields with a `skip_serializing` or `serialize_with` attribute, or which ++// belong to a variant with a `serialize_with` attribute, are not serialized by ++// us so we do not generate a bound. Fields with a `bound` attribute specify ++// their own bound so we do not generate one. All other fields may need a `T: ++// Serialize` bound where T is the type of the field. ++fn needs_serialize_bound(field: &attr::Field, variant: Option<&attr::Variant>) -> bool { ++ !field.skip_serializing() && ++ field.serialize_with().is_none() && ++ field.ser_bound().is_none() && ++ variant.map_or(true, |variant| variant.serialize_with().is_none()) ++} ++ ++fn serialize_body(cont: &Container, params: &Parameters) -> Fragment { ++ if let Some(into_type) = cont.attrs.into_type() { ++ serialize_into(params, into_type) ++ } else { ++ match cont.body { ++ Body::Enum(ref variants) => serialize_enum(params, variants, &cont.attrs), ++ Body::Struct(Style::Struct, ref fields) => { ++ if fields.iter().any(|field| field.ident.is_none()) { ++ panic!("struct has unnamed fields"); ++ } ++ serialize_struct(params, fields, &cont.attrs) ++ } ++ Body::Struct(Style::Tuple, ref fields) => { ++ if fields.iter().any(|field| field.ident.is_some()) { ++ panic!("tuple struct has named fields"); ++ } ++ serialize_tuple_struct(params, fields, &cont.attrs) ++ } ++ Body::Struct(Style::Newtype, ref fields) => { ++ serialize_newtype_struct(params, &fields[0], &cont.attrs) ++ } ++ Body::Struct(Style::Unit, _) => serialize_unit_struct(&cont.attrs), ++ } ++ } ++} ++ ++fn serialize_into(params: &Parameters, into_type: &syn::Ty) -> Fragment { ++ let self_var = ¶ms.self_var; ++ quote_block! { ++ _serde::Serialize::serialize( ++ &_serde::export::Into::<#into_type>::into(_serde::export::Clone::clone(#self_var)), ++ __serializer) ++ } ++} ++ ++fn serialize_unit_struct(cattrs: &attr::Container) -> Fragment { ++ let type_name = cattrs.name().serialize_name(); ++ ++ quote_expr! { ++ _serde::Serializer::serialize_unit_struct(__serializer, #type_name) ++ } ++} ++ ++fn serialize_newtype_struct( ++ params: &Parameters, ++ field: &Field, ++ cattrs: &attr::Container, ++) -> Fragment { ++ let type_name = cattrs.name().serialize_name(); ++ ++ let mut field_expr = get_field(params, field, 0); ++ if let Some(path) = field.attrs.serialize_with() { ++ field_expr = wrap_serialize_field_with(params, field.ty, path, field_expr); ++ } ++ ++ quote_expr! { ++ _serde::Serializer::serialize_newtype_struct(__serializer, #type_name, #field_expr) ++ } ++} ++ ++fn serialize_tuple_struct( ++ params: &Parameters, ++ fields: &[Field], ++ cattrs: &attr::Container, ++) -> Fragment { ++ let serialize_stmts = serialize_tuple_struct_visitor( ++ fields, ++ params, ++ false, ++ quote!(_serde::ser::SerializeTupleStruct::serialize_field), ++ ); ++ ++ let type_name = cattrs.name().serialize_name(); ++ let len = serialize_stmts.len(); ++ let let_mut = mut_if(len > 0); ++ ++ quote_block! { ++ let #let_mut __serde_state = try!(_serde::Serializer::serialize_tuple_struct(__serializer, #type_name, #len)); ++ #(#serialize_stmts)* ++ _serde::ser::SerializeTupleStruct::end(__serde_state) ++ } ++} ++ ++fn serialize_struct(params: &Parameters, fields: &[Field], cattrs: &attr::Container) -> Fragment { ++ assert!(fields.len() as u64 <= u32::MAX as u64); ++ ++ let serialize_fields = serialize_struct_visitor( ++ fields, ++ params, ++ false, ++ quote!(_serde::ser::SerializeStruct::serialize_field), ++ quote!(_serde::ser::SerializeStruct::skip_field), ++ ); ++ ++ let type_name = cattrs.name().serialize_name(); ++ ++ let mut serialized_fields = fields ++ .iter() ++ .filter(|&field| !field.attrs.skip_serializing()) ++ .peekable(); ++ ++ let let_mut = mut_if(serialized_fields.peek().is_some()); ++ ++ let len = serialized_fields ++ .map( ++ |field| match field.attrs.skip_serializing_if() { ++ None => quote!(1), ++ Some(path) => { ++ let ident = field.ident.clone().expect("struct has unnamed fields"); ++ let field_expr = get_field(params, field, ident); ++ quote!(if #path(#field_expr) { 0 } else { 1 }) ++ } ++ }, ++ ) ++ .fold(quote!(0), |sum, expr| quote!(#sum + #expr)); ++ ++ quote_block! { ++ let #let_mut __serde_state = try!(_serde::Serializer::serialize_struct(__serializer, #type_name, #len)); ++ #(#serialize_fields)* ++ _serde::ser::SerializeStruct::end(__serde_state) ++ } ++} ++ ++fn serialize_enum(params: &Parameters, variants: &[Variant], cattrs: &attr::Container) -> Fragment { ++ assert!(variants.len() as u64 <= u32::MAX as u64); ++ ++ let self_var = ¶ms.self_var; ++ ++ let arms: Vec<_> = variants ++ .iter() ++ .enumerate() ++ .map( ++ |(variant_index, variant)| { ++ serialize_variant(params, variant, variant_index as u32, cattrs) ++ }, ++ ) ++ .collect(); ++ ++ quote_expr! { ++ match *#self_var { ++ #(#arms)* ++ } ++ } ++} ++ ++fn serialize_variant( ++ params: &Parameters, ++ variant: &Variant, ++ variant_index: u32, ++ cattrs: &attr::Container, ++) -> Tokens { ++ let this = ¶ms.this; ++ let variant_ident = variant.ident.clone(); ++ ++ if variant.attrs.skip_serializing() { ++ let skipped_msg = format!( ++ "the enum variant {}::{} cannot be serialized", ++ params.type_name(), ++ variant_ident ++ ); ++ let skipped_err = quote! { ++ _serde::export::Err(_serde::ser::Error::custom(#skipped_msg)) ++ }; ++ let fields_pat = match variant.style { ++ Style::Unit => quote!(), ++ Style::Newtype | Style::Tuple => quote!((..)), ++ Style::Struct => { ++ quote!( ++ { ++ .. ++ } ++ ) ++ } ++ }; ++ quote! { ++ #this::#variant_ident #fields_pat => #skipped_err, ++ } ++ } else { ++ // variant wasn't skipped ++ let case = match variant.style { ++ Style::Unit => { ++ quote! { ++ #this::#variant_ident ++ } ++ } ++ Style::Newtype => { ++ quote! { ++ #this::#variant_ident(ref __field0) ++ } ++ } ++ Style::Tuple => { ++ let field_names = ++ (0..variant.fields.len()).map(|i| Ident::new(format!("__field{}", i))); ++ quote! { ++ #this::#variant_ident(#(ref #field_names),*) ++ } ++ } ++ Style::Struct => { ++ let fields = variant ++ .fields ++ .iter() ++ .map( ++ |f| { ++ f.ident ++ .clone() ++ .expect("struct variant has unnamed fields") ++ }, ++ ); ++ quote! { ++ #this::#variant_ident { #(ref #fields),* } ++ } ++ } ++ }; ++ ++ let body = Match( ++ match *cattrs.tag() { ++ attr::EnumTag::External => { ++ serialize_externally_tagged_variant(params, variant, variant_index, cattrs) ++ } ++ attr::EnumTag::Internal { ref tag } => { ++ serialize_internally_tagged_variant(params, variant, cattrs, tag) ++ } ++ attr::EnumTag::Adjacent { ++ ref tag, ++ ref content, ++ } => serialize_adjacently_tagged_variant(params, variant, cattrs, tag, content), ++ attr::EnumTag::None => serialize_untagged_variant(params, variant, cattrs), ++ }, ++ ); ++ ++ quote! { ++ #case => #body ++ } ++ } ++} ++ ++fn serialize_externally_tagged_variant( ++ params: &Parameters, ++ variant: &Variant, ++ variant_index: u32, ++ cattrs: &attr::Container, ++) -> Fragment { ++ let type_name = cattrs.name().serialize_name(); ++ let variant_name = variant.attrs.name().serialize_name(); ++ ++ if let Some(path) = variant.attrs.serialize_with() { ++ let ser = wrap_serialize_variant_with(params, path, &variant); ++ return quote_expr! { ++ _serde::Serializer::serialize_newtype_variant( ++ __serializer, ++ #type_name, ++ #variant_index, ++ #variant_name, ++ #ser, ++ ) ++ }; ++ } ++ ++ match variant.style { ++ Style::Unit => { ++ quote_expr! { ++ _serde::Serializer::serialize_unit_variant( ++ __serializer, ++ #type_name, ++ #variant_index, ++ #variant_name, ++ ) ++ } ++ } ++ Style::Newtype => { ++ let field = &variant.fields[0]; ++ let mut field_expr = quote!(__field0); ++ if let Some(path) = field.attrs.serialize_with() { ++ field_expr = wrap_serialize_field_with(params, field.ty, path, field_expr); ++ } ++ ++ quote_expr! { ++ _serde::Serializer::serialize_newtype_variant( ++ __serializer, ++ #type_name, ++ #variant_index, ++ #variant_name, ++ #field_expr, ++ ) ++ } ++ } ++ Style::Tuple => { ++ serialize_tuple_variant( ++ TupleVariant::ExternallyTagged { ++ type_name: type_name, ++ variant_index: variant_index, ++ variant_name: variant_name, ++ }, ++ params, ++ &variant.fields, ++ ) ++ } ++ Style::Struct => { ++ serialize_struct_variant( ++ StructVariant::ExternallyTagged { ++ variant_index: variant_index, ++ variant_name: variant_name, ++ }, ++ params, ++ &variant.fields, ++ &type_name, ++ ) ++ } ++ } ++} ++ ++fn serialize_internally_tagged_variant( ++ params: &Parameters, ++ variant: &Variant, ++ cattrs: &attr::Container, ++ tag: &str, ++) -> Fragment { ++ let type_name = cattrs.name().serialize_name(); ++ let variant_name = variant.attrs.name().serialize_name(); ++ ++ let enum_ident_str = params.type_name(); ++ let variant_ident_str = variant.ident.as_ref(); ++ ++ if let Some(path) = variant.attrs.serialize_with() { ++ let ser = wrap_serialize_variant_with(params, path, &variant); ++ return quote_expr! { ++ _serde::private::ser::serialize_tagged_newtype( ++ __serializer, ++ #enum_ident_str, ++ #variant_ident_str, ++ #tag, ++ #variant_name, ++ #ser, ++ ) ++ }; ++ } ++ ++ match variant.style { ++ Style::Unit => { ++ quote_block! { ++ let mut __struct = try!(_serde::Serializer::serialize_struct( ++ __serializer, #type_name, 1)); ++ try!(_serde::ser::SerializeStruct::serialize_field( ++ &mut __struct, #tag, #variant_name)); ++ _serde::ser::SerializeStruct::end(__struct) ++ } ++ } ++ Style::Newtype => { ++ let field = &variant.fields[0]; ++ let mut field_expr = quote!(__field0); ++ if let Some(path) = field.attrs.serialize_with() { ++ field_expr = wrap_serialize_field_with(params, field.ty, path, field_expr); ++ } ++ ++ quote_expr! { ++ _serde::private::ser::serialize_tagged_newtype( ++ __serializer, ++ #enum_ident_str, ++ #variant_ident_str, ++ #tag, ++ #variant_name, ++ #field_expr, ++ ) ++ } ++ } ++ Style::Struct => { ++ serialize_struct_variant( ++ StructVariant::InternallyTagged { ++ tag: tag, ++ variant_name: variant_name, ++ }, ++ params, ++ &variant.fields, ++ &type_name, ++ ) ++ } ++ Style::Tuple => unreachable!("checked in serde_derive_internals"), ++ } ++} ++ ++fn serialize_adjacently_tagged_variant( ++ params: &Parameters, ++ variant: &Variant, ++ cattrs: &attr::Container, ++ tag: &str, ++ content: &str, ++) -> Fragment { ++ let this = ¶ms.this; ++ let type_name = cattrs.name().serialize_name(); ++ let variant_name = variant.attrs.name().serialize_name(); ++ ++ let inner = Stmts( ++ if let Some(path) = variant.attrs.serialize_with() { ++ let ser = wrap_serialize_variant_with(params, path, &variant); ++ quote_expr! { ++ _serde::Serialize::serialize(#ser, __serializer) ++ } ++ } else { ++ match variant.style { ++ Style::Unit => { ++ return quote_block! { ++ let mut __struct = try!(_serde::Serializer::serialize_struct( ++ __serializer, #type_name, 1)); ++ try!(_serde::ser::SerializeStruct::serialize_field( ++ &mut __struct, #tag, #variant_name)); ++ _serde::ser::SerializeStruct::end(__struct) ++ }; ++ } ++ Style::Newtype => { ++ let field = &variant.fields[0]; ++ let mut field_expr = quote!(__field0); ++ if let Some(path) = field.attrs.serialize_with() { ++ field_expr = wrap_serialize_field_with(params, field.ty, path, field_expr); ++ } ++ ++ quote_expr! { ++ _serde::Serialize::serialize(#field_expr, __serializer) ++ } ++ } ++ Style::Tuple => { ++ serialize_tuple_variant(TupleVariant::Untagged, params, &variant.fields) ++ } ++ Style::Struct => { ++ serialize_struct_variant( ++ StructVariant::Untagged, ++ params, ++ &variant.fields, ++ &variant_name, ++ ) ++ } ++ } ++ }, ++ ); ++ ++ let fields_ty = variant.fields.iter().map(|f| &f.ty); ++ let ref fields_ident: Vec<_> = match variant.style { ++ Style::Unit => { ++ if variant.attrs.serialize_with().is_some() { ++ vec![] ++ } else { ++ unreachable!() ++ } ++ } ++ Style::Newtype => vec![Ident::new("__field0")], ++ Style::Tuple => { ++ (0..variant.fields.len()) ++ .map(|i| Ident::new(format!("__field{}", i))) ++ .collect() ++ } ++ Style::Struct => { ++ variant ++ .fields ++ .iter() ++ .map( ++ |f| { ++ f.ident ++ .clone() ++ .expect("struct variant has unnamed fields") ++ }, ++ ) ++ .collect() ++ } ++ }; ++ ++ let (_, ty_generics, where_clause) = params.generics.split_for_impl(); ++ ++ let wrapper_generics = if let Style::Unit = variant.style { ++ params.generics.clone() ++ } else { ++ bound::with_lifetime_bound(¶ms.generics, "'__a") ++ }; ++ let (wrapper_impl_generics, wrapper_ty_generics, _) = wrapper_generics.split_for_impl(); ++ ++ quote_block! { ++ struct __AdjacentlyTagged #wrapper_generics #where_clause { ++ data: (#(&'__a #fields_ty,)*), ++ phantom: _serde::export::PhantomData<#this #ty_generics>, ++ } ++ ++ impl #wrapper_impl_generics _serde::Serialize for __AdjacentlyTagged #wrapper_ty_generics #where_clause { ++ fn serialize<__S>(&self, __serializer: __S) -> _serde::export::Result<__S::Ok, __S::Error> ++ where __S: _serde::Serializer ++ { ++ let (#(#fields_ident,)*) = self.data; ++ #inner ++ } ++ } ++ ++ let mut __struct = try!(_serde::Serializer::serialize_struct( ++ __serializer, #type_name, 2)); ++ try!(_serde::ser::SerializeStruct::serialize_field( ++ &mut __struct, #tag, #variant_name)); ++ try!(_serde::ser::SerializeStruct::serialize_field( ++ &mut __struct, #content, &__AdjacentlyTagged { ++ data: (#(#fields_ident,)*), ++ phantom: _serde::export::PhantomData::<#this #ty_generics>, ++ })); ++ _serde::ser::SerializeStruct::end(__struct) ++ } ++} ++ ++fn serialize_untagged_variant( ++ params: &Parameters, ++ variant: &Variant, ++ cattrs: &attr::Container, ++) -> Fragment { ++ if let Some(path) = variant.attrs.serialize_with() { ++ let ser = wrap_serialize_variant_with(params, path, &variant); ++ return quote_expr! { ++ _serde::Serialize::serialize(#ser, __serializer) ++ }; ++ } ++ ++ match variant.style { ++ Style::Unit => { ++ quote_expr! { ++ _serde::Serializer::serialize_unit(__serializer) ++ } ++ } ++ Style::Newtype => { ++ let field = &variant.fields[0]; ++ let mut field_expr = quote!(__field0); ++ if let Some(path) = field.attrs.serialize_with() { ++ field_expr = wrap_serialize_field_with(params, field.ty, path, field_expr); ++ } ++ ++ quote_expr! { ++ _serde::Serialize::serialize(#field_expr, __serializer) ++ } ++ } ++ Style::Tuple => serialize_tuple_variant(TupleVariant::Untagged, params, &variant.fields), ++ Style::Struct => { ++ let type_name = cattrs.name().serialize_name(); ++ serialize_struct_variant(StructVariant::Untagged, params, &variant.fields, &type_name) ++ } ++ } ++} ++ ++enum TupleVariant { ++ ExternallyTagged { ++ type_name: String, ++ variant_index: u32, ++ variant_name: String, ++ }, ++ Untagged, ++} ++ ++fn serialize_tuple_variant( ++ context: TupleVariant, ++ params: &Parameters, ++ fields: &[Field], ++) -> Fragment { ++ let method = match context { ++ TupleVariant::ExternallyTagged { .. } => { ++ quote!(_serde::ser::SerializeTupleVariant::serialize_field) ++ } ++ TupleVariant::Untagged => quote!(_serde::ser::SerializeTuple::serialize_element), ++ }; ++ ++ let serialize_stmts = serialize_tuple_struct_visitor(fields, params, true, method); ++ ++ let len = serialize_stmts.len(); ++ let let_mut = mut_if(len > 0); ++ ++ match context { ++ TupleVariant::ExternallyTagged { ++ type_name, ++ variant_index, ++ variant_name, ++ } => { ++ quote_block! { ++ let #let_mut __serde_state = try!(_serde::Serializer::serialize_tuple_variant( ++ __serializer, ++ #type_name, ++ #variant_index, ++ #variant_name, ++ #len)); ++ #(#serialize_stmts)* ++ _serde::ser::SerializeTupleVariant::end(__serde_state) ++ } ++ } ++ TupleVariant::Untagged => { ++ quote_block! { ++ let #let_mut __serde_state = try!(_serde::Serializer::serialize_tuple( ++ __serializer, ++ #len)); ++ #(#serialize_stmts)* ++ _serde::ser::SerializeTuple::end(__serde_state) ++ } ++ } ++ } ++} ++ ++enum StructVariant<'a> { ++ ExternallyTagged { ++ variant_index: u32, ++ variant_name: String, ++ }, ++ InternallyTagged { tag: &'a str, variant_name: String }, ++ Untagged, ++} ++ ++fn serialize_struct_variant<'a>( ++ context: StructVariant<'a>, ++ params: &Parameters, ++ fields: &[Field], ++ name: &str, ++) -> Fragment { ++ let (method, skip_method) = match context { ++ StructVariant::ExternallyTagged { .. } => { ++ ( ++ quote!(_serde::ser::SerializeStructVariant::serialize_field), ++ quote!(_serde::ser::SerializeStructVariant::skip_field), ++ ) ++ } ++ StructVariant::InternallyTagged { .. } | ++ StructVariant::Untagged => { ++ ( ++ quote!(_serde::ser::SerializeStruct::serialize_field), ++ quote!(_serde::ser::SerializeStruct::skip_field), ++ ) ++ } ++ }; ++ ++ let serialize_fields = serialize_struct_visitor(fields, params, true, method, skip_method); ++ ++ let mut serialized_fields = fields ++ .iter() ++ .filter(|&field| !field.attrs.skip_serializing()) ++ .peekable(); ++ ++ let let_mut = mut_if(serialized_fields.peek().is_some()); ++ ++ let len = serialized_fields ++ .map( ++ |field| { ++ let ident = field.ident.clone().expect("struct has unnamed fields"); ++ ++ match field.attrs.skip_serializing_if() { ++ Some(path) => quote!(if #path(#ident) { 0 } else { 1 }), ++ None => quote!(1), ++ } ++ }, ++ ) ++ .fold(quote!(0), |sum, expr| quote!(#sum + #expr)); ++ ++ match context { ++ StructVariant::ExternallyTagged { ++ variant_index, ++ variant_name, ++ } => { ++ quote_block! { ++ let #let_mut __serde_state = try!(_serde::Serializer::serialize_struct_variant( ++ __serializer, ++ #name, ++ #variant_index, ++ #variant_name, ++ #len, ++ )); ++ #(#serialize_fields)* ++ _serde::ser::SerializeStructVariant::end(__serde_state) ++ } ++ } ++ StructVariant::InternallyTagged { tag, variant_name } => { ++ quote_block! { ++ let mut __serde_state = try!(_serde::Serializer::serialize_struct( ++ __serializer, ++ #name, ++ #len + 1, ++ )); ++ try!(_serde::ser::SerializeStruct::serialize_field( ++ &mut __serde_state, ++ #tag, ++ #variant_name, ++ )); ++ #(#serialize_fields)* ++ _serde::ser::SerializeStruct::end(__serde_state) ++ } ++ } ++ StructVariant::Untagged => { ++ quote_block! { ++ let #let_mut __serde_state = try!(_serde::Serializer::serialize_struct( ++ __serializer, ++ #name, ++ #len, ++ )); ++ #(#serialize_fields)* ++ _serde::ser::SerializeStruct::end(__serde_state) ++ } ++ } ++ } ++} ++ ++fn serialize_tuple_struct_visitor( ++ fields: &[Field], ++ params: &Parameters, ++ is_enum: bool, ++ func: Tokens, ++) -> Vec { ++ fields ++ .iter() ++ .enumerate() ++ .map( ++ |(i, field)| { ++ let mut field_expr = if is_enum { ++ let id = Ident::new(format!("__field{}", i)); ++ quote!(#id) ++ } else { ++ get_field(params, field, i) ++ }; ++ ++ let skip = field ++ .attrs ++ .skip_serializing_if() ++ .map(|path| quote!(#path(#field_expr))); ++ ++ if let Some(path) = field.attrs.serialize_with() { ++ field_expr = wrap_serialize_field_with(params, field.ty, path, field_expr); ++ } ++ ++ let ser = quote! { ++ try!(#func(&mut __serde_state, #field_expr)); ++ }; ++ ++ match skip { ++ None => ser, ++ Some(skip) => quote!(if !#skip { #ser }), ++ } ++ }, ++ ) ++ .collect() ++} ++ ++fn serialize_struct_visitor( ++ fields: &[Field], ++ params: &Parameters, ++ is_enum: bool, ++ func: Tokens, ++ skip_func: Tokens, ++) -> Vec { ++ fields ++ .iter() ++ .filter(|&field| !field.attrs.skip_serializing()) ++ .map( ++ |field| { ++ let field_ident = field.ident.clone().expect("struct has unnamed field"); ++ let mut field_expr = if is_enum { ++ quote!(#field_ident) ++ } else { ++ get_field(params, field, field_ident) ++ }; ++ ++ let key_expr = field.attrs.name().serialize_name(); ++ ++ let skip = field ++ .attrs ++ .skip_serializing_if() ++ .map(|path| quote!(#path(#field_expr))); ++ ++ if let Some(path) = field.attrs.serialize_with() { ++ field_expr = wrap_serialize_field_with(params, field.ty, path, field_expr); ++ } ++ ++ let ser = quote! { ++ try!(#func(&mut __serde_state, #key_expr, #field_expr)); ++ }; ++ ++ match skip { ++ None => ser, ++ Some(skip) => { ++ quote! { ++ if !#skip { ++ #ser ++ } else { ++ try!(#skip_func(&mut __serde_state, #key_expr)); ++ } ++ } ++ } ++ } ++ }, ++ ) ++ .collect() ++} ++ ++fn wrap_serialize_field_with( ++ params: &Parameters, ++ field_ty: &syn::Ty, ++ serialize_with: &syn::Path, ++ field_expr: Tokens, ++) -> Tokens { ++ wrap_serialize_with(params, ++ serialize_with, ++ &[field_ty], ++ &[quote!(#field_expr)]) ++} ++ ++fn wrap_serialize_variant_with( ++ params: &Parameters, ++ serialize_with: &syn::Path, ++ variant: &Variant, ++) -> Tokens { ++ let field_tys: Vec<_> = variant.fields.iter().map(|field| field.ty).collect(); ++ let field_exprs: Vec<_> = variant.fields.iter() ++ .enumerate() ++ .map(|(i, field)| { ++ let id = field.ident.as_ref().map_or_else(|| Ident::new(format!("__field{}", i)), ++ |id| id.clone()); ++ quote!(#id) ++ }) ++ .collect(); ++ wrap_serialize_with(params, serialize_with, field_tys.as_slice(), field_exprs.as_slice()) ++} ++ ++fn wrap_serialize_with( ++ params: &Parameters, ++ serialize_with: &syn::Path, ++ field_tys: &[&syn::Ty], ++ field_exprs: &[Tokens], ++) -> Tokens { ++ let this = ¶ms.this; ++ let (_, ty_generics, where_clause) = params.generics.split_for_impl(); ++ ++ let wrapper_generics = if field_exprs.len() == 0 { ++ params.generics.clone() ++ } else { ++ bound::with_lifetime_bound(¶ms.generics, "'__a") ++ }; ++ let (wrapper_impl_generics, wrapper_ty_generics, _) = wrapper_generics.split_for_impl(); ++ ++ let field_access = (0..field_exprs.len()).map(|n| Ident::new(format!("{}", n))); ++ ++ quote!({ ++ struct __SerializeWith #wrapper_impl_generics #where_clause { ++ values: (#(&'__a #field_tys, )*), ++ phantom: _serde::export::PhantomData<#this #ty_generics>, ++ } ++ ++ impl #wrapper_impl_generics _serde::Serialize for __SerializeWith #wrapper_ty_generics #where_clause { ++ fn serialize<__S>(&self, __s: __S) -> _serde::export::Result<__S::Ok, __S::Error> ++ where __S: _serde::Serializer ++ { ++ #serialize_with(#(self.values.#field_access, )* __s) ++ } ++ } ++ ++ &__SerializeWith { ++ values: (#(#field_exprs, )*), ++ phantom: _serde::export::PhantomData::<#this #ty_generics>, ++ } ++ }) ++} ++ ++// Serialization of an empty struct results in code like: ++// ++// let mut __serde_state = try!(serializer.serialize_struct("S", 0)); ++// _serde::ser::SerializeStruct::end(__serde_state) ++// ++// where we want to omit the `mut` to avoid a warning. ++fn mut_if(is_mut: bool) -> Option { ++ if is_mut { Some(quote!(mut)) } else { None } ++} ++ ++fn get_field(params: &Parameters, field: &Field, ident: I) -> Tokens ++where ++ I: Into, ++{ ++ let self_var = ¶ms.self_var; ++ match (params.is_remote, field.attrs.getter()) { ++ (false, None) => { ++ let ident = ident.into(); ++ quote!(&#self_var.#ident) ++ } ++ (true, None) => { ++ let ty = field.ty; ++ let ident = ident.into(); ++ quote!(_serde::private::ser::constrain::<#ty>(&#self_var.#ident)) ++ } ++ (true, Some(getter)) => { ++ let ty = field.ty; ++ quote!(_serde::private::ser::constrain::<#ty>(&#getter(#self_var))) ++ } ++ (false, Some(_)) => { ++ unreachable!("getter is only allowed for remote impls"); ++ } ++ } ++} diff --cc vendor/serde_derive_internals-0.16.0/.cargo-checksum.json index 000000000,000000000..f1c4032e5 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"bd381f6d01a6616cdba8530492d453b7761b456ba974e98768a18cad2cd76f58"} diff --cc vendor/serde_derive_internals-0.16.0/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/.cargo-ok diff --cc vendor/serde_derive_internals-0.16.0/Cargo.toml index 000000000,000000000..b05996459 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/Cargo.toml @@@ -1,0 -1,0 +1,33 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "serde_derive_internals" ++version = "0.16.0" ++authors = ["Erick Tryzelaar ", "David Tolnay "] ++include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] ++description = "AST representation used by Serde derive macros. Unstable." ++homepage = "https://serde.rs" ++documentation = "https://docs.serde.rs/serde_derive_internals/" ++readme = "README.md" ++keywords = ["serde", "serialization"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/serde-rs/serde" ++[dependencies.syn] ++version = "0.11.10" ++features = ["parsing"] ++default-features = false ++ ++[dependencies.synom] ++version = "0.11" ++[badges.travis-ci] ++repository = "serde-rs/serde" diff --cc vendor/serde_derive_internals-0.16.0/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/serde_derive_internals-0.16.0/LICENSE-MIT index 000000000,000000000..39d4bdb5a new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/serde_derive_internals-0.16.0/README.md index 000000000,000000000..c2f35e9cd new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/README.md @@@ -1,0 -1,0 +1,81 @@@ ++# Serde   [![Build Status]][travis] [![Latest Version]][crates.io] ++ ++[Build Status]: https://api.travis-ci.org/serde-rs/serde.svg?branch=master ++[travis]: https://travis-ci.org/serde-rs/serde ++[Latest Version]: https://img.shields.io/crates/v/serde.svg ++[crates.io]: https://crates.io/crates/serde ++ ++**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.** ++ ++--- ++ ++You may be looking for: ++ ++- [An overview of Serde](https://serde.rs/) ++- [Data formats supported by Serde](https://serde.rs/#data-formats) ++- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html) ++- [Examples](https://serde.rs/examples.html) ++- [API documentation](https://docs.serde.rs/serde/) ++- [Release notes](https://github.com/serde-rs/serde/releases) ++ ++## Serde in action ++ ++ ++ ++ ++ ++```rust ++#[macro_use] ++extern crate serde_derive; ++ ++extern crate serde; ++extern crate serde_json; ++ ++#[derive(Serialize, Deserialize, Debug)] ++struct Point { ++ x: i32, ++ y: i32, ++} ++ ++fn main() { ++ let point = Point { x: 1, y: 2 }; ++ ++ // Convert the Point to a JSON string. ++ let serialized = serde_json::to_string(&point).unwrap(); ++ ++ // Prints serialized = {"x":1,"y":2} ++ println!("serialized = {}", serialized); ++ ++ // Convert the JSON string back to a Point. ++ let deserialized: Point = serde_json::from_str(&serialized).unwrap(); ++ ++ // Prints deserialized = Point { x: 1, y: 2 } ++ println!("deserialized = {:?}", deserialized); ++} ++``` ++ ++## Getting help ++ ++Serde developers live in the #serde channel on ++[`irc.mozilla.org`](https://wiki.mozilla.org/IRC). The #rust channel is also a ++good resource with generally faster response time but less specific knowledge ++about Serde. If IRC is not your thing or you don't get a good response, we are ++happy to respond to [GitHub issues](https://github.com/serde-rs/serde/issues/new) ++as well. ++ ++## License ++ ++Serde is licensed under either of ++ ++ * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ++ http://www.apache.org/licenses/LICENSE-2.0) ++ * MIT license ([LICENSE-MIT](LICENSE-MIT) or ++ http://opensource.org/licenses/MIT) ++ ++at your option. ++ ++### Contribution ++ ++Unless you explicitly state otherwise, any contribution intentionally submitted ++for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be ++dual licensed as above, without any additional terms or conditions. diff --cc vendor/serde_derive_internals-0.16.0/src/ast.rs index 000000000,000000000..818d301bd new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/src/ast.rs @@@ -1,0 -1,0 +1,143 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use syn; ++use attr; ++use check; ++use Ctxt; ++ ++pub struct Container<'a> { ++ pub ident: syn::Ident, ++ pub attrs: attr::Container, ++ pub body: Body<'a>, ++ pub generics: &'a syn::Generics, ++} ++ ++pub enum Body<'a> { ++ Enum(Vec>), ++ Struct(Style, Vec>), ++} ++ ++pub struct Variant<'a> { ++ pub ident: syn::Ident, ++ pub attrs: attr::Variant, ++ pub style: Style, ++ pub fields: Vec>, ++} ++ ++pub struct Field<'a> { ++ pub ident: Option, ++ pub attrs: attr::Field, ++ pub ty: &'a syn::Ty, ++} ++ ++#[derive(Copy, Clone)] ++pub enum Style { ++ Struct, ++ Tuple, ++ Newtype, ++ Unit, ++} ++ ++impl<'a> Container<'a> { ++ pub fn from_ast(cx: &Ctxt, item: &'a syn::DeriveInput) -> Container<'a> { ++ let attrs = attr::Container::from_ast(cx, item); ++ ++ let mut body = match item.body { ++ syn::Body::Enum(ref variants) => Body::Enum(enum_from_ast(cx, variants)), ++ syn::Body::Struct(ref variant_data) => { ++ let (style, fields) = struct_from_ast(cx, variant_data); ++ Body::Struct(style, fields) ++ } ++ }; ++ ++ match body { ++ Body::Enum(ref mut variants) => { ++ for ref mut variant in variants { ++ variant.attrs.rename_by_rule(attrs.rename_all()); ++ for ref mut field in &mut variant.fields { ++ field.attrs.rename_by_rule(variant.attrs.rename_all()); ++ } ++ } ++ } ++ Body::Struct(_, ref mut fields) => { ++ for field in fields { ++ field.attrs.rename_by_rule(attrs.rename_all()); ++ } ++ } ++ } ++ ++ let item = Container { ++ ident: item.ident.clone(), ++ attrs: attrs, ++ body: body, ++ generics: &item.generics, ++ }; ++ check::check(cx, &item); ++ item ++ } ++} ++ ++impl<'a> Body<'a> { ++ pub fn all_fields(&'a self) -> Box> + 'a> { ++ match *self { ++ Body::Enum(ref variants) => { ++ Box::new(variants.iter().flat_map(|variant| variant.fields.iter())) ++ } ++ Body::Struct(_, ref fields) => Box::new(fields.iter()), ++ } ++ } ++ ++ pub fn has_getter(&self) -> bool { ++ self.all_fields().any(|f| f.attrs.getter().is_some()) ++ } ++} ++ ++fn enum_from_ast<'a>(cx: &Ctxt, variants: &'a [syn::Variant]) -> Vec> { ++ variants ++ .iter() ++ .map( ++ |variant| { ++ let (style, fields) = struct_from_ast(cx, &variant.data); ++ Variant { ++ ident: variant.ident.clone(), ++ attrs: attr::Variant::from_ast(cx, variant), ++ style: style, ++ fields: fields, ++ } ++ }, ++ ) ++ .collect() ++} ++ ++fn struct_from_ast<'a>(cx: &Ctxt, data: &'a syn::VariantData) -> (Style, Vec>) { ++ match *data { ++ syn::VariantData::Struct(ref fields) => (Style::Struct, fields_from_ast(cx, fields)), ++ syn::VariantData::Tuple(ref fields) if fields.len() == 1 => { ++ (Style::Newtype, fields_from_ast(cx, fields)) ++ } ++ syn::VariantData::Tuple(ref fields) => (Style::Tuple, fields_from_ast(cx, fields)), ++ syn::VariantData::Unit => (Style::Unit, Vec::new()), ++ } ++} ++ ++fn fields_from_ast<'a>(cx: &Ctxt, fields: &'a [syn::Field]) -> Vec> { ++ fields ++ .iter() ++ .enumerate() ++ .map( ++ |(i, field)| { ++ Field { ++ ident: field.ident.clone(), ++ attrs: attr::Field::from_ast(cx, i, field), ++ ty: &field.ty, ++ } ++ }, ++ ) ++ .collect() ++} diff --cc vendor/serde_derive_internals-0.16.0/src/attr.rs index 000000000,000000000..454b8b59c new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/src/attr.rs @@@ -1,0 -1,0 +1,1255 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use Ctxt; ++use syn; ++use syn::MetaItem::{List, NameValue, Word}; ++use syn::NestedMetaItem::{Literal, MetaItem}; ++use synom::IResult; ++use std::collections::BTreeSet; ++use std::str::FromStr; ++ ++// This module handles parsing of `#[serde(...)]` attributes. The entrypoints ++// are `attr::Container::from_ast`, `attr::Variant::from_ast`, and ++// `attr::Field::from_ast`. Each returns an instance of the corresponding ++// struct. Note that none of them return a Result. Unrecognized, malformed, or ++// duplicated attributes result in a span_err but otherwise are ignored. The ++// user will see errors simultaneously for all bad attributes in the crate ++// rather than just the first. ++ ++pub use case::RenameRule; ++ ++struct Attr<'c, T> { ++ cx: &'c Ctxt, ++ name: &'static str, ++ value: Option, ++} ++ ++impl<'c, T> Attr<'c, T> { ++ fn none(cx: &'c Ctxt, name: &'static str) -> Self { ++ Attr { ++ cx: cx, ++ name: name, ++ value: None, ++ } ++ } ++ ++ fn set(&mut self, value: T) { ++ if self.value.is_some() { ++ self.cx ++ .error(format!("duplicate serde attribute `{}`", self.name)); ++ } else { ++ self.value = Some(value); ++ } ++ } ++ ++ fn set_opt(&mut self, value: Option) { ++ if let Some(value) = value { ++ self.set(value); ++ } ++ } ++ ++ fn set_if_none(&mut self, value: T) { ++ if self.value.is_none() { ++ self.value = Some(value); ++ } ++ } ++ ++ fn get(self) -> Option { ++ self.value ++ } ++} ++ ++struct BoolAttr<'c>(Attr<'c, ()>); ++ ++impl<'c> BoolAttr<'c> { ++ fn none(cx: &'c Ctxt, name: &'static str) -> Self { ++ BoolAttr(Attr::none(cx, name)) ++ } ++ ++ fn set_true(&mut self) { ++ self.0.set(()); ++ } ++ ++ fn get(&self) -> bool { ++ self.0.value.is_some() ++ } ++} ++ ++#[derive(Debug)] ++pub struct Name { ++ serialize: String, ++ deserialize: String, ++} ++ ++impl Name { ++ /// Return the container name for the container when serializing. ++ pub fn serialize_name(&self) -> String { ++ self.serialize.clone() ++ } ++ ++ /// Return the container name for the container when deserializing. ++ pub fn deserialize_name(&self) -> String { ++ self.deserialize.clone() ++ } ++} ++ ++/// Represents container (e.g. struct) attribute information ++#[derive(Debug)] ++pub struct Container { ++ name: Name, ++ deny_unknown_fields: bool, ++ default: Default, ++ rename_all: RenameRule, ++ ser_bound: Option>, ++ de_bound: Option>, ++ tag: EnumTag, ++ from_type: Option, ++ into_type: Option, ++ remote: Option, ++ identifier: Identifier, ++} ++ ++/// Styles of representing an enum. ++#[derive(Debug)] ++pub enum EnumTag { ++ /// The default. ++ /// ++ /// ```json ++ /// {"variant1": {"key1": "value1", "key2": "value2"}} ++ /// ``` ++ External, ++ ++ /// `#[serde(tag = "type")]` ++ /// ++ /// ```json ++ /// {"type": "variant1", "key1": "value1", "key2": "value2"} ++ /// ``` ++ Internal { tag: String }, ++ ++ /// `#[serde(tag = "t", content = "c")]` ++ /// ++ /// ```json ++ /// {"t": "variant1", "c": {"key1": "value1", "key2": "value2"}} ++ /// ``` ++ Adjacent { tag: String, content: String }, ++ ++ /// `#[serde(untagged)]` ++ /// ++ /// ```json ++ /// {"key1": "value1", "key2": "value2"} ++ /// ``` ++ None, ++} ++ ++/// Whether this enum represents the fields of a struct or the variants of an ++/// enum. ++#[derive(Copy, Clone, Debug)] ++pub enum Identifier { ++ /// It does not. ++ No, ++ ++ /// This enum represents the fields of a struct. All of the variants must be ++ /// unit variants, except possibly one which is annotated with ++ /// `#[serde(other)]` and is a newtype variant. ++ Field, ++ ++ /// This enum represents the variants of an enum. All of the variants must ++ /// be unit variants. ++ Variant, ++} ++ ++impl Container { ++ /// Extract out the `#[serde(...)]` attributes from an item. ++ pub fn from_ast(cx: &Ctxt, item: &syn::DeriveInput) -> Self { ++ let mut ser_name = Attr::none(cx, "rename"); ++ let mut de_name = Attr::none(cx, "rename"); ++ let mut deny_unknown_fields = BoolAttr::none(cx, "deny_unknown_fields"); ++ let mut default = Attr::none(cx, "default"); ++ let mut rename_all = Attr::none(cx, "rename_all"); ++ let mut ser_bound = Attr::none(cx, "bound"); ++ let mut de_bound = Attr::none(cx, "bound"); ++ let mut untagged = BoolAttr::none(cx, "untagged"); ++ let mut internal_tag = Attr::none(cx, "tag"); ++ let mut content = Attr::none(cx, "content"); ++ let mut from_type = Attr::none(cx, "from"); ++ let mut into_type = Attr::none(cx, "into"); ++ let mut remote = Attr::none(cx, "remote"); ++ let mut field_identifier = BoolAttr::none(cx, "field_identifier"); ++ let mut variant_identifier = BoolAttr::none(cx, "variant_identifier"); ++ ++ for meta_items in item.attrs.iter().filter_map(get_serde_meta_items) { ++ for meta_item in meta_items { ++ match meta_item { ++ // Parse `#[serde(rename = "foo")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "rename" => { ++ if let Ok(s) = get_string_from_lit(cx, name.as_ref(), name.as_ref(), lit) { ++ ser_name.set(s.clone()); ++ de_name.set(s); ++ } ++ } ++ ++ // Parse `#[serde(rename(serialize = "foo", deserialize = "bar"))]` ++ MetaItem(List(ref name, ref meta_items)) if name == "rename" => { ++ if let Ok((ser, de)) = get_renames(cx, meta_items) { ++ ser_name.set_opt(ser); ++ de_name.set_opt(de); ++ } ++ } ++ ++ // Parse `#[serde(rename_all = "foo")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "rename_all" => { ++ if let Ok(s) = get_string_from_lit(cx, name.as_ref(), name.as_ref(), lit) { ++ match RenameRule::from_str(&s) { ++ Ok(rename_rule) => rename_all.set(rename_rule), ++ Err(()) => { ++ cx.error(format!("unknown rename rule for #[serde(rename_all \ ++ = {:?})]", ++ s)) ++ } ++ } ++ } ++ } ++ ++ // Parse `#[serde(deny_unknown_fields)]` ++ MetaItem(Word(ref name)) if name == "deny_unknown_fields" => { ++ deny_unknown_fields.set_true(); ++ } ++ ++ // Parse `#[serde(default)]` ++ MetaItem(Word(ref name)) if name == "default" => { ++ match item.body { ++ syn::Body::Struct(syn::VariantData::Struct(_)) => { ++ default.set(Default::Default); ++ } ++ _ => { ++ cx.error( ++ "#[serde(default)] can only be used on structs \ ++ with named fields", ++ ) ++ } ++ } ++ } ++ ++ // Parse `#[serde(default = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "default" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ match item.body { ++ syn::Body::Struct(syn::VariantData::Struct(_)) => { ++ default.set(Default::Path(path)); ++ } ++ _ => { ++ cx.error( ++ "#[serde(default = \"...\")] can only be used \ ++ on structs with named fields", ++ ) ++ } ++ } ++ } ++ } ++ ++ // Parse `#[serde(bound = "D: Serialize")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "bound" => { ++ if let Ok(where_predicates) = ++ parse_lit_into_where(cx, name.as_ref(), name.as_ref(), lit) { ++ ser_bound.set(where_predicates.clone()); ++ de_bound.set(where_predicates); ++ } ++ } ++ ++ // Parse `#[serde(bound(serialize = "D: Serialize", deserialize = "D: Deserialize"))]` ++ MetaItem(List(ref name, ref meta_items)) if name == "bound" => { ++ if let Ok((ser, de)) = get_where_predicates(cx, meta_items) { ++ ser_bound.set_opt(ser); ++ de_bound.set_opt(de); ++ } ++ } ++ ++ // Parse `#[serde(untagged)]` ++ MetaItem(Word(ref name)) if name == "untagged" => { ++ match item.body { ++ syn::Body::Enum(_) => { ++ untagged.set_true(); ++ } ++ syn::Body::Struct(_) => { ++ cx.error("#[serde(untagged)] can only be used on enums") ++ } ++ } ++ } ++ ++ // Parse `#[serde(tag = "type")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "tag" => { ++ if let Ok(s) = get_string_from_lit(cx, name.as_ref(), name.as_ref(), lit) { ++ match item.body { ++ syn::Body::Enum(_) => { ++ internal_tag.set(s); ++ } ++ syn::Body::Struct(_) => { ++ cx.error("#[serde(tag = \"...\")] can only be used on enums") ++ } ++ } ++ } ++ } ++ ++ // Parse `#[serde(content = "c")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "content" => { ++ if let Ok(s) = get_string_from_lit(cx, name.as_ref(), name.as_ref(), lit) { ++ match item.body { ++ syn::Body::Enum(_) => { ++ content.set(s); ++ } ++ syn::Body::Struct(_) => { ++ cx.error( ++ "#[serde(content = \"...\")] can only be used on \ ++ enums", ++ ) ++ } ++ } ++ } ++ } ++ ++ // Parse `#[serde(from = "Type")] ++ MetaItem(NameValue(ref name, ref lit)) if name == "from" => { ++ if let Ok(from_ty) = parse_lit_into_ty(cx, name.as_ref(), lit) { ++ from_type.set_opt(Some(from_ty)); ++ } ++ } ++ ++ // Parse `#[serde(into = "Type")] ++ MetaItem(NameValue(ref name, ref lit)) if name == "into" => { ++ if let Ok(into_ty) = parse_lit_into_ty(cx, name.as_ref(), lit) { ++ into_type.set_opt(Some(into_ty)); ++ } ++ } ++ ++ // Parse `#[serde(remote = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "remote" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ remote.set(path); ++ } ++ } ++ ++ // Parse `#[serde(field_identifier)]` ++ MetaItem(Word(ref name)) if name == "field_identifier" => { ++ field_identifier.set_true(); ++ } ++ ++ // Parse `#[serde(variant_identifier)]` ++ MetaItem(Word(ref name)) if name == "variant_identifier" => { ++ variant_identifier.set_true(); ++ } ++ ++ MetaItem(ref meta_item) => { ++ cx.error(format!("unknown serde container attribute `{}`", ++ meta_item.name())); ++ } ++ ++ Literal(_) => { ++ cx.error("unexpected literal in serde container attribute"); ++ } ++ } ++ } ++ } ++ ++ Container { ++ name: Name { ++ serialize: ser_name.get().unwrap_or_else(|| item.ident.to_string()), ++ deserialize: de_name.get().unwrap_or_else(|| item.ident.to_string()), ++ }, ++ deny_unknown_fields: deny_unknown_fields.get(), ++ default: default.get().unwrap_or(Default::None), ++ rename_all: rename_all.get().unwrap_or(RenameRule::None), ++ ser_bound: ser_bound.get(), ++ de_bound: de_bound.get(), ++ tag: decide_tag(cx, item, untagged, internal_tag, content), ++ from_type: from_type.get(), ++ into_type: into_type.get(), ++ remote: remote.get(), ++ identifier: decide_identifier(cx, item, field_identifier, variant_identifier), ++ } ++ } ++ ++ pub fn name(&self) -> &Name { ++ &self.name ++ } ++ ++ pub fn rename_all(&self) -> &RenameRule { ++ &self.rename_all ++ } ++ ++ pub fn deny_unknown_fields(&self) -> bool { ++ self.deny_unknown_fields ++ } ++ ++ pub fn default(&self) -> &Default { ++ &self.default ++ } ++ ++ pub fn ser_bound(&self) -> Option<&[syn::WherePredicate]> { ++ self.ser_bound.as_ref().map(|vec| &vec[..]) ++ } ++ ++ pub fn de_bound(&self) -> Option<&[syn::WherePredicate]> { ++ self.de_bound.as_ref().map(|vec| &vec[..]) ++ } ++ ++ pub fn tag(&self) -> &EnumTag { ++ &self.tag ++ } ++ ++ pub fn from_type(&self) -> Option<&syn::Ty> { ++ self.from_type.as_ref() ++ } ++ ++ pub fn into_type(&self) -> Option<&syn::Ty> { ++ self.into_type.as_ref() ++ } ++ ++ pub fn remote(&self) -> Option<&syn::Path> { ++ self.remote.as_ref() ++ } ++ ++ pub fn identifier(&self) -> Identifier { ++ self.identifier ++ } ++} ++ ++fn decide_tag( ++ cx: &Ctxt, ++ item: &syn::DeriveInput, ++ untagged: BoolAttr, ++ internal_tag: Attr, ++ content: Attr, ++) -> EnumTag { ++ match (untagged.get(), internal_tag.get(), content.get()) { ++ (false, None, None) => EnumTag::External, ++ (true, None, None) => EnumTag::None, ++ (false, Some(tag), None) => { ++ // Check that there are no tuple variants. ++ if let syn::Body::Enum(ref variants) = item.body { ++ for variant in variants { ++ match variant.data { ++ syn::VariantData::Struct(_) | ++ syn::VariantData::Unit => {} ++ syn::VariantData::Tuple(ref fields) => { ++ if fields.len() != 1 { ++ cx.error( ++ "#[serde(tag = \"...\")] cannot be used with tuple \ ++ variants", ++ ); ++ break; ++ } ++ } ++ } ++ } ++ } ++ EnumTag::Internal { tag: tag } ++ } ++ (true, Some(_), None) => { ++ cx.error("enum cannot be both untagged and internally tagged"); ++ EnumTag::External // doesn't matter, will error ++ } ++ (false, None, Some(_)) => { ++ cx.error("#[serde(tag = \"...\", content = \"...\")] must be used together",); ++ EnumTag::External ++ } ++ (true, None, Some(_)) => { ++ cx.error("untagged enum cannot have #[serde(content = \"...\")]"); ++ EnumTag::External ++ } ++ (false, Some(tag), Some(content)) => { ++ EnumTag::Adjacent { ++ tag: tag, ++ content: content, ++ } ++ } ++ (true, Some(_), Some(_)) => { ++ cx.error("untagged enum cannot have #[serde(tag = \"...\", content = \"...\")]",); ++ EnumTag::External ++ } ++ } ++} ++ ++fn decide_identifier( ++ cx: &Ctxt, ++ item: &syn::DeriveInput, ++ field_identifier: BoolAttr, ++ variant_identifier: BoolAttr, ++) -> Identifier { ++ match (&item.body, field_identifier.get(), variant_identifier.get()) { ++ (_, false, false) => Identifier::No, ++ (_, true, true) => { ++ cx.error("`field_identifier` and `variant_identifier` cannot both be set",); ++ Identifier::No ++ } ++ (&syn::Body::Struct(_), true, false) => { ++ cx.error("`field_identifier` can only be used on an enum"); ++ Identifier::No ++ } ++ (&syn::Body::Struct(_), false, true) => { ++ cx.error("`variant_identifier` can only be used on an enum"); ++ Identifier::No ++ } ++ (&syn::Body::Enum(_), true, false) => Identifier::Field, ++ (&syn::Body::Enum(_), false, true) => Identifier::Variant, ++ } ++} ++ ++/// Represents variant attribute information ++#[derive(Debug)] ++pub struct Variant { ++ name: Name, ++ ser_renamed: bool, ++ de_renamed: bool, ++ rename_all: RenameRule, ++ skip_deserializing: bool, ++ skip_serializing: bool, ++ other: bool, ++ serialize_with: Option, ++ deserialize_with: Option, ++} ++ ++impl Variant { ++ pub fn from_ast(cx: &Ctxt, variant: &syn::Variant) -> Self { ++ let mut ser_name = Attr::none(cx, "rename"); ++ let mut de_name = Attr::none(cx, "rename"); ++ let mut skip_deserializing = BoolAttr::none(cx, "skip_deserializing"); ++ let mut skip_serializing = BoolAttr::none(cx, "skip_serializing"); ++ let mut rename_all = Attr::none(cx, "rename_all"); ++ let mut other = BoolAttr::none(cx, "other"); ++ let mut serialize_with = Attr::none(cx, "serialize_with"); ++ let mut deserialize_with = Attr::none(cx, "deserialize_with"); ++ ++ for meta_items in variant.attrs.iter().filter_map(get_serde_meta_items) { ++ for meta_item in meta_items { ++ match meta_item { ++ // Parse `#[serde(rename = "foo")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "rename" => { ++ if let Ok(s) = get_string_from_lit(cx, name.as_ref(), name.as_ref(), lit) { ++ ser_name.set(s.clone()); ++ de_name.set(s); ++ } ++ } ++ ++ // Parse `#[serde(rename(serialize = "foo", deserialize = "bar"))]` ++ MetaItem(List(ref name, ref meta_items)) if name == "rename" => { ++ if let Ok((ser, de)) = get_renames(cx, meta_items) { ++ ser_name.set_opt(ser); ++ de_name.set_opt(de); ++ } ++ } ++ ++ // Parse `#[serde(rename_all = "foo")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "rename_all" => { ++ if let Ok(s) = get_string_from_lit(cx, name.as_ref(), name.as_ref(), lit) { ++ match RenameRule::from_str(&s) { ++ Ok(rename_rule) => rename_all.set(rename_rule), ++ Err(()) => { ++ cx.error(format!("unknown rename rule for #[serde(rename_all \ ++ = {:?})]", ++ s)) ++ } ++ } ++ } ++ } ++ ++ // Parse `#[serde(skip_deserializing)]` ++ MetaItem(Word(ref name)) if name == "skip_deserializing" => { ++ skip_deserializing.set_true(); ++ } ++ ++ // Parse `#[serde(skip_serializing)]` ++ MetaItem(Word(ref name)) if name == "skip_serializing" => { ++ skip_serializing.set_true(); ++ } ++ ++ // Parse `#[serde(other)]` ++ MetaItem(Word(ref name)) if name == "other" => { ++ other.set_true(); ++ } ++ ++ // Parse `#[serde(with = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "with" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ let mut ser_path = path.clone(); ++ ser_path.segments.push("serialize".into()); ++ serialize_with.set(ser_path); ++ let mut de_path = path; ++ de_path.segments.push("deserialize".into()); ++ deserialize_with.set(de_path); ++ } ++ } ++ ++ // Parse `#[serde(serialize_with = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "serialize_with" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ serialize_with.set(path); ++ } ++ } ++ ++ // Parse `#[serde(deserialize_with = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "deserialize_with" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ deserialize_with.set(path); ++ } ++ } ++ ++ MetaItem(ref meta_item) => { ++ cx.error(format!("unknown serde variant attribute `{}`", meta_item.name())); ++ } ++ ++ Literal(_) => { ++ cx.error("unexpected literal in serde variant attribute"); ++ } ++ } ++ } ++ } ++ ++ let ser_name = ser_name.get(); ++ let ser_renamed = ser_name.is_some(); ++ let de_name = de_name.get(); ++ let de_renamed = de_name.is_some(); ++ Variant { ++ name: Name { ++ serialize: ser_name.unwrap_or_else(|| variant.ident.to_string()), ++ deserialize: de_name.unwrap_or_else(|| variant.ident.to_string()), ++ }, ++ ser_renamed: ser_renamed, ++ de_renamed: de_renamed, ++ rename_all: rename_all.get().unwrap_or(RenameRule::None), ++ skip_deserializing: skip_deserializing.get(), ++ skip_serializing: skip_serializing.get(), ++ other: other.get(), ++ serialize_with: serialize_with.get(), ++ deserialize_with: deserialize_with.get(), ++ } ++ } ++ ++ pub fn name(&self) -> &Name { ++ &self.name ++ } ++ ++ pub fn rename_by_rule(&mut self, rule: &RenameRule) { ++ if !self.ser_renamed { ++ self.name.serialize = rule.apply_to_variant(&self.name.serialize); ++ } ++ if !self.de_renamed { ++ self.name.deserialize = rule.apply_to_variant(&self.name.deserialize); ++ } ++ } ++ ++ pub fn rename_all(&self) -> &RenameRule { ++ &self.rename_all ++ } ++ ++ pub fn skip_deserializing(&self) -> bool { ++ self.skip_deserializing ++ } ++ ++ pub fn skip_serializing(&self) -> bool { ++ self.skip_serializing ++ } ++ ++ pub fn other(&self) -> bool { ++ self.other ++ } ++ ++ pub fn serialize_with(&self) -> Option<&syn::Path> { ++ self.serialize_with.as_ref() ++ } ++ ++ pub fn deserialize_with(&self) -> Option<&syn::Path> { ++ self.deserialize_with.as_ref() ++ } ++} ++ ++/// Represents field attribute information ++#[derive(Debug)] ++pub struct Field { ++ name: Name, ++ ser_renamed: bool, ++ de_renamed: bool, ++ skip_serializing: bool, ++ skip_deserializing: bool, ++ skip_serializing_if: Option, ++ default: Default, ++ serialize_with: Option, ++ deserialize_with: Option, ++ ser_bound: Option>, ++ de_bound: Option>, ++ borrowed_lifetimes: BTreeSet, ++ getter: Option, ++} ++ ++/// Represents the default to use for a field when deserializing. ++#[derive(Debug, PartialEq)] ++pub enum Default { ++ /// Field must always be specified because it does not have a default. ++ None, ++ /// The default is given by `std::default::Default::default()`. ++ Default, ++ /// The default is given by this function. ++ Path(syn::Path), ++} ++ ++impl Field { ++ /// Extract out the `#[serde(...)]` attributes from a struct field. ++ pub fn from_ast(cx: &Ctxt, index: usize, field: &syn::Field) -> Self { ++ let mut ser_name = Attr::none(cx, "rename"); ++ let mut de_name = Attr::none(cx, "rename"); ++ let mut skip_serializing = BoolAttr::none(cx, "skip_serializing"); ++ let mut skip_deserializing = BoolAttr::none(cx, "skip_deserializing"); ++ let mut skip_serializing_if = Attr::none(cx, "skip_serializing_if"); ++ let mut default = Attr::none(cx, "default"); ++ let mut serialize_with = Attr::none(cx, "serialize_with"); ++ let mut deserialize_with = Attr::none(cx, "deserialize_with"); ++ let mut ser_bound = Attr::none(cx, "bound"); ++ let mut de_bound = Attr::none(cx, "bound"); ++ let mut borrowed_lifetimes = Attr::none(cx, "borrow"); ++ let mut getter = Attr::none(cx, "getter"); ++ ++ let ident = match field.ident { ++ Some(ref ident) => ident.to_string(), ++ None => index.to_string(), ++ }; ++ ++ for meta_items in field.attrs.iter().filter_map(get_serde_meta_items) { ++ for meta_item in meta_items { ++ match meta_item { ++ // Parse `#[serde(rename = "foo")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "rename" => { ++ if let Ok(s) = get_string_from_lit(cx, name.as_ref(), name.as_ref(), lit) { ++ ser_name.set(s.clone()); ++ de_name.set(s); ++ } ++ } ++ ++ // Parse `#[serde(rename(serialize = "foo", deserialize = "bar"))]` ++ MetaItem(List(ref name, ref meta_items)) if name == "rename" => { ++ if let Ok((ser, de)) = get_renames(cx, meta_items) { ++ ser_name.set_opt(ser); ++ de_name.set_opt(de); ++ } ++ } ++ ++ // Parse `#[serde(default)]` ++ MetaItem(Word(ref name)) if name == "default" => { ++ default.set(Default::Default); ++ } ++ ++ // Parse `#[serde(default = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "default" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ default.set(Default::Path(path)); ++ } ++ } ++ ++ // Parse `#[serde(skip_serializing)]` ++ MetaItem(Word(ref name)) if name == "skip_serializing" => { ++ skip_serializing.set_true(); ++ } ++ ++ // Parse `#[serde(skip_deserializing)]` ++ MetaItem(Word(ref name)) if name == "skip_deserializing" => { ++ skip_deserializing.set_true(); ++ } ++ ++ // Parse `#[serde(skip)]` ++ MetaItem(Word(ref name)) if name == "skip" => { ++ skip_serializing.set_true(); ++ skip_deserializing.set_true(); ++ }, ++ ++ // Parse `#[serde(skip_serializing_if = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "skip_serializing_if" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ skip_serializing_if.set(path); ++ } ++ } ++ ++ // Parse `#[serde(serialize_with = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "serialize_with" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ serialize_with.set(path); ++ } ++ } ++ ++ // Parse `#[serde(deserialize_with = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "deserialize_with" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ deserialize_with.set(path); ++ } ++ } ++ ++ // Parse `#[serde(with = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "with" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ let mut ser_path = path.clone(); ++ ser_path.segments.push("serialize".into()); ++ serialize_with.set(ser_path); ++ let mut de_path = path; ++ de_path.segments.push("deserialize".into()); ++ deserialize_with.set(de_path); ++ } ++ } ++ ++ // Parse `#[serde(bound = "D: Serialize")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "bound" => { ++ if let Ok(where_predicates) = ++ parse_lit_into_where(cx, name.as_ref(), name.as_ref(), lit) { ++ ser_bound.set(where_predicates.clone()); ++ de_bound.set(where_predicates); ++ } ++ } ++ ++ // Parse `#[serde(bound(serialize = "D: Serialize", deserialize = "D: Deserialize"))]` ++ MetaItem(List(ref name, ref meta_items)) if name == "bound" => { ++ if let Ok((ser, de)) = get_where_predicates(cx, meta_items) { ++ ser_bound.set_opt(ser); ++ de_bound.set_opt(de); ++ } ++ } ++ ++ // Parse `#[serde(borrow)]` ++ MetaItem(Word(ref name)) if name == "borrow" => { ++ if let Ok(borrowable) = borrowable_lifetimes(cx, &ident, &field.ty) { ++ borrowed_lifetimes.set(borrowable); ++ } ++ } ++ ++ // Parse `#[serde(borrow = "'a + 'b")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "borrow" => { ++ if let Ok(lifetimes) = parse_lit_into_lifetimes(cx, name.as_ref(), lit) { ++ if let Ok(borrowable) = borrowable_lifetimes(cx, &ident, &field.ty) { ++ for lifetime in &lifetimes { ++ if !borrowable.contains(lifetime) { ++ cx.error( ++ format!( ++ "field `{}` does not have lifetime {}", ++ ident, ++ lifetime.ident ++ ), ++ ); ++ } ++ } ++ borrowed_lifetimes.set(lifetimes); ++ } ++ } ++ } ++ ++ // Parse `#[serde(getter = "...")]` ++ MetaItem(NameValue(ref name, ref lit)) if name == "getter" => { ++ if let Ok(path) = parse_lit_into_path(cx, name.as_ref(), lit) { ++ getter.set(path); ++ } ++ } ++ ++ MetaItem(ref meta_item) => { ++ cx.error(format!("unknown serde field attribute `{}`", meta_item.name()),); ++ } ++ ++ Literal(_) => { ++ cx.error("unexpected literal in serde field attribute"); ++ } ++ } ++ } ++ } ++ ++ // Is skip_deserializing, initialize the field to Default::default() ++ // unless a different default is specified by `#[serde(default = "...")]` ++ if skip_deserializing.0.value.is_some() { ++ default.set_if_none(Default::Default); ++ } ++ ++ let mut borrowed_lifetimes = borrowed_lifetimes.get().unwrap_or_default(); ++ if !borrowed_lifetimes.is_empty() { ++ // Cow and Cow<[u8]> never borrow by default: ++ // ++ // impl<'de, 'a, T: ?Sized> Deserialize<'de> for Cow<'a, T> ++ // ++ // A #[serde(borrow)] attribute enables borrowing that corresponds ++ // roughly to these impls: ++ // ++ // impl<'de: 'a, 'a> Deserialize<'de> for Cow<'a, str> ++ // impl<'de: 'a, 'a> Deserialize<'de> for Cow<'a, [u8]> ++ if is_cow(&field.ty, "str") { ++ let path = syn::parse_path("_serde::private::de::borrow_cow_str").unwrap(); ++ deserialize_with.set_if_none(path); ++ } else if is_cow(&field.ty, "[u8]") { ++ let path = syn::parse_path("_serde::private::de::borrow_cow_bytes").unwrap(); ++ deserialize_with.set_if_none(path); ++ } ++ } else if is_rptr(&field.ty, "str") || is_rptr(&field.ty, "[u8]") { ++ // Types &str and &[u8] are always implicitly borrowed. No need for ++ // a #[serde(borrow)]. ++ borrowed_lifetimes = borrowable_lifetimes(cx, &ident, &field.ty).unwrap(); ++ } ++ ++ let ser_name = ser_name.get(); ++ let ser_renamed = ser_name.is_some(); ++ let de_name = de_name.get(); ++ let de_renamed = de_name.is_some(); ++ Field { ++ name: Name { ++ serialize: ser_name.unwrap_or_else(|| ident.clone()), ++ deserialize: de_name.unwrap_or(ident), ++ }, ++ ser_renamed: ser_renamed, ++ de_renamed: de_renamed, ++ skip_serializing: skip_serializing.get(), ++ skip_deserializing: skip_deserializing.get(), ++ skip_serializing_if: skip_serializing_if.get(), ++ default: default.get().unwrap_or(Default::None), ++ serialize_with: serialize_with.get(), ++ deserialize_with: deserialize_with.get(), ++ ser_bound: ser_bound.get(), ++ de_bound: de_bound.get(), ++ borrowed_lifetimes: borrowed_lifetimes, ++ getter: getter.get(), ++ } ++ } ++ ++ pub fn name(&self) -> &Name { ++ &self.name ++ } ++ ++ pub fn rename_by_rule(&mut self, rule: &RenameRule) { ++ if !self.ser_renamed { ++ self.name.serialize = rule.apply_to_field(&self.name.serialize); ++ } ++ if !self.de_renamed { ++ self.name.deserialize = rule.apply_to_field(&self.name.deserialize); ++ } ++ } ++ ++ pub fn skip_serializing(&self) -> bool { ++ self.skip_serializing ++ } ++ ++ pub fn skip_deserializing(&self) -> bool { ++ self.skip_deserializing ++ } ++ ++ pub fn skip_serializing_if(&self) -> Option<&syn::Path> { ++ self.skip_serializing_if.as_ref() ++ } ++ ++ pub fn default(&self) -> &Default { ++ &self.default ++ } ++ ++ pub fn serialize_with(&self) -> Option<&syn::Path> { ++ self.serialize_with.as_ref() ++ } ++ ++ pub fn deserialize_with(&self) -> Option<&syn::Path> { ++ self.deserialize_with.as_ref() ++ } ++ ++ pub fn ser_bound(&self) -> Option<&[syn::WherePredicate]> { ++ self.ser_bound.as_ref().map(|vec| &vec[..]) ++ } ++ ++ pub fn de_bound(&self) -> Option<&[syn::WherePredicate]> { ++ self.de_bound.as_ref().map(|vec| &vec[..]) ++ } ++ ++ pub fn borrowed_lifetimes(&self) -> &BTreeSet { ++ &self.borrowed_lifetimes ++ } ++ ++ pub fn getter(&self) -> Option<&syn::Path> { ++ self.getter.as_ref() ++ } ++} ++ ++type SerAndDe = (Option, Option); ++ ++fn get_ser_and_de( ++ cx: &Ctxt, ++ attr_name: &'static str, ++ items: &[syn::NestedMetaItem], ++ f: F, ++) -> Result, ()> ++where ++ F: Fn(&Ctxt, &str, &str, &syn::Lit) -> Result, ++{ ++ let mut ser_item = Attr::none(cx, attr_name); ++ let mut de_item = Attr::none(cx, attr_name); ++ ++ for item in items { ++ match *item { ++ MetaItem(NameValue(ref name, ref lit)) if name == "serialize" => { ++ if let Ok(v) = f(cx, attr_name, name.as_ref(), lit) { ++ ser_item.set(v); ++ } ++ } ++ ++ MetaItem(NameValue(ref name, ref lit)) if name == "deserialize" => { ++ if let Ok(v) = f(cx, attr_name, name.as_ref(), lit) { ++ de_item.set(v); ++ } ++ } ++ ++ _ => { ++ cx.error( ++ format!( ++ "malformed {0} attribute, expected `{0}(serialize = ..., \ ++ deserialize = ...)`", ++ attr_name ++ ), ++ ); ++ return Err(()); ++ } ++ } ++ } ++ ++ Ok((ser_item.get(), de_item.get())) ++} ++ ++fn get_renames(cx: &Ctxt, items: &[syn::NestedMetaItem]) -> Result, ()> { ++ get_ser_and_de(cx, "rename", items, get_string_from_lit) ++} ++ ++fn get_where_predicates( ++ cx: &Ctxt, ++ items: &[syn::NestedMetaItem], ++) -> Result>, ()> { ++ get_ser_and_de(cx, "bound", items, parse_lit_into_where) ++} ++ ++pub fn get_serde_meta_items(attr: &syn::Attribute) -> Option> { ++ match attr.value { ++ List(ref name, ref items) if name == "serde" => Some(items.iter().cloned().collect()), ++ _ => None, ++ } ++} ++ ++fn get_string_from_lit( ++ cx: &Ctxt, ++ attr_name: &str, ++ meta_item_name: &str, ++ lit: &syn::Lit, ++) -> Result { ++ if let syn::Lit::Str(ref s, _) = *lit { ++ Ok(s.clone()) ++ } else { ++ cx.error( ++ format!( ++ "expected serde {} attribute to be a string: `{} = \"...\"`", ++ attr_name, ++ meta_item_name ++ ), ++ ); ++ Err(()) ++ } ++} ++ ++fn parse_lit_into_path(cx: &Ctxt, attr_name: &str, lit: &syn::Lit) -> Result { ++ let string = try!(get_string_from_lit(cx, attr_name, attr_name, lit)); ++ syn::parse_path(&string).map_err(|err| cx.error(err)) ++} ++ ++fn parse_lit_into_where( ++ cx: &Ctxt, ++ attr_name: &str, ++ meta_item_name: &str, ++ lit: &syn::Lit, ++) -> Result, ()> { ++ let string = try!(get_string_from_lit(cx, attr_name, meta_item_name, lit)); ++ if string.is_empty() { ++ return Ok(Vec::new()); ++ } ++ ++ let where_string = format!("where {}", string); ++ ++ syn::parse_where_clause(&where_string) ++ .map(|wh| wh.predicates) ++ .map_err(|err| cx.error(err)) ++} ++ ++fn parse_lit_into_ty(cx: &Ctxt, attr_name: &str, lit: &syn::Lit) -> Result { ++ let string = try!(get_string_from_lit(cx, attr_name, attr_name, lit)); ++ ++ syn::parse_type(&string).map_err( ++ |_| { ++ cx.error(format!("failed to parse type: {} = {:?}", attr_name, string),) ++ }, ++ ) ++} ++ ++// Parses a string literal like "'a + 'b + 'c" containing a nonempty list of ++// lifetimes separated by `+`. ++fn parse_lit_into_lifetimes( ++ cx: &Ctxt, ++ attr_name: &str, ++ lit: &syn::Lit, ++) -> Result, ()> { ++ let string = try!(get_string_from_lit(cx, attr_name, attr_name, lit)); ++ if string.is_empty() { ++ cx.error("at least one lifetime must be borrowed"); ++ return Err(()); ++ } ++ ++ named!(lifetimes -> Vec, ++ separated_nonempty_list!(punct!("+"), syn::parse::lifetime) ++ ); ++ ++ if let IResult::Done(rest, o) = lifetimes(&string) { ++ if rest.trim().is_empty() { ++ let mut set = BTreeSet::new(); ++ for lifetime in o { ++ if !set.insert(lifetime.clone()) { ++ cx.error(format!("duplicate borrowed lifetime `{}`", lifetime.ident)); ++ } ++ } ++ return Ok(set); ++ } ++ } ++ Err(cx.error(format!("failed to parse borrowed lifetimes: {:?}", string)),) ++} ++ ++// Whether the type looks like it might be `std::borrow::Cow` where elem="T". ++// This can have false negatives and false positives. ++// ++// False negative: ++// ++// use std::borrow::Cow as Pig; ++// ++// #[derive(Deserialize)] ++// struct S<'a> { ++// #[serde(borrow)] ++// pig: Pig<'a, str>, ++// } ++// ++// False positive: ++// ++// type str = [i16]; ++// ++// #[derive(Deserialize)] ++// struct S<'a> { ++// #[serde(borrow)] ++// cow: Cow<'a, str>, ++// } ++fn is_cow(ty: &syn::Ty, elem: &str) -> bool { ++ let path = match *ty { ++ syn::Ty::Path(None, ref path) => path, ++ _ => { ++ return false; ++ } ++ }; ++ let seg = match path.segments.last() { ++ Some(seg) => seg, ++ None => { ++ return false; ++ } ++ }; ++ let params = match seg.parameters { ++ syn::PathParameters::AngleBracketed(ref params) => params, ++ _ => { ++ return false; ++ } ++ }; ++ seg.ident == "Cow" && params.lifetimes.len() == 1 && ++ params.types == vec![syn::parse_type(elem).unwrap()] && params.bindings.is_empty() ++} ++ ++// Whether the type looks like it might be `&T` where elem="T". This can have ++// false negatives and false positives. ++// ++// False negative: ++// ++// type Yarn = str; ++// ++// #[derive(Deserialize)] ++// struct S<'a> { ++// r: &'a Yarn, ++// } ++// ++// False positive: ++// ++// type str = [i16]; ++// ++// #[derive(Deserialize)] ++// struct S<'a> { ++// r: &'a str, ++// } ++fn is_rptr(ty: &syn::Ty, elem: &str) -> bool { ++ match *ty { ++ syn::Ty::Rptr(Some(_), ref mut_ty) => { ++ mut_ty.mutability == syn::Mutability::Immutable && ++ mut_ty.ty == syn::parse_type(elem).unwrap() ++ } ++ _ => false, ++ } ++} ++ ++// All lifetimes that this type could borrow from a Deserializer. ++// ++// For example a type `S<'a, 'b>` could borrow `'a` and `'b`. On the other hand ++// a type `for<'a> fn(&'a str)` could not borrow `'a` from the Deserializer. ++// ++// This is used when there is an explicit or implicit `#[serde(borrow)]` ++// attribute on the field so there must be at least one borrowable lifetime. ++fn borrowable_lifetimes( ++ cx: &Ctxt, ++ name: &str, ++ ty: &syn::Ty, ++) -> Result, ()> { ++ let mut lifetimes = BTreeSet::new(); ++ collect_lifetimes(ty, &mut lifetimes); ++ if lifetimes.is_empty() { ++ Err(cx.error(format!("field `{}` has no lifetimes to borrow", name)),) ++ } else { ++ Ok(lifetimes) ++ } ++} ++ ++fn collect_lifetimes(ty: &syn::Ty, out: &mut BTreeSet) { ++ match *ty { ++ syn::Ty::Slice(ref elem) | ++ syn::Ty::Array(ref elem, _) | ++ syn::Ty::Paren(ref elem) => { ++ collect_lifetimes(elem, out); ++ } ++ syn::Ty::Ptr(ref elem) => { ++ collect_lifetimes(&elem.ty, out); ++ } ++ syn::Ty::Rptr(ref lifetime, ref elem) => { ++ out.extend(lifetime.iter().cloned()); ++ collect_lifetimes(&elem.ty, out); ++ } ++ syn::Ty::Tup(ref elems) => { ++ for elem in elems { ++ collect_lifetimes(elem, out); ++ } ++ } ++ syn::Ty::Path(ref qself, ref path) => { ++ if let Some(ref qself) = *qself { ++ collect_lifetimes(&qself.ty, out); ++ } ++ for seg in &path.segments { ++ if let syn::PathParameters::AngleBracketed(ref params) = seg.parameters { ++ out.extend(params.lifetimes.iter().cloned()); ++ for ty in ¶ms.types { ++ collect_lifetimes(ty, out); ++ } ++ for binding in ¶ms.bindings { ++ collect_lifetimes(&binding.ty, out); ++ } ++ } ++ } ++ } ++ syn::Ty::BareFn(_) | ++ syn::Ty::Never | ++ syn::Ty::TraitObject(_) | ++ syn::Ty::ImplTrait(_) | ++ syn::Ty::Infer | ++ syn::Ty::Mac(_) => {} ++ } ++} diff --cc vendor/serde_derive_internals-0.16.0/src/case.rs index 000000000,000000000..1fa1ae7d2 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/src/case.rs @@@ -1,0 -1,0 +1,139 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::ascii::AsciiExt; ++use std::str::FromStr; ++ ++use self::RenameRule::*; ++ ++#[derive(Debug, PartialEq)] ++pub enum RenameRule { ++ /// Don't apply a default rename rule. ++ None, ++ /// Rename direct children to "lowercase" style. ++ LowerCase, ++ /// Rename direct children to "PascalCase" style, as typically used for enum variants. ++ PascalCase, ++ /// Rename direct children to "camelCase" style. ++ CamelCase, ++ /// Rename direct children to "snake_case" style, as commonly used for fields. ++ SnakeCase, ++ /// Rename direct children to "SCREAMING_SNAKE_CASE" style, as commonly used for constants. ++ ScreamingSnakeCase, ++ /// Rename direct children to "kebab-case" style. ++ KebabCase, ++ /// Rename direct children to "SCREAMING-KEBAB-CASE" style. ++ ScreamingKebabCase ++} ++ ++impl RenameRule { ++ pub fn apply_to_variant(&self, variant: &str) -> String { ++ match *self { ++ None | PascalCase => variant.to_owned(), ++ LowerCase => variant.to_ascii_lowercase(), ++ CamelCase => variant[..1].to_ascii_lowercase() + &variant[1..], ++ SnakeCase => { ++ let mut snake = String::new(); ++ for (i, ch) in variant.char_indices() { ++ if i > 0 && ch.is_uppercase() { ++ snake.push('_'); ++ } ++ snake.push(ch.to_ascii_lowercase()); ++ } ++ snake ++ } ++ ScreamingSnakeCase => SnakeCase.apply_to_variant(variant).to_ascii_uppercase(), ++ KebabCase => SnakeCase.apply_to_variant(variant).replace('_', "-"), ++ ScreamingKebabCase => ScreamingSnakeCase.apply_to_variant(variant).replace('_', "-") ++ } ++ } ++ ++ pub fn apply_to_field(&self, field: &str) -> String { ++ match *self { ++ None | LowerCase | SnakeCase => field.to_owned(), ++ PascalCase => { ++ let mut pascal = String::new(); ++ let mut capitalize = true; ++ for ch in field.chars() { ++ if ch == '_' { ++ capitalize = true; ++ } else if capitalize { ++ pascal.push(ch.to_ascii_uppercase()); ++ capitalize = false; ++ } else { ++ pascal.push(ch); ++ } ++ } ++ pascal ++ } ++ CamelCase => { ++ let pascal = PascalCase.apply_to_field(field); ++ pascal[..1].to_ascii_lowercase() + &pascal[1..] ++ } ++ ScreamingSnakeCase => field.to_ascii_uppercase(), ++ KebabCase => field.replace('_', "-"), ++ ScreamingKebabCase => ScreamingSnakeCase.apply_to_field(field).replace('_', "-") ++ } ++ } ++} ++ ++impl FromStr for RenameRule { ++ type Err = (); ++ ++ fn from_str(rename_all_str: &str) -> Result { ++ match rename_all_str { ++ "lowercase" => Ok(LowerCase), ++ "PascalCase" => Ok(PascalCase), ++ "camelCase" => Ok(CamelCase), ++ "snake_case" => Ok(SnakeCase), ++ "SCREAMING_SNAKE_CASE" => Ok(ScreamingSnakeCase), ++ "kebab-case" => Ok(KebabCase), ++ "SCREAMING-KEBAB-CASE" => Ok(ScreamingKebabCase), ++ _ => Err(()), ++ } ++ } ++} ++ ++#[test] ++fn rename_variants() { ++ for &(original, lower, camel, snake, screaming, kebab, screaming_kebab) in ++ &[ ++ ("Outcome", "outcome", "outcome", "outcome", "OUTCOME", "outcome", "OUTCOME"), ++ ("VeryTasty", "verytasty", "veryTasty", "very_tasty", "VERY_TASTY", "very-tasty", "VERY-TASTY"), ++ ("A", "a", "a", "a", "A", "a", "A"), ++ ("Z42", "z42", "z42", "z42", "Z42", "z42", "Z42"), ++ ] { ++ assert_eq!(None.apply_to_variant(original), original); ++ assert_eq!(LowerCase.apply_to_variant(original), lower); ++ assert_eq!(PascalCase.apply_to_variant(original), original); ++ assert_eq!(CamelCase.apply_to_variant(original), camel); ++ assert_eq!(SnakeCase.apply_to_variant(original), snake); ++ assert_eq!(ScreamingSnakeCase.apply_to_variant(original), screaming); ++ assert_eq!(KebabCase.apply_to_variant(original), kebab); ++ assert_eq!(ScreamingKebabCase.apply_to_variant(original), screaming_kebab); ++ } ++} ++ ++#[test] ++fn rename_fields() { ++ for &(original, pascal, camel, screaming, kebab, screaming_kebab) in ++ &[ ++ ("outcome", "Outcome", "outcome", "OUTCOME", "outcome", "OUTCOME"), ++ ("very_tasty", "VeryTasty", "veryTasty", "VERY_TASTY", "very-tasty", "VERY-TASTY"), ++ ("a", "A", "a", "A", "a", "A"), ++ ("z42", "Z42", "z42", "Z42", "z42", "Z42"), ++ ] { ++ assert_eq!(None.apply_to_field(original), original); ++ assert_eq!(PascalCase.apply_to_field(original), pascal); ++ assert_eq!(CamelCase.apply_to_field(original), camel); ++ assert_eq!(SnakeCase.apply_to_field(original), original); ++ assert_eq!(ScreamingSnakeCase.apply_to_field(original), screaming); ++ assert_eq!(KebabCase.apply_to_field(original), kebab); ++ assert_eq!(ScreamingKebabCase.apply_to_field(original), screaming_kebab); ++ } ++} diff --cc vendor/serde_derive_internals-0.16.0/src/check.rs index 000000000,000000000..5d6a76ff8 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/src/check.rs @@@ -1,0 -1,0 +1,152 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use ast::{Body, Container, Style}; ++use attr::Identifier; ++use Ctxt; ++ ++/// Cross-cutting checks that require looking at more than a single attrs ++/// object. Simpler checks should happen when parsing and building the attrs. ++pub fn check(cx: &Ctxt, cont: &Container) { ++ check_getter(cx, cont); ++ check_identifier(cx, cont); ++ check_variant_skip_attrs(cx, cont); ++} ++ ++/// Getters are only allowed inside structs (not enums) with the `remote` ++/// attribute. ++fn check_getter(cx: &Ctxt, cont: &Container) { ++ match cont.body { ++ Body::Enum(_) => { ++ if cont.body.has_getter() { ++ cx.error("#[serde(getter = \"...\")] is not allowed in an enum"); ++ } ++ } ++ Body::Struct(_, _) => { ++ if cont.body.has_getter() && cont.attrs.remote().is_none() { ++ cx.error( ++ "#[serde(getter = \"...\")] can only be used in structs \ ++ that have #[serde(remote = \"...\")]", ++ ); ++ } ++ } ++ } ++} ++ ++/// The `other` attribute must be used at most once and it must be the last ++/// variant of an enum that has the `field_identifier` attribute. ++/// ++/// Inside a `variant_identifier` all variants must be unit variants. Inside a ++/// `field_identifier` all but possibly one variant must be unit variants. The ++/// last variant may be a newtype variant which is an implicit "other" case. ++fn check_identifier(cx: &Ctxt, cont: &Container) { ++ let variants = match cont.body { ++ Body::Enum(ref variants) => variants, ++ Body::Struct(_, _) => { ++ return; ++ } ++ }; ++ ++ for (i, variant) in variants.iter().enumerate() { ++ match (variant.style, cont.attrs.identifier(), variant.attrs.other()) { ++ // The `other` attribute may only be used in a field_identifier. ++ (_, Identifier::Variant, true) | ++ (_, Identifier::No, true) => { ++ cx.error("#[serde(other)] may only be used inside a field_identifier"); ++ } ++ ++ // Variant with `other` attribute must be the last one. ++ (Style::Unit, Identifier::Field, true) => { ++ if i < variants.len() - 1 { ++ cx.error("#[serde(other)] must be the last variant"); ++ } ++ } ++ ++ // Variant with `other` attribute must be a unit variant. ++ (_, Identifier::Field, true) => { ++ cx.error("#[serde(other)] must be on a unit variant"); ++ } ++ ++ // Any sort of variant is allowed if this is not an identifier. ++ (_, Identifier::No, false) => {} ++ ++ // Unit variant without `other` attribute is always fine. ++ (Style::Unit, _, false) => {} ++ ++ // The last field is allowed to be a newtype catch-all. ++ (Style::Newtype, Identifier::Field, false) => { ++ if i < variants.len() - 1 { ++ cx.error(format!("`{}` must be the last variant", variant.ident)); ++ } ++ } ++ ++ (_, Identifier::Field, false) => { ++ cx.error("field_identifier may only contain unit variants"); ++ } ++ ++ (_, Identifier::Variant, false) => { ++ cx.error("variant_identifier may only contain unit variants"); ++ } ++ } ++ } ++} ++ ++/// Skip-(de)serializing attributes are not allowed on variants marked ++/// (de)serialize_with. ++fn check_variant_skip_attrs(cx: &Ctxt, cont: &Container) { ++ let variants = match cont.body { ++ Body::Enum(ref variants) => variants, ++ Body::Struct(_, _) => { ++ return; ++ } ++ }; ++ ++ for variant in variants.iter() { ++ if variant.attrs.serialize_with().is_some() { ++ if variant.attrs.skip_serializing() { ++ cx.error(format!("variant `{}` cannot have both #[serde(serialize_with)] and \ ++ #[serde(skip_serializing)]", variant.ident)); ++ } ++ ++ for (i, field) in variant.fields.iter().enumerate() { ++ let ident = field.ident.as_ref().map_or_else(|| format!("{}", i), ++ |ident| format!("`{}`", ident)); ++ ++ if field.attrs.skip_serializing() { ++ cx.error(format!("variant `{}` cannot have both #[serde(serialize_with)] and \ ++ a field {} marked with #[serde(skip_serializing)]", ++ variant.ident, ident)); ++ } ++ ++ if field.attrs.skip_serializing_if().is_some() { ++ cx.error(format!("variant `{}` cannot have both #[serde(serialize_with)] and \ ++ a field {} marked with #[serde(skip_serializing_if)]", ++ variant.ident, ident)); ++ } ++ } ++ } ++ ++ if variant.attrs.deserialize_with().is_some() { ++ if variant.attrs.skip_deserializing() { ++ cx.error(format!("variant `{}` cannot have both #[serde(deserialize_with)] and \ ++ #[serde(skip_deserializing)]", variant.ident)); ++ } ++ ++ for (i, field) in variant.fields.iter().enumerate() { ++ if field.attrs.skip_deserializing() { ++ let ident = field.ident.as_ref().map_or_else(|| format!("{}", i), ++ |ident| format!("`{}`", ident)); ++ ++ cx.error(format!("variant `{}` cannot have both #[serde(deserialize_with)] \ ++ and a field {} marked with #[serde(skip_deserializing)]", ++ variant.ident, ident)); ++ } ++ } ++ } ++ } ++} diff --cc vendor/serde_derive_internals-0.16.0/src/ctxt.rs index 000000000,000000000..fa8c57ad6 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/src/ctxt.rs @@@ -1,0 -1,0 +1,53 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::fmt::Display; ++use std::cell::RefCell; ++ ++#[derive(Default)] ++pub struct Ctxt { ++ errors: RefCell>>, ++} ++ ++impl Ctxt { ++ pub fn new() -> Self { ++ Ctxt { errors: RefCell::new(Some(Vec::new())) } ++ } ++ ++ pub fn error(&self, msg: T) { ++ self.errors ++ .borrow_mut() ++ .as_mut() ++ .unwrap() ++ .push(msg.to_string()); ++ } ++ ++ pub fn check(self) -> Result<(), String> { ++ let mut errors = self.errors.borrow_mut().take().unwrap(); ++ match errors.len() { ++ 0 => Ok(()), ++ 1 => Err(errors.pop().unwrap()), ++ n => { ++ let mut msg = format!("{} errors:", n); ++ for err in errors { ++ msg.push_str("\n\t# "); ++ msg.push_str(&err); ++ } ++ Err(msg) ++ } ++ } ++ } ++} ++ ++impl Drop for Ctxt { ++ fn drop(&mut self) { ++ if self.errors.borrow().is_some() { ++ panic!("forgot to check for errors"); ++ } ++ } ++} diff --cc vendor/serde_derive_internals-0.16.0/src/lib.rs index 000000000,000000000..e20881437 new file mode 100644 --- /dev/null +++ b/vendor/serde_derive_internals-0.16.0/src/lib.rs @@@ -1,0 -1,0 +1,22 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++#![doc(html_root_url = "https://docs.rs/serde_derive_internals/0.16.0")] ++ ++extern crate syn; ++#[macro_use] ++extern crate synom; ++ ++pub mod ast; ++pub mod attr; ++ ++mod ctxt; ++pub use ctxt::Ctxt; ++ ++mod case; ++mod check; diff --cc vendor/serde_ignored-0.0.4/.cargo-checksum.json index 000000000,000000000..c9a1eb6f6 new file mode 100644 --- /dev/null +++ b/vendor/serde_ignored-0.0.4/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"190e9765dcedb56be63b6e0993a006c7e3b071a016a304736e4a315dc01fb142"} diff --cc vendor/serde_ignored-0.0.4/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/serde_ignored-0.0.4/.cargo-ok diff --cc vendor/serde_ignored-0.0.4/.travis.yml index 000000000,000000000..f63906bd2 new file mode 100644 --- /dev/null +++ b/vendor/serde_ignored-0.0.4/.travis.yml @@@ -1,0 -1,0 +1,9 @@@ ++sudo: false ++language: rust ++ ++rust: ++ - stable ++ - beta ++ - nightly ++ ++script: cargo test diff --cc vendor/serde_ignored-0.0.4/Cargo.toml index 000000000,000000000..8ab5a24e6 new file mode 100644 --- /dev/null +++ b/vendor/serde_ignored-0.0.4/Cargo.toml @@@ -1,0 -1,0 +1,16 @@@ ++[package] ++name = "serde_ignored" ++version = "0.0.4" # update version in readme for breaking changes ++authors = ["David Tolnay "] ++license = "MIT/Apache-2.0" ++description = "Find out about keys that are ignored when deserializing data" ++repository = "https://github.com/dtolnay/serde-ignored" ++keywords = ["serde"] ++categories = ["encoding"] ++ ++[dependencies] ++serde = "1.0" ++ ++[dev-dependencies] ++serde_derive = "1.0" ++serde_json = "1.0" diff --cc vendor/serde_ignored-0.0.4/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/serde_ignored-0.0.4/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/serde_ignored-0.0.4/LICENSE-MIT index 000000000,000000000..39d4bdb5a new file mode 100644 --- /dev/null +++ b/vendor/serde_ignored-0.0.4/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/serde_ignored-0.0.4/README.md index 000000000,000000000..cc54f7247 new file mode 100644 --- /dev/null +++ b/vendor/serde_ignored-0.0.4/README.md @@@ -1,0 -1,0 +1,98 @@@ ++# Serde ignored ++ ++[![Build Status](https://api.travis-ci.org/dtolnay/serde-ignored.svg?branch=master)](https://travis-ci.org/dtolnay/serde-ignored) ++[![Latest Version](https://img.shields.io/crates/v/serde-ignored.svg)](https://crates.io/crates/serde-ignored) ++[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/serde_ignored) ++ ++Find out about keys that are ignored when deserializing data. This crate ++provides a wrapper that works with any existing Serde `Deserializer` and invokes ++a callback on every ignored field. ++ ++You can use this to warn users about extraneous keys in a config file, for ++example. ++ ++Note that if you want unrecognized fields to be an error, consider using the ++`#[serde(deny_unknown_fields)]` [attribute] instead. ++ ++[attribute]: https://serde.rs/attributes.html ++ ++```toml ++[dependencies] ++serde = "1.0" ++serde_ignored = "0.0.4" ++``` ++ ++```rust ++#[macro_use] ++extern crate serde_derive; ++ ++extern crate serde; ++extern crate serde_json; ++extern crate serde_ignored; ++ ++use std::collections::{BTreeSet as Set, BTreeMap as Map}; ++ ++#[derive(Debug, PartialEq, Deserialize)] ++struct Package { ++ name: String, ++ dependencies: Map, ++} ++ ++#[derive(Debug, PartialEq, Deserialize)] ++struct Dependency { ++ version: String, ++} ++ ++fn main() { ++ let j = r#"{ ++ "name": "demo", ++ "dependencies": { ++ "serde": { ++ "version": "0.9", ++ "typo1": "" ++ } ++ }, ++ "typo2": { ++ "inner": "" ++ }, ++ "typo3": {} ++ }"#; ++ ++ // Some Deserializer. ++ let jd = &mut serde_json::Deserializer::from_str(j); ++ ++ // We will build a set of paths to the unused elements. ++ let mut unused = Set::new(); ++ ++ let p: Package = serde_ignored::deserialize(jd, |path| { ++ unused.insert(path.to_string()); ++ }).unwrap(); ++ ++ // Deserialized as normal. ++ println!("{:?}", p); ++ ++ // There were three ignored keys. ++ let mut expected = Set::new(); ++ expected.insert("dependencies.serde.typo1".to_owned()); ++ expected.insert("typo2".to_owned()); ++ expected.insert("typo3".to_owned()); ++ assert_eq!(unused, expected); ++} ++``` ++ ++## License ++ ++This crate is licensed under either of ++ ++ * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ++ http://www.apache.org/licenses/LICENSE-2.0) ++ * MIT license ([LICENSE-MIT](LICENSE-MIT) or ++ http://opensource.org/licenses/MIT) ++ ++at your option. ++ ++### Contribution ++ ++Unless you explicitly state otherwise, any contribution intentionally submitted ++for inclusion in this crate by you, as defined in the Apache-2.0 license, shall ++be dual licensed as above, without any additional terms or conditions. diff --cc vendor/serde_ignored-0.0.4/src/lib.rs index 000000000,000000000..4abe968eb new file mode 100644 --- /dev/null +++ b/vendor/serde_ignored-0.0.4/src/lib.rs @@@ -1,0 -1,0 +1,1104 @@@ ++//! ```rust ++//! #[macro_use] ++//! extern crate serde_derive; ++//! ++//! extern crate serde; ++//! extern crate serde_json; ++//! extern crate serde_ignored; ++//! ++//! use std::collections::{BTreeSet as Set, BTreeMap as Map}; ++//! ++//! #[derive(Debug, PartialEq, Deserialize)] ++//! struct Package { ++//! name: String, ++//! dependencies: Map, ++//! } ++//! ++//! #[derive(Debug, PartialEq, Deserialize)] ++//! struct Dependency { ++//! version: String, ++//! } ++//! ++//! # fn try_main() -> Result<(), Box<::std::error::Error>> { ++//! let j = r#"{ ++//! "name": "demo", ++//! "dependencies": { ++//! "serde": { ++//! "version": "0.9", ++//! "typo1": "" ++//! } ++//! }, ++//! "typo2": { ++//! "inner": "" ++//! }, ++//! "typo3": {} ++//! }"#; ++//! ++//! // Some Deserializer. ++//! let jd = &mut serde_json::Deserializer::from_str(j); ++//! ++//! // We will build a set of paths to the unused elements. ++//! let mut unused = Set::new(); ++//! ++//! let p: Package = serde_ignored::deserialize(jd, |path| { ++//! unused.insert(path.to_string()); ++//! })?; ++//! ++//! assert_eq!(p, Package { ++//! name: "demo".to_owned(), ++//! dependencies: { ++//! let mut map = Map::new(); ++//! map.insert("serde".to_owned(), Dependency { ++//! version: "0.9".to_owned(), ++//! }); ++//! map ++//! }, ++//! }); ++//! ++//! assert_eq!(unused, { ++//! let mut expected = Set::new(); ++//! expected.insert("dependencies.serde.typo1".to_owned()); ++//! expected.insert("typo2".to_owned()); ++//! expected.insert("typo3".to_owned()); ++//! expected ++//! }); ++//! ++//! # Ok(()) } ++//! # fn main() { try_main().unwrap() } ++//! ``` ++ ++extern crate serde; ++ ++use std::fmt::{self, Display}; ++use serde::de::{self, Deserialize, DeserializeSeed, Visitor}; ++ ++/// Entry point. See crate documentation for an example. ++pub fn deserialize<'de, D, F, T>(deserializer: D, mut callback: F) -> Result ++ where D: de::Deserializer<'de>, ++ F: FnMut(Path), ++ T: Deserialize<'de> ++{ ++ T::deserialize(Deserializer::new(deserializer, &mut callback)) ++} ++ ++/// Deserializer adapter that invokes a callback with the path to every unused ++/// field of the input. ++pub struct Deserializer<'a, 'b, D, F: 'b> { ++ de: D, ++ callback: &'b mut F, ++ path: Path<'a>, ++} ++ ++impl<'a, 'b, D, F> Deserializer<'a, 'b, D, F> ++ where F: FnMut(Path) ++{ ++ pub fn new(de: D, callback: &'b mut F) -> Self { ++ Deserializer { ++ de: de, ++ callback: callback, ++ path: Path::Root, ++ } ++ } ++} ++ ++/// Path to the current value in the input, like `dependencies.serde.typo1`. ++pub enum Path<'a> { ++ Root, ++ Seq { parent: &'a Path<'a>, index: usize }, ++ Map { parent: &'a Path<'a>, key: String }, ++ Some { parent: &'a Path<'a> }, ++ NewtypeStruct { parent: &'a Path<'a> }, ++ NewtypeVariant { parent: &'a Path<'a> }, ++} ++ ++impl<'a> Display for Path<'a> { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { ++ struct Parent<'a>(&'a Path<'a>); ++ ++ impl<'a> Display for Parent<'a> { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { ++ match *self.0 { ++ Path::Root => Ok(()), ++ ref path => write!(formatter, "{}.", path), ++ } ++ } ++ } ++ ++ match *self { ++ Path::Root => formatter.write_str("."), ++ Path::Seq { parent, index } => write!(formatter, "{}{}", Parent(parent), index), ++ Path::Map { parent, ref key } => write!(formatter, "{}{}", Parent(parent), key), ++ Path::Some { parent } | ++ Path::NewtypeStruct { parent } | ++ Path::NewtypeVariant { parent } => write!(formatter, "{}?", Parent(parent)), ++ } ++ } ++} ++ ++/// Plain old forwarding impl except for `deserialize_ignored_any` which invokes ++/// the callback. ++impl<'a, 'b, 'de, D, F> de::Deserializer<'de> for Deserializer<'a, 'b, D, F> ++ where D: de::Deserializer<'de>, ++ F: FnMut(Path) ++{ ++ type Error = D::Error; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_any(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_bool(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_bool(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_u8(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_u8(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_u16(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_u16(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_u32(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_u32(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_u64(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_u64(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_i8(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_i8(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_i16(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_i16(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_i32(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_i32(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_i64(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_i64(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_f32(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_f32(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_f64(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_f64(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_char(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_char(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_str(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_str(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_string(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_string(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_bytes(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_bytes(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_byte_buf(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_byte_buf(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_option(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_option(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_unit(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_unit(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_unit_struct(self, ++ name: &'static str, ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_unit_struct(name, Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_newtype_struct(self, ++ name: &'static str, ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_newtype_struct(name, Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_seq(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_seq(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_tuple(self, len: usize, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_tuple(len, Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_tuple_struct(self, ++ name: &'static str, ++ len: usize, ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_tuple_struct(name, len, Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_map(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_map(Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_struct(self, ++ name: &'static str, ++ fields: &'static [&'static str], ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_struct(name, fields, Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_enum(self, ++ name: &'static str, ++ variants: &'static [&'static str], ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_enum(name, ++ variants, ++ Wrap::new(visitor, self.callback, &self.path)) ++ } ++ ++ fn deserialize_ignored_any(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ (self.callback)(self.path); ++ self.de.deserialize_ignored_any(visitor) ++ } ++ ++ fn deserialize_identifier(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.de.deserialize_identifier(visitor) ++ } ++} ++ ++/// Wrapper that attaches context to a `Visitor`, `SeqAccess`, `EnumAccess` or ++/// `VariantAccess`. ++struct Wrap<'a, 'b, X, F: 'b> { ++ delegate: X, ++ callback: &'b mut F, ++ path: &'a Path<'a>, ++} ++ ++impl<'a, 'b, X, F> Wrap<'a, 'b, X, F> { ++ fn new(delegate: X, callback: &'b mut F, path: &'a Path<'a>) -> Self { ++ Wrap { ++ delegate: delegate, ++ callback: callback, ++ path: path, ++ } ++ } ++} ++ ++/// Forwarding impl to preserve context. ++impl<'a, 'b, 'de, X, F> Visitor<'de> for Wrap<'a, 'b, X, F> ++ where X: Visitor<'de>, ++ F: FnMut(Path) ++{ ++ type Value = X::Value; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ self.delegate.expecting(formatter) ++ } ++ ++ fn visit_bool(self, v: bool) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_bool(v) ++ } ++ ++ fn visit_i8(self, v: i8) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_i8(v) ++ } ++ ++ fn visit_i16(self, v: i16) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_i16(v) ++ } ++ ++ fn visit_i32(self, v: i32) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_i32(v) ++ } ++ ++ fn visit_i64(self, v: i64) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_i64(v) ++ } ++ ++ fn visit_u8(self, v: u8) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_u8(v) ++ } ++ ++ fn visit_u16(self, v: u16) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_u16(v) ++ } ++ ++ fn visit_u32(self, v: u32) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_u32(v) ++ } ++ ++ fn visit_u64(self, v: u64) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_u64(v) ++ } ++ ++ fn visit_f32(self, v: f32) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_f32(v) ++ } ++ ++ fn visit_f64(self, v: f64) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_f64(v) ++ } ++ ++ fn visit_char(self, v: char) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_char(v) ++ } ++ ++ fn visit_str(self, v: &str) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_str(v) ++ } ++ ++ fn visit_borrowed_str(self, v: &'de str) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_borrowed_str(v) ++ } ++ ++ fn visit_string(self, v: String) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_string(v) ++ } ++ ++ fn visit_unit(self) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_unit() ++ } ++ ++ fn visit_none(self) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_none() ++ } ++ ++ fn visit_some(self, deserializer: D) -> Result ++ where D: de::Deserializer<'de> ++ { ++ self.delegate.visit_some(Deserializer { ++ de: deserializer, ++ callback: self.callback, ++ path: Path::Some { parent: self.path }, ++ }) ++ } ++ ++ fn visit_newtype_struct(self, deserializer: D) -> Result ++ where D: de::Deserializer<'de> ++ { ++ self.delegate.visit_newtype_struct(Deserializer { ++ de: deserializer, ++ callback: self.callback, ++ path: Path::NewtypeStruct { parent: self.path }, ++ }) ++ } ++ ++ fn visit_seq(self, visitor: V) -> Result ++ where V: de::SeqAccess<'de> ++ { ++ self.delegate.visit_seq(SeqAccess::new(visitor, self.callback, self.path)) ++ } ++ ++ fn visit_map(self, visitor: V) -> Result ++ where V: de::MapAccess<'de> ++ { ++ self.delegate.visit_map(MapAccess::new(visitor, self.callback, self.path)) ++ } ++ ++ fn visit_enum(self, visitor: V) -> Result ++ where V: de::EnumAccess<'de> ++ { ++ self.delegate.visit_enum(Wrap::new(visitor, self.callback, self.path)) ++ } ++ ++ fn visit_bytes(self, v: &[u8]) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_bytes(v) ++ } ++ ++ fn visit_borrowed_bytes(self, v: &'de [u8]) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_borrowed_bytes(v) ++ } ++ ++ fn visit_byte_buf(self, v: Vec) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_byte_buf(v) ++ } ++} ++ ++/// Forwarding impl to preserve context. ++impl<'a, 'b, 'de, X: 'a, F: 'b> de::EnumAccess<'de> for Wrap<'a, 'b, X, F> ++ where X: de::EnumAccess<'de>, ++ F: FnMut(Path) ++{ ++ type Error = X::Error; ++ type Variant = Wrap<'a, 'b, X::Variant, F>; ++ ++ fn variant_seed(self, seed: V) -> Result<(V::Value, Self::Variant), X::Error> ++ where V: DeserializeSeed<'de> ++ { ++ let callback = self.callback; ++ let path = self.path; ++ self.delegate ++ .variant_seed(seed) ++ .map(move |(v, vis)| (v, Wrap::new(vis, callback, path))) ++ } ++} ++ ++/// Forwarding impl to preserve context. ++impl<'a, 'b, 'de, X, F> de::VariantAccess<'de> for Wrap<'a, 'b, X, F> ++ where X: de::VariantAccess<'de>, ++ F: FnMut(Path) ++{ ++ type Error = X::Error; ++ ++ fn unit_variant(self) -> Result<(), X::Error> { ++ self.delegate.unit_variant() ++ } ++ ++ fn newtype_variant_seed(self, seed: T) -> Result ++ where T: DeserializeSeed<'de> ++ { ++ let path = Path::NewtypeVariant { parent: self.path }; ++ self.delegate ++ .newtype_variant_seed(TrackedSeed::new(seed, self.callback, path)) ++ } ++ ++ fn tuple_variant(self, len: usize, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.tuple_variant(len, Wrap::new(visitor, self.callback, self.path)) ++ } ++ ++ fn struct_variant(self, ++ fields: &'static [&'static str], ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.struct_variant(fields, Wrap::new(visitor, self.callback, self.path)) ++ } ++} ++ ++/// Seed that saves the string into the given optional during `visit_str` and ++/// `visit_string`. ++struct CaptureKey<'a, X> { ++ delegate: X, ++ key: &'a mut Option, ++} ++ ++impl<'a, X> CaptureKey<'a, X> { ++ fn new(delegate: X, key: &'a mut Option) -> Self { ++ CaptureKey { ++ delegate: delegate, ++ key: key, ++ } ++ } ++} ++ ++/// Forwarding impl. ++impl<'a, 'de, X> DeserializeSeed<'de> for CaptureKey<'a, X> ++ where X: DeserializeSeed<'de> ++{ ++ type Value = X::Value; ++ ++ fn deserialize(self, deserializer: D) -> Result ++ where D: de::Deserializer<'de> ++ { ++ self.delegate.deserialize(CaptureKey::new(deserializer, self.key)) ++ } ++} ++ ++/// Forwarding impl. ++impl<'a, 'de, X> de::Deserializer<'de> for CaptureKey<'a, X> ++ where X: de::Deserializer<'de> ++{ ++ type Error = X::Error; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_any(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_bool(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_bool(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_u8(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_u8(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_u16(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_u16(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_u32(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_u32(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_u64(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_u64(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_i8(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_i8(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_i16(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_i16(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_i32(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_i32(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_i64(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_i64(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_f32(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_f32(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_f64(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_f64(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_char(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_char(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_str(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_str(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_string(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_string(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_bytes(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_bytes(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_byte_buf(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_byte_buf(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_option(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_option(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_unit(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_unit(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_unit_struct(self, ++ name: &'static str, ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_unit_struct(name, CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_newtype_struct(self, ++ name: &'static str, ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_newtype_struct(name, CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_seq(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_seq(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_tuple(self, len: usize, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_tuple(len, CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_tuple_struct(self, ++ name: &'static str, ++ len: usize, ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_tuple_struct(name, len, CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_map(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_map(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_struct(self, ++ name: &'static str, ++ fields: &'static [&'static str], ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_struct(name, fields, CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_enum(self, ++ name: &'static str, ++ variants: &'static [&'static str], ++ visitor: V) ++ -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_enum(name, variants, CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_ignored_any(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_ignored_any(CaptureKey::new(visitor, self.key)) ++ } ++ ++ fn deserialize_identifier(self, visitor: V) -> Result ++ where V: Visitor<'de> ++ { ++ self.delegate.deserialize_identifier(CaptureKey::new(visitor, self.key)) ++ } ++} ++ ++/// Forwarding impl except `visit_str` and `visit_string` which save the string. ++impl<'a, 'de, X> Visitor<'de> for CaptureKey<'a, X> ++ where X: Visitor<'de> ++{ ++ type Value = X::Value; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ self.delegate.expecting(formatter) ++ } ++ ++ fn visit_bool(self, v: bool) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_bool(v) ++ } ++ ++ fn visit_i8(self, v: i8) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_i8(v) ++ } ++ ++ fn visit_i16(self, v: i16) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_i16(v) ++ } ++ ++ fn visit_i32(self, v: i32) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_i32(v) ++ } ++ ++ fn visit_i64(self, v: i64) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_i64(v) ++ } ++ ++ fn visit_u8(self, v: u8) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_u8(v) ++ } ++ ++ fn visit_u16(self, v: u16) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_u16(v) ++ } ++ ++ fn visit_u32(self, v: u32) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_u32(v) ++ } ++ ++ fn visit_u64(self, v: u64) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_u64(v) ++ } ++ ++ fn visit_f32(self, v: f32) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_f32(v) ++ } ++ ++ fn visit_f64(self, v: f64) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_f64(v) ++ } ++ ++ fn visit_char(self, v: char) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_char(v) ++ } ++ ++ fn visit_str(self, v: &str) -> Result ++ where E: de::Error ++ { ++ *self.key = Some(v.to_owned()); ++ self.delegate.visit_str(v) ++ } ++ ++ fn visit_borrowed_str(self, v: &'de str) -> Result ++ where E: de::Error ++ { ++ *self.key = Some(v.to_owned()); ++ self.delegate.visit_borrowed_str(v) ++ } ++ ++ fn visit_string(self, v: String) -> Result ++ where E: de::Error ++ { ++ *self.key = Some(v.clone()); ++ self.delegate.visit_string(v) ++ } ++ ++ fn visit_unit(self) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_unit() ++ } ++ ++ fn visit_none(self) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_none() ++ } ++ ++ fn visit_some(self, deserializer: D) -> Result ++ where D: de::Deserializer<'de> ++ { ++ self.delegate.visit_some(deserializer) ++ } ++ ++ fn visit_newtype_struct(self, deserializer: D) -> Result ++ where D: de::Deserializer<'de> ++ { ++ self.delegate.visit_newtype_struct(deserializer) ++ } ++ ++ fn visit_seq(self, visitor: V) -> Result ++ where V: de::SeqAccess<'de> ++ { ++ self.delegate.visit_seq(visitor) ++ } ++ ++ fn visit_map(self, visitor: V) -> Result ++ where V: de::MapAccess<'de> ++ { ++ self.delegate.visit_map(visitor) ++ } ++ ++ fn visit_enum(self, visitor: V) -> Result ++ where V: de::EnumAccess<'de> ++ { ++ self.delegate.visit_enum(visitor) ++ } ++ ++ fn visit_bytes(self, v: &[u8]) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_bytes(v) ++ } ++ ++ fn visit_borrowed_bytes(self, v: &'de [u8]) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_borrowed_bytes(v) ++ } ++ ++ fn visit_byte_buf(self, v: Vec) -> Result ++ where E: de::Error ++ { ++ self.delegate.visit_byte_buf(v) ++ } ++} ++ ++/// Seed used for map values, sequence elements and newtype variants to track ++/// their path. ++struct TrackedSeed<'a, X, F: 'a> { ++ seed: X, ++ callback: &'a mut F, ++ path: Path<'a>, ++} ++ ++impl<'a, X, F> TrackedSeed<'a, X, F> { ++ fn new(seed: X, callback: &'a mut F, path: Path<'a>) -> Self { ++ TrackedSeed { ++ seed: seed, ++ callback: callback, ++ path: path, ++ } ++ } ++} ++ ++impl<'a, 'de, X, F> DeserializeSeed<'de> for TrackedSeed<'a, X, F> ++ where X: DeserializeSeed<'de>, ++ F: FnMut(Path) ++{ ++ type Value = X::Value; ++ ++ fn deserialize(self, deserializer: D) -> Result ++ where D: de::Deserializer<'de> ++ { ++ self.seed.deserialize(Deserializer { ++ de: deserializer, ++ callback: self.callback, ++ path: self.path, ++ }) ++ } ++} ++ ++/// Seq visitor that tracks the index of its elements. ++struct SeqAccess<'a, 'b, X, F: 'b> { ++ delegate: X, ++ callback: &'b mut F, ++ path: &'a Path<'a>, ++ index: usize, ++} ++ ++impl<'a, 'b, X, F> SeqAccess<'a, 'b, X, F> { ++ fn new(delegate: X, callback: &'b mut F, path: &'a Path<'a>) -> Self { ++ SeqAccess { ++ delegate: delegate, ++ callback: callback, ++ path: path, ++ index: 0, ++ } ++ } ++} ++ ++/// Forwarding impl to preserve context. ++impl<'a, 'b, 'de, X, F> de::SeqAccess<'de> for SeqAccess<'a, 'b, X, F> ++ where X: de::SeqAccess<'de>, ++ F: FnMut(Path) ++{ ++ type Error = X::Error; ++ ++ fn next_element_seed(&mut self, seed: T) -> Result, X::Error> ++ where T: DeserializeSeed<'de> ++ { ++ let path = Path::Seq { ++ parent: self.path, ++ index: self.index, ++ }; ++ self.index += 1; ++ self.delegate.next_element_seed(TrackedSeed::new(seed, self.callback, path)) ++ } ++ ++ fn size_hint(&self) -> Option { ++ self.delegate.size_hint() ++ } ++} ++ ++/// Map visitor that captures the string value of its keys and uses that to ++/// track the path to its values. ++struct MapAccess<'a, 'b, X, F: 'b> { ++ delegate: X, ++ callback: &'b mut F, ++ path: &'a Path<'a>, ++ key: Option, ++} ++ ++impl<'a, 'b, X, F> MapAccess<'a, 'b, X, F> { ++ fn new(delegate: X, callback: &'b mut F, path: &'a Path<'a>) -> Self { ++ MapAccess { ++ delegate: delegate, ++ callback: callback, ++ path: path, ++ key: None, ++ } ++ } ++ ++ fn key(&mut self) -> Result ++ where E: de::Error ++ { ++ self.key.take().ok_or_else(|| E::custom("non-string key")) ++ } ++} ++ ++impl<'a, 'b, 'de, X, F> de::MapAccess<'de> for MapAccess<'a, 'b, X, F> ++ where X: de::MapAccess<'de>, ++ F: FnMut(Path) ++{ ++ type Error = X::Error; ++ ++ fn next_key_seed(&mut self, seed: K) -> Result, X::Error> ++ where K: DeserializeSeed<'de> ++ { ++ self.delegate.next_key_seed(CaptureKey::new(seed, &mut self.key)) ++ } ++ ++ fn next_value_seed(&mut self, seed: V) -> Result ++ where V: DeserializeSeed<'de> ++ { ++ let path = Path::Map { ++ parent: self.path, ++ key: self.key()?, ++ }; ++ self.delegate.next_value_seed(TrackedSeed::new(seed, self.callback, path)) ++ } ++ ++ fn size_hint(&self) -> Option { ++ self.delegate.size_hint() ++ } ++} diff --cc vendor/serde_json-1.0.3/.cargo-checksum.json index 000000000,000000000..0fce56c7a new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"d243424e06f9f9c39e3cd36147470fd340db785825e367625f79298a6ac6b7ac"} diff --cc vendor/serde_json-1.0.3/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/.cargo-ok diff --cc vendor/serde_json-1.0.3/Cargo.toml index 000000000,000000000..1b8fd96e1 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/Cargo.toml @@@ -1,0 -1,0 +1,56 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "serde_json" ++version = "1.0.3" ++authors = ["Erick Tryzelaar ", "David Tolnay "] ++include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] ++description = "A JSON serialization file format" ++documentation = "http://docs.serde.rs/serde_json/" ++readme = "README.md" ++keywords = ["json", "serde", "serialization"] ++categories = ["encoding"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/serde-rs/json" ++[dependencies.num-traits] ++version = "0.1.32" ++ ++[dependencies.serde] ++version = "1.0" ++ ++[dependencies.linked-hash-map] ++version = "0.4.1" ++optional = true ++ ++[dependencies.itoa] ++version = "0.3" ++ ++[dependencies.dtoa] ++version = "0.4" ++[dev-dependencies.serde_derive] ++version = "1.0" ++ ++[dev-dependencies.compiletest_rs] ++version = "0.2" ++ ++[dev-dependencies.serde_bytes] ++version = "0.10" ++ ++[features] ++default = [] ++preserve_order = ["linked-hash-map"] ++[badges.appveyor] ++repository = "serde-rs/json" ++ ++[badges.travis-ci] ++repository = "serde-rs/json" diff --cc vendor/serde_json-1.0.3/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/serde_json-1.0.3/LICENSE-MIT index 000000000,000000000..39d4bdb5a new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/serde_json-1.0.3/README.md index 000000000,000000000..6828915a6 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/README.md @@@ -1,0 -1,0 +1,339 @@@ ++# Serde JSON   [![Build Status]][travis] [![Latest Version]][crates.io] ++ ++[Build Status]: https://api.travis-ci.org/serde-rs/json.svg?branch=master ++[travis]: https://travis-ci.org/serde-rs/json ++[Latest Version]: https://img.shields.io/crates/v/serde_json.svg ++[crates.io]: https://crates.io/crates/serde\_json ++ ++**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.** ++ ++--- ++ ++```toml ++[dependencies] ++serde_json = "1.0" ++``` ++ ++You may be looking for: ++ ++- [JSON API documentation](https://docs.serde.rs/serde_json/) ++- [Serde API documentation](https://docs.serde.rs/serde/) ++- [Detailed documentation about Serde](https://serde.rs/) ++- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html) ++- [Release notes](https://github.com/serde-rs/json/releases) ++ ++JSON is a ubiquitous open-standard format that uses human-readable text to ++transmit data objects consisting of key-value pairs. ++ ++```json,ignore ++{ ++ "name": "John Doe", ++ "age": 43, ++ "address": { ++ "street": "10 Downing Street", ++ "city": "London" ++ }, ++ "phones": [ ++ "+44 1234567", ++ "+44 2345678" ++ ] ++} ++``` ++ ++There are three common ways that you might find yourself needing to work ++with JSON data in Rust. ++ ++ - **As text data.** An unprocessed string of JSON data that you receive on ++ an HTTP endpoint, read from a file, or prepare to send to a remote ++ server. ++ - **As an untyped or loosely typed representation.** Maybe you want to ++ check that some JSON data is valid before passing it on, but without ++ knowing the structure of what it contains. Or you want to do very basic ++ manipulations like insert a key in a particular spot. ++ - **As a strongly typed Rust data structure.** When you expect all or most ++ of your data to conform to a particular structure and want to get real ++ work done without JSON's loosey-goosey nature tripping you up. ++ ++Serde JSON provides efficient, flexible, safe ways of converting data ++between each of these representations. ++ ++## Operating on untyped JSON values ++ ++Any valid JSON data can be manipulated in the following recursive enum ++representation. This data structure is [`serde_json::Value`][value]. ++ ++```rust,ignore ++enum Value { ++ Null, ++ Bool(bool), ++ Number(Number), ++ String(String), ++ Array(Vec), ++ Object(Map), ++} ++``` ++ ++A string of JSON data can be parsed into a `serde_json::Value` by the ++[`serde_json::from_str`][from_str] function. There is also ++[`from_slice`][from_slice] for parsing from a byte slice &[u8] and ++[`from_reader`][from_reader] for parsing from any `io::Read` like a File or ++a TCP stream. ++ ++ ++ ++ ++ ++```rust ++extern crate serde_json; ++ ++use serde_json::{Value, Error}; ++ ++fn untyped_example() -> Result<(), Error> { ++ // Some JSON input data as a &str. Maybe this comes from the user. ++ let data = r#"{ ++ "name": "John Doe", ++ "age": 43, ++ "phones": [ ++ "+44 1234567", ++ "+44 2345678" ++ ] ++ }"#; ++ ++ // Parse the string of data into serde_json::Value. ++ let v: Value = serde_json::from_str(data)?; ++ ++ // Access parts of the data by indexing with square brackets. ++ println!("Please call {} at the number {}", v["name"], v["phones"][0]); ++ ++ Ok(()) ++} ++``` ++ ++The `Value` representation is sufficient for very basic tasks but can be tedious ++to work with for anything more significant. Error handling is verbose to ++implement correctly, for example imagine trying to detect the presence of ++unrecognized fields in the input data. The compiler is powerless to help you ++when you make a mistake, for example imagine typoing `v["name"]` as `v["nmae"]` ++in one of the dozens of places it is used in your code. ++ ++## Parsing JSON as strongly typed data structures ++ ++Serde provides a powerful way of mapping JSON data into Rust data structures ++largely automatically. ++ ++ ++ ++ ++ ++```rust ++extern crate serde; ++extern crate serde_json; ++ ++#[macro_use] ++extern crate serde_derive; ++ ++use serde_json::Error; ++ ++#[derive(Serialize, Deserialize)] ++struct Person { ++ name: String, ++ age: u8, ++ phones: Vec, ++} ++ ++fn typed_example() -> Result<(), Error> { ++ // Some JSON input data as a &str. Maybe this comes from the user. ++ let data = r#"{ ++ "name": "John Doe", ++ "age": 43, ++ "phones": [ ++ "+44 1234567", ++ "+44 2345678" ++ ] ++ }"#; ++ ++ // Parse the string of data into a Person object. This is exactly the ++ // same function as the one that produced serde_json::Value above, but ++ // now we are asking it for a Person as output. ++ let p: Person = serde_json::from_str(data)?; ++ ++ // Do things just like with any other Rust data structure. ++ println!("Please call {} at the number {}", p.name, p.phones[0]); ++ ++ Ok(()) ++} ++``` ++ ++This is the same `serde_json::from_str` function as before, but this time we ++assign the return value to a variable of type `Person` so Serde will ++automatically interpret the input data as a `Person` and produce informative ++error messages if the layout does not conform to what a `Person` is expected ++to look like. ++ ++Any type that implements Serde's `Deserialize` trait can be deserialized ++this way. This includes built-in Rust standard library types like `Vec` ++and `HashMap`, as well as any structs or enums annotated with ++`#[derive(Deserialize)]`. ++ ++Once we have `p` of type `Person`, our IDE and the Rust compiler can help us ++use it correctly like they do for any other Rust code. The IDE can ++autocomplete field names to prevent typos, which was impossible in the ++`serde_json::Value` representation. And the Rust compiler can check that ++when we write `p.phones[0]`, then `p.phones` is guaranteed to be a ++`Vec` so indexing into it makes sense and produces a `String`. ++ ++## Constructing JSON values ++ ++Serde JSON provides a [`json!` macro][macro] to build `serde_json::Value` ++objects with very natural JSON syntax. In order to use this macro, ++`serde_json` needs to be imported with the `#[macro_use]` attribute. ++ ++ ++ ++ ++ ++```rust ++#[macro_use] ++extern crate serde_json; ++ ++fn main() { ++ // The type of `john` is `serde_json::Value` ++ let john = json!({ ++ "name": "John Doe", ++ "age": 43, ++ "phones": [ ++ "+44 1234567", ++ "+44 2345678" ++ ] ++ }); ++ ++ println!("first phone number: {}", john["phones"][0]); ++ ++ // Convert to a string of JSON and print it out ++ println!("{}", john.to_string()); ++} ++``` ++ ++The `Value::to_string()` function converts a `serde_json::Value` into a ++`String` of JSON text. ++ ++One neat thing about the `json!` macro is that variables and expressions can ++be interpolated directly into the JSON value as you are building it. Serde ++will check at compile time that the value you are interpolating is able to ++be represented as JSON. ++ ++ ++ ++ ++ ++```rust ++let full_name = "John Doe"; ++let age_last_year = 42; ++ ++// The type of `john` is `serde_json::Value` ++let john = json!({ ++ "name": full_name, ++ "age": age_last_year + 1, ++ "phones": [ ++ format!("+44 {}", random_phone()) ++ ] ++}); ++``` ++ ++This is amazingly convenient but we have the problem we had before with ++`Value` which is that the IDE and Rust compiler cannot help us if we get it ++wrong. Serde JSON provides a better way of serializing strongly-typed data ++structures into JSON text. ++ ++## Creating JSON by serializing data structures ++ ++A data structure can be converted to a JSON string by ++[`serde_json::to_string`][to_string]. There is also ++[`serde_json::to_vec`][to_vec] which serializes to a `Vec` and ++[`serde_json::to_writer`][to_writer] which serializes to any `io::Write` ++such as a File or a TCP stream. ++ ++ ++ ++ ++ ++```rust ++extern crate serde; ++extern crate serde_json; ++ ++#[macro_use] ++extern crate serde_derive; ++ ++use serde_json::Error; ++ ++#[derive(Serialize, Deserialize)] ++struct Address { ++ street: String, ++ city: String, ++} ++ ++fn print_an_address() -> Result<(), Error> { ++ // Some data structure. ++ let address = Address { ++ street: "10 Downing Street".to_owned(), ++ city: "London".to_owned(), ++ }; ++ ++ // Serialize it to a JSON string. ++ let j = serde_json::to_string(&address)?; ++ ++ // Print, write to a file, or send to an HTTP server. ++ println!("{}", j); ++ ++ Ok(()) ++} ++``` ++ ++Any type that implements Serde's `Serialize` trait can be serialized this ++way. This includes built-in Rust standard library types like `Vec` and ++`HashMap`, as well as any structs or enums annotated with ++`#[derive(Serialize)]`. ++ ++## Performance ++ ++It is fast. You should expect in the ballpark of 500 to 1000 megabytes per ++second deserialization and 600 to 900 megabytes per second serialization, ++depending on the characteristics of your data. This is competitive with the ++fastest C and C++ JSON libraries or even 30% faster for many use cases. ++Benchmarks live in the [serde-rs/json-benchmark] repo. ++ ++[serde-rs/json-benchmark]: https://github.com/serde-rs/json-benchmark ++ ++## Getting help ++ ++Serde developers live in the #serde channel on ++[`irc.mozilla.org`](https://wiki.mozilla.org/IRC). The #rust channel is also a ++good resource with generally faster response time but less specific knowledge ++about Serde. If IRC is not your thing, we are happy to respond to [GitHub ++issues](https://github.com/serde-rs/json/issues/new) as well. ++ ++## License ++ ++Serde JSON is licensed under either of ++ ++ * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or ++ http://www.apache.org/licenses/LICENSE-2.0) ++ * MIT license ([LICENSE-MIT](LICENSE-MIT) or ++ http://opensource.org/licenses/MIT) ++ ++at your option. ++ ++### Contribution ++ ++Unless you explicitly state otherwise, any contribution intentionally submitted ++for inclusion in Serde JSON by you, as defined in the Apache-2.0 license, shall ++be dual licensed as above, without any additional terms or conditions. ++ ++[value]: https://docs.serde.rs/serde_json/value/enum.Value.html ++[from_str]: https://docs.serde.rs/serde_json/de/fn.from_str.html ++[from_slice]: https://docs.serde.rs/serde_json/de/fn.from_slice.html ++[from_reader]: https://docs.serde.rs/serde_json/de/fn.from_reader.html ++[to_string]: https://docs.serde.rs/serde_json/ser/fn.to_string.html ++[to_vec]: https://docs.serde.rs/serde_json/ser/fn.to_vec.html ++[to_writer]: https://docs.serde.rs/serde_json/ser/fn.to_writer.html ++[macro]: https://docs.serde.rs/serde_json/macro.json.html diff --cc vendor/serde_json-1.0.3/src/de.rs index 000000000,000000000..fd2a4894d new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/de.rs @@@ -1,0 -1,0 +1,1560 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! Deserialize JSON data to a Rust data structure. ++ ++use std::{i32, u64}; ++use std::io; ++use std::marker::PhantomData; ++ ++use serde::de::{self, Unexpected}; ++ ++use super::error::{Error, ErrorCode, Result}; ++ ++use read::{self, Reference}; ++ ++pub use read::{Read, IoRead, SliceRead, StrRead}; ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++/// A structure that deserializes JSON into Rust values. ++pub struct Deserializer { ++ read: R, ++ str_buf: Vec, ++ remaining_depth: u8, ++} ++ ++impl<'de, R> Deserializer ++where ++ R: read::Read<'de>, ++{ ++ /// Create a JSON deserializer from one of the possible serde_json input ++ /// sources. ++ /// ++ /// Typically it is more convenient to use one of these methods instead: ++ /// ++ /// - Deserializer::from_str ++ /// - Deserializer::from_bytes ++ /// - Deserializer::from_reader ++ pub fn new(read: R) -> Self { ++ Deserializer { ++ read: read, ++ str_buf: Vec::with_capacity(128), ++ remaining_depth: 128, ++ } ++ } ++} ++ ++impl Deserializer> ++where ++ R: io::Read, ++{ ++ /// Creates a JSON deserializer from an `io::Read`. ++ pub fn from_reader(reader: R) -> Self { ++ Deserializer::new(read::IoRead::new(reader)) ++ } ++} ++ ++impl<'a> Deserializer> { ++ /// Creates a JSON deserializer from a `&[u8]`. ++ pub fn from_slice(bytes: &'a [u8]) -> Self { ++ Deserializer::new(read::SliceRead::new(bytes)) ++ } ++} ++ ++impl<'a> Deserializer> { ++ /// Creates a JSON deserializer from a `&str`. ++ pub fn from_str(s: &'a str) -> Self { ++ Deserializer::new(read::StrRead::new(s)) ++ } ++} ++ ++macro_rules! overflow { ++ ($a:ident * 10 + $b:ident, $c:expr) => { ++ $a >= $c / 10 && ($a > $c / 10 || $b > $c % 10) ++ } ++} ++ ++enum Number { ++ F64(f64), ++ U64(u64), ++ I64(i64), ++} ++ ++impl Number { ++ fn visit<'de, V>(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ match self { ++ Number::F64(x) => visitor.visit_f64(x), ++ Number::U64(x) => visitor.visit_u64(x), ++ Number::I64(x) => visitor.visit_i64(x), ++ } ++ } ++} ++ ++impl<'de, R: Read<'de>> Deserializer { ++ /// The `Deserializer::end` method should be called after a value has been fully deserialized. ++ /// This allows the `Deserializer` to validate that the input stream is at the end or that it ++ /// only has trailing whitespace. ++ pub fn end(&mut self) -> Result<()> { ++ match try!(self.parse_whitespace()) { ++ Some(_) => Err(self.peek_error(ErrorCode::TrailingCharacters)), ++ None => Ok(()), ++ } ++ } ++ ++ /// Turn a JSON deserializer into an iterator over values of type T. ++ pub fn into_iter(self) -> StreamDeserializer<'de, R, T> ++ where ++ T: de::Deserialize<'de>, ++ { ++ // This cannot be an implementation of std::iter::IntoIterator because ++ // we need the caller to choose what T is. ++ let offset = self.read.byte_offset(); ++ StreamDeserializer { ++ de: self, ++ offset: offset, ++ output: PhantomData, ++ lifetime: PhantomData, ++ } ++ } ++ ++ fn peek(&mut self) -> Result> { ++ self.read.peek().map_err(Error::io) ++ } ++ ++ fn peek_or_null(&mut self) -> Result { ++ Ok(try!(self.peek()).unwrap_or(b'\x00')) ++ } ++ ++ fn eat_char(&mut self) { ++ self.read.discard(); ++ } ++ ++ fn next_char(&mut self) -> Result> { ++ self.read.next().map_err(Error::io) ++ } ++ ++ fn next_char_or_null(&mut self) -> Result { ++ Ok(try!(self.next_char()).unwrap_or(b'\x00')) ++ } ++ ++ /// Error caused by a byte from next_char(). ++ fn error(&mut self, reason: ErrorCode) -> Error { ++ let pos = self.read.position(); ++ Error::syntax(reason, pos.line, pos.column) ++ } ++ ++ /// Error caused by a byte from peek(). ++ fn peek_error(&mut self, reason: ErrorCode) -> Error { ++ let pos = self.read.peek_position(); ++ Error::syntax(reason, pos.line, pos.column) ++ } ++ ++ /// Returns the first non-whitespace byte without consuming it, or `None` if ++ /// EOF is encountered. ++ fn parse_whitespace(&mut self) -> Result> { ++ loop { ++ match try!(self.peek()) { ++ Some(b' ') | Some(b'\n') | Some(b'\t') | Some(b'\r') => { ++ self.eat_char(); ++ } ++ other => { ++ return Ok(other); ++ } ++ } ++ } ++ } ++ ++ fn parse_value(&mut self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ let peek = match try!(self.parse_whitespace()) { ++ Some(b) => b, ++ None => { ++ return Err(self.peek_error(ErrorCode::EofWhileParsingValue)); ++ } ++ }; ++ ++ let value = match peek { ++ b'n' => { ++ self.eat_char(); ++ try!(self.parse_ident(b"ull")); ++ visitor.visit_unit() ++ } ++ b't' => { ++ self.eat_char(); ++ try!(self.parse_ident(b"rue")); ++ visitor.visit_bool(true) ++ } ++ b'f' => { ++ self.eat_char(); ++ try!(self.parse_ident(b"alse")); ++ visitor.visit_bool(false) ++ } ++ b'-' => { ++ self.eat_char(); ++ try!(self.parse_integer(false)).visit(visitor) ++ } ++ b'0'...b'9' => try!(self.parse_integer(true)).visit(visitor), ++ b'"' => { ++ self.eat_char(); ++ self.str_buf.clear(); ++ match try!(self.read.parse_str(&mut self.str_buf)) { ++ Reference::Borrowed(s) => visitor.visit_borrowed_str(s), ++ Reference::Copied(s) => visitor.visit_str(s), ++ } ++ } ++ b'[' => { ++ self.remaining_depth -= 1; ++ if self.remaining_depth == 0 { ++ return Err(self.peek_error(ErrorCode::RecursionLimitExceeded)); ++ } ++ ++ self.eat_char(); ++ let ret = visitor.visit_seq(SeqAccess::new(self)); ++ ++ self.remaining_depth += 1; ++ ++ match (ret, self.end_seq()) { ++ (Ok(ret), Ok(())) => Ok(ret), ++ (Err(err), _) | (_, Err(err)) => Err(err), ++ } ++ } ++ b'{' => { ++ self.remaining_depth -= 1; ++ if self.remaining_depth == 0 { ++ return Err(self.peek_error(ErrorCode::RecursionLimitExceeded)); ++ } ++ ++ self.eat_char(); ++ let ret = visitor.visit_map(MapAccess::new(self)); ++ ++ self.remaining_depth += 1; ++ ++ match (ret, self.end_map()) { ++ (Ok(ret), Ok(())) => Ok(ret), ++ (Err(err), _) | (_, Err(err)) => Err(err), ++ } ++ } ++ _ => Err(self.peek_error(ErrorCode::ExpectedSomeValue)), ++ }; ++ ++ match value { ++ Ok(value) => Ok(value), ++ // The de::Error and From impls both create errors ++ // with unknown line and column. Fill in the position here by ++ // looking at the current index in the input. There is no way to ++ // tell whether this should call `error` or `peek_error` so pick the ++ // one that seems correct more often. Worst case, the position is ++ // off by one character. ++ Err(err) => Err(err.fix_position(|code| self.error(code))), ++ } ++ } ++ ++ fn parse_ident(&mut self, ident: &[u8]) -> Result<()> { ++ for c in ident { ++ if Some(*c) != try!(self.next_char()) { ++ return Err(self.error(ErrorCode::ExpectedSomeIdent)); ++ } ++ } ++ ++ Ok(()) ++ } ++ ++ fn parse_integer(&mut self, pos: bool) -> Result { ++ match try!(self.next_char_or_null()) { ++ b'0' => { ++ // There can be only one leading '0'. ++ match try!(self.peek_or_null()) { ++ b'0'...b'9' => Err(self.peek_error(ErrorCode::InvalidNumber)), ++ _ => self.parse_number(pos, 0), ++ } ++ } ++ c @ b'1'...b'9' => { ++ let mut res = (c - b'0') as u64; ++ ++ loop { ++ match try!(self.peek_or_null()) { ++ c @ b'0'...b'9' => { ++ self.eat_char(); ++ let digit = (c - b'0') as u64; ++ ++ // We need to be careful with overflow. If we can, try to keep the ++ // number as a `u64` until we grow too large. At that point, switch to ++ // parsing the value as a `f64`. ++ if overflow!(res * 10 + digit, u64::MAX) { ++ return Ok(Number::F64(try!(self.parse_long_integer( ++ pos, ++ res, ++ 1, // res * 10^1 ++ )))); ++ } ++ ++ res = res * 10 + digit; ++ } ++ _ => { ++ return self.parse_number(pos, res); ++ } ++ } ++ } ++ } ++ _ => Err(self.error(ErrorCode::InvalidNumber)), ++ } ++ } ++ ++ fn parse_long_integer( ++ &mut self, ++ pos: bool, ++ significand: u64, ++ mut exponent: i32, ++ ) -> Result { ++ loop { ++ match try!(self.peek_or_null()) { ++ b'0'...b'9' => { ++ self.eat_char(); ++ // This could overflow... if your integer is gigabytes long. ++ // Ignore that possibility. ++ exponent += 1; ++ } ++ b'.' => { ++ return self.parse_decimal(pos, significand, exponent); ++ } ++ b'e' | b'E' => { ++ return self.parse_exponent(pos, significand, exponent); ++ } ++ _ => { ++ return self.f64_from_parts(pos, significand, exponent); ++ } ++ } ++ } ++ } ++ ++ fn parse_number(&mut self, pos: bool, significand: u64) -> Result { ++ Ok(match try!(self.peek_or_null()) { ++ b'.' => Number::F64(try!(self.parse_decimal(pos, significand, 0))), ++ b'e' | b'E' => Number::F64(try!(self.parse_exponent(pos, significand, 0))), ++ _ => { ++ if pos { ++ Number::U64(significand) ++ } else { ++ let neg = (significand as i64).wrapping_neg(); ++ ++ // Convert into a float if we underflow. ++ if neg > 0 { ++ Number::F64(-(significand as f64)) ++ } else { ++ Number::I64(neg) ++ } ++ } ++ } ++ }) ++ } ++ ++ fn parse_decimal( ++ &mut self, ++ pos: bool, ++ mut significand: u64, ++ mut exponent: i32, ++ ) -> Result { ++ self.eat_char(); ++ ++ let mut at_least_one_digit = false; ++ while let c @ b'0'...b'9' = try!(self.peek_or_null()) { ++ self.eat_char(); ++ let digit = (c - b'0') as u64; ++ at_least_one_digit = true; ++ ++ if overflow!(significand * 10 + digit, u64::MAX) { ++ // The next multiply/add would overflow, so just ignore all ++ // further digits. ++ while let b'0'...b'9' = try!(self.peek_or_null()) { ++ self.eat_char(); ++ } ++ break; ++ } ++ ++ significand = significand * 10 + digit; ++ exponent -= 1; ++ } ++ ++ if !at_least_one_digit { ++ return Err(self.peek_error(ErrorCode::InvalidNumber)); ++ } ++ ++ match try!(self.peek_or_null()) { ++ b'e' | b'E' => self.parse_exponent(pos, significand, exponent), ++ _ => self.f64_from_parts(pos, significand, exponent), ++ } ++ } ++ ++ fn parse_exponent( ++ &mut self, ++ pos: bool, ++ significand: u64, ++ starting_exp: i32, ++ ) -> Result { ++ self.eat_char(); ++ ++ let pos_exp = match try!(self.peek_or_null()) { ++ b'+' => { ++ self.eat_char(); ++ true ++ } ++ b'-' => { ++ self.eat_char(); ++ false ++ } ++ _ => true, ++ }; ++ ++ // Make sure a digit follows the exponent place. ++ let mut exp = match try!(self.next_char_or_null()) { ++ c @ b'0'...b'9' => (c - b'0') as i32, ++ _ => { ++ return Err(self.error(ErrorCode::InvalidNumber)); ++ } ++ }; ++ ++ while let c @ b'0'...b'9' = try!(self.peek_or_null()) { ++ self.eat_char(); ++ let digit = (c - b'0') as i32; ++ ++ if overflow!(exp * 10 + digit, i32::MAX) { ++ return self.parse_exponent_overflow(pos, significand, pos_exp); ++ } ++ ++ exp = exp * 10 + digit; ++ } ++ ++ let final_exp = if pos_exp { ++ starting_exp.saturating_add(exp) ++ } else { ++ starting_exp.saturating_sub(exp) ++ }; ++ ++ self.f64_from_parts(pos, significand, final_exp) ++ } ++ ++ // This cold code should not be inlined into the middle of the hot ++ // exponent-parsing loop above. ++ #[cold] ++ #[inline(never)] ++ fn parse_exponent_overflow( ++ &mut self, ++ pos: bool, ++ significand: u64, ++ pos_exp: bool, ++ ) -> Result { ++ // Error instead of +/- infinity. ++ if significand != 0 && pos_exp { ++ return Err(self.error(ErrorCode::NumberOutOfRange)); ++ } ++ ++ while let b'0'...b'9' = try!(self.peek_or_null()) { ++ self.eat_char(); ++ } ++ Ok(if pos { 0.0 } else { -0.0 }) ++ } ++ ++ fn f64_from_parts( ++ &mut self, ++ pos: bool, ++ significand: u64, ++ mut exponent: i32, ++ ) -> Result { ++ let mut f = significand as f64; ++ loop { ++ match POW10.get(exponent.abs() as usize) { ++ Some(&pow) => { ++ if exponent >= 0 { ++ f *= pow; ++ if f.is_infinite() { ++ return Err(self.error(ErrorCode::NumberOutOfRange)); ++ } ++ } else { ++ f /= pow; ++ } ++ break; ++ } ++ None => { ++ if f == 0.0 { ++ break; ++ } ++ if exponent >= 0 { ++ return Err(self.error(ErrorCode::NumberOutOfRange)); ++ } ++ f /= 1e308; ++ exponent += 308; ++ } ++ } ++ } ++ Ok(if pos { f } else { -f }) ++ } ++ ++ fn parse_object_colon(&mut self) -> Result<()> { ++ match try!(self.parse_whitespace()) { ++ Some(b':') => { ++ self.eat_char(); ++ Ok(()) ++ } ++ Some(_) => Err(self.peek_error(ErrorCode::ExpectedColon)), ++ None => Err(self.peek_error(ErrorCode::EofWhileParsingObject)), ++ } ++ } ++ ++ fn end_seq(&mut self) -> Result<()> { ++ match try!(self.parse_whitespace()) { ++ Some(b']') => { ++ self.eat_char(); ++ Ok(()) ++ } ++ Some(_) => Err(self.peek_error(ErrorCode::TrailingCharacters)), ++ None => Err(self.peek_error(ErrorCode::EofWhileParsingList)), ++ } ++ } ++ ++ fn end_map(&mut self) -> Result<()> { ++ match try!(self.parse_whitespace()) { ++ Some(b'}') => { ++ self.eat_char(); ++ Ok(()) ++ } ++ Some(_) => Err(self.peek_error(ErrorCode::TrailingCharacters)), ++ None => Err(self.peek_error(ErrorCode::EofWhileParsingObject)), ++ } ++ } ++ ++ fn ignore_value(&mut self) -> Result<()> { ++ let peek = match try!(self.parse_whitespace()) { ++ Some(b) => b, ++ None => { ++ return Err(self.peek_error(ErrorCode::EofWhileParsingValue)); ++ } ++ }; ++ ++ match peek { ++ b'n' => { ++ self.eat_char(); ++ self.parse_ident(b"ull") ++ } ++ b't' => { ++ self.eat_char(); ++ self.parse_ident(b"rue") ++ } ++ b'f' => { ++ self.eat_char(); ++ self.parse_ident(b"alse") ++ } ++ b'-' => { ++ self.eat_char(); ++ self.ignore_integer() ++ } ++ b'0'...b'9' => { ++ self.ignore_integer() ++ } ++ b'"' => { ++ self.eat_char(); ++ self.read.ignore_str() ++ } ++ b'[' => { ++ self.remaining_depth -= 1; ++ if self.remaining_depth == 0 { ++ return Err(self.peek_error(ErrorCode::RecursionLimitExceeded)); ++ } ++ ++ self.eat_char(); ++ let res = self.ignore_seq(); ++ self.remaining_depth += 1; ++ res ++ } ++ b'{' => { ++ self.remaining_depth -= 1; ++ if self.remaining_depth == 0 { ++ return Err(self.peek_error(ErrorCode::RecursionLimitExceeded)); ++ } ++ ++ self.eat_char(); ++ let res = self.ignore_map(); ++ self.remaining_depth += 1; ++ res ++ } ++ _ => { ++ Err(self.peek_error(ErrorCode::ExpectedSomeValue)) ++ } ++ } ++ } ++ ++ fn ignore_integer(&mut self) -> Result<()> { ++ match try!(self.next_char_or_null()) { ++ b'0' => { ++ // There can be only one leading '0'. ++ if let b'0'...b'9' = try!(self.peek_or_null()) { ++ return Err(self.peek_error(ErrorCode::InvalidNumber)); ++ } ++ } ++ b'1'...b'9' => { ++ while let b'0'...b'9' = try!(self.peek_or_null()) { ++ self.eat_char(); ++ } ++ } ++ _ => { ++ return Err(self.error(ErrorCode::InvalidNumber)); ++ } ++ } ++ ++ match try!(self.peek_or_null()) { ++ b'.' => self.ignore_decimal(), ++ b'e' | b'E' => self.ignore_exponent(), ++ _ => Ok(()), ++ } ++ } ++ ++ fn ignore_decimal(&mut self) -> Result<()> { ++ self.eat_char(); ++ ++ let mut at_least_one_digit = false; ++ while let b'0'...b'9' = try!(self.peek_or_null()) { ++ self.eat_char(); ++ at_least_one_digit = true; ++ } ++ ++ if !at_least_one_digit { ++ return Err(self.peek_error(ErrorCode::InvalidNumber)); ++ } ++ ++ match try!(self.peek_or_null()) { ++ b'e' | b'E' => self.ignore_exponent(), ++ _ => Ok(()), ++ } ++ } ++ ++ fn ignore_exponent(&mut self) -> Result<()> { ++ self.eat_char(); ++ ++ match try!(self.peek_or_null()) { ++ b'+' | b'-' => self.eat_char(), ++ _ => {} ++ } ++ ++ // Make sure a digit follows the exponent place. ++ match try!(self.next_char_or_null()) { ++ b'0'...b'9' => {} ++ _ => { ++ return Err(self.error(ErrorCode::InvalidNumber)); ++ } ++ } ++ ++ while let b'0'...b'9' = try!(self.peek_or_null()) { ++ self.eat_char(); ++ } ++ ++ Ok(()) ++ } ++ ++ fn ignore_seq(&mut self) -> Result<()> { ++ let mut first = true; ++ ++ loop { ++ match try!(self.parse_whitespace()) { ++ Some(b']') => { ++ self.eat_char(); ++ return Ok(()); ++ } ++ Some(b',') if !first => { ++ self.eat_char(); ++ } ++ Some(_) => { ++ if first { ++ first = false; ++ } else { ++ return Err(self.peek_error(ErrorCode::ExpectedListCommaOrEnd)); ++ } ++ } ++ None => { ++ return Err(self.peek_error(ErrorCode::EofWhileParsingList)); ++ } ++ } ++ ++ try!(self.ignore_value()); ++ } ++ } ++ ++ fn ignore_map(&mut self) -> Result<()> { ++ let mut first = true; ++ ++ loop { ++ let peek = match try!(self.parse_whitespace()) { ++ Some(b'}') => { ++ self.eat_char(); ++ return Ok(()); ++ } ++ Some(b',') if !first => { ++ self.eat_char(); ++ try!(self.parse_whitespace()) ++ } ++ Some(b) => { ++ if first { ++ first = false; ++ Some(b) ++ } else { ++ return Err(self.peek_error(ErrorCode::ExpectedObjectCommaOrEnd)); ++ } ++ } ++ None => { ++ return Err(self.peek_error(ErrorCode::EofWhileParsingObject)); ++ } ++ }; ++ ++ match peek { ++ Some(b'"') => { ++ self.eat_char(); ++ try!(self.read.ignore_str()); ++ } ++ Some(_) => { ++ return Err(self.peek_error(ErrorCode::KeyMustBeAString)); ++ } ++ None => { ++ return Err(self.peek_error(ErrorCode::EofWhileParsingObject)); ++ } ++ } ++ ++ match try!(self.parse_whitespace()) { ++ Some(b':') => { ++ self.eat_char(); ++ try!(self.ignore_value()); ++ } ++ Some(_) => { ++ return Err(self.peek_error(ErrorCode::ExpectedColon)); ++ } ++ None => { ++ return Err(self.peek_error(ErrorCode::EofWhileParsingObject)); ++ } ++ } ++ } ++ } ++} ++ ++#[cfg_attr(rustfmt, rustfmt_skip)] ++static POW10: [f64; 309] = ++ [1e000, 1e001, 1e002, 1e003, 1e004, 1e005, 1e006, 1e007, 1e008, 1e009, ++ 1e010, 1e011, 1e012, 1e013, 1e014, 1e015, 1e016, 1e017, 1e018, 1e019, ++ 1e020, 1e021, 1e022, 1e023, 1e024, 1e025, 1e026, 1e027, 1e028, 1e029, ++ 1e030, 1e031, 1e032, 1e033, 1e034, 1e035, 1e036, 1e037, 1e038, 1e039, ++ 1e040, 1e041, 1e042, 1e043, 1e044, 1e045, 1e046, 1e047, 1e048, 1e049, ++ 1e050, 1e051, 1e052, 1e053, 1e054, 1e055, 1e056, 1e057, 1e058, 1e059, ++ 1e060, 1e061, 1e062, 1e063, 1e064, 1e065, 1e066, 1e067, 1e068, 1e069, ++ 1e070, 1e071, 1e072, 1e073, 1e074, 1e075, 1e076, 1e077, 1e078, 1e079, ++ 1e080, 1e081, 1e082, 1e083, 1e084, 1e085, 1e086, 1e087, 1e088, 1e089, ++ 1e090, 1e091, 1e092, 1e093, 1e094, 1e095, 1e096, 1e097, 1e098, 1e099, ++ 1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109, ++ 1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119, ++ 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129, ++ 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139, ++ 1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149, ++ 1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159, ++ 1e160, 1e161, 1e162, 1e163, 1e164, 1e165, 1e166, 1e167, 1e168, 1e169, ++ 1e170, 1e171, 1e172, 1e173, 1e174, 1e175, 1e176, 1e177, 1e178, 1e179, ++ 1e180, 1e181, 1e182, 1e183, 1e184, 1e185, 1e186, 1e187, 1e188, 1e189, ++ 1e190, 1e191, 1e192, 1e193, 1e194, 1e195, 1e196, 1e197, 1e198, 1e199, ++ 1e200, 1e201, 1e202, 1e203, 1e204, 1e205, 1e206, 1e207, 1e208, 1e209, ++ 1e210, 1e211, 1e212, 1e213, 1e214, 1e215, 1e216, 1e217, 1e218, 1e219, ++ 1e220, 1e221, 1e222, 1e223, 1e224, 1e225, 1e226, 1e227, 1e228, 1e229, ++ 1e230, 1e231, 1e232, 1e233, 1e234, 1e235, 1e236, 1e237, 1e238, 1e239, ++ 1e240, 1e241, 1e242, 1e243, 1e244, 1e245, 1e246, 1e247, 1e248, 1e249, ++ 1e250, 1e251, 1e252, 1e253, 1e254, 1e255, 1e256, 1e257, 1e258, 1e259, ++ 1e260, 1e261, 1e262, 1e263, 1e264, 1e265, 1e266, 1e267, 1e268, 1e269, ++ 1e270, 1e271, 1e272, 1e273, 1e274, 1e275, 1e276, 1e277, 1e278, 1e279, ++ 1e280, 1e281, 1e282, 1e283, 1e284, 1e285, 1e286, 1e287, 1e288, 1e289, ++ 1e290, 1e291, 1e292, 1e293, 1e294, 1e295, 1e296, 1e297, 1e298, 1e299, ++ 1e300, 1e301, 1e302, 1e303, 1e304, 1e305, 1e306, 1e307, 1e308]; ++ ++impl<'de, 'a, R: Read<'de>> de::Deserializer<'de> for &'a mut Deserializer { ++ type Error = Error; ++ ++ #[inline] ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ self.parse_value(visitor) ++ } ++ ++ /// Parses a `null` as a None, and any other values as a `Some(...)`. ++ #[inline] ++ fn deserialize_option(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ match try!(self.parse_whitespace()) { ++ Some(b'n') => { ++ self.eat_char(); ++ try!(self.parse_ident(b"ull")); ++ visitor.visit_none() ++ } ++ _ => visitor.visit_some(self), ++ } ++ } ++ ++ /// Parses a newtype struct as the underlying value. ++ #[inline] ++ fn deserialize_newtype_struct(self, _name: &str, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_newtype_struct(self) ++ } ++ ++ /// Parses an enum as an object like `{"$KEY":$VALUE}`, where $VALUE is either a straight ++ /// value, a `[..]`, or a `{..}`. ++ #[inline] ++ fn deserialize_enum( ++ self, ++ _name: &str, ++ _variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ match try!(self.parse_whitespace()) { ++ Some(b'{') => { ++ self.remaining_depth -= 1; ++ if self.remaining_depth == 0 { ++ return Err(self.peek_error(ErrorCode::RecursionLimitExceeded)); ++ } ++ ++ self.eat_char(); ++ let value = try!(visitor.visit_enum(VariantAccess::new(self))); ++ ++ self.remaining_depth += 1; ++ ++ match try!(self.parse_whitespace()) { ++ Some(b'}') => { ++ self.eat_char(); ++ Ok(value) ++ } ++ Some(_) => Err(self.error(ErrorCode::ExpectedSomeValue)), ++ None => Err(self.error(ErrorCode::EofWhileParsingObject)), ++ } ++ } ++ Some(b'"') => visitor.visit_enum(UnitVariantAccess::new(self)), ++ Some(_) => Err(self.peek_error(ErrorCode::ExpectedSomeValue)), ++ None => Err(self.peek_error(ErrorCode::EofWhileParsingValue)), ++ } ++ } ++ ++ /// Parses a JSON string as bytes. Note that this function does not check ++ /// whether the bytes represent a valid UTF-8 string. ++ /// ++ /// The relevant part of the JSON specification is Section 8.2 of [RFC ++ /// 7159]: ++ /// ++ /// > When all the strings represented in a JSON text are composed entirely ++ /// > of Unicode characters (however escaped), then that JSON text is ++ /// > interoperable in the sense that all software implementations that ++ /// > parse it will agree on the contents of names and of string values in ++ /// > objects and arrays. ++ /// > ++ /// > However, the ABNF in this specification allows member names and string ++ /// > values to contain bit sequences that cannot encode Unicode characters; ++ /// > for example, "\uDEAD" (a single unpaired UTF-16 surrogate). Instances ++ /// > of this have been observed, for example, when a library truncates a ++ /// > UTF-16 string without checking whether the truncation split a ++ /// > surrogate pair. The behavior of software that receives JSON texts ++ /// > containing such values is unpredictable; for example, implementations ++ /// > might return different values for the length of a string value or even ++ /// > suffer fatal runtime exceptions. ++ /// ++ /// [RFC 7159]: https://tools.ietf.org/html/rfc7159 ++ /// ++ /// The behavior of serde_json is specified to fail on non-UTF-8 strings ++ /// when deserializing into Rust UTF-8 string types such as String, and ++ /// succeed with non-UTF-8 bytes when deserializing using this method. ++ /// ++ /// Escape sequences are processed as usual, and for `\uXXXX` escapes it is ++ /// still checked if the hex number represents a valid Unicode code point. ++ /// ++ /// # Examples ++ /// ++ /// You can use this to parse JSON strings containing invalid UTF-8 bytes. ++ /// ++ /// ```rust ++ /// extern crate serde_json; ++ /// extern crate serde_bytes; ++ /// ++ /// use serde_bytes::ByteBuf; ++ /// ++ /// fn look_at_bytes() -> Result<(), serde_json::Error> { ++ /// let json_data = b"\"some bytes: \xe5\x00\xe5\""; ++ /// let bytes: ByteBuf = serde_json::from_slice(json_data)?; ++ /// ++ /// assert_eq!(b'\xe5', bytes[12]); ++ /// assert_eq!(b'\0', bytes[13]); ++ /// assert_eq!(b'\xe5', bytes[14]); ++ /// ++ /// Ok(()) ++ /// } ++ /// # ++ /// # fn main() { ++ /// # look_at_bytes().unwrap(); ++ /// # } ++ /// ``` ++ /// ++ /// Backslash escape sequences like `\n` are still interpreted and required ++ /// to be valid, and `\u` escape sequences are required to represent valid ++ /// Unicode code points. ++ /// ++ /// ```rust ++ /// extern crate serde_json; ++ /// extern crate serde_bytes; ++ /// ++ /// use serde_bytes::ByteBuf; ++ /// ++ /// fn look_at_bytes() { ++ /// let json_data = b"\"invalid unicode surrogate: \\uD801\""; ++ /// let parsed: Result = serde_json::from_slice(json_data); ++ /// ++ /// assert!(parsed.is_err()); ++ /// ++ /// let expected_msg = "unexpected end of hex escape at line 1 column 35"; ++ /// assert_eq!(expected_msg, parsed.unwrap_err().to_string()); ++ /// } ++ /// # ++ /// # fn main() { ++ /// # look_at_bytes(); ++ /// # } ++ /// ``` ++ fn deserialize_bytes(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ match try!(self.parse_whitespace()) { ++ Some(b'"') => { ++ self.eat_char(); ++ self.str_buf.clear(); ++ match try!(self.read.parse_str_raw(&mut self.str_buf)) { ++ Reference::Borrowed(b) => visitor.visit_borrowed_bytes(b), ++ Reference::Copied(b) => visitor.visit_bytes(b), ++ } ++ } ++ _ => self.deserialize_any(visitor), ++ } ++ ++ } ++ ++ #[inline] ++ fn deserialize_byte_buf(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ self.deserialize_bytes(visitor) ++ } ++ ++ fn deserialize_ignored_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ try!(self.ignore_value()); ++ visitor.visit_unit() ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string unit ++ unit_struct seq tuple tuple_struct map struct identifier ++ } ++} ++ ++struct SeqAccess<'a, R: 'a> { ++ de: &'a mut Deserializer, ++ first: bool, ++} ++ ++impl<'a, R: 'a> SeqAccess<'a, R> { ++ fn new(de: &'a mut Deserializer) -> Self { ++ SeqAccess { ++ de: de, ++ first: true, ++ } ++ } ++} ++ ++impl<'de, 'a, R: Read<'de> + 'a> de::SeqAccess<'de> for SeqAccess<'a, R> { ++ type Error = Error; ++ ++ fn next_element_seed(&mut self, seed: T) -> Result> ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ match try!(self.de.parse_whitespace()) { ++ Some(b']') => { ++ return Ok(None); ++ } ++ Some(b',') if !self.first => { ++ self.de.eat_char(); ++ } ++ Some(_) => { ++ if self.first { ++ self.first = false; ++ } else { ++ return Err(self.de.peek_error(ErrorCode::ExpectedListCommaOrEnd)); ++ } ++ } ++ None => { ++ return Err(self.de.peek_error(ErrorCode::EofWhileParsingList)); ++ } ++ } ++ ++ let value = try!(seed.deserialize(&mut *self.de)); ++ Ok(Some(value)) ++ } ++} ++ ++struct MapAccess<'a, R: 'a> { ++ de: &'a mut Deserializer, ++ first: bool, ++} ++ ++impl<'a, R: 'a> MapAccess<'a, R> { ++ fn new(de: &'a mut Deserializer) -> Self { ++ MapAccess { ++ de: de, ++ first: true, ++ } ++ } ++} ++ ++impl<'de, 'a, R: Read<'de> + 'a> de::MapAccess<'de> for MapAccess<'a, R> { ++ type Error = Error; ++ ++ fn next_key_seed(&mut self, seed: K) -> Result> ++ where ++ K: de::DeserializeSeed<'de>, ++ { ++ let peek = match try!(self.de.parse_whitespace()) { ++ Some(b'}') => { ++ return Ok(None); ++ } ++ Some(b',') if !self.first => { ++ self.de.eat_char(); ++ try!(self.de.parse_whitespace()) ++ } ++ Some(b) => { ++ if self.first { ++ self.first = false; ++ Some(b) ++ } else { ++ return Err(self.de.peek_error(ErrorCode::ExpectedObjectCommaOrEnd)); ++ } ++ } ++ None => { ++ return Err(self.de.peek_error(ErrorCode::EofWhileParsingObject)); ++ } ++ }; ++ ++ match peek { ++ Some(b'"') => seed.deserialize(MapKey { de: &mut *self.de }).map(Some), ++ Some(_) => Err(self.de.peek_error(ErrorCode::KeyMustBeAString)), ++ None => Err(self.de.peek_error(ErrorCode::EofWhileParsingValue)), ++ } ++ } ++ ++ fn next_value_seed(&mut self, seed: V) -> Result ++ where ++ V: de::DeserializeSeed<'de>, ++ { ++ try!(self.de.parse_object_colon()); ++ ++ seed.deserialize(&mut *self.de) ++ } ++} ++ ++struct VariantAccess<'a, R: 'a> { ++ de: &'a mut Deserializer, ++} ++ ++impl<'a, R: 'a> VariantAccess<'a, R> { ++ fn new(de: &'a mut Deserializer) -> Self { ++ VariantAccess { de: de } ++ } ++} ++ ++impl<'de, 'a, R: Read<'de> + 'a> de::EnumAccess<'de> for VariantAccess<'a, R> { ++ type Error = Error; ++ type Variant = Self; ++ ++ fn variant_seed(self, seed: V) -> Result<(V::Value, Self)> ++ where ++ V: de::DeserializeSeed<'de>, ++ { ++ let val = try!(seed.deserialize(&mut *self.de)); ++ try!(self.de.parse_object_colon()); ++ Ok((val, self)) ++ } ++} ++ ++impl<'de, 'a, R: Read<'de> + 'a> de::VariantAccess<'de> for VariantAccess<'a, R> { ++ type Error = Error; ++ ++ fn unit_variant(self) -> Result<()> { ++ de::Deserialize::deserialize(self.de) ++ } ++ ++ fn newtype_variant_seed(self, seed: T) -> Result ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ seed.deserialize(self.de) ++ } ++ ++ fn tuple_variant(self, _len: usize, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ de::Deserializer::deserialize_any(self.de, visitor) ++ } ++ ++ fn struct_variant(self, _fields: &'static [&'static str], visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ de::Deserializer::deserialize_any(self.de, visitor) ++ } ++} ++ ++struct UnitVariantAccess<'a, R: 'a> { ++ de: &'a mut Deserializer, ++} ++ ++impl<'a, R: 'a> UnitVariantAccess<'a, R> { ++ fn new(de: &'a mut Deserializer) -> Self { ++ UnitVariantAccess { de: de } ++ } ++} ++ ++impl<'de, 'a, R: Read<'de> + 'a> de::EnumAccess<'de> for UnitVariantAccess<'a, R> { ++ type Error = Error; ++ type Variant = Self; ++ ++ fn variant_seed(self, seed: V) -> Result<(V::Value, Self)> ++ where ++ V: de::DeserializeSeed<'de>, ++ { ++ let variant = try!(seed.deserialize(&mut *self.de)); ++ Ok((variant, self)) ++ } ++} ++ ++impl<'de, 'a, R: Read<'de> + 'a> de::VariantAccess<'de> for UnitVariantAccess<'a, R> { ++ type Error = Error; ++ ++ fn unit_variant(self) -> Result<()> { ++ Ok(()) ++ } ++ ++ fn newtype_variant_seed(self, _seed: T) -> Result ++ where ++ T: de::DeserializeSeed<'de>, ++ { ++ Err(de::Error::invalid_type(Unexpected::UnitVariant, &"newtype variant"),) ++ } ++ ++ fn tuple_variant(self, _len: usize, _visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ Err(de::Error::invalid_type(Unexpected::UnitVariant, &"tuple variant"),) ++ } ++ ++ fn struct_variant(self, _fields: &'static [&'static str], _visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ Err(de::Error::invalid_type(Unexpected::UnitVariant, &"struct variant"),) ++ } ++} ++ ++/// Only deserialize from this after peeking a '"' byte! Otherwise it may ++/// deserialize invalid JSON successfully. ++struct MapKey<'a, R: 'a> { ++ de: &'a mut Deserializer, ++} ++ ++macro_rules! deserialize_integer_key { ++ ($deserialize:ident => $visit:ident) => { ++ fn $deserialize(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ self.de.eat_char(); ++ self.de.str_buf.clear(); ++ let string = try!(self.de.read.parse_str(&mut self.de.str_buf)); ++ match (string.parse(), string) { ++ (Ok(integer), _) => visitor.$visit(integer), ++ (Err(_), Reference::Borrowed(s)) => visitor.visit_borrowed_str(s), ++ (Err(_), Reference::Copied(s)) => visitor.visit_str(s), ++ } ++ } ++ } ++} ++ ++impl<'de, 'a, R> de::Deserializer<'de> for MapKey<'a, R> ++where ++ R: Read<'de>, ++{ ++ type Error = Error; ++ ++ #[inline] ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ self.de.parse_value(visitor) ++ } ++ ++ deserialize_integer_key!(deserialize_i8 => visit_i8); ++ deserialize_integer_key!(deserialize_i16 => visit_i16); ++ deserialize_integer_key!(deserialize_i32 => visit_i32); ++ deserialize_integer_key!(deserialize_i64 => visit_i64); ++ deserialize_integer_key!(deserialize_u8 => visit_u8); ++ deserialize_integer_key!(deserialize_u16 => visit_u16); ++ deserialize_integer_key!(deserialize_u32 => visit_u32); ++ deserialize_integer_key!(deserialize_u64 => visit_u64); ++ ++ #[inline] ++ fn deserialize_option(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ // Map keys cannot be null. ++ visitor.visit_some(self) ++ } ++ ++ #[inline] ++ fn deserialize_newtype_struct(self, _name: &'static str, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_newtype_struct(self) ++ } ++ ++ #[inline] ++ fn deserialize_enum( ++ self, ++ name: &'static str, ++ variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ self.de.deserialize_enum(name, variants, visitor) ++ } ++ ++ #[inline] ++ fn deserialize_bytes(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ self.de.deserialize_bytes(visitor) ++ } ++ ++ #[inline] ++ fn deserialize_byte_buf(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ self.de.deserialize_bytes(visitor) ++ } ++ ++ forward_to_deserialize_any! { ++ bool f32 f64 char str string unit unit_struct seq tuple tuple_struct map ++ struct identifier ignored_any ++ } ++} ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++/// Iterator that deserializes a stream into multiple JSON values. ++/// ++/// A stream deserializer can be created from any JSON deserializer using the ++/// `Deserializer::into_iter` method. ++/// ++/// The data must consist of JSON arrays and JSON objects optionally separated ++/// by whitespace. A null, boolean, number, or string at the top level are all ++/// errors. ++/// ++/// ```rust ++/// extern crate serde_json; ++/// ++/// use serde_json::{Deserializer, Value}; ++/// ++/// fn main() { ++/// let data = "{\"k\": 3} {} [0, 1, 2]"; ++/// ++/// let stream = Deserializer::from_str(data).into_iter::(); ++/// ++/// for value in stream { ++/// println!("{}", value.unwrap()); ++/// } ++/// } ++/// ``` ++pub struct StreamDeserializer<'de, R, T> { ++ de: Deserializer, ++ offset: usize, ++ output: PhantomData, ++ lifetime: PhantomData<&'de ()>, ++} ++ ++impl<'de, R, T> StreamDeserializer<'de, R, T> ++where ++ R: read::Read<'de>, ++ T: de::Deserialize<'de>, ++{ ++ /// Create a JSON stream deserializer from one of the possible serde_json ++ /// input sources. ++ /// ++ /// Typically it is more convenient to use one of these methods instead: ++ /// ++ /// - Deserializer::from_str(...).into_iter() ++ /// - Deserializer::from_bytes(...).into_iter() ++ /// - Deserializer::from_reader(...).into_iter() ++ pub fn new(read: R) -> Self { ++ let offset = read.byte_offset(); ++ StreamDeserializer { ++ de: Deserializer::new(read), ++ offset: offset, ++ output: PhantomData, ++ lifetime: PhantomData, ++ } ++ } ++ ++ /// Returns the number of bytes so far deserialized into a successful `T`. ++ /// ++ /// If a stream deserializer returns an EOF error, new data can be joined to ++ /// `old_data[stream.byte_offset()..]` to try again. ++ /// ++ /// ```rust ++ /// let data = b"[0] [1] ["; ++ /// ++ /// let de = serde_json::Deserializer::from_slice(data); ++ /// let mut stream = de.into_iter::>(); ++ /// assert_eq!(0, stream.byte_offset()); ++ /// ++ /// println!("{:?}", stream.next()); // [0] ++ /// assert_eq!(3, stream.byte_offset()); ++ /// ++ /// println!("{:?}", stream.next()); // [1] ++ /// assert_eq!(7, stream.byte_offset()); ++ /// ++ /// println!("{:?}", stream.next()); // error ++ /// assert_eq!(8, stream.byte_offset()); ++ /// ++ /// // If err.is_eof(), can join the remaining data to new data and continue. ++ /// let remaining = &data[stream.byte_offset()..]; ++ /// ``` ++ /// ++ /// *Note:* In the future this method may be changed to return the number of ++ /// bytes so far deserialized into a successful T *or* syntactically valid ++ /// JSON skipped over due to a type error. See [serde-rs/json#70] for an ++ /// example illustrating this. ++ /// ++ /// [serde-rs/json#70]: https://github.com/serde-rs/json/issues/70 ++ pub fn byte_offset(&self) -> usize { ++ self.offset ++ } ++} ++ ++impl<'de, R, T> Iterator for StreamDeserializer<'de, R, T> ++where ++ R: Read<'de>, ++ T: de::Deserialize<'de>, ++{ ++ type Item = Result; ++ ++ fn next(&mut self) -> Option> { ++ // skip whitespaces, if any ++ // this helps with trailing whitespaces, since whitespaces between ++ // values are handled for us. ++ match self.de.parse_whitespace() { ++ Ok(None) => { ++ self.offset = self.de.read.byte_offset(); ++ None ++ } ++ Ok(Some(b'{')) | Ok(Some(b'[')) => { ++ self.offset = self.de.read.byte_offset(); ++ let result = de::Deserialize::deserialize(&mut self.de); ++ if result.is_ok() { ++ self.offset = self.de.read.byte_offset(); ++ } ++ Some(result) ++ } ++ Ok(Some(_)) => Some(Err(self.de.peek_error(ErrorCode::ExpectedObjectOrArray))), ++ Err(e) => Some(Err(e)), ++ } ++ } ++} ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++fn from_trait<'de, R, T>(read: R) -> Result ++where ++ R: Read<'de>, ++ T: de::Deserialize<'de>, ++{ ++ let mut de = Deserializer::new(read); ++ let value = try!(de::Deserialize::deserialize(&mut de)); ++ ++ // Make sure the whole stream has been consumed. ++ try!(de.end()); ++ Ok(value) ++} ++ ++/// Deserialize an instance of type `T` from an IO stream of JSON. ++/// ++/// # Errors ++/// ++/// This conversion can fail if the structure of the input does not match the ++/// structure expected by `T`, for example if `T` is a struct type but the input ++/// contains something other than a JSON map. It can also fail if the structure ++/// is correct but `T`'s implementation of `Deserialize` decides that something ++/// is wrong with the data, for example required struct fields are missing from ++/// the JSON map or some number is too big to fit in the expected primitive ++/// type. ++/// ++/// ```rust ++/// #[macro_use] ++/// extern crate serde_derive; ++/// ++/// extern crate serde; ++/// extern crate serde_json; ++/// ++/// use std::error::Error; ++/// use std::fs::File; ++/// use std::path::Path; ++/// ++/// #[derive(Deserialize, Debug)] ++/// struct User { ++/// fingerprint: String, ++/// location: String, ++/// } ++/// ++/// fn read_user_from_file>(path: P) -> Result> { ++/// // Open the file in read-only mode. ++/// let file = File::open(path)?; ++/// ++/// // Read the JSON contents of the file as an instance of `User`. ++/// let u = serde_json::from_reader(file)?; ++/// ++/// // Return the `User`. ++/// Ok(u) ++/// } ++/// ++/// fn main() { ++/// # } ++/// # fn fake_main() { ++/// let u = read_user_from_file("test.json").unwrap(); ++/// println!("{:#?}", u); ++/// } ++/// ``` ++pub fn from_reader(rdr: R) -> Result ++where ++ R: io::Read, ++ T: de::DeserializeOwned, ++{ ++ from_trait(read::IoRead::new(rdr)) ++} ++ ++/// Deserialize an instance of type `T` from bytes of JSON text. ++/// ++/// # Errors ++/// ++/// This conversion can fail if the structure of the input does not match the ++/// structure expected by `T`, for example if `T` is a struct type but the input ++/// contains something other than a JSON map. It can also fail if the structure ++/// is correct but `T`'s implementation of `Deserialize` decides that something ++/// is wrong with the data, for example required struct fields are missing from ++/// the JSON map or some number is too big to fit in the expected primitive ++/// type. ++/// ++/// ```rust ++/// #[macro_use] ++/// extern crate serde_derive; ++/// ++/// extern crate serde; ++/// extern crate serde_json; ++/// ++/// #[derive(Deserialize, Debug)] ++/// struct User { ++/// fingerprint: String, ++/// location: String, ++/// } ++/// ++/// fn main() { ++/// // The type of `j` is `&[u8]` ++/// let j = b"{ ++/// \"fingerprint\": \"0xF9BA143B95FF6D82\", ++/// \"location\": \"Menlo Park, CA\" ++/// }"; ++/// ++/// let u: User = serde_json::from_slice(j).unwrap(); ++/// println!("{:#?}", u); ++/// } ++/// ``` ++pub fn from_slice<'a, T>(v: &'a [u8]) -> Result ++where ++ T: de::Deserialize<'a>, ++{ ++ from_trait(read::SliceRead::new(v)) ++} ++ ++/// Deserialize an instance of type `T` from a string of JSON text. ++/// ++/// # Errors ++/// ++/// This conversion can fail if the structure of the input does not match the ++/// structure expected by `T`, for example if `T` is a struct type but the input ++/// contains something other than a JSON map. It can also fail if the structure ++/// is correct but `T`'s implementation of `Deserialize` decides that something ++/// is wrong with the data, for example required struct fields are missing from ++/// the JSON map or some number is too big to fit in the expected primitive ++/// type. ++/// ++/// ```rust ++/// #[macro_use] ++/// extern crate serde_derive; ++/// ++/// extern crate serde; ++/// extern crate serde_json; ++/// ++/// #[derive(Deserialize, Debug)] ++/// struct User { ++/// fingerprint: String, ++/// location: String, ++/// } ++/// ++/// fn main() { ++/// // The type of `j` is `&str` ++/// let j = "{ ++/// \"fingerprint\": \"0xF9BA143B95FF6D82\", ++/// \"location\": \"Menlo Park, CA\" ++/// }"; ++/// ++/// let u: User = serde_json::from_str(j).unwrap(); ++/// println!("{:#?}", u); ++/// } ++/// ``` ++pub fn from_str<'a, T>(s: &'a str) -> Result ++where ++ T: de::Deserialize<'a>, ++{ ++ from_trait(read::StrRead::new(s)) ++} diff --cc vendor/serde_json-1.0.3/src/error.rs index 000000000,000000000..bb82ad69c new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/error.rs @@@ -1,0 -1,0 +1,414 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! When serializing or deserializing JSON goes wrong. ++ ++use std::error; ++use std::fmt::{self, Debug, Display}; ++use std::io; ++use std::result; ++ ++use serde::de; ++use serde::ser; ++ ++/// This type represents all possible errors that can occur when serializing or ++/// deserializing JSON data. ++pub struct Error { ++ /// This `Box` allows us to keep the size of `Error` as small as possible. A ++ /// larger `Error` type was substantially slower due to all the functions ++ /// that pass around `Result`. ++ err: Box, ++} ++ ++/// Alias for a `Result` with the error type `serde_json::Error`. ++pub type Result = result::Result; ++ ++impl Error { ++ /// One-based line number at which the error was detected. ++ /// ++ /// Characters in the first line of the input (before the first newline ++ /// character) are in line 1. ++ pub fn line(&self) -> usize { ++ self.err.line ++ } ++ ++ /// One-based column number at which the error was detected. ++ /// ++ /// The first character in the input and any characters immediately ++ /// following a newline character are in column 1. ++ /// ++ /// Note that errors may occur in column 0, for example if a read from an IO ++ /// stream fails immediately following a previously read newline character. ++ pub fn column(&self) -> usize { ++ self.err.column ++ } ++ ++ /// Categorizes the cause of this error. ++ /// ++ /// - `Category::Io` - failure to read or write bytes on an IO stream ++ /// - `Category::Syntax` - input that is not syntactically valid JSON ++ /// - `Category::Data` - input data that is semantically incorrect ++ /// - `Category::Eof` - unexpected end of the input data ++ pub fn classify(&self) -> Category { ++ match self.err.code { ++ ErrorCode::Message(_) => Category::Data, ++ ErrorCode::Io(_) => Category::Io, ++ ErrorCode::EofWhileParsingList | ++ ErrorCode::EofWhileParsingObject | ++ ErrorCode::EofWhileParsingString | ++ ErrorCode::EofWhileParsingValue => Category::Eof, ++ ErrorCode::ExpectedColon | ++ ErrorCode::ExpectedListCommaOrEnd | ++ ErrorCode::ExpectedObjectCommaOrEnd | ++ ErrorCode::ExpectedObjectOrArray | ++ ErrorCode::ExpectedSomeIdent | ++ ErrorCode::ExpectedSomeValue | ++ ErrorCode::ExpectedSomeString | ++ ErrorCode::InvalidEscape | ++ ErrorCode::InvalidNumber | ++ ErrorCode::NumberOutOfRange | ++ ErrorCode::InvalidUnicodeCodePoint | ++ ErrorCode::KeyMustBeAString | ++ ErrorCode::LoneLeadingSurrogateInHexEscape | ++ ErrorCode::TrailingCharacters | ++ ErrorCode::UnexpectedEndOfHexEscape | ++ ErrorCode::RecursionLimitExceeded => Category::Syntax, ++ } ++ } ++ ++ /// Returns true if this error was caused by a failure to read or write ++ /// bytes on an IO stream. ++ pub fn is_io(&self) -> bool { ++ self.classify() == Category::Io ++ } ++ ++ /// Returns true if this error was caused by input that was not ++ /// syntactically valid JSON. ++ pub fn is_syntax(&self) -> bool { ++ self.classify() == Category::Syntax ++ } ++ ++ /// Returns true if this error was caused by input data that was ++ /// semantically incorrect. ++ /// ++ /// For example, JSON containing a number is semantically incorrect when the ++ /// type being deserialized into holds a String. ++ pub fn is_data(&self) -> bool { ++ self.classify() == Category::Data ++ } ++ ++ /// Returns true if this error was caused by prematurely reaching the end of ++ /// the input data. ++ /// ++ /// Callers that process streaming input may be interested in retrying the ++ /// deserialization once more data is available. ++ pub fn is_eof(&self) -> bool { ++ self.classify() == Category::Eof ++ } ++} ++ ++/// Categorizes the cause of a `serde_json::Error`. ++#[derive(Copy, Clone, PartialEq, Eq, Debug)] ++pub enum Category { ++ /// The error was caused by a failure to read or write bytes on an IO ++ /// stream. ++ Io, ++ ++ /// The error was caused by input that was not syntactically valid JSON. ++ Syntax, ++ ++ /// The error was caused by input data that was semantically incorrect. ++ /// ++ /// For example, JSON containing a number is semantically incorrect when the ++ /// type being deserialized into holds a String. ++ Data, ++ ++ /// The error was caused by prematurely reaching the end of the input data. ++ /// ++ /// Callers that process streaming input may be interested in retrying the ++ /// deserialization once more data is available. ++ Eof, ++} ++ ++impl From for io::Error { ++ /// Convert a `serde_json::Error` into an `io::Error`. ++ /// ++ /// JSON syntax and data errors are turned into `InvalidData` IO errors. ++ /// EOF errors are turned into `UnexpectedEof` IO errors. ++ /// ++ /// ```rust ++ /// use std::io; ++ /// ++ /// enum MyError { ++ /// Io(io::Error), ++ /// Json(serde_json::Error), ++ /// } ++ /// ++ /// impl From for MyError { ++ /// fn from(err: serde_json::Error) -> MyError { ++ /// use serde_json::error::Category; ++ /// match err.classify() { ++ /// Category::Io => { ++ /// MyError::Io(err.into()) ++ /// } ++ /// Category::Syntax | Category::Data | Category::Eof => { ++ /// MyError::Json(err) ++ /// } ++ /// } ++ /// } ++ /// } ++ /// ``` ++ fn from(j: Error) -> Self { ++ if let ErrorCode::Io(err) = j.err.code { ++ err ++ } else { ++ match j.classify() { ++ Category::Io => unreachable!(), ++ Category::Syntax | Category::Data => io::Error::new(io::ErrorKind::InvalidData, j), ++ Category::Eof => io::Error::new(io::ErrorKind::UnexpectedEof, j), ++ } ++ } ++ } ++} ++ ++#[derive(Debug)] ++struct ErrorImpl { ++ code: ErrorCode, ++ line: usize, ++ column: usize, ++} ++ ++// Not public API. Should be pub(crate). ++#[doc(hidden)] ++#[derive(Debug)] ++pub enum ErrorCode { ++ /// Catchall for syntax error messages ++ Message(String), ++ ++ /// Some IO error occurred while serializing or deserializing. ++ Io(io::Error), ++ ++ /// EOF while parsing a list. ++ EofWhileParsingList, ++ ++ /// EOF while parsing an object. ++ EofWhileParsingObject, ++ ++ /// EOF while parsing a string. ++ EofWhileParsingString, ++ ++ /// EOF while parsing a JSON value. ++ EofWhileParsingValue, ++ ++ /// Expected this character to be a `':'`. ++ ExpectedColon, ++ ++ /// Expected this character to be either a `','` or a `']'`. ++ ExpectedListCommaOrEnd, ++ ++ /// Expected this character to be either a `','` or a `'}'`. ++ ExpectedObjectCommaOrEnd, ++ ++ /// Expected this character to be either a `'{'` or a `'['`. ++ ExpectedObjectOrArray, ++ ++ /// Expected to parse either a `true`, `false`, or a `null`. ++ ExpectedSomeIdent, ++ ++ /// Expected this character to start a JSON value. ++ ExpectedSomeValue, ++ ++ /// Expected this character to start a JSON string. ++ ExpectedSomeString, ++ ++ /// Invalid hex escape code. ++ InvalidEscape, ++ ++ /// Invalid number. ++ InvalidNumber, ++ ++ /// Number is bigger than the maximum value of its type. ++ NumberOutOfRange, ++ ++ /// Invalid unicode code point. ++ InvalidUnicodeCodePoint, ++ ++ /// Object key is not a string. ++ KeyMustBeAString, ++ ++ /// Lone leading surrogate in hex escape. ++ LoneLeadingSurrogateInHexEscape, ++ ++ /// JSON has non-whitespace trailing characters after the value. ++ TrailingCharacters, ++ ++ /// Unexpected end of hex excape. ++ UnexpectedEndOfHexEscape, ++ ++ /// Encountered nesting of JSON maps and arrays more than 128 layers deep. ++ RecursionLimitExceeded, ++} ++ ++impl Error { ++ // Not public API. Should be pub(crate). ++ #[doc(hidden)] ++ pub fn syntax(code: ErrorCode, line: usize, column: usize) -> Self { ++ Error { ++ err: Box::new( ++ ErrorImpl { ++ code: code, ++ line: line, ++ column: column, ++ }, ++ ), ++ } ++ } ++ ++ // Not public API. Should be pub(crate). ++ #[doc(hidden)] ++ pub fn io(error: io::Error) -> Self { ++ Error { ++ err: Box::new( ++ ErrorImpl { ++ code: ErrorCode::Io(error), ++ line: 0, ++ column: 0, ++ }, ++ ), ++ } ++ } ++ ++ // Not public API. Should be pub(crate). ++ #[doc(hidden)] ++ pub fn fix_position(self, f: F) -> Self ++ where ++ F: FnOnce(ErrorCode) -> Error, ++ { ++ if self.err.line == 0 { ++ f(self.err.code) ++ } else { ++ self ++ } ++ } ++} ++ ++impl Display for ErrorCode { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ match *self { ++ ErrorCode::Message(ref msg) => f.write_str(msg), ++ ErrorCode::Io(ref err) => Display::fmt(err, f), ++ ErrorCode::EofWhileParsingList => f.write_str("EOF while parsing a list"), ++ ErrorCode::EofWhileParsingObject => f.write_str("EOF while parsing an object"), ++ ErrorCode::EofWhileParsingString => f.write_str("EOF while parsing a string"), ++ ErrorCode::EofWhileParsingValue => f.write_str("EOF while parsing a value"), ++ ErrorCode::ExpectedColon => f.write_str("expected `:`"), ++ ErrorCode::ExpectedListCommaOrEnd => f.write_str("expected `,` or `]`"), ++ ErrorCode::ExpectedObjectCommaOrEnd => f.write_str("expected `,` or `}`"), ++ ErrorCode::ExpectedObjectOrArray => f.write_str("expected `{` or `[`"), ++ ErrorCode::ExpectedSomeIdent => f.write_str("expected ident"), ++ ErrorCode::ExpectedSomeValue => f.write_str("expected value"), ++ ErrorCode::ExpectedSomeString => f.write_str("expected string"), ++ ErrorCode::InvalidEscape => f.write_str("invalid escape"), ++ ErrorCode::InvalidNumber => f.write_str("invalid number"), ++ ErrorCode::NumberOutOfRange => f.write_str("number out of range"), ++ ErrorCode::InvalidUnicodeCodePoint => f.write_str("invalid unicode code point"), ++ ErrorCode::KeyMustBeAString => f.write_str("key must be a string"), ++ ErrorCode::LoneLeadingSurrogateInHexEscape => { ++ f.write_str("lone leading surrogate in hex escape") ++ } ++ ErrorCode::TrailingCharacters => f.write_str("trailing characters"), ++ ErrorCode::UnexpectedEndOfHexEscape => f.write_str("unexpected end of hex escape"), ++ ErrorCode::RecursionLimitExceeded => f.write_str("recursion limit exceeded"), ++ } ++ } ++} ++ ++impl error::Error for Error { ++ fn description(&self) -> &str { ++ match self.err.code { ++ ErrorCode::Io(ref err) => error::Error::description(err), ++ _ => { ++ // If you want a better message, use Display::fmt or to_string(). ++ "JSON error" ++ } ++ } ++ } ++ ++ fn cause(&self) -> Option<&error::Error> { ++ match self.err.code { ++ ErrorCode::Io(ref err) => Some(err), ++ _ => None, ++ } ++ } ++} ++ ++impl Display for Error { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ Display::fmt(&*self.err, f) ++ } ++} ++ ++impl Display for ErrorImpl { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ if self.line == 0 { ++ Display::fmt(&self.code, f) ++ } else { ++ write!( ++ f, ++ "{} at line {} column {}", ++ self.code, ++ self.line, ++ self.column ++ ) ++ } ++ } ++} ++ ++// Remove two layers of verbosity from the debug representation. Humans often ++// end up seeing this representation because it is what unwrap() shows. ++impl Debug for Error { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ Debug::fmt(&*self.err, f) ++ } ++} ++ ++impl de::Error for Error { ++ fn custom(msg: T) -> Error { ++ Error { ++ err: Box::new( ++ ErrorImpl { ++ code: ErrorCode::Message(msg.to_string()), ++ line: 0, ++ column: 0, ++ }, ++ ), ++ } ++ } ++ ++ fn invalid_type(unexp: de::Unexpected, exp: &de::Expected) -> Self { ++ if let de::Unexpected::Unit = unexp { ++ Error::custom(format_args!("invalid type: null, expected {}", exp)) ++ } else { ++ Error::custom(format_args!("invalid type: {}, expected {}", unexp, exp)) ++ } ++ } ++} ++ ++impl ser::Error for Error { ++ fn custom(msg: T) -> Error { ++ Error { ++ err: Box::new( ++ ErrorImpl { ++ code: ErrorCode::Message(msg.to_string()), ++ line: 0, ++ column: 0, ++ }, ++ ), ++ } ++ } ++} diff --cc vendor/serde_json-1.0.3/src/iter.rs index 000000000,000000000..344e8a420 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/iter.rs @@@ -1,0 -1,0 +1,78 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::io; ++ ++pub struct LineColIterator { ++ iter: I, ++ ++ /// Index of the current line. Characters in the first line of the input ++ /// (before the first newline character) are in line 1. ++ line: usize, ++ ++ /// Index of the current column. The first character in the input and any ++ /// characters immediately following a newline character are in column 1. ++ /// The column is 0 immediately after a newline character has been read. ++ col: usize, ++ ++ /// Byte offset of the start of the current line. This is the sum of lenghts ++ /// of all previous lines. Keeping track of things this way allows efficient ++ /// computation of the current line, column, and byte offset while only ++ /// updating one of the counters in `next()` in the common case. ++ start_of_line: usize, ++} ++ ++impl LineColIterator ++where ++ I: Iterator>, ++{ ++ pub fn new(iter: I) -> LineColIterator { ++ LineColIterator { ++ iter: iter, ++ line: 1, ++ col: 0, ++ start_of_line: 0, ++ } ++ } ++ ++ pub fn line(&self) -> usize { ++ self.line ++ } ++ ++ pub fn col(&self) -> usize { ++ self.col ++ } ++ ++ pub fn byte_offset(&self) -> usize { ++ self.start_of_line + self.col ++ } ++} ++ ++impl Iterator for LineColIterator ++where ++ I: Iterator>, ++{ ++ type Item = io::Result; ++ ++ fn next(&mut self) -> Option> { ++ match self.iter.next() { ++ None => None, ++ Some(Ok(b'\n')) => { ++ self.start_of_line += self.col + 1; ++ self.line += 1; ++ self.col = 0; ++ Some(Ok(b'\n')) ++ } ++ Some(Ok(c)) => { ++ self.col += 1; ++ Some(Ok(c)) ++ } ++ Some(Err(e)) => Some(Err(e)), ++ } ++ } ++} diff --cc vendor/serde_json-1.0.3/src/lib.rs index 000000000,000000000..6ce880be4 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/lib.rs @@@ -1,0 -1,0 +1,352 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! # Serde JSON ++//! ++//! JSON is a ubiquitous open-standard format that uses human-readable text to ++//! transmit data objects consisting of key-value pairs. ++//! ++//! ```json,ignore ++//! { ++//! "name": "John Doe", ++//! "age": 43, ++//! "address": { ++//! "street": "10 Downing Street", ++//! "city": "London" ++//! }, ++//! "phones": [ ++//! "+44 1234567", ++//! "+44 2345678" ++//! ] ++//! } ++//! ``` ++//! ++//! There are three common ways that you might find yourself needing to work ++//! with JSON data in Rust. ++//! ++//! - **As text data.** An unprocessed string of JSON data that you receive on ++//! an HTTP endpoint, read from a file, or prepare to send to a remote ++//! server. ++//! - **As an untyped or loosely typed representation.** Maybe you want to ++//! check that some JSON data is valid before passing it on, but without ++//! knowing the structure of what it contains. Or you want to do very basic ++//! manipulations like insert a key in a particular spot. ++//! - **As a strongly typed Rust data structure.** When you expect all or most ++//! of your data to conform to a particular structure and want to get real ++//! work done without JSON's loosey-goosey nature tripping you up. ++//! ++//! Serde JSON provides efficient, flexible, safe ways of converting data ++//! between each of these representations. ++//! ++//! # Operating on untyped JSON values ++//! ++//! Any valid JSON data can be manipulated in the following recursive enum ++//! representation. This data structure is [`serde_json::Value`][value]. ++//! ++//! ```rust ++//! # use serde_json::{Number, Map}; ++//! # ++//! # #[allow(dead_code)] ++//! enum Value { ++//! Null, ++//! Bool(bool), ++//! Number(Number), ++//! String(String), ++//! Array(Vec), ++//! Object(Map), ++//! } ++//! ``` ++//! ++//! A string of JSON data can be parsed into a `serde_json::Value` by the ++//! [`serde_json::from_str`][from_str] function. There is also ++//! [`from_slice`][from_slice] for parsing from a byte slice &[u8] and ++//! [`from_reader`][from_reader] for parsing from any `io::Read` like a File or ++//! a TCP stream. ++//! ++//! ```rust ++//! extern crate serde_json; ++//! ++//! use serde_json::{Value, Error}; ++//! ++//! fn untyped_example() -> Result<(), Error> { ++//! // Some JSON input data as a &str. Maybe this comes from the user. ++//! let data = r#"{ ++//! "name": "John Doe", ++//! "age": 43, ++//! "phones": [ ++//! "+44 1234567", ++//! "+44 2345678" ++//! ] ++//! }"#; ++//! ++//! // Parse the string of data into serde_json::Value. ++//! let v: Value = serde_json::from_str(data)?; ++//! ++//! // Access parts of the data by indexing with square brackets. ++//! println!("Please call {} at the number {}", v["name"], v["phones"][0]); ++//! ++//! Ok(()) ++//! } ++//! # ++//! # fn main() { ++//! # untyped_example().unwrap(); ++//! # } ++//! ``` ++//! ++//! The `Value` representation is sufficient for very basic tasks but can be ++//! tedious to work with for anything more significant. Error handling is ++//! verbose to implement correctly, for example imagine trying to detect the ++//! presence of unrecognized fields in the input data. The compiler is powerless ++//! to help you when you make a mistake, for example imagine typoing `v["name"]` ++//! as `v["nmae"]` in one of the dozens of places it is used in your code. ++//! ++//! # Parsing JSON as strongly typed data structures ++//! ++//! Serde provides a powerful way of mapping JSON data into Rust data structures ++//! largely automatically. ++//! ++//! ```rust ++//! extern crate serde; ++//! extern crate serde_json; ++//! ++//! #[macro_use] ++//! extern crate serde_derive; ++//! ++//! use serde_json::Error; ++//! ++//! #[derive(Serialize, Deserialize)] ++//! struct Person { ++//! name: String, ++//! age: u8, ++//! phones: Vec, ++//! } ++//! ++//! fn typed_example() -> Result<(), Error> { ++//! // Some JSON input data as a &str. Maybe this comes from the user. ++//! let data = r#"{ ++//! "name": "John Doe", ++//! "age": 43, ++//! "phones": [ ++//! "+44 1234567", ++//! "+44 2345678" ++//! ] ++//! }"#; ++//! ++//! // Parse the string of data into a Person object. This is exactly the ++//! // same function as the one that produced serde_json::Value above, but ++//! // now we are asking it for a Person as output. ++//! let p: Person = serde_json::from_str(data)?; ++//! ++//! // Do things just like with any other Rust data structure. ++//! println!("Please call {} at the number {}", p.name, p.phones[0]); ++//! ++//! Ok(()) ++//! } ++//! # ++//! # fn main() { ++//! # typed_example().unwrap(); ++//! # } ++//! ``` ++//! ++//! This is the same `serde_json::from_str` function as before, but this time we ++//! assign the return value to a variable of type `Person` so Serde will ++//! automatically interpret the input data as a `Person` and produce informative ++//! error messages if the layout does not conform to what a `Person` is expected ++//! to look like. ++//! ++//! Any type that implements Serde's `Deserialize` trait can be deserialized ++//! this way. This includes built-in Rust standard library types like `Vec` ++//! and `HashMap`, as well as any structs or enums annotated with ++//! `#[derive(Deserialize)]`. ++//! ++//! Once we have `p` of type `Person`, our IDE and the Rust compiler can help us ++//! use it correctly like they do for any other Rust code. The IDE can ++//! autocomplete field names to prevent typos, which was impossible in the ++//! `serde_json::Value` representation. And the Rust compiler can check that ++//! when we write `p.phones[0]`, then `p.phones` is guaranteed to be a ++//! `Vec` so indexing into it makes sense and produces a `String`. ++//! ++//! # Constructing JSON values ++//! ++//! Serde JSON provides a [`json!` macro][macro] to build `serde_json::Value` ++//! objects with very natural JSON syntax. In order to use this macro, ++//! `serde_json` needs to be imported with the `#[macro_use]` attribute. ++//! ++//! ```rust ++//! #[macro_use] ++//! extern crate serde_json; ++//! ++//! fn main() { ++//! // The type of `john` is `serde_json::Value` ++//! let john = json!({ ++//! "name": "John Doe", ++//! "age": 43, ++//! "phones": [ ++//! "+44 1234567", ++//! "+44 2345678" ++//! ] ++//! }); ++//! ++//! println!("first phone number: {}", john["phones"][0]); ++//! ++//! // Convert to a string of JSON and print it out ++//! println!("{}", john.to_string()); ++//! } ++//! ``` ++//! ++//! The `Value::to_string()` function converts a `serde_json::Value` into a ++//! `String` of JSON text. ++//! ++//! One neat thing about the `json!` macro is that variables and expressions can ++//! be interpolated directly into the JSON value as you are building it. Serde ++//! will check at compile time that the value you are interpolating is able to ++//! be represented as JSON. ++//! ++//! ```rust ++//! # #[macro_use] ++//! # extern crate serde_json; ++//! # ++//! # fn random_phone() -> u16 { 0 } ++//! # ++//! # fn main() { ++//! let full_name = "John Doe"; ++//! let age_last_year = 42; ++//! ++//! // The type of `john` is `serde_json::Value` ++//! let john = json!({ ++//! "name": full_name, ++//! "age": age_last_year + 1, ++//! "phones": [ ++//! format!("+44 {}", random_phone()) ++//! ] ++//! }); ++//! # let _ = john; ++//! # } ++//! ``` ++//! ++//! This is amazingly convenient but we have the problem we had before with ++//! `Value` which is that the IDE and Rust compiler cannot help us if we get it ++//! wrong. Serde JSON provides a better way of serializing strongly-typed data ++//! structures into JSON text. ++//! ++//! # Creating JSON by serializing data structures ++//! ++//! A data structure can be converted to a JSON string by ++//! [`serde_json::to_string`][to_string]. There is also ++//! [`serde_json::to_vec`][to_vec] which serializes to a `Vec` and ++//! [`serde_json::to_writer`][to_writer] which serializes to any `io::Write` ++//! such as a File or a TCP stream. ++//! ++//! ```rust ++//! extern crate serde; ++//! extern crate serde_json; ++//! ++//! #[macro_use] ++//! extern crate serde_derive; ++//! ++//! use serde_json::Error; ++//! ++//! #[derive(Serialize, Deserialize)] ++//! struct Address { ++//! street: String, ++//! city: String, ++//! } ++//! ++//! fn print_an_address() -> Result<(), Error> { ++//! // Some data structure. ++//! let address = Address { ++//! street: "10 Downing Street".to_owned(), ++//! city: "London".to_owned(), ++//! }; ++//! ++//! // Serialize it to a JSON string. ++//! let j = serde_json::to_string(&address)?; ++//! ++//! // Print, write to a file, or send to an HTTP server. ++//! println!("{}", j); ++//! ++//! Ok(()) ++//! } ++//! # ++//! # fn main() { ++//! # print_an_address().unwrap(); ++//! # } ++//! ``` ++//! ++//! Any type that implements Serde's `Serialize` trait can be serialized this ++//! way. This includes built-in Rust standard library types like `Vec` and ++//! `HashMap`, as well as any structs or enums annotated with ++//! `#[derive(Serialize)]`. ++//! ++//! [value]: https://docs.serde.rs/serde_json/value/enum.Value.html ++//! [from_str]: https://docs.serde.rs/serde_json/de/fn.from_str.html ++//! [from_slice]: https://docs.serde.rs/serde_json/de/fn.from_slice.html ++//! [from_reader]: https://docs.serde.rs/serde_json/de/fn.from_reader.html ++//! [to_string]: https://docs.serde.rs/serde_json/ser/fn.to_string.html ++//! [to_vec]: https://docs.serde.rs/serde_json/ser/fn.to_vec.html ++//! [to_writer]: https://docs.serde.rs/serde_json/ser/fn.to_writer.html ++//! [macro]: https://docs.serde.rs/serde_json/macro.json.html ++ ++#![doc(html_root_url = "https://docs.rs/serde_json/1.0.3")] ++#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))] ++// Because of "JavaScript"... fixed in Manishearth/rust-clippy#1071 ++#![cfg_attr(feature = "cargo-clippy", allow(doc_markdown))] ++// Whitelisted clippy_pedantic lints ++#![cfg_attr(feature = "cargo-clippy", allow( ++// Deserializer::from_str, into_iter ++ should_implement_trait, ++// integer and float ser/de requires these sorts of casts ++ cast_possible_truncation, ++ cast_possible_wrap, ++ cast_precision_loss, ++ cast_sign_loss, ++// string ser/de uses indexing and slicing ++ indexing_slicing, ++// things are often more readable this way ++ cast_lossless, ++ shadow_reuse, ++ shadow_unrelated, ++ single_match_else, ++ stutter, ++ use_self, ++// not practical ++ missing_docs_in_private_items, ++))] ++ ++#![deny(missing_docs)] ++ ++extern crate num_traits; ++#[macro_use] ++extern crate serde; ++extern crate itoa; ++extern crate dtoa; ++#[cfg(feature = "preserve_order")] ++extern crate linked_hash_map; ++ ++#[doc(inline)] ++pub use self::de::{Deserializer, StreamDeserializer, from_reader, from_slice, from_str}; ++#[doc(inline)] ++pub use self::error::{Error, Result}; ++#[doc(inline)] ++pub use self::ser::{Serializer, to_string, to_string_pretty, to_vec, to_vec_pretty, to_writer, ++ to_writer_pretty}; ++#[doc(inline)] ++pub use self::value::{Map, Number, Value, from_value, to_value}; ++ ++#[macro_use] ++mod macros; ++ ++pub mod de; ++pub mod error; ++pub mod map; ++pub mod ser; ++pub mod value; ++ ++mod iter; ++mod number; ++mod read; diff --cc vendor/serde_json-1.0.3/src/macros.rs index 000000000,000000000..bb595f908 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/macros.rs @@@ -1,0 -1,0 +1,282 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++/// Construct a `serde_json::Value` from a JSON literal. ++/// ++/// ```rust ++/// # #[macro_use] ++/// # extern crate serde_json; ++/// # ++/// # fn main() { ++/// let value = json!({ ++/// "code": 200, ++/// "success": true, ++/// "payload": { ++/// "features": [ ++/// "serde", ++/// "json" ++/// ] ++/// } ++/// }); ++/// # } ++/// ``` ++/// ++/// Variables or expressions can be interpolated into the JSON literal. Any type ++/// interpolated into an array element or object value must implement Serde's ++/// `Serialize` trait, while any type interpolated into a object key must ++/// implement `Into`. If the `Serialize` implementation of the ++/// interpolated type decides to fail, or if the interpolated type contains a ++/// map with non-string keys, the `json!` macro will panic. ++/// ++/// ```rust ++/// # #[macro_use] ++/// # extern crate serde_json; ++/// # ++/// # fn main() { ++/// let code = 200; ++/// let features = vec!["serde", "json"]; ++/// ++/// let value = json!({ ++/// "code": code, ++/// "success": code == 200, ++/// "payload": { ++/// features[0]: features[1] ++/// } ++/// }); ++/// # } ++/// ``` ++/// ++/// Trailing commas are allowed inside both arrays and objects. ++/// ++/// ```rust ++/// # #[macro_use] ++/// # extern crate serde_json; ++/// # ++/// # fn main() { ++/// let value = json!([ ++/// "notice", ++/// "the", ++/// "trailing", ++/// "comma -->", ++/// ]); ++/// # } ++/// ``` ++#[macro_export] ++macro_rules! json { ++ // Hide distracting implementation details from the generated rustdoc. ++ ($($json:tt)+) => { ++ json_internal!($($json)+) ++ }; ++} ++ ++// Rocket relies on this because they export their own `json!` with a different ++// doc comment than ours, and various Rust bugs prevent them from calling our ++// `json!` from their `json!` so they call `json_internal!` directly. Check with ++// @SergioBenitez before making breaking changes to this macro. ++// ++// Changes are fine as long as `json_internal!` does not call any new helper ++// macros and can still be invoked as `json_internal!($($json)+)`. ++#[macro_export] ++#[doc(hidden)] ++macro_rules! json_internal { ++ ////////////////////////////////////////////////////////////////////////// ++ // TT muncher for parsing the inside of an array [...]. Produces a vec![...] ++ // of the elements. ++ // ++ // Must be invoked as: json_internal!(@array [] $($tt)*) ++ ////////////////////////////////////////////////////////////////////////// ++ ++ // Done with trailing comma. ++ (@array [$($elems:expr,)*]) => { ++ vec![$($elems,)*] ++ }; ++ ++ // Done without trailing comma. ++ (@array [$($elems:expr),*]) => { ++ vec![$($elems),*] ++ }; ++ ++ // Next element is `null`. ++ (@array [$($elems:expr,)*] null $($rest:tt)*) => { ++ json_internal!(@array [$($elems,)* json_internal!(null)] $($rest)*) ++ }; ++ ++ // Next element is `true`. ++ (@array [$($elems:expr,)*] true $($rest:tt)*) => { ++ json_internal!(@array [$($elems,)* json_internal!(true)] $($rest)*) ++ }; ++ ++ // Next element is `false`. ++ (@array [$($elems:expr,)*] false $($rest:tt)*) => { ++ json_internal!(@array [$($elems,)* json_internal!(false)] $($rest)*) ++ }; ++ ++ // Next element is an array. ++ (@array [$($elems:expr,)*] [$($array:tt)*] $($rest:tt)*) => { ++ json_internal!(@array [$($elems,)* json_internal!([$($array)*])] $($rest)*) ++ }; ++ ++ // Next element is a map. ++ (@array [$($elems:expr,)*] {$($map:tt)*} $($rest:tt)*) => { ++ json_internal!(@array [$($elems,)* json_internal!({$($map)*})] $($rest)*) ++ }; ++ ++ // Next element is an expression followed by comma. ++ (@array [$($elems:expr,)*] $next:expr, $($rest:tt)*) => { ++ json_internal!(@array [$($elems,)* json_internal!($next),] $($rest)*) ++ }; ++ ++ // Last element is an expression with no trailing comma. ++ (@array [$($elems:expr,)*] $last:expr) => { ++ json_internal!(@array [$($elems,)* json_internal!($last)]) ++ }; ++ ++ // Comma after the most recent element. ++ (@array [$($elems:expr),*] , $($rest:tt)*) => { ++ json_internal!(@array [$($elems,)*] $($rest)*) ++ }; ++ ++ ////////////////////////////////////////////////////////////////////////// ++ // TT muncher for parsing the inside of an object {...}. Each entry is ++ // inserted into the given map variable. ++ // ++ // Must be invoked as: json_internal!(@object $map () ($($tt)*) ($($tt)*)) ++ // ++ // We require two copies of the input tokens so that we can match on one ++ // copy and trigger errors on the other copy. ++ ////////////////////////////////////////////////////////////////////////// ++ ++ // Done. ++ (@object $object:ident () () ()) => {}; ++ ++ // Insert the current entry followed by trailing comma. ++ (@object $object:ident [$($key:tt)+] ($value:expr) , $($rest:tt)*) => { ++ $object.insert(($($key)+).into(), $value); ++ json_internal!(@object $object () ($($rest)*) ($($rest)*)); ++ }; ++ ++ // Insert the last entry without trailing comma. ++ (@object $object:ident [$($key:tt)+] ($value:expr)) => { ++ $object.insert(($($key)+).into(), $value); ++ }; ++ ++ // Next value is `null`. ++ (@object $object:ident ($($key:tt)+) (: null $($rest:tt)*) $copy:tt) => { ++ json_internal!(@object $object [$($key)+] (json_internal!(null)) $($rest)*); ++ }; ++ ++ // Next value is `true`. ++ (@object $object:ident ($($key:tt)+) (: true $($rest:tt)*) $copy:tt) => { ++ json_internal!(@object $object [$($key)+] (json_internal!(true)) $($rest)*); ++ }; ++ ++ // Next value is `false`. ++ (@object $object:ident ($($key:tt)+) (: false $($rest:tt)*) $copy:tt) => { ++ json_internal!(@object $object [$($key)+] (json_internal!(false)) $($rest)*); ++ }; ++ ++ // Next value is an array. ++ (@object $object:ident ($($key:tt)+) (: [$($array:tt)*] $($rest:tt)*) $copy:tt) => { ++ json_internal!(@object $object [$($key)+] (json_internal!([$($array)*])) $($rest)*); ++ }; ++ ++ // Next value is a map. ++ (@object $object:ident ($($key:tt)+) (: {$($map:tt)*} $($rest:tt)*) $copy:tt) => { ++ json_internal!(@object $object [$($key)+] (json_internal!({$($map)*})) $($rest)*); ++ }; ++ ++ // Next value is an expression followed by comma. ++ (@object $object:ident ($($key:tt)+) (: $value:expr , $($rest:tt)*) $copy:tt) => { ++ json_internal!(@object $object [$($key)+] (json_internal!($value)) , $($rest)*); ++ }; ++ ++ // Last value is an expression with no trailing comma. ++ (@object $object:ident ($($key:tt)+) (: $value:expr) $copy:tt) => { ++ json_internal!(@object $object [$($key)+] (json_internal!($value))); ++ }; ++ ++ // Missing value for last entry. Trigger a reasonable error message. ++ (@object $object:ident ($($key:tt)+) (:) $copy:tt) => { ++ // "unexpected end of macro invocation" ++ json_internal!(); ++ }; ++ ++ // Missing colon and value for last entry. Trigger a reasonable error ++ // message. ++ (@object $object:ident ($($key:tt)+) () $copy:tt) => { ++ // "unexpected end of macro invocation" ++ json_internal!(); ++ }; ++ ++ // Misplaced colon. Trigger a reasonable error message. ++ (@object $object:ident () (: $($rest:tt)*) ($colon:tt $($copy:tt)*)) => { ++ // Takes no arguments so "no rules expected the token `:`". ++ unimplemented!($colon); ++ }; ++ ++ // Found a comma inside a key. Trigger a reasonable error message. ++ (@object $object:ident ($($key:tt)*) (, $($rest:tt)*) ($comma:tt $($copy:tt)*)) => { ++ // Takes no arguments so "no rules expected the token `,`". ++ unimplemented!($comma); ++ }; ++ ++ // Key is fully parenthesized. This avoids clippy double_parens false ++ // positives because the parenthesization may be necessary here. ++ (@object $object:ident () (($key:expr) : $($rest:tt)*) $copy:tt) => { ++ json_internal!(@object $object ($key) (: $($rest)*) (: $($rest)*)); ++ }; ++ ++ // Munch a token into the current key. ++ (@object $object:ident ($($key:tt)*) ($tt:tt $($rest:tt)*) $copy:tt) => { ++ json_internal!(@object $object ($($key)* $tt) ($($rest)*) ($($rest)*)); ++ }; ++ ++ ////////////////////////////////////////////////////////////////////////// ++ // The main implementation. ++ // ++ // Must be invoked as: json_internal!($($json)+) ++ ////////////////////////////////////////////////////////////////////////// ++ ++ (null) => { ++ $crate::Value::Null ++ }; ++ ++ (true) => { ++ $crate::Value::Bool(true) ++ }; ++ ++ (false) => { ++ $crate::Value::Bool(false) ++ }; ++ ++ ([]) => { ++ $crate::Value::Array(vec![]) ++ }; ++ ++ ([ $($tt:tt)+ ]) => { ++ $crate::Value::Array(json_internal!(@array [] $($tt)+)) ++ }; ++ ++ ({}) => { ++ $crate::Value::Object($crate::Map::new()) ++ }; ++ ++ ({ $($tt:tt)+ }) => { ++ $crate::Value::Object({ ++ let mut object = $crate::Map::new(); ++ json_internal!(@object object () ($($tt)+) ($($tt)+)); ++ object ++ }) ++ }; ++ ++ // Any Serialize type: numbers, strings, struct literals, variables etc. ++ // Must be below every other rule. ++ ($other:expr) => { ++ $crate::to_value(&$other).unwrap() ++ }; ++} diff --cc vendor/serde_json-1.0.3/src/map.rs index 000000000,000000000..180d37008 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/map.rs @@@ -1,0 -1,0 +1,796 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! A map of String to serde_json::Value. ++//! ++//! By default the map is backed by a [`BTreeMap`]. Enable the `preserve_order` ++//! feature of serde_json to use [`LinkedHashMap`] instead. ++//! ++//! [`BTreeMap`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html ++//! [`LinkedHashMap`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html ++ ++use serde::{ser, de}; ++use std::fmt::{self, Debug}; ++use value::Value; ++use std::hash::Hash; ++use std::iter::FromIterator; ++use std::borrow::Borrow; ++use std::ops; ++ ++#[cfg(not(feature = "preserve_order"))] ++use std::collections::{BTreeMap, btree_map}; ++ ++#[cfg(feature = "preserve_order")] ++use linked_hash_map::{self, LinkedHashMap}; ++ ++/// Represents a JSON key/value type. ++pub struct Map { ++ map: MapImpl, ++} ++ ++#[cfg(not(feature = "preserve_order"))] ++type MapImpl = BTreeMap; ++#[cfg(feature = "preserve_order")] ++type MapImpl = LinkedHashMap; ++ ++impl Map { ++ /// Makes a new empty Map. ++ #[inline] ++ pub fn new() -> Self { ++ Map { map: MapImpl::new() } ++ } ++ ++ #[cfg(not(feature = "preserve_order"))] ++ /// Makes a new empty Map with the given initial capacity. ++ #[inline] ++ pub fn with_capacity(capacity: usize) -> Self { ++ // does not support with_capacity ++ let _ = capacity; ++ Map { map: BTreeMap::new() } ++ } ++ ++ #[cfg(feature = "preserve_order")] ++ /// Makes a new empty Map with the given initial capacity. ++ #[inline] ++ pub fn with_capacity(capacity: usize) -> Self { ++ Map { map: LinkedHashMap::with_capacity(capacity) } ++ } ++ ++ /// Clears the map, removing all values. ++ #[inline] ++ pub fn clear(&mut self) { ++ self.map.clear() ++ } ++ ++ /// Returns a reference to the value corresponding to the key. ++ /// ++ /// The key may be any borrowed form of the map's key type, but the ordering ++ /// on the borrowed form *must* match the ordering on the key type. ++ #[inline] ++ pub fn get(&self, key: &Q) -> Option<&Value> ++ where ++ String: Borrow, ++ Q: Ord + Eq + Hash, ++ { ++ self.map.get(key) ++ } ++ ++ /// Returns true if the map contains a value for the specified key. ++ /// ++ /// The key may be any borrowed form of the map's key type, but the ordering ++ /// on the borrowed form *must* match the ordering on the key type. ++ #[inline] ++ pub fn contains_key(&self, key: &Q) -> bool ++ where ++ String: Borrow, ++ Q: Ord + Eq + Hash, ++ { ++ self.map.contains_key(key) ++ } ++ ++ /// Returns a mutable reference to the value corresponding to the key. ++ /// ++ /// The key may be any borrowed form of the map's key type, but the ordering ++ /// on the borrowed form *must* match the ordering on the key type. ++ #[inline] ++ pub fn get_mut(&mut self, key: &Q) -> Option<&mut Value> ++ where ++ String: Borrow, ++ Q: Ord + Eq + Hash, ++ { ++ self.map.get_mut(key) ++ } ++ ++ /// Inserts a key-value pair into the map. ++ /// ++ /// If the map did not have this key present, `None` is returned. ++ /// ++ /// If the map did have this key present, the value is updated, and the old ++ /// value is returned. The key is not updated, though; this matters for ++ /// types that can be `==` without being identical. ++ #[inline] ++ pub fn insert(&mut self, k: String, v: Value) -> Option { ++ self.map.insert(k, v) ++ } ++ ++ /// Removes a key from the map, returning the value at the key if the key ++ /// was previously in the map. ++ /// ++ /// The key may be any borrowed form of the map's key type, but the ordering ++ /// on the borrowed form *must* match the ordering on the key type. ++ #[inline] ++ pub fn remove(&mut self, key: &Q) -> Option ++ where ++ String: Borrow, ++ Q: Ord + Eq + Hash, ++ { ++ self.map.remove(key) ++ } ++ ++ /// Gets the given key's corresponding entry in the map for in-place ++ /// manipulation. ++ pub fn entry(&mut self, key: S) -> Entry ++ where ++ S: Into, ++ { ++ #[cfg(not(feature = "preserve_order"))] ++ use std::collections::btree_map::Entry as EntryImpl; ++ #[cfg(feature = "preserve_order")] ++ use linked_hash_map::Entry as EntryImpl; ++ ++ match self.map.entry(key.into()) { ++ EntryImpl::Vacant(vacant) => Entry::Vacant(VacantEntry { vacant: vacant }), ++ EntryImpl::Occupied(occupied) => Entry::Occupied(OccupiedEntry { occupied: occupied }), ++ } ++ } ++ ++ /// Returns the number of elements in the map. ++ #[inline] ++ pub fn len(&self) -> usize { ++ self.map.len() ++ } ++ ++ /// Returns true if the map contains no elements. ++ #[inline] ++ pub fn is_empty(&self) -> bool { ++ self.map.is_empty() ++ } ++ ++ /// Gets an iterator over the entries of the map. ++ #[inline] ++ pub fn iter(&self) -> Iter { ++ Iter { iter: self.map.iter() } ++ } ++ ++ /// Gets a mutable iterator over the entries of the map. ++ #[inline] ++ pub fn iter_mut(&mut self) -> IterMut { ++ IterMut { iter: self.map.iter_mut() } ++ } ++ ++ /// Gets an iterator over the keys of the map. ++ #[inline] ++ pub fn keys(&self) -> Keys { ++ Keys { iter: self.map.keys() } ++ } ++ ++ /// Gets an iterator over the values of the map. ++ #[inline] ++ pub fn values(&self) -> Values { ++ Values { iter: self.map.values() } ++ } ++} ++ ++impl Default for Map { ++ #[inline] ++ fn default() -> Self { ++ Map { map: MapImpl::new() } ++ } ++} ++ ++impl Clone for Map { ++ #[inline] ++ fn clone(&self) -> Self { ++ Map { map: self.map.clone() } ++ } ++} ++ ++impl PartialEq for Map { ++ #[inline] ++ fn eq(&self, other: &Self) -> bool { ++ self.map.eq(&other.map) ++ } ++} ++ ++/// Access an element of this map. Panics if the given key is not present in the ++/// map. ++/// ++/// ```rust ++/// # use serde_json::Value; ++/// # ++/// # let val = &Value::String("".to_owned()); ++/// # let _ = ++/// match *val { ++/// Value::String(ref s) => Some(s.as_str()), ++/// Value::Array(ref arr) => arr[0].as_str(), ++/// Value::Object(ref map) => map["type"].as_str(), ++/// _ => None, ++/// } ++/// # ; ++/// ``` ++impl<'a, Q: ?Sized> ops::Index<&'a Q> for Map ++where ++ String: Borrow, ++ Q: Ord + Eq + Hash, ++{ ++ type Output = Value; ++ ++ fn index(&self, index: &Q) -> &Value { ++ self.map.index(index) ++ } ++} ++ ++/// Mutably access an element of this map. Panics if the given key is not ++/// present in the map. ++/// ++/// ```rust ++/// # #[macro_use] ++/// # extern crate serde_json; ++/// # ++/// # fn main() { ++/// # let mut map = serde_json::Map::new(); ++/// # map.insert("key".to_owned(), serde_json::Value::Null); ++/// # ++/// map["key"] = json!("value"); ++/// # } ++/// ``` ++impl<'a, Q: ?Sized> ops::IndexMut<&'a Q> for Map ++where ++ String: Borrow, ++ Q: Ord + Eq + Hash, ++{ ++ fn index_mut(&mut self, index: &Q) -> &mut Value { ++ self.map.get_mut(index).expect("no entry found for key") ++ } ++} ++ ++impl Debug for Map { ++ #[inline] ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { ++ self.map.fmt(formatter) ++ } ++} ++ ++impl ser::Serialize for Map { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: ser::Serializer, ++ { ++ use serde::ser::SerializeMap; ++ let mut map = try!(serializer.serialize_map(Some(self.len()))); ++ for (k, v) in self { ++ try!(map.serialize_key(k)); ++ try!(map.serialize_value(v)); ++ } ++ map.end() ++ } ++} ++ ++impl<'de> de::Deserialize<'de> for Map { ++ #[inline] ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: de::Deserializer<'de>, ++ { ++ struct Visitor; ++ ++ impl<'de> de::Visitor<'de> for Visitor { ++ type Value = Map; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a map") ++ } ++ ++ #[inline] ++ fn visit_unit(self) -> Result ++ where ++ E: de::Error, ++ { ++ Ok(Map::new()) ++ } ++ ++ #[inline] ++ fn visit_map(self, mut visitor: V) -> Result ++ where ++ V: de::MapAccess<'de>, ++ { ++ let mut values = Map::new(); ++ ++ while let Some((key, value)) = try!(visitor.next_entry()) { ++ values.insert(key, value); ++ } ++ ++ Ok(values) ++ } ++ } ++ ++ deserializer.deserialize_map(Visitor) ++ } ++} ++ ++impl FromIterator<(String, Value)> for Map { ++ fn from_iter(iter: T) -> Self ++ where ++ T: IntoIterator, ++ { ++ Map { map: FromIterator::from_iter(iter) } ++ } ++} ++ ++impl Extend<(String, Value)> for Map { ++ fn extend(&mut self, iter: T) ++ where ++ T: IntoIterator, ++ { ++ self.map.extend(iter); ++ } ++} ++ ++macro_rules! delegate_iterator { ++ (($name:ident $($generics:tt)*) => $item:ty) => { ++ impl $($generics)* Iterator for $name $($generics)* { ++ type Item = $item; ++ #[inline] ++ fn next(&mut self) -> Option { ++ self.iter.next() ++ } ++ #[inline] ++ fn size_hint(&self) -> (usize, Option) { ++ self.iter.size_hint() ++ } ++ } ++ ++ impl $($generics)* DoubleEndedIterator for $name $($generics)* { ++ #[inline] ++ fn next_back(&mut self) -> Option { ++ self.iter.next_back() ++ } ++ } ++ ++ impl $($generics)* ExactSizeIterator for $name $($generics)* { ++ #[inline] ++ fn len(&self) -> usize { ++ self.iter.len() ++ } ++ } ++ } ++} ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++/// A view into a single entry in a map, which may either be vacant or occupied. ++/// This enum is constructed from the [`entry`] method on [`Map`]. ++/// ++/// [`entry`]: struct.Map.html#method.entry ++/// [`Map`]: struct.Map.html ++pub enum Entry<'a> { ++ /// A vacant Entry. ++ Vacant(VacantEntry<'a>), ++ /// An occupied Entry. ++ Occupied(OccupiedEntry<'a>), ++} ++ ++/// A vacant Entry. It is part of the [`Entry`] enum. ++/// ++/// [`Entry`]: enum.Entry.html ++pub struct VacantEntry<'a> { ++ vacant: VacantEntryImpl<'a>, ++} ++ ++/// An occupied Entry. It is part of the [`Entry`] enum. ++/// ++/// [`Entry`]: enum.Entry.html ++pub struct OccupiedEntry<'a> { ++ occupied: OccupiedEntryImpl<'a>, ++} ++ ++#[cfg(not(feature = "preserve_order"))] ++type VacantEntryImpl<'a> = btree_map::VacantEntry<'a, String, Value>; ++#[cfg(feature = "preserve_order")] ++type VacantEntryImpl<'a> = linked_hash_map::VacantEntry<'a, String, Value>; ++ ++#[cfg(not(feature = "preserve_order"))] ++type OccupiedEntryImpl<'a> = btree_map::OccupiedEntry<'a, String, Value>; ++#[cfg(feature = "preserve_order")] ++type OccupiedEntryImpl<'a> = linked_hash_map::OccupiedEntry<'a, String, Value>; ++ ++impl<'a> Entry<'a> { ++ /// Returns a reference to this entry's key. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// let mut map = serde_json::Map::new(); ++ /// assert_eq!(map.entry("serde").key(), &"serde"); ++ /// ``` ++ pub fn key(&self) -> &String { ++ match *self { ++ Entry::Vacant(ref e) => e.key(), ++ Entry::Occupied(ref e) => e.key(), ++ } ++ } ++ ++ /// Ensures a value is in the entry by inserting the default if empty, and ++ /// returns a mutable reference to the value in the entry. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let mut map = serde_json::Map::new(); ++ /// map.entry("serde").or_insert(json!(12)); ++ /// ++ /// assert_eq!(map["serde"], 12); ++ /// # } ++ /// ``` ++ pub fn or_insert(self, default: Value) -> &'a mut Value { ++ match self { ++ Entry::Vacant(entry) => entry.insert(default.into()), ++ Entry::Occupied(entry) => entry.into_mut(), ++ } ++ } ++ ++ /// Ensures a value is in the entry by inserting the result of the default ++ /// function if empty, and returns a mutable reference to the value in the ++ /// entry. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let mut map = serde_json::Map::new(); ++ /// map.entry("serde").or_insert_with(|| json!("hoho")); ++ /// ++ /// assert_eq!(map["serde"], "hoho".to_owned()); ++ /// # } ++ /// ``` ++ pub fn or_insert_with(self, default: F) -> &'a mut Value ++ where ++ F: FnOnce() -> Value, ++ { ++ match self { ++ Entry::Vacant(entry) => entry.insert(default()), ++ Entry::Occupied(entry) => entry.into_mut(), ++ } ++ } ++} ++ ++impl<'a> VacantEntry<'a> { ++ /// Gets a reference to the key that would be used when inserting a value ++ /// through the VacantEntry. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// use serde_json::map::Entry; ++ /// ++ /// let mut map = serde_json::Map::new(); ++ /// ++ /// match map.entry("serde") { ++ /// Entry::Vacant(vacant) => { ++ /// assert_eq!(vacant.key(), &"serde"); ++ /// } ++ /// Entry::Occupied(_) => unimplemented!(), ++ /// } ++ /// ``` ++ #[inline] ++ pub fn key(&self) -> &String { ++ self.vacant.key() ++ } ++ ++ /// Sets the value of the entry with the VacantEntry's key, and returns a ++ /// mutable reference to it. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::map::Entry; ++ /// ++ /// let mut map = serde_json::Map::new(); ++ /// ++ /// match map.entry("serde") { ++ /// Entry::Vacant(vacant) => { ++ /// vacant.insert(json!("hoho")); ++ /// } ++ /// Entry::Occupied(_) => unimplemented!(), ++ /// } ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn insert(self, value: Value) -> &'a mut Value { ++ self.vacant.insert(value.into()) ++ } ++} ++ ++impl<'a> OccupiedEntry<'a> { ++ /// Gets a reference to the key in the entry. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::map::Entry; ++ /// ++ /// let mut map = serde_json::Map::new(); ++ /// map.insert("serde".to_owned(), json!(12)); ++ /// ++ /// match map.entry("serde") { ++ /// Entry::Occupied(occupied) => { ++ /// assert_eq!(occupied.key(), &"serde"); ++ /// } ++ /// Entry::Vacant(_) => unimplemented!(), ++ /// } ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn key(&self) -> &String { ++ self.occupied.key() ++ } ++ ++ /// Gets a reference to the value in the entry. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::map::Entry; ++ /// ++ /// let mut map = serde_json::Map::new(); ++ /// map.insert("serde".to_owned(), json!(12)); ++ /// ++ /// match map.entry("serde") { ++ /// Entry::Occupied(occupied) => { ++ /// assert_eq!(occupied.get(), 12); ++ /// } ++ /// Entry::Vacant(_) => unimplemented!(), ++ /// } ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn get(&self) -> &Value { ++ self.occupied.get() ++ } ++ ++ /// Gets a mutable reference to the value in the entry. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::map::Entry; ++ /// ++ /// let mut map = serde_json::Map::new(); ++ /// map.insert("serde".to_owned(), json!([1, 2, 3])); ++ /// ++ /// match map.entry("serde") { ++ /// Entry::Occupied(mut occupied) => { ++ /// occupied.get_mut().as_array_mut().unwrap().push(json!(4)); ++ /// } ++ /// Entry::Vacant(_) => unimplemented!(), ++ /// } ++ /// ++ /// assert_eq!(map["serde"].as_array().unwrap().len(), 4); ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn get_mut(&mut self) -> &mut Value { ++ self.occupied.get_mut() ++ } ++ ++ /// Converts the entry into a mutable reference to its value. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::map::Entry; ++ /// ++ /// let mut map = serde_json::Map::new(); ++ /// map.insert("serde".to_owned(), json!([1, 2, 3])); ++ /// ++ /// match map.entry("serde") { ++ /// Entry::Occupied(mut occupied) => { ++ /// occupied.into_mut().as_array_mut().unwrap().push(json!(4)); ++ /// } ++ /// Entry::Vacant(_) => unimplemented!(), ++ /// } ++ /// ++ /// assert_eq!(map["serde"].as_array().unwrap().len(), 4); ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn into_mut(self) -> &'a mut Value { ++ self.occupied.into_mut() ++ } ++ ++ /// Sets the value of the entry with the `OccupiedEntry`'s key, and returns ++ /// the entry's old value. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::map::Entry; ++ /// ++ /// let mut map = serde_json::Map::new(); ++ /// map.insert("serde".to_owned(), json!(12)); ++ /// ++ /// match map.entry("serde") { ++ /// Entry::Occupied(mut occupied) => { ++ /// assert_eq!(occupied.insert(json!(13)), 12); ++ /// assert_eq!(occupied.get(), 13); ++ /// } ++ /// Entry::Vacant(_) => unimplemented!(), ++ /// } ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn insert(&mut self, value: Value) -> Value { ++ self.occupied.insert(value.into()) ++ } ++ ++ /// Takes the value of the entry out of the map, and returns it. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::map::Entry; ++ /// ++ /// let mut map = serde_json::Map::new(); ++ /// map.insert("serde".to_owned(), json!(12)); ++ /// ++ /// match map.entry("serde") { ++ /// Entry::Occupied(occupied) => { ++ /// assert_eq!(occupied.remove(), 12); ++ /// } ++ /// Entry::Vacant(_) => unimplemented!(), ++ /// } ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn remove(self) -> Value { ++ self.occupied.remove() ++ } ++} ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++impl<'a> IntoIterator for &'a Map { ++ type Item = (&'a String, &'a Value); ++ type IntoIter = Iter<'a>; ++ #[inline] ++ fn into_iter(self) -> Self::IntoIter { ++ Iter { iter: self.map.iter() } ++ } ++} ++ ++/// An iterator over a serde_json::Map's entries. ++pub struct Iter<'a> { ++ iter: IterImpl<'a>, ++} ++ ++#[cfg(not(feature = "preserve_order"))] ++type IterImpl<'a> = btree_map::Iter<'a, String, Value>; ++#[cfg(feature = "preserve_order")] ++type IterImpl<'a> = linked_hash_map::Iter<'a, String, Value>; ++ ++delegate_iterator!((Iter<'a>) => (&'a String, &'a Value)); ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++impl<'a> IntoIterator for &'a mut Map { ++ type Item = (&'a String, &'a mut Value); ++ type IntoIter = IterMut<'a>; ++ #[inline] ++ fn into_iter(self) -> Self::IntoIter { ++ IterMut { iter: self.map.iter_mut() } ++ } ++} ++ ++/// A mutable iterator over a serde_json::Map's entries. ++pub struct IterMut<'a> { ++ iter: IterMutImpl<'a>, ++} ++ ++#[cfg(not(feature = "preserve_order"))] ++type IterMutImpl<'a> = btree_map::IterMut<'a, String, Value>; ++#[cfg(feature = "preserve_order")] ++type IterMutImpl<'a> = linked_hash_map::IterMut<'a, String, Value>; ++ ++delegate_iterator!((IterMut<'a>) => (&'a String, &'a mut Value)); ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++impl IntoIterator for Map { ++ type Item = (String, Value); ++ type IntoIter = IntoIter; ++ #[inline] ++ fn into_iter(self) -> Self::IntoIter { ++ IntoIter { iter: self.map.into_iter() } ++ } ++} ++ ++/// An owning iterator over a serde_json::Map's entries. ++pub struct IntoIter { ++ iter: IntoIterImpl, ++} ++ ++#[cfg(not(feature = "preserve_order"))] ++type IntoIterImpl = btree_map::IntoIter; ++#[cfg(feature = "preserve_order")] ++type IntoIterImpl = linked_hash_map::IntoIter; ++ ++delegate_iterator!((IntoIter) => (String, Value)); ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++/// An iterator over a serde_json::Map's keys. ++pub struct Keys<'a> { ++ iter: KeysImpl<'a>, ++} ++ ++#[cfg(not(feature = "preserve_order"))] ++type KeysImpl<'a> = btree_map::Keys<'a, String, Value>; ++#[cfg(feature = "preserve_order")] ++type KeysImpl<'a> = linked_hash_map::Keys<'a, String, Value>; ++ ++delegate_iterator!((Keys<'a>) => &'a String); ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++/// An iterator over a serde_json::Map's values. ++pub struct Values<'a> { ++ iter: ValuesImpl<'a>, ++} ++ ++#[cfg(not(feature = "preserve_order"))] ++type ValuesImpl<'a> = btree_map::Values<'a, String, Value>; ++#[cfg(feature = "preserve_order")] ++type ValuesImpl<'a> = linked_hash_map::Values<'a, String, Value>; ++ ++delegate_iterator!((Values<'a>) => &'a Value); diff --cc vendor/serde_json-1.0.3/src/number.rs index 000000000,000000000..929ddd167 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/number.rs @@@ -1,0 -1,0 +1,379 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use error::Error; ++use num_traits::NumCast; ++use serde::de::{self, Visitor, Unexpected}; ++use serde::{Serialize, Serializer, Deserialize, Deserializer}; ++use std::fmt::{self, Debug, Display}; ++use std::i64; ++ ++/// Represents a JSON number, whether integer or floating point. ++#[derive(Clone, PartialEq)] ++pub struct Number { ++ n: N, ++} ++ ++// "N" is a prefix of "NegInt"... this is a false positive. ++// https://github.com/Manishearth/rust-clippy/issues/1241 ++#[cfg_attr(feature = "cargo-clippy", allow(enum_variant_names))] ++#[derive(Copy, Clone, Debug, PartialEq)] ++enum N { ++ PosInt(u64), ++ /// Always less than zero. ++ NegInt(i64), ++ /// Always finite. ++ Float(f64), ++} ++ ++impl Number { ++ /// Returns true if the `Number` is an integer between `i64::MIN` and ++ /// `i64::MAX`. ++ /// ++ /// For any Number on which `is_i64` returns true, `as_i64` is guaranteed to ++ /// return the integer value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # use std::i64; ++ /// # ++ /// # fn main() { ++ /// let big = i64::MAX as u64 + 10; ++ /// let v = json!({ "a": 64, "b": big, "c": 256.0 }); ++ /// ++ /// assert!(v["a"].is_i64()); ++ /// ++ /// // Greater than i64::MAX. ++ /// assert!(!v["b"].is_i64()); ++ /// ++ /// // Numbers with a decimal point are not considered integers. ++ /// assert!(!v["c"].is_i64()); ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn is_i64(&self) -> bool { ++ match self.n { ++ N::PosInt(v) => v <= i64::MAX as u64, ++ N::NegInt(_) => true, ++ N::Float(_) => false, ++ } ++ } ++ ++ /// Returns true if the `Number` is an integer between zero and `u64::MAX`. ++ /// ++ /// For any Number on which `is_u64` returns true, `as_u64` is guaranteed to ++ /// return the integer value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": 64, "b": -64, "c": 256.0 }); ++ /// ++ /// assert!(v["a"].is_u64()); ++ /// ++ /// // Negative integer. ++ /// assert!(!v["b"].is_u64()); ++ /// ++ /// // Numbers with a decimal point are not considered integers. ++ /// assert!(!v["c"].is_u64()); ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn is_u64(&self) -> bool { ++ match self.n { ++ N::PosInt(_) => true, ++ N::NegInt(_) | N::Float(_) => false, ++ } ++ } ++ ++ /// Returns true if the `Number` can be represented by f64. ++ /// ++ /// For any Number on which `is_f64` returns true, `as_f64` is guaranteed to ++ /// return the floating point value. ++ /// ++ /// Currently this function returns true if and only if both `is_i64` and ++ /// `is_u64` return false but this is not a guarantee in the future. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": 256.0, "b": 64, "c": -64 }); ++ /// ++ /// assert!(v["a"].is_f64()); ++ /// ++ /// // Integers. ++ /// assert!(!v["b"].is_f64()); ++ /// assert!(!v["c"].is_f64()); ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn is_f64(&self) -> bool { ++ match self.n { ++ N::Float(_) => true, ++ N::PosInt(_) | N::NegInt(_) => false, ++ } ++ } ++ ++ /// If the `Number` is an integer, represent it as i64 if possible. Returns ++ /// None otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # use std::i64; ++ /// # ++ /// # fn main() { ++ /// let big = i64::MAX as u64 + 10; ++ /// let v = json!({ "a": 64, "b": big, "c": 256.0 }); ++ /// ++ /// assert_eq!(v["a"].as_i64(), Some(64)); ++ /// assert_eq!(v["b"].as_i64(), None); ++ /// assert_eq!(v["c"].as_i64(), None); ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn as_i64(&self) -> Option { ++ match self.n { ++ N::PosInt(n) => NumCast::from(n), ++ N::NegInt(n) => Some(n), ++ N::Float(_) => None, ++ } ++ } ++ ++ /// If the `Number` is an integer, represent it as u64 if possible. Returns ++ /// None otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": 64, "b": -64, "c": 256.0 }); ++ /// ++ /// assert_eq!(v["a"].as_u64(), Some(64)); ++ /// assert_eq!(v["b"].as_u64(), None); ++ /// assert_eq!(v["c"].as_u64(), None); ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn as_u64(&self) -> Option { ++ match self.n { ++ N::PosInt(n) => Some(n), ++ N::NegInt(n) => NumCast::from(n), ++ N::Float(_) => None, ++ } ++ } ++ ++ /// Represents the number as f64 if possible. Returns None otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": 256.0, "b": 64, "c": -64 }); ++ /// ++ /// assert_eq!(v["a"].as_f64(), Some(256.0)); ++ /// assert_eq!(v["b"].as_f64(), Some(64.0)); ++ /// assert_eq!(v["c"].as_f64(), Some(-64.0)); ++ /// # } ++ /// ``` ++ #[inline] ++ pub fn as_f64(&self) -> Option { ++ match self.n { ++ N::PosInt(n) => NumCast::from(n), ++ N::NegInt(n) => NumCast::from(n), ++ N::Float(n) => Some(n), ++ } ++ } ++ ++ /// Converts a finite `f64` to a `Number`. Infinite or NaN values are not JSON ++ /// numbers. ++ /// ++ /// ```rust ++ /// # use std::f64; ++ /// # ++ /// # use serde_json::Number; ++ /// # ++ /// assert!(Number::from_f64(256.0).is_some()); ++ /// ++ /// assert!(Number::from_f64(f64::NAN).is_none()); ++ /// ``` ++ #[inline] ++ pub fn from_f64(f: f64) -> Option { ++ if f.is_finite() { ++ Some(Number { n: N::Float(f) }) ++ } else { ++ None ++ } ++ } ++} ++ ++impl fmt::Display for Number { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ match self.n { ++ N::PosInt(i) => Display::fmt(&i, formatter), ++ N::NegInt(i) => Display::fmt(&i, formatter), ++ N::Float(f) => Display::fmt(&f, formatter), ++ } ++ } ++} ++ ++impl Debug for Number { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ Debug::fmt(&self.n, formatter) ++ } ++} ++ ++impl Serialize for Number { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: Serializer, ++ { ++ match self.n { ++ N::PosInt(i) => serializer.serialize_u64(i), ++ N::NegInt(i) => serializer.serialize_i64(i), ++ N::Float(f) => serializer.serialize_f64(f), ++ } ++ } ++} ++ ++impl<'de> Deserialize<'de> for Number { ++ #[inline] ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: Deserializer<'de>, ++ { ++ struct NumberVisitor; ++ ++ impl<'de> Visitor<'de> for NumberVisitor { ++ type Value = Number; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("a number") ++ } ++ ++ #[inline] ++ fn visit_i64(self, value: i64) -> Result { ++ Ok(value.into()) ++ } ++ ++ #[inline] ++ fn visit_u64(self, value: u64) -> Result { ++ Ok(value.into()) ++ } ++ ++ #[inline] ++ fn visit_f64(self, value: f64) -> Result ++ where ++ E: de::Error, ++ { ++ Number::from_f64(value).ok_or_else(|| de::Error::custom("not a JSON number")) ++ } ++ } ++ ++ deserializer.deserialize_any(NumberVisitor) ++ } ++} ++ ++impl<'de> Deserializer<'de> for Number { ++ type Error = Error; ++ ++ #[inline] ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match self.n { ++ N::PosInt(i) => visitor.visit_u64(i), ++ N::NegInt(i) => visitor.visit_i64(i), ++ N::Float(f) => visitor.visit_f64(f), ++ } ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++} ++ ++impl<'de, 'a> Deserializer<'de> for &'a Number { ++ type Error = Error; ++ ++ #[inline] ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match self.n { ++ N::PosInt(i) => visitor.visit_u64(i), ++ N::NegInt(i) => visitor.visit_i64(i), ++ N::Float(f) => visitor.visit_f64(f), ++ } ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++} ++ ++macro_rules! from_signed { ++ ($($signed_ty:ident)*) => { ++ $( ++ impl From<$signed_ty> for Number { ++ #[inline] ++ fn from(i: $signed_ty) -> Self { ++ if i < 0 { ++ Number { n: N::NegInt(i as i64) } ++ } else { ++ Number { n: N::PosInt(i as u64) } ++ } ++ } ++ } ++ )* ++ }; ++} ++ ++macro_rules! from_unsigned { ++ ($($unsigned_ty:ident)*) => { ++ $( ++ impl From<$unsigned_ty> for Number { ++ #[inline] ++ fn from(u: $unsigned_ty) -> Self { ++ Number { n: N::PosInt(u as u64) } ++ } ++ } ++ )* ++ }; ++} ++ ++from_signed!(i8 i16 i32 i64 isize); ++from_unsigned!(u8 u16 u32 u64 usize); ++ ++impl Number { ++ // Not public API. Should be pub(crate). ++ #[doc(hidden)] ++ pub fn unexpected(&self) -> Unexpected { ++ match self.n { ++ N::PosInt(u) => Unexpected::Unsigned(u), ++ N::NegInt(i) => Unexpected::Signed(i), ++ N::Float(f) => Unexpected::Float(f), ++ } ++ } ++} diff --cc vendor/serde_json-1.0.3/src/read.rs index 000000000,000000000..02db8f7d6 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/read.rs @@@ -1,0 -1,0 +1,698 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::{char, cmp, io, str}; ++use std::ops::Deref; ++ ++use iter::LineColIterator; ++ ++use super::error::{Error, ErrorCode, Result}; ++ ++/// Trait used by the deserializer for iterating over input. This is manually ++/// "specialized" for iterating over &[u8]. Once feature(specialization) is ++/// stable we can use actual specialization. ++/// ++/// This trait is sealed and cannot be implemented for types outside of ++/// `serde_json`. ++pub trait Read<'de>: private::Sealed { ++ #[doc(hidden)] ++ fn next(&mut self) -> io::Result>; ++ #[doc(hidden)] ++ fn peek(&mut self) -> io::Result>; ++ ++ /// Only valid after a call to peek(). Discards the peeked byte. ++ #[doc(hidden)] ++ fn discard(&mut self); ++ ++ /// Position of the most recent call to next(). ++ /// ++ /// The most recent call was probably next() and not peek(), but this method ++ /// should try to return a sensible result if the most recent call was ++ /// actually peek() because we don't always know. ++ /// ++ /// Only called in case of an error, so performance is not important. ++ #[doc(hidden)] ++ fn position(&self) -> Position; ++ ++ /// Position of the most recent call to peek(). ++ /// ++ /// The most recent call was probably peek() and not next(), but this method ++ /// should try to return a sensible result if the most recent call was ++ /// actually next() because we don't always know. ++ /// ++ /// Only called in case of an error, so performance is not important. ++ #[doc(hidden)] ++ fn peek_position(&self) -> Position; ++ ++ /// Offset from the beginning of the input to the next byte that would be ++ /// returned by next() or peek(). ++ #[doc(hidden)] ++ fn byte_offset(&self) -> usize; ++ ++ /// Assumes the previous byte was a quotation mark. Parses a JSON-escaped ++ /// string until the next quotation mark using the given scratch space if ++ /// necessary. The scratch space is initially empty. ++ #[doc(hidden)] ++ fn parse_str<'s>(&'s mut self, scratch: &'s mut Vec) -> Result>; ++ ++ /// Assumes the previous byte was a quotation mark. Parses a JSON-escaped ++ /// string until the next quotation mark using the given scratch space if ++ /// necessary. The scratch space is initially empty. ++ /// ++ /// This function returns the raw bytes in the string with escape sequences ++ /// expanded but without performing unicode validation. ++ #[doc(hidden)] ++ fn parse_str_raw<'s>( ++ &'s mut self, ++ scratch: &'s mut Vec, ++ ) -> Result>; ++ ++ /// Assumes the previous byte was a quotation mark. Parses a JSON-escaped ++ /// string until the next quotation mark but discards the data. ++ #[doc(hidden)] ++ fn ignore_str(&mut self) -> Result<()>; ++} ++ ++pub struct Position { ++ pub line: usize, ++ pub column: usize, ++} ++ ++pub enum Reference<'b, 'c, T: ?Sized + 'static> { ++ Borrowed(&'b T), ++ Copied(&'c T), ++} ++ ++impl<'b, 'c, T: ?Sized + 'static> Deref for Reference<'b, 'c, T> { ++ type Target = T; ++ ++ fn deref(&self) -> &Self::Target { ++ match *self { ++ Reference::Borrowed(b) => b, ++ Reference::Copied(c) => c, ++ } ++ } ++} ++ ++/// JSON input source that reads from a std::io input stream. ++pub struct IoRead ++where ++ R: io::Read, ++{ ++ iter: LineColIterator>, ++ /// Temporary storage of peeked byte. ++ ch: Option, ++} ++ ++/// JSON input source that reads from a slice of bytes. ++// ++// This is more efficient than other iterators because peek() can be read-only ++// and we can compute line/col position only if an error happens. ++pub struct SliceRead<'a> { ++ slice: &'a [u8], ++ /// Index of the *next* byte that will be returned by next() or peek(). ++ index: usize, ++} ++ ++/// JSON input source that reads from a UTF-8 string. ++// ++// Able to elide UTF-8 checks by assuming that the input is valid UTF-8. ++pub struct StrRead<'a> { ++ delegate: SliceRead<'a>, ++} ++ ++// Prevent users from implementing the Read trait. ++mod private { ++ pub trait Sealed {} ++} ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++impl IoRead ++where ++ R: io::Read, ++{ ++ /// Create a JSON input source to read from a std::io input stream. ++ pub fn new(reader: R) -> Self { ++ IoRead { ++ iter: LineColIterator::new(reader.bytes()), ++ ch: None, ++ } ++ } ++} ++ ++impl private::Sealed for IoRead ++where ++ R: io::Read, ++{ ++} ++ ++impl IoRead ++where ++ R: io::Read, ++{ ++ fn parse_str_bytes<'s, T, F>( ++ &'s mut self, ++ scratch: &'s mut Vec, ++ validate: bool, ++ result: F, ++ ) -> Result ++ where ++ T: 's, ++ F: FnOnce(&'s Self, &'s [u8]) -> Result, ++ { ++ loop { ++ let ch = try!(next_or_eof(self)); ++ if !ESCAPE[ch as usize] { ++ scratch.push(ch); ++ continue; ++ } ++ match ch { ++ b'"' => { ++ return result(self, scratch); ++ } ++ b'\\' => { ++ try!(parse_escape(self, scratch)); ++ } ++ _ => { ++ if validate { ++ return error(self, ErrorCode::InvalidUnicodeCodePoint); ++ } ++ scratch.push(ch); ++ } ++ } ++ } ++ } ++} ++ ++impl<'de, R> Read<'de> for IoRead ++where ++ R: io::Read, ++{ ++ #[inline] ++ fn next(&mut self) -> io::Result> { ++ match self.ch.take() { ++ Some(ch) => Ok(Some(ch)), ++ None => { ++ match self.iter.next() { ++ Some(Err(err)) => Err(err), ++ Some(Ok(ch)) => Ok(Some(ch)), ++ None => Ok(None), ++ } ++ } ++ } ++ } ++ ++ #[inline] ++ fn peek(&mut self) -> io::Result> { ++ match self.ch { ++ Some(ch) => Ok(Some(ch)), ++ None => { ++ match self.iter.next() { ++ Some(Err(err)) => Err(err), ++ Some(Ok(ch)) => { ++ self.ch = Some(ch); ++ Ok(self.ch) ++ } ++ None => Ok(None), ++ } ++ } ++ } ++ } ++ ++ #[inline] ++ fn discard(&mut self) { ++ self.ch = None; ++ } ++ ++ fn position(&self) -> Position { ++ Position { ++ line: self.iter.line(), ++ column: self.iter.col(), ++ } ++ } ++ ++ fn peek_position(&self) -> Position { ++ // The LineColIterator updates its position during peek() so it has the ++ // right one here. ++ self.position() ++ } ++ ++ fn byte_offset(&self) -> usize { ++ match self.ch { ++ Some(_) => self.iter.byte_offset() - 1, ++ None => self.iter.byte_offset(), ++ } ++ } ++ ++ fn parse_str<'s>(&'s mut self, scratch: &'s mut Vec) -> Result> { ++ self.parse_str_bytes(scratch, true, as_str) ++ .map(Reference::Copied) ++ } ++ ++ fn parse_str_raw<'s>( ++ &'s mut self, ++ scratch: &'s mut Vec, ++ ) -> Result> { ++ self.parse_str_bytes(scratch, false, |_, bytes| Ok(bytes)) ++ .map(Reference::Copied) ++ } ++ ++ fn ignore_str(&mut self) -> Result<()> { ++ loop { ++ let ch = try!(next_or_eof(self)); ++ if !ESCAPE[ch as usize] { ++ continue; ++ } ++ match ch { ++ b'"' => { ++ return Ok(()); ++ } ++ b'\\' => { ++ try!(ignore_escape(self)); ++ } ++ _ => { ++ return error(self, ErrorCode::InvalidUnicodeCodePoint); ++ } ++ } ++ } ++ } ++} ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++impl<'a> SliceRead<'a> { ++ /// Create a JSON input source to read from a slice of bytes. ++ pub fn new(slice: &'a [u8]) -> Self { ++ SliceRead { ++ slice: slice, ++ index: 0, ++ } ++ } ++ ++ fn position_of_index(&self, i: usize) -> Position { ++ let mut pos = Position { line: 1, column: 0 }; ++ for ch in &self.slice[..i] { ++ match *ch { ++ b'\n' => { ++ pos.line += 1; ++ pos.column = 0; ++ } ++ _ => { ++ pos.column += 1; ++ } ++ } ++ } ++ pos ++ } ++ ++ /// The big optimization here over IoRead is that if the string contains no ++ /// backslash escape sequences, the returned &str is a slice of the raw JSON ++ /// data so we avoid copying into the scratch space. ++ fn parse_str_bytes<'s, T: ?Sized, F>( ++ &'s mut self, ++ scratch: &'s mut Vec, ++ validate: bool, ++ result: F, ++ ) -> Result> ++ where ++ T: 's, ++ F: for<'f> FnOnce(&'s Self, &'f [u8]) -> Result<&'f T>, ++ { ++ // Index of the first byte not yet copied into the scratch space. ++ let mut start = self.index; ++ ++ loop { ++ while self.index < self.slice.len() && !ESCAPE[self.slice[self.index] as usize] { ++ self.index += 1; ++ } ++ if self.index == self.slice.len() { ++ return error(self, ErrorCode::EofWhileParsingString); ++ } ++ match self.slice[self.index] { ++ b'"' => { ++ if scratch.is_empty() { ++ // Fast path: return a slice of the raw JSON without any ++ // copying. ++ let borrowed = &self.slice[start..self.index]; ++ self.index += 1; ++ return result(self, borrowed).map(Reference::Borrowed); ++ } else { ++ scratch.extend_from_slice(&self.slice[start..self.index]); ++ // "as &[u8]" is required for rustc 1.8.0 ++ let copied = scratch as &[u8]; ++ self.index += 1; ++ return result(self, copied).map(Reference::Copied); ++ } ++ } ++ b'\\' => { ++ scratch.extend_from_slice(&self.slice[start..self.index]); ++ self.index += 1; ++ try!(parse_escape(self, scratch)); ++ start = self.index; ++ } ++ _ => { ++ if validate { ++ return error(self, ErrorCode::InvalidUnicodeCodePoint); ++ } ++ self.index += 1; ++ } ++ } ++ } ++ } ++} ++ ++impl<'a> private::Sealed for SliceRead<'a> {} ++ ++impl<'a> Read<'a> for SliceRead<'a> { ++ #[inline] ++ fn next(&mut self) -> io::Result> { ++ // `Ok(self.slice.get(self.index).map(|ch| { self.index += 1; *ch }))` ++ // is about 10% slower. ++ Ok( ++ if self.index < self.slice.len() { ++ let ch = self.slice[self.index]; ++ self.index += 1; ++ Some(ch) ++ } else { ++ None ++ }, ++ ) ++ } ++ ++ #[inline] ++ fn peek(&mut self) -> io::Result> { ++ // `Ok(self.slice.get(self.index).map(|ch| *ch))` is about 10% slower ++ // for some reason. ++ Ok( ++ if self.index < self.slice.len() { ++ Some(self.slice[self.index]) ++ } else { ++ None ++ }, ++ ) ++ } ++ ++ #[inline] ++ fn discard(&mut self) { ++ self.index += 1; ++ } ++ ++ fn position(&self) -> Position { ++ self.position_of_index(self.index) ++ } ++ ++ fn peek_position(&self) -> Position { ++ // Cap it at slice.len() just in case the most recent call was next() ++ // and it returned the last byte. ++ self.position_of_index(cmp::min(self.slice.len(), self.index + 1)) ++ } ++ ++ fn byte_offset(&self) -> usize { ++ self.index ++ } ++ ++ fn parse_str<'s>(&'s mut self, scratch: &'s mut Vec) -> Result> { ++ self.parse_str_bytes(scratch, true, as_str) ++ } ++ ++ fn parse_str_raw<'s>( ++ &'s mut self, ++ scratch: &'s mut Vec, ++ ) -> Result> { ++ self.parse_str_bytes(scratch, false, |_, bytes| Ok(bytes)) ++ } ++ ++ fn ignore_str(&mut self) -> Result<()> { ++ loop { ++ while self.index < self.slice.len() && !ESCAPE[self.slice[self.index] as usize] { ++ self.index += 1; ++ } ++ if self.index == self.slice.len() { ++ return error(self, ErrorCode::EofWhileParsingString); ++ } ++ match self.slice[self.index] { ++ b'"' => { ++ self.index += 1; ++ return Ok(()); ++ } ++ b'\\' => { ++ self.index += 1; ++ try!(ignore_escape(self)); ++ } ++ _ => { ++ return error(self, ErrorCode::InvalidUnicodeCodePoint); ++ } ++ } ++ } ++ } ++} ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++impl<'a> StrRead<'a> { ++ /// Create a JSON input source to read from a UTF-8 string. ++ pub fn new(s: &'a str) -> Self { ++ StrRead { delegate: SliceRead::new(s.as_bytes()) } ++ } ++} ++ ++impl<'a> private::Sealed for StrRead<'a> {} ++ ++impl<'a> Read<'a> for StrRead<'a> { ++ #[inline] ++ fn next(&mut self) -> io::Result> { ++ self.delegate.next() ++ } ++ ++ #[inline] ++ fn peek(&mut self) -> io::Result> { ++ self.delegate.peek() ++ } ++ ++ #[inline] ++ fn discard(&mut self) { ++ self.delegate.discard(); ++ } ++ ++ fn position(&self) -> Position { ++ self.delegate.position() ++ } ++ ++ fn peek_position(&self) -> Position { ++ self.delegate.peek_position() ++ } ++ ++ fn byte_offset(&self) -> usize { ++ self.delegate.byte_offset() ++ } ++ ++ fn parse_str<'s>(&'s mut self, scratch: &'s mut Vec) -> Result> { ++ self.delegate ++ .parse_str_bytes( ++ scratch, true, |_, bytes| { ++ // The input is assumed to be valid UTF-8 and the \u-escapes are ++ // checked along the way, so don't need to check here. ++ Ok(unsafe { str::from_utf8_unchecked(bytes) }) ++ } ++ ) ++ } ++ ++ fn parse_str_raw<'s>( ++ &'s mut self, ++ scratch: &'s mut Vec, ++ ) -> Result> { ++ self.delegate.parse_str_raw(scratch) ++ } ++ ++ fn ignore_str(&mut self) -> Result<()> { ++ self.delegate.ignore_str() ++ } ++} ++ ++////////////////////////////////////////////////////////////////////////////// ++ ++const CT: bool = true; // control character \x00...\x1F ++const QU: bool = true; // quote \x22 ++const BS: bool = true; // backslash \x5C ++const O: bool = false; // allow unescaped ++ ++// Lookup table of bytes that must be escaped. A value of true at index i means ++// that byte i requires an escape sequence in the input. ++#[cfg_attr(rustfmt, rustfmt_skip)] ++static ESCAPE: [bool; 256] = [ ++ // 1 2 3 4 5 6 7 8 9 A B C D E F ++ CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, // 0 ++ CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, CT, // 1 ++ O, O, QU, O, O, O, O, O, O, O, O, O, O, O, O, O, // 2 ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // 3 ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // 4 ++ O, O, O, O, O, O, O, O, O, O, O, O, BS, O, O, O, // 5 ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // 6 ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // 7 ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // 8 ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // 9 ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // A ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // B ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // C ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // D ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // E ++ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, // F ++]; ++ ++fn next_or_eof<'de, R: ?Sized + Read<'de>>(read: &mut R) -> Result { ++ match try!(read.next().map_err(Error::io)) { ++ Some(b) => Ok(b), ++ None => error(read, ErrorCode::EofWhileParsingString), ++ } ++} ++ ++fn error<'de, R: ?Sized + Read<'de>, T>(read: &R, reason: ErrorCode) -> Result { ++ let pos = read.position(); ++ Err(Error::syntax(reason, pos.line, pos.column)) ++} ++ ++fn as_str<'de, 's, R: Read<'de>>(read: &R, slice: &'s [u8]) -> Result<&'s str> { ++ str::from_utf8(slice).or_else(|_| error(read, ErrorCode::InvalidUnicodeCodePoint)) ++} ++ ++/// Parses a JSON escape sequence and appends it into the scratch space. Assumes ++/// the previous byte read was a backslash. ++fn parse_escape<'de, R: Read<'de>>(read: &mut R, scratch: &mut Vec) -> Result<()> { ++ let ch = try!(next_or_eof(read)); ++ ++ match ch { ++ b'"' => scratch.push(b'"'), ++ b'\\' => scratch.push(b'\\'), ++ b'/' => scratch.push(b'/'), ++ b'b' => scratch.push(b'\x08'), ++ b'f' => scratch.push(b'\x0c'), ++ b'n' => scratch.push(b'\n'), ++ b'r' => scratch.push(b'\r'), ++ b't' => scratch.push(b'\t'), ++ b'u' => { ++ let c = match try!(decode_hex_escape(read)) { ++ 0xDC00...0xDFFF => { ++ return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape); ++ } ++ ++ // Non-BMP characters are encoded as a sequence of ++ // two hex escapes, representing UTF-16 surrogates. ++ n1 @ 0xD800...0xDBFF => { ++ if try!(next_or_eof(read)) != b'\\' { ++ return error(read, ErrorCode::UnexpectedEndOfHexEscape); ++ } ++ if try!(next_or_eof(read)) != b'u' { ++ return error(read, ErrorCode::UnexpectedEndOfHexEscape); ++ } ++ ++ let n2 = try!(decode_hex_escape(read)); ++ ++ if n2 < 0xDC00 || n2 > 0xDFFF { ++ return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape); ++ } ++ ++ let n = (((n1 - 0xD800) as u32) << 10 | (n2 - 0xDC00) as u32) + 0x1_0000; ++ ++ match char::from_u32(n) { ++ Some(c) => c, ++ None => { ++ return error(read, ErrorCode::InvalidUnicodeCodePoint); ++ } ++ } ++ } ++ ++ n => { ++ match char::from_u32(n as u32) { ++ Some(c) => c, ++ None => { ++ return error(read, ErrorCode::InvalidUnicodeCodePoint); ++ } ++ } ++ } ++ }; ++ ++ // FIXME: this allocation is required in order to be compatible with stable ++ // rust, which doesn't support encoding a `char` into a stack buffer. ++ let mut buf = String::new(); ++ buf.push(c); ++ scratch.extend(buf.bytes()); ++ } ++ _ => { ++ return error(read, ErrorCode::InvalidEscape); ++ } ++ } ++ ++ Ok(()) ++} ++ ++/// Parses a JSON escape sequence and discards the value. Assumes the previous ++/// byte read was a backslash. ++fn ignore_escape<'de, R: ?Sized + Read<'de>>(read: &mut R) -> Result<()> { ++ let ch = try!(next_or_eof(read)); ++ ++ match ch { ++ b'"' | b'\\' | b'/' | b'b' | b'f' | b'n' | b'r' | b't' => {} ++ b'u' => { ++ let n = match try!(decode_hex_escape(read)) { ++ 0xDC00...0xDFFF => { ++ return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape); ++ } ++ ++ // Non-BMP characters are encoded as a sequence of ++ // two hex escapes, representing UTF-16 surrogates. ++ n1 @ 0xD800...0xDBFF => { ++ if try!(next_or_eof(read)) != b'\\' { ++ return error(read, ErrorCode::UnexpectedEndOfHexEscape); ++ } ++ if try!(next_or_eof(read)) != b'u' { ++ return error(read, ErrorCode::UnexpectedEndOfHexEscape); ++ } ++ ++ let n2 = try!(decode_hex_escape(read)); ++ ++ if n2 < 0xDC00 || n2 > 0xDFFF { ++ return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape); ++ } ++ ++ (((n1 - 0xD800) as u32) << 10 | (n2 - 0xDC00) as u32) + 0x1_0000 ++ } ++ ++ n => n as u32, ++ }; ++ ++ if char::from_u32(n).is_none() { ++ return error(read, ErrorCode::InvalidUnicodeCodePoint); ++ } ++ } ++ _ => { ++ return error(read, ErrorCode::InvalidEscape); ++ } ++ } ++ ++ Ok(()) ++} ++ ++fn decode_hex_escape<'de, R: ?Sized + Read<'de>>(read: &mut R) -> Result { ++ let mut n = 0; ++ for _ in 0..4 { ++ n = match try!(next_or_eof(read)) { ++ c @ b'0'...b'9' => n * 16_u16 + ((c as u16) - (b'0' as u16)), ++ b'a' | b'A' => n * 16_u16 + 10_u16, ++ b'b' | b'B' => n * 16_u16 + 11_u16, ++ b'c' | b'C' => n * 16_u16 + 12_u16, ++ b'd' | b'D' => n * 16_u16 + 13_u16, ++ b'e' | b'E' => n * 16_u16 + 14_u16, ++ b'f' | b'F' => n * 16_u16 + 15_u16, ++ _ => { ++ return error(read, ErrorCode::InvalidEscape); ++ } ++ }; ++ } ++ Ok(n) ++} diff --cc vendor/serde_json-1.0.3/src/ser.rs index 000000000,000000000..39cc03087 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/ser.rs @@@ -1,0 -1,0 +1,1821 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! Serialize a Rust data structure into JSON data. ++ ++use std::fmt; ++use std::io; ++use std::num::FpCategory; ++use std::str; ++ ++use serde::ser::{self, Impossible}; ++use super::error::{Error, ErrorCode, Result}; ++ ++use itoa; ++use dtoa; ++ ++/// A structure for serializing Rust values into JSON. ++pub struct Serializer { ++ writer: W, ++ formatter: F, ++} ++ ++impl Serializer ++where ++ W: io::Write, ++{ ++ /// Creates a new JSON serializer. ++ #[inline] ++ pub fn new(writer: W) -> Self { ++ Serializer::with_formatter(writer, CompactFormatter) ++ } ++} ++ ++impl<'a, W> Serializer> ++where ++ W: io::Write, ++{ ++ /// Creates a new JSON pretty print serializer. ++ #[inline] ++ pub fn pretty(writer: W) -> Self { ++ Serializer::with_formatter(writer, PrettyFormatter::new()) ++ } ++} ++ ++impl Serializer ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ /// Creates a new JSON visitor whose output will be written to the writer ++ /// specified. ++ #[inline] ++ pub fn with_formatter(writer: W, formatter: F) -> Self { ++ Serializer { ++ writer: writer, ++ formatter: formatter, ++ } ++ } ++ ++ /// Unwrap the `Writer` from the `Serializer`. ++ #[inline] ++ pub fn into_inner(self) -> W { ++ self.writer ++ } ++} ++ ++impl<'a, W, F> ser::Serializer for &'a mut Serializer ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ type Ok = (); ++ type Error = Error; ++ ++ type SerializeSeq = Compound<'a, W, F>; ++ type SerializeTuple = Compound<'a, W, F>; ++ type SerializeTupleStruct = Compound<'a, W, F>; ++ type SerializeTupleVariant = Compound<'a, W, F>; ++ type SerializeMap = Compound<'a, W, F>; ++ type SerializeStruct = Compound<'a, W, F>; ++ type SerializeStructVariant = Compound<'a, W, F>; ++ ++ #[inline] ++ fn serialize_bool(self, value: bool) -> Result<()> { ++ try!( ++ self.formatter ++ .write_bool(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_i8(self, value: i8) -> Result<()> { ++ try!( ++ self.formatter ++ .write_i8(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_i16(self, value: i16) -> Result<()> { ++ try!( ++ self.formatter ++ .write_i16(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_i32(self, value: i32) -> Result<()> { ++ try!( ++ self.formatter ++ .write_i32(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_i64(self, value: i64) -> Result<()> { ++ try!( ++ self.formatter ++ .write_i64(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_u8(self, value: u8) -> Result<()> { ++ try!( ++ self.formatter ++ .write_u8(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_u16(self, value: u16) -> Result<()> { ++ try!( ++ self.formatter ++ .write_u16(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_u32(self, value: u32) -> Result<()> { ++ try!( ++ self.formatter ++ .write_u32(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_u64(self, value: u64) -> Result<()> { ++ try!( ++ self.formatter ++ .write_u64(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_f32(self, value: f32) -> Result<()> { ++ match value.classify() { ++ FpCategory::Nan | FpCategory::Infinite => { ++ try!( ++ self.formatter ++ .write_null(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ } ++ _ => { ++ try!( ++ self.formatter ++ .write_f32(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ } ++ } ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_f64(self, value: f64) -> Result<()> { ++ match value.classify() { ++ FpCategory::Nan | FpCategory::Infinite => { ++ try!( ++ self.formatter ++ .write_null(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ } ++ _ => { ++ try!( ++ self.formatter ++ .write_f64(&mut self.writer, value) ++ .map_err(Error::io) ++ ); ++ } ++ } ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_char(self, value: char) -> Result<()> { ++ // A char encoded as UTF-8 takes 4 bytes at most. ++ let mut buf = [0; 4]; ++ self.serialize_str(value.encode_utf8(&mut buf)) ++ } ++ ++ #[inline] ++ fn serialize_str(self, value: &str) -> Result<()> { ++ try!(format_escaped_str(&mut self.writer, &mut self.formatter, value).map_err(Error::io)); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_bytes(self, value: &[u8]) -> Result<()> { ++ use serde::ser::SerializeSeq; ++ let mut seq = try!(self.serialize_seq(Some(value.len()))); ++ for byte in value { ++ try!(seq.serialize_element(byte)); ++ } ++ seq.end() ++ } ++ ++ #[inline] ++ fn serialize_unit(self) -> Result<()> { ++ try!( ++ self.formatter ++ .write_null(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_unit_struct(self, _name: &'static str) -> Result<()> { ++ self.serialize_unit() ++ } ++ ++ #[inline] ++ fn serialize_unit_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ variant: &'static str, ++ ) -> Result<()> { ++ self.serialize_str(variant) ++ } ++ ++ /// Serialize newtypes without an object wrapper. ++ #[inline] ++ fn serialize_newtype_struct(self, _name: &'static str, value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ value.serialize(self) ++ } ++ ++ #[inline] ++ fn serialize_newtype_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ variant: &'static str, ++ value: &T, ++ ) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ try!( ++ self.formatter ++ .begin_object(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.formatter ++ .begin_object_key(&mut self.writer, true) ++ .map_err(Error::io) ++ ); ++ try!(self.serialize_str(variant)); ++ try!( ++ self.formatter ++ .end_object_key(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.formatter ++ .begin_object_value(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ try!(value.serialize(&mut *self)); ++ try!( ++ self.formatter ++ .end_object_value(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.formatter ++ .end_object(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_none(self) -> Result<()> { ++ self.serialize_unit() ++ } ++ ++ #[inline] ++ fn serialize_some(self, value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ value.serialize(self) ++ } ++ ++ #[inline] ++ fn serialize_seq(self, len: Option) -> Result { ++ if len == Some(0) { ++ try!( ++ self.formatter ++ .begin_array(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.formatter ++ .end_array(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ Ok( ++ Compound { ++ ser: self, ++ state: State::Empty, ++ }, ++ ) ++ } else { ++ try!( ++ self.formatter ++ .begin_array(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ Ok( ++ Compound { ++ ser: self, ++ state: State::First, ++ }, ++ ) ++ } ++ } ++ ++ #[inline] ++ fn serialize_tuple(self, len: usize) -> Result { ++ self.serialize_seq(Some(len)) ++ } ++ ++ #[inline] ++ fn serialize_tuple_struct( ++ self, ++ _name: &'static str, ++ len: usize, ++ ) -> Result { ++ self.serialize_seq(Some(len)) ++ } ++ ++ #[inline] ++ fn serialize_tuple_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ variant: &'static str, ++ len: usize, ++ ) -> Result { ++ try!( ++ self.formatter ++ .begin_object(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.formatter ++ .begin_object_key(&mut self.writer, true) ++ .map_err(Error::io) ++ ); ++ try!(self.serialize_str(variant)); ++ try!( ++ self.formatter ++ .end_object_key(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.formatter ++ .begin_object_value(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ self.serialize_seq(Some(len)) ++ } ++ ++ #[inline] ++ fn serialize_map(self, len: Option) -> Result { ++ if len == Some(0) { ++ try!( ++ self.formatter ++ .begin_object(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.formatter ++ .end_object(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ Ok( ++ Compound { ++ ser: self, ++ state: State::Empty, ++ }, ++ ) ++ } else { ++ try!( ++ self.formatter ++ .begin_object(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ Ok( ++ Compound { ++ ser: self, ++ state: State::First, ++ }, ++ ) ++ } ++ } ++ ++ #[inline] ++ fn serialize_struct(self, _name: &'static str, len: usize) -> Result { ++ self.serialize_map(Some(len)) ++ } ++ ++ #[inline] ++ fn serialize_struct_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ variant: &'static str, ++ len: usize, ++ ) -> Result { ++ try!( ++ self.formatter ++ .begin_object(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.formatter ++ .begin_object_key(&mut self.writer, true) ++ .map_err(Error::io) ++ ); ++ try!(self.serialize_str(variant)); ++ try!( ++ self.formatter ++ .end_object_key(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.formatter ++ .begin_object_value(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ self.serialize_map(Some(len)) ++ } ++ ++ fn collect_str(self, value: &T) -> Result ++ where ++ T: fmt::Display, ++ { ++ use std::fmt::Write; ++ ++ struct Adapter<'ser, W: 'ser, F: 'ser> { ++ writer: &'ser mut W, ++ formatter: &'ser mut F, ++ error: Option, ++ } ++ ++ impl<'ser, W, F> Write for Adapter<'ser, W, F> ++ where ++ W: io::Write, ++ F: Formatter, ++ { ++ fn write_str(&mut self, s: &str) -> fmt::Result { ++ assert!(self.error.is_none()); ++ match format_escaped_str_contents(self.writer, self.formatter, s) { ++ Ok(()) => Ok(()), ++ Err(err) => { ++ self.error = Some(err); ++ Err(fmt::Error) ++ } ++ } ++ } ++ } ++ ++ try!( ++ self.formatter ++ .begin_string(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ { ++ let mut adapter = Adapter { ++ writer: &mut self.writer, ++ formatter: &mut self.formatter, ++ error: None, ++ }; ++ match write!(adapter, "{}", value) { ++ Ok(()) => assert!(adapter.error.is_none()), ++ Err(fmt::Error) => { ++ return Err(Error::io(adapter.error.expect("there should be an error"))); ++ } ++ } ++ } ++ try!( ++ self.formatter ++ .end_string(&mut self.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++} ++ ++#[doc(hidden)] ++#[derive(Eq, PartialEq)] ++pub enum State { ++ Empty, ++ First, ++ Rest, ++} ++ ++#[doc(hidden)] ++pub struct Compound<'a, W: 'a, F: 'a> { ++ ser: &'a mut Serializer, ++ state: State, ++} ++ ++impl<'a, W, F> ser::SerializeSeq for Compound<'a, W, F> ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ type Ok = (); ++ type Error = Error; ++ ++ #[inline] ++ fn serialize_element(&mut self, value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ try!( ++ self.ser ++ .formatter ++ .begin_array_value(&mut self.ser.writer, self.state == State::First) ++ .map_err(Error::io) ++ ); ++ self.state = State::Rest; ++ try!(value.serialize(&mut *self.ser)); ++ try!( ++ self.ser ++ .formatter ++ .end_array_value(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn end(self) -> Result<()> { ++ match self.state { ++ State::Empty => {} ++ _ => { ++ try!( ++ self.ser ++ .formatter ++ .end_array(&mut self.ser.writer) ++ .map_err(Error::io) ++ ) ++ } ++ } ++ Ok(()) ++ } ++} ++ ++impl<'a, W, F> ser::SerializeTuple for Compound<'a, W, F> ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ type Ok = (); ++ type Error = Error; ++ ++ #[inline] ++ fn serialize_element(&mut self, value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ ser::SerializeSeq::serialize_element(self, value) ++ } ++ ++ #[inline] ++ fn end(self) -> Result<()> { ++ ser::SerializeSeq::end(self) ++ } ++} ++ ++impl<'a, W, F> ser::SerializeTupleStruct for Compound<'a, W, F> ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ type Ok = (); ++ type Error = Error; ++ ++ #[inline] ++ fn serialize_field(&mut self, value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ ser::SerializeSeq::serialize_element(self, value) ++ } ++ ++ #[inline] ++ fn end(self) -> Result<()> { ++ ser::SerializeSeq::end(self) ++ } ++} ++ ++impl<'a, W, F> ser::SerializeTupleVariant for Compound<'a, W, F> ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ type Ok = (); ++ type Error = Error; ++ ++ #[inline] ++ fn serialize_field(&mut self, value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ ser::SerializeSeq::serialize_element(self, value) ++ } ++ ++ #[inline] ++ fn end(self) -> Result<()> { ++ match self.state { ++ State::Empty => {} ++ _ => { ++ try!( ++ self.ser ++ .formatter ++ .end_array(&mut self.ser.writer) ++ .map_err(Error::io) ++ ) ++ } ++ } ++ try!( ++ self.ser ++ .formatter ++ .end_object_value(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .end_object(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++} ++ ++impl<'a, W, F> ser::SerializeMap for Compound<'a, W, F> ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ type Ok = (); ++ type Error = Error; ++ ++ #[inline] ++ fn serialize_key(&mut self, key: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ try!( ++ self.ser ++ .formatter ++ .begin_object_key(&mut self.ser.writer, self.state == State::First) ++ .map_err(Error::io) ++ ); ++ self.state = State::Rest; ++ ++ try!(key.serialize(MapKeySerializer { ser: self.ser })); ++ ++ try!( ++ self.ser ++ .formatter ++ .end_object_key(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn serialize_value(&mut self, value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ try!( ++ self.ser ++ .formatter ++ .begin_object_value(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!(value.serialize(&mut *self.ser)); ++ try!( ++ self.ser ++ .formatter ++ .end_object_value(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn end(self) -> Result<()> { ++ match self.state { ++ State::Empty => {} ++ _ => { ++ try!( ++ self.ser ++ .formatter ++ .end_object(&mut self.ser.writer) ++ .map_err(Error::io) ++ ) ++ } ++ } ++ Ok(()) ++ } ++} ++ ++impl<'a, W, F> ser::SerializeStruct for Compound<'a, W, F> ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ type Ok = (); ++ type Error = Error; ++ ++ #[inline] ++ fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ try!(ser::SerializeMap::serialize_key(self, key)); ++ ser::SerializeMap::serialize_value(self, value) ++ } ++ ++ #[inline] ++ fn end(self) -> Result<()> { ++ ser::SerializeMap::end(self) ++ } ++} ++ ++impl<'a, W, F> ser::SerializeStructVariant for Compound<'a, W, F> ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ type Ok = (); ++ type Error = Error; ++ ++ #[inline] ++ fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ ser::SerializeStruct::serialize_field(self, key, value) ++ } ++ ++ #[inline] ++ fn end(self) -> Result<()> { ++ match self.state { ++ State::Empty => {} ++ _ => { ++ try!( ++ self.ser ++ .formatter ++ .end_object(&mut self.ser.writer) ++ .map_err(Error::io) ++ ) ++ } ++ } ++ try!( ++ self.ser ++ .formatter ++ .end_object_value(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .end_object(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++} ++ ++struct MapKeySerializer<'a, W: 'a, F: 'a> { ++ ser: &'a mut Serializer, ++} ++ ++fn key_must_be_a_string() -> Error { ++ Error::syntax(ErrorCode::KeyMustBeAString, 0, 0) ++} ++ ++impl<'a, W, F> ser::Serializer for MapKeySerializer<'a, W, F> ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ type Ok = (); ++ type Error = Error; ++ ++ #[inline] ++ fn serialize_str(self, value: &str) -> Result<()> { ++ self.ser.serialize_str(value) ++ } ++ ++ #[inline] ++ fn serialize_unit_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ variant: &'static str, ++ ) -> Result<()> { ++ self.ser.serialize_str(variant) ++ } ++ ++ #[inline] ++ fn serialize_newtype_struct(self, _name: &'static str, value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ value.serialize(self) ++ } ++ ++ type SerializeSeq = Impossible<(), Error>; ++ type SerializeTuple = Impossible<(), Error>; ++ type SerializeTupleStruct = Impossible<(), Error>; ++ type SerializeTupleVariant = Impossible<(), Error>; ++ type SerializeMap = Impossible<(), Error>; ++ type SerializeStruct = Impossible<(), Error>; ++ type SerializeStructVariant = Impossible<(), Error>; ++ ++ fn serialize_bool(self, _value: bool) -> Result<()> { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_i8(self, value: i8) -> Result<()> { ++ try!( ++ self.ser ++ .formatter ++ .begin_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .write_i8(&mut self.ser.writer, value) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .end_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ fn serialize_i16(self, value: i16) -> Result<()> { ++ try!( ++ self.ser ++ .formatter ++ .begin_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .write_i16(&mut self.ser.writer, value) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .end_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ fn serialize_i32(self, value: i32) -> Result<()> { ++ try!( ++ self.ser ++ .formatter ++ .begin_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .write_i32(&mut self.ser.writer, value) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .end_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ fn serialize_i64(self, value: i64) -> Result<()> { ++ try!( ++ self.ser ++ .formatter ++ .begin_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .write_i64(&mut self.ser.writer, value) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .end_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ fn serialize_u8(self, value: u8) -> Result<()> { ++ try!( ++ self.ser ++ .formatter ++ .begin_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .write_u8(&mut self.ser.writer, value) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .end_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ fn serialize_u16(self, value: u16) -> Result<()> { ++ try!( ++ self.ser ++ .formatter ++ .begin_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .write_u16(&mut self.ser.writer, value) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .end_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ fn serialize_u32(self, value: u32) -> Result<()> { ++ try!( ++ self.ser ++ .formatter ++ .begin_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .write_u32(&mut self.ser.writer, value) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .end_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ fn serialize_u64(self, value: u64) -> Result<()> { ++ try!( ++ self.ser ++ .formatter ++ .begin_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .write_u64(&mut self.ser.writer, value) ++ .map_err(Error::io) ++ ); ++ try!( ++ self.ser ++ .formatter ++ .end_string(&mut self.ser.writer) ++ .map_err(Error::io) ++ ); ++ Ok(()) ++ } ++ ++ fn serialize_f32(self, _value: f32) -> Result<()> { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_f64(self, _value: f64) -> Result<()> { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_char(self, _value: char) -> Result<()> { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_bytes(self, _value: &[u8]) -> Result<()> { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_unit(self) -> Result<()> { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_unit_struct(self, _name: &'static str) -> Result<()> { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_newtype_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ _variant: &'static str, ++ _value: &T, ++ ) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_none(self) -> Result<()> { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_some(self, _value: &T) -> Result<()> ++ where ++ T: ser::Serialize, ++ { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_seq(self, _len: Option) -> Result { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_tuple(self, _len: usize) -> Result { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_tuple_struct( ++ self, ++ _name: &'static str, ++ _len: usize, ++ ) -> Result { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_tuple_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ _variant: &'static str, ++ _len: usize, ++ ) -> Result { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_map(self, _len: Option) -> Result { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_struct(self, _name: &'static str, _len: usize) -> Result { ++ Err(key_must_be_a_string()) ++ } ++ ++ fn serialize_struct_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ _variant: &'static str, ++ _len: usize, ++ ) -> Result { ++ Err(key_must_be_a_string()) ++ } ++} ++ ++/// Represents a character escape code in a type-safe manner. ++pub enum CharEscape { ++ /// An escaped quote `"` ++ Quote, ++ /// An escaped reverse solidus `\` ++ ReverseSolidus, ++ /// An escaped solidus `/` ++ Solidus, ++ /// An escaped backspace character (usually escaped as `\b`) ++ Backspace, ++ /// An escaped form feed character (usually escaped as `\f`) ++ FormFeed, ++ /// An escaped line feed character (usually escaped as `\n`) ++ LineFeed, ++ /// An escaped carriage return character (usually escaped as `\r`) ++ CarriageReturn, ++ /// An escaped tab character (usually escaped as `\t`) ++ Tab, ++ /// An escaped ASCII plane control character (usually escaped as ++ /// `\u00XX` where `XX` are two hex characters) ++ AsciiControl(u8), ++} ++ ++impl CharEscape { ++ #[inline] ++ fn from_escape_table(escape: u8, byte: u8) -> CharEscape { ++ match escape { ++ self::BB => CharEscape::Backspace, ++ self::TT => CharEscape::Tab, ++ self::NN => CharEscape::LineFeed, ++ self::FF => CharEscape::FormFeed, ++ self::RR => CharEscape::CarriageReturn, ++ self::QU => CharEscape::Quote, ++ self::BS => CharEscape::ReverseSolidus, ++ self::U => CharEscape::AsciiControl(byte), ++ _ => unreachable!(), ++ } ++ } ++} ++ ++/// This trait abstracts away serializing the JSON control characters, which allows the user to ++/// optionally pretty print the JSON output. ++pub trait Formatter { ++ /// Writes a `null` value to the specified writer. ++ #[inline] ++ fn write_null(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ writer.write_all(b"null") ++ } ++ ++ /// Writes a `true` or `false` value to the specified writer. ++ #[inline] ++ fn write_bool(&mut self, writer: &mut W, value: bool) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ let s = if value { ++ b"true" as &[u8] ++ } else { ++ b"false" as &[u8] ++ }; ++ writer.write_all(s) ++ } ++ ++ /// Writes an integer value like `-123` to the specified writer. ++ #[inline] ++ fn write_i8(&mut self, writer: &mut W, value: i8) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ itoa::write(writer, value).map(|_| ()) ++ } ++ ++ /// Writes an integer value like `-123` to the specified writer. ++ #[inline] ++ fn write_i16(&mut self, writer: &mut W, value: i16) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ itoa::write(writer, value).map(|_| ()) ++ } ++ ++ /// Writes an integer value like `-123` to the specified writer. ++ #[inline] ++ fn write_i32(&mut self, writer: &mut W, value: i32) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ itoa::write(writer, value).map(|_| ()) ++ } ++ ++ /// Writes an integer value like `-123` to the specified writer. ++ #[inline] ++ fn write_i64(&mut self, writer: &mut W, value: i64) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ itoa::write(writer, value).map(|_| ()) ++ } ++ ++ /// Writes an integer value like `123` to the specified writer. ++ #[inline] ++ fn write_u8(&mut self, writer: &mut W, value: u8) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ itoa::write(writer, value).map(|_| ()) ++ } ++ ++ /// Writes an integer value like `123` to the specified writer. ++ #[inline] ++ fn write_u16(&mut self, writer: &mut W, value: u16) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ itoa::write(writer, value).map(|_| ()) ++ } ++ ++ /// Writes an integer value like `123` to the specified writer. ++ #[inline] ++ fn write_u32(&mut self, writer: &mut W, value: u32) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ itoa::write(writer, value).map(|_| ()) ++ } ++ ++ /// Writes an integer value like `123` to the specified writer. ++ #[inline] ++ fn write_u64(&mut self, writer: &mut W, value: u64) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ itoa::write(writer, value).map(|_| ()) ++ } ++ ++ /// Writes a floating point value like `-31.26e+12` to the specified writer. ++ #[inline] ++ fn write_f32(&mut self, writer: &mut W, value: f32) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ dtoa::write(writer, value).map(|_| ()) ++ } ++ ++ /// Writes a floating point value like `-31.26e+12` to the specified writer. ++ #[inline] ++ fn write_f64(&mut self, writer: &mut W, value: f64) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ dtoa::write(writer, value).map(|_| ()) ++ } ++ ++ /// Called before each series of `write_string_fragment` and ++ /// `write_char_escape`. Writes a `"` to the specified writer. ++ #[inline] ++ fn begin_string(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ writer.write_all(b"\"") ++ } ++ ++ /// Called after each series of `write_string_fragment` and ++ /// `write_char_escape`. Writes a `"` to the specified writer. ++ #[inline] ++ fn end_string(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ writer.write_all(b"\"") ++ } ++ ++ /// Writes a string fragment that doesn't need any escaping to the ++ /// specified writer. ++ #[inline] ++ fn write_string_fragment(&mut self, writer: &mut W, fragment: &str) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ writer.write_all(fragment.as_bytes()) ++ } ++ ++ /// Writes a character escape code to the specified writer. ++ #[inline] ++ fn write_char_escape( ++ &mut self, ++ writer: &mut W, ++ char_escape: CharEscape, ++ ) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ use self::CharEscape::*; ++ ++ let s = match char_escape { ++ Quote => b"\\\"", ++ ReverseSolidus => b"\\\\", ++ Solidus => b"\\/", ++ Backspace => b"\\b", ++ FormFeed => b"\\f", ++ LineFeed => b"\\n", ++ CarriageReturn => b"\\r", ++ Tab => b"\\t", ++ AsciiControl(byte) => { ++ static HEX_DIGITS: [u8; 16] = *b"0123456789abcdef"; ++ let bytes = &[ ++ b'\\', ++ b'u', ++ b'0', ++ b'0', ++ HEX_DIGITS[(byte >> 4) as usize], ++ HEX_DIGITS[(byte & 0xF) as usize], ++ ]; ++ return writer.write_all(bytes); ++ } ++ }; ++ ++ writer.write_all(s) ++ } ++ ++ /// Called before every array. Writes a `[` to the specified ++ /// writer. ++ #[inline] ++ fn begin_array(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ writer.write_all(b"[") ++ } ++ ++ /// Called after every array. Writes a `]` to the specified ++ /// writer. ++ #[inline] ++ fn end_array(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ writer.write_all(b"]") ++ } ++ ++ /// Called before every array value. Writes a `,` if needed to ++ /// the specified writer. ++ #[inline] ++ fn begin_array_value(&mut self, writer: &mut W, first: bool) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ if first { ++ Ok(()) ++ } else { ++ writer.write_all(b",") ++ } ++ } ++ ++ /// Called after every array value. ++ #[inline] ++ fn end_array_value(&mut self, _writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ Ok(()) ++ } ++ ++ /// Called before every object. Writes a `{` to the specified ++ /// writer. ++ #[inline] ++ fn begin_object(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ writer.write_all(b"{") ++ } ++ ++ /// Called after every object. Writes a `}` to the specified ++ /// writer. ++ #[inline] ++ fn end_object(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ writer.write_all(b"}") ++ } ++ ++ /// Called before every object key. ++ #[inline] ++ fn begin_object_key(&mut self, writer: &mut W, first: bool) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ if first { ++ Ok(()) ++ } else { ++ writer.write_all(b",") ++ } ++ } ++ ++ /// Called after every object key. A `:` should be written to the ++ /// specified writer by either this method or ++ /// `begin_object_value`. ++ #[inline] ++ fn end_object_key(&mut self, _writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ Ok(()) ++ } ++ ++ /// Called before every object value. A `:` should be written to ++ /// the specified writer by either this method or ++ /// `end_object_key`. ++ #[inline] ++ fn begin_object_value(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ writer.write_all(b":") ++ } ++ ++ /// Called after every object value. ++ #[inline] ++ fn end_object_value(&mut self, _writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ Ok(()) ++ } ++} ++ ++/// This structure compacts a JSON value with no extra whitespace. ++#[derive(Clone, Debug)] ++pub struct CompactFormatter; ++ ++impl Formatter for CompactFormatter {} ++ ++/// This structure pretty prints a JSON value to make it human readable. ++#[derive(Clone, Debug)] ++pub struct PrettyFormatter<'a> { ++ current_indent: usize, ++ has_value: bool, ++ indent: &'a [u8], ++} ++ ++impl<'a> PrettyFormatter<'a> { ++ /// Construct a pretty printer formatter that defaults to using two spaces for indentation. ++ pub fn new() -> Self { ++ PrettyFormatter::with_indent(b" ") ++ } ++ ++ /// Construct a pretty printer formatter that uses the `indent` string for indentation. ++ pub fn with_indent(indent: &'a [u8]) -> Self { ++ PrettyFormatter { ++ current_indent: 0, ++ has_value: false, ++ indent: indent, ++ } ++ } ++} ++ ++impl<'a> Default for PrettyFormatter<'a> { ++ fn default() -> Self { ++ PrettyFormatter::new() ++ } ++} ++ ++impl<'a> Formatter for PrettyFormatter<'a> { ++ #[inline] ++ fn begin_array(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ self.current_indent += 1; ++ self.has_value = false; ++ writer.write_all(b"[") ++ } ++ ++ #[inline] ++ fn end_array(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ self.current_indent -= 1; ++ ++ if self.has_value { ++ try!(writer.write_all(b"\n")); ++ try!(indent(writer, self.current_indent, self.indent)); ++ } ++ ++ writer.write_all(b"]") ++ } ++ ++ #[inline] ++ fn begin_array_value(&mut self, writer: &mut W, first: bool) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ if first { ++ try!(writer.write_all(b"\n")); ++ } else { ++ try!(writer.write_all(b",\n")); ++ } ++ try!(indent(writer, self.current_indent, self.indent)); ++ Ok(()) ++ } ++ ++ #[inline] ++ fn end_array_value(&mut self, _writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ self.has_value = true; ++ Ok(()) ++ } ++ ++ #[inline] ++ fn begin_object(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ self.current_indent += 1; ++ self.has_value = false; ++ writer.write_all(b"{") ++ } ++ ++ #[inline] ++ fn end_object(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ self.current_indent -= 1; ++ ++ if self.has_value { ++ try!(writer.write_all(b"\n")); ++ try!(indent(writer, self.current_indent, self.indent)); ++ } ++ ++ writer.write_all(b"}") ++ } ++ ++ #[inline] ++ fn begin_object_key(&mut self, writer: &mut W, first: bool) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ if first { ++ try!(writer.write_all(b"\n")); ++ } else { ++ try!(writer.write_all(b",\n")); ++ } ++ indent(writer, self.current_indent, self.indent) ++ } ++ ++ #[inline] ++ fn begin_object_value(&mut self, writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ writer.write_all(b": ") ++ } ++ ++ #[inline] ++ fn end_object_value(&mut self, _writer: &mut W) -> io::Result<()> ++ where ++ W: io::Write, ++ { ++ self.has_value = true; ++ Ok(()) ++ } ++} ++ ++fn format_escaped_str( ++ writer: &mut W, ++ formatter: &mut F, ++ value: &str, ++) -> io::Result<()> ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ try!(formatter.begin_string(writer)); ++ try!(format_escaped_str_contents(writer, formatter, value)); ++ try!(formatter.end_string(writer)); ++ Ok(()) ++} ++ ++fn format_escaped_str_contents( ++ writer: &mut W, ++ formatter: &mut F, ++ value: &str, ++) -> io::Result<()> ++where ++ W: io::Write, ++ F: Formatter, ++{ ++ let bytes = value.as_bytes(); ++ ++ let mut start = 0; ++ ++ for (i, &byte) in bytes.iter().enumerate() { ++ let escape = ESCAPE[byte as usize]; ++ if escape == 0 { ++ continue; ++ } ++ ++ if start < i { ++ try!(formatter.write_string_fragment(writer, &value[start..i])); ++ } ++ ++ let char_escape = CharEscape::from_escape_table(escape, byte); ++ try!(formatter.write_char_escape(writer, char_escape)); ++ ++ start = i + 1; ++ } ++ ++ if start != bytes.len() { ++ try!(formatter.write_string_fragment(writer, &value[start..])); ++ } ++ ++ Ok(()) ++} ++ ++const BB: u8 = b'b'; // \x08 ++const TT: u8 = b't'; // \x09 ++const NN: u8 = b'n'; // \x0A ++const FF: u8 = b'f'; // \x0C ++const RR: u8 = b'r'; // \x0D ++const QU: u8 = b'"'; // \x22 ++const BS: u8 = b'\\'; // \x5C ++const U: u8 = b'u'; // \x00...\x1F except the ones above ++ ++// Lookup table of escape sequences. A value of b'x' at index i means that byte ++// i is escaped as "\x" in JSON. A value of 0 means that byte i is not escaped. ++#[cfg_attr(rustfmt, rustfmt_skip)] ++static ESCAPE: [u8; 256] = [ ++ // 1 2 3 4 5 6 7 8 9 A B C D E F ++ U, U, U, U, U, U, U, U, BB, TT, NN, U, FF, RR, U, U, // 0 ++ U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, // 1 ++ 0, 0, QU, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2 ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3 ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 4 ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, BS, 0, 0, 0, // 5 ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 6 ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7 ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8 ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9 ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // A ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // B ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // C ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // D ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // E ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // F ++]; ++ ++/// Serialize the given data structure as JSON into the IO stream. ++/// ++/// # Errors ++/// ++/// Serialization can fail if `T`'s implementation of `Serialize` decides to ++/// fail, or if `T` contains a map with non-string keys. ++#[inline] ++pub fn to_writer(writer: W, value: &T) -> Result<()> ++where ++ W: io::Write, ++ T: ser::Serialize, ++{ ++ let mut ser = Serializer::new(writer); ++ try!(value.serialize(&mut ser)); ++ Ok(()) ++} ++ ++/// Serialize the given data structure as pretty-printed JSON into the IO ++/// stream. ++/// ++/// # Errors ++/// ++/// Serialization can fail if `T`'s implementation of `Serialize` decides to ++/// fail, or if `T` contains a map with non-string keys. ++#[inline] ++pub fn to_writer_pretty(writer: W, value: &T) -> Result<()> ++where ++ W: io::Write, ++ T: ser::Serialize, ++{ ++ let mut ser = Serializer::pretty(writer); ++ try!(value.serialize(&mut ser)); ++ Ok(()) ++} ++ ++/// Serialize the given data structure as a JSON byte vector. ++/// ++/// # Errors ++/// ++/// Serialization can fail if `T`'s implementation of `Serialize` decides to ++/// fail, or if `T` contains a map with non-string keys. ++#[inline] ++pub fn to_vec(value: &T) -> Result> ++where ++ T: ser::Serialize, ++{ ++ let mut writer = Vec::with_capacity(128); ++ try!(to_writer(&mut writer, value)); ++ Ok(writer) ++} ++ ++/// Serialize the given data structure as a pretty-printed JSON byte vector. ++/// ++/// # Errors ++/// ++/// Serialization can fail if `T`'s implementation of `Serialize` decides to ++/// fail, or if `T` contains a map with non-string keys. ++#[inline] ++pub fn to_vec_pretty(value: &T) -> Result> ++where ++ T: ser::Serialize, ++{ ++ let mut writer = Vec::with_capacity(128); ++ try!(to_writer_pretty(&mut writer, value)); ++ Ok(writer) ++} ++ ++/// Serialize the given data structure as a String of JSON. ++/// ++/// # Errors ++/// ++/// Serialization can fail if `T`'s implementation of `Serialize` decides to ++/// fail, or if `T` contains a map with non-string keys. ++#[inline] ++pub fn to_string(value: &T) -> Result ++where ++ T: ser::Serialize, ++{ ++ let vec = try!(to_vec(value)); ++ let string = unsafe { ++ // We do not emit invalid UTF-8. ++ String::from_utf8_unchecked(vec) ++ }; ++ Ok(string) ++} ++ ++/// Serialize the given data structure as a pretty-printed String of JSON. ++/// ++/// # Errors ++/// ++/// Serialization can fail if `T`'s implementation of `Serialize` decides to ++/// fail, or if `T` contains a map with non-string keys. ++#[inline] ++pub fn to_string_pretty(value: &T) -> Result ++where ++ T: ser::Serialize, ++{ ++ let vec = try!(to_vec_pretty(value)); ++ let string = unsafe { ++ // We do not emit invalid UTF-8. ++ String::from_utf8_unchecked(vec) ++ }; ++ Ok(string) ++} ++ ++fn indent(wr: &mut W, n: usize, s: &[u8]) -> io::Result<()> ++where ++ W: io::Write, ++{ ++ for _ in 0..n { ++ try!(wr.write_all(s)); ++ } ++ ++ Ok(()) ++} diff --cc vendor/serde_json-1.0.3/src/value/de.rs index 000000000,000000000..b8737a873 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/value/de.rs @@@ -1,0 -1,0 +1,909 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::borrow::Cow; ++use std::fmt; ++use std::i64; ++use std::io; ++use std::slice; ++use std::str; ++use std::vec; ++ ++use serde; ++use serde::de::{ ++ Deserialize, ++ DeserializeSeed, ++ IntoDeserializer, ++ Visitor, ++ SeqAccess, ++ MapAccess, ++ EnumAccess, ++ VariantAccess, ++ Unexpected ++}; ++ ++use error::Error; ++use map::Map; ++use number::Number; ++use value::Value; ++ ++impl<'de> Deserialize<'de> for Value { ++ #[inline] ++ fn deserialize(deserializer: D) -> Result ++ where ++ D: serde::Deserializer<'de>, ++ { ++ struct ValueVisitor; ++ ++ impl<'de> Visitor<'de> for ValueVisitor { ++ type Value = Value; ++ ++ fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ formatter.write_str("any valid JSON value") ++ } ++ ++ #[inline] ++ fn visit_bool(self, value: bool) -> Result { ++ Ok(Value::Bool(value)) ++ } ++ ++ #[inline] ++ fn visit_i64(self, value: i64) -> Result { ++ Ok(Value::Number(value.into())) ++ } ++ ++ #[inline] ++ fn visit_u64(self, value: u64) -> Result { ++ Ok(Value::Number(value.into())) ++ } ++ ++ #[inline] ++ fn visit_f64(self, value: f64) -> Result { ++ Ok(Number::from_f64(value).map_or(Value::Null, Value::Number)) ++ } ++ ++ #[inline] ++ fn visit_str(self, value: &str) -> Result ++ where ++ E: serde::de::Error, ++ { ++ self.visit_string(String::from(value)) ++ } ++ ++ #[inline] ++ fn visit_string(self, value: String) -> Result { ++ Ok(Value::String(value)) ++ } ++ ++ #[inline] ++ fn visit_none(self) -> Result { ++ Ok(Value::Null) ++ } ++ ++ #[inline] ++ fn visit_some(self, deserializer: D) -> Result ++ where ++ D: serde::Deserializer<'de>, ++ { ++ Deserialize::deserialize(deserializer) ++ } ++ ++ #[inline] ++ fn visit_unit(self) -> Result { ++ Ok(Value::Null) ++ } ++ ++ #[inline] ++ fn visit_seq(self, mut visitor: V) -> Result ++ where ++ V: SeqAccess<'de>, ++ { ++ let mut vec = Vec::new(); ++ ++ while let Some(elem) = try!(visitor.next_element()) { ++ vec.push(elem); ++ } ++ ++ Ok(Value::Array(vec)) ++ } ++ ++ fn visit_map(self, mut visitor: V) -> Result ++ where ++ V: MapAccess<'de>, ++ { ++ let mut values = Map::new(); ++ ++ while let Some((key, value)) = try!(visitor.next_entry()) { ++ values.insert(key, value); ++ } ++ ++ Ok(Value::Object(values)) ++ } ++ } ++ ++ deserializer.deserialize_any(ValueVisitor) ++ } ++} ++ ++struct WriterFormatter<'a, 'b: 'a> { ++ inner: &'a mut fmt::Formatter<'b>, ++} ++ ++impl<'a, 'b> io::Write for WriterFormatter<'a, 'b> { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ fn io_error(_: E) -> io::Error { ++ // Value does not matter because fmt::Debug and fmt::Display impls ++ // below just map it to fmt::Error ++ io::Error::new(io::ErrorKind::Other, "fmt error") ++ } ++ let s = try!(str::from_utf8(buf).map_err(io_error)); ++ try!(self.inner.write_str(s).map_err(io_error)); ++ Ok(buf.len()) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ Ok(()) ++ } ++} ++ ++impl fmt::Display for Value { ++ /// Display a JSON value as a string. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let json = json!({ "city": "London", "street": "10 Downing Street" }); ++ /// ++ /// // Compact format: ++ /// // ++ /// // {"city":"London","street":"10 Downing Street"} ++ /// let compact = format!("{}", json); ++ /// assert_eq!(compact, ++ /// "{\"city\":\"London\",\"street\":\"10 Downing Street\"}"); ++ /// ++ /// // Pretty format: ++ /// // ++ /// // { ++ /// // "city": "London", ++ /// // "street": "10 Downing Street" ++ /// // } ++ /// let pretty = format!("{:#}", json); ++ /// assert_eq!(pretty, ++ /// "{\n \"city\": \"London\",\n \"street\": \"10 Downing Street\"\n}"); ++ /// # } ++ /// ``` ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ let alternate = f.alternate(); ++ let mut wr = WriterFormatter { inner: f }; ++ if alternate { ++ // {:#} ++ super::super::ser::to_writer_pretty(&mut wr, self).map_err(|_| fmt::Error) ++ } else { ++ // {} ++ super::super::ser::to_writer(&mut wr, self).map_err(|_| fmt::Error) ++ } ++ } ++} ++ ++impl str::FromStr for Value { ++ type Err = Error; ++ fn from_str(s: &str) -> Result { ++ super::super::de::from_str(s) ++ } ++} ++ ++impl<'de> serde::Deserializer<'de> for Value { ++ type Error = Error; ++ ++ #[inline] ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match self { ++ Value::Null => visitor.visit_unit(), ++ Value::Bool(v) => visitor.visit_bool(v), ++ Value::Number(n) => n.deserialize_any(visitor), ++ Value::String(v) => visitor.visit_string(v), ++ Value::Array(v) => { ++ let len = v.len(); ++ let mut deserializer = SeqDeserializer::new(v); ++ let seq = try!(visitor.visit_seq(&mut deserializer)); ++ let remaining = deserializer.iter.len(); ++ if remaining == 0 { ++ Ok(seq) ++ } else { ++ Err(serde::de::Error::invalid_length(len, &"fewer elements in array")) ++ } ++ } ++ Value::Object(v) => { ++ let len = v.len(); ++ let mut deserializer = MapDeserializer::new(v); ++ let map = try!(visitor.visit_map(&mut deserializer)); ++ let remaining = deserializer.iter.len(); ++ if remaining == 0 { ++ Ok(map) ++ } else { ++ Err(serde::de::Error::invalid_length(len, &"fewer elements in map")) ++ } ++ } ++ } ++ } ++ ++ #[inline] ++ fn deserialize_option(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match self { ++ Value::Null => visitor.visit_none(), ++ _ => visitor.visit_some(self), ++ } ++ } ++ ++ #[inline] ++ fn deserialize_enum( ++ self, ++ _name: &str, ++ _variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ let (variant, value) = match self { ++ Value::Object(value) => { ++ let mut iter = value.into_iter(); ++ let (variant, value) = match iter.next() { ++ Some(v) => v, ++ None => { ++ return Err( ++ serde::de::Error::invalid_value( ++ Unexpected::Map, ++ &"map with a single key", ++ ), ++ ); ++ } ++ }; ++ // enums are encoded in json as maps with a single key:value pair ++ if iter.next().is_some() { ++ return Err(serde::de::Error::invalid_value(Unexpected::Map, &"map with a single key"),); ++ } ++ (variant, Some(value)) ++ } ++ Value::String(variant) => (variant, None), ++ other => { ++ return Err(serde::de::Error::invalid_type(other.unexpected(), &"string or map"),); ++ } ++ }; ++ ++ visitor.visit_enum( ++ EnumDeserializer { ++ variant: variant, ++ value: value, ++ }, ++ ) ++ } ++ ++ #[inline] ++ fn deserialize_newtype_struct( ++ self, ++ _name: &'static str, ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ visitor.visit_newtype_struct(self) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf unit unit_struct seq tuple tuple_struct map struct identifier ++ ignored_any ++ } ++} ++ ++struct EnumDeserializer { ++ variant: String, ++ value: Option, ++} ++ ++impl<'de> EnumAccess<'de> for EnumDeserializer { ++ type Error = Error; ++ type Variant = VariantDeserializer; ++ ++ fn variant_seed(self, seed: V) -> Result<(V::Value, VariantDeserializer), Error> ++ where ++ V: DeserializeSeed<'de>, ++ { ++ let variant = self.variant.into_deserializer(); ++ let visitor = VariantDeserializer { value: self.value }; ++ seed.deserialize(variant).map(|v| (v, visitor)) ++ } ++} ++ ++struct VariantDeserializer { ++ value: Option, ++} ++ ++impl<'de> VariantAccess<'de> for VariantDeserializer { ++ type Error = Error; ++ ++ fn unit_variant(self) -> Result<(), Error> { ++ match self.value { ++ Some(value) => Deserialize::deserialize(value), ++ None => Ok(()), ++ } ++ } ++ ++ fn newtype_variant_seed(self, seed: T) -> Result ++ where ++ T: DeserializeSeed<'de>, ++ { ++ match self.value { ++ Some(value) => seed.deserialize(value), ++ None => Err(serde::de::Error::invalid_type(Unexpected::UnitVariant, &"newtype variant"),), ++ } ++ } ++ ++ fn tuple_variant(self, _len: usize, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match self.value { ++ Some(Value::Array(v)) => { ++ serde::Deserializer::deserialize_any(SeqDeserializer::new(v), visitor) ++ } ++ Some(other) => Err(serde::de::Error::invalid_type(other.unexpected(), &"tuple variant"),), ++ None => Err(serde::de::Error::invalid_type(Unexpected::UnitVariant, &"tuple variant"),), ++ } ++ } ++ ++ fn struct_variant( ++ self, ++ _fields: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match self.value { ++ Some(Value::Object(v)) => { ++ serde::Deserializer::deserialize_any(MapDeserializer::new(v), visitor) ++ } ++ Some(other) => Err(serde::de::Error::invalid_type(other.unexpected(), &"struct variant"),), ++ _ => Err(serde::de::Error::invalid_type(Unexpected::UnitVariant, &"struct variant"),), ++ } ++ } ++} ++ ++struct SeqDeserializer { ++ iter: vec::IntoIter, ++} ++ ++impl SeqDeserializer { ++ fn new(vec: Vec) -> Self { ++ SeqDeserializer { iter: vec.into_iter() } ++ } ++} ++ ++impl<'de> serde::Deserializer<'de> for SeqDeserializer { ++ type Error = Error; ++ ++ #[inline] ++ fn deserialize_any(mut self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ let len = self.iter.len(); ++ if len == 0 { ++ visitor.visit_unit() ++ } else { ++ let ret = try!(visitor.visit_seq(&mut self)); ++ let remaining = self.iter.len(); ++ if remaining == 0 { ++ Ok(ret) ++ } else { ++ Err(serde::de::Error::invalid_length(len, &"fewer elements in array")) ++ } ++ } ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++} ++ ++impl<'de> SeqAccess<'de> for SeqDeserializer { ++ type Error = Error; ++ ++ fn next_element_seed(&mut self, seed: T) -> Result, Error> ++ where ++ T: DeserializeSeed<'de>, ++ { ++ match self.iter.next() { ++ Some(value) => seed.deserialize(value).map(Some), ++ None => Ok(None), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ match self.iter.size_hint() { ++ (lower, Some(upper)) if lower == upper => Some(upper), ++ _ => None, ++ } ++ } ++} ++ ++struct MapDeserializer { ++ iter: as IntoIterator>::IntoIter, ++ value: Option, ++} ++ ++impl MapDeserializer { ++ fn new(map: Map) -> Self { ++ MapDeserializer { ++ iter: map.into_iter(), ++ value: None, ++ } ++ } ++} ++ ++impl<'de> MapAccess<'de> for MapDeserializer { ++ type Error = Error; ++ ++ fn next_key_seed(&mut self, seed: T) -> Result, Error> ++ where ++ T: DeserializeSeed<'de>, ++ { ++ match self.iter.next() { ++ Some((key, value)) => { ++ self.value = Some(value); ++ let key_de = MapKeyDeserializer { key: Cow::Owned(key) }; ++ seed.deserialize(key_de).map(Some) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ fn next_value_seed(&mut self, seed: T) -> Result ++ where ++ T: DeserializeSeed<'de>, ++ { ++ match self.value.take() { ++ Some(value) => seed.deserialize(value), ++ None => Err(serde::de::Error::custom("value is missing")), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ match self.iter.size_hint() { ++ (lower, Some(upper)) if lower == upper => Some(upper), ++ _ => None, ++ } ++ } ++} ++ ++impl<'de> serde::Deserializer<'de> for MapDeserializer { ++ type Error = Error; ++ ++ #[inline] ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ visitor.visit_map(self) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++} ++ ++impl<'de> serde::Deserializer<'de> for &'de Value { ++ type Error = Error; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match *self { ++ Value::Null => visitor.visit_unit(), ++ Value::Bool(v) => visitor.visit_bool(v), ++ Value::Number(ref n) => n.deserialize_any(visitor), ++ Value::String(ref v) => visitor.visit_borrowed_str(v), ++ Value::Array(ref v) => { ++ let len = v.len(); ++ let mut deserializer = SeqRefDeserializer::new(v); ++ let seq = try!(visitor.visit_seq(&mut deserializer)); ++ let remaining = deserializer.iter.len(); ++ if remaining == 0 { ++ Ok(seq) ++ } else { ++ Err(serde::de::Error::invalid_length(len, &"fewer elements in array")) ++ } ++ } ++ Value::Object(ref v) => { ++ let len = v.len(); ++ let mut deserializer = MapRefDeserializer::new(v); ++ let map = try!(visitor.visit_map(&mut deserializer)); ++ let remaining = deserializer.iter.len(); ++ if remaining == 0 { ++ Ok(map) ++ } else { ++ Err(serde::de::Error::invalid_length(len, &"fewer elements in map")) ++ } ++ } ++ } ++ } ++ ++ fn deserialize_option(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match *self { ++ Value::Null => visitor.visit_none(), ++ _ => visitor.visit_some(self), ++ } ++ } ++ ++ fn deserialize_enum( ++ self, ++ _name: &str, ++ _variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ let (variant, value) = match *self { ++ Value::Object(ref value) => { ++ let mut iter = value.into_iter(); ++ let (variant, value) = match iter.next() { ++ Some(v) => v, ++ None => { ++ return Err( ++ serde::de::Error::invalid_value( ++ Unexpected::Map, ++ &"map with a single key", ++ ), ++ ); ++ } ++ }; ++ // enums are encoded in json as maps with a single key:value pair ++ if iter.next().is_some() { ++ return Err(serde::de::Error::invalid_value(Unexpected::Map, &"map with a single key"),); ++ } ++ (variant, Some(value)) ++ } ++ Value::String(ref variant) => (variant, None), ++ ref other => { ++ return Err(serde::de::Error::invalid_type(other.unexpected(), &"string or map"),); ++ } ++ }; ++ ++ visitor.visit_enum( ++ EnumRefDeserializer { ++ variant: variant, ++ value: value, ++ }, ++ ) ++ } ++ ++ #[inline] ++ fn deserialize_newtype_struct( ++ self, ++ _name: &'static str, ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ visitor.visit_newtype_struct(self) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf unit unit_struct seq tuple tuple_struct map struct identifier ++ ignored_any ++ } ++} ++ ++struct EnumRefDeserializer<'de> { ++ variant: &'de str, ++ value: Option<&'de Value>, ++} ++ ++impl<'de> EnumAccess<'de> for EnumRefDeserializer<'de> { ++ type Error = Error; ++ type Variant = VariantRefDeserializer<'de>; ++ ++ fn variant_seed(self, seed: V) -> Result<(V::Value, Self::Variant), Error> ++ where ++ V: DeserializeSeed<'de>, ++ { ++ let variant = self.variant.into_deserializer(); ++ let visitor = VariantRefDeserializer { value: self.value }; ++ seed.deserialize(variant).map(|v| (v, visitor)) ++ } ++} ++ ++struct VariantRefDeserializer<'de> { ++ value: Option<&'de Value>, ++} ++ ++impl<'de> VariantAccess<'de> for VariantRefDeserializer<'de> { ++ type Error = Error; ++ ++ fn unit_variant(self) -> Result<(), Error> { ++ match self.value { ++ Some(value) => Deserialize::deserialize(value), ++ None => Ok(()), ++ } ++ } ++ ++ fn newtype_variant_seed(self, seed: T) -> Result ++ where ++ T: DeserializeSeed<'de>, ++ { ++ match self.value { ++ Some(value) => seed.deserialize(value), ++ None => Err(serde::de::Error::invalid_type(Unexpected::UnitVariant, &"newtype variant"),), ++ } ++ } ++ ++ fn tuple_variant(self, _len: usize, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match self.value { ++ Some(&Value::Array(ref v)) => { ++ serde::Deserializer::deserialize_any(SeqRefDeserializer::new(v), visitor) ++ } ++ Some(other) => Err(serde::de::Error::invalid_type(other.unexpected(), &"tuple variant"),), ++ None => Err(serde::de::Error::invalid_type(Unexpected::UnitVariant, &"tuple variant"),), ++ } ++ } ++ ++ fn struct_variant( ++ self, ++ _fields: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match self.value { ++ Some(&Value::Object(ref v)) => { ++ serde::Deserializer::deserialize_any(MapRefDeserializer::new(v), visitor) ++ } ++ Some(other) => Err(serde::de::Error::invalid_type(other.unexpected(), &"struct variant"),), ++ _ => Err(serde::de::Error::invalid_type(Unexpected::UnitVariant, &"struct variant"),), ++ } ++ } ++} ++ ++struct SeqRefDeserializer<'de> { ++ iter: slice::Iter<'de, Value>, ++} ++ ++impl<'de> SeqRefDeserializer<'de> { ++ fn new(slice: &'de [Value]) -> Self { ++ SeqRefDeserializer { iter: slice.iter() } ++ } ++} ++ ++impl<'de> serde::Deserializer<'de> for SeqRefDeserializer<'de> { ++ type Error = Error; ++ ++ #[inline] ++ fn deserialize_any(mut self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ let len = self.iter.len(); ++ if len == 0 { ++ visitor.visit_unit() ++ } else { ++ let ret = try!(visitor.visit_seq(&mut self)); ++ let remaining = self.iter.len(); ++ if remaining == 0 { ++ Ok(ret) ++ } else { ++ Err(serde::de::Error::invalid_length(len, &"fewer elements in array")) ++ } ++ } ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++} ++ ++impl<'de> SeqAccess<'de> for SeqRefDeserializer<'de> { ++ type Error = Error; ++ ++ fn next_element_seed(&mut self, seed: T) -> Result, Error> ++ where ++ T: DeserializeSeed<'de>, ++ { ++ match self.iter.next() { ++ Some(value) => seed.deserialize(value).map(Some), ++ None => Ok(None), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ match self.iter.size_hint() { ++ (lower, Some(upper)) if lower == upper => Some(upper), ++ _ => None, ++ } ++ } ++} ++ ++struct MapRefDeserializer<'de> { ++ iter: <&'de Map as IntoIterator>::IntoIter, ++ value: Option<&'de Value>, ++} ++ ++impl<'de> MapRefDeserializer<'de> { ++ fn new(map: &'de Map) -> Self { ++ MapRefDeserializer { ++ iter: map.into_iter(), ++ value: None, ++ } ++ } ++} ++ ++impl<'de> MapAccess<'de> for MapRefDeserializer<'de> { ++ type Error = Error; ++ ++ fn next_key_seed(&mut self, seed: T) -> Result, Error> ++ where ++ T: DeserializeSeed<'de>, ++ { ++ match self.iter.next() { ++ Some((key, value)) => { ++ self.value = Some(value); ++ let key_de = MapKeyDeserializer { key: Cow::Borrowed(&**key) }; ++ seed.deserialize(key_de).map(Some) ++ } ++ None => Ok(None), ++ } ++ } ++ ++ fn next_value_seed(&mut self, seed: T) -> Result ++ where ++ T: DeserializeSeed<'de>, ++ { ++ match self.value.take() { ++ Some(value) => seed.deserialize(value), ++ None => Err(serde::de::Error::custom("value is missing")), ++ } ++ } ++ ++ fn size_hint(&self) -> Option { ++ match self.iter.size_hint() { ++ (lower, Some(upper)) if lower == upper => Some(upper), ++ _ => None, ++ } ++ } ++} ++ ++impl<'de> serde::Deserializer<'de> for MapRefDeserializer<'de> { ++ type Error = Error; ++ ++ #[inline] ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ visitor.visit_map(self) ++ } ++ ++ forward_to_deserialize_any! { ++ bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes ++ byte_buf option unit unit_struct newtype_struct seq tuple ++ tuple_struct map struct enum identifier ignored_any ++ } ++} ++ ++struct MapKeyDeserializer<'de> { ++ key: Cow<'de, str>, ++} ++ ++macro_rules! deserialize_integer_key { ++ ($deserialize:ident => $visit:ident) => { ++ fn $deserialize(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ match (self.key.parse(), self.key) { ++ (Ok(integer), _) => visitor.$visit(integer), ++ (Err(_), Cow::Borrowed(s)) => visitor.visit_borrowed_str(s), ++ (Err(_), Cow::Owned(s)) => visitor.visit_string(s), ++ } ++ } ++ } ++} ++ ++impl<'de> serde::Deserializer<'de> for MapKeyDeserializer<'de> { ++ type Error = Error; ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ self.key.into_deserializer().deserialize_any(visitor) ++ } ++ ++ deserialize_integer_key!(deserialize_i8 => visit_i8); ++ deserialize_integer_key!(deserialize_i16 => visit_i16); ++ deserialize_integer_key!(deserialize_i32 => visit_i32); ++ deserialize_integer_key!(deserialize_i64 => visit_i64); ++ deserialize_integer_key!(deserialize_u8 => visit_u8); ++ deserialize_integer_key!(deserialize_u16 => visit_u16); ++ deserialize_integer_key!(deserialize_u32 => visit_u32); ++ deserialize_integer_key!(deserialize_u64 => visit_u64); ++ ++ #[inline] ++ fn deserialize_option(self, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ // Map keys cannot be null. ++ visitor.visit_some(self) ++ } ++ ++ #[inline] ++ fn deserialize_newtype_struct(self, _name: &'static str, visitor: V) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ visitor.visit_newtype_struct(self) ++ } ++ ++ fn deserialize_enum( ++ self, ++ name: &'static str, ++ variants: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: Visitor<'de>, ++ { ++ self.key.into_deserializer().deserialize_enum(name, variants, visitor) ++ } ++ ++ forward_to_deserialize_any! { ++ bool f32 f64 char str string bytes byte_buf unit unit_struct seq tuple ++ tuple_struct map struct identifier ignored_any ++ } ++} ++ ++impl Value { ++ fn unexpected(&self) -> Unexpected { ++ match *self { ++ Value::Null => Unexpected::Unit, ++ Value::Bool(b) => Unexpected::Bool(b), ++ Value::Number(ref n) => n.unexpected(), ++ Value::String(ref s) => Unexpected::Str(s), ++ Value::Array(_) => Unexpected::Seq, ++ Value::Object(_) => Unexpected::Map, ++ } ++ } ++} diff --cc vendor/serde_json-1.0.3/src/value/from.rs index 000000000,000000000..30032acee new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/value/from.rs @@@ -1,0 -1,0 +1,268 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::borrow::Cow; ++ ++use super::Value; ++use map::Map; ++use number::Number; ++ ++macro_rules! from_integer { ++ ($($ty:ident)*) => { ++ $( ++ impl From<$ty> for Value { ++ fn from(n: $ty) -> Self { ++ Value::Number(n.into()) ++ } ++ } ++ )* ++ }; ++} ++ ++from_integer! { ++ i8 i16 i32 i64 isize ++ u8 u16 u32 u64 usize ++} ++ ++impl From for Value { ++ /// Convert 32-bit floating point number to `Value` ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// ++ /// let f: f32 = 13.37; ++ /// let x: Value = f.into(); ++ /// # } ++ /// ``` ++ fn from(f: f32) -> Self { ++ From::from(f as f64) ++ } ++} ++ ++impl From for Value { ++ /// Convert 64-bit floating point number to `Value` ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// ++ /// let f: f64 = 13.37; ++ /// let x: Value = f.into(); ++ /// # } ++ /// ``` ++ fn from(f: f64) -> Self { ++ Number::from_f64(f).map_or(Value::Null, Value::Number) ++ } ++} ++ ++impl From for Value { ++ /// Convert boolean to `Value` ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// ++ /// let b = false; ++ /// let x: Value = b.into(); ++ /// # } ++ /// ``` ++ fn from(f: bool) -> Self { ++ Value::Bool(f) ++ } ++} ++ ++impl From for Value { ++ /// Convert `String` to `Value` ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// ++ /// let s: String = "lorem".to_string(); ++ /// let x: Value = s.into(); ++ /// # } ++ /// ``` ++ fn from(f: String) -> Self { ++ Value::String(f) ++ } ++} ++ ++impl<'a> From<&'a str> for Value { ++ /// Convert string slice to `Value` ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// ++ /// let s: &str = "lorem"; ++ /// let x: Value = s.into(); ++ /// # } ++ /// ``` ++ fn from(f: &str) -> Self { ++ Value::String(f.to_string()) ++ } ++} ++ ++impl<'a> From> for Value { ++ /// Convert copy-on-write string to `Value` ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// use std::borrow::Cow; ++ /// ++ /// let s: Cow = Cow::Borrowed("lorem"); ++ /// let x: Value = s.into(); ++ /// # } ++ /// ``` ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// use std::borrow::Cow; ++ /// ++ /// let s: Cow = Cow::Owned("lorem".to_string()); ++ /// let x: Value = s.into(); ++ /// # } ++ /// ``` ++ fn from(f: Cow<'a, str>) -> Self { ++ Value::String(f.to_string()) ++ } ++} ++ ++impl From> for Value { ++ /// Convert map (with string keys) to `Value` ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::{Map, Value}; ++ /// ++ /// let mut m = Map::new(); ++ /// m.insert("Lorem".to_string(), "ipsum".into()); ++ /// let x: Value = m.into(); ++ /// # } ++ /// ``` ++ fn from(f: Map) -> Self { ++ Value::Object(f) ++ } ++} ++ ++impl> From> for Value { ++ /// Convert a `Vec` to `Value` ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// ++ /// let v = vec!["lorem", "ipsum", "dolor"]; ++ /// let x: Value = v.into(); ++ /// # } ++ /// ``` ++ fn from(f: Vec) -> Self { ++ Value::Array(f.into_iter().map(Into::into).collect()) ++ } ++} ++ ++impl<'a, T: Clone + Into> From<&'a [T]> for Value { ++ /// Convert a slice to `Value` ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// ++ /// let v: &[&str] = &["lorem", "ipsum", "dolor"]; ++ /// let x: Value = v.into(); ++ /// # } ++ /// ``` ++ fn from(f: &'a [T]) -> Self { ++ Value::Array(f.into_iter().cloned().map(Into::into).collect()) ++ } ++} ++ ++impl> ::std::iter::FromIterator for Value { ++ /// Convert an iteratable type to a `Value` ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// ++ /// let v = std::iter::repeat(42).take(5); ++ /// let x: Value = v.collect(); ++ /// # } ++ /// ``` ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use serde_json::Value; ++ /// ++ /// let v: Vec<_> = vec!["lorem", "ipsum", "dolor"]; ++ /// let x: Value = v.into_iter().collect(); ++ /// # } ++ /// ``` ++ /// ++ /// ```rust ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// use std::iter::FromIterator; ++ /// use serde_json::Value; ++ /// ++ /// let x: Value = Value::from_iter(vec!["lorem", "ipsum", "dolor"]); ++ /// # } ++ /// ``` ++ fn from_iter>(iter: I) -> Self { ++ let vec: Vec = iter.into_iter().map(|x| x.into()).collect(); ++ ++ Value::Array(vec) ++ } ++} diff --cc vendor/serde_json-1.0.3/src/value/index.rs index 000000000,000000000..761d8faf6 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/value/index.rs @@@ -1,0 -1,0 +1,259 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::fmt; ++use std::ops; ++ ++use super::Value; ++use map::Map; ++ ++/// A type that can be used to index into a `serde_json::Value`. See the `get` ++/// and `get_mut` methods of `Value`. ++/// ++/// This trait is sealed and cannot be implemented for types outside of ++/// `serde_json`. ++pub trait Index: private::Sealed { ++ /// Return None if the key is not already in the array or object. ++ #[doc(hidden)] ++ fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value>; ++ ++ /// Return None if the key is not already in the array or object. ++ #[doc(hidden)] ++ fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value>; ++ ++ /// Panic if array index out of bounds. If key is not already in the object, ++ /// insert it with a value of null. Panic if Value is a type that cannot be ++ /// indexed into, except if Value is null then it can be treated as an empty ++ /// object. ++ #[doc(hidden)] ++ fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value; ++} ++ ++impl Index for usize { ++ fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value> { ++ match *v { ++ Value::Array(ref vec) => vec.get(*self), ++ _ => None, ++ } ++ } ++ fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value> { ++ match *v { ++ Value::Array(ref mut vec) => vec.get_mut(*self), ++ _ => None, ++ } ++ } ++ fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value { ++ match *v { ++ Value::Array(ref mut vec) => { ++ let len = vec.len(); ++ vec.get_mut(*self) ++ .unwrap_or_else( ++ || { ++ panic!( ++ "cannot access index {} of JSON array of length {}", ++ self, ++ len ++ ) ++ }, ++ ) ++ } ++ _ => panic!("cannot access index {} of JSON {}", self, Type(v)), ++ } ++ } ++} ++ ++impl Index for str { ++ fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value> { ++ match *v { ++ Value::Object(ref map) => map.get(self), ++ _ => None, ++ } ++ } ++ fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value> { ++ match *v { ++ Value::Object(ref mut map) => map.get_mut(self), ++ _ => None, ++ } ++ } ++ fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value { ++ if let Value::Null = *v { ++ let mut map = Map::new(); ++ map.insert(self.to_owned(), Value::Null); ++ *v = Value::Object(map); ++ } ++ match *v { ++ Value::Object(ref mut map) => { ++ map.entry(self.to_owned()).or_insert(Value::Null) ++ } ++ _ => panic!("cannot access key {:?} in JSON {}", self, Type(v)), ++ } ++ } ++} ++ ++impl Index for String { ++ fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value> { ++ self[..].index_into(v) ++ } ++ fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value> { ++ self[..].index_into_mut(v) ++ } ++ fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value { ++ self[..].index_or_insert(v) ++ } ++} ++ ++impl<'a, T: ?Sized> Index for &'a T ++where ++ T: Index, ++{ ++ fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value> { ++ (**self).index_into(v) ++ } ++ fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value> { ++ (**self).index_into_mut(v) ++ } ++ fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value { ++ (**self).index_or_insert(v) ++ } ++} ++ ++// Prevent users from implementing the Index trait. ++mod private { ++ pub trait Sealed {} ++ impl Sealed for usize {} ++ impl Sealed for str {} ++ impl Sealed for String {} ++ impl<'a, T: ?Sized> Sealed for &'a T ++ where ++ T: Sealed, ++ { ++ } ++} ++ ++/// Used in panic messages. ++struct Type<'a>(&'a Value); ++ ++impl<'a> fmt::Display for Type<'a> { ++ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { ++ match *self.0 { ++ Value::Null => formatter.write_str("null"), ++ Value::Bool(_) => formatter.write_str("boolean"), ++ Value::Number(_) => formatter.write_str("number"), ++ Value::String(_) => formatter.write_str("string"), ++ Value::Array(_) => formatter.write_str("array"), ++ Value::Object(_) => formatter.write_str("object"), ++ } ++ } ++} ++ ++// The usual semantics of Index is to panic on invalid indexing. ++// ++// That said, the usual semantics are for things like Vec and BTreeMap which ++// have different use cases than Value. If you are working with a Vec, you know ++// that you are working with a Vec and you can get the len of the Vec and make ++// sure your indices are within bounds. The Value use cases are more ++// loosey-goosey. You got some JSON from an endpoint and you want to pull values ++// out of it. Outside of this Index impl, you already have the option of using ++// value.as_array() and working with the Vec directly, or matching on ++// Value::Array and getting the Vec directly. The Index impl means you can skip ++// that and index directly into the thing using a concise syntax. You don't have ++// to check the type, you don't have to check the len, it is all about what you ++// expect the Value to look like. ++// ++// Basically the use cases that would be well served by panicking here are ++// better served by using one of the other approaches: get and get_mut, ++// as_array, or match. The value of this impl is that it adds a way of working ++// with Value that is not well served by the existing approaches: concise and ++// careless and sometimes that is exactly what you want. ++impl ops::Index for Value ++where ++ I: Index, ++{ ++ type Output = Value; ++ ++ /// Index into a `serde_json::Value` using the syntax `value[0]` or ++ /// `value["k"]`. ++ /// ++ /// Returns `Value::Null` if the type of `self` does not match the type of ++ /// the index, for example if the index is a string and `self` is an array ++ /// or a number. Also returns `Value::Null` if the given key does not exist ++ /// in the map or the given index is not within the bounds of the array. ++ /// ++ /// For retrieving deeply nested values, you should have a look at the ++ /// `Value::pointer` method. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let data = json!({ ++ /// "x": { ++ /// "y": ["z", "zz"] ++ /// } ++ /// }); ++ /// ++ /// assert_eq!(data["x"]["y"], json!(["z", "zz"])); ++ /// assert_eq!(data["x"]["y"][0], json!("z")); ++ /// ++ /// assert_eq!(data["a"], json!(null)); // returns null for undefined values ++ /// assert_eq!(data["a"]["b"], json!(null)); // does not panic ++ /// # } ++ /// ``` ++ fn index(&self, index: I) -> &Value { ++ static NULL: Value = Value::Null; ++ index.index_into(self).unwrap_or(&NULL) ++ } ++} ++ ++impl ops::IndexMut for Value ++where ++ I: Index, ++{ ++ /// Write into a `serde_json::Value` using the syntax `value[0] = ...` or ++ /// `value["k"] = ...`. ++ /// ++ /// If the index is a number, the value must be an array of length bigger ++ /// than the index. Indexing into a value that is not an array or an array ++ /// that is too small will panic. ++ /// ++ /// If the index is a string, the value must be an object or null which is ++ /// treated like an empty object. If the key is not already present in the ++ /// object, it will be inserted with a value of null. Indexing into a value ++ /// that is neither an object nor null will panic. ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let mut data = json!({ "x": 0 }); ++ /// ++ /// // replace an existing key ++ /// data["x"] = json!(1); ++ /// ++ /// // insert a new key ++ /// data["y"] = json!([false, false, false]); ++ /// ++ /// // replace an array value ++ /// data["y"][0] = json!(true); ++ /// ++ /// // inserted a deeply nested key ++ /// data["a"]["b"]["c"]["d"] = json!(true); ++ /// ++ /// println!("{}", data); ++ /// # } ++ /// ``` ++ fn index_mut(&mut self, index: I) -> &mut Value { ++ index.index_or_insert(self) ++ } ++} diff --cc vendor/serde_json-1.0.3/src/value/mod.rs index 000000000,000000000..095915ed1 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/value/mod.rs @@@ -1,0 -1,0 +1,1029 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! The Value enum, a loosely typed way of representing any valid JSON value. ++//! ++//! # Constructing JSON ++//! ++//! Serde JSON provides a [`json!` macro][macro] to build `serde_json::Value` ++//! objects with very natural JSON syntax. In order to use this macro, ++//! `serde_json` needs to be imported with the `#[macro_use]` attribute. ++//! ++//! ```rust ++//! #[macro_use] ++//! extern crate serde_json; ++//! ++//! fn main() { ++//! // The type of `john` is `serde_json::Value` ++//! let john = json!({ ++//! "name": "John Doe", ++//! "age": 43, ++//! "phones": [ ++//! "+44 1234567", ++//! "+44 2345678" ++//! ] ++//! }); ++//! ++//! println!("first phone number: {}", john["phones"][0]); ++//! ++//! // Convert to a string of JSON and print it out ++//! println!("{}", john.to_string()); ++//! } ++//! ``` ++//! ++//! The `Value::to_string()` function converts a `serde_json::Value` into a ++//! `String` of JSON text. ++//! ++//! One neat thing about the `json!` macro is that variables and expressions can ++//! be interpolated directly into the JSON value as you are building it. Serde ++//! will check at compile time that the value you are interpolating is able to ++//! be represented as JSON. ++//! ++//! ```rust ++//! # #[macro_use] ++//! # extern crate serde_json; ++//! # ++//! # fn random_phone() -> u16 { 0 } ++//! # ++//! # fn main() { ++//! let full_name = "John Doe"; ++//! let age_last_year = 42; ++//! ++//! // The type of `john` is `serde_json::Value` ++//! let john = json!({ ++//! "name": full_name, ++//! "age": age_last_year + 1, ++//! "phones": [ ++//! format!("+44 {}", random_phone()) ++//! ] ++//! }); ++//! # let _ = john; ++//! # } ++//! ``` ++//! ++//! A string of JSON data can be parsed into a `serde_json::Value` by the ++//! [`serde_json::from_str`][from_str] function. There is also ++//! [`from_slice`][from_slice] for parsing from a byte slice &[u8] and ++//! [`from_reader`][from_reader] for parsing from any `io::Read` like a File or ++//! a TCP stream. ++//! ++//! ```rust ++//! extern crate serde_json; ++//! ++//! use serde_json::{Value, Error}; ++//! ++//! fn untyped_example() -> Result<(), Error> { ++//! // Some JSON input data as a &str. Maybe this comes from the user. ++//! let data = r#"{ ++//! "name": "John Doe", ++//! "age": 43, ++//! "phones": [ ++//! "+44 1234567", ++//! "+44 2345678" ++//! ] ++//! }"#; ++//! ++//! // Parse the string of data into serde_json::Value. ++//! let v: Value = serde_json::from_str(data)?; ++//! ++//! // Access parts of the data by indexing with square brackets. ++//! println!("Please call {} at the number {}", v["name"], v["phones"][0]); ++//! ++//! Ok(()) ++//! } ++//! # ++//! # fn main() { ++//! # untyped_example().unwrap(); ++//! # } ++//! ``` ++//! ++//! [macro]: https://docs.serde.rs/serde_json/macro.json.html ++//! [from_str]: https://docs.serde.rs/serde_json/de/fn.from_str.html ++//! [from_slice]: https://docs.serde.rs/serde_json/de/fn.from_slice.html ++//! [from_reader]: https://docs.serde.rs/serde_json/de/fn.from_reader.html ++ ++use std::i64; ++use std::str; ++ ++use serde::ser::Serialize; ++use serde::de::DeserializeOwned; ++ ++use error::Error; ++pub use map::Map; ++pub use number::Number; ++ ++pub use self::index::Index; ++ ++use self::ser::Serializer; ++ ++/// Represents any valid JSON value. ++/// ++/// See the `serde_json::value` module documentation for usage examples. ++#[derive(Debug, Clone, PartialEq)] ++pub enum Value { ++ /// Represents a JSON null value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!(null); ++ /// # } ++ /// ``` ++ Null, ++ ++ /// Represents a JSON boolean. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!(true); ++ /// # } ++ /// ``` ++ Bool(bool), ++ ++ /// Represents a JSON number, whether integer or floating point. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!(12.5); ++ /// # } ++ /// ``` ++ Number(Number), ++ ++ /// Represents a JSON string. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!("a string"); ++ /// # } ++ /// ``` ++ String(String), ++ ++ /// Represents a JSON array. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!(["an", "array"]); ++ /// # } ++ /// ``` ++ Array(Vec), ++ ++ /// Represents a JSON object. ++ /// ++ /// By default the map is backed by a BTreeMap. Enable the `preserve_order` ++ /// feature of serde_json to use LinkedHashMap instead, which preserves ++ /// entries in the order they are inserted into the map. In particular, this ++ /// allows JSON data to be deserialized into a Value and serialized to a ++ /// string while retaining the order of map keys in the input. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "an": "object" }); ++ /// # } ++ /// ``` ++ Object(Map), ++} ++ ++fn parse_index(s: &str) -> Option { ++ if s.starts_with('+') || (s.starts_with('0') && s.len() != 1) { ++ return None; ++ } ++ s.parse().ok() ++} ++ ++impl Value { ++ /// Index into a JSON array or map. A string index can be used to access a ++ /// value in a map, and a usize index can be used to access an element of an ++ /// array. ++ /// ++ /// Returns `None` if the type of `self` does not match the type of the ++ /// index, for example if the index is a string and `self` is an array or a ++ /// number. Also returns `None` if the given key does not exist in the map ++ /// or the given index is not within the bounds of the array. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let object = json!({ "A": 65, "B": 66, "C": 67 }); ++ /// assert_eq!(*object.get("A").unwrap(), json!(65)); ++ /// ++ /// let array = json!([ "A", "B", "C" ]); ++ /// assert_eq!(*array.get(2).unwrap(), json!("C")); ++ /// ++ /// assert_eq!(array.get("A"), None); ++ /// # } ++ /// ``` ++ /// ++ /// Square brackets can also be used to index into a value in a more concise ++ /// way. This returns `Value::Null` in cases where `get` would have returned ++ /// `None`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let object = json!({ ++ /// "A": ["a", "á", "à"], ++ /// "B": ["b", "b́"], ++ /// "C": ["c", "ć", "ć̣", "ḉ"], ++ /// }); ++ /// assert_eq!(object["B"][0], json!("b")); ++ /// ++ /// assert_eq!(object["D"], json!(null)); ++ /// assert_eq!(object[0]["x"]["y"]["z"], json!(null)); ++ /// # } ++ /// ``` ++ pub fn get(&self, index: I) -> Option<&Value> { ++ index.index_into(self) ++ } ++ ++ /// Mutably index into a JSON array or map. A string index can be used to ++ /// access a value in a map, and a usize index can be used to access an ++ /// element of an array. ++ /// ++ /// Returns `None` if the type of `self` does not match the type of the ++ /// index, for example if the index is a string and `self` is an array or a ++ /// number. Also returns `None` if the given key does not exist in the map ++ /// or the given index is not within the bounds of the array. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let mut object = json!({ "A": 65, "B": 66, "C": 67 }); ++ /// *object.get_mut("A").unwrap() = json!(69); ++ /// ++ /// let mut array = json!([ "A", "B", "C" ]); ++ /// *array.get_mut(2).unwrap() = json!("D"); ++ /// # } ++ /// ``` ++ pub fn get_mut(&mut self, index: I) -> Option<&mut Value> { ++ index.index_into_mut(self) ++ } ++ ++ /// Returns true if the `Value` is an Object. Returns false otherwise. ++ /// ++ /// For any Value on which `is_object` returns true, `as_object` and ++ /// `as_object_mut` are guaranteed to return the map representation of the ++ /// object. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let obj = json!({ "a": { "nested": true }, "b": ["an", "array"] }); ++ /// ++ /// assert!(obj.is_object()); ++ /// assert!(obj["a"].is_object()); ++ /// ++ /// // array, not an object ++ /// assert!(!obj["b"].is_object()); ++ /// # } ++ /// ``` ++ pub fn is_object(&self) -> bool { ++ self.as_object().is_some() ++ } ++ ++ /// If the `Value` is an Object, returns the associated Map. Returns None ++ /// otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": { "nested": true }, "b": ["an", "array"] }); ++ /// ++ /// // The length of `{"nested": true}` is 1 entry. ++ /// assert_eq!(v["a"].as_object().unwrap().len(), 1); ++ /// ++ /// // The array `["an", "array"]` is not an object. ++ /// assert_eq!(v["b"].as_object(), None); ++ /// # } ++ /// ``` ++ pub fn as_object(&self) -> Option<&Map> { ++ match *self { ++ Value::Object(ref map) => Some(map), ++ _ => None, ++ } ++ } ++ ++ /// If the `Value` is an Object, returns the associated mutable Map. ++ /// Returns None otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let mut v = json!({ "a": { "nested": true } }); ++ /// ++ /// v["a"].as_object_mut().unwrap().clear(); ++ /// assert_eq!(v, json!({ "a": {} })); ++ /// # } ++ /// ++ /// ``` ++ pub fn as_object_mut(&mut self) -> Option<&mut Map> { ++ match *self { ++ Value::Object(ref mut map) => Some(map), ++ _ => None, ++ } ++ } ++ ++ /// Returns true if the `Value` is an Array. Returns false otherwise. ++ /// ++ /// For any Value on which `is_array` returns true, `as_array` and ++ /// `as_array_mut` are guaranteed to return the vector representing the ++ /// array. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let obj = json!({ "a": ["an", "array"], "b": { "an": "object" } }); ++ /// ++ /// assert!(obj["a"].is_array()); ++ /// ++ /// // an object, not an array ++ /// assert!(!obj["b"].is_array()); ++ /// # } ++ /// ``` ++ pub fn is_array(&self) -> bool { ++ self.as_array().is_some() ++ } ++ ++ /// If the `Value` is an Array, returns the associated vector. Returns None ++ /// otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": ["an", "array"], "b": { "an": "object" } }); ++ /// ++ /// // The length of `["an", "array"]` is 2 elements. ++ /// assert_eq!(v["a"].as_array().unwrap().len(), 2); ++ /// ++ /// // The object `{"an": "object"}` is not an array. ++ /// assert_eq!(v["b"].as_array(), None); ++ /// # } ++ /// ``` ++ pub fn as_array(&self) -> Option<&Vec> { ++ match *self { ++ Value::Array(ref array) => Some(&*array), ++ _ => None, ++ } ++ } ++ ++ /// If the `Value` is an Array, returns the associated mutable vector. ++ /// Returns None otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let mut v = json!({ "a": ["an", "array"] }); ++ /// ++ /// v["a"].as_array_mut().unwrap().clear(); ++ /// assert_eq!(v, json!({ "a": [] })); ++ /// # } ++ /// ``` ++ pub fn as_array_mut(&mut self) -> Option<&mut Vec> { ++ match *self { ++ Value::Array(ref mut list) => Some(list), ++ _ => None, ++ } ++ } ++ ++ /// Returns true if the `Value` is a String. Returns false otherwise. ++ /// ++ /// For any Value on which `is_string` returns true, `as_str` is guaranteed ++ /// to return the string slice. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": "some string", "b": false }); ++ /// ++ /// assert!(v["a"].is_string()); ++ /// ++ /// // The boolean `false` is not a string. ++ /// assert!(!v["b"].is_string()); ++ /// # } ++ /// ``` ++ pub fn is_string(&self) -> bool { ++ self.as_str().is_some() ++ } ++ ++ /// If the `Value` is a String, returns the associated str. Returns None ++ /// otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": "some string", "b": false }); ++ /// ++ /// assert_eq!(v["a"].as_str(), Some("some string")); ++ /// ++ /// // The boolean `false` is not a string. ++ /// assert_eq!(v["b"].as_str(), None); ++ /// # } ++ /// ``` ++ pub fn as_str(&self) -> Option<&str> { ++ match *self { ++ Value::String(ref s) => Some(s), ++ _ => None, ++ } ++ } ++ ++ /// Returns true if the `Value` is a Number. Returns false otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": 1, "b": "2" }); ++ /// ++ /// assert!(v["a"].is_number()); ++ /// ++ /// // The string `"2"` is a string, not a number. ++ /// assert!(!v["b"].is_number()); ++ /// # } ++ /// ``` ++ pub fn is_number(&self) -> bool { ++ match *self { ++ Value::Number(_) => true, ++ _ => false, ++ } ++ } ++ ++ /// Returns true if the `Value` is an integer between `i64::MIN` and ++ /// `i64::MAX`. ++ /// ++ /// For any Value on which `is_i64` returns true, `as_i64` is guaranteed to ++ /// return the integer value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # use std::i64; ++ /// # ++ /// # fn main() { ++ /// let big = i64::MAX as u64 + 10; ++ /// let v = json!({ "a": 64, "b": big, "c": 256.0 }); ++ /// ++ /// assert!(v["a"].is_i64()); ++ /// ++ /// // Greater than i64::MAX. ++ /// assert!(!v["b"].is_i64()); ++ /// ++ /// // Numbers with a decimal point are not considered integers. ++ /// assert!(!v["c"].is_i64()); ++ /// # } ++ /// ``` ++ pub fn is_i64(&self) -> bool { ++ match *self { ++ Value::Number(ref n) => n.is_i64(), ++ _ => false, ++ } ++ } ++ ++ /// Returns true if the `Value` is an integer between zero and `u64::MAX`. ++ /// ++ /// For any Value on which `is_u64` returns true, `as_u64` is guaranteed to ++ /// return the integer value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": 64, "b": -64, "c": 256.0 }); ++ /// ++ /// assert!(v["a"].is_u64()); ++ /// ++ /// // Negative integer. ++ /// assert!(!v["b"].is_u64()); ++ /// ++ /// // Numbers with a decimal point are not considered integers. ++ /// assert!(!v["c"].is_u64()); ++ /// # } ++ /// ``` ++ pub fn is_u64(&self) -> bool { ++ match *self { ++ Value::Number(ref n) => n.is_u64(), ++ _ => false, ++ } ++ } ++ ++ /// Returns true if the `Value` is a number that can be represented by f64. ++ /// ++ /// For any Value on which `is_f64` returns true, `as_f64` is guaranteed to ++ /// return the floating point value. ++ /// ++ /// Currently this function returns true if and only if both `is_i64` and ++ /// `is_u64` return false but this is not a guarantee in the future. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": 256.0, "b": 64, "c": -64 }); ++ /// ++ /// assert!(v["a"].is_f64()); ++ /// ++ /// // Integers. ++ /// assert!(!v["b"].is_f64()); ++ /// assert!(!v["c"].is_f64()); ++ /// # } ++ /// ``` ++ pub fn is_f64(&self) -> bool { ++ match *self { ++ Value::Number(ref n) => n.is_f64(), ++ _ => false, ++ } ++ } ++ ++ /// If the `Value` is an integer, represent it as i64 if possible. Returns ++ /// None otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # use std::i64; ++ /// # ++ /// # fn main() { ++ /// let big = i64::MAX as u64 + 10; ++ /// let v = json!({ "a": 64, "b": big, "c": 256.0 }); ++ /// ++ /// assert_eq!(v["a"].as_i64(), Some(64)); ++ /// assert_eq!(v["b"].as_i64(), None); ++ /// assert_eq!(v["c"].as_i64(), None); ++ /// # } ++ /// ``` ++ pub fn as_i64(&self) -> Option { ++ match *self { ++ Value::Number(ref n) => n.as_i64(), ++ _ => None, ++ } ++ } ++ ++ /// If the `Value` is an integer, represent it as u64 if possible. Returns ++ /// None otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": 64, "b": -64, "c": 256.0 }); ++ /// ++ /// assert_eq!(v["a"].as_u64(), Some(64)); ++ /// assert_eq!(v["b"].as_u64(), None); ++ /// assert_eq!(v["c"].as_u64(), None); ++ /// # } ++ /// ``` ++ pub fn as_u64(&self) -> Option { ++ match *self { ++ Value::Number(ref n) => n.as_u64(), ++ _ => None, ++ } ++ } ++ ++ /// If the `Value` is a number, represent it as f64 if possible. Returns ++ /// None otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": 256.0, "b": 64, "c": -64 }); ++ /// ++ /// assert_eq!(v["a"].as_f64(), Some(256.0)); ++ /// assert_eq!(v["b"].as_f64(), Some(64.0)); ++ /// assert_eq!(v["c"].as_f64(), Some(-64.0)); ++ /// # } ++ /// ``` ++ pub fn as_f64(&self) -> Option { ++ match *self { ++ Value::Number(ref n) => n.as_f64(), ++ _ => None, ++ } ++ } ++ ++ /// Returns true if the `Value` is a Boolean. Returns false otherwise. ++ /// ++ /// For any Value on which `is_boolean` returns true, `as_bool` is ++ /// guaranteed to return the boolean value. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": false, "b": "false" }); ++ /// ++ /// assert!(v["a"].is_boolean()); ++ /// ++ /// // The string `"false"` is a string, not a boolean. ++ /// assert!(!v["b"].is_boolean()); ++ /// # } ++ /// ``` ++ pub fn is_boolean(&self) -> bool { ++ self.as_bool().is_some() ++ } ++ ++ /// If the `Value` is a Boolean, returns the associated bool. Returns None ++ /// otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": false, "b": "false" }); ++ /// ++ /// assert_eq!(v["a"].as_bool(), Some(false)); ++ /// ++ /// // The string `"false"` is a string, not a boolean. ++ /// assert_eq!(v["b"].as_bool(), None); ++ /// # } ++ /// ``` ++ pub fn as_bool(&self) -> Option { ++ match *self { ++ Value::Bool(b) => Some(b), ++ _ => None, ++ } ++ } ++ ++ /// Returns true if the `Value` is a Null. Returns false otherwise. ++ /// ++ /// For any Value on which `is_null` returns true, `as_null` is guaranteed ++ /// to return `Some(())`. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": null, "b": false }); ++ /// ++ /// assert!(v["a"].is_null()); ++ /// ++ /// // The boolean `false` is not null. ++ /// assert!(!v["b"].is_null()); ++ /// # } ++ /// ``` ++ pub fn is_null(&self) -> bool { ++ self.as_null().is_some() ++ } ++ ++ /// If the `Value` is a Null, returns (). Returns None otherwise. ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let v = json!({ "a": null, "b": false }); ++ /// ++ /// assert_eq!(v["a"].as_null(), Some(())); ++ /// ++ /// // The boolean `false` is not null. ++ /// assert_eq!(v["b"].as_null(), None); ++ /// # } ++ /// ``` ++ pub fn as_null(&self) -> Option<()> { ++ match *self { ++ Value::Null => Some(()), ++ _ => None, ++ } ++ } ++ ++ /// Looks up a value by a JSON Pointer. ++ /// ++ /// JSON Pointer defines a string syntax for identifying a specific value ++ /// within a JavaScript Object Notation (JSON) document. ++ /// ++ /// A Pointer is a Unicode string with the reference tokens separated by `/`. ++ /// Inside tokens `/` is replaced by `~1` and `~` is replaced by `~0`. The ++ /// addressed value is returned and if there is no such value `None` is ++ /// returned. ++ /// ++ /// For more information read [RFC6901](https://tools.ietf.org/html/rfc6901). ++ /// ++ /// # Examples ++ /// ++ /// ```rust ++ /// # #[macro_use] ++ /// # extern crate serde_json; ++ /// # ++ /// # fn main() { ++ /// let data = json!({ ++ /// "x": { ++ /// "y": ["z", "zz"] ++ /// } ++ /// }); ++ /// ++ /// assert_eq!(data.pointer("/x/y/1").unwrap(), &json!("zz")); ++ /// assert_eq!(data.pointer("/a/b/c"), None); ++ /// # } ++ /// ``` ++ pub fn pointer<'a>(&'a self, pointer: &str) -> Option<&'a Value> { ++ if pointer == "" { ++ return Some(self); ++ } ++ if !pointer.starts_with('/') { ++ return None; ++ } ++ let tokens = pointer ++ .split('/') ++ .skip(1) ++ .map(|x| x.replace("~1", "/").replace("~0", "~")); ++ let mut target = self; ++ ++ for token in tokens { ++ let target_opt = match *target { ++ Value::Object(ref map) => map.get(&token), ++ Value::Array(ref list) => parse_index(&token).and_then(|x| list.get(x)), ++ _ => return None, ++ }; ++ if let Some(t) = target_opt { ++ target = t; ++ } else { ++ return None; ++ } ++ } ++ Some(target) ++ } ++ ++ /// Looks up a value by a JSON Pointer and returns a mutable reference to ++ /// that value. ++ /// ++ /// JSON Pointer defines a string syntax for identifying a specific value ++ /// within a JavaScript Object Notation (JSON) document. ++ /// ++ /// A Pointer is a Unicode string with the reference tokens separated by `/`. ++ /// Inside tokens `/` is replaced by `~1` and `~` is replaced by `~0`. The ++ /// addressed value is returned and if there is no such value `None` is ++ /// returned. ++ /// ++ /// For more information read [RFC6901](https://tools.ietf.org/html/rfc6901). ++ /// ++ /// # Example of Use ++ /// ++ /// ```rust ++ /// extern crate serde_json; ++ /// ++ /// use serde_json::Value; ++ /// use std::mem; ++ /// ++ /// fn main() { ++ /// let s = r#"{"x": 1.0, "y": 2.0}"#; ++ /// let mut value: Value = serde_json::from_str(s).unwrap(); ++ /// ++ /// // Check value using read-only pointer ++ /// assert_eq!(value.pointer("/x"), Some(&1.0.into())); ++ /// // Change value with direct assignment ++ /// *value.pointer_mut("/x").unwrap() = 1.5.into(); ++ /// // Check that new value was written ++ /// assert_eq!(value.pointer("/x"), Some(&1.5.into())); ++ /// ++ /// // "Steal" ownership of a value. Can replace with any valid Value. ++ /// let old_x = value.pointer_mut("/x").map(|x| mem::replace(x, Value::Null)).unwrap(); ++ /// assert_eq!(old_x, 1.5); ++ /// assert_eq!(value.pointer("/x").unwrap(), &Value::Null); ++ /// } ++ /// ``` ++ pub fn pointer_mut<'a>(&'a mut self, pointer: &str) -> Option<&'a mut Value> { ++ if pointer == "" { ++ return Some(self); ++ } ++ if !pointer.starts_with('/') { ++ return None; ++ } ++ let tokens = pointer ++ .split('/') ++ .skip(1) ++ .map(|x| x.replace("~1", "/").replace("~0", "~")); ++ let mut target = self; ++ ++ for token in tokens { ++ // borrow checker gets confused about `target` being mutably borrowed too many times because of the loop ++ // this once-per-loop binding makes the scope clearer and circumvents the error ++ let target_once = target; ++ let target_opt = match *target_once { ++ Value::Object(ref mut map) => map.get_mut(&token), ++ Value::Array(ref mut list) => { ++ parse_index(&token).and_then(move |x| list.get_mut(x)) ++ } ++ _ => return None, ++ }; ++ if let Some(t) = target_opt { ++ target = t; ++ } else { ++ return None; ++ } ++ } ++ Some(target) ++ } ++} ++ ++/// The default value is `Value::Null`. ++/// ++/// This is useful for handling omitted `Value` fields when deserializing. ++/// ++/// # Examples ++/// ++/// ```rust ++/// # #[macro_use] ++/// # extern crate serde_derive; ++/// # ++/// # extern crate serde_json; ++/// # ++/// use serde_json::Value; ++/// ++/// #[derive(Deserialize)] ++/// struct Settings { ++/// level: i32, ++/// #[serde(default)] ++/// extras: Value, ++/// } ++/// ++/// # fn try_main() -> Result<(), serde_json::Error> { ++/// let data = r#" { "level": 42 } "#; ++/// let s: Settings = serde_json::from_str(data)?; ++/// ++/// assert_eq!(s.level, 42); ++/// assert_eq!(s.extras, Value::Null); ++/// # ++/// # Ok(()) ++/// # } ++/// # ++/// # fn main() { ++/// # try_main().unwrap() ++/// # } ++/// ``` ++impl Default for Value { ++ fn default() -> Value { ++ Value::Null ++ } ++} ++ ++mod index; ++mod partial_eq; ++mod from; ++mod ser; ++mod de; ++ ++/// Convert a `T` into `serde_json::Value` which is an enum that can represent ++/// any valid JSON data. ++/// ++/// ```rust ++/// extern crate serde; ++/// ++/// #[macro_use] ++/// extern crate serde_derive; ++/// ++/// #[macro_use] ++/// extern crate serde_json; ++/// ++/// use std::error::Error; ++/// ++/// #[derive(Serialize)] ++/// struct User { ++/// fingerprint: String, ++/// location: String, ++/// } ++/// ++/// fn compare_json_values() -> Result<(), Box> { ++/// let u = User { ++/// fingerprint: "0xF9BA143B95FF6D82".to_owned(), ++/// location: "Menlo Park, CA".to_owned(), ++/// }; ++/// ++/// // The type of `expected` is `serde_json::Value` ++/// let expected = json!({ ++/// "fingerprint": "0xF9BA143B95FF6D82", ++/// "location": "Menlo Park, CA", ++/// }); ++/// ++/// let v = serde_json::to_value(u).unwrap(); ++/// assert_eq!(v, expected); ++/// ++/// Ok(()) ++/// } ++/// # ++/// # fn main() { ++/// # compare_json_values().unwrap(); ++/// # } ++/// ``` ++/// ++/// # Errors ++/// ++/// This conversion can fail if `T`'s implementation of `Serialize` decides to ++/// fail, or if `T` contains a map with non-string keys. ++/// ++/// ```rust ++/// extern crate serde_json; ++/// ++/// use std::collections::BTreeMap; ++/// ++/// fn main() { ++/// // The keys in this map are vectors, not strings. ++/// let mut map = BTreeMap::new(); ++/// map.insert(vec![32, 64], "x86"); ++/// ++/// println!("{}", serde_json::to_value(map).unwrap_err()); ++/// } ++/// ``` ++#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] ++// Taking by value is more friendly to iterator adapters, option and result ++// consumers, etc. See https://github.com/serde-rs/json/pull/149. ++pub fn to_value(value: T) -> Result ++where ++ T: Serialize, ++{ ++ value.serialize(Serializer) ++} ++ ++/// Interpret a `serde_json::Value` as an instance of type `T`. ++/// ++/// This conversion can fail if the structure of the Value does not match the ++/// structure expected by `T`, for example if `T` is a struct type but the Value ++/// contains something other than a JSON map. It can also fail if the structure ++/// is correct but `T`'s implementation of `Deserialize` decides that something ++/// is wrong with the data, for example required struct fields are missing from ++/// the JSON map or some number is too big to fit in the expected primitive ++/// type. ++/// ++/// ```rust ++/// #[macro_use] ++/// extern crate serde_json; ++/// ++/// #[macro_use] ++/// extern crate serde_derive; ++/// ++/// extern crate serde; ++/// ++/// #[derive(Deserialize, Debug)] ++/// struct User { ++/// fingerprint: String, ++/// location: String, ++/// } ++/// ++/// fn main() { ++/// // The type of `j` is `serde_json::Value` ++/// let j = json!({ ++/// "fingerprint": "0xF9BA143B95FF6D82", ++/// "location": "Menlo Park, CA" ++/// }); ++/// ++/// let u: User = serde_json::from_value(j).unwrap(); ++/// println!("{:#?}", u); ++/// } ++/// ``` ++pub fn from_value(value: Value) -> Result ++where ++ T: DeserializeOwned, ++{ ++ T::deserialize(value) ++} diff --cc vendor/serde_json-1.0.3/src/value/partial_eq.rs index 000000000,000000000..c4938ea9d new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/value/partial_eq.rs @@@ -1,0 -1,0 +1,83 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use super::Value; ++ ++impl PartialEq for Value { ++ fn eq(&self, other: &str) -> bool { ++ self.as_str().map_or(false, |s| s == other) ++ } ++} ++ ++impl<'a> PartialEq<&'a str> for Value { ++ fn eq(&self, other: &&str) -> bool { ++ self.as_str().map_or(false, |s| s == *other) ++ } ++} ++ ++impl PartialEq for str { ++ fn eq(&self, other: &Value) -> bool { ++ other.as_str().map_or(false, |s| s == self) ++ } ++} ++ ++impl<'a> PartialEq for &'a str { ++ fn eq(&self, other: &Value) -> bool { ++ other.as_str().map_or(false, |s| s == *self) ++ } ++} ++ ++impl PartialEq for Value { ++ fn eq(&self, other: &String) -> bool { ++ self.as_str().map_or(false, |s| s == other) ++ } ++} ++ ++ ++impl PartialEq for String { ++ fn eq(&self, other: &Value) -> bool { ++ other.as_str().map_or(false, |s| s == self) ++ } ++} ++ ++macro_rules! partialeq_numeric { ++ ($([$($ty:ty)*], $conversion:ident, $base:ty)*) => { ++ $($( ++ impl PartialEq<$ty> for Value { ++ fn eq(&self, other: &$ty) -> bool { ++ self.$conversion().map_or(false, |i| i == (*other as $base)) ++ } ++ } ++ ++ impl PartialEq for $ty { ++ fn eq(&self, other: &Value) -> bool { ++ other.$conversion().map_or(false, |i| i == (*self as $base)) ++ } ++ } ++ ++ impl<'a> PartialEq<$ty> for &'a Value { ++ fn eq(&self, other: &$ty) -> bool { ++ self.$conversion().map_or(false, |i| i == (*other as $base)) ++ } ++ } ++ ++ impl<'a> PartialEq<$ty> for &'a mut Value { ++ fn eq(&self, other: &$ty) -> bool { ++ self.$conversion().map_or(false, |i| i == (*other as $base)) ++ } ++ } ++ )*)* ++ } ++} ++ ++partialeq_numeric! { ++ [i8 i16 i32 i64 isize], as_i64, i64 ++ [u8 u16 u32 u64 usize], as_u64, u64 ++ [f32 f64], as_f64, f64 ++ [bool], as_bool, bool ++} diff --cc vendor/serde_json-1.0.3/src/value/ser.rs index 000000000,000000000..dc5a30699 new file mode 100644 --- /dev/null +++ b/vendor/serde_json-1.0.3/src/value/ser.rs @@@ -1,0 -1,0 +1,419 @@@ ++// Copyright 2017 Serde Developers ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use serde::{self, Serialize}; ++ ++use error::{Error, ErrorCode}; ++use map::Map; ++use number::Number; ++use value::{Value, to_value}; ++ ++impl Serialize for Value { ++ #[inline] ++ fn serialize(&self, serializer: S) -> Result ++ where ++ S: ::serde::Serializer, ++ { ++ match *self { ++ Value::Null => serializer.serialize_unit(), ++ Value::Bool(b) => serializer.serialize_bool(b), ++ Value::Number(ref n) => n.serialize(serializer), ++ Value::String(ref s) => serializer.serialize_str(s), ++ Value::Array(ref v) => v.serialize(serializer), ++ Value::Object(ref m) => { ++ use serde::ser::SerializeMap; ++ let mut map = try!(serializer.serialize_map(Some(m.len()))); ++ for (k, v) in m { ++ try!(map.serialize_key(k)); ++ try!(map.serialize_value(v)); ++ } ++ map.end() ++ } ++ } ++ } ++} ++ ++pub struct Serializer; ++ ++impl serde::Serializer for Serializer { ++ type Ok = Value; ++ type Error = Error; ++ ++ type SerializeSeq = SerializeVec; ++ type SerializeTuple = SerializeVec; ++ type SerializeTupleStruct = SerializeVec; ++ type SerializeTupleVariant = SerializeTupleVariant; ++ type SerializeMap = SerializeMap; ++ type SerializeStruct = SerializeMap; ++ type SerializeStructVariant = SerializeStructVariant; ++ ++ #[inline] ++ fn serialize_bool(self, value: bool) -> Result { ++ Ok(Value::Bool(value)) ++ } ++ ++ #[inline] ++ fn serialize_i8(self, value: i8) -> Result { ++ self.serialize_i64(value as i64) ++ } ++ ++ #[inline] ++ fn serialize_i16(self, value: i16) -> Result { ++ self.serialize_i64(value as i64) ++ } ++ ++ #[inline] ++ fn serialize_i32(self, value: i32) -> Result { ++ self.serialize_i64(value as i64) ++ } ++ ++ fn serialize_i64(self, value: i64) -> Result { ++ Ok(Value::Number(value.into())) ++ } ++ ++ #[inline] ++ fn serialize_u8(self, value: u8) -> Result { ++ self.serialize_u64(value as u64) ++ } ++ ++ #[inline] ++ fn serialize_u16(self, value: u16) -> Result { ++ self.serialize_u64(value as u64) ++ } ++ ++ #[inline] ++ fn serialize_u32(self, value: u32) -> Result { ++ self.serialize_u64(value as u64) ++ } ++ ++ #[inline] ++ fn serialize_u64(self, value: u64) -> Result { ++ Ok(Value::Number(value.into())) ++ } ++ ++ #[inline] ++ fn serialize_f32(self, value: f32) -> Result { ++ self.serialize_f64(value as f64) ++ } ++ ++ #[inline] ++ fn serialize_f64(self, value: f64) -> Result { ++ Ok(Number::from_f64(value).map_or(Value::Null, Value::Number)) ++ } ++ ++ #[inline] ++ fn serialize_char(self, value: char) -> Result { ++ let mut s = String::new(); ++ s.push(value); ++ self.serialize_str(&s) ++ } ++ ++ #[inline] ++ fn serialize_str(self, value: &str) -> Result { ++ Ok(Value::String(value.to_owned())) ++ } ++ ++ fn serialize_bytes(self, value: &[u8]) -> Result { ++ let vec = value.iter().map(|&b| Value::Number(b.into())).collect(); ++ Ok(Value::Array(vec)) ++ } ++ ++ #[inline] ++ fn serialize_unit(self) -> Result { ++ Ok(Value::Null) ++ } ++ ++ #[inline] ++ fn serialize_unit_struct(self, _name: &'static str) -> Result { ++ self.serialize_unit() ++ } ++ ++ #[inline] ++ fn serialize_unit_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ variant: &'static str, ++ ) -> Result { ++ self.serialize_str(variant) ++ } ++ ++ #[inline] ++ fn serialize_newtype_struct( ++ self, ++ _name: &'static str, ++ value: &T, ++ ) -> Result ++ where ++ T: Serialize, ++ { ++ value.serialize(self) ++ } ++ ++ fn serialize_newtype_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ variant: &'static str, ++ value: &T, ++ ) -> Result ++ where ++ T: Serialize, ++ { ++ let mut values = Map::new(); ++ values.insert(String::from(variant), try!(to_value(&value))); ++ Ok(Value::Object(values)) ++ } ++ ++ #[inline] ++ fn serialize_none(self) -> Result { ++ self.serialize_unit() ++ } ++ ++ #[inline] ++ fn serialize_some(self, value: &T) -> Result ++ where ++ T: Serialize, ++ { ++ value.serialize(self) ++ } ++ ++ fn serialize_seq(self, len: Option) -> Result { ++ Ok(SerializeVec { vec: Vec::with_capacity(len.unwrap_or(0)) }) ++ } ++ ++ fn serialize_tuple(self, len: usize) -> Result { ++ self.serialize_seq(Some(len)) ++ } ++ ++ fn serialize_tuple_struct( ++ self, ++ _name: &'static str, ++ len: usize, ++ ) -> Result { ++ self.serialize_seq(Some(len)) ++ } ++ ++ fn serialize_tuple_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ variant: &'static str, ++ len: usize, ++ ) -> Result { ++ Ok( ++ SerializeTupleVariant { ++ name: String::from(variant), ++ vec: Vec::with_capacity(len), ++ }, ++ ) ++ } ++ ++ fn serialize_map(self, _len: Option) -> Result { ++ Ok( ++ SerializeMap { ++ map: Map::new(), ++ next_key: None, ++ }, ++ ) ++ } ++ ++ fn serialize_struct( ++ self, ++ _name: &'static str, ++ len: usize, ++ ) -> Result { ++ self.serialize_map(Some(len)) ++ } ++ ++ fn serialize_struct_variant( ++ self, ++ _name: &'static str, ++ _variant_index: u32, ++ variant: &'static str, ++ _len: usize, ++ ) -> Result { ++ Ok( ++ SerializeStructVariant { ++ name: String::from(variant), ++ map: Map::new(), ++ }, ++ ) ++ } ++} ++ ++#[doc(hidden)] ++pub struct SerializeVec { ++ vec: Vec, ++} ++ ++#[doc(hidden)] ++pub struct SerializeTupleVariant { ++ name: String, ++ vec: Vec, ++} ++ ++#[doc(hidden)] ++pub struct SerializeMap { ++ map: Map, ++ next_key: Option, ++} ++ ++#[doc(hidden)] ++pub struct SerializeStructVariant { ++ name: String, ++ map: Map, ++} ++ ++impl serde::ser::SerializeSeq for SerializeVec { ++ type Ok = Value; ++ type Error = Error; ++ ++ fn serialize_element(&mut self, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ self.vec.push(try!(to_value(&value))); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ Ok(Value::Array(self.vec)) ++ } ++} ++ ++impl serde::ser::SerializeTuple for SerializeVec { ++ type Ok = Value; ++ type Error = Error; ++ ++ fn serialize_element(&mut self, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ serde::ser::SerializeSeq::serialize_element(self, value) ++ } ++ ++ fn end(self) -> Result { ++ serde::ser::SerializeSeq::end(self) ++ } ++} ++ ++impl serde::ser::SerializeTupleStruct for SerializeVec { ++ type Ok = Value; ++ type Error = Error; ++ ++ fn serialize_field(&mut self, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ serde::ser::SerializeSeq::serialize_element(self, value) ++ } ++ ++ fn end(self) -> Result { ++ serde::ser::SerializeSeq::end(self) ++ } ++} ++ ++impl serde::ser::SerializeTupleVariant for SerializeTupleVariant { ++ type Ok = Value; ++ type Error = Error; ++ ++ fn serialize_field(&mut self, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ self.vec.push(try!(to_value(&value))); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ let mut object = Map::new(); ++ ++ object.insert(self.name, Value::Array(self.vec)); ++ ++ Ok(Value::Object(object)) ++ } ++} ++ ++impl serde::ser::SerializeMap for SerializeMap { ++ type Ok = Value; ++ type Error = Error; ++ ++ fn serialize_key(&mut self, key: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ match try!(to_value(&key)) { ++ Value::String(s) => self.next_key = Some(s), ++ Value::Number(n) => { ++ if n.is_u64() || n.is_i64() { ++ self.next_key = Some(n.to_string()) ++ } else { ++ return Err(Error::syntax(ErrorCode::KeyMustBeAString, 0, 0)); ++ } ++ } ++ _ => return Err(Error::syntax(ErrorCode::KeyMustBeAString, 0, 0)), ++ }; ++ Ok(()) ++ } ++ ++ fn serialize_value(&mut self, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ let key = self.next_key.take(); ++ // Panic because this indicates a bug in the program rather than an ++ // expected failure. ++ let key = key.expect("serialize_value called before serialize_key"); ++ self.map.insert(key, try!(to_value(&value))); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ Ok(Value::Object(self.map)) ++ } ++} ++ ++impl serde::ser::SerializeStruct for SerializeMap { ++ type Ok = Value; ++ type Error = Error; ++ ++ fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ try!(serde::ser::SerializeMap::serialize_key(self, key)); ++ serde::ser::SerializeMap::serialize_value(self, value) ++ } ++ ++ fn end(self) -> Result { ++ serde::ser::SerializeMap::end(self) ++ } ++} ++ ++impl serde::ser::SerializeStructVariant for SerializeStructVariant { ++ type Ok = Value; ++ type Error = Error; ++ ++ fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<(), Error> ++ where ++ T: Serialize, ++ { ++ self.map ++ .insert(String::from(key), try!(to_value(&value))); ++ Ok(()) ++ } ++ ++ fn end(self) -> Result { ++ let mut object = Map::new(); ++ ++ object.insert(self.name, Value::Object(self.map)); ++ ++ Ok(Value::Object(object)) ++ } ++} diff --cc vendor/socket2-0.2.3/.appveyor.yml index 000000000,000000000..4880006c5 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/.appveyor.yml @@@ -1,0 -1,0 +1,16 @@@ ++environment: ++ matrix: ++ - TARGET: x86_64-pc-windows-msvc ++install: ++ - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe ++ - rustup-init.exe -y --default-host x86_64-pc-windows-msvc ++ - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin ++ - if NOT "%TARGET%" == "x86_64-pc-windows-msvc" rustup target add %TARGET% ++ - rustc -V ++ - cargo -V ++ ++build: false ++ ++test_script: ++ - cargo test ++ - cargo test --features reuseport diff --cc vendor/socket2-0.2.3/.cargo-checksum.json index 000000000,000000000..af04db538 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"9e76b159741052c7deaa9fd0b5ca6b5f79cecf525ed665abfe5002086c6b2791"} diff --cc vendor/socket2-0.2.3/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/.cargo-ok diff --cc vendor/socket2-0.2.3/.travis.yml index 000000000,000000000..e6a4bd7c1 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/.travis.yml @@@ -1,0 -1,0 +1,27 @@@ ++language: rust ++rust: ++ - stable ++sudo: false ++before_script: ++ - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH ++script: ++ - cargo test ++ - cargo test --features "reuseport unix pair" ++ - cargo doc --no-deps --all-features ++after_success: ++ - travis-cargo --only nightly doc-upload ++env: ++ global: ++ secure: "qibsiOrfM/GjYgYFXycSqKMwIK9ZR4cvHZsSqTtqrtxGq5Q7jTwMqdDl8KHDgX1a4it4tGay+7joex8k2zL6OQ+FljQGQq54EDiGw82HWix/fBpOMjMszw+GEDMG/9hUSb6HFdzAKLPAsBRvIs2QteJ60GhL/w4Z/EmfHlVKMnVsYUjfBf5BNlkv8yFvRMY6QqL+F85N7dDQ7JAgdiP79jR7LP8IlCEu/8pgSrf9pSqAHSC1Co1CaN8uhhMlcIIOZ5qYAK4Xty26r2EDzPm5Lw2Bd7a4maN0x+Be2DJvrnX30QkJNNU1XhxYkeZEeUCYAlUhBE5nBHpyyrbAxv+rJodPeyRl5EVpyqi8htPVmcnuA2XpNoHCud7CnzxaFytGvAC5kp0EgS7f3ac4hTnZXCfP0CvnT5UyWfWv9yLwQycdYcAsV4TnKxVAw4ykApGey+h0dyIM2VnzRPOo9D2ZS+JpzPHtx/PXD7aN7IungfTj4PmT+i00QNzkzJR9BqYKmEDBUcz6MLctg4D6xChhN8Go4hvk22F0RVyvEg1MAvXc07EKeWXG/VZ+H2frcPEceMGRBBHiOfOEE/2utNYgvIcmQxd1hvbm3cQOIjeXU2rGneN86cSmx7zNlfOyJUoBfsgGvSEzRxUueibUCaujB/El70HGrMlTnXeERiyd/2Y=" ++ ++matrix: ++ include: ++ - rust: beta ++ - rust: nightly ++ ++notifications: ++ email: ++ on_success: never ++os: ++ - linux ++ - osx diff --cc vendor/socket2-0.2.3/Cargo.toml index 000000000,000000000..4e63117f5 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/Cargo.toml @@@ -1,0 -1,0 +1,44 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "socket2" ++version = "0.2.3" ++authors = ["Alex Crichton "] ++description = "Utilities for handling networking sockets with a maximal amount of configuration\npossible intended.\n" ++homepage = "https://github.com/alexcrichton/socket2-rs" ++documentation = "https://docs.rs/socket2" ++readme = "README.md" ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/socket2-rs" ++[package.metadata.docs.rs] ++all-features = true ++[dev-dependencies.tempdir] ++version = "0.3" ++ ++[features] ++reuseport = [] ++pair = [] ++unix = [] ++[target."cfg(windows)".dependencies.ws2_32-sys] ++version = "0.2" ++ ++[target."cfg(windows)".dependencies.winapi] ++version = "0.2" ++ ++[target."cfg(windows)".dependencies.kernel32-sys] ++version = "0.2" ++[target."cfg(unix)".dependencies.libc] ++version = "0.2.14" ++ ++[target."cfg(unix)".dependencies.cfg-if] ++version = "0.1" diff --cc vendor/socket2-0.2.3/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/socket2-0.2.3/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/socket2-0.2.3/README.md index 000000000,000000000..02c16d7d1 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/README.md @@@ -1,0 -1,0 +1,14 @@@ ++# socket2-rs ++ ++[![Build Status](https://travis-ci.org/alexcrichton/socket2-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/socket2-rs) ++[![Build status](https://ci.appveyor.com/api/projects/status/hovebj1gr4bgm3d9?svg=true)](https://ci.appveyor.com/project/alexcrichton/socket2-rs) ++ ++[Documentation](https://docs.rs/socket2) ++ ++# License ++ ++`socket2-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 --cc vendor/socket2-0.2.3/src/lib.rs index 000000000,000000000..40e6084e6 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/src/lib.rs @@@ -1,0 -1,0 +1,130 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++//! Utilities for handling sockets ++//! ++//! This crate is sort of an evolution of the `net2` crate after seeing the ++//! issues on it over time. The intention of this crate is to provide as direct ++//! as possible access to the system's functionality for sockets as possible. No ++//! extra fluff (e.g. multiple syscalls or builders) provided in this crate. As ++//! a result using this crate can be a little wordy, but it should give you ++//! maximal flexibility over configuration of sockets. ++//! ++//! # Examples ++//! ++//! ```no_run ++//! use std::net::SocketAddr; ++//! use socket2::{Socket, Domain, Type}; ++//! ++//! // create a TCP listener bound to two addresses ++//! let socket = Socket::new(Domain::ipv4(), Type::stream(), None).unwrap(); ++//! ++//! socket.bind(&"127.0.0.1:12345".parse::().unwrap().into()).unwrap(); ++//! socket.bind(&"127.0.0.1:12346".parse::().unwrap().into()).unwrap(); ++//! socket.listen(128).unwrap(); ++//! ++//! let listener = socket.into_tcp_listener(); ++//! // ... ++//! ``` ++ ++#![doc(html_root_url = "https://docs.rs/socket2/0.2")] ++#![deny(missing_docs)] ++ ++#[cfg(unix)] extern crate libc; ++#[cfg(unix)] #[macro_use] extern crate cfg_if; ++ ++#[cfg(windows)] extern crate kernel32; ++#[cfg(windows)] extern crate winapi; ++#[cfg(windows)] extern crate ws2_32; ++ ++#[cfg(test)] extern crate tempdir; ++ ++use utils::NetInt; ++ ++#[cfg(unix)] use libc::{sockaddr_storage, socklen_t}; ++#[cfg(windows)] use winapi::{SOCKADDR_STORAGE as sockaddr_storage, socklen_t}; ++ ++mod sockaddr; ++mod socket; ++mod utils; ++ ++#[cfg(unix)] #[path = "sys/unix/mod.rs"] mod sys; ++#[cfg(windows)] #[path = "sys/windows.rs"] mod sys; ++ ++/// Newtype, owned, wrapper around a system socket. ++/// ++/// This type simply wraps an instance of a file descriptor (`c_int`) on Unix ++/// and an instance of `SOCKET` on Windows. This is the main type exported by ++/// this crate and is intended to mirror the raw semantics of sockets on ++/// platforms as closely as possible. Almost all methods correspond to ++/// precisely one libc or OS API call which is essentially just a "Rustic ++/// translation" of what's below. ++/// ++/// # Examples ++/// ++/// ```no_run ++/// use std::net::SocketAddr; ++/// use socket2::{Socket, Domain, Type, SockAddr}; ++/// ++/// // create a TCP listener bound to two addresses ++/// let socket = Socket::new(Domain::ipv4(), Type::stream(), None).unwrap(); ++/// ++/// socket.bind(&"127.0.0.1:12345".parse::().unwrap().into()).unwrap(); ++/// socket.bind(&"127.0.0.1:12346".parse::().unwrap().into()).unwrap(); ++/// socket.listen(128).unwrap(); ++/// ++/// let listener = socket.into_tcp_listener(); ++/// // ... ++/// ``` ++pub struct Socket { ++ inner: sys::Socket, ++} ++ ++/// The address of a socket. ++/// ++/// `SockAddr`s may be constructed directly to and from the standard library ++/// `SocketAddr`, `SocketAddrV4`, and `SocketAddrV6` types. ++pub struct SockAddr { ++ storage: sockaddr_storage, ++ len: socklen_t, ++} ++ ++/// Specification of the communication domain for a socket. ++/// ++/// This is a newtype wrapper around an integer which provides a nicer API in ++/// addition to an injection point for documentation. Convenience constructors ++/// such as `Domain::ipv4`, `Domain::ipv6`, etc, are provided to avoid reaching ++/// into libc for various constants. ++/// ++/// This type is freely interconvertible with the `i32` type, however, if a raw ++/// value needs to be provided. ++pub struct Domain(i32); ++ ++/// Specification of communication semantics on a socket. ++/// ++/// This is a newtype wrapper around an integer which provides a nicer API in ++/// addition to an injection point for documentation. Convenience constructors ++/// such as `Type::stream`, `Type::dgram`, etc, are provided to avoid reaching ++/// into libc for various constants. ++/// ++/// This type is freely interconvertible with the `i32` type, however, if a raw ++/// value needs to be provided. ++pub struct Type(i32); ++ ++/// Protocol specification used for creating sockets via `Socket::new`. ++/// ++/// This is a newtype wrapper around an integer which provides a nicer API in ++/// addition to an injection point for documentation. ++/// ++/// This type is freely interconvertible with the `i32` type, however, if a raw ++/// value needs to be provided. ++pub struct Protocol(i32); ++ ++fn hton(i: I) -> I { i.to_be() } diff --cc vendor/socket2-0.2.3/src/sockaddr.rs index 000000000,000000000..9484f8526 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/src/sockaddr.rs @@@ -1,0 -1,0 +1,194 @@@ ++use std::fmt; ++use std::mem; ++use std::net::{SocketAddrV4, SocketAddrV6, SocketAddr}; ++use std::ptr; ++ ++#[cfg(unix)] ++use libc::{sockaddr, sockaddr_storage, sockaddr_in, sockaddr_in6, sa_family_t, socklen_t, AF_INET, ++ AF_INET6}; ++#[cfg(windows)] ++use winapi::{SOCKADDR as sockaddr, SOCKADDR_STORAGE as sockaddr_storage, ++ SOCKADDR_IN as sockaddr_in, sockaddr_in6, ++ ADDRESS_FAMILY as sa_family_t, socklen_t, AF_INET, AF_INET6}; ++ ++use SockAddr; ++ ++impl fmt::Debug for SockAddr { ++ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { ++ let mut builder = fmt.debug_struct("SockAddr"); ++ builder.field("family", &self.family()); ++ if let Some(addr) = self.as_inet() { ++ builder.field("inet", &addr); ++ } else if let Some(addr) = self.as_inet6() { ++ builder.field("inet6", &addr); ++ } ++ builder.finish() ++ } ++} ++ ++impl SockAddr { ++ /// Constructs a `SockAddr` from its raw components. ++ pub unsafe fn from_raw_parts(addr: *const sockaddr, len: socklen_t) -> SockAddr { ++ let mut storage = mem::uninitialized::(); ++ ptr::copy_nonoverlapping(addr as *const _ as *const u8, ++ &mut storage as *mut _ as *mut u8, ++ len as usize); ++ ++ SockAddr { ++ storage: storage, ++ len: len, ++ } ++ } ++ ++ /// Constructs a `SockAddr` with the family `AF_UNIX` and the provided path. ++ /// ++ /// This function is only available on Unix when the `unix` feature is ++ /// enabled. ++ /// ++ /// # Failure ++ /// ++ /// Returns an error if the path is longer than `SUN_LEN`. ++ #[cfg(all(unix, feature = "unix"))] ++ pub fn unix

      (path: P) -> ::std::io::Result ++ where P: AsRef<::std::path::Path> ++ { ++ use std::cmp::Ordering; ++ use std::io; ++ use std::os::unix::ffi::OsStrExt; ++ use libc::{sockaddr_un, AF_UNIX, c_char}; ++ ++ unsafe { ++ let mut addr = mem::zeroed::(); ++ addr.sun_family = AF_UNIX as sa_family_t; ++ ++ let bytes = path.as_ref().as_os_str().as_bytes(); ++ ++ match (bytes.get(0), bytes.len().cmp(&addr.sun_path.len())) { ++ // Abstract paths don't need a null terminator ++ (Some(&0), Ordering::Greater) => { ++ return Err(io::Error::new(io::ErrorKind::InvalidInput, ++ "path must be no longer than SUN_LEN")); ++ } ++ (Some(&0), _) => {} ++ (_, Ordering::Greater) | (_, Ordering::Equal) => { ++ return Err(io::Error::new(io::ErrorKind::InvalidInput, ++ "path must be shorter than SUN_LEN")); ++ } ++ _ => {} ++ } ++ ++ for (dst, src) in addr.sun_path.iter_mut().zip(bytes) { ++ *dst = *src as c_char; ++ } ++ // null byte for pathname is already there since we zeroed up front ++ ++ let base = &addr as *const _ as usize; ++ let path = &addr.sun_path as *const _ as usize; ++ let sun_path_offset = path - base; ++ ++ let mut len = sun_path_offset + bytes.len(); ++ match bytes.get(0) { ++ Some(&0) | None => {} ++ Some(_) => len += 1, ++ } ++ Ok(SockAddr::from_raw_parts(&addr as *const _ as *const _, len as socklen_t)) ++ } ++ } ++ ++ unsafe fn as_(&self, family: sa_family_t) -> Option { ++ if self.storage.ss_family != family { ++ return None; ++ } ++ ++ Some(mem::transmute_copy(&self.storage)) ++ } ++ ++ /// Returns this address as a `SocketAddrV4` if it is in the `AF_INET` ++ /// family. ++ pub fn as_inet(&self) -> Option { ++ unsafe { self.as_(AF_INET as sa_family_t) } ++ } ++ ++ /// Returns this address as a `SocketAddrV4` if it is in the `AF_INET6` ++ /// family. ++ pub fn as_inet6(&self) -> Option { ++ unsafe { self.as_(AF_INET6 as sa_family_t) } ++ } ++ ++ /// Returns this address's family. ++ pub fn family(&self) -> sa_family_t { ++ self.storage.ss_family ++ } ++ ++ /// Returns the size of this address in bytes. ++ pub fn len(&self) -> socklen_t { ++ self.len ++ } ++ ++ /// Returns a raw pointer to the address. ++ pub fn as_ptr(&self) -> *const sockaddr { ++ &self.storage as *const _ as *const _ ++ } ++} ++ ++// SocketAddrV4 and SocketAddrV6 are just wrappers around sockaddr_in and sockaddr_in6 ++ ++// check to make sure that the sizes at least match up ++fn _size_checks(v4: SocketAddrV4, v6: SocketAddrV6) { ++ unsafe { ++ mem::transmute::(v4); ++ mem::transmute::(v6); ++ } ++} ++ ++impl From for SockAddr { ++ fn from(addr: SocketAddrV4) -> SockAddr { ++ unsafe { ++ SockAddr::from_raw_parts(&addr as *const _ as *const _, ++ mem::size_of::() as socklen_t) ++ } ++ } ++} ++ ++impl From for SockAddr { ++ fn from(addr: SocketAddrV6) -> SockAddr { ++ unsafe { ++ SockAddr::from_raw_parts(&addr as *const _ as *const _, ++ mem::size_of::() as socklen_t) ++ } ++ } ++} ++ ++impl From for SockAddr { ++ fn from(addr: SocketAddr) -> SockAddr { ++ match addr { ++ SocketAddr::V4(addr) => addr.into(), ++ SocketAddr::V6(addr) => addr.into(), ++ } ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use super::*; ++ ++ #[test] ++ fn inet() { ++ let raw = "127.0.0.1:80".parse::().unwrap(); ++ let addr = SockAddr::from(raw); ++ assert!(addr.as_inet6().is_none()); ++ let addr = addr.as_inet().unwrap(); ++ assert_eq!(raw, addr); ++ } ++ ++ #[test] ++ fn inet6() { ++ let raw = "[2001:db8::ff00:42:8329]:80" ++ .parse::() ++ .unwrap(); ++ let addr = SockAddr::from(raw); ++ assert!(addr.as_inet().is_none()); ++ let addr = addr.as_inet6().unwrap(); ++ assert_eq!(raw, addr); ++ } ++} diff --cc vendor/socket2-0.2.3/src/socket.rs index 000000000,000000000..eed39ba04 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/src/socket.rs @@@ -1,0 -1,0 +1,852 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::fmt; ++use std::io::{self, Read, Write}; ++use std::net::{self, Ipv4Addr, Ipv6Addr, Shutdown}; ++use std::time::Duration; ++#[cfg(all(unix, feature = "unix"))] ++use std::os::unix::net::{UnixDatagram, UnixListener, UnixStream}; ++ ++#[cfg(unix)] ++use libc as c; ++#[cfg(windows)] ++use winapi as c; ++ ++use sys; ++use {Socket, Protocol, Domain, Type, SockAddr}; ++ ++impl Socket { ++ /// Creates a new socket ready to be configured. ++ /// ++ /// This function corresponds to `socket(2)` and simply creates a new ++ /// socket, no other configuration is done and further functions must be ++ /// invoked to configure this socket. ++ pub fn new(domain: Domain, ++ type_: Type, ++ protocol: Option) -> io::Result { ++ let protocol = protocol.map(|p| p.0).unwrap_or(0); ++ Ok(Socket { ++ inner: sys::Socket::new(domain.0, type_.0, protocol)?, ++ }) ++ } ++ ++ /// Creates a pair of sockets which are connected to each other. ++ /// ++ /// This function corresponds to `socketpair(2)`. ++ /// ++ /// This function is only available on Unix when the `pair` feature is ++ /// enabled. ++ #[cfg(all(unix, feature = "pair"))] ++ pub fn pair(domain: Domain, ++ type_: Type, ++ protocol: Option) -> io::Result<(Socket, Socket)> { ++ let protocol = protocol.map(|p| p.0).unwrap_or(0); ++ let sockets = sys::Socket::pair(domain.0, type_.0, protocol)?; ++ Ok((Socket { inner: sockets.0 }, Socket { inner: sockets.1 })) ++ } ++ ++ /// Consumes this `Socket`, converting it to a `TcpStream`. ++ pub fn into_tcp_stream(self) -> net::TcpStream { ++ self.into() ++ } ++ ++ /// Consumes this `Socket`, converting it to a `TcpListener`. ++ pub fn into_tcp_listener(self) -> net::TcpListener { ++ self.into() ++ } ++ ++ /// Consumes this `Socket`, converting it to a `UdpSocket`. ++ pub fn into_udp_socket(self) -> net::UdpSocket { ++ self.into() ++ } ++ ++ /// Consumes this `Socket`, converting it into a `UnixStream`. ++ /// ++ /// This function is only available on Unix when the `unix` feature is ++ /// enabled. ++ #[cfg(all(unix, feature = "unix"))] ++ pub fn into_unix_stream(self) -> UnixStream { ++ self.into() ++ } ++ ++ /// Consumes this `Socket`, converting it into a `UnixListener`. ++ /// ++ /// This function is only available on Unix when the `unix` feature is ++ /// enabled. ++ #[cfg(all(unix, feature = "unix"))] ++ pub fn into_unix_listener(self) -> UnixListener { ++ self.into() ++ } ++ ++ /// Consumes this `Socket`, converting it into a `UnixDatagram`. ++ /// ++ /// This function is only available on Unix when the `unix` feature is ++ /// enabled. ++ #[cfg(all(unix, feature = "unix"))] ++ pub fn into_unix_datagram(self) -> UnixDatagram { ++ self.into() ++ } ++ ++ /// Initiate a connection on this socket to the specified address. ++ /// ++ /// This function directly corresponds to the connect(2) function on Windows ++ /// and Unix. ++ /// ++ /// An error will be returned if `listen` or `connect` has already been ++ /// called on this builder. ++ pub fn connect(&self, addr: &SockAddr) -> io::Result<()> { ++ self.inner.connect(addr) ++ } ++ ++ /// Initiate a connection on this socket to the specified address, only ++ /// only waiting for a certain period of time for the connection to be ++ /// established. ++ /// ++ /// Unlike many other methods on `Socket`, this does *not* correspond to a ++ /// single C function. It sets the socket to nonblocking mode, connects via ++ /// connect(2), and then waits for the connection to complete with poll(2) ++ /// on Unix and select on Windows. When the connection is complete, the ++ /// socket is set back to blocking mode. On Unix, this will loop over ++ /// `EINTR` errors. ++ /// ++ /// # Warnings ++ /// ++ /// The nonblocking state of the socket is overridden by this function - ++ /// it will be returned in blocking mode on success, and in an indeterminate ++ /// state on failure. ++ /// ++ /// If the connection request times out, it may still be processing in the ++ /// background - a second call to `connect` or `connect_timeout` may fail. ++ pub fn connect_timeout(&self, addr: &SockAddr, timeout: Duration) -> io::Result<()> { ++ self.inner.connect_timeout(addr, timeout) ++ } ++ ++ /// Binds this socket to the specified address. ++ /// ++ /// This function directly corresponds to the bind(2) function on Windows ++ /// and Unix. ++ pub fn bind(&self, addr: &SockAddr) -> io::Result<()> { ++ self.inner.bind(addr) ++ } ++ ++ /// Mark a socket as ready to accept incoming connection requests using ++ /// accept() ++ /// ++ /// This function directly corresponds to the listen(2) function on Windows ++ /// and Unix. ++ /// ++ /// An error will be returned if `listen` or `connect` has already been ++ /// called on this builder. ++ pub fn listen(&self, backlog: i32) -> io::Result<()> { ++ self.inner.listen(backlog) ++ } ++ ++ /// Accept a new incoming connection from this listener. ++ /// ++ /// This function will block the calling thread until a new connection is ++ /// established. When established, the corresponding `Socket` and the ++ /// remote peer's address will be returned. ++ pub fn accept(&self) -> io::Result<(Socket, SockAddr)> { ++ self.inner.accept().map(|(socket, addr)| { ++ (Socket { inner: socket }, addr) ++ }) ++ } ++ ++ /// Returns the socket address of the local half of this TCP connection. ++ pub fn local_addr(&self) -> io::Result { ++ self.inner.local_addr() ++ } ++ ++ /// Returns the socket address of the remote peer of this TCP connection. ++ pub fn peer_addr(&self) -> io::Result { ++ self.inner.peer_addr() ++ } ++ ++ /// Creates a new independently owned handle to the underlying socket. ++ /// ++ /// The returned `TcpStream` is a reference to the same stream that this ++ /// object references. Both handles will read and write the same stream of ++ /// data, and options set on one stream will be propagated to the other ++ /// stream. ++ pub fn try_clone(&self) -> io::Result { ++ self.inner.try_clone().map(|s| Socket { inner: s }) ++ } ++ ++ /// Get the value of the `SO_ERROR` option on this socket. ++ /// ++ /// This will retrieve the stored error in the underlying socket, clearing ++ /// the field in the process. This can be useful for checking errors between ++ /// calls. ++ pub fn take_error(&self) -> io::Result> { ++ self.inner.take_error() ++ } ++ ++ /// Moves this TCP stream into or out of nonblocking mode. ++ /// ++ /// On Unix this corresponds to calling fcntl, and on Windows this ++ /// corresponds to calling ioctlsocket. ++ pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { ++ self.inner.set_nonblocking(nonblocking) ++ } ++ ++ /// Shuts down the read, write, or both halves of this connection. ++ /// ++ /// This function will cause all pending and future I/O on the specified ++ /// portions to return immediately with an appropriate value. ++ pub fn shutdown(&self, how: Shutdown) -> io::Result<()> { ++ self.inner.shutdown(how) ++ } ++ ++ /// Receives data on the socket from the remote address to which it is ++ /// connected. ++ /// ++ /// The [`connect`] method will connect this socket to a remote address. This ++ /// method will fail if the socket is not connected. ++ /// ++ /// [`connect`]: #method.connect ++ pub fn recv(&self, buf: &mut [u8]) -> io::Result { ++ self.inner.recv(buf) ++ } ++ ++ /// Receives data on the socket from the remote adress to which it is ++ /// connected, without removing that data from the queue. On success, ++ /// returns the number of bytes peeked. ++ /// ++ /// Successive calls return the same data. This is accomplished by passing ++ /// `MSG_PEEK` as a flag to the underlying `recv` system call. ++ pub fn peek(&self, buf: &mut [u8]) -> io::Result { ++ self.inner.peek(buf) ++ } ++ ++ /// Receives data from the socket. On success, returns the number of bytes ++ /// read and the address from whence the data came. ++ pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SockAddr)> { ++ self.inner.recv_from(buf) ++ } ++ ++ /// Receives data from the socket, without removing it from the queue. ++ /// ++ /// Successive calls return the same data. This is accomplished by passing ++ /// `MSG_PEEK` as a flag to the underlying `recvfrom` system call. ++ /// ++ /// On success, returns the number of bytes peeked and the address from ++ /// whence the data came. ++ pub fn peek_from(&self, buf: &mut [u8]) -> io::Result<(usize, SockAddr)> { ++ self.inner.peek_from(buf) ++ } ++ ++ /// Sends data on the socket to a connected peer. ++ /// ++ /// This is typically used on TCP sockets or datagram sockets which have ++ /// been connected. ++ /// ++ /// On success returns the number of bytes that were sent. ++ pub fn send(&self, buf: &[u8]) -> io::Result { ++ self.inner.send(buf) ++ } ++ ++ /// Sends data on the socket to the given address. On success, returns the ++ /// number of bytes written. ++ /// ++ /// This is typically used on UDP or datagram-oriented sockets. On success ++ /// returns the number of bytes that were sent. ++ pub fn send_to(&self, buf: &[u8], addr: &SockAddr) -> io::Result { ++ self.inner.send_to(buf, addr) ++ } ++ ++ // ================================================ ++ ++ /// Gets the value of the `IP_TTL` option for this socket. ++ /// ++ /// For more information about this option, see [`set_ttl`][link]. ++ /// ++ /// [link]: #method.set_ttl ++ pub fn ttl(&self) -> io::Result { ++ self.inner.ttl() ++ } ++ ++ /// Sets the value for the `IP_TTL` option on this socket. ++ /// ++ /// This value sets the time-to-live field that is used in every packet sent ++ /// from this socket. ++ pub fn set_ttl(&self, ttl: u32) -> io::Result<()> { ++ self.inner.set_ttl(ttl) ++ } ++ ++ /// Gets the value of the `IPV6_V6ONLY` option for this socket. ++ /// ++ /// For more information about this option, see [`set_only_v6`][link]. ++ /// ++ /// [link]: #method.set_only_v6 ++ pub fn only_v6(&self) -> io::Result { ++ self.inner.only_v6() ++ } ++ ++ /// Sets the value for the `IPV6_V6ONLY` option on this socket. ++ /// ++ /// If this is set to `true` then the socket is restricted to sending and ++ /// receiving IPv6 packets only. In this case two IPv4 and IPv6 applications ++ /// can bind the same port at the same time. ++ /// ++ /// If this is set to `false` then the socket can be used to send and ++ /// receive packets from an IPv4-mapped IPv6 address. ++ pub fn set_only_v6(&self, only_v6: bool) -> io::Result<()> { ++ self.inner.set_only_v6(only_v6) ++ } ++ ++ /// Returns the read timeout of this socket. ++ /// ++ /// If the timeout is `None`, then `read` calls will block indefinitely. ++ pub fn read_timeout(&self) -> io::Result> { ++ self.inner.read_timeout() ++ } ++ ++ /// Sets the read timeout to the timeout specified. ++ /// ++ /// If the value specified is `None`, then `read` calls will block ++ /// indefinitely. It is an error to pass the zero `Duration` to this ++ /// method. ++ pub fn set_read_timeout(&self, dur: Option) -> io::Result<()> { ++ self.inner.set_read_timeout(dur) ++ } ++ ++ /// Returns the write timeout of this socket. ++ /// ++ /// If the timeout is `None`, then `write` calls will block indefinitely. ++ pub fn write_timeout(&self) -> io::Result> { ++ self.inner.write_timeout() ++ } ++ ++ /// Sets the write timeout to the timeout specified. ++ /// ++ /// If the value specified is `None`, then `write` calls will block ++ /// indefinitely. It is an error to pass the zero `Duration` to this ++ /// method. ++ pub fn set_write_timeout(&self, dur: Option) -> io::Result<()> { ++ self.inner.set_write_timeout(dur) ++ } ++ ++ /// Gets the value of the `TCP_NODELAY` option on this socket. ++ /// ++ /// For more information about this option, see [`set_nodelay`][link]. ++ /// ++ /// [link]: #method.set_nodelay ++ pub fn nodelay(&self) -> io::Result { ++ self.inner.nodelay() ++ } ++ ++ /// Sets the value of the `TCP_NODELAY` option on this socket. ++ /// ++ /// If set, this option disables the Nagle algorithm. This means that ++ /// segments are always sent as soon as possible, even if there is only a ++ /// small amount of data. When not set, data is buffered until there is a ++ /// sufficient amount to send out, thereby avoiding the frequent sending of ++ /// small packets. ++ pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> { ++ self.inner.set_nodelay(nodelay) ++ } ++ ++ /// Sets the value of the `SO_BROADCAST` option for this socket. ++ /// ++ /// When enabled, this socket is allowed to send packets to a broadcast ++ /// address. ++ pub fn broadcast(&self) -> io::Result { ++ self.inner.broadcast() ++ } ++ ++ /// Gets the value of the `SO_BROADCAST` option for this socket. ++ /// ++ /// For more information about this option, see ++ /// [`set_broadcast`][link]. ++ /// ++ /// [link]: #method.set_broadcast ++ pub fn set_broadcast(&self, broadcast: bool) -> io::Result<()> { ++ self.inner.set_broadcast(broadcast) ++ } ++ ++ /// Gets the value of the `IP_MULTICAST_TTL` option for this socket. ++ /// ++ /// For more information about this option, see ++ /// [`set_multicast_ttl_v4`][link]. ++ /// ++ /// [link]: #method.set_multicast_ttl_v4 ++ pub fn multicast_loop_v4(&self) -> io::Result { ++ self.inner.multicast_loop_v4() ++ } ++ ++ /// Sets the value of the `IP_MULTICAST_LOOP` option for this socket. ++ /// ++ /// If enabled, multicast packets will be looped back to the local socket. ++ /// Note that this may not have any affect on IPv6 sockets. ++ pub fn set_multicast_loop_v4(&self, multicast_loop_v4: bool) -> io::Result<()> { ++ self.inner.set_multicast_loop_v4(multicast_loop_v4) ++ } ++ ++ /// Gets the value of the `IP_MULTICAST_TTL` option for this socket. ++ /// ++ /// For more information about this option, see ++ /// [`set_multicast_ttl_v4`][link]. ++ /// ++ /// [link]: #method.set_multicast_ttl_v4 ++ pub fn multicast_ttl_v4(&self) -> io::Result { ++ self.inner.multicast_ttl_v4() ++ } ++ ++ /// Sets the value of the `IP_MULTICAST_TTL` option for this socket. ++ /// ++ /// Indicates the time-to-live value of outgoing multicast packets for ++ /// this socket. The default value is 1 which means that multicast packets ++ /// don't leave the local network unless explicitly requested. ++ /// ++ /// Note that this may not have any affect on IPv6 sockets. ++ pub fn set_multicast_ttl_v4(&self, multicast_ttl_v4: u32) -> io::Result<()> { ++ self.inner.set_multicast_ttl_v4(multicast_ttl_v4) ++ } ++ ++ /// Gets the value of the `IPV6_MULTICAST_LOOP` option for this socket. ++ /// ++ /// For more information about this option, see ++ /// [`set_multicast_loop_v6`][link]. ++ /// ++ /// [link]: #method.set_multicast_loop_v6 ++ pub fn multicast_loop_v6(&self) -> io::Result { ++ self.inner.multicast_loop_v6() ++ } ++ ++ /// Sets the value of the `IPV6_MULTICAST_LOOP` option for this socket. ++ /// ++ /// Controls whether this socket sees the multicast packets it sends itself. ++ /// Note that this may not have any affect on IPv4 sockets. ++ pub fn set_multicast_loop_v6(&self, multicast_loop_v6: bool) -> io::Result<()> { ++ self.inner.set_multicast_loop_v6(multicast_loop_v6) ++ } ++ ++ ++ /// Executes an operation of the `IP_ADD_MEMBERSHIP` type. ++ /// ++ /// This function specifies a new multicast group for this socket to join. ++ /// The address must be a valid multicast address, and `interface` is the ++ /// address of the local interface with which the system should join the ++ /// multicast group. If it's equal to `INADDR_ANY` then an appropriate ++ /// interface is chosen by the system. ++ pub fn join_multicast_v4(&self, ++ multiaddr: &Ipv4Addr, ++ interface: &Ipv4Addr) -> io::Result<()> { ++ self.inner.join_multicast_v4(multiaddr, interface) ++ } ++ ++ /// Executes an operation of the `IPV6_ADD_MEMBERSHIP` type. ++ /// ++ /// This function specifies a new multicast group for this socket to join. ++ /// The address must be a valid multicast address, and `interface` is the ++ /// index of the interface to join/leave (or 0 to indicate any interface). ++ pub fn join_multicast_v6(&self, ++ multiaddr: &Ipv6Addr, ++ interface: u32) -> io::Result<()> { ++ self.inner.join_multicast_v6(multiaddr, interface) ++ } ++ ++ /// Executes an operation of the `IP_DROP_MEMBERSHIP` type. ++ /// ++ /// For more information about this option, see ++ /// [`join_multicast_v4`][link]. ++ /// ++ /// [link]: #method.join_multicast_v4 ++ pub fn leave_multicast_v4(&self, ++ multiaddr: &Ipv4Addr, ++ interface: &Ipv4Addr) -> io::Result<()> { ++ self.inner.leave_multicast_v4(multiaddr, interface) ++ } ++ ++ /// Executes an operation of the `IPV6_DROP_MEMBERSHIP` type. ++ /// ++ /// For more information about this option, see ++ /// [`join_multicast_v6`][link]. ++ /// ++ /// [link]: #method.join_multicast_v6 ++ pub fn leave_multicast_v6(&self, ++ multiaddr: &Ipv6Addr, ++ interface: u32) -> io::Result<()> { ++ self.inner.leave_multicast_v6(multiaddr, interface) ++ } ++ ++ /// Reads the linger duration for this socket by getting the SO_LINGER ++ /// option ++ pub fn linger(&self) -> io::Result> { ++ self.inner.linger() ++ } ++ ++ /// Sets the linger duration of this socket by setting the SO_LINGER option ++ pub fn set_linger(&self, dur: Option) -> io::Result<()> { ++ self.inner.set_linger(dur) ++ } ++ ++ /// Check the `SO_REUSEADDR` option on this socket. ++ pub fn reuse_address(&self) -> io::Result { ++ self.inner.reuse_address() ++ } ++ ++ /// Set value for the `SO_REUSEADDR` option on this socket. ++ /// ++ /// This indicates that futher calls to `bind` may allow reuse of local ++ /// addresses. For IPv4 sockets this means that a socket may bind even when ++ /// there's a socket already listening on this port. ++ pub fn set_reuse_address(&self, reuse: bool) -> io::Result<()> { ++ self.inner.set_reuse_address(reuse) ++ } ++ ++ /// Gets the value of the `SO_RCVBUF` option on this socket. ++ /// ++ /// For more information about this option, see ++ /// [`set_recv_buffer_size`][link]. ++ /// ++ /// [link]: #method.set_recv_buffer_size ++ pub fn recv_buffer_size(&self) -> io::Result { ++ self.inner.recv_buffer_size() ++ } ++ ++ /// Sets the value of the `SO_RCVBUF` option on this socket. ++ /// ++ /// Changes the size of the operating system's receive buffer associated ++ /// with the socket. ++ pub fn set_recv_buffer_size(&self, size: usize) -> io::Result<()> { ++ self.inner.set_recv_buffer_size(size) ++ } ++ ++ /// Gets the value of the `SO_SNDBUF` option on this socket. ++ /// ++ /// For more information about this option, see [`set_send_buffer`][link]. ++ /// ++ /// [link]: #method.set_send_buffer ++ pub fn send_buffer_size(&self) -> io::Result { ++ self.inner.send_buffer_size() ++ } ++ ++ /// Sets the value of the `SO_SNDBUF` option on this socket. ++ /// ++ /// Changes the size of the operating system's send buffer associated with ++ /// the socket. ++ pub fn set_send_buffer_size(&self, size: usize) -> io::Result<()> { ++ self.inner.set_send_buffer_size(size) ++ } ++ ++ /// Returns whether keepalive messages are enabled on this socket, and if so ++ /// the duration of time between them. ++ /// ++ /// For more information about this option, see [`set_keepalive`][link]. ++ /// ++ /// [link]: #method.set_keepalive ++ pub fn keepalive(&self) -> io::Result> { ++ self.inner.keepalive() ++ } ++ ++ /// Sets whether keepalive messages are enabled to be sent on this socket. ++ /// ++ /// On Unix, this option will set the `SO_KEEPALIVE` as well as the ++ /// `TCP_KEEPALIVE` or `TCP_KEEPIDLE` option (depending on your platform). ++ /// On Windows, this will set the `SIO_KEEPALIVE_VALS` option. ++ /// ++ /// If `None` is specified then keepalive messages are disabled, otherwise ++ /// the duration specified will be the time to remain idle before sending a ++ /// TCP keepalive probe. ++ /// ++ /// Some platforms specify this value in seconds, so sub-second ++ /// specifications may be omitted. ++ pub fn set_keepalive(&self, keepalive: Option) -> io::Result<()> { ++ self.inner.set_keepalive(keepalive) ++ } ++ ++ /// Check the value of the `SO_REUSEPORT` option on this socket. ++ /// ++ /// This function is only available on Unix when the `reuseport` feature is ++ /// enabled. ++ #[cfg(all(unix, feature = "reuseport"))] ++ pub fn reuse_port(&self) -> io::Result { ++ self.inner.reuse_port() ++ } ++ ++ /// Set value for the `SO_REUSEPORT` option on this socket. ++ /// ++ /// This indicates that futher calls to `bind` may allow reuse of local ++ /// addresses. For IPv4 sockets this means that a socket may bind even when ++ /// there's a socket already listening on this port. ++ /// ++ /// This function is only available on Unix when the `reuseport` feature is ++ /// enabled. ++ #[cfg(all(unix, feature = "reuseport"))] ++ pub fn set_reuse_port(&self, reuse: bool) -> io::Result<()> { ++ self.inner.set_reuse_port(reuse) ++ } ++} ++ ++impl Read for Socket { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.inner.read(buf) ++ } ++} ++ ++impl<'a> Read for &'a Socket { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ (&self.inner).read(buf) ++ } ++} ++ ++impl Write for Socket { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.inner.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.inner.flush() ++ } ++} ++ ++impl<'a> Write for &'a Socket { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ (&self.inner).write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ (&self.inner).flush() ++ } ++} ++ ++impl fmt::Debug for Socket { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ self.inner.fmt(f) ++ } ++} ++ ++impl From for Socket { ++ fn from(socket: net::TcpStream) -> Socket { ++ Socket { inner: socket.into() } ++ } ++} ++ ++impl From for Socket { ++ fn from(socket: net::TcpListener) -> Socket { ++ Socket { inner: socket.into() } ++ } ++} ++ ++impl From for Socket { ++ fn from(socket: net::UdpSocket) -> Socket { ++ Socket { inner: socket.into() } ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for Socket { ++ fn from(socket: UnixStream) -> Socket { ++ Socket { inner: socket.into() } ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for Socket { ++ fn from(socket: UnixListener) -> Socket { ++ Socket { inner: socket.into() } ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for Socket { ++ fn from(socket: UnixDatagram) -> Socket { ++ Socket { inner: socket.into() } ++ } ++} ++ ++impl From for net::TcpStream { ++ fn from(socket: Socket) -> net::TcpStream { ++ socket.inner.into() ++ } ++} ++ ++impl From for net::TcpListener { ++ fn from(socket: Socket) -> net::TcpListener { ++ socket.inner.into() ++ } ++} ++ ++impl From for net::UdpSocket { ++ fn from(socket: Socket) -> net::UdpSocket { ++ socket.inner.into() ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for UnixStream { ++ fn from(socket: Socket) -> UnixStream { ++ socket.inner.into() ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for UnixListener { ++ fn from(socket: Socket) -> UnixListener { ++ socket.inner.into() ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for UnixDatagram { ++ fn from(socket: Socket) -> UnixDatagram { ++ socket.inner.into() ++ } ++} ++ ++impl Domain { ++ /// Domain for IPv4 communication, corresponding to `AF_INET`. ++ pub fn ipv4() -> Domain { ++ Domain(c::AF_INET) ++ } ++ ++ /// Domain for IPv6 communication, corresponding to `AF_INET6`. ++ pub fn ipv6() -> Domain { ++ Domain(c::AF_INET6) ++ } ++ ++ /// Domain for Unix socket communication, corresponding to `AF_UNIX`. ++ /// ++ /// This function is only available on Unix when the `unix` feature is ++ /// activated. ++ #[cfg(all(unix, feature = "unix"))] ++ pub fn unix() -> Domain { ++ Domain(c::AF_UNIX) ++ } ++} ++ ++impl From for Domain { ++ fn from(a: i32) -> Domain { ++ Domain(a) ++ } ++} ++ ++impl From for i32 { ++ fn from(a: Domain) -> i32 { ++ a.into() ++ } ++} ++ ++impl Type { ++ /// Type corresponding to `SOCK_STREAM` ++ /// ++ /// Used for protocols such as TCP. ++ pub fn stream() -> Type { ++ Type(c::SOCK_STREAM) ++ } ++ ++ /// Type corresponding to `SOCK_DGRAM` ++ /// ++ /// Used for protocols such as UDP. ++ pub fn dgram() -> Type { ++ Type(c::SOCK_DGRAM) ++ } ++ ++ /// Type corresponding to `SOCK_SEQPACKET` ++ pub fn seqpacket() -> Type { ++ Type(c::SOCK_SEQPACKET) ++ } ++ ++ /// Type corresponding to `SOCK_RAW` ++ pub fn raw() -> Type { ++ Type(c::SOCK_RAW) ++ } ++} ++ ++impl From for Type { ++ fn from(a: i32) -> Type { ++ Type(a) ++ } ++} ++ ++impl From for i32 { ++ fn from(a: Type) -> i32 { ++ a.into() ++ } ++} ++ ++impl From for Protocol { ++ fn from(a: i32) -> Protocol { ++ Protocol(a) ++ } ++} ++ ++impl From for i32 { ++ fn from(a: Protocol) -> i32 { ++ a.into() ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use std::net::SocketAddr; ++ ++ use super::*; ++ ++ #[test] ++ fn connect_timeout_unrouteable() { ++ // this IP is unroutable, so connections should always time out ++ let addr = "10.255.255.1:80".parse::().unwrap().into(); ++ ++ let socket = Socket::new(Domain::ipv4(), Type::stream(), None).unwrap(); ++ match socket.connect_timeout(&addr, Duration::from_millis(250)) { ++ Ok(_) => panic!("unexpected success"), ++ Err(ref e) if e.kind() == io::ErrorKind::TimedOut => {} ++ Err(e) => panic!("unexpected error {}", e), ++ } ++ } ++ ++ #[test] ++ fn connect_timeout_valid() { ++ let socket = Socket::new(Domain::ipv4(), Type::stream(), None).unwrap(); ++ socket.bind(&"127.0.0.1:0".parse::().unwrap().into()).unwrap(); ++ socket.listen(128).unwrap(); ++ ++ let addr = socket.local_addr().unwrap(); ++ ++ let socket = Socket::new(Domain::ipv4(), Type::stream(), None).unwrap(); ++ socket.connect_timeout(&addr, Duration::from_millis(250)).unwrap(); ++ } ++ ++ #[test] ++ #[cfg(all(unix, feature = "pair", feature = "unix"))] ++ fn pair() { ++ let (mut a, mut b) = Socket::pair(Domain::unix(), Type::stream(), None).unwrap(); ++ a.write_all(b"hello world").unwrap(); ++ let mut buf = [0; 11]; ++ b.read_exact(&mut buf).unwrap(); ++ assert_eq!(buf, &b"hello world"[..]); ++ } ++ ++ #[test] ++ #[cfg(all(unix, feature = "unix"))] ++ fn unix() { ++ use tempdir::TempDir; ++ ++ let dir = TempDir::new("unix").unwrap(); ++ let addr = SockAddr::unix(dir.path().join("sock")).unwrap(); ++ ++ let listener = Socket::new(Domain::unix(), Type::stream(), None).unwrap(); ++ listener.bind(&addr).unwrap(); ++ listener.listen(10).unwrap(); ++ ++ let mut a = Socket::new(Domain::unix(), Type::stream(), None).unwrap(); ++ a.connect(&addr).unwrap(); ++ ++ let mut b = listener.accept().unwrap().0; ++ ++ a.write_all(b"hello world").unwrap(); ++ let mut buf = [0; 11]; ++ b.read_exact(&mut buf).unwrap(); ++ assert_eq!(buf, &b"hello world"[..]); ++ } ++} diff --cc vendor/socket2-0.2.3/src/sys/unix/mod.rs index 000000000,000000000..3d1fcb89d new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/src/sys/unix/mod.rs @@@ -1,0 -1,0 +1,1028 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::cmp; ++use std::fmt; ++use std::io::{Read, Write, ErrorKind}; ++use std::io; ++use std::mem; ++use std::net::Shutdown; ++use std::net::{self, Ipv4Addr, Ipv6Addr}; ++use std::ops::Neg; ++use std::os::unix::prelude::*; ++use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT}; ++use std::time::{Duration, Instant}; ++#[cfg(feature = "unix")] ++use std::os::unix::net::{UnixDatagram, UnixListener, UnixStream}; ++ ++use libc::{self, c_void, c_int}; ++use libc::{sockaddr, socklen_t, ssize_t}; ++ ++cfg_if! { ++ if #[cfg(any(target_os = "dragonfly", target_os = "freebsd", ++ target_os = "ios", target_os = "macos", ++ target_os = "openbsd", target_os = "netbsd", ++ target_os = "solaris", target_os = "haiku"))] { ++ use libc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP; ++ use libc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP; ++ } else { ++ use libc::IPV6_ADD_MEMBERSHIP; ++ use libc::IPV6_DROP_MEMBERSHIP; ++ } ++} ++ ++cfg_if! { ++ if #[cfg(any(target_os = "linux", target_os = "android", ++ target_os = "dragonfly", target_os = "freebsd", ++ target_os = "openbsd", target_os = "netbsd", ++ target_os = "haiku", target_os = "bitrig"))] { ++ use libc::MSG_NOSIGNAL; ++ } else { ++ const MSG_NOSIGNAL: c_int = 0x0; ++ } ++} ++ ++cfg_if! { ++ if #[cfg(any(target_os = "macos", target_os = "ios"))] { ++ use libc::TCP_KEEPALIVE as KEEPALIVE_OPTION; ++ } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd", target_os = "haiku"))] { ++ use libc::SO_KEEPALIVE as KEEPALIVE_OPTION; ++ } else { ++ use libc::TCP_KEEPIDLE as KEEPALIVE_OPTION; ++ } ++} ++ ++use SockAddr; ++use utils::One; ++ ++#[macro_use] ++#[cfg(target_os = "linux")] ++mod weak; ++ ++pub struct Socket { ++ fd: c_int, ++} ++ ++impl Socket { ++ pub fn new(family: c_int, ty: c_int, protocol: c_int) -> io::Result { ++ unsafe { ++ // On linux we first attempt to pass the SOCK_CLOEXEC flag to ++ // atomically create the socket and set it as CLOEXEC. Support for ++ // this option, however, was added in 2.6.27, and we still support ++ // 2.6.18 as a kernel, so if the returned error is EINVAL we ++ // fallthrough to the fallback. ++ #[cfg(target_os = "linux")] { ++ match cvt(libc::socket(family, ty | libc::SOCK_CLOEXEC, protocol)) { ++ Ok(fd) => return Ok(Socket::from_raw_fd(fd)), ++ Err(ref e) if e.raw_os_error() == Some(libc::EINVAL) => {} ++ Err(e) => return Err(e), ++ } ++ } ++ ++ let fd = cvt(libc::socket(family, ty, protocol))?; ++ let fd = Socket::from_raw_fd(fd); ++ set_cloexec(fd.as_raw_fd())?; ++ #[cfg(target_os = "macos")] { ++ fd.setsockopt(libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1i32)?; ++ } ++ Ok(fd) ++ } ++ } ++ ++ pub fn pair(family: c_int, ty: c_int, protocol: c_int) -> io::Result<(Socket, Socket)> { ++ unsafe { ++ let mut fds = [0, 0]; ++ cvt(libc::socketpair(family, ty, protocol, fds.as_mut_ptr()))?; ++ let fds = (Socket::from_raw_fd(fds[0]), Socket::from_raw_fd(fds[1])); ++ set_cloexec(fds.0.as_raw_fd())?; ++ set_cloexec(fds.1.as_raw_fd())?; ++ #[cfg(target_os = "macos")] { ++ fds.0.setsockopt(libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1i32)?; ++ fds.1.setsockopt(libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1i32)?; ++ } ++ Ok(fds) ++ } ++ } ++ ++ pub fn bind(&self, addr: &SockAddr) -> io::Result<()> { ++ unsafe { ++ cvt(libc::bind(self.fd, addr.as_ptr(), addr.len() as _)).map(|_| ()) ++ } ++ } ++ ++ pub fn listen(&self, backlog: i32) -> io::Result<()> { ++ unsafe { ++ cvt(libc::listen(self.fd, backlog)).map(|_| ()) ++ } ++ } ++ ++ pub fn connect(&self, addr: &SockAddr) -> io::Result<()> { ++ unsafe { ++ cvt(libc::connect(self.fd, addr.as_ptr(), addr.len())).map(|_| ()) ++ } ++ } ++ ++ pub fn connect_timeout(&self, addr: &SockAddr, timeout: Duration) -> io::Result<()> { ++ self.set_nonblocking(true)?; ++ let r = self.connect(addr); ++ self.set_nonblocking(false)?; ++ ++ match r { ++ Ok(()) => return Ok(()), ++ // there's no io::ErrorKind conversion registered for EINPROGRESS :( ++ Err(ref e) if e.raw_os_error() == Some(libc::EINPROGRESS) => {} ++ Err(e) => return Err(e), ++ } ++ ++ let mut pollfd = libc::pollfd { ++ fd: self.fd, ++ events: libc::POLLOUT, ++ revents: 0, ++ }; ++ ++ if timeout.as_secs() == 0 && timeout.subsec_nanos() == 0 { ++ return Err(io::Error::new(io::ErrorKind::InvalidInput, ++ "cannot set a 0 duration timeout")); ++ } ++ ++ let start = Instant::now(); ++ ++ loop { ++ let elapsed = start.elapsed(); ++ if elapsed >= timeout { ++ return Err(io::Error::new(io::ErrorKind::TimedOut, "connection timed out")); ++ } ++ ++ let timeout = timeout - elapsed; ++ let mut timeout = timeout.as_secs() ++ .saturating_mul(1_000) ++ .saturating_add(timeout.subsec_nanos() as u64 / 1_000_000); ++ if timeout == 0 { ++ timeout = 1; ++ } ++ ++ let timeout = cmp::min(timeout, c_int::max_value() as u64) as c_int; ++ ++ match unsafe { libc::poll(&mut pollfd, 1, timeout) } { ++ -1 => { ++ let err = io::Error::last_os_error(); ++ if err.kind() != io::ErrorKind::Interrupted { ++ return Err(err); ++ } ++ } ++ 0 => return Err(io::Error::new(io::ErrorKind::TimedOut, "connection timed out")), ++ _ => { ++ if pollfd.revents & libc::POLLOUT == 0 { ++ if let Some(e) = self.take_error()? { ++ return Err(e); ++ } ++ } ++ return Ok(()); ++ } ++ } ++ } ++ } ++ ++ pub fn local_addr(&self) -> io::Result { ++ unsafe { ++ let mut storage: libc::sockaddr_storage = mem::zeroed(); ++ let mut len = mem::size_of_val(&storage) as libc::socklen_t; ++ cvt(libc::getsockname(self.fd, ++ &mut storage as *mut _ as *mut _, ++ &mut len))?; ++ Ok(SockAddr::from_raw_parts(&storage as *const _ as *const _, len)) ++ } ++ } ++ ++ pub fn peer_addr(&self) -> io::Result { ++ unsafe { ++ let mut storage: libc::sockaddr_storage = mem::zeroed(); ++ let mut len = mem::size_of_val(&storage) as libc::socklen_t; ++ cvt(libc::getpeername(self.fd, ++ &mut storage as *mut _ as *mut _, ++ &mut len))?; ++ Ok(SockAddr::from_raw_parts(&storage as *const _ as *const _, len)) ++ } ++ } ++ ++ pub fn try_clone(&self) -> io::Result { ++ // implementation lifted from libstd ++ #[cfg(any(target_os = "android", target_os = "haiku"))] ++ use libc::F_DUPFD as F_DUPFD_CLOEXEC; ++ #[cfg(not(any(target_os = "android", target_os = "haiku")))] ++ use libc::F_DUPFD_CLOEXEC; ++ ++ static CLOEXEC_FAILED: AtomicBool = ATOMIC_BOOL_INIT; ++ unsafe { ++ if !CLOEXEC_FAILED.load(Ordering::Relaxed) { ++ match cvt(libc::fcntl(self.fd, F_DUPFD_CLOEXEC, 0)) { ++ Ok(fd) => { ++ let fd = Socket::from_raw_fd(fd); ++ if cfg!(target_os = "linux") { ++ set_cloexec(fd.as_raw_fd())?; ++ } ++ return Ok(fd) ++ } ++ Err(ref e) if e.raw_os_error() == Some(libc::EINVAL) => { ++ CLOEXEC_FAILED.store(true, Ordering::Relaxed); ++ } ++ Err(e) => return Err(e), ++ } ++ } ++ let fd = cvt(libc::fcntl(self.fd, libc::F_DUPFD, 0))?; ++ let fd = Socket::from_raw_fd(fd); ++ set_cloexec(fd.as_raw_fd())?; ++ Ok(fd) ++ } ++ } ++ ++ #[allow(unused_mut)] ++ pub fn accept(&self) -> io::Result<(Socket, SockAddr)> { ++ let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; ++ let mut len = mem::size_of_val(&storage) as socklen_t; ++ ++ let mut socket = None; ++ #[cfg(target_os = "linux")] { ++ weak! { ++ fn accept4(c_int, *mut sockaddr, *mut socklen_t, c_int) -> c_int ++ } ++ if let Some(f) = accept4.get() { ++ let res = cvt_r(|| unsafe { ++ f(self.fd, ++ &mut storage as *mut _ as *mut _, ++ &mut len, ++ libc::SOCK_CLOEXEC) ++ }); ++ match res { ++ Ok(fd) => socket = Some(Socket { fd: fd }), ++ Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => {} ++ Err(e) => return Err(e), ++ } ++ } ++ } ++ ++ let socket = match socket { ++ Some(socket) => socket, ++ None => unsafe { ++ let fd = cvt_r(|| { ++ libc::accept(self.fd, ++ &mut storage as *mut _ as *mut _, ++ &mut len) ++ })?; ++ let fd = Socket::from_raw_fd(fd); ++ set_cloexec(fd.as_raw_fd())?; ++ fd ++ } ++ }; ++ let addr = unsafe { SockAddr::from_raw_parts(&storage as *const _ as *const _, len) }; ++ Ok((socket, addr)) ++ } ++ ++ pub fn take_error(&self) -> io::Result> { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::SOL_SOCKET, libc::SO_ERROR)?; ++ if raw == 0 { ++ Ok(None) ++ } else { ++ Ok(Some(io::Error::from_raw_os_error(raw as i32))) ++ } ++ } ++ } ++ ++ pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { ++ unsafe { ++ let previous = cvt(libc::fcntl(self.fd, libc::F_GETFL))?; ++ let new = if nonblocking { ++ previous | libc::O_NONBLOCK ++ } else { ++ previous & !libc::O_NONBLOCK ++ }; ++ if new != previous { ++ cvt(libc::fcntl(self.fd, libc::F_SETFL, new))?; ++ } ++ Ok(()) ++ } ++ } ++ ++ pub fn shutdown(&self, how: Shutdown) -> io::Result<()> { ++ let how = match how { ++ Shutdown::Write => libc::SHUT_WR, ++ Shutdown::Read => libc::SHUT_RD, ++ Shutdown::Both => libc::SHUT_RDWR, ++ }; ++ cvt(unsafe { libc::shutdown(self.fd, how) })?; ++ Ok(()) ++ } ++ ++ pub fn recv(&self, buf: &mut [u8]) -> io::Result { ++ unsafe { ++ let n = cvt({ ++ libc::recv(self.fd, ++ buf.as_mut_ptr() as *mut c_void, ++ cmp::min(buf.len(), max_len()), ++ 0) ++ })?; ++ Ok(n as usize) ++ } ++ } ++ ++ pub fn peek(&self, buf: &mut [u8]) -> io::Result { ++ unsafe { ++ let n = cvt({ ++ libc::recv(self.fd, ++ buf.as_mut_ptr() as *mut c_void, ++ cmp::min(buf.len(), max_len()), ++ libc::MSG_PEEK) ++ })?; ++ Ok(n as usize) ++ } ++ } ++ ++ pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SockAddr)> { ++ self.recvfrom(buf, 0) ++ } ++ ++ pub fn peek_from(&self, buf: &mut [u8]) -> io::Result<(usize, SockAddr)> { ++ self.recvfrom(buf, libc::MSG_PEEK) ++ } ++ ++ fn recvfrom(&self, buf: &mut [u8], flags: c_int) ++ -> io::Result<(usize, SockAddr)> { ++ unsafe { ++ let mut storage: libc::sockaddr_storage = mem::zeroed(); ++ let mut addrlen = mem::size_of_val(&storage) as socklen_t; ++ ++ let n = cvt({ ++ libc::recvfrom(self.fd, ++ buf.as_mut_ptr() as *mut c_void, ++ cmp::min(buf.len(), max_len()), ++ flags, ++ &mut storage as *mut _ as *mut _, ++ &mut addrlen) ++ })?; ++ let addr = SockAddr::from_raw_parts(&storage as *const _ as *const _, addrlen); ++ Ok((n as usize, addr)) ++ } ++ } ++ ++ pub fn send(&self, buf: &[u8]) -> io::Result { ++ unsafe { ++ let n = cvt({ ++ libc::send(self.fd, ++ buf.as_ptr() as *const c_void, ++ cmp::min(buf.len(), max_len()), ++ MSG_NOSIGNAL) ++ })?; ++ Ok(n as usize) ++ } ++ } ++ ++ pub fn send_to(&self, buf: &[u8], addr: &SockAddr) -> io::Result { ++ unsafe { ++ let n = cvt({ ++ libc::sendto(self.fd, ++ buf.as_ptr() as *const c_void, ++ cmp::min(buf.len(), max_len()), ++ MSG_NOSIGNAL, ++ addr.as_ptr(), ++ addr.len()) ++ })?; ++ Ok(n as usize) ++ } ++ } ++ ++ // ================================================ ++ ++ pub fn ttl(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::IPPROTO_IP, libc::IP_TTL)?; ++ Ok(raw as u32) ++ } ++ } ++ ++ pub fn set_ttl(&self, ttl: u32) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::IPPROTO_IP, libc::IP_TTL, ttl as c_int) ++ } ++ } ++ ++ pub fn only_v6(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::IPPROTO_IPV6, ++ libc::IPV6_V6ONLY)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn set_only_v6(&self, only_v6: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::IPPROTO_IPV6, ++ libc::IPV6_V6ONLY, ++ only_v6 as c_int) ++ } ++ } ++ ++ pub fn read_timeout(&self) -> io::Result> { ++ unsafe { ++ Ok(timeval2dur(self.getsockopt(libc::SOL_SOCKET, libc::SO_RCVTIMEO)?)) ++ } ++ } ++ ++ pub fn set_read_timeout(&self, dur: Option) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::SOL_SOCKET, ++ libc::SO_RCVTIMEO, ++ dur2timeval(dur)?) ++ } ++ } ++ ++ pub fn write_timeout(&self) -> io::Result> { ++ unsafe { ++ Ok(timeval2dur(self.getsockopt(libc::SOL_SOCKET, libc::SO_SNDTIMEO)?)) ++ } ++ } ++ ++ pub fn set_write_timeout(&self, dur: Option) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::SOL_SOCKET, ++ libc::SO_SNDTIMEO, ++ dur2timeval(dur)?) ++ } ++ } ++ ++ pub fn nodelay(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::IPPROTO_TCP, ++ libc::TCP_NODELAY)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::IPPROTO_TCP, ++ libc::TCP_NODELAY, ++ nodelay as c_int) ++ } ++ } ++ ++ pub fn broadcast(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::SOL_SOCKET, ++ libc::SO_BROADCAST)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn set_broadcast(&self, broadcast: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::SOL_SOCKET, ++ libc::SO_BROADCAST, ++ broadcast as c_int) ++ } ++ } ++ ++ pub fn multicast_loop_v4(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::IPPROTO_IP, ++ libc::IP_MULTICAST_LOOP)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn set_multicast_loop_v4(&self, multicast_loop_v4: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::IPPROTO_IP, ++ libc::IP_MULTICAST_LOOP, ++ multicast_loop_v4 as c_int) ++ } ++ } ++ ++ pub fn multicast_ttl_v4(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::IPPROTO_IP, ++ libc::IP_MULTICAST_TTL)?; ++ Ok(raw as u32) ++ } ++ } ++ ++ pub fn set_multicast_ttl_v4(&self, multicast_ttl_v4: u32) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::IPPROTO_IP, ++ libc::IP_MULTICAST_TTL, ++ multicast_ttl_v4 as c_int) ++ } ++ } ++ ++ pub fn multicast_loop_v6(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::IPPROTO_IPV6, ++ libc::IPV6_MULTICAST_LOOP)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn set_multicast_loop_v6(&self, multicast_loop_v6: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::IPPROTO_IPV6, ++ libc::IPV6_MULTICAST_LOOP, ++ multicast_loop_v6 as c_int) ++ } ++ } ++ ++ pub fn join_multicast_v4(&self, ++ multiaddr: &Ipv4Addr, ++ interface: &Ipv4Addr) -> io::Result<()> { ++ let multiaddr = to_s_addr(multiaddr); ++ let interface = to_s_addr(interface); ++ let mreq = libc::ip_mreq { ++ imr_multiaddr: libc::in_addr { s_addr: multiaddr }, ++ imr_interface: libc::in_addr { s_addr: interface }, ++ }; ++ unsafe { ++ self.setsockopt(libc::IPPROTO_IP, libc::IP_ADD_MEMBERSHIP, mreq) ++ } ++ } ++ ++ pub fn join_multicast_v6(&self, ++ multiaddr: &Ipv6Addr, ++ interface: u32) -> io::Result<()> { ++ let multiaddr = to_in6_addr(multiaddr); ++ let mreq = libc::ipv6_mreq { ++ ipv6mr_multiaddr: multiaddr, ++ ipv6mr_interface: to_ipv6mr_interface(interface), ++ }; ++ unsafe { ++ self.setsockopt(libc::IPPROTO_IP, IPV6_ADD_MEMBERSHIP, mreq) ++ } ++ } ++ ++ pub fn leave_multicast_v4(&self, ++ multiaddr: &Ipv4Addr, ++ interface: &Ipv4Addr) -> io::Result<()> { ++ let multiaddr = to_s_addr(multiaddr); ++ let interface = to_s_addr(interface); ++ let mreq = libc::ip_mreq { ++ imr_multiaddr: libc::in_addr { s_addr: multiaddr }, ++ imr_interface: libc::in_addr { s_addr: interface }, ++ }; ++ unsafe { ++ self.setsockopt(libc::IPPROTO_IP, libc::IP_DROP_MEMBERSHIP, mreq) ++ } ++ } ++ ++ pub fn leave_multicast_v6(&self, ++ multiaddr: &Ipv6Addr, ++ interface: u32) -> io::Result<()> { ++ let multiaddr = to_in6_addr(multiaddr); ++ let mreq = libc::ipv6_mreq { ++ ipv6mr_multiaddr: multiaddr, ++ ipv6mr_interface: to_ipv6mr_interface(interface), ++ }; ++ unsafe { ++ self.setsockopt(libc::IPPROTO_IP, IPV6_DROP_MEMBERSHIP, mreq) ++ } ++ } ++ ++ pub fn linger(&self) -> io::Result> { ++ unsafe { ++ Ok(linger2dur(self.getsockopt(libc::SOL_SOCKET, libc::SO_LINGER)?)) ++ } ++ } ++ ++ pub fn set_linger(&self, dur: Option) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::SOL_SOCKET, libc::SO_LINGER, dur2linger(dur)) ++ } ++ } ++ ++ pub fn set_reuse_address(&self, reuse: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::SOL_SOCKET, libc::SO_REUSEADDR, reuse as c_int) ++ } ++ } ++ ++ pub fn reuse_address(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::SOL_SOCKET, ++ libc::SO_REUSEADDR)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn recv_buffer_size(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::SOL_SOCKET, libc::SO_RCVBUF)?; ++ Ok(raw as usize) ++ } ++ } ++ ++ pub fn set_recv_buffer_size(&self, size: usize) -> io::Result<()> { ++ unsafe { ++ // TODO: casting usize to a c_int should be a checked cast ++ self.setsockopt(libc::SOL_SOCKET, libc::SO_RCVBUF, size as c_int) ++ } ++ } ++ ++ pub fn send_buffer_size(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::SOL_SOCKET, libc::SO_SNDBUF)?; ++ Ok(raw as usize) ++ } ++ } ++ ++ pub fn set_send_buffer_size(&self, size: usize) -> io::Result<()> { ++ unsafe { ++ // TODO: casting usize to a c_int should be a checked cast ++ self.setsockopt(libc::SOL_SOCKET, libc::SO_SNDBUF, size as c_int) ++ } ++ } ++ ++ pub fn keepalive(&self) -> io::Result> { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::SOL_SOCKET, ++ libc::SO_KEEPALIVE)?; ++ if raw == 0 { ++ return Ok(None) ++ } ++ let secs: c_int = self.getsockopt(libc::IPPROTO_TCP, ++ KEEPALIVE_OPTION)?; ++ Ok(Some(Duration::new(secs as u64, 0))) ++ } ++ } ++ ++ pub fn set_keepalive(&self, keepalive: Option) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::SOL_SOCKET, ++ libc::SO_KEEPALIVE, ++ keepalive.is_some() as c_int)?; ++ if let Some(dur) = keepalive { ++ // TODO: checked cast here ++ self.setsockopt(libc::IPPROTO_TCP, ++ KEEPALIVE_OPTION, ++ (dur.as_secs() / 1000) as c_int)?; ++ } ++ Ok(()) ++ } ++ } ++ ++ #[cfg(all(unix, feature = "reuseport"))] ++ pub fn reuse_port(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(libc::SOL_SOCKET, ++ libc::SO_REUSEPORT)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ #[cfg(all(unix, feature = "reuseport"))] ++ pub fn set_reuse_port(&self, reuse: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(libc::SOL_SOCKET, libc::SO_REUSEPORT, reuse as c_int) ++ } ++ } ++ ++ unsafe fn setsockopt(&self, ++ opt: c_int, ++ val: c_int, ++ payload: T) -> io::Result<()> ++ where T: Copy, ++ { ++ let payload = &payload as *const T as *const c_void; ++ cvt(libc::setsockopt(self.fd, ++ opt, ++ val, ++ payload, ++ mem::size_of::() as libc::socklen_t))?; ++ Ok(()) ++ } ++ ++ unsafe fn getsockopt(&self, opt: c_int, val: c_int) -> io::Result { ++ let mut slot: T = mem::zeroed(); ++ let mut len = mem::size_of::() as libc::socklen_t; ++ cvt(libc::getsockopt(self.fd, ++ opt, ++ val, ++ &mut slot as *mut _ as *mut _, ++ &mut len))?; ++ assert_eq!(len as usize, mem::size_of::()); ++ Ok(slot) ++ } ++} ++ ++impl Read for Socket { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ <&Socket>::read(&mut &*self, buf) ++ } ++} ++ ++impl<'a> Read for &'a Socket { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ unsafe { ++ let n = cvt({ ++ libc::read(self.fd, ++ buf.as_mut_ptr() as *mut c_void, ++ cmp::min(buf.len(), max_len())) ++ })?; ++ Ok(n as usize) ++ } ++ } ++} ++ ++impl Write for Socket { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ <&Socket>::write(&mut &*self, buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ <&Socket>::flush(&mut &*self) ++ } ++} ++ ++impl<'a> Write for &'a Socket { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.send(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ Ok(()) ++ } ++} ++ ++impl fmt::Debug for Socket { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ let mut f = f.debug_struct("Socket"); ++ f.field("fd", &self.fd); ++ if let Ok(addr) = self.local_addr() { ++ f.field("local_addr", &addr); ++ } ++ if let Ok(addr) = self.peer_addr() { ++ f.field("peer_addr", &addr); ++ } ++ f.finish() ++ } ++} ++ ++impl AsRawFd for Socket { ++ fn as_raw_fd(&self) -> c_int { ++ self.fd ++ } ++} ++ ++impl IntoRawFd for Socket { ++ fn into_raw_fd(self) -> c_int { ++ let fd = self.fd; ++ mem::forget(self); ++ return fd ++ } ++} ++ ++impl FromRawFd for Socket { ++ unsafe fn from_raw_fd(fd: c_int) -> Socket { ++ Socket { fd: fd } ++ } ++} ++ ++impl AsRawFd for ::Socket { ++ fn as_raw_fd(&self) -> c_int { ++ self.inner.as_raw_fd() ++ } ++} ++ ++impl IntoRawFd for ::Socket { ++ fn into_raw_fd(self) -> c_int { ++ self.inner.into_raw_fd() ++ } ++} ++ ++impl FromRawFd for ::Socket { ++ unsafe fn from_raw_fd(fd: c_int) -> ::Socket { ++ ::Socket { inner: Socket::from_raw_fd(fd) } ++ } ++} ++ ++impl Drop for Socket { ++ fn drop(&mut self) { ++ unsafe { ++ let _ = libc::close(self.fd); ++ } ++ } ++} ++ ++impl From for net::TcpStream { ++ fn from(socket: Socket) -> net::TcpStream { ++ unsafe { net::TcpStream::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++impl From for net::TcpListener { ++ fn from(socket: Socket) -> net::TcpListener { ++ unsafe { net::TcpListener::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++impl From for net::UdpSocket { ++ fn from(socket: Socket) -> net::UdpSocket { ++ unsafe { net::UdpSocket::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for UnixStream { ++ fn from(socket: Socket) -> UnixStream { ++ unsafe { UnixStream::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for UnixListener { ++ fn from(socket: Socket) -> UnixListener { ++ unsafe { UnixListener::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for UnixDatagram { ++ fn from(socket: Socket) -> UnixDatagram { ++ unsafe { UnixDatagram::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++impl From for Socket { ++ fn from(socket: net::TcpStream) -> Socket { ++ unsafe { Socket::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++impl From for Socket { ++ fn from(socket: net::TcpListener) -> Socket { ++ unsafe { Socket::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++impl From for Socket { ++ fn from(socket: net::UdpSocket) -> Socket { ++ unsafe { Socket::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for Socket { ++ fn from(socket: UnixStream) -> Socket { ++ unsafe { Socket::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for Socket { ++ fn from(socket: UnixListener) -> Socket { ++ unsafe { Socket::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++#[cfg(all(unix, feature = "unix"))] ++impl From for Socket { ++ fn from(socket: UnixDatagram) -> Socket { ++ unsafe { Socket::from_raw_fd(socket.into_raw_fd()) } ++ } ++} ++ ++fn max_len() -> usize { ++ // The maximum read limit on most posix-like systems is `SSIZE_MAX`, ++ // with the man page quoting that if the count of bytes to read is ++ // greater than `SSIZE_MAX` the result is "unspecified". ++ // ++ // On macOS, however, apparently the 64-bit libc is either buggy or ++ // intentionally showing odd behavior by rejecting any read with a size ++ // larger than or equal to INT_MAX. To handle both of these the read ++ // size is capped on both platforms. ++ if cfg!(target_os = "macos") { ++ ::max_value() as usize - 1 ++ } else { ++ ::max_value() as usize ++ } ++} ++ ++fn cvt>(t: T) -> io::Result { ++ let one: T = T::one(); ++ if t == -one { ++ Err(io::Error::last_os_error()) ++ } else { ++ Ok(t) ++ } ++} ++ ++fn cvt_r(mut f: F) -> io::Result ++ where F: FnMut() -> T, ++ T: One + PartialEq + Neg ++{ ++ loop { ++ match cvt(f()) { ++ Err(ref e) if e.kind() == ErrorKind::Interrupted => {} ++ other => return other, ++ } ++ } ++} ++ ++fn set_cloexec(fd: c_int) -> io::Result<()> { ++ unsafe { ++ let previous = cvt(libc::fcntl(fd, libc::F_GETFD))?; ++ let new = previous | libc::FD_CLOEXEC; ++ if new != previous { ++ cvt(libc::fcntl(fd, libc::F_SETFD, new))?; ++ } ++ Ok(()) ++ } ++} ++ ++fn dur2timeval(dur: Option) -> io::Result { ++ match dur { ++ Some(dur) => { ++ if dur.as_secs() == 0 && dur.subsec_nanos() == 0 { ++ return Err(io::Error::new(io::ErrorKind::InvalidInput, ++ "cannot set a 0 duration timeout")); ++ } ++ ++ let secs = if dur.as_secs() > libc::time_t::max_value() as u64 { ++ libc::time_t::max_value() ++ } else { ++ dur.as_secs() as libc::time_t ++ }; ++ let mut timeout = libc::timeval { ++ tv_sec: secs, ++ tv_usec: (dur.subsec_nanos() / 1000) as libc::suseconds_t, ++ }; ++ if timeout.tv_sec == 0 && timeout.tv_usec == 0 { ++ timeout.tv_usec = 1; ++ } ++ Ok(timeout) ++ } ++ None => { ++ Ok(libc::timeval { ++ tv_sec: 0, ++ tv_usec: 0, ++ }) ++ } ++ } ++} ++ ++fn timeval2dur(raw: libc::timeval) -> Option { ++ if raw.tv_sec == 0 && raw.tv_usec == 0 { ++ None ++ } else { ++ let sec = raw.tv_sec as u64; ++ let nsec = (raw.tv_usec as u32) * 1000; ++ Some(Duration::new(sec, nsec)) ++ } ++} ++ ++fn to_s_addr(addr: &Ipv4Addr) -> libc::in_addr_t { ++ let octets = addr.octets(); ++ ::hton(((octets[0] as libc::in_addr_t) << 24) | ++ ((octets[1] as libc::in_addr_t) << 16) | ++ ((octets[2] as libc::in_addr_t) << 8) | ++ ((octets[3] as libc::in_addr_t) << 0)) ++} ++ ++fn to_in6_addr(addr: &Ipv6Addr) -> libc::in6_addr { ++ let mut ret: libc::in6_addr = unsafe { mem::zeroed() }; ++ ret.s6_addr = addr.octets(); ++ return ret ++} ++ ++#[cfg(target_os = "android")] ++fn to_ipv6mr_interface(value: u32) -> c_int { ++ value as c_int ++} ++ ++#[cfg(not(target_os = "android"))] ++fn to_ipv6mr_interface(value: u32) -> libc::c_uint { ++ value as libc::c_uint ++} ++ ++fn linger2dur(linger_opt: libc::linger) -> Option { ++ if linger_opt.l_onoff == 0 { ++ None ++ } else { ++ Some(Duration::from_secs(linger_opt.l_linger as u64)) ++ } ++} ++ ++fn dur2linger(dur: Option) -> libc::linger { ++ match dur { ++ Some(d) => { ++ libc::linger { ++ l_onoff: 1, ++ l_linger: d.as_secs() as c_int, ++ } ++ } ++ None => libc::linger { l_onoff: 0, l_linger: 0 }, ++ } ++} diff --cc vendor/socket2-0.2.3/src/sys/unix/weak.rs index 000000000,000000000..83f979d22 new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/src/sys/unix/weak.rs @@@ -1,0 -1,0 +1,60 @@@ ++// Copyright 2016 The Rust Project Developers. See the COPYRIGHT ++// file at the top-level directory of this distribution and at ++// http://rust-lang.org/COPYRIGHT. ++// ++// Licensed under the Apache License, Version 2.0 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::marker; ++use std::mem; ++use std::sync::atomic::{AtomicUsize, Ordering}; ++ ++use libc; ++ ++macro_rules! weak { ++ (fn $name:ident($($t:ty),*) -> $ret:ty) => ( ++ #[allow(bad_style)] ++ static $name: ::sys::weak::Weak $ret> = ++ ::sys::weak::Weak { ++ name: concat!(stringify!($name), "\0"), ++ addr: ::std::sync::atomic::ATOMIC_USIZE_INIT, ++ _marker: ::std::marker::PhantomData, ++ }; ++ ) ++} ++ ++pub struct Weak { ++ pub name: &'static str, ++ pub addr: AtomicUsize, ++ pub _marker: marker::PhantomData, ++} ++ ++impl Weak { ++ pub fn get(&self) -> Option<&F> { ++ assert_eq!(mem::size_of::(), mem::size_of::()); ++ unsafe { ++ if self.addr.load(Ordering::SeqCst) == 0 { ++ let ptr = match fetch(self.name) { ++ 1 => 1, ++ n => n, ++ }; ++ self.addr.store(ptr, Ordering::SeqCst); ++ } ++ if self.addr.load(Ordering::SeqCst) == 1 { ++ None ++ } else { ++ mem::transmute::<&AtomicUsize, Option<&F>>(&self.addr) ++ } ++ } ++ } ++} ++ ++unsafe fn fetch(name: &str) -> usize { ++ let name = name.as_bytes(); ++ assert_eq!(name[name.len() - 1], 0); ++ libc::dlsym(libc::RTLD_DEFAULT, name.as_ptr() as *const _) as usize ++} ++ diff --cc vendor/socket2-0.2.3/src/sys/windows.rs index 000000000,000000000..21038e3fe new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/src/sys/windows.rs @@@ -1,0 -1,0 +1,913 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++use std::cmp; ++use std::fmt; ++use std::io::{Read, Write}; ++use std::io; ++use std::mem; ++use std::net::Shutdown; ++use std::net::{self, Ipv4Addr, Ipv6Addr}; ++use std::os::windows::prelude::*; ++use std::ptr; ++use std::sync::{Once, ONCE_INIT}; ++use std::time::Duration; ++ ++use kernel32; ++use winapi::*; ++use ws2_32; ++ ++use SockAddr; ++ ++const HANDLE_FLAG_INHERIT: DWORD = 0x00000001; ++const MSG_PEEK: c_int = 0x2; ++const SD_BOTH: c_int = 2; ++const SD_RECEIVE: c_int = 0; ++const SD_SEND: c_int = 1; ++const SIO_KEEPALIVE_VALS: DWORD = 0x98000004; ++const WSA_FLAG_OVERLAPPED: DWORD = 0x01; ++ ++#[repr(C)] ++struct tcp_keepalive { ++ onoff: c_ulong, ++ keepalivetime: c_ulong, ++ keepaliveinterval: c_ulong, ++} ++ ++fn init() { ++ static INIT: Once = ONCE_INIT; ++ ++ INIT.call_once(|| { ++ // Initialize winsock through the standard library by just creating a ++ // dummy socket. Whether this is successful or not we drop the result as ++ // libstd will be sure to have initialized winsock. ++ let _ = net::UdpSocket::bind("127.0.0.1:34254"); ++ }); ++} ++ ++fn last_error() -> io::Error { ++ io::Error::from_raw_os_error(unsafe { ws2_32::WSAGetLastError() }) ++} ++ ++pub struct Socket { ++ socket: SOCKET, ++} ++ ++impl Socket { ++ pub fn new(family: c_int, ty: c_int, protocol: c_int) -> io::Result { ++ init(); ++ unsafe { ++ let socket = match ws2_32::WSASocketW(family, ++ ty, ++ protocol, ++ ptr::null_mut(), ++ 0, ++ WSA_FLAG_OVERLAPPED) { ++ INVALID_SOCKET => return Err(last_error()), ++ socket => socket, ++ }; ++ let socket = Socket::from_raw_socket(socket); ++ socket.set_no_inherit()?; ++ Ok(socket) ++ } ++ } ++ ++ pub fn bind(&self, addr: &SockAddr) -> io::Result<()> { ++ unsafe { ++ if ws2_32::bind(self.socket, addr.as_ptr(), addr.len()) == 0 { ++ Ok(()) ++ } else { ++ Err(last_error()) ++ } ++ } ++ } ++ ++ pub fn listen(&self, backlog: i32) -> io::Result<()> { ++ unsafe { ++ if ws2_32::listen(self.socket, backlog) == 0 { ++ Ok(()) ++ } else { ++ Err(last_error()) ++ } ++ } ++ } ++ ++ pub fn connect(&self, addr: &SockAddr) -> io::Result<()> { ++ unsafe { ++ if ws2_32::connect(self.socket, addr.as_ptr(), addr.len()) == 0 { ++ Ok(()) ++ } else { ++ Err(last_error()) ++ } ++ } ++ } ++ ++ pub fn connect_timeout(&self, addr: &SockAddr, timeout: Duration) -> io::Result<()> { ++ self.set_nonblocking(true)?; ++ let r = self.connect(addr); ++ self.set_nonblocking(true)?; ++ ++ match r { ++ Ok(()) => return Ok(()), ++ Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {} ++ Err(e) => return Err(e), ++ } ++ ++ if timeout.as_secs() == 0 && timeout.subsec_nanos() == 0 { ++ return Err(io::Error::new(io::ErrorKind::InvalidInput, ++ "cannot set a 0 duration timeout")); ++ } ++ ++ let mut timeout = timeval { ++ tv_sec: timeout.as_secs() as c_long, ++ tv_usec: (timeout.subsec_nanos() / 1000) as c_long, ++ }; ++ if timeout.tv_sec == 0 && timeout.tv_usec == 0 { ++ timeout.tv_usec = 1; ++ } ++ ++ let fds = unsafe { ++ let mut fds = mem::zeroed::(); ++ fds.fd_count = 1; ++ fds.fd_array[0] = self.socket; ++ fds ++ }; ++ ++ let mut writefds = fds; ++ let mut errorfds = fds; ++ ++ match unsafe { ws2_32::select(1, ptr::null_mut(), &mut writefds, &mut errorfds, &timeout) } { ++ SOCKET_ERROR => return Err(io::Error::last_os_error()), ++ 0 => return Err(io::Error::new(io::ErrorKind::TimedOut, "connection timed out")), ++ _ => { ++ if writefds.fd_count != 1 { ++ if let Some(e) = self.take_error()? { ++ return Err(e); ++ } ++ } ++ Ok(()) ++ } ++ } ++ } ++ ++ pub fn local_addr(&self) -> io::Result { ++ unsafe { ++ let mut storage: SOCKADDR_STORAGE = mem::zeroed(); ++ let mut len = mem::size_of_val(&storage) as c_int; ++ if ws2_32::getsockname(self.socket, ++ &mut storage as *mut _ as *mut _, ++ &mut len) != 0 { ++ return Err(last_error()) ++ } ++ Ok(SockAddr::from_raw_parts(&storage as *const _ as *const _, len)) ++ } ++ } ++ ++ pub fn peer_addr(&self) -> io::Result { ++ unsafe { ++ let mut storage: SOCKADDR_STORAGE = mem::zeroed(); ++ let mut len = mem::size_of_val(&storage) as c_int; ++ if ws2_32::getpeername(self.socket, ++ &mut storage as *mut _ as *mut _, ++ &mut len) != 0 { ++ return Err(last_error()) ++ } ++ Ok(SockAddr::from_raw_parts(&storage as *const _ as *const _, len)) ++ } ++ } ++ ++ pub fn try_clone(&self) -> io::Result { ++ unsafe { ++ let mut info: WSAPROTOCOL_INFOW = mem::zeroed(); ++ let r = ws2_32::WSADuplicateSocketW(self.socket, ++ kernel32::GetCurrentProcessId(), ++ &mut info); ++ if r != 0 { ++ return Err(io::Error::last_os_error()) ++ } ++ let socket = ws2_32::WSASocketW(info.iAddressFamily, ++ info.iSocketType, ++ info.iProtocol, ++ &mut info, ++ 0, ++ WSA_FLAG_OVERLAPPED); ++ let socket = match socket { ++ INVALID_SOCKET => return Err(last_error()), ++ n => Socket::from_raw_socket(n), ++ }; ++ socket.set_no_inherit()?; ++ Ok(socket) ++ } ++ } ++ ++ pub fn accept(&self) -> io::Result<(Socket, SockAddr)> { ++ unsafe { ++ let mut storage: SOCKADDR_STORAGE = mem::zeroed(); ++ let mut len = mem::size_of_val(&storage) as c_int; ++ let socket = { ++ ws2_32::accept(self.socket, ++ &mut storage as *mut _ as *mut _, ++ &mut len) ++ }; ++ let socket = match socket { ++ INVALID_SOCKET => return Err(last_error()), ++ socket => Socket::from_raw_socket(socket), ++ }; ++ socket.set_no_inherit()?; ++ let addr = SockAddr::from_raw_parts(&storage as *const _ as *const _, len); ++ Ok((socket, addr)) ++ } ++ } ++ ++ pub fn take_error(&self) -> io::Result> { ++ unsafe { ++ let raw: c_int = self.getsockopt(SOL_SOCKET, SO_ERROR)?; ++ if raw == 0 { ++ Ok(None) ++ } else { ++ Ok(Some(io::Error::from_raw_os_error(raw as i32))) ++ } ++ } ++ } ++ ++ pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { ++ unsafe { ++ let mut nonblocking = nonblocking as c_ulong; ++ let r = ws2_32::ioctlsocket(self.socket, ++ FIONBIO as c_int, ++ &mut nonblocking); ++ if r == 0 { ++ Ok(()) ++ } else { ++ Err(io::Error::last_os_error()) ++ } ++ } ++ } ++ ++ pub fn shutdown(&self, how: Shutdown) -> io::Result<()> { ++ ++ let how = match how { ++ Shutdown::Write => SD_SEND, ++ Shutdown::Read => SD_RECEIVE, ++ Shutdown::Both => SD_BOTH, ++ }; ++ if unsafe { ws2_32::shutdown(self.socket, how) == 0 } { ++ Ok(()) ++ } else { ++ Err(last_error()) ++ } ++ } ++ ++ pub fn recv(&self, buf: &mut [u8]) -> io::Result { ++ unsafe { ++ let n = { ++ ws2_32::recv(self.socket, ++ buf.as_mut_ptr() as *mut c_char, ++ clamp(buf.len()), ++ 0) ++ }; ++ match n { ++ SOCKET_ERROR if ws2_32::WSAGetLastError() == WSAESHUTDOWN as i32 => Ok(0), ++ SOCKET_ERROR => Err(last_error()), ++ n => Ok(n as usize) ++ } ++ } ++ } ++ ++ pub fn peek(&self, buf: &mut [u8]) -> io::Result { ++ unsafe { ++ let n = { ++ ws2_32::recv(self.socket, ++ buf.as_mut_ptr() as *mut c_char, ++ clamp(buf.len()), ++ MSG_PEEK) ++ }; ++ match n { ++ SOCKET_ERROR if ws2_32::WSAGetLastError() == WSAESHUTDOWN as i32 => Ok(0), ++ SOCKET_ERROR => Err(last_error()), ++ n => Ok(n as usize) ++ } ++ } ++ } ++ ++ pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SockAddr)> { ++ self.recvfrom(buf, 0) ++ } ++ ++ pub fn peek_from(&self, buf: &mut [u8]) -> io::Result<(usize, SockAddr)> { ++ self.recvfrom(buf, MSG_PEEK) ++ } ++ ++ fn recvfrom(&self, buf: &mut [u8], flags: c_int) ++ -> io::Result<(usize, SockAddr)> { ++ unsafe { ++ let mut storage: SOCKADDR_STORAGE = mem::zeroed(); ++ let mut addrlen = mem::size_of_val(&storage) as c_int; ++ ++ let n = { ++ ws2_32::recvfrom(self.socket, ++ buf.as_mut_ptr() as *mut c_char, ++ clamp(buf.len()), ++ flags, ++ &mut storage as *mut _ as *mut _, ++ &mut addrlen) ++ }; ++ let n = match n { ++ SOCKET_ERROR if ws2_32::WSAGetLastError() == WSAESHUTDOWN as i32 => 0, ++ SOCKET_ERROR => return Err(last_error()), ++ n => n as usize, ++ }; ++ let addr = SockAddr::from_raw_parts(&storage as *const _ as *const _, addrlen); ++ Ok((n, addr)) ++ } ++ } ++ ++ pub fn send(&self, buf: &[u8]) -> io::Result { ++ unsafe { ++ let n = { ++ ws2_32::send(self.socket, ++ buf.as_ptr() as *const c_char, ++ clamp(buf.len()), ++ 0) ++ }; ++ if n == SOCKET_ERROR { ++ Err(last_error()) ++ } else { ++ Ok(n as usize) ++ } ++ } ++ } ++ ++ pub fn send_to(&self, buf: &[u8], addr: &SockAddr) -> io::Result { ++ unsafe { ++ let n = { ++ ws2_32::sendto(self.socket, ++ buf.as_ptr() as *const c_char, ++ clamp(buf.len()), ++ 0, ++ addr.as_ptr(), ++ addr.len()) ++ }; ++ if n == SOCKET_ERROR { ++ Err(last_error()) ++ } else { ++ Ok(n as usize) ++ } ++ } ++ } ++ ++ // ================================================ ++ ++ pub fn ttl(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(IPPROTO_IP, IP_TTL)?; ++ Ok(raw as u32) ++ } ++ } ++ ++ pub fn set_ttl(&self, ttl: u32) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(IPPROTO_IP, IP_TTL, ttl as c_int) ++ } ++ } ++ ++ pub fn only_v6(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(IPPROTO_IPV6.0 as c_int, ++ IPV6_V6ONLY)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn set_only_v6(&self, only_v6: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(IPPROTO_IPV6.0 as c_int, ++ IPV6_V6ONLY, ++ only_v6 as c_int) ++ } ++ } ++ ++ pub fn read_timeout(&self) -> io::Result> { ++ unsafe { ++ Ok(ms2dur(self.getsockopt(SOL_SOCKET, SO_RCVTIMEO)?)) ++ } ++ } ++ ++ pub fn set_read_timeout(&self, dur: Option) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(SOL_SOCKET, SO_RCVTIMEO, dur2ms(dur)?) ++ } ++ } ++ ++ pub fn write_timeout(&self) -> io::Result> { ++ unsafe { ++ Ok(ms2dur(self.getsockopt(SOL_SOCKET, SO_SNDTIMEO)?)) ++ } ++ } ++ ++ pub fn set_write_timeout(&self, dur: Option) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(SOL_SOCKET, SO_SNDTIMEO, dur2ms(dur)?) ++ } ++ } ++ ++ pub fn nodelay(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(IPPROTO_TCP.0 as c_int, ++ TCP_NODELAY)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(IPPROTO_TCP.0 as c_int, ++ TCP_NODELAY, ++ nodelay as c_int) ++ } ++ } ++ ++ pub fn broadcast(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(SOL_SOCKET, SO_BROADCAST)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn set_broadcast(&self, broadcast: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(SOL_SOCKET, SO_BROADCAST, broadcast as c_int) ++ } ++ } ++ ++ pub fn multicast_loop_v4(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(IPPROTO_IP, IP_MULTICAST_LOOP)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn set_multicast_loop_v4(&self, multicast_loop_v4: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(IPPROTO_IP, ++ IP_MULTICAST_LOOP, ++ multicast_loop_v4 as c_int) ++ } ++ } ++ ++ pub fn multicast_ttl_v4(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(IPPROTO_IP, IP_MULTICAST_TTL)?; ++ Ok(raw as u32) ++ } ++ } ++ ++ pub fn set_multicast_ttl_v4(&self, multicast_ttl_v4: u32) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(IPPROTO_IP, ++ IP_MULTICAST_TTL, ++ multicast_ttl_v4 as c_int) ++ } ++ } ++ ++ pub fn multicast_loop_v6(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(IPPROTO_IPV6.0 as c_int, ++ IPV6_MULTICAST_LOOP)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn set_multicast_loop_v6(&self, multicast_loop_v6: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(IPPROTO_IPV6.0 as c_int, ++ IPV6_MULTICAST_LOOP, ++ multicast_loop_v6 as c_int) ++ } ++ } ++ ++ pub fn join_multicast_v4(&self, ++ multiaddr: &Ipv4Addr, ++ interface: &Ipv4Addr) -> io::Result<()> { ++ let multiaddr = to_s_addr(multiaddr); ++ let interface = to_s_addr(interface); ++ let mreq = ip_mreq { ++ imr_multiaddr: in_addr { S_un: multiaddr }, ++ imr_interface: in_addr { S_un: interface }, ++ }; ++ unsafe { ++ self.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq) ++ } ++ } ++ ++ pub fn join_multicast_v6(&self, ++ multiaddr: &Ipv6Addr, ++ interface: u32) -> io::Result<()> { ++ let multiaddr = to_in6_addr(multiaddr); ++ let mreq = ipv6_mreq { ++ ipv6mr_multiaddr: multiaddr, ++ ipv6mr_interface: interface, ++ }; ++ unsafe { ++ self.setsockopt(IPPROTO_IP, IPV6_ADD_MEMBERSHIP, mreq) ++ } ++ } ++ ++ pub fn leave_multicast_v4(&self, ++ multiaddr: &Ipv4Addr, ++ interface: &Ipv4Addr) -> io::Result<()> { ++ let multiaddr = to_s_addr(multiaddr); ++ let interface = to_s_addr(interface); ++ let mreq = ip_mreq { ++ imr_multiaddr: in_addr { S_un: multiaddr }, ++ imr_interface: in_addr { S_un: interface }, ++ }; ++ unsafe { ++ self.setsockopt(IPPROTO_IP, IP_DROP_MEMBERSHIP, mreq) ++ } ++ } ++ ++ pub fn leave_multicast_v6(&self, ++ multiaddr: &Ipv6Addr, ++ interface: u32) -> io::Result<()> { ++ let multiaddr = to_in6_addr(multiaddr); ++ let mreq = ipv6_mreq { ++ ipv6mr_multiaddr: multiaddr, ++ ipv6mr_interface: interface, ++ }; ++ unsafe { ++ self.setsockopt(IPPROTO_IP, IPV6_DROP_MEMBERSHIP, mreq) ++ } ++ } ++ ++ pub fn linger(&self) -> io::Result> { ++ unsafe { ++ Ok(linger2dur(self.getsockopt(SOL_SOCKET, SO_LINGER)?)) ++ } ++ } ++ ++ pub fn set_linger(&self, dur: Option) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(SOL_SOCKET, SO_LINGER, dur2linger(dur)) ++ } ++ } ++ ++ pub fn set_reuse_address(&self, reuse: bool) -> io::Result<()> { ++ unsafe { ++ self.setsockopt(SOL_SOCKET, SO_REUSEADDR, reuse as c_int) ++ } ++ } ++ ++ pub fn reuse_address(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(SOL_SOCKET, SO_REUSEADDR)?; ++ Ok(raw != 0) ++ } ++ } ++ ++ pub fn recv_buffer_size(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(SOL_SOCKET, SO_RCVBUF)?; ++ Ok(raw as usize) ++ } ++ } ++ ++ pub fn set_recv_buffer_size(&self, size: usize) -> io::Result<()> { ++ unsafe { ++ // TODO: casting usize to a c_int should be a checked cast ++ self.setsockopt(SOL_SOCKET, SO_RCVBUF, size as c_int) ++ } ++ } ++ ++ pub fn send_buffer_size(&self) -> io::Result { ++ unsafe { ++ let raw: c_int = self.getsockopt(SOL_SOCKET, SO_SNDBUF)?; ++ Ok(raw as usize) ++ } ++ } ++ ++ pub fn set_send_buffer_size(&self, size: usize) -> io::Result<()> { ++ unsafe { ++ // TODO: casting usize to a c_int should be a checked cast ++ self.setsockopt(SOL_SOCKET, SO_SNDBUF, size as c_int) ++ } ++ } ++ ++ pub fn keepalive(&self) -> io::Result> { ++ let mut ka = tcp_keepalive { ++ onoff: 0, ++ keepalivetime: 0, ++ keepaliveinterval: 0, ++ }; ++ let n = unsafe { ++ ws2_32::WSAIoctl(self.socket, ++ SIO_KEEPALIVE_VALS, ++ 0 as *mut _, ++ 0, ++ &mut ka as *mut _ as *mut _, ++ mem::size_of_val(&ka) as DWORD, ++ 0 as *mut _, ++ 0 as *mut _, ++ None) ++ }; ++ if n == 0 { ++ Ok(if ka.onoff == 0 { ++ None ++ } else if ka.keepaliveinterval == 0 { ++ None ++ } else { ++ let seconds = ka.keepaliveinterval / 1000; ++ let nanos = (ka.keepaliveinterval % 1000) * 1_000_000; ++ Some(Duration::new(seconds as u64, nanos as u32)) ++ }) ++ } else { ++ Err(last_error()) ++ } ++ } ++ ++ pub fn set_keepalive(&self, keepalive: Option) -> io::Result<()> { ++ let ms = dur2ms(keepalive)?; ++ // TODO: checked casts here ++ let ka = tcp_keepalive { ++ onoff: keepalive.is_some() as c_ulong, ++ keepalivetime: ms as c_ulong, ++ keepaliveinterval: ms as c_ulong, ++ }; ++ let n = unsafe { ++ ws2_32::WSAIoctl(self.socket, ++ SIO_KEEPALIVE_VALS, ++ &ka as *const _ as *mut _, ++ mem::size_of_val(&ka) as DWORD, ++ 0 as *mut _, ++ 0, ++ 0 as *mut _, ++ 0 as *mut _, ++ None) ++ }; ++ if n == 0 { ++ Ok(()) ++ } else { ++ Err(last_error()) ++ } ++ } ++ ++ unsafe fn setsockopt(&self, ++ opt: c_int, ++ val: c_int, ++ payload: T) -> io::Result<()> ++ where T: Copy, ++ { ++ let payload = &payload as *const T as *const c_char; ++ if ws2_32::setsockopt(self.socket, ++ opt, ++ val, ++ payload, ++ mem::size_of::() as c_int) == 0 { ++ Ok(()) ++ } else { ++ Err(last_error()) ++ } ++ } ++ ++ unsafe fn getsockopt(&self, opt: c_int, val: c_int) -> io::Result { ++ let mut slot: T = mem::zeroed(); ++ let mut len = mem::size_of::() as c_int; ++ if ws2_32::getsockopt(self.socket, ++ opt, ++ val, ++ &mut slot as *mut _ as *mut _, ++ &mut len) == 0 { ++ assert_eq!(len as usize, mem::size_of::()); ++ Ok(slot) ++ } else { ++ Err(last_error()) ++ } ++ } ++ ++ fn set_no_inherit(&self) -> io::Result<()> { ++ unsafe { ++ let r = kernel32::SetHandleInformation(self.socket as HANDLE, ++ HANDLE_FLAG_INHERIT, ++ 0); ++ if r == 0 { ++ Err(io::Error::last_os_error()) ++ } else { ++ Ok(()) ++ } ++ } ++ } ++} ++ ++impl Read for Socket { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ <&Socket>::read(&mut &*self, buf) ++ } ++} ++ ++impl<'a> Read for &'a Socket { ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ self.recv(buf) ++ } ++} ++ ++impl Write for Socket { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ <&Socket>::write(&mut &*self, buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ <&Socket>::flush(&mut &*self) ++ } ++} ++ ++impl<'a> Write for &'a Socket { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.send(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ Ok(()) ++ } ++} ++ ++impl fmt::Debug for Socket { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ let mut f = f.debug_struct("Socket"); ++ f.field("socket", &self.socket); ++ if let Ok(addr) = self.local_addr() { ++ f.field("local_addr", &addr); ++ } ++ if let Ok(addr) = self.peer_addr() { ++ f.field("peer_addr", &addr); ++ } ++ f.finish() ++ } ++} ++ ++impl AsRawSocket for Socket { ++ fn as_raw_socket(&self) -> SOCKET { ++ self.socket ++ } ++} ++ ++impl IntoRawSocket for Socket { ++ fn into_raw_socket(self) -> SOCKET { ++ let socket = self.socket; ++ mem::forget(self); ++ return socket ++ } ++} ++ ++impl FromRawSocket for Socket { ++ unsafe fn from_raw_socket(socket: SOCKET) -> Socket { ++ Socket { socket: socket } ++ } ++} ++ ++impl AsRawSocket for ::Socket { ++ fn as_raw_socket(&self) -> SOCKET { ++ self.inner.as_raw_socket() ++ } ++} ++ ++impl IntoRawSocket for ::Socket { ++ fn into_raw_socket(self) -> SOCKET { ++ self.inner.into_raw_socket() ++ } ++} ++ ++impl FromRawSocket for ::Socket { ++ unsafe fn from_raw_socket(socket: SOCKET) -> ::Socket { ++ ::Socket { inner: Socket::from_raw_socket(socket) } ++ } ++} ++ ++impl Drop for Socket { ++ fn drop(&mut self) { ++ unsafe { ++ let _ = ws2_32::closesocket(self.socket); ++ } ++ } ++} ++ ++impl From for net::TcpStream { ++ fn from(socket: Socket) -> net::TcpStream { ++ unsafe { net::TcpStream::from_raw_socket(socket.into_raw_socket()) } ++ } ++} ++ ++impl From for net::TcpListener { ++ fn from(socket: Socket) -> net::TcpListener { ++ unsafe { net::TcpListener::from_raw_socket(socket.into_raw_socket()) } ++ } ++} ++ ++impl From for net::UdpSocket { ++ fn from(socket: Socket) -> net::UdpSocket { ++ unsafe { net::UdpSocket::from_raw_socket(socket.into_raw_socket()) } ++ } ++} ++ ++impl From for Socket { ++ fn from(socket: net::TcpStream) -> Socket { ++ unsafe { Socket::from_raw_socket(socket.into_raw_socket()) } ++ } ++} ++ ++impl From for Socket { ++ fn from(socket: net::TcpListener) -> Socket { ++ unsafe { Socket::from_raw_socket(socket.into_raw_socket()) } ++ } ++} ++ ++impl From for Socket { ++ fn from(socket: net::UdpSocket) -> Socket { ++ unsafe { Socket::from_raw_socket(socket.into_raw_socket()) } ++ } ++} ++ ++fn clamp(input: usize) -> c_int { ++ cmp::min(input, ::max_value() as usize) as c_int ++} ++ ++fn dur2ms(dur: Option) -> io::Result { ++ match dur { ++ Some(dur) => { ++ // Note that a duration is a (u64, u32) (seconds, nanoseconds) ++ // pair, and the timeouts in windows APIs are typically u32 ++ // milliseconds. To translate, we have two pieces to take care of: ++ // ++ // * Nanosecond precision is rounded up ++ // * Greater than u32::MAX milliseconds (50 days) is rounded up to ++ // INFINITE (never time out). ++ let ms = dur.as_secs().checked_mul(1000).and_then(|ms| { ++ ms.checked_add((dur.subsec_nanos() as u64) / 1_000_000) ++ }).and_then(|ms| { ++ ms.checked_add(if dur.subsec_nanos() % 1_000_000 > 0 {1} else {0}) ++ }).map(|ms| { ++ if ms > ::max_value() as u64 { ++ INFINITE ++ } else { ++ ms as DWORD ++ } ++ }).unwrap_or(INFINITE); ++ if ms == 0 { ++ return Err(io::Error::new(io::ErrorKind::InvalidInput, ++ "cannot set a 0 duration timeout")); ++ } ++ Ok(ms) ++ } ++ None => Ok(0), ++ } ++} ++ ++fn ms2dur(raw: DWORD) -> Option { ++ if raw == 0 { ++ None ++ } else { ++ let secs = raw / 1000; ++ let nsec = (raw % 1000) * 1000000; ++ Some(Duration::new(secs as u64, nsec as u32)) ++ } ++} ++ ++fn to_s_addr(addr: &Ipv4Addr) -> ULONG { ++ let octets = addr.octets(); ++ ::hton(((octets[0] as ULONG) << 24) | ++ ((octets[1] as ULONG) << 16) | ++ ((octets[2] as ULONG) << 8) | ++ ((octets[3] as ULONG) << 0)) ++} ++ ++fn to_in6_addr(addr: &Ipv6Addr) -> in6_addr { ++ let mut ret: in6_addr = unsafe { mem::zeroed() }; ++ ret.s6_addr = addr.octets(); ++ return ret ++} ++ ++fn linger2dur(linger_opt: linger) -> Option { ++ if linger_opt.l_onoff == 0 { ++ None ++ } else { ++ Some(Duration::from_secs(linger_opt.l_linger as u64)) ++ } ++} ++ ++fn dur2linger(dur: Option) -> linger { ++ match dur { ++ Some(d) => { ++ linger { ++ l_onoff: 1, ++ l_linger: d.as_secs() as u16, ++ } ++ } ++ None => linger { l_onoff: 0, l_linger: 0 }, ++ } ++} diff --cc vendor/socket2-0.2.3/src/utils.rs index 000000000,000000000..21fe9d61f new file mode 100644 --- /dev/null +++ b/vendor/socket2-0.2.3/src/utils.rs @@@ -1,0 -1,0 +1,51 @@@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++ ++#[doc(hidden)] ++pub trait NetInt { ++ fn from_be(i: Self) -> Self; ++ fn to_be(&self) -> Self; ++} ++macro_rules! doit { ++ ($($t:ident)*) => ($(impl NetInt for $t { ++ fn from_be(i: Self) -> Self { <$t>::from_be(i) } ++ fn to_be(&self) -> Self { <$t>::to_be(*self) } ++ })*) ++} ++doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } ++ ++#[doc(hidden)] ++pub trait One { ++ fn one() -> Self; ++} ++ ++macro_rules! one { ++ ($($t:ident)*) => ($( ++ impl One for $t { fn one() -> $t { 1 } } ++ )*) ++} ++ ++one! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } ++ ++ ++#[doc(hidden)] ++pub trait Zero { ++ fn zero() -> Self; ++} ++ ++macro_rules! zero { ++ ($($t:ident)*) => ($( ++ impl Zero for $t { fn zero() -> $t { 0 } } ++ )*) ++} ++ ++zero! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } ++ diff --cc vendor/termcolor-0.3.3/.cargo-checksum.json index 000000000,000000000..47cd666d1 new file mode 100644 --- /dev/null +++ b/vendor/termcolor-0.3.3/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"9065bced9c3e43453aa3d56f1e98590b8455b341d2fa191a1090c0dd0b242c75"} diff --cc vendor/termcolor-0.3.3/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/termcolor-0.3.3/.cargo-ok diff --cc vendor/termcolor-0.3.3/COPYING index 000000000,000000000..bb9c20a09 new file mode 100644 --- /dev/null +++ b/vendor/termcolor-0.3.3/COPYING @@@ -1,0 -1,0 +1,3 @@@ ++This project is dual-licensed under the Unlicense and MIT licenses. ++ ++You may use this code under the terms of either license. diff --cc vendor/termcolor-0.3.3/Cargo.toml index 000000000,000000000..d95122f32 new file mode 100644 --- /dev/null +++ b/vendor/termcolor-0.3.3/Cargo.toml @@@ -1,0 -1,0 +1,29 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "termcolor" ++version = "0.3.3" ++authors = ["Andrew Gallant "] ++description = "A simple cross platform library for writing colored text to a terminal.\n" ++homepage = "https://github.com/BurntSushi/ripgrep/tree/master/termcolor" ++documentation = "https://docs.rs/termcolor" ++readme = "README.md" ++keywords = ["windows", "win", "color", "ansi", "console"] ++license = "Unlicense/MIT" ++repository = "https://github.com/BurntSushi/ripgrep/tree/master/termcolor" ++ ++[lib] ++name = "termcolor" ++bench = false ++[target."cfg(windows)".dependencies.wincolor] ++version = "0.1.3" diff --cc vendor/termcolor-0.3.3/LICENSE-MIT index 000000000,000000000..3b0a5dc09 new file mode 100644 --- /dev/null +++ b/vendor/termcolor-0.3.3/LICENSE-MIT @@@ -1,0 -1,0 +1,21 @@@ ++The MIT License (MIT) ++ ++Copyright (c) 2015 Andrew Gallant ++ ++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 --cc vendor/termcolor-0.3.3/README.md index 000000000,000000000..11bda604f new file mode 100644 --- /dev/null +++ b/vendor/termcolor-0.3.3/README.md @@@ -1,0 -1,0 +1,86 @@@ ++termcolor ++========= ++A simple cross platform library for writing colored text to a terminal. This ++library writes colored text either using standard ANSI escape sequences or ++by interacting with the Windows console. Several convenient abstractions ++are provided for use in single-threaded or multi-threaded command line ++applications. ++ ++[![Linux build status](https://api.travis-ci.org/BurntSushi/ripgrep.png)](https://travis-ci.org/BurntSushi/ripgrep) ++[![Windows build status](https://ci.appveyor.com/api/projects/status/github/BurntSushi/ripgrep?svg=true)](https://ci.appveyor.com/project/BurntSushi/ripgrep) ++[![](https://img.shields.io/crates/v/termcolor.svg)](https://crates.io/crates/termcolor) ++ ++Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). ++ ++### Documentation ++ ++[https://docs.rs/termcolor](https://docs.rs/termcolor) ++ ++### Usage ++ ++Add this to your `Cargo.toml`: ++ ++```toml ++[dependencies] ++termcolor = "0.3" ++``` ++ ++and this to your crate root: ++ ++```rust ++extern crate termcolor; ++``` ++ ++### Organization ++ ++The `WriteColor` trait extends the `io::Write` trait with methods for setting ++colors or resetting them. ++ ++`StandardStream` and `StandardStreamLock` both satisfy `WriteColor` and are ++analogous to `std::io::Stdout` and `std::io::StdoutLock`, or `std::io::Stderr` ++and `std::io::StderrLock`. ++ ++`Buffer` is an in memory buffer that supports colored text. In a parallel ++program, each thread might write to its own buffer. A buffer can be printed to ++stdout or stderr using a `BufferWriter`. The advantage of this design is that ++each thread can work in parallel on a buffer without having to synchronize ++access to global resources such as the Windows console. Moreover, this design ++also prevents interleaving of buffer output. ++ ++`Ansi` and `NoColor` both satisfy `WriteColor` for arbitrary implementors of ++`io::Write`. These types are useful when you know exactly what you need. An ++analogous type for the Windows console is not provided since it cannot exist. ++ ++### Example: using `StandardStream` ++ ++The `StandardStream` type in this crate works similarly to `std::io::Stdout`, ++except it is augmented with methods for coloring by the `WriteColor` trait. ++For example, to write some green text: ++ ++```rust ++use std::io::Write; ++use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; ++ ++let mut stdout = StandardStream::stdout(ColorChoice::Always); ++try!(stdout.set_color(ColorSpec::new().set_fg(Some(Color::Green)))); ++try!(writeln!(&mut stdout, "green text!")); ++``` ++ ++### Example: using `BufferWriter` ++ ++A `BufferWriter` can create buffers and write buffers to stdout or stderr. It ++does *not* implement `io::Write` or `WriteColor` itself. Instead, `Buffer` ++implements `io::Write` and `io::WriteColor`. ++ ++This example shows how to print some green text to stderr. ++ ++```rust ++use std::io::Write; ++use termcolor::{BufferWriter, Color, ColorChoice, ColorSpec, WriteColor}; ++ ++let mut bufwtr = BufferWriter::stderr(ColorChoice::Always); ++let mut buffer = bufwtr.buffer(); ++try!(buffer.set_color(ColorSpec::new().set_fg(Some(Color::Green)))); ++try!(writeln!(&mut buffer, "green text!")); ++try!(bufwtr.print(&buffer)); ++``` diff --cc vendor/termcolor-0.3.3/UNLICENSE index 000000000,000000000..68a49daad new file mode 100644 --- /dev/null +++ b/vendor/termcolor-0.3.3/UNLICENSE @@@ -1,0 -1,0 +1,24 @@@ ++This is free and unencumbered software released into the public domain. ++ ++Anyone is free to copy, modify, publish, use, compile, sell, or ++distribute this software, either in source code form or as a compiled ++binary, for any purpose, commercial or non-commercial, and by any ++means. ++ ++In jurisdictions that recognize copyright laws, the author or authors ++of this software dedicate any and all copyright interest in the ++software to the public domain. We make this dedication for the benefit ++of the public at large and to the detriment of our heirs and ++successors. We intend this dedication to be an overt act of ++relinquishment in perpetuity of all present and future rights to this ++software under copyright law. ++ ++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 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. ++ ++For more information, please refer to diff --cc vendor/termcolor-0.3.3/src/lib.rs index 000000000,000000000..b07071e94 new file mode 100644 --- /dev/null +++ b/vendor/termcolor-0.3.3/src/lib.rs @@@ -1,0 -1,0 +1,1388 @@@ ++/*! ++This crate provides a cross platform abstraction for writing colored text to ++a terminal. Colors are written using either ANSI escape sequences or by ++communicating with a Windows console. Much of this API was motivated by use ++inside command line applications, where colors or styles can be configured ++by the end user and/or the environment. ++ ++This crate also provides platform independent support for writing colored text ++to an in memory buffer. While this is easy to do with ANSI escape sequences ++(because they are in the buffer themselves), it is trickier to do with the ++Windows console API, which requires synchronous communication. ++ ++# Organization ++ ++The `WriteColor` trait extends the `io::Write` trait with methods for setting ++colors or resetting them. ++ ++`StandardStream` and `StandardStreamLock` both satisfy `WriteColor` and are ++analogous to `std::io::Stdout` and `std::io::StdoutLock`, or `std::io::Stderr` ++and `std::io::StderrLock`. ++ ++`Buffer` is an in memory buffer that supports colored text. In a parallel ++program, each thread might write to its own buffer. A buffer can be printed to ++using a `BufferWriter`. The advantage of this design is that each thread can ++work in parallel on a buffer without having to synchronize access to global ++resources such as the Windows console. Moreover, this design also prevents ++interleaving of buffer output. ++ ++`Ansi` and `NoColor` both satisfy `WriteColor` for arbitrary implementors of ++`io::Write`. These types are useful when you know exactly what you need. An ++analogous type for the Windows console is not provided since it cannot exist. ++ ++# Example: using `StandardStream` ++ ++The `StandardStream` type in this crate works similarly to `std::io::Stdout`, ++except it is augmented with methods for coloring by the `WriteColor` trait. ++For example, to write some green text: ++ ++```rust,no_run ++# fn test() -> Result<(), Box<::std::error::Error>> { ++use std::io::Write; ++use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; ++ ++let mut stdout = StandardStream::stdout(ColorChoice::Always); ++try!(stdout.set_color(ColorSpec::new().set_fg(Some(Color::Green)))); ++try!(writeln!(&mut stdout, "green text!")); ++# Ok(()) } ++``` ++ ++# Example: using `BufferWriter` ++ ++A `BufferWriter` can create buffers and write buffers to stdout or stderr. It ++does *not* implement `io::Write` or `WriteColor` itself. Instead, `Buffer` ++implements `io::Write` and `io::WriteColor`. ++ ++This example shows how to print some green text to stderr. ++ ++```rust,no_run ++# fn test() -> Result<(), Box<::std::error::Error>> { ++use std::io::Write; ++use termcolor::{BufferWriter, Color, ColorChoice, ColorSpec, WriteColor}; ++ ++let mut bufwtr = BufferWriter::stderr(ColorChoice::Always); ++let mut buffer = bufwtr.buffer(); ++try!(buffer.set_color(ColorSpec::new().set_fg(Some(Color::Green)))); ++try!(writeln!(&mut buffer, "green text!")); ++try!(bufwtr.print(&buffer)); ++# Ok(()) } ++``` ++*/ ++ ++#![deny(missing_docs)] ++ ++#[cfg(windows)] ++extern crate wincolor; ++ ++use std::env; ++use std::error; ++use std::fmt; ++use std::io::{self, Write}; ++use std::str::FromStr; ++#[cfg(windows)] ++use std::sync::{Mutex, MutexGuard}; ++use std::sync::atomic::{AtomicBool, Ordering}; ++ ++/// This trait describes the behavior of writers that support colored output. ++pub trait WriteColor: io::Write { ++ /// Returns true if and only if the underlying writer supports colors. ++ fn supports_color(&self) -> bool; ++ ++ /// Set the color settings of the writer. ++ /// ++ /// Subsequent writes to this writer will use these settings until either ++ /// `reset` is called or new color settings are set. ++ /// ++ /// If there was a problem setting the color settings, then an error is ++ /// returned. ++ fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()>; ++ ++ /// Reset the current color settings to their original settings. ++ /// ++ /// If there was a problem resetting the color settings, then an error is ++ /// returned. ++ fn reset(&mut self) -> io::Result<()>; ++} ++ ++impl<'a, T: WriteColor> WriteColor for &'a mut T { ++ fn supports_color(&self) -> bool { (&**self).supports_color() } ++ fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { ++ (&mut **self).set_color(spec) ++ } ++ fn reset(&mut self) -> io::Result<()> { (&mut **self).reset() } ++} ++ ++/// ColorChoice represents the color preferences of an end user. ++#[derive(Clone, Copy, Debug, Eq, PartialEq)] ++pub enum ColorChoice { ++ /// Try very hard to emit colors. This includes emitting ANSI colors ++ /// on Windows if the console API is unavailable. ++ Always, ++ /// AlwaysAnsi is like Always, except it never tries to use anything other ++ /// than emitting ANSI color codes. ++ AlwaysAnsi, ++ /// Try to use colors, but don't force the issue. If the console isn't ++ /// available on Windows, or if TERM=dumb, for example, then don't use ++ /// colors. ++ Auto, ++ /// Never emit colors. ++ Never, ++} ++ ++impl ColorChoice { ++ /// Returns true if we should attempt to write colored output. ++ #[cfg(not(windows))] ++ fn should_attempt_color(&self) -> bool { ++ match *self { ++ ColorChoice::Always => true, ++ ColorChoice::AlwaysAnsi => true, ++ ColorChoice::Never => false, ++ ColorChoice::Auto => { ++ match env::var("TERM") { ++ Err(_) => false, ++ Ok(k) => k != "dumb", ++ } ++ } ++ } ++ } ++ ++ /// Returns true if we should attempt to write colored output. ++ #[cfg(windows)] ++ fn should_attempt_color(&self) -> bool { ++ match *self { ++ ColorChoice::Always => true, ++ ColorChoice::AlwaysAnsi => true, ++ ColorChoice::Never => false, ++ ColorChoice::Auto => { ++ match env::var("TERM") { ++ Err(_) => true, ++ Ok(k) => k != "dumb", ++ } ++ } ++ } ++ } ++ ++ /// Returns true if this choice should forcefully use ANSI color codes. ++ /// ++ /// It's possible that ANSI is still the correct choice even if this ++ /// returns false. ++ #[cfg(windows)] ++ fn should_ansi(&self) -> bool { ++ match *self { ++ ColorChoice::Always => false, ++ ColorChoice::AlwaysAnsi => true, ++ ColorChoice::Never => false, ++ ColorChoice::Auto => { ++ match env::var("TERM") { ++ Err(_) => false, ++ // cygwin doesn't seem to support ANSI escape sequences ++ // and instead has its own variety. However, the Windows ++ // console API may be available. ++ Ok(k) => k != "dumb" && k != "cygwin", ++ } ++ } ++ } ++ } ++} ++ ++/// `std::io` implements `Stdout` and `Stderr` (and their `Lock` variants) as ++/// separate types, which makes it difficult to abstract over them. We use ++/// some simple internal enum types to work around this. ++ ++enum StandardStreamType { ++ Stdout, ++ Stderr, ++} ++ ++enum IoStandardStream { ++ Stdout(io::Stdout), ++ Stderr(io::Stderr), ++} ++ ++impl IoStandardStream { ++ fn new(sty: StandardStreamType) -> IoStandardStream { ++ match sty { ++ StandardStreamType::Stdout => { ++ IoStandardStream::Stdout(io::stdout()) ++ } ++ StandardStreamType::Stderr => { ++ IoStandardStream::Stderr(io::stderr()) ++ } ++ } ++ } ++ ++ fn lock(&self) -> IoStandardStreamLock { ++ match *self { ++ IoStandardStream::Stdout(ref s) => { ++ IoStandardStreamLock::StdoutLock(s.lock()) ++ } ++ IoStandardStream::Stderr(ref s) => { ++ IoStandardStreamLock::StderrLock(s.lock()) ++ } ++ } ++ } ++} ++ ++impl io::Write for IoStandardStream { ++ fn write(&mut self, b: &[u8]) -> io::Result { ++ match *self { ++ IoStandardStream::Stdout(ref mut s) => s.write(b), ++ IoStandardStream::Stderr(ref mut s) => s.write(b), ++ } ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ match *self { ++ IoStandardStream::Stdout(ref mut s) => s.flush(), ++ IoStandardStream::Stderr(ref mut s) => s.flush(), ++ } ++ } ++} ++ ++/// Same rigamorale for the locked variants of the standard streams. ++ ++enum IoStandardStreamLock<'a> { ++ StdoutLock(io::StdoutLock<'a>), ++ StderrLock(io::StderrLock<'a>), ++} ++ ++impl<'a> io::Write for IoStandardStreamLock<'a> { ++ fn write(&mut self, b: &[u8]) -> io::Result { ++ match *self { ++ IoStandardStreamLock::StdoutLock(ref mut s) => s.write(b), ++ IoStandardStreamLock::StderrLock(ref mut s) => s.write(b), ++ } ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ match *self { ++ IoStandardStreamLock::StdoutLock(ref mut s) => s.flush(), ++ IoStandardStreamLock::StderrLock(ref mut s) => s.flush(), ++ } ++ } ++} ++ ++/// Satisfies `io::Write` and `WriteColor`, and supports optional coloring ++/// to either of the standard output streams, stdout and stderr. ++pub struct StandardStream { ++ wtr: LossyStandardStream>, ++} ++ ++/// `StandardStreamLock` is a locked reference to a `StandardStream`. ++/// ++/// This implements the `io::Write` and `WriteColor` traits, and is constructed ++/// via the `Write::lock` method. ++/// ++/// The lifetime `'a` refers to the lifetime of the corresponding ++/// `StandardStream`. ++pub struct StandardStreamLock<'a> { ++ wtr: LossyStandardStream>>, ++} ++ ++/// WriterInner is a (limited) generic representation of a writer. It is ++/// limited because W should only ever be stdout/stderr on Windows. ++enum WriterInner { ++ NoColor(NoColor), ++ Ansi(Ansi), ++ #[cfg(windows)] ++ Windows { wtr: W, console: Mutex }, ++} ++ ++/// WriterInnerLock is a (limited) generic representation of a writer. It is ++/// limited because W should only ever be stdout/stderr on Windows. ++enum WriterInnerLock<'a, W> { ++ NoColor(NoColor), ++ Ansi(Ansi), ++ /// What a gross hack. On Windows, we need to specify a lifetime for the ++ /// console when in a locked state, but obviously don't need to do that ++ /// on Unix, which make the `'a` unused. To satisfy the compiler, we need ++ /// a PhantomData. ++ #[allow(dead_code)] ++ Unreachable(::std::marker::PhantomData<&'a ()>), ++ #[cfg(windows)] ++ Windows { wtr: W, console: MutexGuard<'a, wincolor::Console> }, ++} ++ ++impl StandardStream { ++ /// Create a new `StandardStream` with the given color preferences. ++ /// ++ /// The specific color/style settings can be configured when writing via ++ /// the `WriteColor` trait. ++ #[cfg(not(windows))] ++ fn create(sty: StandardStreamType, choice: ColorChoice) -> StandardStream { ++ let wtr = ++ if choice.should_attempt_color() { ++ WriterInner::Ansi(Ansi(IoStandardStream::new(sty))) ++ } else { ++ WriterInner::NoColor(NoColor(IoStandardStream::new(sty))) ++ }; ++ StandardStream { wtr: LossyStandardStream::new(wtr) } ++ } ++ ++ /// Create a new `StandardStream` with the given color preferences. ++ /// ++ /// If coloring is desired and a Windows console could not be found, then ++ /// ANSI escape sequences are used instead. ++ /// ++ /// The specific color/style settings can be configured when writing via ++ /// the `WriteColor` trait. ++ #[cfg(windows)] ++ fn create(sty: StandardStreamType, choice: ColorChoice) -> StandardStream { ++ let con = match sty { ++ StandardStreamType::Stdout => wincolor::Console::stdout(), ++ StandardStreamType::Stderr => wincolor::Console::stderr(), ++ }; ++ let is_win_console = con.is_ok(); ++ let wtr = ++ if choice.should_attempt_color() { ++ if choice.should_ansi() { ++ WriterInner::Ansi(Ansi(IoStandardStream::new(sty))) ++ } else if let Ok(console) = con { ++ WriterInner::Windows { ++ wtr: IoStandardStream::new(sty), ++ console: Mutex::new(console), ++ } ++ } else { ++ WriterInner::Ansi(Ansi(IoStandardStream::new(sty))) ++ } ++ } else { ++ WriterInner::NoColor(NoColor(IoStandardStream::new(sty))) ++ }; ++ StandardStream { ++ wtr: LossyStandardStream::new(wtr).is_console(is_win_console), ++ } ++ } ++ ++ /// Create a new `StandardStream` with the given color preferences that ++ /// writes to standard output. ++ /// ++ /// On Windows, if coloring is desired and a Windows console could not be ++ /// found, then ANSI escape sequences are used instead. ++ /// ++ /// The specific color/style settings can be configured when writing via ++ /// the `WriteColor` trait. ++ pub fn stdout(choice: ColorChoice) -> StandardStream { ++ StandardStream::create(StandardStreamType::Stdout, choice) ++ } ++ ++ /// Create a new `StandardStream` with the given color preferences that ++ /// writes to standard error. ++ /// ++ /// On Windows, if coloring is desired and a Windows console could not be ++ /// found, then ANSI escape sequences are used instead. ++ /// ++ /// The specific color/style settings can be configured when writing via ++ /// the `WriteColor` trait. ++ pub fn stderr(choice: ColorChoice) -> StandardStream { ++ StandardStream::create(StandardStreamType::Stderr, choice) ++ } ++ ++ /// Lock the underlying writer. ++ /// ++ /// The lock guard returned also satisfies `io::Write` and ++ /// `WriteColor`. ++ /// ++ /// This method is **not reentrant**. It may panic if `lock` is called ++ /// while a `StandardStreamLock` is still alive. ++ pub fn lock(&self) -> StandardStreamLock { ++ StandardStreamLock::from_stream(self) ++ } ++} ++ ++impl<'a> StandardStreamLock<'a> { ++ #[cfg(not(windows))] ++ fn from_stream(stream: &StandardStream) -> StandardStreamLock { ++ let locked = match *stream.wtr.get_ref() { ++ WriterInner::NoColor(ref w) => { ++ WriterInnerLock::NoColor(NoColor(w.0.lock())) ++ } ++ WriterInner::Ansi(ref w) => { ++ WriterInnerLock::Ansi(Ansi(w.0.lock())) ++ } ++ }; ++ StandardStreamLock { wtr: stream.wtr.wrap(locked) } ++ } ++ ++ #[cfg(windows)] ++ fn from_stream(stream: &StandardStream) -> StandardStreamLock { ++ let locked = match *stream.wtr.get_ref() { ++ WriterInner::NoColor(ref w) => { ++ WriterInnerLock::NoColor(NoColor(w.0.lock())) ++ } ++ WriterInner::Ansi(ref w) => { ++ WriterInnerLock::Ansi(Ansi(w.0.lock())) ++ } ++ #[cfg(windows)] ++ WriterInner::Windows { ref wtr, ref console } => { ++ WriterInnerLock::Windows { ++ wtr: wtr.lock(), ++ console: console.lock().unwrap(), ++ } ++ } ++ }; ++ StandardStreamLock { wtr: stream.wtr.wrap(locked) } ++ } ++} ++ ++impl io::Write for StandardStream { ++ fn write(&mut self, b: &[u8]) -> io::Result { self.wtr.write(b) } ++ fn flush(&mut self) -> io::Result<()> { self.wtr.flush() } ++} ++ ++impl WriteColor for StandardStream { ++ fn supports_color(&self) -> bool { self.wtr.supports_color() } ++ fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { ++ self.wtr.set_color(spec) ++ } ++ fn reset(&mut self) -> io::Result<()> { self.wtr.reset() } ++} ++ ++impl<'a> io::Write for StandardStreamLock<'a> { ++ fn write(&mut self, b: &[u8]) -> io::Result { self.wtr.write(b) } ++ fn flush(&mut self) -> io::Result<()> { self.wtr.flush() } ++} ++ ++impl<'a> WriteColor for StandardStreamLock<'a> { ++ fn supports_color(&self) -> bool { self.wtr.supports_color() } ++ fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { ++ self.wtr.set_color(spec) ++ } ++ fn reset(&mut self) -> io::Result<()> { self.wtr.reset() } ++} ++ ++impl io::Write for WriterInner { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ match *self { ++ WriterInner::NoColor(ref mut wtr) => wtr.write(buf), ++ WriterInner::Ansi(ref mut wtr) => wtr.write(buf), ++ #[cfg(windows)] ++ WriterInner::Windows { ref mut wtr, .. } => wtr.write(buf), ++ } ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ match *self { ++ WriterInner::NoColor(ref mut wtr) => wtr.flush(), ++ WriterInner::Ansi(ref mut wtr) => wtr.flush(), ++ #[cfg(windows)] ++ WriterInner::Windows { ref mut wtr, .. } => wtr.flush(), ++ } ++ } ++} ++ ++impl WriteColor for WriterInner { ++ fn supports_color(&self) -> bool { ++ match *self { ++ WriterInner::NoColor(_) => false, ++ WriterInner::Ansi(_) => true, ++ #[cfg(windows)] ++ WriterInner::Windows { .. } => true, ++ } ++ } ++ ++ fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { ++ match *self { ++ WriterInner::NoColor(ref mut wtr) => wtr.set_color(spec), ++ WriterInner::Ansi(ref mut wtr) => wtr.set_color(spec), ++ #[cfg(windows)] ++ WriterInner::Windows { ref mut wtr, ref console } => { ++ try!(wtr.flush()); ++ let mut console = console.lock().unwrap(); ++ spec.write_console(&mut *console) ++ } ++ } ++ } ++ ++ fn reset(&mut self) -> io::Result<()> { ++ match *self { ++ WriterInner::NoColor(ref mut wtr) => wtr.reset(), ++ WriterInner::Ansi(ref mut wtr) => wtr.reset(), ++ #[cfg(windows)] ++ WriterInner::Windows { ref mut wtr, ref mut console } => { ++ try!(wtr.flush()); ++ try!(console.lock().unwrap().reset()); ++ Ok(()) ++ } ++ } ++ } ++} ++ ++impl<'a, W: io::Write> io::Write for WriterInnerLock<'a, W> { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ match *self { ++ WriterInnerLock::Unreachable(_) => unreachable!(), ++ WriterInnerLock::NoColor(ref mut wtr) => wtr.write(buf), ++ WriterInnerLock::Ansi(ref mut wtr) => wtr.write(buf), ++ #[cfg(windows)] ++ WriterInnerLock::Windows { ref mut wtr, .. } => wtr.write(buf), ++ } ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ match *self { ++ WriterInnerLock::Unreachable(_) => unreachable!(), ++ WriterInnerLock::NoColor(ref mut wtr) => wtr.flush(), ++ WriterInnerLock::Ansi(ref mut wtr) => wtr.flush(), ++ #[cfg(windows)] ++ WriterInnerLock::Windows { ref mut wtr, .. } => wtr.flush(), ++ } ++ } ++} ++ ++impl<'a, W: io::Write> WriteColor for WriterInnerLock<'a, W> { ++ fn supports_color(&self) -> bool { ++ match *self { ++ WriterInnerLock::Unreachable(_) => unreachable!(), ++ WriterInnerLock::NoColor(_) => false, ++ WriterInnerLock::Ansi(_) => true, ++ #[cfg(windows)] ++ WriterInnerLock::Windows { .. } => true, ++ } ++ } ++ ++ fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { ++ match *self { ++ WriterInnerLock::Unreachable(_) => unreachable!(), ++ WriterInnerLock::NoColor(ref mut wtr) => wtr.set_color(spec), ++ WriterInnerLock::Ansi(ref mut wtr) => wtr.set_color(spec), ++ #[cfg(windows)] ++ WriterInnerLock::Windows { ref mut wtr, ref mut console } => { ++ try!(wtr.flush()); ++ spec.write_console(console) ++ } ++ } ++ } ++ ++ fn reset(&mut self) -> io::Result<()> { ++ match *self { ++ WriterInnerLock::Unreachable(_) => unreachable!(), ++ WriterInnerLock::NoColor(ref mut wtr) => wtr.reset(), ++ WriterInnerLock::Ansi(ref mut wtr) => wtr.reset(), ++ #[cfg(windows)] ++ WriterInnerLock::Windows { ref mut wtr, ref mut console } => { ++ try!(wtr.flush()); ++ try!(console.reset()); ++ Ok(()) ++ } ++ } ++ } ++} ++ ++/// Writes colored buffers to stdout or stderr. ++/// ++/// Writable buffers can be obtained by calling `buffer` on a `BufferWriter`. ++/// ++/// This writer works with terminals that support ANSI escape sequences or ++/// with a Windows console. ++/// ++/// It is intended for a `BufferWriter` to be put in an `Arc` and written to ++/// from multiple threads simultaneously. ++pub struct BufferWriter { ++ stream: LossyStandardStream, ++ printed: AtomicBool, ++ separator: Option>, ++ color_choice: ColorChoice, ++ #[cfg(windows)] ++ console: Option>, ++} ++ ++impl BufferWriter { ++ /// Create a new `BufferWriter` that writes to a standard stream with the ++ /// given color preferences. ++ /// ++ /// The specific color/style settings can be configured when writing to ++ /// the buffers themselves. ++ #[cfg(not(windows))] ++ fn create(sty: StandardStreamType, choice: ColorChoice) -> BufferWriter { ++ BufferWriter { ++ stream: LossyStandardStream::new(IoStandardStream::new(sty)), ++ printed: AtomicBool::new(false), ++ separator: None, ++ color_choice: choice, ++ } ++ } ++ ++ /// Create a new `BufferWriter` that writes to a standard stream with the ++ /// given color preferences. ++ /// ++ /// If coloring is desired and a Windows console could not be found, then ++ /// ANSI escape sequences are used instead. ++ /// ++ /// The specific color/style settings can be configured when writing to ++ /// the buffers themselves. ++ #[cfg(windows)] ++ fn create(sty: StandardStreamType, choice: ColorChoice) -> BufferWriter { ++ let con = match sty { ++ StandardStreamType::Stdout => wincolor::Console::stdout(), ++ StandardStreamType::Stderr => wincolor::Console::stderr(), ++ }.ok().map(Mutex::new); ++ let stream = LossyStandardStream::new(IoStandardStream::new(sty)) ++ .is_console(con.is_some()); ++ BufferWriter { ++ stream: stream, ++ printed: AtomicBool::new(false), ++ separator: None, ++ color_choice: choice, ++ console: con, ++ } ++ } ++ ++ /// Create a new `BufferWriter` that writes to stdout with the given ++ /// color preferences. ++ /// ++ /// On Windows, if coloring is desired and a Windows console could not be ++ /// found, then ANSI escape sequences are used instead. ++ /// ++ /// The specific color/style settings can be configured when writing to ++ /// the buffers themselves. ++ pub fn stdout(choice: ColorChoice) -> BufferWriter { ++ BufferWriter::create(StandardStreamType::Stdout, choice) ++ } ++ ++ /// Create a new `BufferWriter` that writes to stderr with the given ++ /// color preferences. ++ /// ++ /// On Windows, if coloring is desired and a Windows console could not be ++ /// found, then ANSI escape sequences are used instead. ++ /// ++ /// The specific color/style settings can be configured when writing to ++ /// the buffers themselves. ++ pub fn stderr(choice: ColorChoice) -> BufferWriter { ++ BufferWriter::create(StandardStreamType::Stderr, choice) ++ } ++ ++ /// If set, the separator given is printed between buffers. By default, no ++ /// separator is printed. ++ /// ++ /// The default value is `None`. ++ pub fn separator(&mut self, sep: Option>) { ++ self.separator = sep; ++ } ++ ++ /// Creates a new `Buffer` with the current color preferences. ++ /// ++ /// A `Buffer` satisfies both `io::Write` and `WriteColor`. A `Buffer` can ++ /// be printed using the `print` method. ++ #[cfg(not(windows))] ++ pub fn buffer(&self) -> Buffer { ++ Buffer::new(self.color_choice) ++ } ++ ++ /// Creates a new `Buffer` with the current color preferences. ++ /// ++ /// A `Buffer` satisfies both `io::Write` and `WriteColor`. A `Buffer` can ++ /// be printed using the `print` method. ++ #[cfg(windows)] ++ pub fn buffer(&self) -> Buffer { ++ Buffer::new(self.color_choice, self.console.is_some()) ++ } ++ ++ /// Prints the contents of the given buffer. ++ /// ++ /// It is safe to call this from multiple threads simultaneously. In ++ /// particular, all buffers are written atomically. No interleaving will ++ /// occur. ++ pub fn print(&self, buf: &Buffer) -> io::Result<()> { ++ if buf.is_empty() { ++ return Ok(()); ++ } ++ let mut stream = self.stream.wrap(self.stream.get_ref().lock()); ++ if let Some(ref sep) = self.separator { ++ if self.printed.load(Ordering::SeqCst) { ++ try!(stream.write_all(sep)); ++ try!(stream.write_all(b"\n")); ++ } ++ } ++ match buf.0 { ++ BufferInner::NoColor(ref b) => try!(stream.write_all(&b.0)), ++ BufferInner::Ansi(ref b) => try!(stream.write_all(&b.0)), ++ #[cfg(windows)] ++ BufferInner::Windows(ref b) => { ++ // We guarantee by construction that we have a console here. ++ // Namely, a BufferWriter is the only way to produce a Buffer. ++ let console_mutex = self.console.as_ref() ++ .expect("got Windows buffer but have no Console"); ++ let mut console = console_mutex.lock().unwrap(); ++ try!(b.print(&mut *console, &mut stream)); ++ } ++ } ++ self.printed.store(true, Ordering::SeqCst); ++ Ok(()) ++ } ++} ++ ++/// Write colored text to memory. ++/// ++/// `Buffer` is a platform independent abstraction for printing colored text to ++/// an in memory buffer. When the buffer is printed using a `BufferWriter`, the ++/// color information will be applied to the output device (a tty on Unix and a ++/// console on Windows). ++/// ++/// A `Buffer` is typically created by calling the `BufferWriter.buffer` ++/// method, which will take color preferences and the environment into ++/// account. However, buffers can also be manually created using `no_color`, ++/// `ansi` or `console` (on Windows). ++pub struct Buffer(BufferInner); ++ ++/// BufferInner is an enumeration of different buffer types. ++enum BufferInner { ++ /// No coloring information should be applied. This ignores all coloring ++ /// directives. ++ NoColor(NoColor>), ++ /// Apply coloring using ANSI escape sequences embedded into the buffer. ++ Ansi(Ansi>), ++ /// Apply coloring using the Windows console APIs. This buffer saves ++ /// color information in memory and only interacts with the console when ++ /// the buffer is printed. ++ #[cfg(windows)] ++ Windows(WindowsBuffer), ++} ++ ++impl Buffer { ++ /// Create a new buffer with the given color settings. ++ #[cfg(not(windows))] ++ fn new(choice: ColorChoice) -> Buffer { ++ if choice.should_attempt_color() { ++ Buffer::ansi() ++ } else { ++ Buffer::no_color() ++ } ++ } ++ ++ /// Create a new buffer with the given color settings. ++ /// ++ /// On Windows, one can elect to create a buffer capable of being written ++ /// to a console. Only enable it if a console is available. ++ /// ++ /// If coloring is desired and `console` is false, then ANSI escape ++ /// sequences are used instead. ++ #[cfg(windows)] ++ fn new(choice: ColorChoice, console: bool) -> Buffer { ++ if choice.should_attempt_color() { ++ if !console || choice.should_ansi() { ++ Buffer::ansi() ++ } else { ++ Buffer::console() ++ } ++ } else { ++ Buffer::no_color() ++ } ++ } ++ ++ /// Create a buffer that drops all color information. ++ pub fn no_color() -> Buffer { ++ Buffer(BufferInner::NoColor(NoColor(vec![]))) ++ } ++ ++ /// Create a buffer that uses ANSI escape sequences. ++ pub fn ansi() -> Buffer { ++ Buffer(BufferInner::Ansi(Ansi(vec![]))) ++ } ++ ++ /// Create a buffer that can be written to a Windows console. ++ #[cfg(windows)] ++ pub fn console() -> Buffer { ++ Buffer(BufferInner::Windows(WindowsBuffer::new())) ++ } ++ ++ /// Returns true if and only if this buffer is empty. ++ pub fn is_empty(&self) -> bool { ++ self.len() == 0 ++ } ++ ++ /// Returns the length of this buffer in bytes. ++ pub fn len(&self) -> usize { ++ match self.0 { ++ BufferInner::NoColor(ref b) => b.0.len(), ++ BufferInner::Ansi(ref b) => b.0.len(), ++ #[cfg(windows)] ++ BufferInner::Windows(ref b) => b.buf.len(), ++ } ++ } ++ ++ /// Clears this buffer. ++ pub fn clear(&mut self) { ++ match self.0 { ++ BufferInner::NoColor(ref mut b) => b.0.clear(), ++ BufferInner::Ansi(ref mut b) => b.0.clear(), ++ #[cfg(windows)] ++ BufferInner::Windows(ref mut b) => b.clear(), ++ } ++ } ++ ++ /// Consume this buffer and return the underlying raw data. ++ /// ++ /// On Windows, this unrecoverably drops all color information associated ++ /// with the buffer. ++ pub fn into_inner(self) -> Vec { ++ match self.0 { ++ BufferInner::NoColor(b) => b.0, ++ BufferInner::Ansi(b) => b.0, ++ #[cfg(windows)] ++ BufferInner::Windows(b) => b.buf, ++ } ++ } ++ ++ /// Return the underlying data of the buffer. ++ pub fn as_slice(&self) -> &[u8] { ++ match self.0 { ++ BufferInner::NoColor(ref b) => &b.0, ++ BufferInner::Ansi(ref b) => &b.0, ++ #[cfg(windows)] ++ BufferInner::Windows(ref b) => &b.buf, ++ } ++ } ++ ++ /// Return the underlying data of the buffer as a mutable slice. ++ pub fn as_mut_slice(&mut self) -> &mut [u8] { ++ match self.0 { ++ BufferInner::NoColor(ref mut b) => &mut b.0, ++ BufferInner::Ansi(ref mut b) => &mut b.0, ++ #[cfg(windows)] ++ BufferInner::Windows(ref mut b) => &mut b.buf, ++ } ++ } ++} ++ ++impl io::Write for Buffer { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ match self.0 { ++ BufferInner::NoColor(ref mut w) => w.write(buf), ++ BufferInner::Ansi(ref mut w) => w.write(buf), ++ #[cfg(windows)] ++ BufferInner::Windows(ref mut w) => w.write(buf), ++ } ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ match self.0 { ++ BufferInner::NoColor(ref mut w) => w.flush(), ++ BufferInner::Ansi(ref mut w) => w.flush(), ++ #[cfg(windows)] ++ BufferInner::Windows(ref mut w) => w.flush(), ++ } ++ } ++} ++ ++impl WriteColor for Buffer { ++ fn supports_color(&self) -> bool { ++ match self.0 { ++ BufferInner::NoColor(_) => false, ++ BufferInner::Ansi(_) => true, ++ #[cfg(windows)] ++ BufferInner::Windows(_) => true, ++ } ++ } ++ ++ fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { ++ match self.0 { ++ BufferInner::NoColor(ref mut w) => w.set_color(spec), ++ BufferInner::Ansi(ref mut w) => w.set_color(spec), ++ #[cfg(windows)] ++ BufferInner::Windows(ref mut w) => w.set_color(spec), ++ } ++ } ++ ++ fn reset(&mut self) -> io::Result<()> { ++ match self.0 { ++ BufferInner::NoColor(ref mut w) => w.reset(), ++ BufferInner::Ansi(ref mut w) => w.reset(), ++ #[cfg(windows)] ++ BufferInner::Windows(ref mut w) => w.reset(), ++ } ++ } ++} ++ ++/// Satisfies `WriteColor` but ignores all color options. ++pub struct NoColor(W); ++ ++impl NoColor { ++ /// Create a new writer that satisfies `WriteColor` but drops all color ++ /// information. ++ pub fn new(wtr: W) -> NoColor { NoColor(wtr) } ++ ++ /// Consume this `NoColor` value and return the inner writer. ++ pub fn into_inner(self) -> W { self.0 } ++ ++ /// Return a reference to the inner writer. ++ pub fn get_ref(&self) -> &W { &self.0 } ++ ++ /// Return a mutable reference to the inner writer. ++ pub fn get_mut(&mut self) -> &mut W { &mut self.0 } ++} ++ ++impl io::Write for NoColor { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.0.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.0.flush() ++ } ++} ++ ++impl WriteColor for NoColor { ++ fn supports_color(&self) -> bool { false } ++ fn set_color(&mut self, _: &ColorSpec) -> io::Result<()> { Ok(()) } ++ fn reset(&mut self) -> io::Result<()> { Ok(()) } ++} ++ ++/// Satisfies `WriteColor` using standard ANSI escape sequences. ++pub struct Ansi(W); ++ ++impl Ansi { ++ /// Create a new writer that satisfies `WriteColor` using standard ANSI ++ /// escape sequences. ++ pub fn new(wtr: W) -> Ansi { Ansi(wtr) } ++ ++ /// Consume this `Ansi` value and return the inner writer. ++ pub fn into_inner(self) -> W { self.0 } ++ ++ /// Return a reference to the inner writer. ++ pub fn get_ref(&self) -> &W { &self.0 } ++ ++ /// Return a mutable reference to the inner writer. ++ pub fn get_mut(&mut self) -> &mut W { &mut self.0 } ++} ++ ++impl io::Write for Ansi { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.0.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.0.flush() ++ } ++} ++ ++impl WriteColor for Ansi { ++ fn supports_color(&self) -> bool { true } ++ ++ fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { ++ try!(self.reset()); ++ if let Some(ref c) = spec.fg_color { ++ try!(self.write_color(true, c, spec.intense)); ++ } ++ if let Some(ref c) = spec.bg_color { ++ try!(self.write_color(false, c, spec.intense)); ++ } ++ if spec.bold { ++ try!(self.write_str("\x1B[1m")); ++ } ++ Ok(()) ++ } ++ ++ fn reset(&mut self) -> io::Result<()> { ++ self.write_str("\x1B[m") ++ } ++} ++ ++impl Ansi { ++ fn write_str(&mut self, s: &str) -> io::Result<()> { ++ self.write_all(s.as_bytes()) ++ } ++ ++ fn write_color( ++ &mut self, ++ fg: bool, ++ c: &Color, ++ intense: bool, ++ ) -> io::Result<()> { ++ macro_rules! write_intense { ++ ($clr:expr) => { ++ if fg { ++ self.write_str(concat!("\x1B[38;5;", $clr, "m")) ++ } else { ++ self.write_str(concat!("\x1B[48;5;", $clr, "m")) ++ } ++ } ++ } ++ macro_rules! write_normal { ++ ($clr:expr) => { ++ if fg { ++ self.write_str(concat!("\x1B[3", $clr, "m")) ++ } else { ++ self.write_str(concat!("\x1B[4", $clr, "m")) ++ } ++ } ++ } ++ if intense { ++ match *c { ++ Color::Black => write_intense!("8"), ++ Color::Blue => write_intense!("12"), ++ Color::Green => write_intense!("10"), ++ Color::Red => write_intense!("9"), ++ Color::Cyan => write_intense!("14"), ++ Color::Magenta => write_intense!("13"), ++ Color::Yellow => write_intense!("11"), ++ Color::White => write_intense!("15"), ++ Color::__Nonexhaustive => unreachable!(), ++ } ++ } else { ++ match *c { ++ Color::Black => write_normal!("0"), ++ Color::Blue => write_normal!("4"), ++ Color::Green => write_normal!("2"), ++ Color::Red => write_normal!("1"), ++ Color::Cyan => write_normal!("6"), ++ Color::Magenta => write_normal!("5"), ++ Color::Yellow => write_normal!("3"), ++ Color::White => write_normal!("7"), ++ Color::__Nonexhaustive => unreachable!(), ++ } ++ } ++ } ++} ++ ++/// An in-memory buffer that provides Windows console coloring. ++/// ++/// This doesn't actually communicate with the Windows console. Instead, it ++/// acts like a normal buffer but also saves the color information associated ++/// with positions in the buffer. It is only when the buffer is written to the ++/// console that coloring is actually applied. ++/// ++/// This is roughly isomorphic to the ANSI based approach (i.e., ++/// `Ansi>`), except with ANSI, the color information is embedded ++/// directly into the buffer. ++/// ++/// Note that there is no way to write something generic like ++/// `WindowsConsole` since coloring on Windows is tied ++/// specifically to the console APIs, and therefore can't work on arbitrary ++/// writers. ++#[cfg(windows)] ++#[derive(Clone, Debug)] ++struct WindowsBuffer { ++ /// The actual content that should be printed. ++ buf: Vec, ++ /// A sequence of position oriented color specifications. Namely, each ++ /// element is a position and a color spec, where the color spec should ++ /// be applied at the position inside of `buf`. ++ /// ++ /// A missing color spec implies the underlying console should be reset. ++ colors: Vec<(usize, Option)>, ++} ++ ++#[cfg(windows)] ++impl WindowsBuffer { ++ /// Create a new empty buffer for Windows console coloring. ++ fn new() -> WindowsBuffer { ++ WindowsBuffer { ++ buf: vec![], ++ colors: vec![], ++ } ++ } ++ ++ /// Push the given color specification into this buffer. ++ /// ++ /// This has the effect of setting the given color information at the ++ /// current position in the buffer. ++ fn push(&mut self, spec: Option) { ++ let pos = self.buf.len(); ++ self.colors.push((pos, spec)); ++ } ++ ++ /// Print the contents to the given stream handle, and use the console ++ /// for coloring. ++ fn print( ++ &self, ++ console: &mut wincolor::Console, ++ stream: &mut LossyStandardStream, ++ ) -> io::Result<()> { ++ let mut last = 0; ++ for &(pos, ref spec) in &self.colors { ++ try!(stream.write_all(&self.buf[last..pos])); ++ try!(stream.flush()); ++ last = pos; ++ match *spec { ++ None => try!(console.reset()), ++ Some(ref spec) => try!(spec.write_console(console)), ++ } ++ } ++ try!(stream.write_all(&self.buf[last..])); ++ stream.flush() ++ } ++ ++ /// Clear the buffer. ++ fn clear(&mut self) { ++ self.buf.clear(); ++ self.colors.clear(); ++ } ++} ++ ++#[cfg(windows)] ++impl io::Write for WindowsBuffer { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.buf.extend_from_slice(buf); ++ Ok(buf.len()) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ Ok(()) ++ } ++} ++ ++#[cfg(windows)] ++impl WriteColor for WindowsBuffer { ++ fn supports_color(&self) -> bool { true } ++ ++ fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { ++ self.push(Some(spec.clone())); ++ Ok(()) ++ } ++ ++ fn reset(&mut self) -> io::Result<()> { ++ self.push(None); ++ Ok(()) ++ } ++} ++ ++/// A color specification. ++#[derive(Clone, Debug, Default, Eq, PartialEq)] ++pub struct ColorSpec { ++ fg_color: Option, ++ bg_color: Option, ++ bold: bool, ++ intense: bool, ++} ++ ++impl ColorSpec { ++ /// Create a new color specification that has no colors or styles. ++ pub fn new() -> ColorSpec { ++ ColorSpec::default() ++ } ++ ++ /// Get the foreground color. ++ pub fn fg(&self) -> Option<&Color> { self.fg_color.as_ref() } ++ ++ /// Set the foreground color. ++ pub fn set_fg(&mut self, color: Option) -> &mut ColorSpec { ++ self.fg_color = color; ++ self ++ } ++ ++ /// Get the background color. ++ pub fn bg(&self) -> Option<&Color> { self.bg_color.as_ref() } ++ ++ /// Set the background color. ++ pub fn set_bg(&mut self, color: Option) -> &mut ColorSpec { ++ self.bg_color = color; ++ self ++ } ++ ++ /// Get whether this is bold or not. ++ /// ++ /// Note that the bold setting has no effect in a Windows console. ++ pub fn bold(&self) -> bool { self.bold } ++ ++ /// Set whether the text is bolded or not. ++ /// ++ /// Note that the bold setting has no effect in a Windows console. ++ pub fn set_bold(&mut self, yes: bool) -> &mut ColorSpec { ++ self.bold = yes; ++ self ++ } ++ ++ /// Get whether this is intense or not. ++ pub fn intense(&self) -> bool { self.intense } ++ ++ /// Set whether the text is intense or not. ++ pub fn set_intense(&mut self, yes: bool) -> &mut ColorSpec { ++ self.intense = yes; ++ self ++ } ++ ++ /// Returns true if this color specification has no colors or styles. ++ pub fn is_none(&self) -> bool { ++ self.fg_color.is_none() && self.bg_color.is_none() && !self.bold ++ } ++ ++ /// Clears this color specification so that it has no color/style settings. ++ pub fn clear(&mut self) { ++ self.fg_color = None; ++ self.bg_color = None; ++ self.bold = false; ++ } ++ ++ /// Writes this color spec to the given Windows console. ++ #[cfg(windows)] ++ fn write_console( ++ &self, ++ console: &mut wincolor::Console, ++ ) -> io::Result<()> { ++ use wincolor::Intense; ++ ++ let intense = if self.intense { Intense::Yes } else { Intense::No }; ++ if let Some(color) = self.fg_color.as_ref().map(|c| c.to_windows()) { ++ try!(console.fg(intense, color)); ++ } ++ if let Some(color) = self.bg_color.as_ref().map(|c| c.to_windows()) { ++ try!(console.bg(intense, color)); ++ } ++ Ok(()) ++ } ++} ++ ++/// The set of available English colors for the terminal foreground/background. ++/// ++/// Note that this set may expand over time. ++#[allow(missing_docs)] ++#[derive(Clone, Debug, Eq, PartialEq)] ++pub enum Color { ++ Black, ++ Blue, ++ Green, ++ Red, ++ Cyan, ++ Magenta, ++ Yellow, ++ White, ++ #[doc(hidden)] ++ __Nonexhaustive, ++} ++ ++#[cfg(windows)] ++impl Color { ++ /// Translate this color to a wincolor::Color. ++ fn to_windows(&self) -> wincolor::Color { ++ match *self { ++ Color::Black => wincolor::Color::Black, ++ Color::Blue => wincolor::Color::Blue, ++ Color::Green => wincolor::Color::Green, ++ Color::Red => wincolor::Color::Red, ++ Color::Cyan => wincolor::Color::Cyan, ++ Color::Magenta => wincolor::Color::Magenta, ++ Color::Yellow => wincolor::Color::Yellow, ++ Color::White => wincolor::Color::White, ++ Color::__Nonexhaustive => unreachable!(), ++ } ++ } ++} ++ ++/// An error from parsing an invalid color name. ++#[derive(Clone, Debug, Eq, PartialEq)] ++pub struct ParseColorError(String); ++ ++impl ParseColorError { ++ /// Return the string that couldn't be parsed as a valid color. ++ pub fn invalid(&self) -> &str { &self.0 } ++} ++ ++impl error::Error for ParseColorError { ++ fn description(&self) -> &str { "unrecognized color name" } ++} ++ ++impl fmt::Display for ParseColorError { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, "Unrecognized color name '{}'. Choose from: \ ++ black, blue, green, red, cyan, magenta, yellow, white.", ++ self.0) ++ } ++} ++ ++impl FromStr for Color { ++ type Err = ParseColorError; ++ ++ fn from_str(s: &str) -> Result { ++ match &*s.to_lowercase() { ++ "black" => Ok(Color::Black), ++ "blue" => Ok(Color::Blue), ++ "green" => Ok(Color::Green), ++ "red" => Ok(Color::Red), ++ "cyan" => Ok(Color::Cyan), ++ "magenta" => Ok(Color::Magenta), ++ "yellow" => Ok(Color::Yellow), ++ "white" => Ok(Color::White), ++ _ => Err(ParseColorError(s.to_string())), ++ } ++ } ++} ++ ++struct LossyStandardStream { ++ wtr: W, ++ #[cfg(windows)] ++ is_console: bool, ++} ++ ++impl LossyStandardStream { ++ #[cfg(not(windows))] ++ fn new(wtr: W) -> LossyStandardStream { ++ LossyStandardStream { wtr: wtr } ++ } ++ ++ #[cfg(windows)] ++ fn new(wtr: W) -> LossyStandardStream { ++ LossyStandardStream { wtr: wtr, is_console: false } ++ } ++ ++ #[cfg(not(windows))] ++ fn wrap(&self, wtr: Q) -> LossyStandardStream { ++ LossyStandardStream::new(wtr) ++ } ++ ++ #[cfg(windows)] ++ fn wrap(&self, wtr: Q) -> LossyStandardStream { ++ LossyStandardStream::new(wtr).is_console(self.is_console) ++ } ++ ++ #[cfg(windows)] ++ fn is_console(mut self, yes: bool) -> LossyStandardStream { ++ self.is_console = yes; ++ self ++ } ++ ++ fn get_ref(&self) -> &W { ++ &self.wtr ++ } ++} ++ ++impl WriteColor for LossyStandardStream { ++ fn supports_color(&self) -> bool { self.wtr.supports_color() } ++ fn set_color(&mut self, spec: &ColorSpec) -> io::Result<()> { ++ self.wtr.set_color(spec) ++ } ++ fn reset(&mut self) -> io::Result<()> { self.wtr.reset() } ++} ++ ++impl io::Write for LossyStandardStream { ++ #[cfg(not(windows))] ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.wtr.write(buf) ++ } ++ ++ #[cfg(windows)] ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ if self.is_console { ++ write_lossy_utf8(&mut self.wtr, buf) ++ } else { ++ self.wtr.write(buf) ++ } ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.wtr.flush() ++ } ++} ++ ++#[cfg(windows)] ++fn write_lossy_utf8(mut w: W, buf: &[u8]) -> io::Result { ++ match ::std::str::from_utf8(buf) { ++ Ok(s) => w.write(s.as_bytes()), ++ Err(ref e) if e.valid_up_to() == 0 => { ++ try!(w.write(b"\xEF\xBF\xBD")); ++ Ok(1) ++ } ++ Err(e) => w.write(&buf[..e.valid_up_to()]), ++ } ++} ++ ++#[cfg(test)] ++mod tests { ++ use super::StandardStream; ++ ++ fn assert_is_send() {} ++ ++ #[test] ++ fn standard_stream_is_send() { ++ assert_is_send::(); ++ } ++} diff --cc vendor/termion-1.5.1/.cargo-checksum.json index 000000000,000000000..d957fcd74 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"} diff --cc vendor/termion-1.5.1/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/.cargo-ok diff --cc vendor/termion-1.5.1/.travis.yml index 000000000,000000000..f20effce7 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/.travis.yml @@@ -1,0 -1,0 +1,14 @@@ ++language: rust ++cache: cargo ++rust: ++ - stable ++ - beta ++ - nightly ++os: ++ - linux ++ - osx ++script: ++ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then FAKETTY="script -q /dev/null"; fi ++ - $FAKETTY cargo build --verbose ++ - $FAKETTY cargo test --verbose ++ - $FAKETTY cargo test --release --verbose diff --cc vendor/termion-1.5.1/Cargo.toml index 000000000,000000000..a4415719a new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/Cargo.toml @@@ -1,0 -1,0 +1,17 @@@ ++[package] ++name = "termion" ++version = "1.5.1" ++authors = ["ticki ", "gycos ", "IGI-111 "] ++description = "A bindless library for manipulating terminals." ++repository = "https://github.com/ticki/termion" ++documentation = "https://docs.rs/termion" ++license = "MIT" ++keywords = ["tty", "color", "terminal", "password", "tui"] ++exclude = ["target", "CHANGELOG.md", "image.png", "Cargo.lock"] ++ ++[target.'cfg(not(target_os = "redox"))'.dependencies] ++libc = "0.2.8" ++ ++[target.'cfg(target_os = "redox")'.dependencies] ++redox_syscall = "0.1" ++redox_termios = "0.1" diff --cc vendor/termion-1.5.1/LICENSE index 000000000,000000000..3903091a1 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/LICENSE @@@ -1,0 -1,0 +1,21 @@@ ++The MIT License (MIT) ++ ++Copyright (c) 2016 Ticki ++ ++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 --cc vendor/termion-1.5.1/README.md index 000000000,000000000..7bda9d317 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/README.md @@@ -1,0 -1,0 +1,181 @@@ ++

      ++Termion logo ++

      ++ ++[![Build Status](https://travis-ci.org/ticki/termion.svg?branch=master)](https://travis-ci.org/ticki/termion) [![Latest Version](https://img.shields.io/crates/v/termion.svg)](https://crates.io/crates/termion) | [Documentation](https://docs.rs/termion) | [Examples](https://github.com/Ticki/termion/tree/master/examples) | [Changelog](https://github.com/Ticki/termion/tree/master/CHANGELOG.md) | [Tutorial](http://ticki.github.io/blog/making-terminal-applications-in-rust-with-termion/) ++|----|----|----|----|---- ++ ++ ++**Termion** is a pure Rust, bindless library for low-level handling, manipulating ++and reading information about terminals. This provides a full-featured ++alternative to Termbox. ++ ++Termion aims to be simple and yet expressive. It is bindless, meaning that it ++is not a front-end to some other library (e.g., ncurses or termbox), but a ++standalone library directly talking to the TTY. ++ ++Termion is quite convenient, due to its complete coverage of essential TTY ++features, providing one consistent API. Termion is rather low-level containing ++only abstraction aligned with what actually happens behind the scenes. For ++something more high-level, refer to inquirer-rs, which uses Termion as backend. ++ ++Termion generates escapes and API calls for the user. This makes it a whole lot ++cleaner to use escapes. ++ ++Supports Redox, Mac OS X, BSD, and Linux (or, in general, ANSI terminals). ++ ++## A note on stability ++ ++This crate is stable. ++ ++## Cargo.toml ++ ++```toml ++[dependencies] ++termion = "*" ++``` ++ ++## 0.1.0 to 1.0.0 guide ++ ++This sample table gives an idea of how to go about converting to the new major ++version of Termion. ++ ++| 0.1.0 | 1.0.0 ++|--------------------------------|--------------------------- ++| `use termion::IntoRawMode` | `use termion::raw::IntoRawMode` ++| `use termion::TermRead` | `use termion::input::TermRead` ++| `stdout.color(color::Red);` | `write!(stdout, "{}", color::Fg(color::Red));` ++| `stdout.color_bg(color::Red);` | `write!(stdout, "{}", color::Bg(color::Red));` ++| `stdout.goto(x, y);` | `write!(stdout, "{}", cursor::Goto(x, y));` ++| `color::rgb(r, g, b);` | `color::Rgb(r, g, b)` (truecolor) ++| `x.with_mouse()` | `MouseTerminal::from(x)` ++ ++## Features ++ ++- Raw mode. ++- TrueColor. ++- 256-color mode. ++- Cursor movement. ++- Text formatting. ++- Console size. ++- TTY-only stream. ++- Control sequences. ++- Termios control. ++- Password input. ++- Redox support. ++- Safe `isatty` wrapper. ++- Panic-free error handling. ++- Special keys events (modifiers, special keys, etc.). ++- Allocation-free. ++- Asynchronous key events. ++- Mouse input. ++- Carefully tested. ++- Detailed documentation on every item. ++ ++and much more. ++ ++## Examples ++ ++### Style and colors. ++ ++```rust ++extern crate termion; ++ ++use termion::{color, style}; ++ ++use std::io; ++ ++fn main() { ++ println!("{}Red", color::Fg(color::Red)); ++ println!("{}Blue", color::Fg(color::Blue)); ++ println!("{}Blue'n'Bold{}", style::Bold, style::Reset); ++ println!("{}Just plain italic", style::Italic); ++} ++``` ++ ++### Moving the cursor ++ ++```rust ++extern crate termion; ++ ++fn main() { ++ print!("{}{}Stuff", termion::clear::All, termion::cursor::Goto(1, 1)); ++} ++ ++``` ++ ++### Mouse ++ ++```rust ++extern crate termion; ++ ++use termion::event::{Key, Event, MouseEvent}; ++use termion::input::{TermRead, MouseTerminal}; ++use termion::raw::IntoRawMode; ++use std::io::{Write, stdout, stdin}; ++ ++fn main() { ++ let stdin = stdin(); ++ let mut stdout = MouseTerminal::from(stdout().into_raw_mode().unwrap()); ++ ++ write!(stdout, "{}{}q to exit. Click, click, click!", termion::clear::All, termion::cursor::Goto(1, 1)).unwrap(); ++ stdout.flush().unwrap(); ++ ++ for c in stdin.events() { ++ let evt = c.unwrap(); ++ match evt { ++ Event::Key(Key::Char('q')) => break, ++ Event::Mouse(me) => { ++ match me { ++ MouseEvent::Press(_, x, y) => { ++ write!(stdout, "{}x", termion::cursor::Goto(x, y)).unwrap(); ++ }, ++ _ => (), ++ } ++ } ++ _ => {} ++ } ++ stdout.flush().unwrap(); ++ } ++} ++``` ++ ++### Read a password ++ ++```rust ++extern crate termion; ++ ++use termion::input::TermRead; ++use std::io::{Write, stdout, stdin}; ++ ++fn main() { ++ let stdout = stdout(); ++ let mut stdout = stdout.lock(); ++ let stdin = stdin(); ++ let mut stdin = stdin.lock(); ++ ++ stdout.write_all(b"password: ").unwrap(); ++ stdout.flush().unwrap(); ++ ++ let pass = stdin.read_passwd(&mut stdout); ++ ++ if let Ok(Some(pass)) = pass { ++ stdout.write_all(pass.as_bytes()).unwrap(); ++ stdout.write_all(b"\n").unwrap(); ++ } else { ++ stdout.write_all(b"Error\n").unwrap(); ++ } ++} ++``` ++ ++## Usage ++ ++See `examples/`, and the documentation, which can be rendered using `cargo doc`. ++ ++For a more complete example, see [a minesweeper implementation](https://github.com/redox-os/games-for-redox/blob/master/src/minesweeper/main.rs), that I made for Redox using termion. ++ ++ ++ ++## License ++ ++MIT/X11. diff --cc vendor/termion-1.5.1/examples/alternate_screen.rs index 000000000,000000000..91d28b170 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/alternate_screen.rs @@@ -1,0 -1,0 +1,17 @@@ ++extern crate termion; ++ ++use termion::screen::*; ++use std::io::{Write, stdout}; ++use std::{time, thread}; ++ ++fn main() { ++ { ++ let mut screen = AlternateScreen::from(stdout()); ++ write!(screen, "Welcome to the alternate screen.\n\nPlease wait patiently until we arrive back at the main screen in a about three seconds.").unwrap(); ++ screen.flush().unwrap(); ++ ++ thread::sleep(time::Duration::from_secs(3)); ++ } ++ ++ println!("Phew! We are back."); ++} diff --cc vendor/termion-1.5.1/examples/alternate_screen_raw.rs index 000000000,000000000..7ba788880 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/alternate_screen_raw.rs @@@ -1,0 -1,0 +1,40 @@@ ++extern crate termion; ++ ++use termion::event::Key; ++use termion::input::TermRead; ++use termion::raw::IntoRawMode; ++use termion::screen::*; ++use std::io::{Write, stdout, stdin}; ++ ++fn write_alt_screen_msg(screen: &mut W) { ++ write!(screen, "{}{}Welcome to the alternate screen.{}Press '1' to switch to the main screen or '2' to switch to the alternate screen.{}Press 'q' to exit (and switch back to the main screen).", ++ termion::clear::All, ++ termion::cursor::Goto(1, 1), ++ termion::cursor::Goto(1, 3), ++ termion::cursor::Goto(1, 4)).unwrap(); ++} ++ ++fn main() { ++ let stdin = stdin(); ++ let mut screen = AlternateScreen::from(stdout().into_raw_mode().unwrap()); ++ write!(screen, "{}", termion::cursor::Hide).unwrap(); ++ write_alt_screen_msg(&mut screen); ++ ++ screen.flush().unwrap(); ++ ++ for c in stdin.keys() { ++ match c.unwrap() { ++ Key::Char('q') => break, ++ Key::Char('1') => { ++ write!(screen, "{}", ToMainScreen).unwrap(); ++ } ++ Key::Char('2') => { ++ write!(screen, "{}", ToAlternateScreen).unwrap(); ++ write_alt_screen_msg(&mut screen); ++ } ++ _ => {} ++ } ++ screen.flush().unwrap(); ++ } ++ write!(screen, "{}", termion::cursor::Show).unwrap(); ++} diff --cc vendor/termion-1.5.1/examples/async.rs index 000000000,000000000..b16bb7861 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/async.rs @@@ -1,0 -1,0 +1,39 @@@ ++extern crate termion; ++ ++use termion::raw::IntoRawMode; ++use termion::async_stdin; ++use std::io::{Read, Write, stdout}; ++use std::thread; ++use std::time::Duration; ++ ++fn main() { ++ let stdout = stdout(); ++ let mut stdout = stdout.lock().into_raw_mode().unwrap(); ++ let mut stdin = async_stdin().bytes(); ++ ++ write!(stdout, ++ "{}{}", ++ termion::clear::All, ++ termion::cursor::Goto(1, 1)) ++ .unwrap(); ++ ++ loop { ++ write!(stdout, "{}", termion::clear::CurrentLine).unwrap(); ++ ++ let b = stdin.next(); ++ write!(stdout, "\r{:?} <- This demonstrates the async read input char. Between each update a 100 ms. is waited, simply to demonstrate the async fashion. \n\r", b).unwrap(); ++ if let Some(Ok(b'q')) = b { ++ break; ++ } ++ ++ stdout.flush().unwrap(); ++ ++ thread::sleep(Duration::from_millis(50)); ++ stdout.write_all(b"# ").unwrap(); ++ stdout.flush().unwrap(); ++ thread::sleep(Duration::from_millis(50)); ++ stdout.write_all(b"\r #").unwrap(); ++ write!(stdout, "{}", termion::cursor::Goto(1, 1)).unwrap(); ++ stdout.flush().unwrap(); ++ } ++} diff --cc vendor/termion-1.5.1/examples/click.rs index 000000000,000000000..fe903d837 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/click.rs @@@ -1,0 -1,0 +1,35 @@@ ++extern crate termion; ++ ++use termion::event::{Key, Event, MouseEvent}; ++use termion::input::{TermRead, MouseTerminal}; ++use termion::raw::IntoRawMode; ++use std::io::{Write, stdout, stdin}; ++ ++fn main() { ++ let stdin = stdin(); ++ let mut stdout = MouseTerminal::from(stdout().into_raw_mode().unwrap()); ++ ++ write!(stdout, ++ "{}{}q to exit. Click, click, click!", ++ termion::clear::All, ++ termion::cursor::Goto(1, 1)) ++ .unwrap(); ++ stdout.flush().unwrap(); ++ ++ for c in stdin.events() { ++ let evt = c.unwrap(); ++ match evt { ++ Event::Key(Key::Char('q')) => break, ++ Event::Mouse(me) => { ++ match me { ++ MouseEvent::Press(_, x, y) => { ++ write!(stdout, "{}x", termion::cursor::Goto(x, y)).unwrap(); ++ } ++ _ => (), ++ } ++ } ++ _ => {} ++ } ++ stdout.flush().unwrap(); ++ } ++} diff --cc vendor/termion-1.5.1/examples/color.rs index 000000000,000000000..16071be99 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/color.rs @@@ -1,0 -1,0 +1,10 @@@ ++extern crate termion; ++ ++use termion::{color, style}; ++ ++fn main() { ++ println!("{}Red", color::Fg(color::Red)); ++ println!("{}Blue", color::Fg(color::Blue)); ++ println!("{}Blue'n'Bold{}", style::Bold, style::Reset); ++ println!("{}Just plain italic", style::Italic); ++} diff --cc vendor/termion-1.5.1/examples/commie.rs index 000000000,000000000..32f8820e5 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/commie.rs @@@ -1,0 -1,0 +1,51 @@@ ++extern crate termion; ++ ++use termion::{clear, color, cursor}; ++ ++use std::{time, thread}; ++ ++const COMMUNISM: &'static str = r#" ++ !######### # ++ !########! ##! ++ !########! ### ++ !########## #### ++ ######### ##### ###### ++ !###! !####! ###### ++ ! ##### ######! ++ !####! ####### ++ ##### ####### ++ !####! #######! ++ ####!######## ++ ## ########## ++ ,######! !############# ++ ,#### ########################!####! ++ ,####' ##################!' ##### ++ ,####' ####### !####! ++ ####' ##### ++ ~## ##~ ++"#; ++ ++fn main() { ++ let mut state = 0; ++ ++ println!("\n{}{}{}{}{}{}", ++ cursor::Hide, ++ clear::All, ++ cursor::Goto(1, 1), ++ color::Fg(color::Black), ++ color::Bg(color::Red), ++ COMMUNISM); ++ loop { ++ println!("{}{} ☭ GAY ☭ SPACE ☭ COMMUNISM ☭ ", ++ cursor::Goto(1, 1), ++ color::Bg(color::AnsiValue(state))); ++ println!("{}{} WILL PREVAIL, COMRADES! ", ++ cursor::Goto(1, 20), ++ color::Bg(color::AnsiValue(state))); ++ ++ state += 1; ++ state %= 8; ++ ++ thread::sleep(time::Duration::from_millis(90)); ++ } ++} diff --cc vendor/termion-1.5.1/examples/detect_color.rs index 000000000,000000000..ecfdd5b45 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/detect_color.rs @@@ -1,0 -1,0 +1,19 @@@ ++extern crate termion; ++ ++use termion::color::{DetectColors, AnsiValue, Bg}; ++use termion::raw::IntoRawMode; ++use std::io::stdout; ++ ++fn main() { ++ let count; ++ { ++ let mut term = stdout().into_raw_mode().unwrap(); ++ count = term.available_colors().unwrap(); ++ } ++ ++ println!("This terminal supports {} colors.", count); ++ for i in 0..count { ++ print!("{} {}", Bg(AnsiValue(i as u8)), Bg(AnsiValue(0))); ++ } ++ println!(); ++} diff --cc vendor/termion-1.5.1/examples/is_tty.rs index 000000000,000000000..52d1bc1d2 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/is_tty.rs @@@ -1,0 -1,0 +1,11 @@@ ++extern crate termion; ++ ++use std::fs; ++ ++fn main() { ++ if termion::is_tty(&fs::File::create("/dev/stdout").unwrap()) { ++ println!("This is a TTY!"); ++ } else { ++ println!("This is not a TTY :("); ++ } ++} diff --cc vendor/termion-1.5.1/examples/keys.rs index 000000000,000000000..272ffd1b9 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/keys.rs @@@ -1,0 -1,0 +1,44 @@@ ++extern crate termion; ++ ++use termion::event::Key; ++use termion::input::TermRead; ++use termion::raw::IntoRawMode; ++use std::io::{Write, stdout, stdin}; ++ ++fn main() { ++ let stdin = stdin(); ++ let mut stdout = stdout().into_raw_mode().unwrap(); ++ ++ write!(stdout, ++ "{}{}q to exit. Type stuff, use alt, and so on.{}", ++ termion::clear::All, ++ termion::cursor::Goto(1, 1), ++ termion::cursor::Hide) ++ .unwrap(); ++ stdout.flush().unwrap(); ++ ++ for c in stdin.keys() { ++ write!(stdout, ++ "{}{}", ++ termion::cursor::Goto(1, 1), ++ termion::clear::CurrentLine) ++ .unwrap(); ++ ++ match c.unwrap() { ++ Key::Char('q') => break, ++ Key::Char(c) => println!("{}", c), ++ Key::Alt(c) => println!("^{}", c), ++ Key::Ctrl(c) => println!("*{}", c), ++ Key::Esc => println!("ESC"), ++ Key::Left => println!("←"), ++ Key::Right => println!("→"), ++ Key::Up => println!("↑"), ++ Key::Down => println!("↓"), ++ Key::Backspace => println!("×"), ++ _ => {} ++ } ++ stdout.flush().unwrap(); ++ } ++ ++ write!(stdout, "{}", termion::cursor::Show).unwrap(); ++} diff --cc vendor/termion-1.5.1/examples/mouse.rs index 000000000,000000000..cbe8baf46 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/mouse.rs @@@ -1,0 -1,0 +1,46 @@@ ++extern crate termion; ++ ++use termion::event::*; ++use termion::cursor::{self, DetectCursorPos}; ++use termion::input::{TermRead, MouseTerminal}; ++use termion::raw::IntoRawMode; ++use std::io::{self, Write}; ++ ++fn main() { ++ let stdin = io::stdin(); ++ let mut stdout = MouseTerminal::from(io::stdout().into_raw_mode().unwrap()); ++ ++ writeln!(stdout, ++ "{}{}q to exit. Type stuff, use alt, click around...", ++ termion::clear::All, ++ termion::cursor::Goto(1, 1)) ++ .unwrap(); ++ ++ for c in stdin.events() { ++ let evt = c.unwrap(); ++ match evt { ++ Event::Key(Key::Char('q')) => break, ++ Event::Mouse(me) => { ++ match me { ++ MouseEvent::Press(_, a, b) | ++ MouseEvent::Release(a, b) | ++ MouseEvent::Hold(a, b) => { ++ write!(stdout, "{}", cursor::Goto(a, b)).unwrap(); ++ let (x, y) = stdout.cursor_pos().unwrap(); ++ write!(stdout, ++ "{}{}Cursor is at: ({},{}){}", ++ cursor::Goto(5, 5), ++ termion::clear::UntilNewline, ++ x, ++ y, ++ cursor::Goto(a, b)) ++ .unwrap(); ++ } ++ } ++ } ++ _ => {} ++ } ++ ++ stdout.flush().unwrap(); ++ } ++} diff --cc vendor/termion-1.5.1/examples/rainbow.rs index 000000000,000000000..4ee4000d0 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/rainbow.rs @@@ -1,0 -1,0 +1,60 @@@ ++extern crate termion; ++ ++use termion::event::Key; ++use termion::input::TermRead; ++use termion::raw::IntoRawMode; ++use std::io::{Write, stdout, stdin}; ++ ++fn rainbow(stdout: &mut W, blue: u8) { ++ write!(stdout, ++ "{}{}", ++ termion::cursor::Goto(1, 1), ++ termion::clear::All) ++ .unwrap(); ++ ++ for red in 0..32 { ++ let red = red * 8; ++ for green in 0..64 { ++ let green = green * 4; ++ write!(stdout, ++ "{} ", ++ termion::color::Bg(termion::color::Rgb(red, green, blue))) ++ .unwrap(); ++ } ++ write!(stdout, "\n\r").unwrap(); ++ } ++ ++ writeln!(stdout, "{}b = {}", termion::style::Reset, blue).unwrap(); ++} ++ ++fn main() { ++ let stdin = stdin(); ++ let mut stdout = stdout().into_raw_mode().unwrap(); ++ ++ writeln!(stdout, ++ "{}{}{}Use the up/down arrow keys to change the blue in the rainbow.", ++ termion::clear::All, ++ termion::cursor::Goto(1, 1), ++ termion::cursor::Hide) ++ .unwrap(); ++ ++ let mut blue = 172u8; ++ ++ for c in stdin.keys() { ++ match c.unwrap() { ++ Key::Up => { ++ blue = blue.saturating_add(4); ++ rainbow(&mut stdout, blue); ++ } ++ Key::Down => { ++ blue = blue.saturating_sub(4); ++ rainbow(&mut stdout, blue); ++ } ++ Key::Char('q') => break, ++ _ => {} ++ } ++ stdout.flush().unwrap(); ++ } ++ ++ write!(stdout, "{}", termion::cursor::Show).unwrap(); ++} diff --cc vendor/termion-1.5.1/examples/read.rs index 000000000,000000000..8d53e1bf7 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/read.rs @@@ -1,0 -1,0 +1,23 @@@ ++extern crate termion; ++ ++use termion::input::TermRead; ++use std::io::{Write, stdout, stdin}; ++ ++fn main() { ++ let stdout = stdout(); ++ let mut stdout = stdout.lock(); ++ let stdin = stdin(); ++ let mut stdin = stdin.lock(); ++ ++ stdout.write_all(b"password: ").unwrap(); ++ stdout.flush().unwrap(); ++ ++ let pass = stdin.read_passwd(&mut stdout); ++ ++ if let Ok(Some(pass)) = pass { ++ stdout.write_all(pass.as_bytes()).unwrap(); ++ stdout.write_all(b"\n").unwrap(); ++ } else { ++ stdout.write_all(b"Error\n").unwrap(); ++ } ++} diff --cc vendor/termion-1.5.1/examples/rustc_fun.rs index 000000000,000000000..734e89f42 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/rustc_fun.rs @@@ -1,0 -1,0 +1,24 @@@ ++extern crate termion; ++ ++use termion::{color, style}; ++ ++fn main() { ++ println!("{lighgreen}-- src/test/ui/borrow-errors.rs at 82:18 --\n\ ++ {red}error: {reset}{bold}two closures require unique access to `vec` at the same time {reset}{bold}{magenta}[E0524]{reset}\n\ ++ {line_num_fg}{line_num_bg}79 {reset} let append = |e| {{\n\ ++ {line_num_fg}{line_num_bg}{info_line}{reset} {red}^^^{reset} {error_fg}first closure is constructed here\n\ ++ {line_num_fg}{line_num_bg}80 {reset} vec.push(e)\n\ ++ {line_num_fg}{line_num_bg}{info_line}{reset} {red}^^^{reset} {error_fg}previous borrow occurs due to use of `vec` in closure\n\ ++ {line_num_fg}{line_num_bg}84 {reset} }};\n\ ++ {line_num_fg}{line_num_bg}85 {reset} }}\n\ ++ {line_num_fg}{line_num_bg}{info_line}{reset} {red}^{reset} {error_fg}borrow from first closure ends here", ++ lighgreen = color::Fg(color::LightGreen), ++ red = color::Fg(color::Red), ++ bold = style::Bold, ++ reset = style::Reset, ++ magenta = color::Fg(color::Magenta), ++ line_num_bg = color::Bg(color::AnsiValue::grayscale(3)), ++ line_num_fg = color::Fg(color::AnsiValue::grayscale(18)), ++ info_line = "| ", ++ error_fg = color::Fg(color::AnsiValue::grayscale(17))) ++} diff --cc vendor/termion-1.5.1/examples/simple.rs index 000000000,000000000..93ef1df3a new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/simple.rs @@@ -1,0 -1,0 +1,42 @@@ ++extern crate termion; ++ ++use termion::color; ++use termion::raw::IntoRawMode; ++use std::io::{Read, Write, stdout, stdin}; ++ ++fn main() { ++ // Initialize 'em all. ++ let stdout = stdout(); ++ let mut stdout = stdout.lock().into_raw_mode().unwrap(); ++ let stdin = stdin(); ++ let stdin = stdin.lock(); ++ ++ write!(stdout, ++ "{}{}{}yo, 'q' will exit.{}{}", ++ termion::clear::All, ++ termion::cursor::Goto(5, 5), ++ termion::style::Bold, ++ termion::style::Reset, ++ termion::cursor::Goto(20, 10)) ++ .unwrap(); ++ stdout.flush().unwrap(); ++ ++ let mut bytes = stdin.bytes(); ++ loop { ++ let b = bytes.next().unwrap().unwrap(); ++ ++ match b { ++ // Quit ++ b'q' => return, ++ // Clear the screen ++ b'c' => write!(stdout, "{}", termion::clear::All), ++ // Set red color ++ b'r' => write!(stdout, "{}", color::Fg(color::Rgb(5, 0, 0))), ++ // Write it to stdout. ++ a => write!(stdout, "{}", a), ++ } ++ .unwrap(); ++ ++ stdout.flush().unwrap(); ++ } ++} diff --cc vendor/termion-1.5.1/examples/size.rs index 000000000,000000000..e91fa5430 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/size.rs @@@ -1,0 -1,0 +1,7 @@@ ++extern crate termion; ++ ++use termion::terminal_size; ++ ++fn main() { ++ println!("Size is {:?}", terminal_size().unwrap()) ++} diff --cc vendor/termion-1.5.1/examples/truecolor.rs index 000000000,000000000..ba5c8685b new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/examples/truecolor.rs @@@ -1,0 -1,0 +1,12 @@@ ++extern crate termion; ++ ++use termion::{color, cursor, clear}; ++use std::{thread, time}; ++ ++fn main() { ++ for r in 0..255 { ++ let c = color::Rgb(r, !r, 2 * ((r % 128) as i8 - 64).abs() as u8); ++ println!("{}{}{}wow", cursor::Goto(1, 1), color::Bg(c), clear::All); ++ thread::sleep(time::Duration::from_millis(100)); ++ } ++} diff --cc vendor/termion-1.5.1/logo.svg index 000000000,000000000..39bc574b6 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/logo.svg @@@ -1,0 -1,0 +1,9 @@@ ++ ++ ++ ++ ++ ++ ++ diff --cc vendor/termion-1.5.1/src/async.rs index 000000000,000000000..f58b0444c new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/async.rs @@@ -1,0 -1,0 +1,78 @@@ ++use std::io::{self, Read}; ++use std::sync::mpsc; ++use std::thread; ++ ++use sys::tty::get_tty; ++ ++/// Construct an asynchronous handle to the TTY standard input. ++/// ++/// This allows you to read from standard input _without blocking_ the current thread. ++/// Specifically, it works by firing up another thread to handle the event stream, which will then ++/// be buffered in a mpsc queue, which will eventually be read by the current thread. ++/// ++/// This will not read the piped standard input, but rather read from the TTY device, since reading ++/// asyncronized from piped input would rarely make sense. In other words, if you pipe standard ++/// output from another process, it won't be reflected in the stream returned by this function, as ++/// this represents the TTY device, and not the piped standard input. ++pub fn async_stdin() -> AsyncReader { ++ let (send, recv) = mpsc::channel(); ++ ++ thread::spawn(move || for i in get_tty().unwrap().bytes() { ++ if send.send(i).is_err() { ++ return; ++ } ++ }); ++ ++ AsyncReader { recv: recv } ++} ++ ++/// An asynchronous reader. ++/// ++/// This acts as any other stream, with the exception that reading from it won't block. Instead, ++/// the buffer will only be partially updated based on how much the internal buffer holds. ++pub struct AsyncReader { ++ /// The underlying mpsc receiver. ++ recv: mpsc::Receiver>, ++} ++ ++// FIXME: Allow constructing an async reader from an arbitrary stream. ++ ++impl Read for AsyncReader { ++ /// Read from the byte stream. ++ /// ++ /// This will never block, but try to drain the event queue until empty. If the total number of ++ /// bytes written is lower than the buffer's length, the event queue is empty or that the event ++ /// stream halted. ++ fn read(&mut self, buf: &mut [u8]) -> io::Result { ++ let mut total = 0; ++ ++ loop { ++ if total >= buf.len() { ++ break; ++ } ++ ++ match self.recv.try_recv() { ++ Ok(Ok(b)) => { ++ buf[total] = b; ++ total += 1; ++ } ++ Ok(Err(e)) => return Err(e), ++ Err(_) => break, ++ } ++ } ++ ++ Ok(total) ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use super::*; ++ use std::io::Read; ++ ++ #[test] ++ fn test_async_stdin() { ++ let stdin = async_stdin(); ++ stdin.bytes().next(); ++ } ++} diff --cc vendor/termion-1.5.1/src/clear.rs index 000000000,000000000..d37f2c6b9 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/clear.rs @@@ -1,0 -1,0 +1,9 @@@ ++//! Clearing the screen. ++ ++use std::fmt; ++ ++derive_csi_sequence!("Clear the entire screen.", All, "2J"); ++derive_csi_sequence!("Clear everything after the cursor.", AfterCursor, "J"); ++derive_csi_sequence!("Clear everything before the cursor.", BeforeCursor, "1J"); ++derive_csi_sequence!("Clear the current line.", CurrentLine, "2K"); ++derive_csi_sequence!("Clear from cursor to newline.", UntilNewline, "K"); diff --cc vendor/termion-1.5.1/src/color.rs index 000000000,000000000..6f3fd8813 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/color.rs @@@ -1,0 -1,0 +1,242 @@@ ++//! Color managemement. ++//! ++//! # Example ++//! ++//! ```rust ++//! use termion::color; ++//! ++//! fn main() { ++//! println!("{}Red", color::Fg(color::Red)); ++//! println!("{}Blue", color::Fg(color::Blue)); ++//! println!("{}Back again", color::Fg(color::Reset)); ++//! } ++//! ``` ++ ++use std::fmt; ++use raw::CONTROL_SEQUENCE_TIMEOUT; ++use std::io::{self, Write, Read}; ++use std::time::{SystemTime, Duration}; ++use async::async_stdin; ++use std::env; ++ ++/// A terminal color. ++pub trait Color { ++ /// Write the foreground version of this color. ++ fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result; ++ /// Write the background version of this color. ++ fn write_bg(&self, f: &mut fmt::Formatter) -> fmt::Result; ++} ++ ++macro_rules! derive_color { ++ ($doc:expr, $name:ident, $value:expr) => { ++ #[doc = $doc] ++ #[derive(Copy, Clone, Debug)] ++ pub struct $name; ++ ++ impl Color for $name { ++ #[inline] ++ fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("38;5;", $value, "m")) ++ } ++ ++ #[inline] ++ fn write_bg(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("48;5;", $value, "m")) ++ } ++ } ++ }; ++} ++ ++derive_color!("Black.", Black, "0"); ++derive_color!("Red.", Red, "1"); ++derive_color!("Green.", Green, "2"); ++derive_color!("Yellow.", Yellow, "3"); ++derive_color!("Blue.", Blue, "4"); ++derive_color!("Magenta.", Magenta, "5"); ++derive_color!("Cyan.", Cyan, "6"); ++derive_color!("White.", White, "7"); ++derive_color!("High-intensity light black.", LightBlack, "8"); ++derive_color!("High-intensity light red.", LightRed, "9"); ++derive_color!("High-intensity light green.", LightGreen, "10"); ++derive_color!("High-intensity light yellow.", LightYellow, "11"); ++derive_color!("High-intensity light blue.", LightBlue, "12"); ++derive_color!("High-intensity light magenta.", LightMagenta, "13"); ++derive_color!("High-intensity light cyan.", LightCyan, "14"); ++derive_color!("High-intensity light white.", LightWhite, "15"); ++ ++impl<'a> Color for &'a Color { ++ #[inline] ++ fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ (*self).write_fg(f) ++ } ++ ++ #[inline] ++ fn write_bg(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ (*self).write_bg(f) ++ } ++} ++ ++/// An arbitrary ANSI color value. ++#[derive(Clone, Copy, Debug)] ++pub struct AnsiValue(pub u8); ++ ++impl AnsiValue { ++ /// 216-color (r, g, b ≤ 5) RGB. ++ pub fn rgb(r: u8, g: u8, b: u8) -> AnsiValue { ++ debug_assert!(r <= 5, ++ "Red color fragment (r = {}) is out of bound. Make sure r ≤ 5.", ++ r); ++ debug_assert!(g <= 5, ++ "Green color fragment (g = {}) is out of bound. Make sure g ≤ 5.", ++ g); ++ debug_assert!(b <= 5, ++ "Blue color fragment (b = {}) is out of bound. Make sure b ≤ 5.", ++ b); ++ ++ AnsiValue(16 + 36 * r + 6 * g + b) ++ } ++ ++ /// Grayscale color. ++ /// ++ /// There are 24 shades of gray. ++ pub fn grayscale(shade: u8) -> AnsiValue { ++ // Unfortunately, there are a little less than fifty shades. ++ debug_assert!(shade < 24, ++ "Grayscale out of bound (shade = {}). There are only 24 shades of \ ++ gray.", ++ shade); ++ ++ AnsiValue(0xE8 + shade) ++ } ++} ++ ++impl Color for AnsiValue { ++ #[inline] ++ fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("38;5;{}m"), self.0) ++ } ++ ++ #[inline] ++ fn write_bg(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("48;5;{}m"), self.0) ++ } ++} ++ ++/// A truecolor RGB. ++#[derive(Debug, Clone, Copy, PartialEq)] ++pub struct Rgb(pub u8, pub u8, pub u8); ++ ++impl Color for Rgb { ++ #[inline] ++ fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("38;2;{};{};{}m"), self.0, self.1, self.2) ++ } ++ ++ #[inline] ++ fn write_bg(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("48;2;{};{};{}m"), self.0, self.1, self.2) ++ } ++} ++ ++/// Reset colors to defaults. ++#[derive(Debug, Clone, Copy)] ++pub struct Reset; ++ ++impl Color for Reset { ++ #[inline] ++ fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("39m")) ++ } ++ ++ #[inline] ++ fn write_bg(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("49m")) ++ } ++} ++ ++/// A foreground color. ++#[derive(Debug, Clone, Copy)] ++pub struct Fg(pub C); ++ ++impl fmt::Display for Fg { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ self.0.write_fg(f) ++ } ++} ++ ++/// A background color. ++#[derive(Debug, Clone, Copy)] ++pub struct Bg(pub C); ++ ++impl fmt::Display for Bg { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ self.0.write_bg(f) ++ } ++} ++ ++/// Types that allow detection of the colors they support. ++pub trait DetectColors { ++ /// How many ANSI colors are supported (from 8 to 256)? ++ /// ++ /// Beware: the information given isn't authoritative, it's infered through escape codes or the ++ /// value of `TERM`, more colors may be available. ++ fn available_colors(&mut self) -> io::Result; ++} ++ ++impl DetectColors for W { ++ fn available_colors(&mut self) -> io::Result { ++ let mut stdin = async_stdin(); ++ ++ if detect_color(self, &mut stdin, 0)? { ++ // OSC 4 is supported, detect how many colors there are. ++ // Do a binary search of the last supported color. ++ let mut min = 8; ++ let mut max = 256; ++ let mut i; ++ while min + 1 < max { ++ i = (min + max) / 2; ++ if detect_color(self, &mut stdin, i)? { ++ min = i ++ } else { ++ max = i ++ } ++ } ++ Ok(max) ++ } else { ++ // OSC 4 is not supported, trust TERM contents. ++ Ok(match env::var_os("TERM") { ++ Some(val) => { ++ if val.to_str().unwrap_or("").contains("256color") { ++ 256 ++ } else { ++ 8 ++ } ++ } ++ None => 8, ++ }) ++ } ++ } ++} ++ ++/// Detect a color using OSC 4. ++fn detect_color(stdout: &mut Write, stdin: &mut Read, color: u16) -> io::Result { ++ // Is the color available? ++ // Use `ESC ] 4 ; color ; ? BEL`. ++ write!(stdout, "\x1B]4;{};?\x07", color)?; ++ stdout.flush()?; ++ ++ let mut buf: [u8; 1] = [0]; ++ let mut total_read = 0; ++ ++ let timeout = Duration::from_millis(CONTROL_SEQUENCE_TIMEOUT); ++ let now = SystemTime::now(); ++ let bell = 7u8; ++ ++ // Either consume all data up to bell or wait for a timeout. ++ while buf[0] != bell && now.elapsed().unwrap() < timeout { ++ total_read += stdin.read(&mut buf)?; ++ } ++ ++ // If there was a response, the color is supported. ++ Ok(total_read > 0) ++} diff --cc vendor/termion-1.5.1/src/cursor.rs index 000000000,000000000..6296da9b1 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/cursor.rs @@@ -1,0 -1,0 +1,140 @@@ ++//! Cursor movement. ++ ++use std::fmt; ++use std::io::{self, Write, Error, ErrorKind, Read}; ++use async::async_stdin; ++use std::time::{SystemTime, Duration}; ++use raw::CONTROL_SEQUENCE_TIMEOUT; ++ ++derive_csi_sequence!("Hide the cursor.", Hide, "?25l"); ++derive_csi_sequence!("Show the cursor.", Show, "?25h"); ++ ++derive_csi_sequence!("Restore the cursor.", Restore, "u"); ++derive_csi_sequence!("Save the cursor.", Save, "s"); ++ ++/// Goto some position ((1,1)-based). ++/// ++/// # Why one-based? ++/// ++/// ANSI escapes are very poorly designed, and one of the many odd aspects is being one-based. This ++/// can be quite strange at first, but it is not that big of an obstruction once you get used to ++/// it. ++/// ++/// # Example ++/// ++/// ```rust ++/// extern crate termion; ++/// ++/// fn main() { ++/// print!("{}{}Stuff", termion::clear::All, termion::cursor::Goto(5, 3)); ++/// } ++/// ``` ++#[derive(Copy, Clone, PartialEq, Eq)] ++pub struct Goto(pub u16, pub u16); ++ ++impl Default for Goto { ++ fn default() -> Goto { ++ Goto(1, 1) ++ } ++} ++ ++impl fmt::Display for Goto { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ debug_assert!(self != &Goto(0, 0), "Goto is one-based."); ++ ++ write!(f, csi!("{};{}H"), self.1, self.0) ++ } ++} ++ ++/// Move cursor left. ++#[derive(Copy, Clone, PartialEq, Eq)] ++pub struct Left(pub u16); ++ ++impl fmt::Display for Left { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("{}D"), self.0) ++ } ++} ++ ++/// Move cursor right. ++#[derive(Copy, Clone, PartialEq, Eq)] ++pub struct Right(pub u16); ++ ++impl fmt::Display for Right { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("{}C"), self.0) ++ } ++} ++ ++/// Move cursor up. ++#[derive(Copy, Clone, PartialEq, Eq)] ++pub struct Up(pub u16); ++ ++impl fmt::Display for Up { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("{}A"), self.0) ++ } ++} ++ ++/// Move cursor down. ++#[derive(Copy, Clone, PartialEq, Eq)] ++pub struct Down(pub u16); ++ ++impl fmt::Display for Down { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("{}B"), self.0) ++ } ++} ++ ++/// Types that allow detection of the cursor position. ++pub trait DetectCursorPos { ++ /// Get the (1,1)-based cursor position from the terminal. ++ fn cursor_pos(&mut self) -> io::Result<(u16, u16)>; ++} ++ ++impl DetectCursorPos for W { ++ fn cursor_pos(&mut self) -> io::Result<(u16, u16)> { ++ let mut stdin = async_stdin(); ++ ++ // Where is the cursor? ++ // Use `ESC [ 6 n`. ++ write!(self, "\x1B[6n")?; ++ self.flush()?; ++ ++ let mut buf: [u8; 1] = [0]; ++ let mut read_chars = Vec::new(); ++ ++ let timeout = Duration::from_millis(CONTROL_SEQUENCE_TIMEOUT); ++ let now = SystemTime::now(); ++ ++ // Either consume all data up to R or wait for a timeout. ++ while buf[0] != b'R' && now.elapsed().unwrap() < timeout { ++ if stdin.read(&mut buf)? > 0 { ++ read_chars.push(buf[0]); ++ } ++ } ++ ++ if read_chars.len() == 0 { ++ return Err(Error::new(ErrorKind::Other, "Cursor position detection timed out.")); ++ } ++ ++ // The answer will look like `ESC [ Cy ; Cx R`. ++ ++ read_chars.pop(); // remove trailing R. ++ let read_str = String::from_utf8(read_chars).unwrap(); ++ let beg = read_str.rfind('[').unwrap(); ++ let coords: String = read_str.chars().skip(beg + 1).collect(); ++ let mut nums = coords.split(';'); ++ ++ let cy = nums.next() ++ .unwrap() ++ .parse::() ++ .unwrap(); ++ let cx = nums.next() ++ .unwrap() ++ .parse::() ++ .unwrap(); ++ ++ Ok((cx, cy)) ++ } ++} diff --cc vendor/termion-1.5.1/src/event.rs index 000000000,000000000..f79cb4c11 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/event.rs @@@ -1,0 -1,0 +1,351 @@@ ++//! Mouse and key events. ++ ++use std::io::{Error, ErrorKind}; ++use std::ascii::AsciiExt; ++use std::str; ++ ++/// An event reported by the terminal. ++#[derive(Debug, Clone, PartialEq, Eq, Hash)] ++pub enum Event { ++ /// A key press. ++ Key(Key), ++ /// A mouse button press, release or wheel use at specific coordinates. ++ Mouse(MouseEvent), ++ /// An event that cannot currently be evaluated. ++ Unsupported(Vec), ++} ++ ++/// A mouse related event. ++#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] ++pub enum MouseEvent { ++ /// A mouse button was pressed. ++ /// ++ /// The coordinates are one-based. ++ Press(MouseButton, u16, u16), ++ /// A mouse button was released. ++ /// ++ /// The coordinates are one-based. ++ Release(u16, u16), ++ /// A mouse button is held over the given coordinates. ++ /// ++ /// The coordinates are one-based. ++ Hold(u16, u16), ++} ++ ++/// A mouse button. ++#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] ++pub enum MouseButton { ++ /// The left mouse button. ++ Left, ++ /// The right mouse button. ++ Right, ++ /// The middle mouse button. ++ Middle, ++ /// Mouse wheel is going up. ++ /// ++ /// This event is typically only used with Mouse::Press. ++ WheelUp, ++ /// Mouse wheel is going down. ++ /// ++ /// This event is typically only used with Mouse::Press. ++ WheelDown, ++} ++ ++/// A key. ++#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] ++pub enum Key { ++ /// Backspace. ++ Backspace, ++ /// Left arrow. ++ Left, ++ /// Right arrow. ++ Right, ++ /// Up arrow. ++ Up, ++ /// Down arrow. ++ Down, ++ /// Home key. ++ Home, ++ /// End key. ++ End, ++ /// Page Up key. ++ PageUp, ++ /// Page Down key. ++ PageDown, ++ /// Delete key. ++ Delete, ++ /// Insert key. ++ Insert, ++ /// Function keys. ++ /// ++ /// Only function keys 1 through 12 are supported. ++ F(u8), ++ /// Normal character. ++ Char(char), ++ /// Alt modified character. ++ Alt(char), ++ /// Ctrl modified character. ++ /// ++ /// Note that certain keys may not be modifiable with `ctrl`, due to limitations of terminals. ++ Ctrl(char), ++ /// Null byte. ++ Null, ++ /// Esc key. ++ Esc, ++ ++ #[doc(hidden)] ++ __IsNotComplete, ++} ++ ++/// Parse an Event from `item` and possibly subsequent bytes through `iter`. ++pub fn parse_event(item: u8, iter: &mut I) -> Result ++ where I: Iterator> ++{ ++ let error = Error::new(ErrorKind::Other, "Could not parse an event"); ++ match item { ++ b'\x1B' => { ++ // This is an escape character, leading a control sequence. ++ Ok(match iter.next() { ++ Some(Ok(b'O')) => { ++ match iter.next() { ++ // F1-F4 ++ Some(Ok(val @ b'P'...b'S')) => Event::Key(Key::F(1 + val - b'P')), ++ _ => return Err(error), ++ } ++ } ++ Some(Ok(b'[')) => { ++ // This is a CSI sequence. ++ parse_csi(iter).ok_or(error)? ++ } ++ Some(Ok(c)) => { ++ let ch = parse_utf8_char(c, iter); ++ Event::Key(Key::Alt(try!(ch))) ++ } ++ Some(Err(_)) | None => return Err(error), ++ }) ++ } ++ b'\n' | b'\r' => Ok(Event::Key(Key::Char('\n'))), ++ b'\t' => Ok(Event::Key(Key::Char('\t'))), ++ b'\x7F' => Ok(Event::Key(Key::Backspace)), ++ c @ b'\x01'...b'\x1A' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1 + b'a') as char))), ++ c @ b'\x1C'...b'\x1F' => Ok(Event::Key(Key::Ctrl((c as u8 - 0x1C + b'4') as char))), ++ b'\0' => Ok(Event::Key(Key::Null)), ++ c => { ++ Ok({ ++ let ch = parse_utf8_char(c, iter); ++ Event::Key(Key::Char(try!(ch))) ++ }) ++ } ++ } ++} ++ ++/// Parses a CSI sequence, just after reading ^[ ++/// ++/// Returns None if an unrecognized sequence is found. ++fn parse_csi(iter: &mut I) -> Option ++ where I: Iterator> ++{ ++ Some(match iter.next() { ++ Some(Ok(b'[')) => match iter.next() { ++ Some(Ok(val @ b'A'...b'E')) => Event::Key(Key::F(1 + val - b'A')), ++ _ => return None, ++ }, ++ Some(Ok(b'D')) => Event::Key(Key::Left), ++ Some(Ok(b'C')) => Event::Key(Key::Right), ++ Some(Ok(b'A')) => Event::Key(Key::Up), ++ Some(Ok(b'B')) => Event::Key(Key::Down), ++ Some(Ok(b'H')) => Event::Key(Key::Home), ++ Some(Ok(b'F')) => Event::Key(Key::End), ++ Some(Ok(b'M')) => { ++ // X10 emulation mouse encoding: ESC [ CB Cx Cy (6 characters only). ++ let mut next = || iter.next().unwrap().unwrap(); ++ ++ let cb = next() as i8 - 32; ++ // (1, 1) are the coords for upper left. ++ let cx = next().saturating_sub(32) as u16; ++ let cy = next().saturating_sub(32) as u16; ++ Event::Mouse(match cb & 0b11 { ++ 0 => { ++ if cb & 0x40 != 0 { ++ MouseEvent::Press(MouseButton::WheelUp, cx, cy) ++ } else { ++ MouseEvent::Press(MouseButton::Left, cx, cy) ++ } ++ } ++ 1 => { ++ if cb & 0x40 != 0 { ++ MouseEvent::Press(MouseButton::WheelDown, cx, cy) ++ } else { ++ MouseEvent::Press(MouseButton::Middle, cx, cy) ++ } ++ } ++ 2 => MouseEvent::Press(MouseButton::Right, cx, cy), ++ 3 => MouseEvent::Release(cx, cy), ++ _ => return None, ++ }) ++ } ++ Some(Ok(b'<')) => { ++ // xterm mouse encoding: ++ // ESC [ < Cb ; Cx ; Cy (;) (M or m) ++ let mut buf = Vec::new(); ++ let mut c = iter.next().unwrap().unwrap(); ++ while match c { ++ b'm' | b'M' => false, ++ _ => true, ++ } { ++ buf.push(c); ++ c = iter.next().unwrap().unwrap(); ++ } ++ let str_buf = String::from_utf8(buf).unwrap(); ++ let nums = &mut str_buf.split(';'); ++ ++ let cb = nums.next() ++ .unwrap() ++ .parse::() ++ .unwrap(); ++ let cx = nums.next() ++ .unwrap() ++ .parse::() ++ .unwrap(); ++ let cy = nums.next() ++ .unwrap() ++ .parse::() ++ .unwrap(); ++ ++ let event = match cb { ++ 0...2 | 64...65 => { ++ let button = match cb { ++ 0 => MouseButton::Left, ++ 1 => MouseButton::Middle, ++ 2 => MouseButton::Right, ++ 64 => MouseButton::WheelUp, ++ 65 => MouseButton::WheelDown, ++ _ => unreachable!(), ++ }; ++ match c { ++ b'M' => MouseEvent::Press(button, cx, cy), ++ b'm' => MouseEvent::Release(cx, cy), ++ _ => return None, ++ } ++ } ++ 32 => MouseEvent::Hold(cx, cy), ++ 3 => MouseEvent::Release(cx, cy), ++ _ => return None, ++ }; ++ ++ Event::Mouse(event) ++ } ++ Some(Ok(c @ b'0'...b'9')) => { ++ // Numbered escape code. ++ let mut buf = Vec::new(); ++ buf.push(c); ++ let mut c = iter.next().unwrap().unwrap(); ++ // The final byte of a CSI sequence can be in the range 64-126, so ++ // let's keep reading anything else. ++ while c < 64 || c > 126 { ++ buf.push(c); ++ c = iter.next().unwrap().unwrap(); ++ } ++ ++ match c { ++ // rxvt mouse encoding: ++ // ESC [ Cb ; Cx ; Cy ; M ++ b'M' => { ++ let str_buf = String::from_utf8(buf).unwrap(); ++ ++ let nums: Vec = str_buf.split(';').map(|n| n.parse().unwrap()).collect(); ++ ++ let cb = nums[0]; ++ let cx = nums[1]; ++ let cy = nums[2]; ++ ++ let event = match cb { ++ 32 => MouseEvent::Press(MouseButton::Left, cx, cy), ++ 33 => MouseEvent::Press(MouseButton::Middle, cx, cy), ++ 34 => MouseEvent::Press(MouseButton::Right, cx, cy), ++ 35 => MouseEvent::Release(cx, cy), ++ 64 => MouseEvent::Hold(cx, cy), ++ 96 | 97 => MouseEvent::Press(MouseButton::WheelUp, cx, cy), ++ _ => return None, ++ }; ++ ++ Event::Mouse(event) ++ } ++ // Special key code. ++ b'~' => { ++ let str_buf = String::from_utf8(buf).unwrap(); ++ ++ // This CSI sequence can be a list of semicolon-separated ++ // numbers. ++ let nums: Vec = str_buf.split(';').map(|n| n.parse().unwrap()).collect(); ++ ++ if nums.is_empty() { ++ return None; ++ } ++ ++ // TODO: handle multiple values for key modififiers (ex: values ++ // [3, 2] means Shift+Delete) ++ if nums.len() > 1 { ++ return None; ++ } ++ ++ match nums[0] { ++ 1 | 7 => Event::Key(Key::Home), ++ 2 => Event::Key(Key::Insert), ++ 3 => Event::Key(Key::Delete), ++ 4 | 8 => Event::Key(Key::End), ++ 5 => Event::Key(Key::PageUp), ++ 6 => Event::Key(Key::PageDown), ++ v @ 11...15 => Event::Key(Key::F(v - 10)), ++ v @ 17...21 => Event::Key(Key::F(v - 11)), ++ v @ 23...24 => Event::Key(Key::F(v - 12)), ++ _ => return None, ++ } ++ } ++ _ => return None, ++ } ++ } ++ _ => return None, ++ }) ++ ++} ++ ++/// Parse `c` as either a single byte ASCII char or a variable size UTF-8 char. ++fn parse_utf8_char(c: u8, iter: &mut I) -> Result ++ where I: Iterator> ++{ ++ let error = Err(Error::new(ErrorKind::Other, "Input character is not valid UTF-8")); ++ if c.is_ascii() { ++ Ok(c as char) ++ } else { ++ let bytes = &mut Vec::new(); ++ bytes.push(c); ++ ++ loop { ++ match iter.next() { ++ Some(Ok(next)) => { ++ bytes.push(next); ++ if let Ok(st) = str::from_utf8(bytes) { ++ return Ok(st.chars().next().unwrap()); ++ } ++ if bytes.len() >= 4 { ++ return error; ++ } ++ } ++ _ => return error, ++ } ++ } ++ } ++} ++ ++#[cfg(test)] ++#[test] ++fn test_parse_utf8() { ++ let st = "abcéŷ¤£€ù%323"; ++ let ref mut bytes = st.bytes().map(|x| Ok(x)); ++ let chars = st.chars(); ++ for c in chars { ++ let b = bytes.next().unwrap().unwrap(); ++ assert!(c == parse_utf8_char(b, bytes).unwrap()); ++ } ++} diff --cc vendor/termion-1.5.1/src/input.rs index 000000000,000000000..6f6dd171f new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/input.rs @@@ -1,0 -1,0 +1,388 @@@ ++//! User input. ++ ++use std::io::{self, Read, Write}; ++use std::ops; ++ ++use event::{self, Event, Key}; ++use raw::IntoRawMode; ++ ++/// An iterator over input keys. ++pub struct Keys { ++ iter: Events, ++} ++ ++impl Iterator for Keys { ++ type Item = Result; ++ ++ fn next(&mut self) -> Option> { ++ loop { ++ match self.iter.next() { ++ Some(Ok(Event::Key(k))) => return Some(Ok(k)), ++ Some(Ok(_)) => continue, ++ e @ Some(Err(_)) => e, ++ None => return None, ++ }; ++ } ++ } ++} ++ ++/// An iterator over input events. ++pub struct Events { ++ inner: EventsAndRaw ++} ++ ++impl Iterator for Events { ++ type Item = Result; ++ ++ fn next(&mut self) -> Option> { ++ self.inner.next().map(|tuple| tuple.map(|(event, _raw)| event)) ++ } ++} ++ ++/// An iterator over input events and the bytes that define them. ++pub struct EventsAndRaw { ++ source: R, ++ leftover: Option, ++} ++ ++impl Iterator for EventsAndRaw { ++ type Item = Result<(Event, Vec), io::Error>; ++ ++ fn next(&mut self) -> Option), io::Error>> { ++ let mut source = &mut self.source; ++ ++ if let Some(c) = self.leftover { ++ // we have a leftover byte, use it ++ self.leftover = None; ++ return Some(parse_event(c, &mut source.bytes())); ++ } ++ ++ // Here we read two bytes at a time. We need to distinguish between single ESC key presses, ++ // and escape sequences (which start with ESC or a x1B byte). The idea is that if this is ++ // an escape sequence, we will read multiple bytes (the first byte being ESC) but if this ++ // is a single ESC keypress, we will only read a single byte. ++ let mut buf = [0u8; 2]; ++ let res = match source.read(&mut buf) { ++ Ok(0) => return None, ++ Ok(1) => { ++ match buf[0] { ++ b'\x1B' => Ok((Event::Key(Key::Esc), vec![b'\x1B'])), ++ c => parse_event(c, &mut source.bytes()), ++ } ++ } ++ Ok(2) => { ++ let mut option_iter = &mut Some(buf[1]).into_iter(); ++ let result = { ++ let mut iter = option_iter.map(|c| Ok(c)).chain(source.bytes()); ++ parse_event(buf[0], &mut iter) ++ }; ++ // If the option_iter wasn't consumed, keep the byte for later. ++ self.leftover = option_iter.next(); ++ result ++ } ++ Ok(_) => unreachable!(), ++ Err(e) => Err(e), ++ }; ++ ++ Some(res) ++ } ++} ++ ++fn parse_event(item: u8, iter: &mut I) -> Result<(Event, Vec), io::Error> ++ where I: Iterator> ++{ ++ let mut buf = vec![item]; ++ let result = { ++ let mut iter = iter.inspect(|byte| if let &Ok(byte) = byte { ++ buf.push(byte); ++ }); ++ event::parse_event(item, &mut iter) ++ }; ++ result.or(Ok(Event::Unsupported(buf.clone()))).map(|e| (e, buf)) ++} ++ ++ ++/// Extension to `Read` trait. ++pub trait TermRead { ++ /// An iterator over input events. ++ fn events(self) -> Events where Self: Sized; ++ ++ /// An iterator over key inputs. ++ fn keys(self) -> Keys where Self: Sized; ++ ++ /// Read a line. ++ /// ++ /// EOT and ETX will abort the prompt, returning `None`. Newline or carriage return will ++ /// complete the input. ++ fn read_line(&mut self) -> io::Result>; ++ ++ /// Read a password. ++ /// ++ /// EOT and ETX will abort the prompt, returning `None`. Newline or carriage return will ++ /// complete the input. ++ fn read_passwd(&mut self, writer: &mut W) -> io::Result> { ++ let _raw = try!(writer.into_raw_mode()); ++ self.read_line() ++ } ++} ++ ++ ++impl TermRead for R { ++ fn events(self) -> Events { ++ Events { ++ inner: self.events_and_raw() ++ } ++ } ++ fn keys(self) -> Keys { ++ Keys { iter: self.events() } ++ } ++ ++ fn read_line(&mut self) -> io::Result> { ++ let mut buf = Vec::with_capacity(30); ++ ++ for c in self.bytes() { ++ match c { ++ Err(e) => return Err(e), ++ Ok(0) | Ok(3) | Ok(4) => return Ok(None), ++ Ok(0x7f) => { ++ buf.pop(); ++ } ++ Ok(b'\n') | Ok(b'\r') => break, ++ Ok(c) => buf.push(c), ++ } ++ } ++ ++ let string = try!(String::from_utf8(buf) ++ .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))); ++ Ok(Some(string)) ++ } ++} ++ ++/// Extension to `TermRead` trait. A separate trait in order to maintain backwards compatibility. ++pub trait TermReadEventsAndRaw { ++ /// An iterator over input events and the bytes that define them. ++ fn events_and_raw(self) -> EventsAndRaw where Self: Sized; ++} ++ ++impl TermReadEventsAndRaw for R { ++ fn events_and_raw(self) -> EventsAndRaw { ++ EventsAndRaw { ++ source: self, ++ leftover: None, ++ } ++ } ++} ++ ++/// A sequence of escape codes to enable terminal mouse support. ++const ENTER_MOUSE_SEQUENCE: &'static str = csi!("?1000h\x1b[?1002h\x1b[?1015h\x1b[?1006h"); ++ ++/// A sequence of escape codes to disable terminal mouse support. ++const EXIT_MOUSE_SEQUENCE: &'static str = csi!("?1006l\x1b[?1015l\x1b[?1002l\x1b[?1000l"); ++ ++/// A terminal with added mouse support. ++/// ++/// This can be obtained through the `From` implementations. ++pub struct MouseTerminal { ++ term: W, ++} ++ ++impl From for MouseTerminal { ++ fn from(mut from: W) -> MouseTerminal { ++ from.write_all(ENTER_MOUSE_SEQUENCE.as_bytes()).unwrap(); ++ ++ MouseTerminal { term: from } ++ } ++} ++ ++impl Drop for MouseTerminal { ++ fn drop(&mut self) { ++ self.term.write_all(EXIT_MOUSE_SEQUENCE.as_bytes()).unwrap(); ++ } ++} ++ ++impl ops::Deref for MouseTerminal { ++ type Target = W; ++ ++ fn deref(&self) -> &W { ++ &self.term ++ } ++} ++ ++impl ops::DerefMut for MouseTerminal { ++ fn deref_mut(&mut self) -> &mut W { ++ &mut self.term ++ } ++} ++ ++impl Write for MouseTerminal { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.term.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.term.flush() ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use super::*; ++ use std::io; ++ use event::{Key, Event, MouseEvent, MouseButton}; ++ ++ #[test] ++ fn test_keys() { ++ let mut i = b"\x1Bayo\x7F\x1B[D".keys(); ++ ++ assert_eq!(i.next().unwrap().unwrap(), Key::Alt('a')); ++ assert_eq!(i.next().unwrap().unwrap(), Key::Char('y')); ++ assert_eq!(i.next().unwrap().unwrap(), Key::Char('o')); ++ assert_eq!(i.next().unwrap().unwrap(), Key::Backspace); ++ assert_eq!(i.next().unwrap().unwrap(), Key::Left); ++ assert!(i.next().is_none()); ++ } ++ ++ #[test] ++ fn test_events() { ++ let mut i = ++ b"\x1B[\x00bc\x7F\x1B[D\ ++ \x1B[M\x00\x22\x24\x1B[<0;2;4;M\x1B[32;2;4M\x1B[<0;2;4;m\x1B[35;2;4Mb" ++ .events(); ++ ++ assert_eq!(i.next().unwrap().unwrap(), ++ Event::Unsupported(vec![0x1B, b'[', 0x00])); ++ assert_eq!(i.next().unwrap().unwrap(), Event::Key(Key::Char('b'))); ++ assert_eq!(i.next().unwrap().unwrap(), Event::Key(Key::Char('c'))); ++ assert_eq!(i.next().unwrap().unwrap(), Event::Key(Key::Backspace)); ++ assert_eq!(i.next().unwrap().unwrap(), Event::Key(Key::Left)); ++ assert_eq!(i.next().unwrap().unwrap(), ++ Event::Mouse(MouseEvent::Press(MouseButton::WheelUp, 2, 4))); ++ assert_eq!(i.next().unwrap().unwrap(), ++ Event::Mouse(MouseEvent::Press(MouseButton::Left, 2, 4))); ++ assert_eq!(i.next().unwrap().unwrap(), ++ Event::Mouse(MouseEvent::Press(MouseButton::Left, 2, 4))); ++ assert_eq!(i.next().unwrap().unwrap(), ++ Event::Mouse(MouseEvent::Release(2, 4))); ++ assert_eq!(i.next().unwrap().unwrap(), ++ Event::Mouse(MouseEvent::Release(2, 4))); ++ assert_eq!(i.next().unwrap().unwrap(), Event::Key(Key::Char('b'))); ++ assert!(i.next().is_none()); ++ } ++ ++ #[test] ++ fn test_events_and_raw() { ++ let input = b"\x1B[\x00bc\x7F\x1B[D\ ++ \x1B[M\x00\x22\x24\x1B[<0;2;4;M\x1B[32;2;4M\x1B[<0;2;4;m\x1B[35;2;4Mb"; ++ let mut output = Vec::::new(); ++ { ++ let mut i = input.events_and_raw().map(|res| res.unwrap()) ++ .inspect(|&(_, ref raw)| { output.extend(raw); }).map(|(event, _)| event); ++ ++ assert_eq!(i.next().unwrap(), ++ Event::Unsupported(vec![0x1B, b'[', 0x00])); ++ assert_eq!(i.next().unwrap(), Event::Key(Key::Char('b'))); ++ assert_eq!(i.next().unwrap(), Event::Key(Key::Char('c'))); ++ assert_eq!(i.next().unwrap(), Event::Key(Key::Backspace)); ++ assert_eq!(i.next().unwrap(), Event::Key(Key::Left)); ++ assert_eq!(i.next().unwrap(), ++ Event::Mouse(MouseEvent::Press(MouseButton::WheelUp, 2, 4))); ++ assert_eq!(i.next().unwrap(), ++ Event::Mouse(MouseEvent::Press(MouseButton::Left, 2, 4))); ++ assert_eq!(i.next().unwrap(), ++ Event::Mouse(MouseEvent::Press(MouseButton::Left, 2, 4))); ++ assert_eq!(i.next().unwrap(), ++ Event::Mouse(MouseEvent::Release(2, 4))); ++ assert_eq!(i.next().unwrap(), ++ Event::Mouse(MouseEvent::Release(2, 4))); ++ assert_eq!(i.next().unwrap(), Event::Key(Key::Char('b'))); ++ assert!(i.next().is_none()); ++ } ++ ++ assert_eq!(input.iter().map(|b| *b).collect::>(), output) ++ } ++ ++ #[test] ++ fn test_function_keys() { ++ let mut st = b"\x1BOP\x1BOQ\x1BOR\x1BOS".keys(); ++ for i in 1..5 { ++ assert_eq!(st.next().unwrap().unwrap(), Key::F(i)); ++ } ++ ++ let mut st = b"\x1B[11~\x1B[12~\x1B[13~\x1B[14~\x1B[15~\ ++ \x1B[17~\x1B[18~\x1B[19~\x1B[20~\x1B[21~\x1B[23~\x1B[24~" ++ .keys(); ++ for i in 1..13 { ++ assert_eq!(st.next().unwrap().unwrap(), Key::F(i)); ++ } ++ } ++ ++ #[test] ++ fn test_special_keys() { ++ let mut st = b"\x1B[2~\x1B[H\x1B[7~\x1B[5~\x1B[3~\x1B[F\x1B[8~\x1B[6~".keys(); ++ assert_eq!(st.next().unwrap().unwrap(), Key::Insert); ++ assert_eq!(st.next().unwrap().unwrap(), Key::Home); ++ assert_eq!(st.next().unwrap().unwrap(), Key::Home); ++ assert_eq!(st.next().unwrap().unwrap(), Key::PageUp); ++ assert_eq!(st.next().unwrap().unwrap(), Key::Delete); ++ assert_eq!(st.next().unwrap().unwrap(), Key::End); ++ assert_eq!(st.next().unwrap().unwrap(), Key::End); ++ assert_eq!(st.next().unwrap().unwrap(), Key::PageDown); ++ assert!(st.next().is_none()); ++ } ++ ++ #[test] ++ fn test_esc_key() { ++ let mut st = b"\x1B".keys(); ++ assert_eq!(st.next().unwrap().unwrap(), Key::Esc); ++ assert!(st.next().is_none()); ++ } ++ ++ fn line_match(a: &str, b: Option<&str>) { ++ let mut sink = io::sink(); ++ ++ let line = a.as_bytes().read_line().unwrap(); ++ let pass = a.as_bytes().read_passwd(&mut sink).unwrap(); ++ ++ // godammit rustc ++ ++ assert_eq!(line, pass); ++ ++ if let Some(l) = line { ++ assert_eq!(Some(l.as_str()), b); ++ } else { ++ assert!(b.is_none()); ++ } ++ } ++ ++ #[test] ++ fn test_read() { ++ let test1 = "this is the first test"; ++ let test2 = "this is the second test"; ++ ++ line_match(test1, Some(test1)); ++ line_match(test2, Some(test2)); ++ } ++ ++ #[test] ++ fn test_backspace() { ++ line_match("this is the\x7f first\x7f\x7f test", ++ Some("this is th fir test")); ++ line_match("this is the seco\x7fnd test\x7f", ++ Some("this is the secnd tes")); ++ } ++ ++ #[test] ++ fn test_end() { ++ line_match("abc\nhttps://www.youtube.com/watch?v=dQw4w9WgXcQ", ++ Some("abc")); ++ line_match("hello\rhttps://www.youtube.com/watch?v=yPYZpwSpKmA", ++ Some("hello")); ++ } ++ ++ #[test] ++ fn test_abort() { ++ line_match("abc\x03https://www.youtube.com/watch?v=dQw4w9WgXcQ", None); ++ line_match("hello\x04https://www.youtube.com/watch?v=yPYZpwSpKmA", None); ++ } ++ ++} diff --cc vendor/termion-1.5.1/src/lib.rs index 000000000,000000000..b284eddd1 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/lib.rs @@@ -1,0 -1,0 +1,61 @@@ ++//! Termion is a pure Rust, bindless library for low-level handling, manipulating ++//! and reading information about terminals. This provides a full-featured ++//! alternative to Termbox. ++//! ++//! Termion aims to be simple and yet expressive. It is bindless, meaning that it ++//! is not a front-end to some other library (e.g., ncurses or termbox), but a ++//! standalone library directly talking to the TTY. ++//! ++//! Supports Redox, Mac OS X, and Linux (or, in general, ANSI terminals). ++//! ++//! For more information refer to the [README](https://github.com/ticki/termion). ++#![warn(missing_docs)] ++ ++#[cfg(target_os = "redox")] ++#[path="sys/redox/mod.rs"] ++mod sys; ++ ++#[cfg(unix)] ++#[path="sys/unix/mod.rs"] ++mod sys; ++ ++pub use sys::size::terminal_size; ++pub use sys::tty::{is_tty, get_tty}; ++ ++mod async; ++pub use async::{AsyncReader, async_stdin}; ++ ++#[macro_use] ++mod macros; ++pub mod clear; ++pub mod color; ++pub mod cursor; ++pub mod event; ++pub mod input; ++pub mod raw; ++pub mod screen; ++pub mod scroll; ++pub mod style; ++ ++#[cfg(test)] ++mod test { ++ use super::sys; ++ ++ #[test] ++ fn test_get_terminal_attr() { ++ sys::attr::get_terminal_attr().unwrap(); ++ sys::attr::get_terminal_attr().unwrap(); ++ sys::attr::get_terminal_attr().unwrap(); ++ } ++ ++ #[test] ++ fn test_set_terminal_attr() { ++ let ios = sys::attr::get_terminal_attr().unwrap(); ++ sys::attr::set_terminal_attr(&ios).unwrap(); ++ } ++ ++ #[test] ++ fn test_size() { ++ sys::size::terminal_size().unwrap(); ++ } ++} diff --cc vendor/termion-1.5.1/src/macros.rs index 000000000,000000000..28370e36b new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/macros.rs @@@ -1,0 -1,0 +1,19 @@@ ++/// Create a CSI-introduced sequence. ++macro_rules! csi { ++ ($( $l:expr ),*) => { concat!("\x1B[", $( $l ),*) }; ++} ++ ++/// Derive a CSI sequence struct. ++macro_rules! derive_csi_sequence { ++ ($doc:expr, $name:ident, $value:expr) => { ++ #[doc = $doc] ++ #[derive(Copy, Clone)] ++ pub struct $name; ++ ++ impl fmt::Display for $name { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!($value)) ++ } ++ } ++ }; ++} diff --cc vendor/termion-1.5.1/src/raw.rs index 000000000,000000000..5421d5659 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/raw.rs @@@ -1,0 -1,0 +1,117 @@@ ++//! Managing raw mode. ++//! ++//! Raw mode is a particular state a TTY can have. It signifies that: ++//! ++//! 1. No line buffering (the input is given byte-by-byte). ++//! 2. The input is not written out, instead it has to be done manually by the programmer. ++//! 3. The output is not canonicalized (for example, `\n` means "go one line down", not "line ++//! break"). ++//! ++//! It is essential to design terminal programs. ++//! ++//! # Example ++//! ++//! ```rust,no_run ++//! use termion::raw::IntoRawMode; ++//! use std::io::{Write, stdout}; ++//! ++//! fn main() { ++//! let mut stdout = stdout().into_raw_mode().unwrap(); ++//! ++//! write!(stdout, "Hey there.").unwrap(); ++//! } ++//! ``` ++ ++use std::io::{self, Write}; ++use std::ops; ++ ++use sys::Termios; ++use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr}; ++ ++/// The timeout of an escape code control sequence, in milliseconds. ++pub const CONTROL_SEQUENCE_TIMEOUT: u64 = 100; ++ ++/// A terminal restorer, which keeps the previous state of the terminal, and restores it, when ++/// dropped. ++/// ++/// Restoring will entirely bring back the old TTY state. ++pub struct RawTerminal { ++ prev_ios: Termios, ++ output: W, ++} ++ ++impl Drop for RawTerminal { ++ fn drop(&mut self) { ++ set_terminal_attr(&self.prev_ios).unwrap(); ++ } ++} ++ ++impl ops::Deref for RawTerminal { ++ type Target = W; ++ ++ fn deref(&self) -> &W { ++ &self.output ++ } ++} ++ ++impl ops::DerefMut for RawTerminal { ++ fn deref_mut(&mut self) -> &mut W { ++ &mut self.output ++ } ++} ++ ++impl Write for RawTerminal { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.output.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.output.flush() ++ } ++} ++ ++/// Types which can be converted into "raw mode". ++/// ++/// # Why is this type defined on writers and not readers? ++/// ++/// TTYs has their state controlled by the writer, not the reader. You use the writer to clear the ++/// screen, move the cursor and so on, so naturally you use the writer to change the mode as well. ++pub trait IntoRawMode: Write + Sized { ++ /// Switch to raw mode. ++ /// ++ /// Raw mode means that stdin won't be printed (it will instead have to be written manually by ++ /// the program). Furthermore, the input isn't canonicalised or buffered (that is, you can ++ /// read from stdin one byte of a time). The output is neither modified in any way. ++ fn into_raw_mode(self) -> io::Result>; ++} ++ ++impl IntoRawMode for W { ++ fn into_raw_mode(self) -> io::Result> { ++ let mut ios = get_terminal_attr()?; ++ let prev_ios = ios; ++ ++ raw_terminal_attr(&mut ios); ++ ++ set_terminal_attr(&ios)?; ++ ++ Ok(RawTerminal { ++ prev_ios: prev_ios, ++ output: self, ++ }) ++ } ++} ++ ++#[cfg(test)] ++mod test { ++ use super::*; ++ use std::io::{Write, stdout}; ++ ++ #[test] ++ fn test_into_raw_mode() { ++ let mut out = stdout().into_raw_mode().unwrap(); ++ ++ out.write_all(b"this is a test, muahhahahah\r\n").unwrap(); ++ ++ drop(out); ++ } ++} diff --cc vendor/termion-1.5.1/src/screen.rs index 000000000,000000000..822399e27 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/screen.rs @@@ -1,0 -1,0 +1,91 @@@ ++//! Managing switching between main and alternate screen buffers. ++//! ++//! Note that this implementation uses xterm's new escape sequences for screen switching and thus ++//! only works for xterm compatible terminals (which should be most terminals nowadays). ++//! ++//! # Example ++//! ++//! ```rust ++//! use termion::screen::AlternateScreen; ++//! use std::io::{Write, stdout}; ++//! ++//! fn main() { ++//! { ++//! let mut screen = AlternateScreen::from(stdout()); ++//! write!(screen, "Writing to alternate screen!").unwrap(); ++//! screen.flush().unwrap(); ++//! } ++//! println!("Writing to main screen."); ++//! } ++//! ``` ++ ++use std::io::{self, Write}; ++use std::ops; ++use std::fmt; ++ ++/// Switch to the main screen buffer of the terminal. ++pub struct ToMainScreen; ++ ++impl fmt::Display for ToMainScreen { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("?1049l")) ++ } ++} ++ ++/// Switch to the alternate screen buffer of the terminal. ++pub struct ToAlternateScreen; ++ ++impl fmt::Display for ToAlternateScreen { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("?1049h")) ++ } ++} ++ ++/// A terminal restorer, which wraps a type implementing Write, and causes all writes to be written ++/// to an alternate screen. ++/// ++/// This is achieved by switching the terminal to the alternate screen on creation and ++/// automatically switching it back to the original screen on drop. ++pub struct AlternateScreen { ++ /// The output target. ++ output: W, ++} ++ ++impl AlternateScreen { ++ /// Create an alternate screen wrapper struct for the provided output and switch the terminal ++ /// to the alternate screen. ++ pub fn from(mut output: W) -> Self { ++ write!(output, "{}", ToAlternateScreen).expect("switch to alternate screen"); ++ AlternateScreen { output: output } ++ } ++} ++ ++impl Drop for AlternateScreen { ++ fn drop(&mut self) { ++ write!(self, "{}", ToMainScreen).expect("switch to main screen"); ++ } ++} ++ ++impl ops::Deref for AlternateScreen { ++ type Target = W; ++ ++ fn deref(&self) -> &W { ++ &self.output ++ } ++} ++ ++impl ops::DerefMut for AlternateScreen { ++ fn deref_mut(&mut self) -> &mut W { ++ &mut self.output ++ } ++} ++ ++impl Write for AlternateScreen { ++ fn write(&mut self, buf: &[u8]) -> io::Result { ++ self.output.write(buf) ++ } ++ ++ fn flush(&mut self) -> io::Result<()> { ++ self.output.flush() ++ } ++} diff --cc vendor/termion-1.5.1/src/scroll.rs index 000000000,000000000..2744507f3 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/scroll.rs @@@ -1,0 -1,0 +1,23 @@@ ++//! Scrolling. ++ ++use std::fmt; ++ ++/// Scroll up. ++#[derive(Copy, Clone, PartialEq, Eq)] ++pub struct Up(pub u16); ++ ++impl fmt::Display for Up { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("{}S"), self.0) ++ } ++} ++ ++/// Scroll down. ++#[derive(Copy, Clone, PartialEq, Eq)] ++pub struct Down(pub u16); ++ ++impl fmt::Display for Down { ++ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ++ write!(f, csi!("{}T"), self.0) ++ } ++} diff --cc vendor/termion-1.5.1/src/style.rs index 000000000,000000000..58e9a78b8 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/style.rs @@@ -1,0 -1,0 +1,22 @@@ ++//! Text styling management. ++ ++use std::fmt; ++ ++derive_csi_sequence!("Reset SGR parameters.", Reset, "m"); ++derive_csi_sequence!("Bold text.", Bold, "1m"); ++derive_csi_sequence!("Fainted text (not widely supported).", Faint, "2m"); ++derive_csi_sequence!("Italic text.", Italic, "3m"); ++derive_csi_sequence!("Underlined text.", Underline, "4m"); ++derive_csi_sequence!("Blinking text (not widely supported).", Blink, "5m"); ++derive_csi_sequence!("Inverted colors (negative mode).", Invert, "7m"); ++derive_csi_sequence!("Crossed out text (not widely supported).", CrossedOut, "9m"); ++derive_csi_sequence!("Undo bold text.", NoBold, "21m"); ++derive_csi_sequence!("Undo fainted text (not widely supported).", NoFaint, "22m"); ++derive_csi_sequence!("Undo italic text.", NoItalic, "23m"); ++derive_csi_sequence!("Undo underlined text.", NoUnderline, "24m"); ++derive_csi_sequence!("Undo blinking text (not widely supported).", NoBlink, "25m"); ++derive_csi_sequence!("Undo inverted colors (negative mode).", NoInvert, "27m"); ++derive_csi_sequence!("Undo crossed out text (not widely supported).", ++ NoCrossedOut, ++ "29m"); ++derive_csi_sequence!("Framed text (not widely supported).", Framed, "51m"); diff --cc vendor/termion-1.5.1/src/sys/redox/attr.rs index 000000000,000000000..c6489a510 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/sys/redox/attr.rs @@@ -1,0 -1,0 +1,33 @@@ ++use std::io; ++ ++use super::{cvt, syscall, Termios}; ++ ++pub fn get_terminal_attr() -> io::Result { ++ let mut termios = Termios::default(); ++ ++ let fd = cvt(syscall::dup(0, b"termios"))?; ++ let res = cvt(syscall::read(fd, &mut termios)); ++ let _ = syscall::close(fd); ++ ++ if res? == termios.len() { ++ Ok(termios) ++ } else { ++ Err(io::Error::new(io::ErrorKind::Other, "Unable to get the terminal attributes.")) ++ } ++} ++ ++pub fn set_terminal_attr(termios: &Termios) -> io::Result<()> { ++ let fd = cvt(syscall::dup(0, b"termios"))?; ++ let res = cvt(syscall::write(fd, termios)); ++ let _ = syscall::close(fd); ++ ++ if res? == termios.len() { ++ Ok(()) ++ } else { ++ Err(io::Error::new(io::ErrorKind::Other, "Unable to set the terminal attributes.")) ++ } ++} ++ ++pub fn raw_terminal_attr(ios: &mut Termios) { ++ ios.make_raw() ++} diff --cc vendor/termion-1.5.1/src/sys/redox/mod.rs index 000000000,000000000..2a9b875e3 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/sys/redox/mod.rs @@@ -1,0 -1,0 +1,15 @@@ ++extern crate redox_termios; ++extern crate syscall; ++ ++use std::io; ++ ++pub use self::redox_termios::Termios; ++ ++pub mod attr; ++pub mod size; ++pub mod tty; ++ ++// Support function for converting syscall error to io error ++fn cvt(result: Result) -> io::Result { ++ result.map_err(|err| io::Error::from_raw_os_error(err.errno)) ++} diff --cc vendor/termion-1.5.1/src/sys/redox/size.rs index 000000000,000000000..07f64a243 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/sys/redox/size.rs @@@ -1,0 -1,0 +1,18 @@@ ++use std::io; ++ ++use super::{cvt, redox_termios, syscall}; ++ ++/// Get the size of the terminal. ++pub fn terminal_size() -> io::Result<(u16, u16)> { ++ let mut winsize = redox_termios::Winsize::default(); ++ ++ let fd = cvt(syscall::dup(1, b"winsize"))?; ++ let res = cvt(syscall::read(fd, &mut winsize)); ++ let _ = syscall::close(fd); ++ ++ if res? == winsize.len() { ++ Ok((winsize.ws_col, winsize.ws_row)) ++ } else { ++ Err(io::Error::new(io::ErrorKind::Other, "Unable to get the terminal size.")) ++ } ++} diff --cc vendor/termion-1.5.1/src/sys/redox/tty.rs index 000000000,000000000..9179b3962 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/sys/redox/tty.rs @@@ -1,0 -1,0 +1,22 @@@ ++use std::{env, fs, io}; ++use std::os::unix::io::AsRawFd; ++ ++use super::syscall; ++ ++/// Is this stream a TTY? ++pub fn is_tty(stream: &T) -> bool { ++ if let Ok(fd) = syscall::dup(stream.as_raw_fd(), b"termios") { ++ let _ = syscall::close(fd); ++ true ++ } else { ++ false ++ } ++} ++ ++/// Get the TTY device. ++/// ++/// This allows for getting stdio representing _only_ the TTY, and not other streams. ++pub fn get_tty() -> io::Result { ++ let tty = try!(env::var("TTY").map_err(|x| io::Error::new(io::ErrorKind::NotFound, x))); ++ fs::OpenOptions::new().read(true).write(true).open(tty) ++} diff --cc vendor/termion-1.5.1/src/sys/unix/attr.rs index 000000000,000000000..5e21fbac8 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/sys/unix/attr.rs @@@ -1,0 -1,0 +1,29 @@@ ++use std::{io, mem}; ++ ++use super::{cvt, Termios}; ++use super::libc::c_int; ++ ++pub fn get_terminal_attr() -> io::Result { ++ extern "C" { ++ pub fn tcgetattr(fd: c_int, termptr: *mut Termios) -> c_int; ++ } ++ unsafe { ++ let mut termios = mem::zeroed(); ++ cvt(tcgetattr(0, &mut termios))?; ++ Ok(termios) ++ } ++} ++ ++pub fn set_terminal_attr(termios: &Termios) -> io::Result<()> { ++ extern "C" { ++ pub fn tcsetattr(fd: c_int, opt: c_int, termptr: *const Termios) -> c_int; ++ } ++ cvt(unsafe { tcsetattr(0, 0, termios) }).and(Ok(())) ++} ++ ++pub fn raw_terminal_attr(termios: &mut Termios) { ++ extern "C" { ++ pub fn cfmakeraw(termptr: *mut Termios); ++ } ++ unsafe { cfmakeraw(termios) } ++} diff --cc vendor/termion-1.5.1/src/sys/unix/mod.rs index 000000000,000000000..08d73feb1 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/sys/unix/mod.rs @@@ -1,0 -1,0 +1,33 @@@ ++extern crate libc; ++ ++use std::io; ++ ++pub use self::libc::termios as Termios; ++ ++pub mod attr; ++pub mod size; ++pub mod tty; ++ ++// Support functions for converting libc return values to io errors { ++trait IsMinusOne { ++ fn is_minus_one(&self) -> bool; ++} ++ ++macro_rules! impl_is_minus_one { ++ ($($t:ident)*) => ($(impl IsMinusOne for $t { ++ fn is_minus_one(&self) -> bool { ++ *self == -1 ++ } ++ })*) ++ } ++ ++impl_is_minus_one! { i8 i16 i32 i64 isize } ++ ++fn cvt(t: T) -> io::Result { ++ if t.is_minus_one() { ++ Err(io::Error::last_os_error()) ++ } else { ++ Ok(t) ++ } ++} ++// } End of support functions diff --cc vendor/termion-1.5.1/src/sys/unix/size.rs index 000000000,000000000..9c2aaf1a8 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/sys/unix/size.rs @@@ -1,0 -1,0 +1,48 @@@ ++use std::{io, mem}; ++ ++use super::cvt; ++use super::libc::{c_ushort, ioctl, STDOUT_FILENO}; ++ ++#[repr(C)] ++struct TermSize { ++ row: c_ushort, ++ col: c_ushort, ++ _x: c_ushort, ++ _y: c_ushort, ++} ++ ++#[cfg(target_os = "linux")] ++pub const TIOCGWINSZ: usize = 0x00005413; ++ ++#[cfg(not(target_os = "linux"))] ++pub const TIOCGWINSZ: usize = 0x40087468; ++ ++// Since attributes on non-item statements is not stable yet, we use a function. ++#[cfg(not(target_os = "android"))] ++#[cfg(not(target_os = "redox"))] ++#[cfg(target_pointer_width = "64")] ++#[cfg(not(target_env = "musl"))] ++fn tiocgwinsz() -> u64 { ++ TIOCGWINSZ as u64 ++} ++#[cfg(not(target_os = "android"))] ++#[cfg(not(target_os = "redox"))] ++#[cfg(target_pointer_width = "32")] ++#[cfg(not(target_env = "musl"))] ++fn tiocgwinsz() -> u32 { ++ TIOCGWINSZ as u32 ++} ++ ++#[cfg(any(target_env = "musl", target_os = "android"))] ++fn tiocgwinsz() -> i32 { ++ TIOCGWINSZ as i32 ++} ++ ++/// Get the size of the terminal. ++pub fn terminal_size() -> io::Result<(u16, u16)> { ++ unsafe { ++ let mut size: TermSize = mem::zeroed(); ++ cvt(ioctl(STDOUT_FILENO, tiocgwinsz(), &mut size as *mut _))?; ++ Ok((size.col as u16, size.row as u16)) ++ } ++} diff --cc vendor/termion-1.5.1/src/sys/unix/tty.rs index 000000000,000000000..2be936347 new file mode 100644 --- /dev/null +++ b/vendor/termion-1.5.1/src/sys/unix/tty.rs @@@ -1,0 -1,0 +1,17 @@@ ++use std::{fs, io}; ++use std::os::unix::io::AsRawFd; ++ ++use super::libc; ++ ++ ++/// Is this stream a TTY? ++pub fn is_tty(stream: &T) -> bool { ++ unsafe { libc::isatty(stream.as_raw_fd()) == 1 } ++} ++ ++/// Get the TTY device. ++/// ++/// This allows for getting stdio representing _only_ the TTY, and not other streams. ++pub fn get_tty() -> io::Result { ++ fs::OpenOptions::new().read(true).write(true).open("/dev/tty") ++} diff --cc vendor/toml-0.4.5/.cargo-checksum.json index 000000000,000000000..c957e1110 new file mode 100644 --- /dev/null +++ b/vendor/toml-0.4.5/.cargo-checksum.json @@@ -1,0 -1,0 +1,1 @@@ ++{"files":{},"package":"a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e"} diff --cc vendor/toml-0.4.5/.cargo-ok index 000000000,000000000..e69de29bb new file mode 100644 --- /dev/null +++ b/vendor/toml-0.4.5/.cargo-ok diff --cc vendor/toml-0.4.5/.travis.yml index 000000000,000000000..e4c5407b0 new file mode 100644 --- /dev/null +++ b/vendor/toml-0.4.5/.travis.yml @@@ -1,0 -1,0 +1,29 @@@ ++language: rust ++rust: ++ - 1.15.0 ++ - stable ++ - beta ++ - nightly ++sudo: false ++before_script: ++ - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH ++script: ++ - cargo test ++ - rustdoc --test README.md -L target ++ - test "$TRAVIS_RUST_VERSION" != "1.15.0" && cargo doc --no-deps || echo "skipping cargo doc" ++after_success: ++ - travis-cargo --only nightly doc-upload ++ - travis-cargo coveralls --no-sudo ++env: ++ global: ++ secure: "IDm3Oc3bmIL4/6zixovwkuTkbinqWnKdLfeuKTtHqT4ZbVy+rxTDQBgLGfVngymjciHWkJnvQ8/2nT3/KW4MPNY9Sqt3NfWvO7vj9cXypeNeJ4xFrVK49F7CMM4KTCeSMlDKR1C0TVYGgxFIViLtBw/imivl9fk6J489eKv36sA=" ++ ++notifications: ++ email: ++ on_success: never ++addons: ++ apt: ++ packages: ++ - libcurl4-openssl-dev ++ - libelf-dev ++ - libdw-dev diff --cc vendor/toml-0.4.5/Cargo.toml index 000000000,000000000..da921ce45 new file mode 100644 --- /dev/null +++ b/vendor/toml-0.4.5/Cargo.toml @@@ -1,0 -1,0 +1,33 @@@ ++# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO ++# ++# When uploading crates to the registry Cargo will automatically ++# "normalize" Cargo.toml files for maximal compatibility ++# with all versions of Cargo and also rewrite `path` dependencies ++# to registry (e.g. crates.io) dependencies ++# ++# If you believe there's an error in this file please file an ++# issue against the rust-lang/cargo repository. If you're ++# editing this file be aware that the upstream Cargo.toml ++# will likely look very different (and much more reasonable) ++ ++[package] ++name = "toml" ++version = "0.4.5" ++authors = ["Alex Crichton "] ++description = "A native Rust encoder and decoder of TOML-formatted files and streams. Provides\nimplementations of the standard Serialize/Deserialize traits for TOML data to\nfacilitate deserializing and serializing Rust structures.\n" ++homepage = "https://github.com/alexcrichton/toml-rs" ++documentation = "https://docs.rs/toml" ++readme = "README.md" ++keywords = ["encoding"] ++categories = ["config", "encoding", "parser-implementations"] ++license = "MIT/Apache-2.0" ++repository = "https://github.com/alexcrichton/toml-rs" ++[dependencies.serde] ++version = "1.0" ++[dev-dependencies.serde_derive] ++version = "1.0" ++ ++[dev-dependencies.serde_json] ++version = "1.0" ++[badges.travis-ci] ++repository = "alexcrichton/toml-rs" diff --cc vendor/toml-0.4.5/LICENSE-APACHE index 000000000,000000000..16fe87b06 new file mode 100644 --- /dev/null +++ b/vendor/toml-0.4.5/LICENSE-APACHE @@@ -1,0 -1,0 +1,201 @@@ ++ 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 --cc vendor/toml-0.4.5/LICENSE-MIT index 000000000,000000000..39e0ed660 new file mode 100644 --- /dev/null +++ b/vendor/toml-0.4.5/LICENSE-MIT @@@ -1,0 -1,0 +1,25 @@@ ++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 --cc vendor/toml-0.4.5/README.md index 000000000,000000000..47bb8bb5a new file mode 100644 --- /dev/null +++ b/vendor/toml-0.4.5/README.md @@@ -1,0 -1,0 +1,31 @@@ ++# toml-rs ++ ++[![Build Status](https://travis-ci.org/alexcrichton/toml-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/toml-rs) ++[![Coverage Status](https://coveralls.io/repos/alexcrichton/toml-rs/badge.svg?branch=master&service=github)](https://coveralls.io/github/alexcrichton/toml-rs?branch=master) ++[![Latest Version](https://img.shields.io/crates/v/toml.svg)](https://crates.io/crates/toml) ++[![Documentation](https://docs.rs/toml/badge.svg)](https://docs.rs/toml) ++ ++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.4" ++``` ++ ++This crate also supports serialization/deserialization through the ++[serde](https://serde.rs) crate on crates.io. Currently the older `rustc-serialize` ++crate is not supported in the 0.3+ series of the `toml` crate, but 0.2 can be ++used for that support. ++ ++# 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 --cc vendor/toml-0.4.5/examples/decode.rs index 000000000,000000000..e15da79a6 new file mode 100644 --- /dev/null +++ b/vendor/toml-0.4.5/examples/decode.rs @@@ -1,0 -1,0 +1,56 @@@ ++//! An example showing off the usage of `Deserialize` to automatically decode ++//! TOML into a Rust `struct` ++ ++#![deny(warnings)] ++ ++extern crate toml; ++extern crate serde; ++#[macro_use] ++extern crate serde_derive; ++ ++/// This is what we're going to decode into. Each field is optional, meaning ++/// that it doesn't have to be present in TOML. ++#[derive(Debug, Deserialize)] ++struct Config { ++ global_string: Option, ++ global_integer: Option, ++ server: Option, ++ peers: Option>, ++} ++ ++/// Sub-structs are decoded from tables, so this will decode from the `[server]` ++/// table. ++/// ++/// Again, each field is optional, meaning they don't have to be present. ++#[derive(Debug, Deserialize)] ++struct ServerConfig { ++ ip: Option, ++ port: Option, ++} ++ ++#[derive(Debug, Deserialize)] ++struct PeerConfig { ++ ip: Option, ++ port: Option, ++} ++ ++fn main() { ++ let toml_str = r#" ++ global_string = "test" ++ global_integer = 5 ++ ++ [server] ++ ip = "127.0.0.1" ++ port = 80 ++ ++ [[peers]] ++ ip = "127.0.0.1" ++ port = 8080 ++ ++ [[peers]] ++ ip = "127.0.0.1" ++ "#; ++ ++ let decoded: Config = toml::from_str(toml_str).unwrap(); ++ println!("{:#?}", decoded); ++} diff --cc vendor/toml-0.4.5/examples/toml2json.rs index 000000000,000000000..1ed441a93 new file mode 100644 --- /dev/null +++ b/vendor/toml-0.4.5/examples/toml2json.rs @@@ -1,0 -1,0 +1,51 @@@ ++#![deny(warnings)] ++ ++extern crate toml; ++extern crate serde_json; ++ ++use std::fs::File; ++use std::env; ++use std::io; ++use std::io::prelude::*; ++ ++use toml::Value as Toml; ++use serde_json::Value as Json; ++ ++fn main() { ++ let mut args = env::args(); ++ let mut input = String::new(); ++ if args.len() > 1 { ++ let name = args.nth(1).unwrap(); ++ File::open(&name).and_then(|mut f| { ++ f.read_to_string(&mut input) ++ }).unwrap(); ++ } else { ++ io::stdin().read_to_string(&mut input).unwrap(); ++ } ++ ++ match input.parse() { ++ Ok(toml) => { ++ let json = convert(toml); ++ println!("{}", serde_json::to_string_pretty(&json).unwrap()); ++ } ++ Err(error) => println!("failed to parse TOML: {}", error), ++ } ++} ++ ++fn convert(toml: Toml) -> Json { ++ match toml { ++ Toml::String(s) => Json::String(s), ++ Toml::Integer(i) => Json::Number(i.into()), ++ Toml::Float(f) => { ++ let n = serde_json::Number::from_f64(f) ++ .expect("float infinite and nan not allowed"); ++ Json::Number(n) ++ } ++ Toml::Boolean(b) => Json::Bool(b), ++ Toml::Array(arr) => Json::Array(arr.into_iter().map(convert).collect()), ++ Toml::Table(table) => Json::Object(table.into_iter().map(|(k, v)| { ++ (k, convert(v)) ++ }).collect()), ++ Toml::Datetime(dt) => Json::String(dt.to_string()), ++ } ++} diff --cc vendor/toml-0.4.5/src/datetime.rs index 000000000,000000000..83b5c0bb9 new file mode 100644 --- /dev/null +++ b/vendor/toml-0.4.5/src/datetime.rs @@@ -1,0 -1,0 +1,425 @@@ ++use std::fmt; ++use std::str::{self, FromStr}; ++use std::error; ++ ++use serde::{de, ser}; ++ ++/// A parsed TOML datetime value ++/// ++/// This structure is intended to represent the datetime primitive type that can ++/// be encoded into TOML documents. This type is a parsed version that contains ++/// all metadata internally. ++/// ++/// Currently this type is intentionally conservative and only supports ++/// `to_string` as an accessor. Over time though it's intended that it'll grow ++/// more support! ++/// ++/// Note that if you're using `Deserialize` to deserialize a TOML document, you ++/// can use this as a placeholder for where you're expecting a datetime to be ++/// specified. ++/// ++/// Also note though that while this type implements `Serialize` and ++/// `Deserialize` it's only recommended to use this type with the TOML format, ++/// otherwise encoded in other formats it may look a little odd. ++#[derive(PartialEq, Clone)] ++pub struct Datetime { ++ date: Option, ++ time: Option