This commit is contained in:
Adam Ierymenko 2022-06-08 12:43:13 -04:00
commit 91f801ee72
54 changed files with 39178 additions and 180 deletions

4
.gitignore vendored
View File

@ -62,7 +62,6 @@ zt1-src.tar.gz
*.opensdf
*.user
*.cache
*.obj
*.tlog
*.pid
*.pkg
@ -107,7 +106,6 @@ windows/ZeroTierOne/Debug/
*.swp
*~.nib
DerivedData/
build/
*.pbxuser
*.mode1v3
*.mode2v3
@ -118,7 +116,6 @@ build/
!default.perspectivev3
*.xccheckout
xcuserdata/
ext/librethinkdbxx/build
.vscode
__pycache__
*~
@ -127,7 +124,6 @@ attic/world/mkworld
workspace/
workspace2/
zeroidc/target/
tmp/
#snapcraft specifics
/parts/

4
zeroidc/Cargo.lock generated
View File

@ -1143,9 +1143,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
[[package]]
name = "tracing"
version = "0.1.34"
version = "0.1.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09"
checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160"
dependencies = [
"cfg-if",
"pin-project-lite",

View File

@ -0,0 +1,88 @@
pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&'static str> {
let mut cfgs = vec![];
if let Some(libressl_version) = libressl_version {
cfgs.push("libressl");
if libressl_version >= 0x2_05_01_00_0 {
cfgs.push("libressl251");
}
if libressl_version >= 0x2_05_02_00_0 {
cfgs.push("libressl252");
}
if libressl_version >= 0x2_06_01_00_0 {
cfgs.push("libressl261");
}
if libressl_version >= 0x2_07_00_00_0 {
cfgs.push("libressl270");
}
if libressl_version >= 0x2_07_01_00_0 {
cfgs.push("libressl271");
}
if libressl_version >= 0x2_07_03_00_0 {
cfgs.push("libressl273");
}
if libressl_version >= 0x2_08_00_00_0 {
cfgs.push("libressl280");
}
if libressl_version >= 0x2_08_01_00_0 {
cfgs.push("libressl281");
}
if libressl_version >= 0x2_09_01_00_0 {
cfgs.push("libressl291");
}
if libressl_version >= 0x3_02_01_00_0 {
cfgs.push("libressl321");
}
if libressl_version >= 0x3_03_02_00_0 {
cfgs.push("libressl332");
}
if libressl_version >= 0x3_04_00_00_0 {
cfgs.push("libressl340");
}
if libressl_version >= 0x3_05_00_00_0 {
cfgs.push("libressl350");
}
} else {
let openssl_version = openssl_version.unwrap();
if openssl_version >= 0x3_00_00_00_0 {
cfgs.push("ossl300");
}
if openssl_version >= 0x1_00_01_00_0 {
cfgs.push("ossl101");
}
if openssl_version >= 0x1_00_02_00_0 {
cfgs.push("ossl102");
}
if openssl_version >= 0x1_00_02_06_0 {
cfgs.push("ossl102f");
}
if openssl_version >= 0x1_00_02_08_0 {
cfgs.push("ossl102h");
}
if openssl_version >= 0x1_01_00_00_0 {
cfgs.push("ossl110");
}
if openssl_version >= 0x1_01_00_06_0 {
cfgs.push("ossl110f");
}
if openssl_version >= 0x1_01_00_07_0 {
cfgs.push("ossl110g");
}
if openssl_version >= 0x1_01_00_08_0 {
cfgs.push("ossl110h");
}
if openssl_version >= 0x1_01_01_00_0 {
cfgs.push("ossl111");
}
if openssl_version >= 0x1_01_01_02_0 {
cfgs.push("ossl111b");
}
if openssl_version >= 0x1_01_01_03_0 {
cfgs.push("ossl111c");
}
}
cfgs
}

View File

@ -0,0 +1,104 @@
#include <openssl/opensslv.h>
#include <openssl/opensslconf.h>
#define VERSION2(n, v) RUST_VERSION_##n##_##v
#define VERSION(n, v) VERSION2(n, v)
#define NEW_VERSION2(a, b, c) RUST_VERSION_NEW_OPENSSL_##a##_##b##_##c
#define NEW_VERSION(a, b, c) NEW_VERSION2(a, b, c)
#ifdef LIBRESSL_VERSION_NUMBER
VERSION(LIBRESSL, LIBRESSL_VERSION_NUMBER)
#elif defined OPENSSL_VERSION_MAJOR
NEW_VERSION(OPENSSL_VERSION_MAJOR, OPENSSL_VERSION_MINOR, OPENSSL_VERSION_PATCH)
#else
VERSION(OPENSSL, OPENSSL_VERSION_NUMBER)
#endif
#ifdef OPENSSL_NO_BF
RUST_CONF_OPENSSL_NO_BF
#endif
#ifdef OPENSSL_NO_BUF_FREELISTS
RUST_CONF_OPENSSL_NO_BUF_FREELISTS
#endif
#ifdef OPENSSL_NO_CHACHA
RUST_CONF_OPENSSL_NO_CHACHA
#endif
#ifdef OPENSSL_NO_CMS
RUST_CONF_OPENSSL_NO_CMS
#endif
#ifdef OPENSSL_NO_COMP
RUST_CONF_OPENSSL_NO_COMP
#endif
#ifdef OPENSSL_NO_EC
RUST_CONF_OPENSSL_NO_EC
#endif
#ifdef OPENSSL_NO_EC2M
RUST_CONF_OPENSSL_NO_EC2M
#endif
#ifdef OPENSSL_NO_ENGINE
RUST_CONF_OPENSSL_NO_ENGINE
#endif
#ifdef OPENSSL_NO_KRB5
RUST_CONF_OPENSSL_NO_KRB5
#endif
#ifdef OPENSSL_NO_NEXTPROTONEG
RUST_CONF_OPENSSL_NO_NEXTPROTONEG
#endif
#ifdef OPENSSL_NO_OCSP
RUST_CONF_OPENSSL_NO_OCSP
#endif
#ifdef OPENSSL_NO_PSK
RUST_CONF_OPENSSL_NO_PSK
#endif
#ifdef OPENSSL_NO_RFC3779
RUST_CONF_OPENSSL_NO_RFC3779
#endif
#ifdef OPENSSL_NO_RMD160
RUST_CONF_OPENSSL_NO_RMD160
#endif
#ifdef OPENSSL_NO_SHA
RUST_CONF_OPENSSL_NO_SHA
#endif
#ifdef OPENSSL_NO_SRP
RUST_CONF_OPENSSL_NO_SRP
#endif
#ifdef OPENSSL_NO_SSL3_METHOD
RUST_CONF_OPENSSL_NO_SSL3_METHOD
#endif
#ifdef OPENSSL_NO_TLSEXT
RUST_CONF_OPENSSL_NO_TLSEXT
#endif
#ifdef OPENSSL_NO_STDIO
RUST_CONF_OPENSSL_NO_STDIO
#endif
#ifdef OPENSSL_NO_SM3
RUST_CONF_OPENSSL_NO_SM3
#endif
#ifdef OPENSSL_NO_DEPRECATED_3_0
RUST_CONF_OPENSSL_NO_DEPRECATED_3_0
#endif
#ifdef OPENSSL_NO_SEED
RUST_CONF_OPENSSL_NO_SEED
#endif

View File

@ -0,0 +1,276 @@
use pkg_config;
use std::ffi::OsString;
use std::path::{Path, PathBuf};
use std::process::{self, Command};
use super::env;
pub fn get_openssl(target: &str) -> (Vec<PathBuf>, PathBuf) {
let lib_dir = env("OPENSSL_LIB_DIR").map(PathBuf::from);
let include_dir = env("OPENSSL_INCLUDE_DIR").map(PathBuf::from);
match (lib_dir, include_dir) {
(Some(lib_dir), Some(include_dir)) => (vec![lib_dir], include_dir),
(lib_dir, include_dir) => {
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.map(|d| vec![d]).unwrap_or_else(|| {
let mut lib_dirs = vec![];
// OpenSSL 3.0 now puts it's libraries in lib64/ by default,
// check for both it and lib/.
if openssl_dir.join("lib64").exists() {
lib_dirs.push(openssl_dir.join("lib64"));
}
if openssl_dir.join("lib").exists() {
lib_dirs.push(openssl_dir.join("lib"));
}
lib_dirs
});
let include_dir = include_dir.unwrap_or_else(|| openssl_dir.join("include"));
(lib_dir, include_dir)
}
}
}
fn resolve_with_wellknown_homebrew_location(dir: &str) -> Option<PathBuf> {
let versions = ["openssl@3", "openssl@1.1"];
// Check up default aarch 64 Homebrew installation location first
// for quick resolution if possible.
// `pkg-config` on brew doesn't necessarily contain settings for openssl apparently.
for version in &versions {
let homebrew = Path::new(dir).join(format!("opt/{}", version));
if homebrew.exists() {
return Some(homebrew);
}
}
for version in &versions {
// Calling `brew --prefix <package>` command usually slow and
// takes seconds, and will be used only as a last resort.
let output = execute_command_and_get_output("brew", &["--prefix", version]);
if let Some(ref output) = output {
let homebrew = Path::new(&output);
if homebrew.exists() {
return Some(homebrew.to_path_buf());
}
}
}
None
}
fn resolve_with_wellknown_location(dir: &str) -> Option<PathBuf> {
let root_dir = Path::new(dir);
let include_openssl = root_dir.join("include/openssl");
if include_openssl.exists() {
Some(root_dir.to_path_buf())
} else {
None
}
}
fn find_openssl_dir(target: &str) -> OsString {
let host = env::var("HOST").unwrap();
if host == target && target.ends_with("-apple-darwin") {
let homebrew_dir = match target {
"aarch64-apple-darwin" => "/opt/homebrew",
_ => "/usr/local",
};
if let Some(dir) = resolve_with_wellknown_homebrew_location(homebrew_dir) {
return dir.into();
} else if let Some(dir) = resolve_with_wellknown_location("/opt/pkg") {
// pkgsrc
return dir.into();
} else if let Some(dir) = resolve_with_wellknown_location("/opt/local") {
// MacPorts
return dir.into();
}
}
try_pkg_config();
try_vcpkg();
// FreeBSD ships with OpenSSL but doesn't include a pkg-config file :(
if host == target && target.contains("freebsd") {
return OsString::from("/usr");
}
// DragonFly has libressl (or openssl) in ports, but this doesn't include a pkg-config file
if host == target && target.contains("dragonfly") {
return OsString::from("/usr/local");
}
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.
Make sure you also have the development packages of openssl installed.
For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
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(
"
openssl-sys crate build failed: no supported version of OpenSSL found.
Ways to fix it:
- Use the `vendored` feature of openssl-sys crate to build OpenSSL from source.
- Use Homebrew to install the `openssl` package.
",
);
}
}
if host.contains("unknown-linux")
&& target.contains("unknown-linux-gnu")
&& Command::new("pkg-config").output().is_err()
{
msg.push_str(
"
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(
"
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(
"
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;
}
};
super::postprocess(&lib.include_paths);
for include in lib.include_paths.iter() {
println!("cargo:include={}", include.display());
}
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 lib = match vcpkg::Config::new()
.emit_includes(true)
.find_package("openssl")
{
Ok(lib) => lib,
Err(e) => {
println!("note: vcpkg did not find openssl: {}", e);
return;
}
};
super::postprocess(&lib.include_paths);
println!("cargo:rustc-link-lib=user32");
println!("cargo:rustc-link-lib=gdi32");
println!("cargo:rustc-link-lib=crypt32");
process::exit(0);
}
#[cfg(not(target_env = "msvc"))]
fn try_vcpkg() {}
fn execute_command_and_get_output(cmd: &str, args: &[&str]) -> Option<String> {
let out = Command::new(cmd).args(args).output();
if let Ok(ref r1) = out {
if r1.status.success() {
let r2 = String::from_utf8(r1.stdout.clone());
if let Ok(r3) = r2 {
return Some(r3.trim().to_string());
}
}
}
None
}

View File

@ -0,0 +1,16 @@
use openssl_src;
use std::path::PathBuf;
pub fn get_openssl(_target: &str) -> (Vec<PathBuf>, PathBuf) {
let artifacts = openssl_src::Build::new().build();
println!("cargo:vendored=1");
println!(
"cargo:root={}",
artifacts.lib_dir().parent().unwrap().display()
);
(
vec![artifacts.lib_dir().to_path_buf()],
artifacts.include_dir().to_path_buf(),
)
}

399
zeroidc/vendor/openssl-sys/build/main.rs vendored Normal file
View File

@ -0,0 +1,399 @@
#![allow(clippy::inconsistent_digit_grouping, clippy::unusual_byte_groupings)]
extern crate autocfg;
#[cfg(feature = "bindgen")]
extern crate bindgen;
extern crate cc;
#[cfg(feature = "vendored")]
extern crate openssl_src;
extern crate pkg_config;
#[cfg(target_env = "msvc")]
extern crate vcpkg;
use std::collections::HashSet;
use std::env;
use std::ffi::OsString;
use std::path::{Path, PathBuf};
mod cfgs;
mod find_normal;
#[cfg(feature = "vendored")]
mod find_vendored;
#[cfg(feature = "bindgen")]
mod run_bindgen;
#[derive(PartialEq)]
enum Version {
Openssl3xx,
Openssl11x,
Openssl10x,
Libressl,
}
fn env_inner(name: &str) -> Option<OsString> {
let var = env::var_os(name);
println!("cargo:rerun-if-env-changed={}", name);
match var {
Some(ref v) => println!("{} = {}", name, v.to_string_lossy()),
None => println!("{} unset", name),
}
var
}
fn env(name: &str) -> Option<OsString> {
let prefix = env::var("TARGET").unwrap().to_uppercase().replace('-', "_");
let prefixed = format!("{}_{}", prefix, name);
env_inner(&prefixed).or_else(|| env_inner(name))
}
fn find_openssl(target: &str) -> (Vec<PathBuf>, PathBuf) {
#[cfg(feature = "vendored")]
{
// vendor if the feature is present, unless
// OPENSSL_NO_VENDOR exists and isn't `0`
if env("OPENSSL_NO_VENDOR").map_or(true, |s| s == "0") {
return find_vendored::get_openssl(target);
}
}
find_normal::get_openssl(target)
}
fn main() {
check_rustc_versions();
let target = env::var("TARGET").unwrap();
let (lib_dirs, include_dir) = find_openssl(&target);
if !lib_dirs.iter().all(|p| Path::new(p).exists()) {
panic!("OpenSSL library directory does not exist: {:?}", lib_dirs);
}
if !Path::new(&include_dir).exists() {
panic!(
"OpenSSL include directory does not exist: {}",
include_dir.to_string_lossy()
);
}
for lib_dir in lib_dirs.iter() {
println!(
"cargo:rustc-link-search=native={}",
lib_dir.to_string_lossy()
);
}
println!("cargo:include={}", include_dir.to_string_lossy());
let version = postprocess(&[include_dir]);
let libs_env = env("OPENSSL_LIBS");
let libs = match libs_env.as_ref().and_then(|s| s.to_str()) {
Some(v) => {
if v.is_empty() {
vec![]
} else {
v.split(':').collect()
}
}
None => match version {
Version::Openssl10x if target.contains("windows") => vec!["ssleay32", "libeay32"],
Version::Openssl3xx | Version::Openssl11x if target.contains("windows-msvc") => {
vec!["libssl", "libcrypto"]
}
_ => vec!["ssl", "crypto"],
},
};
let kind = determine_mode(&lib_dirs, &libs);
for lib in libs.into_iter() {
println!("cargo:rustc-link-lib={}={}", kind, lib);
}
// https://github.com/openssl/openssl/pull/15086
if version == Version::Openssl3xx
&& kind == "static"
&& (env::var("CARGO_CFG_TARGET_OS").unwrap() == "linux"
|| env::var("CARGO_CFG_TARGET_OS").unwrap() == "android")
&& env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
{
println!("cargo:rustc-link-lib=dylib=atomic");
}
if kind == "static" && target.contains("windows") {
println!("cargo:rustc-link-lib=dylib=gdi32");
println!("cargo:rustc-link-lib=dylib=user32");
println!("cargo:rustc-link-lib=dylib=crypt32");
println!("cargo:rustc-link-lib=dylib=ws2_32");
println!("cargo:rustc-link-lib=dylib=advapi32");
}
}
fn check_rustc_versions() {
let cfg = autocfg::new();
if cfg.probe_rustc_version(1, 31) {
println!("cargo:rustc-cfg=const_fn");
}
}
#[allow(clippy::let_and_return)]
fn postprocess(include_dirs: &[PathBuf]) -> Version {
let version = validate_headers(include_dirs);
#[cfg(feature = "bindgen")]
run_bindgen::run(&include_dirs);
version
}
/// Validates the header files found in `include_dir` and then returns the
/// version string of OpenSSL.
#[allow(clippy::manual_strip)] // we need to support pre-1.45.0
fn validate_headers(include_dirs: &[PathBuf]) -> Version {
// This `*-sys` crate only works with OpenSSL 1.0.1, 1.0.2, 1.1.0, 1.1.1 and 3.0.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.
println!("cargo:rerun-if-changed=build/expando.c");
let mut gcc = cc::Build::new();
for include_dir in include_dirs {
gcc.include(include_dir);
}
let expanded = match gcc.file("build/expando.c").try_expand() {
Ok(expanded) => expanded,
Err(e) => {
panic!(
"
Header expansion error:
{:?}
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
# On Alpine Linux
apk add openssl-dev
See rust-openssl README for more information:
https://github.com/sfackler/rust-openssl#linux
",
e
);
}
};
let expanded = String::from_utf8(expanded).unwrap();
let mut enabled = vec![];
let mut openssl_version = None;
let mut libressl_version = None;
for line in expanded.lines() {
let line = line.trim();
let openssl_prefix = "RUST_VERSION_OPENSSL_";
let new_openssl_prefix = "RUST_VERSION_NEW_OPENSSL_";
let libressl_prefix = "RUST_VERSION_LIBRESSL_";
let conf_prefix = "RUST_CONF_";
if line.starts_with(openssl_prefix) {
let version = &line[openssl_prefix.len()..];
openssl_version = Some(parse_version(version));
} else if line.starts_with(new_openssl_prefix) {
let version = &line[new_openssl_prefix.len()..];
openssl_version = Some(parse_new_version(version));
} else if line.starts_with(libressl_prefix) {
let version = &line[libressl_prefix.len()..];
libressl_version = Some(parse_version(version));
} else if line.starts_with(conf_prefix) {
enabled.push(&line[conf_prefix.len()..]);
}
}
for enabled in &enabled {
println!("cargo:rustc-cfg=osslconf=\"{}\"", enabled);
}
println!("cargo:conf={}", enabled.join(","));
for cfg in cfgs::get(openssl_version, libressl_version) {
println!("cargo:rustc-cfg={}", cfg);
}
if let Some(libressl_version) = libressl_version {
println!("cargo:libressl_version_number={:x}", libressl_version);
let major = (libressl_version >> 28) as u8;
let minor = (libressl_version >> 20) as u8;
let fix = (libressl_version >> 12) as u8;
let (major, minor, fix) = match (major, minor, fix) {
(2, 5, 0) => ('2', '5', '0'),
(2, 5, 1) => ('2', '5', '1'),
(2, 5, 2) => ('2', '5', '2'),
(2, 5, _) => ('2', '5', 'x'),
(2, 6, 0) => ('2', '6', '0'),
(2, 6, 1) => ('2', '6', '1'),
(2, 6, 2) => ('2', '6', '2'),
(2, 6, _) => ('2', '6', 'x'),
(2, 7, _) => ('2', '7', 'x'),
(2, 8, 0) => ('2', '8', '0'),
(2, 8, 1) => ('2', '8', '1'),
(2, 8, _) => ('2', '8', 'x'),
(2, 9, 0) => ('2', '9', '0'),
(2, 9, _) => ('2', '9', 'x'),
(3, 0, 0) => ('3', '0', '0'),
(3, 0, 1) => ('3', '0', '1'),
(3, 0, _) => ('3', '0', 'x'),
(3, 1, 0) => ('3', '1', '0'),
(3, 1, _) => ('3', '1', 'x'),
(3, 2, 0) => ('3', '2', '0'),
(3, 2, 1) => ('3', '2', '1'),
(3, 2, _) => ('3', '2', 'x'),
(3, 3, 0) => ('3', '3', '0'),
(3, 3, 1) => ('3', '3', '1'),
(3, 3, _) => ('3', '3', 'x'),
(3, 4, 0) => ('3', '4', '0'),
(3, 4, _) => ('3', '4', 'x'),
(3, 5, _) => ('3', '5', 'x'),
_ => version_error(),
};
println!("cargo:libressl=true");
println!("cargo:libressl_version={}{}{}", major, minor, fix);
println!("cargo:version=101");
Version::Libressl
} else {
let openssl_version = openssl_version.unwrap();
println!("cargo:version_number={:x}", openssl_version);
if openssl_version >= 0x4_00_00_00_0 {
version_error()
} else if openssl_version >= 0x3_00_00_00_0 {
Version::Openssl3xx
} else if openssl_version >= 0x1_01_01_00_0 {
println!("cargo:version=111");
Version::Openssl11x
} else if openssl_version >= 0x1_01_00_06_0 {
println!("cargo:version=110");
println!("cargo:patch=f");
Version::Openssl11x
} else if openssl_version >= 0x1_01_00_00_0 {
println!("cargo:version=110");
Version::Openssl11x
} else if openssl_version >= 0x1_00_02_00_0 {
println!("cargo:version=102");
Version::Openssl10x
} else if openssl_version >= 0x1_00_01_00_0 {
println!("cargo:version=101");
Version::Openssl10x
} else {
version_error()
}
}
}
fn version_error() -> ! {
panic!(
"
This crate is only compatible with OpenSSL (version 1.0.1 through 1.1.1, or 3.0.0), or LibreSSL 2.5
through 3.5, but a different version of OpenSSL was found. The build is now aborting
due to this version mismatch.
"
);
}
// parses a string that looks like "0x100020cfL"
#[allow(deprecated)] // trim_right_matches is now trim_end_matches
#[allow(clippy::match_like_matches_macro)] // matches macro requires rust 1.42.0
fn parse_version(version: &str) -> u64 {
// cut off the 0x prefix
assert!(version.starts_with("0x"));
let version = &version[2..];
// and the type specifier suffix
let version = version.trim_right_matches(|c: char| match c {
'0'..='9' | 'a'..='f' | 'A'..='F' => false,
_ => true,
});
u64::from_str_radix(version, 16).unwrap()
}
// parses a string that looks like 3_0_0
fn parse_new_version(version: &str) -> u64 {
println!("version: {}", version);
let mut it = version.split('_');
let major = it.next().unwrap().parse::<u64>().unwrap();
let minor = it.next().unwrap().parse::<u64>().unwrap();
let patch = it.next().unwrap().parse::<u64>().unwrap();
(major << 28) | (minor << 20) | (patch << 4)
}
/// 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(libdirs: &[PathBuf], 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()) {
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 mut files = HashSet::new();
for dir in libdirs {
for path in dir
.read_dir()
.unwrap()
.map(|e| e.unwrap())
.map(|e| e.file_name())
.filter_map(|e| e.into_string().ok())
{
files.insert(path);
}
}
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",
libdirs
);
}
(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"
}

View File

@ -0,0 +1,129 @@
use bindgen::callbacks::{MacroParsingBehavior, ParseCallbacks};
use bindgen::RustTarget;
use std::env;
use std::path::PathBuf;
const INCLUDES: &str = "
#include <openssl/aes.h>
#include <openssl/asn1.h>
#include <openssl/bio.h>
#include <openssl/comp.h>
#include <openssl/conf.h>
#include <openssl/crypto.h>
#include <openssl/dh.h>
#include <openssl/dsa.h>
#include <openssl/ec.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/hmac.h>
#include <openssl/objects.h>
#include <openssl/ocsp.h>
#include <openssl/opensslv.h>
#include <openssl/pem.h>
#include <openssl/pkcs12.h>
#include <openssl/pkcs7.h>
#include <openssl/rand.h>
#include <openssl/rsa.h>
#include <openssl/safestack.h>
#include <openssl/sha.h>
#include <openssl/ssl.h>
#include <openssl/stack.h>
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include <openssl/x509v3.h>
// this must be included after ssl.h for libressl!
#include <openssl/srtp.h>
#if !defined(LIBRESSL_VERSION_NUMBER)
#include <openssl/cms.h>
#endif
#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
#include <openssl/kdf.h>
#endif
#if OPENSSL_VERSION_NUMBER >= 0x30000000
#include <openssl/provider.h>
#endif
";
pub fn run(include_dirs: &[PathBuf]) {
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let mut builder = bindgen::builder()
.parse_callbacks(Box::new(OpensslCallbacks))
.rust_target(RustTarget::Stable_1_47)
.ctypes_prefix("::libc")
.raw_line("use libc::*;")
.raw_line("type evp_pkey_st = EVP_PKEY;")
.allowlist_file(".*/openssl/[^/]+\\.h")
.allowlist_recursively(false)
// libc is missing pthread_once_t on macOS
.blocklist_type("CRYPTO_ONCE")
.blocklist_function("CRYPTO_THREAD_run_once")
// we don't want to mess with va_list
.blocklist_function("BIO_vprintf")
.blocklist_function("BIO_vsnprintf")
.blocklist_function("ERR_vset_error")
.blocklist_function("ERR_add_error_vdata")
.blocklist_function("EVP_KDF_vctrl")
.blocklist_type("OSSL_FUNC_core_vset_error_fn")
.blocklist_type("OSSL_FUNC_BIO_vprintf_fn")
.blocklist_type("OSSL_FUNC_BIO_vsnprintf_fn")
// Maintain compatibility for existing enum definitions
.rustified_enum("point_conversion_form_t")
// Maintain compatibility for pre-union definitions
.blocklist_type("GENERAL_NAME")
.blocklist_type("GENERAL_NAME_st")
.blocklist_type("EVP_PKEY")
.blocklist_type("evp_pkey_st")
.layout_tests(false)
.header_contents("includes.h", INCLUDES);
for include_dir in include_dirs {
builder = builder
.clang_arg("-I")
.clang_arg(include_dir.display().to_string());
}
builder
.generate()
.unwrap()
.write_to_file(out_dir.join("bindgen.rs"))
.unwrap();
}
#[derive(Debug)]
struct OpensslCallbacks;
impl ParseCallbacks for OpensslCallbacks {
// for now we'll continue hand-writing constants
fn will_parse_macro(&self, _name: &str) -> MacroParsingBehavior {
MacroParsingBehavior::Ignore
}
fn item_name(&self, original_item_name: &str) -> Option<String> {
match original_item_name {
// Our original definitions of these are wrong, so rename to avoid breakage
"CRYPTO_EX_new"
| "CRYPTO_EX_dup"
| "CRYPTO_EX_free"
| "BIO_meth_set_write"
| "BIO_meth_set_read"
| "BIO_meth_set_puts"
| "BIO_meth_set_ctrl"
| "BIO_meth_set_create"
| "BIO_meth_set_destroy"
| "CRYPTO_set_locking_callback"
| "CRYPTO_set_id_callback"
| "SSL_CTX_set_tmp_dh_callback"
| "SSL_set_tmp_dh_callback"
| "SSL_CTX_set_tmp_ecdh_callback"
| "SSL_set_tmp_ecdh_callback"
| "SSL_CTX_callback_ctrl"
| "SSL_CTX_set_alpn_select_cb" => Some(format!("{}__fixed_rust", original_item_name)),
_ => None,
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,682 @@
; This file is generated from a similarly-named Perl script in the BoringSSL
; source tree. Do not edit by hand.
%ifdef BORINGSSL_PREFIX
%include "boringssl_prefix_symbols_nasm.inc"
%endif
%ifidn __OUTPUT_FORMAT__,obj
section code use32 class=code align=64
%elifidn __OUTPUT_FORMAT__,win32
$@feat.00 equ 1
section .text code align=64
%else
section .text code
%endif
;extern _GFp_ia32cap_P
global _GFp_aes_hw_encrypt
align 16
_GFp_aes_hw_encrypt:
L$_GFp_aes_hw_encrypt_begin:
mov eax,DWORD [4+esp]
mov edx,DWORD [12+esp]
movups xmm2,[eax]
mov ecx,DWORD [240+edx]
mov eax,DWORD [8+esp]
movups xmm0,[edx]
movups xmm1,[16+edx]
lea edx,[32+edx]
xorps xmm2,xmm0
L$000enc1_loop_1:
db 102,15,56,220,209
dec ecx
movups xmm1,[edx]
lea edx,[16+edx]
jnz NEAR L$000enc1_loop_1
db 102,15,56,221,209
pxor xmm0,xmm0
pxor xmm1,xmm1
movups [eax],xmm2
pxor xmm2,xmm2
ret
align 16
__aesni_encrypt2:
movups xmm0,[edx]
shl ecx,4
movups xmm1,[16+edx]
xorps xmm2,xmm0
pxor xmm3,xmm0
movups xmm0,[32+edx]
lea edx,[32+ecx*1+edx]
neg ecx
add ecx,16
L$001enc2_loop:
db 102,15,56,220,209
db 102,15,56,220,217
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,220,208
db 102,15,56,220,216
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$001enc2_loop
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,221,208
db 102,15,56,221,216
ret
align 16
__aesni_encrypt3:
movups xmm0,[edx]
shl ecx,4
movups xmm1,[16+edx]
xorps xmm2,xmm0
pxor xmm3,xmm0
pxor xmm4,xmm0
movups xmm0,[32+edx]
lea edx,[32+ecx*1+edx]
neg ecx
add ecx,16
L$002enc3_loop:
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,220,208
db 102,15,56,220,216
db 102,15,56,220,224
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$002enc3_loop
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
db 102,15,56,221,208
db 102,15,56,221,216
db 102,15,56,221,224
ret
align 16
__aesni_encrypt4:
movups xmm0,[edx]
movups xmm1,[16+edx]
shl ecx,4
xorps xmm2,xmm0
pxor xmm3,xmm0
pxor xmm4,xmm0
pxor xmm5,xmm0
movups xmm0,[32+edx]
lea edx,[32+ecx*1+edx]
neg ecx
db 15,31,64,0
add ecx,16
L$003enc4_loop:
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
db 102,15,56,220,233
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,220,208
db 102,15,56,220,216
db 102,15,56,220,224
db 102,15,56,220,232
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$003enc4_loop
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
db 102,15,56,220,233
db 102,15,56,221,208
db 102,15,56,221,216
db 102,15,56,221,224
db 102,15,56,221,232
ret
align 16
__aesni_encrypt6:
movups xmm0,[edx]
shl ecx,4
movups xmm1,[16+edx]
xorps xmm2,xmm0
pxor xmm3,xmm0
pxor xmm4,xmm0
db 102,15,56,220,209
pxor xmm5,xmm0
pxor xmm6,xmm0
db 102,15,56,220,217
lea edx,[32+ecx*1+edx]
neg ecx
db 102,15,56,220,225
pxor xmm7,xmm0
movups xmm0,[ecx*1+edx]
add ecx,16
jmp NEAR L$004_aesni_encrypt6_inner
align 16
L$005enc6_loop:
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
L$004_aesni_encrypt6_inner:
db 102,15,56,220,233
db 102,15,56,220,241
db 102,15,56,220,249
L$_aesni_encrypt6_enter:
movups xmm1,[ecx*1+edx]
add ecx,32
db 102,15,56,220,208
db 102,15,56,220,216
db 102,15,56,220,224
db 102,15,56,220,232
db 102,15,56,220,240
db 102,15,56,220,248
movups xmm0,[ecx*1+edx-16]
jnz NEAR L$005enc6_loop
db 102,15,56,220,209
db 102,15,56,220,217
db 102,15,56,220,225
db 102,15,56,220,233
db 102,15,56,220,241
db 102,15,56,220,249
db 102,15,56,221,208
db 102,15,56,221,216
db 102,15,56,221,224
db 102,15,56,221,232
db 102,15,56,221,240
db 102,15,56,221,248
ret
global _GFp_aes_hw_ctr32_encrypt_blocks
align 16
_GFp_aes_hw_ctr32_encrypt_blocks:
L$_GFp_aes_hw_ctr32_encrypt_blocks_begin:
push ebp
push ebx
push esi
push edi
mov esi,DWORD [20+esp]
mov edi,DWORD [24+esp]
mov eax,DWORD [28+esp]
mov edx,DWORD [32+esp]
mov ebx,DWORD [36+esp]
mov ebp,esp
sub esp,88
and esp,-16
mov DWORD [80+esp],ebp
cmp eax,1
je NEAR L$006ctr32_one_shortcut
movdqu xmm7,[ebx]
mov DWORD [esp],202182159
mov DWORD [4+esp],134810123
mov DWORD [8+esp],67438087
mov DWORD [12+esp],66051
mov ecx,6
xor ebp,ebp
mov DWORD [16+esp],ecx
mov DWORD [20+esp],ecx
mov DWORD [24+esp],ecx
mov DWORD [28+esp],ebp
db 102,15,58,22,251,3
db 102,15,58,34,253,3
mov ecx,DWORD [240+edx]
bswap ebx
pxor xmm0,xmm0
pxor xmm1,xmm1
movdqa xmm2,[esp]
db 102,15,58,34,195,0
lea ebp,[3+ebx]
db 102,15,58,34,205,0
inc ebx
db 102,15,58,34,195,1
inc ebp
db 102,15,58,34,205,1
inc ebx
db 102,15,58,34,195,2
inc ebp
db 102,15,58,34,205,2
movdqa [48+esp],xmm0
db 102,15,56,0,194
movdqu xmm6,[edx]
movdqa [64+esp],xmm1
db 102,15,56,0,202
pshufd xmm2,xmm0,192
pshufd xmm3,xmm0,128
cmp eax,6
jb NEAR L$007ctr32_tail
pxor xmm7,xmm6
shl ecx,4
mov ebx,16
movdqa [32+esp],xmm7
mov ebp,edx
sub ebx,ecx
lea edx,[32+ecx*1+edx]
sub eax,6
jmp NEAR L$008ctr32_loop6
align 16
L$008ctr32_loop6:
pshufd xmm4,xmm0,64
movdqa xmm0,[32+esp]
pshufd xmm5,xmm1,192
pxor xmm2,xmm0
pshufd xmm6,xmm1,128
pxor xmm3,xmm0
pshufd xmm7,xmm1,64
movups xmm1,[16+ebp]
pxor xmm4,xmm0
pxor xmm5,xmm0
db 102,15,56,220,209
pxor xmm6,xmm0
pxor xmm7,xmm0
db 102,15,56,220,217
movups xmm0,[32+ebp]
mov ecx,ebx
db 102,15,56,220,225
db 102,15,56,220,233
db 102,15,56,220,241
db 102,15,56,220,249
call L$_aesni_encrypt6_enter
movups xmm1,[esi]
movups xmm0,[16+esi]
xorps xmm2,xmm1
movups xmm1,[32+esi]
xorps xmm3,xmm0
movups [edi],xmm2
movdqa xmm0,[16+esp]
xorps xmm4,xmm1
movdqa xmm1,[64+esp]
movups [16+edi],xmm3
movups [32+edi],xmm4
paddd xmm1,xmm0
paddd xmm0,[48+esp]
movdqa xmm2,[esp]
movups xmm3,[48+esi]
movups xmm4,[64+esi]
xorps xmm5,xmm3
movups xmm3,[80+esi]
lea esi,[96+esi]
movdqa [48+esp],xmm0
db 102,15,56,0,194
xorps xmm6,xmm4
movups [48+edi],xmm5
xorps xmm7,xmm3
movdqa [64+esp],xmm1
db 102,15,56,0,202
movups [64+edi],xmm6
pshufd xmm2,xmm0,192
movups [80+edi],xmm7
lea edi,[96+edi]
pshufd xmm3,xmm0,128
sub eax,6
jnc NEAR L$008ctr32_loop6
add eax,6
jz NEAR L$009ctr32_ret
movdqu xmm7,[ebp]
mov edx,ebp
pxor xmm7,[32+esp]
mov ecx,DWORD [240+ebp]
L$007ctr32_tail:
por xmm2,xmm7
cmp eax,2
jb NEAR L$010ctr32_one
pshufd xmm4,xmm0,64
por xmm3,xmm7
je NEAR L$011ctr32_two
pshufd xmm5,xmm1,192
por xmm4,xmm7
cmp eax,4
jb NEAR L$012ctr32_three
pshufd xmm6,xmm1,128
por xmm5,xmm7
je NEAR L$013ctr32_four
por xmm6,xmm7
call __aesni_encrypt6
movups xmm1,[esi]
movups xmm0,[16+esi]
xorps xmm2,xmm1
movups xmm1,[32+esi]
xorps xmm3,xmm0
movups xmm0,[48+esi]
xorps xmm4,xmm1
movups xmm1,[64+esi]
xorps xmm5,xmm0
movups [edi],xmm2
xorps xmm6,xmm1
movups [16+edi],xmm3
movups [32+edi],xmm4
movups [48+edi],xmm5
movups [64+edi],xmm6
jmp NEAR L$009ctr32_ret
align 16
L$006ctr32_one_shortcut:
movups xmm2,[ebx]
mov ecx,DWORD [240+edx]
L$010ctr32_one:
movups xmm0,[edx]
movups xmm1,[16+edx]
lea edx,[32+edx]
xorps xmm2,xmm0
L$014enc1_loop_2:
db 102,15,56,220,209
dec ecx
movups xmm1,[edx]
lea edx,[16+edx]
jnz NEAR L$014enc1_loop_2
db 102,15,56,221,209
movups xmm6,[esi]
xorps xmm6,xmm2
movups [edi],xmm6
jmp NEAR L$009ctr32_ret
align 16
L$011ctr32_two:
call __aesni_encrypt2
movups xmm5,[esi]
movups xmm6,[16+esi]
xorps xmm2,xmm5
xorps xmm3,xmm6
movups [edi],xmm2
movups [16+edi],xmm3
jmp NEAR L$009ctr32_ret
align 16
L$012ctr32_three:
call __aesni_encrypt3
movups xmm5,[esi]
movups xmm6,[16+esi]
xorps xmm2,xmm5
movups xmm7,[32+esi]
xorps xmm3,xmm6
movups [edi],xmm2
xorps xmm4,xmm7
movups [16+edi],xmm3
movups [32+edi],xmm4
jmp NEAR L$009ctr32_ret
align 16
L$013ctr32_four:
call __aesni_encrypt4
movups xmm6,[esi]
movups xmm7,[16+esi]
movups xmm1,[32+esi]
xorps xmm2,xmm6
movups xmm0,[48+esi]
xorps xmm3,xmm7
movups [edi],xmm2
xorps xmm4,xmm1
movups [16+edi],xmm3
xorps xmm5,xmm0
movups [32+edi],xmm4
movups [48+edi],xmm5
L$009ctr32_ret:
pxor xmm0,xmm0
pxor xmm1,xmm1
pxor xmm2,xmm2
pxor xmm3,xmm3
pxor xmm4,xmm4
movdqa [32+esp],xmm0
pxor xmm5,xmm5
movdqa [48+esp],xmm0
pxor xmm6,xmm6
movdqa [64+esp],xmm0
pxor xmm7,xmm7
mov esp,DWORD [80+esp]
pop edi
pop esi
pop ebx
pop ebp
ret
align 16
__aesni_set_encrypt_key:
push ebp
push ebx
test eax,eax
jz NEAR L$015bad_pointer
test edx,edx
jz NEAR L$015bad_pointer
call L$016pic
L$016pic:
pop ebx
lea ebx,[(L$key_const-L$016pic)+ebx]
lea ebp,[_GFp_ia32cap_P]
movups xmm0,[eax]
xorps xmm4,xmm4
mov ebp,DWORD [4+ebp]
lea edx,[16+edx]
and ebp,268437504
cmp ecx,256
je NEAR L$01714rounds
cmp ecx,128
jne NEAR L$018bad_keybits
align 16
L$01910rounds:
cmp ebp,268435456
je NEAR L$02010rounds_alt
mov ecx,9
movups [edx-16],xmm0
db 102,15,58,223,200,1
call L$021key_128_cold
db 102,15,58,223,200,2
call L$022key_128
db 102,15,58,223,200,4
call L$022key_128
db 102,15,58,223,200,8
call L$022key_128
db 102,15,58,223,200,16
call L$022key_128
db 102,15,58,223,200,32
call L$022key_128
db 102,15,58,223,200,64
call L$022key_128
db 102,15,58,223,200,128
call L$022key_128
db 102,15,58,223,200,27
call L$022key_128
db 102,15,58,223,200,54
call L$022key_128
movups [edx],xmm0
mov DWORD [80+edx],ecx
jmp NEAR L$023good_key
align 16
L$022key_128:
movups [edx],xmm0
lea edx,[16+edx]
L$021key_128_cold:
shufps xmm4,xmm0,16
xorps xmm0,xmm4
shufps xmm4,xmm0,140
xorps xmm0,xmm4
shufps xmm1,xmm1,255
xorps xmm0,xmm1
ret
align 16
L$02010rounds_alt:
movdqa xmm5,[ebx]
mov ecx,8
movdqa xmm4,[32+ebx]
movdqa xmm2,xmm0
movdqu [edx-16],xmm0
L$024loop_key128:
db 102,15,56,0,197
db 102,15,56,221,196
pslld xmm4,1
lea edx,[16+edx]
movdqa xmm3,xmm2
pslldq xmm2,4
pxor xmm3,xmm2
pslldq xmm2,4
pxor xmm3,xmm2
pslldq xmm2,4
pxor xmm2,xmm3
pxor xmm0,xmm2
movdqu [edx-16],xmm0
movdqa xmm2,xmm0
dec ecx
jnz NEAR L$024loop_key128
movdqa xmm4,[48+ebx]
db 102,15,56,0,197
db 102,15,56,221,196
pslld xmm4,1
movdqa xmm3,xmm2
pslldq xmm2,4
pxor xmm3,xmm2
pslldq xmm2,4
pxor xmm3,xmm2
pslldq xmm2,4
pxor xmm2,xmm3
pxor xmm0,xmm2
movdqu [edx],xmm0
movdqa xmm2,xmm0
db 102,15,56,0,197
db 102,15,56,221,196
movdqa xmm3,xmm2
pslldq xmm2,4
pxor xmm3,xmm2
pslldq xmm2,4
pxor xmm3,xmm2
pslldq xmm2,4
pxor xmm2,xmm3
pxor xmm0,xmm2
movdqu [16+edx],xmm0
mov ecx,9
mov DWORD [96+edx],ecx
jmp NEAR L$023good_key
align 16
L$01714rounds:
movups xmm2,[16+eax]
lea edx,[16+edx]
cmp ebp,268435456
je NEAR L$02514rounds_alt
mov ecx,13
movups [edx-32],xmm0
movups [edx-16],xmm2
db 102,15,58,223,202,1
call L$026key_256a_cold
db 102,15,58,223,200,1
call L$027key_256b
db 102,15,58,223,202,2
call L$028key_256a
db 102,15,58,223,200,2
call L$027key_256b
db 102,15,58,223,202,4
call L$028key_256a
db 102,15,58,223,200,4
call L$027key_256b
db 102,15,58,223,202,8
call L$028key_256a
db 102,15,58,223,200,8
call L$027key_256b
db 102,15,58,223,202,16
call L$028key_256a
db 102,15,58,223,200,16
call L$027key_256b
db 102,15,58,223,202,32
call L$028key_256a
db 102,15,58,223,200,32
call L$027key_256b
db 102,15,58,223,202,64
call L$028key_256a
movups [edx],xmm0
mov DWORD [16+edx],ecx
xor eax,eax
jmp NEAR L$023good_key
align 16
L$028key_256a:
movups [edx],xmm2
lea edx,[16+edx]
L$026key_256a_cold:
shufps xmm4,xmm0,16
xorps xmm0,xmm4
shufps xmm4,xmm0,140
xorps xmm0,xmm4
shufps xmm1,xmm1,255
xorps xmm0,xmm1
ret
align 16
L$027key_256b:
movups [edx],xmm0
lea edx,[16+edx]
shufps xmm4,xmm2,16
xorps xmm2,xmm4
shufps xmm4,xmm2,140
xorps xmm2,xmm4
shufps xmm1,xmm1,170
xorps xmm2,xmm1
ret
align 16
L$02514rounds_alt:
movdqa xmm5,[ebx]
movdqa xmm4,[32+ebx]
mov ecx,7
movdqu [edx-32],xmm0
movdqa xmm1,xmm2
movdqu [edx-16],xmm2
L$029loop_key256:
db 102,15,56,0,213
db 102,15,56,221,212
movdqa xmm3,xmm0
pslldq xmm0,4
pxor xmm3,xmm0
pslldq xmm0,4
pxor xmm3,xmm0
pslldq xmm0,4
pxor xmm0,xmm3
pslld xmm4,1
pxor xmm0,xmm2
movdqu [edx],xmm0
dec ecx
jz NEAR L$030done_key256
pshufd xmm2,xmm0,255
pxor xmm3,xmm3
db 102,15,56,221,211
movdqa xmm3,xmm1
pslldq xmm1,4
pxor xmm3,xmm1
pslldq xmm1,4
pxor xmm3,xmm1
pslldq xmm1,4
pxor xmm1,xmm3
pxor xmm2,xmm1
movdqu [16+edx],xmm2
lea edx,[32+edx]
movdqa xmm1,xmm2
jmp NEAR L$029loop_key256
L$030done_key256:
mov ecx,13
mov DWORD [16+edx],ecx
L$023good_key:
pxor xmm0,xmm0
pxor xmm1,xmm1
pxor xmm2,xmm2
pxor xmm3,xmm3
pxor xmm4,xmm4
pxor xmm5,xmm5
xor eax,eax
pop ebx
pop ebp
ret
align 4
L$015bad_pointer:
mov eax,-1
pop ebx
pop ebp
ret
align 4
L$018bad_keybits:
pxor xmm0,xmm0
mov eax,-2
pop ebx
pop ebp
ret
global _GFp_aes_hw_set_encrypt_key
align 16
_GFp_aes_hw_set_encrypt_key:
L$_GFp_aes_hw_set_encrypt_key_begin:
mov eax,DWORD [4+esp]
mov ecx,DWORD [8+esp]
mov edx,DWORD [12+esp]
call __aesni_set_encrypt_key
ret
align 64
L$key_const:
dd 202313229,202313229,202313229,202313229
dd 67569157,67569157,67569157,67569157
dd 1,1,1,1
dd 27,27,27,27
db 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69
db 83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83
db 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115
db 115,108,46,111,114,103,62,0
segment .bss
common _GFp_ia32cap_P 16

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,973 @@
; This file is generated from a similarly-named Perl script in the BoringSSL
; source tree. Do not edit by hand.
%ifdef BORINGSSL_PREFIX
%include "boringssl_prefix_symbols_nasm.inc"
%endif
%ifidn __OUTPUT_FORMAT__,obj
section code use32 class=code align=64
%elifidn __OUTPUT_FORMAT__,win32
$@feat.00 equ 1
section .text code align=64
%else
section .text code
%endif
global _GFp_ChaCha20_ctr32
align 16
_GFp_ChaCha20_ctr32:
L$_GFp_ChaCha20_ctr32_begin:
push ebp
push ebx
push esi
push edi
xor eax,eax
cmp eax,DWORD [28+esp]
je NEAR L$000no_data
call L$pic_point
L$pic_point:
pop eax
lea ebp,[_GFp_ia32cap_P]
test DWORD [ebp],16777216
jz NEAR L$001x86
test DWORD [4+ebp],512
jz NEAR L$001x86
jmp NEAR L$ssse3_shortcut
L$001x86:
mov esi,DWORD [32+esp]
mov edi,DWORD [36+esp]
sub esp,132
mov eax,DWORD [esi]
mov ebx,DWORD [4+esi]
mov ecx,DWORD [8+esi]
mov edx,DWORD [12+esi]
mov DWORD [80+esp],eax
mov DWORD [84+esp],ebx
mov DWORD [88+esp],ecx
mov DWORD [92+esp],edx
mov eax,DWORD [16+esi]
mov ebx,DWORD [20+esi]
mov ecx,DWORD [24+esi]
mov edx,DWORD [28+esi]
mov DWORD [96+esp],eax
mov DWORD [100+esp],ebx
mov DWORD [104+esp],ecx
mov DWORD [108+esp],edx
mov eax,DWORD [edi]
mov ebx,DWORD [4+edi]
mov ecx,DWORD [8+edi]
mov edx,DWORD [12+edi]
sub eax,1
mov DWORD [112+esp],eax
mov DWORD [116+esp],ebx
mov DWORD [120+esp],ecx
mov DWORD [124+esp],edx
jmp NEAR L$002entry
align 16
L$003outer_loop:
mov DWORD [156+esp],ebx
mov DWORD [152+esp],eax
mov DWORD [160+esp],ecx
L$002entry:
mov eax,1634760805
mov DWORD [4+esp],857760878
mov DWORD [8+esp],2036477234
mov DWORD [12+esp],1797285236
mov ebx,DWORD [84+esp]
mov ebp,DWORD [88+esp]
mov ecx,DWORD [104+esp]
mov esi,DWORD [108+esp]
mov edx,DWORD [116+esp]
mov edi,DWORD [120+esp]
mov DWORD [20+esp],ebx
mov DWORD [24+esp],ebp
mov DWORD [40+esp],ecx
mov DWORD [44+esp],esi
mov DWORD [52+esp],edx
mov DWORD [56+esp],edi
mov ebx,DWORD [92+esp]
mov edi,DWORD [124+esp]
mov edx,DWORD [112+esp]
mov ebp,DWORD [80+esp]
mov ecx,DWORD [96+esp]
mov esi,DWORD [100+esp]
add edx,1
mov DWORD [28+esp],ebx
mov DWORD [60+esp],edi
mov DWORD [112+esp],edx
mov ebx,10
jmp NEAR L$004loop
align 16
L$004loop:
add eax,ebp
mov DWORD [128+esp],ebx
mov ebx,ebp
xor edx,eax
rol edx,16
add ecx,edx
xor ebx,ecx
mov edi,DWORD [52+esp]
rol ebx,12
mov ebp,DWORD [20+esp]
add eax,ebx
xor edx,eax
mov DWORD [esp],eax
rol edx,8
mov eax,DWORD [4+esp]
add ecx,edx
mov DWORD [48+esp],edx
xor ebx,ecx
add eax,ebp
rol ebx,7
xor edi,eax
mov DWORD [32+esp],ecx
rol edi,16
mov DWORD [16+esp],ebx
add esi,edi
mov ecx,DWORD [40+esp]
xor ebp,esi
mov edx,DWORD [56+esp]
rol ebp,12
mov ebx,DWORD [24+esp]
add eax,ebp
xor edi,eax
mov DWORD [4+esp],eax
rol edi,8
mov eax,DWORD [8+esp]
add esi,edi
mov DWORD [52+esp],edi
xor ebp,esi
add eax,ebx
rol ebp,7
xor edx,eax
mov DWORD [36+esp],esi
rol edx,16
mov DWORD [20+esp],ebp
add ecx,edx
mov esi,DWORD [44+esp]
xor ebx,ecx
mov edi,DWORD [60+esp]
rol ebx,12
mov ebp,DWORD [28+esp]
add eax,ebx
xor edx,eax
mov DWORD [8+esp],eax
rol edx,8
mov eax,DWORD [12+esp]
add ecx,edx
mov DWORD [56+esp],edx
xor ebx,ecx
add eax,ebp
rol ebx,7
xor edi,eax
rol edi,16
mov DWORD [24+esp],ebx
add esi,edi
xor ebp,esi
rol ebp,12
mov ebx,DWORD [20+esp]
add eax,ebp
xor edi,eax
mov DWORD [12+esp],eax
rol edi,8
mov eax,DWORD [esp]
add esi,edi
mov edx,edi
xor ebp,esi
add eax,ebx
rol ebp,7
xor edx,eax
rol edx,16
mov DWORD [28+esp],ebp
add ecx,edx
xor ebx,ecx
mov edi,DWORD [48+esp]
rol ebx,12
mov ebp,DWORD [24+esp]
add eax,ebx
xor edx,eax
mov DWORD [esp],eax
rol edx,8
mov eax,DWORD [4+esp]
add ecx,edx
mov DWORD [60+esp],edx
xor ebx,ecx
add eax,ebp
rol ebx,7
xor edi,eax
mov DWORD [40+esp],ecx
rol edi,16
mov DWORD [20+esp],ebx
add esi,edi
mov ecx,DWORD [32+esp]
xor ebp,esi
mov edx,DWORD [52+esp]
rol ebp,12
mov ebx,DWORD [28+esp]
add eax,ebp
xor edi,eax
mov DWORD [4+esp],eax
rol edi,8
mov eax,DWORD [8+esp]
add esi,edi
mov DWORD [48+esp],edi
xor ebp,esi
add eax,ebx
rol ebp,7
xor edx,eax
mov DWORD [44+esp],esi
rol edx,16
mov DWORD [24+esp],ebp
add ecx,edx
mov esi,DWORD [36+esp]
xor ebx,ecx
mov edi,DWORD [56+esp]
rol ebx,12
mov ebp,DWORD [16+esp]
add eax,ebx
xor edx,eax
mov DWORD [8+esp],eax
rol edx,8
mov eax,DWORD [12+esp]
add ecx,edx
mov DWORD [52+esp],edx
xor ebx,ecx
add eax,ebp
rol ebx,7
xor edi,eax
rol edi,16
mov DWORD [28+esp],ebx
add esi,edi
xor ebp,esi
mov edx,DWORD [48+esp]
rol ebp,12
mov ebx,DWORD [128+esp]
add eax,ebp
xor edi,eax
mov DWORD [12+esp],eax
rol edi,8
mov eax,DWORD [esp]
add esi,edi
mov DWORD [56+esp],edi
xor ebp,esi
rol ebp,7
dec ebx
jnz NEAR L$004loop
mov ebx,DWORD [160+esp]
add eax,1634760805
add ebp,DWORD [80+esp]
add ecx,DWORD [96+esp]
add esi,DWORD [100+esp]
cmp ebx,64
jb NEAR L$005tail
mov ebx,DWORD [156+esp]
add edx,DWORD [112+esp]
add edi,DWORD [120+esp]
xor eax,DWORD [ebx]
xor ebp,DWORD [16+ebx]
mov DWORD [esp],eax
mov eax,DWORD [152+esp]
xor ecx,DWORD [32+ebx]
xor esi,DWORD [36+ebx]
xor edx,DWORD [48+ebx]
xor edi,DWORD [56+ebx]
mov DWORD [16+eax],ebp
mov DWORD [32+eax],ecx
mov DWORD [36+eax],esi
mov DWORD [48+eax],edx
mov DWORD [56+eax],edi
mov ebp,DWORD [4+esp]
mov ecx,DWORD [8+esp]
mov esi,DWORD [12+esp]
mov edx,DWORD [20+esp]
mov edi,DWORD [24+esp]
add ebp,857760878
add ecx,2036477234
add esi,1797285236
add edx,DWORD [84+esp]
add edi,DWORD [88+esp]
xor ebp,DWORD [4+ebx]
xor ecx,DWORD [8+ebx]
xor esi,DWORD [12+ebx]
xor edx,DWORD [20+ebx]
xor edi,DWORD [24+ebx]
mov DWORD [4+eax],ebp
mov DWORD [8+eax],ecx
mov DWORD [12+eax],esi
mov DWORD [20+eax],edx
mov DWORD [24+eax],edi
mov ebp,DWORD [28+esp]
mov ecx,DWORD [40+esp]
mov esi,DWORD [44+esp]
mov edx,DWORD [52+esp]
mov edi,DWORD [60+esp]
add ebp,DWORD [92+esp]
add ecx,DWORD [104+esp]
add esi,DWORD [108+esp]
add edx,DWORD [116+esp]
add edi,DWORD [124+esp]
xor ebp,DWORD [28+ebx]
xor ecx,DWORD [40+ebx]
xor esi,DWORD [44+ebx]
xor edx,DWORD [52+ebx]
xor edi,DWORD [60+ebx]
lea ebx,[64+ebx]
mov DWORD [28+eax],ebp
mov ebp,DWORD [esp]
mov DWORD [40+eax],ecx
mov ecx,DWORD [160+esp]
mov DWORD [44+eax],esi
mov DWORD [52+eax],edx
mov DWORD [60+eax],edi
mov DWORD [eax],ebp
lea eax,[64+eax]
sub ecx,64
jnz NEAR L$003outer_loop
jmp NEAR L$006done
L$005tail:
add edx,DWORD [112+esp]
add edi,DWORD [120+esp]
mov DWORD [esp],eax
mov DWORD [16+esp],ebp
mov DWORD [32+esp],ecx
mov DWORD [36+esp],esi
mov DWORD [48+esp],edx
mov DWORD [56+esp],edi
mov ebp,DWORD [4+esp]
mov ecx,DWORD [8+esp]
mov esi,DWORD [12+esp]
mov edx,DWORD [20+esp]
mov edi,DWORD [24+esp]
add ebp,857760878
add ecx,2036477234
add esi,1797285236
add edx,DWORD [84+esp]
add edi,DWORD [88+esp]
mov DWORD [4+esp],ebp
mov DWORD [8+esp],ecx
mov DWORD [12+esp],esi
mov DWORD [20+esp],edx
mov DWORD [24+esp],edi
mov ebp,DWORD [28+esp]
mov ecx,DWORD [40+esp]
mov esi,DWORD [44+esp]
mov edx,DWORD [52+esp]
mov edi,DWORD [60+esp]
add ebp,DWORD [92+esp]
add ecx,DWORD [104+esp]
add esi,DWORD [108+esp]
add edx,DWORD [116+esp]
add edi,DWORD [124+esp]
mov DWORD [28+esp],ebp
mov ebp,DWORD [156+esp]
mov DWORD [40+esp],ecx
mov ecx,DWORD [152+esp]
mov DWORD [44+esp],esi
xor esi,esi
mov DWORD [52+esp],edx
mov DWORD [60+esp],edi
xor eax,eax
xor edx,edx
L$007tail_loop:
mov al,BYTE [ebp*1+esi]
mov dl,BYTE [esi*1+esp]
lea esi,[1+esi]
xor al,dl
mov BYTE [esi*1+ecx-1],al
dec ebx
jnz NEAR L$007tail_loop
L$006done:
add esp,132
L$000no_data:
pop edi
pop esi
pop ebx
pop ebp
ret
align 16
__ChaCha20_ssse3:
push ebp
push ebx
push esi
push edi
L$ssse3_shortcut:
mov edi,DWORD [20+esp]
mov esi,DWORD [24+esp]
mov ecx,DWORD [28+esp]
mov edx,DWORD [32+esp]
mov ebx,DWORD [36+esp]
mov ebp,esp
sub esp,524
and esp,-64
mov DWORD [512+esp],ebp
lea eax,[(L$ssse3_data-L$pic_point)+eax]
movdqu xmm3,[ebx]
cmp ecx,256
jb NEAR L$0081x
mov DWORD [516+esp],edx
mov DWORD [520+esp],ebx
sub ecx,256
lea ebp,[384+esp]
movdqu xmm7,[edx]
pshufd xmm0,xmm3,0
pshufd xmm1,xmm3,85
pshufd xmm2,xmm3,170
pshufd xmm3,xmm3,255
paddd xmm0,[48+eax]
pshufd xmm4,xmm7,0
pshufd xmm5,xmm7,85
psubd xmm0,[64+eax]
pshufd xmm6,xmm7,170
pshufd xmm7,xmm7,255
movdqa [64+ebp],xmm0
movdqa [80+ebp],xmm1
movdqa [96+ebp],xmm2
movdqa [112+ebp],xmm3
movdqu xmm3,[16+edx]
movdqa [ebp-64],xmm4
movdqa [ebp-48],xmm5
movdqa [ebp-32],xmm6
movdqa [ebp-16],xmm7
movdqa xmm7,[32+eax]
lea ebx,[128+esp]
pshufd xmm0,xmm3,0
pshufd xmm1,xmm3,85
pshufd xmm2,xmm3,170
pshufd xmm3,xmm3,255
pshufd xmm4,xmm7,0
pshufd xmm5,xmm7,85
pshufd xmm6,xmm7,170
pshufd xmm7,xmm7,255
movdqa [ebp],xmm0
movdqa [16+ebp],xmm1
movdqa [32+ebp],xmm2
movdqa [48+ebp],xmm3
movdqa [ebp-128],xmm4
movdqa [ebp-112],xmm5
movdqa [ebp-96],xmm6
movdqa [ebp-80],xmm7
lea esi,[128+esi]
lea edi,[128+edi]
jmp NEAR L$009outer_loop
align 16
L$009outer_loop:
movdqa xmm1,[ebp-112]
movdqa xmm2,[ebp-96]
movdqa xmm3,[ebp-80]
movdqa xmm5,[ebp-48]
movdqa xmm6,[ebp-32]
movdqa xmm7,[ebp-16]
movdqa [ebx-112],xmm1
movdqa [ebx-96],xmm2
movdqa [ebx-80],xmm3
movdqa [ebx-48],xmm5
movdqa [ebx-32],xmm6
movdqa [ebx-16],xmm7
movdqa xmm2,[32+ebp]
movdqa xmm3,[48+ebp]
movdqa xmm4,[64+ebp]
movdqa xmm5,[80+ebp]
movdqa xmm6,[96+ebp]
movdqa xmm7,[112+ebp]
paddd xmm4,[64+eax]
movdqa [32+ebx],xmm2
movdqa [48+ebx],xmm3
movdqa [64+ebx],xmm4
movdqa [80+ebx],xmm5
movdqa [96+ebx],xmm6
movdqa [112+ebx],xmm7
movdqa [64+ebp],xmm4
movdqa xmm0,[ebp-128]
movdqa xmm6,xmm4
movdqa xmm3,[ebp-64]
movdqa xmm4,[ebp]
movdqa xmm5,[16+ebp]
mov edx,10
nop
align 16
L$010loop:
paddd xmm0,xmm3
movdqa xmm2,xmm3
pxor xmm6,xmm0
pshufb xmm6,[eax]
paddd xmm4,xmm6
pxor xmm2,xmm4
movdqa xmm3,[ebx-48]
movdqa xmm1,xmm2
pslld xmm2,12
psrld xmm1,20
por xmm2,xmm1
movdqa xmm1,[ebx-112]
paddd xmm0,xmm2
movdqa xmm7,[80+ebx]
pxor xmm6,xmm0
movdqa [ebx-128],xmm0
pshufb xmm6,[16+eax]
paddd xmm4,xmm6
movdqa [64+ebx],xmm6
pxor xmm2,xmm4
paddd xmm1,xmm3
movdqa xmm0,xmm2
pslld xmm2,7
psrld xmm0,25
pxor xmm7,xmm1
por xmm2,xmm0
movdqa [ebx],xmm4
pshufb xmm7,[eax]
movdqa [ebx-64],xmm2
paddd xmm5,xmm7
movdqa xmm4,[32+ebx]
pxor xmm3,xmm5
movdqa xmm2,[ebx-32]
movdqa xmm0,xmm3
pslld xmm3,12
psrld xmm0,20
por xmm3,xmm0
movdqa xmm0,[ebx-96]
paddd xmm1,xmm3
movdqa xmm6,[96+ebx]
pxor xmm7,xmm1
movdqa [ebx-112],xmm1
pshufb xmm7,[16+eax]
paddd xmm5,xmm7
movdqa [80+ebx],xmm7
pxor xmm3,xmm5
paddd xmm0,xmm2
movdqa xmm1,xmm3
pslld xmm3,7
psrld xmm1,25
pxor xmm6,xmm0
por xmm3,xmm1
movdqa [16+ebx],xmm5
pshufb xmm6,[eax]
movdqa [ebx-48],xmm3
paddd xmm4,xmm6
movdqa xmm5,[48+ebx]
pxor xmm2,xmm4
movdqa xmm3,[ebx-16]
movdqa xmm1,xmm2
pslld xmm2,12
psrld xmm1,20
por xmm2,xmm1
movdqa xmm1,[ebx-80]
paddd xmm0,xmm2
movdqa xmm7,[112+ebx]
pxor xmm6,xmm0
movdqa [ebx-96],xmm0
pshufb xmm6,[16+eax]
paddd xmm4,xmm6
movdqa [96+ebx],xmm6
pxor xmm2,xmm4
paddd xmm1,xmm3
movdqa xmm0,xmm2
pslld xmm2,7
psrld xmm0,25
pxor xmm7,xmm1
por xmm2,xmm0
pshufb xmm7,[eax]
movdqa [ebx-32],xmm2
paddd xmm5,xmm7
pxor xmm3,xmm5
movdqa xmm2,[ebx-48]
movdqa xmm0,xmm3
pslld xmm3,12
psrld xmm0,20
por xmm3,xmm0
movdqa xmm0,[ebx-128]
paddd xmm1,xmm3
pxor xmm7,xmm1
movdqa [ebx-80],xmm1
pshufb xmm7,[16+eax]
paddd xmm5,xmm7
movdqa xmm6,xmm7
pxor xmm3,xmm5
paddd xmm0,xmm2
movdqa xmm1,xmm3
pslld xmm3,7
psrld xmm1,25
pxor xmm6,xmm0
por xmm3,xmm1
pshufb xmm6,[eax]
movdqa [ebx-16],xmm3
paddd xmm4,xmm6
pxor xmm2,xmm4
movdqa xmm3,[ebx-32]
movdqa xmm1,xmm2
pslld xmm2,12
psrld xmm1,20
por xmm2,xmm1
movdqa xmm1,[ebx-112]
paddd xmm0,xmm2
movdqa xmm7,[64+ebx]
pxor xmm6,xmm0
movdqa [ebx-128],xmm0
pshufb xmm6,[16+eax]
paddd xmm4,xmm6
movdqa [112+ebx],xmm6
pxor xmm2,xmm4
paddd xmm1,xmm3
movdqa xmm0,xmm2
pslld xmm2,7
psrld xmm0,25
pxor xmm7,xmm1
por xmm2,xmm0
movdqa [32+ebx],xmm4
pshufb xmm7,[eax]
movdqa [ebx-48],xmm2
paddd xmm5,xmm7
movdqa xmm4,[ebx]
pxor xmm3,xmm5
movdqa xmm2,[ebx-16]
movdqa xmm0,xmm3
pslld xmm3,12
psrld xmm0,20
por xmm3,xmm0
movdqa xmm0,[ebx-96]
paddd xmm1,xmm3
movdqa xmm6,[80+ebx]
pxor xmm7,xmm1
movdqa [ebx-112],xmm1
pshufb xmm7,[16+eax]
paddd xmm5,xmm7
movdqa [64+ebx],xmm7
pxor xmm3,xmm5
paddd xmm0,xmm2
movdqa xmm1,xmm3
pslld xmm3,7
psrld xmm1,25
pxor xmm6,xmm0
por xmm3,xmm1
movdqa [48+ebx],xmm5
pshufb xmm6,[eax]
movdqa [ebx-32],xmm3
paddd xmm4,xmm6
movdqa xmm5,[16+ebx]
pxor xmm2,xmm4
movdqa xmm3,[ebx-64]
movdqa xmm1,xmm2
pslld xmm2,12
psrld xmm1,20
por xmm2,xmm1
movdqa xmm1,[ebx-80]
paddd xmm0,xmm2
movdqa xmm7,[96+ebx]
pxor xmm6,xmm0
movdqa [ebx-96],xmm0
pshufb xmm6,[16+eax]
paddd xmm4,xmm6
movdqa [80+ebx],xmm6
pxor xmm2,xmm4
paddd xmm1,xmm3
movdqa xmm0,xmm2
pslld xmm2,7
psrld xmm0,25
pxor xmm7,xmm1
por xmm2,xmm0
pshufb xmm7,[eax]
movdqa [ebx-16],xmm2
paddd xmm5,xmm7
pxor xmm3,xmm5
movdqa xmm0,xmm3
pslld xmm3,12
psrld xmm0,20
por xmm3,xmm0
movdqa xmm0,[ebx-128]
paddd xmm1,xmm3
movdqa xmm6,[64+ebx]
pxor xmm7,xmm1
movdqa [ebx-80],xmm1
pshufb xmm7,[16+eax]
paddd xmm5,xmm7
movdqa [96+ebx],xmm7
pxor xmm3,xmm5
movdqa xmm1,xmm3
pslld xmm3,7
psrld xmm1,25
por xmm3,xmm1
dec edx
jnz NEAR L$010loop
movdqa [ebx-64],xmm3
movdqa [ebx],xmm4
movdqa [16+ebx],xmm5
movdqa [64+ebx],xmm6
movdqa [96+ebx],xmm7
movdqa xmm1,[ebx-112]
movdqa xmm2,[ebx-96]
movdqa xmm3,[ebx-80]
paddd xmm0,[ebp-128]
paddd xmm1,[ebp-112]
paddd xmm2,[ebp-96]
paddd xmm3,[ebp-80]
movdqa xmm6,xmm0
punpckldq xmm0,xmm1
movdqa xmm7,xmm2
punpckldq xmm2,xmm3
punpckhdq xmm6,xmm1
punpckhdq xmm7,xmm3
movdqa xmm1,xmm0
punpcklqdq xmm0,xmm2
movdqa xmm3,xmm6
punpcklqdq xmm6,xmm7
punpckhqdq xmm1,xmm2
punpckhqdq xmm3,xmm7
movdqu xmm4,[esi-128]
movdqu xmm5,[esi-64]
movdqu xmm2,[esi]
movdqu xmm7,[64+esi]
lea esi,[16+esi]
pxor xmm4,xmm0
movdqa xmm0,[ebx-64]
pxor xmm5,xmm1
movdqa xmm1,[ebx-48]
pxor xmm6,xmm2
movdqa xmm2,[ebx-32]
pxor xmm7,xmm3
movdqa xmm3,[ebx-16]
movdqu [edi-128],xmm4
movdqu [edi-64],xmm5
movdqu [edi],xmm6
movdqu [64+edi],xmm7
lea edi,[16+edi]
paddd xmm0,[ebp-64]
paddd xmm1,[ebp-48]
paddd xmm2,[ebp-32]
paddd xmm3,[ebp-16]
movdqa xmm6,xmm0
punpckldq xmm0,xmm1
movdqa xmm7,xmm2
punpckldq xmm2,xmm3
punpckhdq xmm6,xmm1
punpckhdq xmm7,xmm3
movdqa xmm1,xmm0
punpcklqdq xmm0,xmm2
movdqa xmm3,xmm6
punpcklqdq xmm6,xmm7
punpckhqdq xmm1,xmm2
punpckhqdq xmm3,xmm7
movdqu xmm4,[esi-128]
movdqu xmm5,[esi-64]
movdqu xmm2,[esi]
movdqu xmm7,[64+esi]
lea esi,[16+esi]
pxor xmm4,xmm0
movdqa xmm0,[ebx]
pxor xmm5,xmm1
movdqa xmm1,[16+ebx]
pxor xmm6,xmm2
movdqa xmm2,[32+ebx]
pxor xmm7,xmm3
movdqa xmm3,[48+ebx]
movdqu [edi-128],xmm4
movdqu [edi-64],xmm5
movdqu [edi],xmm6
movdqu [64+edi],xmm7
lea edi,[16+edi]
paddd xmm0,[ebp]
paddd xmm1,[16+ebp]
paddd xmm2,[32+ebp]
paddd xmm3,[48+ebp]
movdqa xmm6,xmm0
punpckldq xmm0,xmm1
movdqa xmm7,xmm2
punpckldq xmm2,xmm3
punpckhdq xmm6,xmm1
punpckhdq xmm7,xmm3
movdqa xmm1,xmm0
punpcklqdq xmm0,xmm2
movdqa xmm3,xmm6
punpcklqdq xmm6,xmm7
punpckhqdq xmm1,xmm2
punpckhqdq xmm3,xmm7
movdqu xmm4,[esi-128]
movdqu xmm5,[esi-64]
movdqu xmm2,[esi]
movdqu xmm7,[64+esi]
lea esi,[16+esi]
pxor xmm4,xmm0
movdqa xmm0,[64+ebx]
pxor xmm5,xmm1
movdqa xmm1,[80+ebx]
pxor xmm6,xmm2
movdqa xmm2,[96+ebx]
pxor xmm7,xmm3
movdqa xmm3,[112+ebx]
movdqu [edi-128],xmm4
movdqu [edi-64],xmm5
movdqu [edi],xmm6
movdqu [64+edi],xmm7
lea edi,[16+edi]
paddd xmm0,[64+ebp]
paddd xmm1,[80+ebp]
paddd xmm2,[96+ebp]
paddd xmm3,[112+ebp]
movdqa xmm6,xmm0
punpckldq xmm0,xmm1
movdqa xmm7,xmm2
punpckldq xmm2,xmm3
punpckhdq xmm6,xmm1
punpckhdq xmm7,xmm3
movdqa xmm1,xmm0
punpcklqdq xmm0,xmm2
movdqa xmm3,xmm6
punpcklqdq xmm6,xmm7
punpckhqdq xmm1,xmm2
punpckhqdq xmm3,xmm7
movdqu xmm4,[esi-128]
movdqu xmm5,[esi-64]
movdqu xmm2,[esi]
movdqu xmm7,[64+esi]
lea esi,[208+esi]
pxor xmm4,xmm0
pxor xmm5,xmm1
pxor xmm6,xmm2
pxor xmm7,xmm3
movdqu [edi-128],xmm4
movdqu [edi-64],xmm5
movdqu [edi],xmm6
movdqu [64+edi],xmm7
lea edi,[208+edi]
sub ecx,256
jnc NEAR L$009outer_loop
add ecx,256
jz NEAR L$011done
mov ebx,DWORD [520+esp]
lea esi,[esi-128]
mov edx,DWORD [516+esp]
lea edi,[edi-128]
movd xmm2,DWORD [64+ebp]
movdqu xmm3,[ebx]
paddd xmm2,[96+eax]
pand xmm3,[112+eax]
por xmm3,xmm2
L$0081x:
movdqa xmm0,[32+eax]
movdqu xmm1,[edx]
movdqu xmm2,[16+edx]
movdqa xmm6,[eax]
movdqa xmm7,[16+eax]
mov DWORD [48+esp],ebp
movdqa [esp],xmm0
movdqa [16+esp],xmm1
movdqa [32+esp],xmm2
movdqa [48+esp],xmm3
mov edx,10
jmp NEAR L$012loop1x
align 16
L$013outer1x:
movdqa xmm3,[80+eax]
movdqa xmm0,[esp]
movdqa xmm1,[16+esp]
movdqa xmm2,[32+esp]
paddd xmm3,[48+esp]
mov edx,10
movdqa [48+esp],xmm3
jmp NEAR L$012loop1x
align 16
L$012loop1x:
paddd xmm0,xmm1
pxor xmm3,xmm0
db 102,15,56,0,222
paddd xmm2,xmm3
pxor xmm1,xmm2
movdqa xmm4,xmm1
psrld xmm1,20
pslld xmm4,12
por xmm1,xmm4
paddd xmm0,xmm1
pxor xmm3,xmm0
db 102,15,56,0,223
paddd xmm2,xmm3
pxor xmm1,xmm2
movdqa xmm4,xmm1
psrld xmm1,25
pslld xmm4,7
por xmm1,xmm4
pshufd xmm2,xmm2,78
pshufd xmm1,xmm1,57
pshufd xmm3,xmm3,147
nop
paddd xmm0,xmm1
pxor xmm3,xmm0
db 102,15,56,0,222
paddd xmm2,xmm3
pxor xmm1,xmm2
movdqa xmm4,xmm1
psrld xmm1,20
pslld xmm4,12
por xmm1,xmm4
paddd xmm0,xmm1
pxor xmm3,xmm0
db 102,15,56,0,223
paddd xmm2,xmm3
pxor xmm1,xmm2
movdqa xmm4,xmm1
psrld xmm1,25
pslld xmm4,7
por xmm1,xmm4
pshufd xmm2,xmm2,78
pshufd xmm1,xmm1,147
pshufd xmm3,xmm3,57
dec edx
jnz NEAR L$012loop1x
paddd xmm0,[esp]
paddd xmm1,[16+esp]
paddd xmm2,[32+esp]
paddd xmm3,[48+esp]
cmp ecx,64
jb NEAR L$014tail
movdqu xmm4,[esi]
movdqu xmm5,[16+esi]
pxor xmm0,xmm4
movdqu xmm4,[32+esi]
pxor xmm1,xmm5
movdqu xmm5,[48+esi]
pxor xmm2,xmm4
pxor xmm3,xmm5
lea esi,[64+esi]
movdqu [edi],xmm0
movdqu [16+edi],xmm1
movdqu [32+edi],xmm2
movdqu [48+edi],xmm3
lea edi,[64+edi]
sub ecx,64
jnz NEAR L$013outer1x
jmp NEAR L$011done
L$014tail:
movdqa [esp],xmm0
movdqa [16+esp],xmm1
movdqa [32+esp],xmm2
movdqa [48+esp],xmm3
xor eax,eax
xor edx,edx
xor ebp,ebp
L$015tail_loop:
mov al,BYTE [ebp*1+esp]
mov dl,BYTE [ebp*1+esi]
lea ebp,[1+ebp]
xor al,dl
mov BYTE [ebp*1+edi-1],al
dec ecx
jnz NEAR L$015tail_loop
L$011done:
mov esp,DWORD [512+esp]
pop edi
pop esi
pop ebx
pop ebp
ret
align 64
L$ssse3_data:
db 2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13
db 3,0,1,2,7,4,5,6,11,8,9,10,15,12,13,14
dd 1634760805,857760878,2036477234,1797285236
dd 0,1,2,3
dd 4,4,4,4
dd 1,0,0,0
dd 4,0,0,0
dd 0,-1,-1,-1
align 64
db 67,104,97,67,104,97,50,48,32,102,111,114,32,120,56,54
db 44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32
db 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111
db 114,103,62,0
segment .bss
common _GFp_ia32cap_P 16

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,359 @@
; This file is generated from a similarly-named Perl script in the BoringSSL
; source tree. Do not edit by hand.
%ifdef BORINGSSL_PREFIX
%include "boringssl_prefix_symbols_nasm.inc"
%endif
%ifidn __OUTPUT_FORMAT__,obj
section code use32 class=code align=64
%elifidn __OUTPUT_FORMAT__,win32
$@feat.00 equ 1
section .text code align=64
%else
section .text code
%endif
global _GFp_gcm_init_clmul
align 16
_GFp_gcm_init_clmul:
L$_GFp_gcm_init_clmul_begin:
mov edx,DWORD [4+esp]
mov eax,DWORD [8+esp]
call L$000pic
L$000pic:
pop ecx
lea ecx,[(L$bswap-L$000pic)+ecx]
movdqu xmm2,[eax]
pshufd xmm2,xmm2,78
pshufd xmm4,xmm2,255
movdqa xmm3,xmm2
psllq xmm2,1
pxor xmm5,xmm5
psrlq xmm3,63
pcmpgtd xmm5,xmm4
pslldq xmm3,8
por xmm2,xmm3
pand xmm5,[16+ecx]
pxor xmm2,xmm5
movdqa xmm0,xmm2
movdqa xmm1,xmm0
pshufd xmm3,xmm0,78
pshufd xmm4,xmm2,78
pxor xmm3,xmm0
pxor xmm4,xmm2
db 102,15,58,68,194,0
db 102,15,58,68,202,17
db 102,15,58,68,220,0
xorps xmm3,xmm0
xorps xmm3,xmm1
movdqa xmm4,xmm3
psrldq xmm3,8
pslldq xmm4,8
pxor xmm1,xmm3
pxor xmm0,xmm4
movdqa xmm4,xmm0
movdqa xmm3,xmm0
psllq xmm0,5
pxor xmm3,xmm0
psllq xmm0,1
pxor xmm0,xmm3
psllq xmm0,57
movdqa xmm3,xmm0
pslldq xmm0,8
psrldq xmm3,8
pxor xmm0,xmm4
pxor xmm1,xmm3
movdqa xmm4,xmm0
psrlq xmm0,1
pxor xmm1,xmm4
pxor xmm4,xmm0
psrlq xmm0,5
pxor xmm0,xmm4
psrlq xmm0,1
pxor xmm0,xmm1
pshufd xmm3,xmm2,78
pshufd xmm4,xmm0,78
pxor xmm3,xmm2
movdqu [edx],xmm2
pxor xmm4,xmm0
movdqu [16+edx],xmm0
db 102,15,58,15,227,8
movdqu [32+edx],xmm4
ret
global _GFp_gcm_gmult_clmul
align 16
_GFp_gcm_gmult_clmul:
L$_GFp_gcm_gmult_clmul_begin:
mov eax,DWORD [4+esp]
mov edx,DWORD [8+esp]
call L$001pic
L$001pic:
pop ecx
lea ecx,[(L$bswap-L$001pic)+ecx]
movdqu xmm0,[eax]
movdqa xmm5,[ecx]
movups xmm2,[edx]
db 102,15,56,0,197
movups xmm4,[32+edx]
movdqa xmm1,xmm0
pshufd xmm3,xmm0,78
pxor xmm3,xmm0
db 102,15,58,68,194,0
db 102,15,58,68,202,17
db 102,15,58,68,220,0
xorps xmm3,xmm0
xorps xmm3,xmm1
movdqa xmm4,xmm3
psrldq xmm3,8
pslldq xmm4,8
pxor xmm1,xmm3
pxor xmm0,xmm4
movdqa xmm4,xmm0
movdqa xmm3,xmm0
psllq xmm0,5
pxor xmm3,xmm0
psllq xmm0,1
pxor xmm0,xmm3
psllq xmm0,57
movdqa xmm3,xmm0
pslldq xmm0,8
psrldq xmm3,8
pxor xmm0,xmm4
pxor xmm1,xmm3
movdqa xmm4,xmm0
psrlq xmm0,1
pxor xmm1,xmm4
pxor xmm4,xmm0
psrlq xmm0,5
pxor xmm0,xmm4
psrlq xmm0,1
pxor xmm0,xmm1
db 102,15,56,0,197
movdqu [eax],xmm0
ret
global _GFp_gcm_ghash_clmul
align 16
_GFp_gcm_ghash_clmul:
L$_GFp_gcm_ghash_clmul_begin:
push ebp
push ebx
push esi
push edi
mov eax,DWORD [20+esp]
mov edx,DWORD [24+esp]
mov esi,DWORD [28+esp]
mov ebx,DWORD [32+esp]
call L$002pic
L$002pic:
pop ecx
lea ecx,[(L$bswap-L$002pic)+ecx]
movdqu xmm0,[eax]
movdqa xmm5,[ecx]
movdqu xmm2,[edx]
db 102,15,56,0,197
sub ebx,16
jz NEAR L$003odd_tail
movdqu xmm3,[esi]
movdqu xmm6,[16+esi]
db 102,15,56,0,221
db 102,15,56,0,245
movdqu xmm5,[32+edx]
pxor xmm0,xmm3
pshufd xmm3,xmm6,78
movdqa xmm7,xmm6
pxor xmm3,xmm6
lea esi,[32+esi]
db 102,15,58,68,242,0
db 102,15,58,68,250,17
db 102,15,58,68,221,0
movups xmm2,[16+edx]
nop
sub ebx,32
jbe NEAR L$004even_tail
jmp NEAR L$005mod_loop
align 32
L$005mod_loop:
pshufd xmm4,xmm0,78
movdqa xmm1,xmm0
pxor xmm4,xmm0
nop
db 102,15,58,68,194,0
db 102,15,58,68,202,17
db 102,15,58,68,229,16
movups xmm2,[edx]
xorps xmm0,xmm6
movdqa xmm5,[ecx]
xorps xmm1,xmm7
movdqu xmm7,[esi]
pxor xmm3,xmm0
movdqu xmm6,[16+esi]
pxor xmm3,xmm1
db 102,15,56,0,253
pxor xmm4,xmm3
movdqa xmm3,xmm4
psrldq xmm4,8
pslldq xmm3,8
pxor xmm1,xmm4
pxor xmm0,xmm3
db 102,15,56,0,245
pxor xmm1,xmm7
movdqa xmm7,xmm6
movdqa xmm4,xmm0
movdqa xmm3,xmm0
psllq xmm0,5
pxor xmm3,xmm0
psllq xmm0,1
pxor xmm0,xmm3
db 102,15,58,68,242,0
movups xmm5,[32+edx]
psllq xmm0,57
movdqa xmm3,xmm0
pslldq xmm0,8
psrldq xmm3,8
pxor xmm0,xmm4
pxor xmm1,xmm3
pshufd xmm3,xmm7,78
movdqa xmm4,xmm0
psrlq xmm0,1
pxor xmm3,xmm7
pxor xmm1,xmm4
db 102,15,58,68,250,17
movups xmm2,[16+edx]
pxor xmm4,xmm0
psrlq xmm0,5
pxor xmm0,xmm4
psrlq xmm0,1
pxor xmm0,xmm1
db 102,15,58,68,221,0
lea esi,[32+esi]
sub ebx,32
ja NEAR L$005mod_loop
L$004even_tail:
pshufd xmm4,xmm0,78
movdqa xmm1,xmm0
pxor xmm4,xmm0
db 102,15,58,68,194,0
db 102,15,58,68,202,17
db 102,15,58,68,229,16
movdqa xmm5,[ecx]
xorps xmm0,xmm6
xorps xmm1,xmm7
pxor xmm3,xmm0
pxor xmm3,xmm1
pxor xmm4,xmm3
movdqa xmm3,xmm4
psrldq xmm4,8
pslldq xmm3,8
pxor xmm1,xmm4
pxor xmm0,xmm3
movdqa xmm4,xmm0
movdqa xmm3,xmm0
psllq xmm0,5
pxor xmm3,xmm0
psllq xmm0,1
pxor xmm0,xmm3
psllq xmm0,57
movdqa xmm3,xmm0
pslldq xmm0,8
psrldq xmm3,8
pxor xmm0,xmm4
pxor xmm1,xmm3
movdqa xmm4,xmm0
psrlq xmm0,1
pxor xmm1,xmm4
pxor xmm4,xmm0
psrlq xmm0,5
pxor xmm0,xmm4
psrlq xmm0,1
pxor xmm0,xmm1
test ebx,ebx
jnz NEAR L$006done
movups xmm2,[edx]
L$003odd_tail:
movdqu xmm3,[esi]
db 102,15,56,0,221
pxor xmm0,xmm3
movdqa xmm1,xmm0
pshufd xmm3,xmm0,78
pshufd xmm4,xmm2,78
pxor xmm3,xmm0
pxor xmm4,xmm2
db 102,15,58,68,194,0
db 102,15,58,68,202,17
db 102,15,58,68,220,0
xorps xmm3,xmm0
xorps xmm3,xmm1
movdqa xmm4,xmm3
psrldq xmm3,8
pslldq xmm4,8
pxor xmm1,xmm3
pxor xmm0,xmm4
movdqa xmm4,xmm0
movdqa xmm3,xmm0
psllq xmm0,5
pxor xmm3,xmm0
psllq xmm0,1
pxor xmm0,xmm3
psllq xmm0,57
movdqa xmm3,xmm0
pslldq xmm0,8
psrldq xmm3,8
pxor xmm0,xmm4
pxor xmm1,xmm3
movdqa xmm4,xmm0
psrlq xmm0,1
pxor xmm1,xmm4
pxor xmm4,xmm0
psrlq xmm0,5
pxor xmm0,xmm4
psrlq xmm0,1
pxor xmm0,xmm1
L$006done:
db 102,15,56,0,197
movdqu [eax],xmm0
pop edi
pop esi
pop ebx
pop ebp
ret
align 64
L$bswap:
db 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
db 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,194
align 64
L$007rem_8bit:
dw 0,450,900,582,1800,1738,1164,1358
dw 3600,4050,3476,3158,2328,2266,2716,2910
dw 7200,7650,8100,7782,6952,6890,6316,6510
dw 4656,5106,4532,4214,5432,5370,5820,6014
dw 14400,14722,15300,14854,16200,16010,15564,15630
dw 13904,14226,13780,13334,12632,12442,13020,13086
dw 9312,9634,10212,9766,9064,8874,8428,8494
dw 10864,11186,10740,10294,11640,11450,12028,12094
dw 28800,28994,29444,29382,30600,30282,29708,30158
dw 32400,32594,32020,31958,31128,30810,31260,31710
dw 27808,28002,28452,28390,27560,27242,26668,27118
dw 25264,25458,24884,24822,26040,25722,26172,26622
dw 18624,18690,19268,19078,20424,19978,19532,19854
dw 18128,18194,17748,17558,16856,16410,16988,17310
dw 21728,21794,22372,22182,21480,21034,20588,20910
dw 23280,23346,22900,22710,24056,23610,24188,24510
dw 57600,57538,57988,58182,58888,59338,58764,58446
dw 61200,61138,60564,60758,59416,59866,60316,59998
dw 64800,64738,65188,65382,64040,64490,63916,63598
dw 62256,62194,61620,61814,62520,62970,63420,63102
dw 55616,55426,56004,56070,56904,57226,56780,56334
dw 55120,54930,54484,54550,53336,53658,54236,53790
dw 50528,50338,50916,50982,49768,50090,49644,49198
dw 52080,51890,51444,51510,52344,52666,53244,52798
dw 37248,36930,37380,37830,38536,38730,38156,38094
dw 40848,40530,39956,40406,39064,39258,39708,39646
dw 36256,35938,36388,36838,35496,35690,35116,35054
dw 33712,33394,32820,33270,33976,34170,34620,34558
dw 43456,43010,43588,43910,44744,44810,44364,44174
dw 42960,42514,42068,42390,41176,41242,41820,41630
dw 46560,46114,46692,47014,45800,45866,45420,45230
dw 48112,47666,47220,47542,48376,48442,49020,48830
db 71,72,65,83,72,32,102,111,114,32,120,56,54,44,32,67
db 82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112
db 112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62
db 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,378 @@
; This file is generated from a similarly-named Perl script in the BoringSSL
; source tree. Do not edit by hand.
%ifdef BORINGSSL_PREFIX
%include "boringssl_prefix_symbols_nasm.inc"
%endif
%ifidn __OUTPUT_FORMAT__,obj
section code use32 class=code align=64
%elifidn __OUTPUT_FORMAT__,win32
$@feat.00 equ 1
section .text code align=64
%else
section .text code
%endif
align 64
L$_vpaes_consts:
dd 218628480,235210255,168496130,67568393
dd 252381056,17041926,33884169,51187212
dd 252645135,252645135,252645135,252645135
dd 1512730624,3266504856,1377990664,3401244816
dd 830229760,1275146365,2969422977,3447763452
dd 3411033600,2979783055,338359620,2782886510
dd 4209124096,907596821,221174255,1006095553
dd 191964160,3799684038,3164090317,1589111125
dd 182528256,1777043520,2877432650,3265356744
dd 1874708224,3503451415,3305285752,363511674
dd 1606117888,3487855781,1093350906,2384367825
dd 197121,67569157,134941193,202313229
dd 67569157,134941193,202313229,197121
dd 134941193,202313229,197121,67569157
dd 202313229,197121,67569157,134941193
dd 33619971,100992007,168364043,235736079
dd 235736079,33619971,100992007,168364043
dd 168364043,235736079,33619971,100992007
dd 100992007,168364043,235736079,33619971
dd 50462976,117835012,185207048,252579084
dd 252314880,51251460,117574920,184942860
dd 184682752,252054788,50987272,118359308
dd 118099200,185467140,251790600,50727180
dd 2946363062,528716217,1300004225,1881839624
dd 1532713819,1532713819,1532713819,1532713819
dd 3602276352,4288629033,3737020424,4153884961
dd 1354558464,32357713,2958822624,3775749553
dd 1201988352,132424512,1572796698,503232858
dd 2213177600,1597421020,4103937655,675398315
db 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105
db 111,110,32,65,69,83,32,102,111,114,32,120,56,54,47,83
db 83,83,69,51,44,32,77,105,107,101,32,72,97,109,98,117
db 114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105
db 118,101,114,115,105,116,121,41,0
align 64
align 16
__vpaes_preheat:
add ebp,DWORD [esp]
movdqa xmm7,[ebp-48]
movdqa xmm6,[ebp-16]
ret
align 16
__vpaes_encrypt_core:
mov ecx,16
mov eax,DWORD [240+edx]
movdqa xmm1,xmm6
movdqa xmm2,[ebp]
pandn xmm1,xmm0
pand xmm0,xmm6
movdqu xmm5,[edx]
db 102,15,56,0,208
movdqa xmm0,[16+ebp]
pxor xmm2,xmm5
psrld xmm1,4
add edx,16
db 102,15,56,0,193
lea ebx,[192+ebp]
pxor xmm0,xmm2
jmp NEAR L$000enc_entry
align 16
L$001enc_loop:
movdqa xmm4,[32+ebp]
movdqa xmm0,[48+ebp]
db 102,15,56,0,226
db 102,15,56,0,195
pxor xmm4,xmm5
movdqa xmm5,[64+ebp]
pxor xmm0,xmm4
movdqa xmm1,[ecx*1+ebx-64]
db 102,15,56,0,234
movdqa xmm2,[80+ebp]
movdqa xmm4,[ecx*1+ebx]
db 102,15,56,0,211
movdqa xmm3,xmm0
pxor xmm2,xmm5
db 102,15,56,0,193
add edx,16
pxor xmm0,xmm2
db 102,15,56,0,220
add ecx,16
pxor xmm3,xmm0
db 102,15,56,0,193
and ecx,48
sub eax,1
pxor xmm0,xmm3
L$000enc_entry:
movdqa xmm1,xmm6
movdqa xmm5,[ebp-32]
pandn xmm1,xmm0
psrld xmm1,4
pand xmm0,xmm6
db 102,15,56,0,232
movdqa xmm3,xmm7
pxor xmm0,xmm1
db 102,15,56,0,217
movdqa xmm4,xmm7
pxor xmm3,xmm5
db 102,15,56,0,224
movdqa xmm2,xmm7
pxor xmm4,xmm5
db 102,15,56,0,211
movdqa xmm3,xmm7
pxor xmm2,xmm0
db 102,15,56,0,220
movdqu xmm5,[edx]
pxor xmm3,xmm1
jnz NEAR L$001enc_loop
movdqa xmm4,[96+ebp]
movdqa xmm0,[112+ebp]
db 102,15,56,0,226
pxor xmm4,xmm5
db 102,15,56,0,195
movdqa xmm1,[64+ecx*1+ebx]
pxor xmm0,xmm4
db 102,15,56,0,193
ret
align 16
__vpaes_schedule_core:
add ebp,DWORD [esp]
movdqu xmm0,[esi]
movdqa xmm2,[320+ebp]
movdqa xmm3,xmm0
lea ebx,[ebp]
movdqa [4+esp],xmm2
call __vpaes_schedule_transform
movdqa xmm7,xmm0
test edi,edi
jnz NEAR L$002schedule_am_decrypting
movdqu [edx],xmm0
jmp NEAR L$003schedule_go
L$002schedule_am_decrypting:
movdqa xmm1,[256+ecx*1+ebp]
db 102,15,56,0,217
movdqu [edx],xmm3
xor ecx,48
L$003schedule_go:
cmp eax,192
ja NEAR L$004schedule_256
L$005schedule_128:
mov eax,10
L$006loop_schedule_128:
call __vpaes_schedule_round
dec eax
jz NEAR L$007schedule_mangle_last
call __vpaes_schedule_mangle
jmp NEAR L$006loop_schedule_128
align 16
L$004schedule_256:
movdqu xmm0,[16+esi]
call __vpaes_schedule_transform
mov eax,7
L$008loop_schedule_256:
call __vpaes_schedule_mangle
movdqa xmm6,xmm0
call __vpaes_schedule_round
dec eax
jz NEAR L$007schedule_mangle_last
call __vpaes_schedule_mangle
pshufd xmm0,xmm0,255
movdqa [20+esp],xmm7
movdqa xmm7,xmm6
call L$_vpaes_schedule_low_round
movdqa xmm7,[20+esp]
jmp NEAR L$008loop_schedule_256
align 16
L$007schedule_mangle_last:
lea ebx,[384+ebp]
test edi,edi
jnz NEAR L$009schedule_mangle_last_dec
movdqa xmm1,[256+ecx*1+ebp]
db 102,15,56,0,193
lea ebx,[352+ebp]
add edx,32
L$009schedule_mangle_last_dec:
add edx,-16
pxor xmm0,[336+ebp]
call __vpaes_schedule_transform
movdqu [edx],xmm0
pxor xmm0,xmm0
pxor xmm1,xmm1
pxor xmm2,xmm2
pxor xmm3,xmm3
pxor xmm4,xmm4
pxor xmm5,xmm5
pxor xmm6,xmm6
pxor xmm7,xmm7
ret
align 16
__vpaes_schedule_round:
movdqa xmm2,[8+esp]
pxor xmm1,xmm1
db 102,15,58,15,202,15
db 102,15,58,15,210,15
pxor xmm7,xmm1
pshufd xmm0,xmm0,255
db 102,15,58,15,192,1
movdqa [8+esp],xmm2
L$_vpaes_schedule_low_round:
movdqa xmm1,xmm7
pslldq xmm7,4
pxor xmm7,xmm1
movdqa xmm1,xmm7
pslldq xmm7,8
pxor xmm7,xmm1
pxor xmm7,[336+ebp]
movdqa xmm4,[ebp-16]
movdqa xmm5,[ebp-48]
movdqa xmm1,xmm4
pandn xmm1,xmm0
psrld xmm1,4
pand xmm0,xmm4
movdqa xmm2,[ebp-32]
db 102,15,56,0,208
pxor xmm0,xmm1
movdqa xmm3,xmm5
db 102,15,56,0,217
pxor xmm3,xmm2
movdqa xmm4,xmm5
db 102,15,56,0,224
pxor xmm4,xmm2
movdqa xmm2,xmm5
db 102,15,56,0,211
pxor xmm2,xmm0
movdqa xmm3,xmm5
db 102,15,56,0,220
pxor xmm3,xmm1
movdqa xmm4,[32+ebp]
db 102,15,56,0,226
movdqa xmm0,[48+ebp]
db 102,15,56,0,195
pxor xmm0,xmm4
pxor xmm0,xmm7
movdqa xmm7,xmm0
ret
align 16
__vpaes_schedule_transform:
movdqa xmm2,[ebp-16]
movdqa xmm1,xmm2
pandn xmm1,xmm0
psrld xmm1,4
pand xmm0,xmm2
movdqa xmm2,[ebx]
db 102,15,56,0,208
movdqa xmm0,[16+ebx]
db 102,15,56,0,193
pxor xmm0,xmm2
ret
align 16
__vpaes_schedule_mangle:
movdqa xmm4,xmm0
movdqa xmm5,[128+ebp]
test edi,edi
jnz NEAR L$010schedule_mangle_dec
add edx,16
pxor xmm4,[336+ebp]
db 102,15,56,0,229
movdqa xmm3,xmm4
db 102,15,56,0,229
pxor xmm3,xmm4
db 102,15,56,0,229
pxor xmm3,xmm4
jmp NEAR L$011schedule_mangle_both
align 16
L$010schedule_mangle_dec:
movdqa xmm2,[ebp-16]
lea esi,[ebp]
movdqa xmm1,xmm2
pandn xmm1,xmm4
psrld xmm1,4
pand xmm4,xmm2
movdqa xmm2,[esi]
db 102,15,56,0,212
movdqa xmm3,[16+esi]
db 102,15,56,0,217
pxor xmm3,xmm2
db 102,15,56,0,221
movdqa xmm2,[32+esi]
db 102,15,56,0,212
pxor xmm2,xmm3
movdqa xmm3,[48+esi]
db 102,15,56,0,217
pxor xmm3,xmm2
db 102,15,56,0,221
movdqa xmm2,[64+esi]
db 102,15,56,0,212
pxor xmm2,xmm3
movdqa xmm3,[80+esi]
db 102,15,56,0,217
pxor xmm3,xmm2
db 102,15,56,0,221
movdqa xmm2,[96+esi]
db 102,15,56,0,212
pxor xmm2,xmm3
movdqa xmm3,[112+esi]
db 102,15,56,0,217
pxor xmm3,xmm2
add edx,-16
L$011schedule_mangle_both:
movdqa xmm1,[256+ecx*1+ebp]
db 102,15,56,0,217
add ecx,-16
and ecx,48
movdqu [edx],xmm3
ret
global _GFp_vpaes_set_encrypt_key
align 16
_GFp_vpaes_set_encrypt_key:
L$_GFp_vpaes_set_encrypt_key_begin:
push ebp
push ebx
push esi
push edi
mov esi,DWORD [20+esp]
lea ebx,[esp-56]
mov eax,DWORD [24+esp]
and ebx,-16
mov edx,DWORD [28+esp]
xchg ebx,esp
mov DWORD [48+esp],ebx
mov ebx,eax
shr ebx,5
add ebx,5
mov DWORD [240+edx],ebx
mov ecx,48
mov edi,0
lea ebp,[(L$_vpaes_consts+0x30-L$012pic_point)]
call __vpaes_schedule_core
L$012pic_point:
mov esp,DWORD [48+esp]
xor eax,eax
pop edi
pop esi
pop ebx
pop ebp
ret
global _GFp_vpaes_encrypt
align 16
_GFp_vpaes_encrypt:
L$_GFp_vpaes_encrypt_begin:
push ebp
push ebx
push esi
push edi
lea ebp,[(L$_vpaes_consts+0x30-L$013pic_point)]
call __vpaes_preheat
L$013pic_point:
mov esi,DWORD [20+esp]
lea ebx,[esp-56]
mov edi,DWORD [24+esp]
and ebx,-16
mov edx,DWORD [28+esp]
xchg ebx,esp
mov DWORD [48+esp],ebx
movdqu xmm0,[esi]
call __vpaes_encrypt_core
movdqu [edi],xmm0
mov esp,DWORD [48+esp]
pop edi
pop esi
pop ebx
pop ebp
ret

View File

@ -0,0 +1,982 @@
; This file is generated from a similarly-named Perl script in the BoringSSL
; source tree. Do not edit by hand.
default rel
%define XMMWORD
%define YMMWORD
%define ZMMWORD
section .text code align=64
ALIGN 16
_vpaes_encrypt_core:
mov r9,rdx
mov r11,16
mov eax,DWORD[240+rdx]
movdqa xmm1,xmm9
movdqa xmm2,XMMWORD[$L$k_ipt]
pandn xmm1,xmm0
movdqu xmm5,XMMWORD[r9]
psrld xmm1,4
pand xmm0,xmm9
DB 102,15,56,0,208
movdqa xmm0,XMMWORD[(($L$k_ipt+16))]
DB 102,15,56,0,193
pxor xmm2,xmm5
add r9,16
pxor xmm0,xmm2
lea r10,[$L$k_mc_backward]
jmp NEAR $L$enc_entry
ALIGN 16
$L$enc_loop:
movdqa xmm4,xmm13
movdqa xmm0,xmm12
DB 102,15,56,0,226
DB 102,15,56,0,195
pxor xmm4,xmm5
movdqa xmm5,xmm15
pxor xmm0,xmm4
movdqa xmm1,XMMWORD[((-64))+r10*1+r11]
DB 102,15,56,0,234
movdqa xmm4,XMMWORD[r10*1+r11]
movdqa xmm2,xmm14
DB 102,15,56,0,211
movdqa xmm3,xmm0
pxor xmm2,xmm5
DB 102,15,56,0,193
add r9,16
pxor xmm0,xmm2
DB 102,15,56,0,220
add r11,16
pxor xmm3,xmm0
DB 102,15,56,0,193
and r11,0x30
sub rax,1
pxor xmm0,xmm3
$L$enc_entry:
movdqa xmm1,xmm9
movdqa xmm5,xmm11
pandn xmm1,xmm0
psrld xmm1,4
pand xmm0,xmm9
DB 102,15,56,0,232
movdqa xmm3,xmm10
pxor xmm0,xmm1
DB 102,15,56,0,217
movdqa xmm4,xmm10
pxor xmm3,xmm5
DB 102,15,56,0,224
movdqa xmm2,xmm10
pxor xmm4,xmm5
DB 102,15,56,0,211
movdqa xmm3,xmm10
pxor xmm2,xmm0
DB 102,15,56,0,220
movdqu xmm5,XMMWORD[r9]
pxor xmm3,xmm1
jnz NEAR $L$enc_loop
movdqa xmm4,XMMWORD[((-96))+r10]
movdqa xmm0,XMMWORD[((-80))+r10]
DB 102,15,56,0,226
pxor xmm4,xmm5
DB 102,15,56,0,195
movdqa xmm1,XMMWORD[64+r10*1+r11]
pxor xmm0,xmm4
DB 102,15,56,0,193
DB 0F3h,0C3h ;repret
ALIGN 16
_vpaes_encrypt_core_2x:
mov r9,rdx
mov r11,16
mov eax,DWORD[240+rdx]
movdqa xmm1,xmm9
movdqa xmm7,xmm9
movdqa xmm2,XMMWORD[$L$k_ipt]
movdqa xmm8,xmm2
pandn xmm1,xmm0
pandn xmm7,xmm6
movdqu xmm5,XMMWORD[r9]
psrld xmm1,4
psrld xmm7,4
pand xmm0,xmm9
pand xmm6,xmm9
DB 102,15,56,0,208
DB 102,68,15,56,0,198
movdqa xmm0,XMMWORD[(($L$k_ipt+16))]
movdqa xmm6,xmm0
DB 102,15,56,0,193
DB 102,15,56,0,247
pxor xmm2,xmm5
pxor xmm8,xmm5
add r9,16
pxor xmm0,xmm2
pxor xmm6,xmm8
lea r10,[$L$k_mc_backward]
jmp NEAR $L$enc2x_entry
ALIGN 16
$L$enc2x_loop:
movdqa xmm4,XMMWORD[$L$k_sb1]
movdqa xmm0,XMMWORD[(($L$k_sb1+16))]
movdqa xmm12,xmm4
movdqa xmm6,xmm0
DB 102,15,56,0,226
DB 102,69,15,56,0,224
DB 102,15,56,0,195
DB 102,65,15,56,0,243
pxor xmm4,xmm5
pxor xmm12,xmm5
movdqa xmm5,XMMWORD[$L$k_sb2]
movdqa xmm13,xmm5
pxor xmm0,xmm4
pxor xmm6,xmm12
movdqa xmm1,XMMWORD[((-64))+r10*1+r11]
DB 102,15,56,0,234
DB 102,69,15,56,0,232
movdqa xmm4,XMMWORD[r10*1+r11]
movdqa xmm2,XMMWORD[(($L$k_sb2+16))]
movdqa xmm8,xmm2
DB 102,15,56,0,211
DB 102,69,15,56,0,195
movdqa xmm3,xmm0
movdqa xmm11,xmm6
pxor xmm2,xmm5
pxor xmm8,xmm13
DB 102,15,56,0,193
DB 102,15,56,0,241
add r9,16
pxor xmm0,xmm2
pxor xmm6,xmm8
DB 102,15,56,0,220
DB 102,68,15,56,0,220
add r11,16
pxor xmm3,xmm0
pxor xmm11,xmm6
DB 102,15,56,0,193
DB 102,15,56,0,241
and r11,0x30
sub rax,1
pxor xmm0,xmm3
pxor xmm6,xmm11
$L$enc2x_entry:
movdqa xmm1,xmm9
movdqa xmm7,xmm9
movdqa xmm5,XMMWORD[(($L$k_inv+16))]
movdqa xmm13,xmm5
pandn xmm1,xmm0
pandn xmm7,xmm6
psrld xmm1,4
psrld xmm7,4
pand xmm0,xmm9
pand xmm6,xmm9
DB 102,15,56,0,232
DB 102,68,15,56,0,238
movdqa xmm3,xmm10
movdqa xmm11,xmm10
pxor xmm0,xmm1
pxor xmm6,xmm7
DB 102,15,56,0,217
DB 102,68,15,56,0,223
movdqa xmm4,xmm10
movdqa xmm12,xmm10
pxor xmm3,xmm5
pxor xmm11,xmm13
DB 102,15,56,0,224
DB 102,68,15,56,0,230
movdqa xmm2,xmm10
movdqa xmm8,xmm10
pxor xmm4,xmm5
pxor xmm12,xmm13
DB 102,15,56,0,211
DB 102,69,15,56,0,195
movdqa xmm3,xmm10
movdqa xmm11,xmm10
pxor xmm2,xmm0
pxor xmm8,xmm6
DB 102,15,56,0,220
DB 102,69,15,56,0,220
movdqu xmm5,XMMWORD[r9]
pxor xmm3,xmm1
pxor xmm11,xmm7
jnz NEAR $L$enc2x_loop
movdqa xmm4,XMMWORD[((-96))+r10]
movdqa xmm0,XMMWORD[((-80))+r10]
movdqa xmm12,xmm4
movdqa xmm6,xmm0
DB 102,15,56,0,226
DB 102,69,15,56,0,224
pxor xmm4,xmm5
pxor xmm12,xmm5
DB 102,15,56,0,195
DB 102,65,15,56,0,243
movdqa xmm1,XMMWORD[64+r10*1+r11]
pxor xmm0,xmm4
pxor xmm6,xmm12
DB 102,15,56,0,193
DB 102,15,56,0,241
DB 0F3h,0C3h ;repret
ALIGN 16
_vpaes_schedule_core:
call _vpaes_preheat
movdqa xmm8,XMMWORD[$L$k_rcon]
movdqu xmm0,XMMWORD[rdi]
movdqa xmm3,xmm0
lea r11,[$L$k_ipt]
call _vpaes_schedule_transform
movdqa xmm7,xmm0
lea r10,[$L$k_sr]
movdqu XMMWORD[rdx],xmm0
$L$schedule_go:
cmp esi,192
ja NEAR $L$schedule_256
$L$schedule_128:
mov esi,10
$L$oop_schedule_128:
call _vpaes_schedule_round
dec rsi
jz NEAR $L$schedule_mangle_last
call _vpaes_schedule_mangle
jmp NEAR $L$oop_schedule_128
ALIGN 16
$L$schedule_256:
movdqu xmm0,XMMWORD[16+rdi]
call _vpaes_schedule_transform
mov esi,7
$L$oop_schedule_256:
call _vpaes_schedule_mangle
movdqa xmm6,xmm0
call _vpaes_schedule_round
dec rsi
jz NEAR $L$schedule_mangle_last
call _vpaes_schedule_mangle
pshufd xmm0,xmm0,0xFF
movdqa xmm5,xmm7
movdqa xmm7,xmm6
call _vpaes_schedule_low_round
movdqa xmm7,xmm5
jmp NEAR $L$oop_schedule_256
ALIGN 16
$L$schedule_mangle_last:
lea r11,[$L$k_deskew]
movdqa xmm1,XMMWORD[r10*1+r8]
DB 102,15,56,0,193
lea r11,[$L$k_opt]
add rdx,32
$L$schedule_mangle_last_dec:
add rdx,-16
pxor xmm0,XMMWORD[$L$k_s63]
call _vpaes_schedule_transform
movdqu XMMWORD[rdx],xmm0
pxor xmm0,xmm0
pxor xmm1,xmm1
pxor xmm2,xmm2
pxor xmm3,xmm3
pxor xmm4,xmm4
pxor xmm5,xmm5
pxor xmm6,xmm6
pxor xmm7,xmm7
DB 0F3h,0C3h ;repret
ALIGN 16
_vpaes_schedule_round:
pxor xmm1,xmm1
DB 102,65,15,58,15,200,15
DB 102,69,15,58,15,192,15
pxor xmm7,xmm1
pshufd xmm0,xmm0,0xFF
DB 102,15,58,15,192,1
_vpaes_schedule_low_round:
movdqa xmm1,xmm7
pslldq xmm7,4
pxor xmm7,xmm1
movdqa xmm1,xmm7
pslldq xmm7,8
pxor xmm7,xmm1
pxor xmm7,XMMWORD[$L$k_s63]
movdqa xmm1,xmm9
pandn xmm1,xmm0
psrld xmm1,4
pand xmm0,xmm9
movdqa xmm2,xmm11
DB 102,15,56,0,208
pxor xmm0,xmm1
movdqa xmm3,xmm10
DB 102,15,56,0,217
pxor xmm3,xmm2
movdqa xmm4,xmm10
DB 102,15,56,0,224
pxor xmm4,xmm2
movdqa xmm2,xmm10
DB 102,15,56,0,211
pxor xmm2,xmm0
movdqa xmm3,xmm10
DB 102,15,56,0,220
pxor xmm3,xmm1
movdqa xmm4,xmm13
DB 102,15,56,0,226
movdqa xmm0,xmm12
DB 102,15,56,0,195
pxor xmm0,xmm4
pxor xmm0,xmm7
movdqa xmm7,xmm0
DB 0F3h,0C3h ;repret
ALIGN 16
_vpaes_schedule_transform:
movdqa xmm1,xmm9
pandn xmm1,xmm0
psrld xmm1,4
pand xmm0,xmm9
movdqa xmm2,XMMWORD[r11]
DB 102,15,56,0,208
movdqa xmm0,XMMWORD[16+r11]
DB 102,15,56,0,193
pxor xmm0,xmm2
DB 0F3h,0C3h ;repret
ALIGN 16
_vpaes_schedule_mangle:
movdqa xmm4,xmm0
movdqa xmm5,XMMWORD[$L$k_mc_forward]
add rdx,16
pxor xmm4,XMMWORD[$L$k_s63]
DB 102,15,56,0,229
movdqa xmm3,xmm4
DB 102,15,56,0,229
pxor xmm3,xmm4
DB 102,15,56,0,229
pxor xmm3,xmm4
$L$schedule_mangle_both:
movdqa xmm1,XMMWORD[r10*1+r8]
DB 102,15,56,0,217
add r8,-16
and r8,0x30
movdqu XMMWORD[rdx],xmm3
DB 0F3h,0C3h ;repret
global GFp_vpaes_set_encrypt_key
ALIGN 16
GFp_vpaes_set_encrypt_key:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_GFp_vpaes_set_encrypt_key:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
%ifdef BORINGSSL_DISPATCH_TEST
EXTERN BORINGSSL_function_hit
mov BYTE[((BORINGSSL_function_hit+5))],1
%endif
lea rsp,[((-184))+rsp]
movaps XMMWORD[16+rsp],xmm6
movaps XMMWORD[32+rsp],xmm7
movaps XMMWORD[48+rsp],xmm8
movaps XMMWORD[64+rsp],xmm9
movaps XMMWORD[80+rsp],xmm10
movaps XMMWORD[96+rsp],xmm11
movaps XMMWORD[112+rsp],xmm12
movaps XMMWORD[128+rsp],xmm13
movaps XMMWORD[144+rsp],xmm14
movaps XMMWORD[160+rsp],xmm15
$L$enc_key_body:
mov eax,esi
shr eax,5
add eax,5
mov DWORD[240+rdx],eax
mov ecx,0
mov r8d,0x30
call _vpaes_schedule_core
movaps xmm6,XMMWORD[16+rsp]
movaps xmm7,XMMWORD[32+rsp]
movaps xmm8,XMMWORD[48+rsp]
movaps xmm9,XMMWORD[64+rsp]
movaps xmm10,XMMWORD[80+rsp]
movaps xmm11,XMMWORD[96+rsp]
movaps xmm12,XMMWORD[112+rsp]
movaps xmm13,XMMWORD[128+rsp]
movaps xmm14,XMMWORD[144+rsp]
movaps xmm15,XMMWORD[160+rsp]
lea rsp,[184+rsp]
$L$enc_key_epilogue:
xor eax,eax
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_GFp_vpaes_set_encrypt_key:
global GFp_vpaes_encrypt
ALIGN 16
GFp_vpaes_encrypt:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_GFp_vpaes_encrypt:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
lea rsp,[((-184))+rsp]
movaps XMMWORD[16+rsp],xmm6
movaps XMMWORD[32+rsp],xmm7
movaps XMMWORD[48+rsp],xmm8
movaps XMMWORD[64+rsp],xmm9
movaps XMMWORD[80+rsp],xmm10
movaps XMMWORD[96+rsp],xmm11
movaps XMMWORD[112+rsp],xmm12
movaps XMMWORD[128+rsp],xmm13
movaps XMMWORD[144+rsp],xmm14
movaps XMMWORD[160+rsp],xmm15
$L$enc_body:
movdqu xmm0,XMMWORD[rdi]
call _vpaes_preheat
call _vpaes_encrypt_core
movdqu XMMWORD[rsi],xmm0
movaps xmm6,XMMWORD[16+rsp]
movaps xmm7,XMMWORD[32+rsp]
movaps xmm8,XMMWORD[48+rsp]
movaps xmm9,XMMWORD[64+rsp]
movaps xmm10,XMMWORD[80+rsp]
movaps xmm11,XMMWORD[96+rsp]
movaps xmm12,XMMWORD[112+rsp]
movaps xmm13,XMMWORD[128+rsp]
movaps xmm14,XMMWORD[144+rsp]
movaps xmm15,XMMWORD[160+rsp]
lea rsp,[184+rsp]
$L$enc_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_GFp_vpaes_encrypt:
global GFp_vpaes_ctr32_encrypt_blocks
ALIGN 16
GFp_vpaes_ctr32_encrypt_blocks:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_GFp_vpaes_ctr32_encrypt_blocks:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
xchg rdx,rcx
test rcx,rcx
jz NEAR $L$ctr32_abort
lea rsp,[((-184))+rsp]
movaps XMMWORD[16+rsp],xmm6
movaps XMMWORD[32+rsp],xmm7
movaps XMMWORD[48+rsp],xmm8
movaps XMMWORD[64+rsp],xmm9
movaps XMMWORD[80+rsp],xmm10
movaps XMMWORD[96+rsp],xmm11
movaps XMMWORD[112+rsp],xmm12
movaps XMMWORD[128+rsp],xmm13
movaps XMMWORD[144+rsp],xmm14
movaps XMMWORD[160+rsp],xmm15
$L$ctr32_body:
movdqu xmm0,XMMWORD[r8]
movdqa xmm8,XMMWORD[$L$ctr_add_one]
sub rsi,rdi
call _vpaes_preheat
movdqa xmm6,xmm0
pshufb xmm6,XMMWORD[$L$rev_ctr]
test rcx,1
jz NEAR $L$ctr32_prep_loop
movdqu xmm7,XMMWORD[rdi]
call _vpaes_encrypt_core
pxor xmm0,xmm7
paddd xmm6,xmm8
movdqu XMMWORD[rdi*1+rsi],xmm0
sub rcx,1
lea rdi,[16+rdi]
jz NEAR $L$ctr32_done
$L$ctr32_prep_loop:
movdqa xmm14,xmm6
movdqa xmm15,xmm6
paddd xmm15,xmm8
$L$ctr32_loop:
movdqa xmm1,XMMWORD[$L$rev_ctr]
movdqa xmm0,xmm14
movdqa xmm6,xmm15
DB 102,15,56,0,193
DB 102,15,56,0,241
call _vpaes_encrypt_core_2x
movdqu xmm1,XMMWORD[rdi]
movdqu xmm2,XMMWORD[16+rdi]
movdqa xmm3,XMMWORD[$L$ctr_add_two]
pxor xmm0,xmm1
pxor xmm6,xmm2
paddd xmm14,xmm3
paddd xmm15,xmm3
movdqu XMMWORD[rdi*1+rsi],xmm0
movdqu XMMWORD[16+rdi*1+rsi],xmm6
sub rcx,2
lea rdi,[32+rdi]
jnz NEAR $L$ctr32_loop
$L$ctr32_done:
movaps xmm6,XMMWORD[16+rsp]
movaps xmm7,XMMWORD[32+rsp]
movaps xmm8,XMMWORD[48+rsp]
movaps xmm9,XMMWORD[64+rsp]
movaps xmm10,XMMWORD[80+rsp]
movaps xmm11,XMMWORD[96+rsp]
movaps xmm12,XMMWORD[112+rsp]
movaps xmm13,XMMWORD[128+rsp]
movaps xmm14,XMMWORD[144+rsp]
movaps xmm15,XMMWORD[160+rsp]
lea rsp,[184+rsp]
$L$ctr32_epilogue:
$L$ctr32_abort:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_GFp_vpaes_ctr32_encrypt_blocks:
ALIGN 16
_vpaes_preheat:
lea r10,[$L$k_s0F]
movdqa xmm10,XMMWORD[((-32))+r10]
movdqa xmm11,XMMWORD[((-16))+r10]
movdqa xmm9,XMMWORD[r10]
movdqa xmm13,XMMWORD[48+r10]
movdqa xmm12,XMMWORD[64+r10]
movdqa xmm15,XMMWORD[80+r10]
movdqa xmm14,XMMWORD[96+r10]
DB 0F3h,0C3h ;repret
ALIGN 64
_vpaes_consts:
$L$k_inv:
DQ 0x0E05060F0D080180,0x040703090A0B0C02
DQ 0x01040A060F0B0780,0x030D0E0C02050809
$L$k_s0F:
DQ 0x0F0F0F0F0F0F0F0F,0x0F0F0F0F0F0F0F0F
$L$k_ipt:
DQ 0xC2B2E8985A2A7000,0xCABAE09052227808
DQ 0x4C01307D317C4D00,0xCD80B1FCB0FDCC81
$L$k_sb1:
DQ 0xB19BE18FCB503E00,0xA5DF7A6E142AF544
DQ 0x3618D415FAE22300,0x3BF7CCC10D2ED9EF
$L$k_sb2:
DQ 0xE27A93C60B712400,0x5EB7E955BC982FCD
DQ 0x69EB88400AE12900,0xC2A163C8AB82234A
$L$k_sbo:
DQ 0xD0D26D176FBDC700,0x15AABF7AC502A878
DQ 0xCFE474A55FBB6A00,0x8E1E90D1412B35FA
$L$k_mc_forward:
DQ 0x0407060500030201,0x0C0F0E0D080B0A09
DQ 0x080B0A0904070605,0x000302010C0F0E0D
DQ 0x0C0F0E0D080B0A09,0x0407060500030201
DQ 0x000302010C0F0E0D,0x080B0A0904070605
$L$k_mc_backward:
DQ 0x0605040702010003,0x0E0D0C0F0A09080B
DQ 0x020100030E0D0C0F,0x0A09080B06050407
DQ 0x0E0D0C0F0A09080B,0x0605040702010003
DQ 0x0A09080B06050407,0x020100030E0D0C0F
$L$k_sr:
DQ 0x0706050403020100,0x0F0E0D0C0B0A0908
DQ 0x030E09040F0A0500,0x0B06010C07020D08
DQ 0x0F060D040B020900,0x070E050C030A0108
DQ 0x0B0E0104070A0D00,0x0306090C0F020508
$L$k_rcon:
DQ 0x1F8391B9AF9DEEB6,0x702A98084D7C7D81
$L$k_s63:
DQ 0x5B5B5B5B5B5B5B5B,0x5B5B5B5B5B5B5B5B
$L$k_opt:
DQ 0xFF9F4929D6B66000,0xF7974121DEBE6808
DQ 0x01EDBD5150BCEC00,0xE10D5DB1B05C0CE0
$L$k_deskew:
DQ 0x07E4A34047A4E300,0x1DFEB95A5DBEF91A
DQ 0x5F36B5DC83EA6900,0x2841C2ABF49D1E77
$L$rev_ctr:
DQ 0x0706050403020100,0x0c0d0e0f0b0a0908
$L$ctr_add_one:
DQ 0x0000000000000000,0x0000000100000000
$L$ctr_add_two:
DQ 0x0000000000000000,0x0000000200000000
DB 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105
DB 111,110,32,65,69,83,32,102,111,114,32,120,56,54,95,54
DB 52,47,83,83,83,69,51,44,32,77,105,107,101,32,72,97
DB 109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32
DB 85,110,105,118,101,114,115,105,116,121,41,0
ALIGN 64
EXTERN __imp_RtlVirtualUnwind
ALIGN 16
se_handler:
push rsi
push rdi
push rbx
push rbp
push r12
push r13
push r14
push r15
pushfq
sub rsp,64
mov rax,QWORD[120+r8]
mov rbx,QWORD[248+r8]
mov rsi,QWORD[8+r9]
mov r11,QWORD[56+r9]
mov r10d,DWORD[r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
jb NEAR $L$in_prologue
mov rax,QWORD[152+r8]
mov r10d,DWORD[4+r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
jae NEAR $L$in_prologue
lea rsi,[16+rax]
lea rdi,[512+r8]
mov ecx,20
DD 0xa548f3fc
lea rax,[184+rax]
$L$in_prologue:
mov rdi,QWORD[8+rax]
mov rsi,QWORD[16+rax]
mov QWORD[152+r8],rax
mov QWORD[168+r8],rsi
mov QWORD[176+r8],rdi
mov rdi,QWORD[40+r9]
mov rsi,r8
mov ecx,154
DD 0xa548f3fc
mov rsi,r9
xor rcx,rcx
mov rdx,QWORD[8+rsi]
mov r8,QWORD[rsi]
mov r9,QWORD[16+rsi]
mov r10,QWORD[40+rsi]
lea r11,[56+rsi]
lea r12,[24+rsi]
mov QWORD[32+rsp],r10
mov QWORD[40+rsp],r11
mov QWORD[48+rsp],r12
mov QWORD[56+rsp],rcx
call QWORD[__imp_RtlVirtualUnwind]
mov eax,1
add rsp,64
popfq
pop r15
pop r14
pop r13
pop r12
pop rbp
pop rbx
pop rdi
pop rsi
DB 0F3h,0C3h ;repret
section .pdata rdata align=4
ALIGN 4
DD $L$SEH_begin_GFp_vpaes_set_encrypt_key wrt ..imagebase
DD $L$SEH_end_GFp_vpaes_set_encrypt_key wrt ..imagebase
DD $L$SEH_info_GFp_vpaes_set_encrypt_key wrt ..imagebase
DD $L$SEH_begin_GFp_vpaes_encrypt wrt ..imagebase
DD $L$SEH_end_GFp_vpaes_encrypt wrt ..imagebase
DD $L$SEH_info_GFp_vpaes_encrypt wrt ..imagebase
DD $L$SEH_begin_GFp_vpaes_ctr32_encrypt_blocks wrt ..imagebase
DD $L$SEH_end_GFp_vpaes_ctr32_encrypt_blocks wrt ..imagebase
DD $L$SEH_info_GFp_vpaes_ctr32_encrypt_blocks wrt ..imagebase
section .xdata rdata align=8
ALIGN 8
$L$SEH_info_GFp_vpaes_set_encrypt_key:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$enc_key_body wrt ..imagebase,$L$enc_key_epilogue wrt ..imagebase
$L$SEH_info_GFp_vpaes_encrypt:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$enc_body wrt ..imagebase,$L$enc_epilogue wrt ..imagebase
$L$SEH_info_GFp_vpaes_ctr32_encrypt_blocks:
DB 9,0,0,0
DD se_handler wrt ..imagebase
DD $L$ctr32_body wrt ..imagebase,$L$ctr32_epilogue wrt ..imagebase

View File

@ -0,0 +1,227 @@
; This file is generated from a similarly-named Perl script in the BoringSSL
; source tree. Do not edit by hand.
%ifdef BORINGSSL_PREFIX
%include "boringssl_prefix_symbols_nasm.inc"
%endif
%ifidn __OUTPUT_FORMAT__,obj
section code use32 class=code align=64
%elifidn __OUTPUT_FORMAT__,win32
$@feat.00 equ 1
section .text code align=64
%else
section .text code
%endif
;extern _GFp_ia32cap_P
global _GFp_bn_mul_mont
align 16
_GFp_bn_mul_mont:
L$_GFp_bn_mul_mont_begin:
push ebp
push ebx
push esi
push edi
xor eax,eax
mov edi,DWORD [40+esp]
lea esi,[20+esp]
lea edx,[24+esp]
add edi,2
neg edi
lea ebp,[edi*4+esp-32]
neg edi
mov eax,ebp
sub eax,edx
and eax,2047
sub ebp,eax
xor edx,ebp
and edx,2048
xor edx,2048
sub ebp,edx
and ebp,-64
mov eax,esp
sub eax,ebp
and eax,-4096
mov edx,esp
lea esp,[eax*1+ebp]
mov eax,DWORD [esp]
cmp esp,ebp
ja NEAR L$000page_walk
jmp NEAR L$001page_walk_done
align 16
L$000page_walk:
lea esp,[esp-4096]
mov eax,DWORD [esp]
cmp esp,ebp
ja NEAR L$000page_walk
L$001page_walk_done:
mov eax,DWORD [esi]
mov ebx,DWORD [4+esi]
mov ecx,DWORD [8+esi]
mov ebp,DWORD [12+esi]
mov esi,DWORD [16+esi]
mov esi,DWORD [esi]
mov DWORD [4+esp],eax
mov DWORD [8+esp],ebx
mov DWORD [12+esp],ecx
mov DWORD [16+esp],ebp
mov DWORD [20+esp],esi
lea ebx,[edi-3]
mov DWORD [24+esp],edx
lea eax,[_GFp_ia32cap_P]
bt DWORD [eax],26
mov eax,-1
movd mm7,eax
mov esi,DWORD [8+esp]
mov edi,DWORD [12+esp]
mov ebp,DWORD [16+esp]
xor edx,edx
xor ecx,ecx
movd mm4,DWORD [edi]
movd mm5,DWORD [esi]
movd mm3,DWORD [ebp]
pmuludq mm5,mm4
movq mm2,mm5
movq mm0,mm5
pand mm0,mm7
pmuludq mm5,[20+esp]
pmuludq mm3,mm5
paddq mm3,mm0
movd mm1,DWORD [4+ebp]
movd mm0,DWORD [4+esi]
psrlq mm2,32
psrlq mm3,32
inc ecx
align 16
L$0021st:
pmuludq mm0,mm4
pmuludq mm1,mm5
paddq mm2,mm0
paddq mm3,mm1
movq mm0,mm2
pand mm0,mm7
movd mm1,DWORD [4+ecx*4+ebp]
paddq mm3,mm0
movd mm0,DWORD [4+ecx*4+esi]
psrlq mm2,32
movd DWORD [28+ecx*4+esp],mm3
psrlq mm3,32
lea ecx,[1+ecx]
cmp ecx,ebx
jl NEAR L$0021st
pmuludq mm0,mm4
pmuludq mm1,mm5
paddq mm2,mm0
paddq mm3,mm1
movq mm0,mm2
pand mm0,mm7
paddq mm3,mm0
movd DWORD [28+ecx*4+esp],mm3
psrlq mm2,32
psrlq mm3,32
paddq mm3,mm2
movq [32+ebx*4+esp],mm3
inc edx
L$003outer:
xor ecx,ecx
movd mm4,DWORD [edx*4+edi]
movd mm5,DWORD [esi]
movd mm6,DWORD [32+esp]
movd mm3,DWORD [ebp]
pmuludq mm5,mm4
paddq mm5,mm6
movq mm0,mm5
movq mm2,mm5
pand mm0,mm7
pmuludq mm5,[20+esp]
pmuludq mm3,mm5
paddq mm3,mm0
movd mm6,DWORD [36+esp]
movd mm1,DWORD [4+ebp]
movd mm0,DWORD [4+esi]
psrlq mm2,32
psrlq mm3,32
paddq mm2,mm6
inc ecx
dec ebx
L$004inner:
pmuludq mm0,mm4
pmuludq mm1,mm5
paddq mm2,mm0
paddq mm3,mm1
movq mm0,mm2
movd mm6,DWORD [36+ecx*4+esp]
pand mm0,mm7
movd mm1,DWORD [4+ecx*4+ebp]
paddq mm3,mm0
movd mm0,DWORD [4+ecx*4+esi]
psrlq mm2,32
movd DWORD [28+ecx*4+esp],mm3
psrlq mm3,32
paddq mm2,mm6
dec ebx
lea ecx,[1+ecx]
jnz NEAR L$004inner
mov ebx,ecx
pmuludq mm0,mm4
pmuludq mm1,mm5
paddq mm2,mm0
paddq mm3,mm1
movq mm0,mm2
pand mm0,mm7
paddq mm3,mm0
movd DWORD [28+ecx*4+esp],mm3
psrlq mm2,32
psrlq mm3,32
movd mm6,DWORD [36+ebx*4+esp]
paddq mm3,mm2
paddq mm3,mm6
movq [32+ebx*4+esp],mm3
lea edx,[1+edx]
cmp edx,ebx
jle NEAR L$003outer
emms
align 16
L$005common_tail:
mov ebp,DWORD [16+esp]
mov edi,DWORD [4+esp]
lea esi,[32+esp]
mov eax,DWORD [esi]
mov ecx,ebx
xor edx,edx
align 16
L$006sub:
sbb eax,DWORD [edx*4+ebp]
mov DWORD [edx*4+edi],eax
dec ecx
mov eax,DWORD [4+edx*4+esi]
lea edx,[1+edx]
jge NEAR L$006sub
sbb eax,0
mov edx,-1
xor edx,eax
jmp NEAR L$007copy
align 16
L$007copy:
mov esi,DWORD [32+ebx*4+esp]
mov ebp,DWORD [ebx*4+edi]
mov DWORD [32+ebx*4+esp],ecx
and esi,eax
and ebp,edx
or ebp,esi
mov DWORD [ebx*4+edi],ebp
dec ebx
jge NEAR L$007copy
mov esp,DWORD [24+esp]
mov eax,1
pop edi
pop esi
pop ebx
pop ebp
ret
db 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105
db 112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56
db 54,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121
db 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46
db 111,114,103,62,0
segment .bss
common _GFp_ia32cap_P 16

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
{"files":{"CHANGELOG.md":"1d82f1ac1540d9606314c56d1701d10fff72688b0bf458398846fa837a6b8209","Cargo.toml":"c924c5dd3ad8b58b4d65ec40f10a44b5352f89145c419d82dab9c647b5d363f3","LICENSE":"898b1ae9821e98daf8964c8d6c7f61641f5f5aa78ad500020771c0939ee0dea1","README.md":"39a30e68fd06cd90cdf232fb87cba82168797c9861739e9529fee68e72c26868","benches/global_subscriber.rs":"271213baed0e02054e506c1ec9c47b58696c78aaa46f0969a147f4c369f80e3d","benches/no_subscriber.rs":"495c9a91fb972ec61ced31ef8e19d2cca02ec8ffae4e98e3316e55f6a0074578","benches/subscriber.rs":"c609be119ed6e4d3fb79df77f15aa14effbd3e2f77c627a49229a50091d3ee6a","src/dispatcher.rs":"5732b1f228328cd41e77b04a27faf3b6054a8ed5cd5034a0dad8e1e694ca3889","src/field.rs":"55c7a2798b9ad0269e7c738c3f15a5d0281bf34ac3a6196a3f0b15801e5278bd","src/instrument.rs":"1fe4de5c13b5ba048e9872d78d1fa4e85655f9f2ed10f79b72b5da881c9b8b45","src/level_filters.rs":"baae8e797897bae9cdd9ec64b8e9a3d71156e9c03261be17b5b18acba034e154","src/lib.rs":"c794108f5f37b5dc1609498afad5ebbb25ad5f80bf9e362c032a63d327429937","src/macros.rs":"1bf35f17cbb50fb92f60e5e60190faf5eeba03c328f754631fff6df183509491","src/span.rs":"e7c16999e8702bf1ff82aaa6803c81ac5b77ab96b754cac6e686acfc6adc14f9","src/stdlib.rs":"248514a9bae6106e436358aee44c92abf8e7f79022895c4a25136ddef211d198","src/subscriber.rs":"ae879c373be7ee4935f7b02a345f92ccbeb7879d61c5d37e3cc1277b3d51ddb2","tests/enabled.rs":"1333339aace87ea9d701f2f76a1985820cc513a75013a7ed89669f7a2c635479","tests/event.rs":"c4ec3ac338475e9e61675551eb99df1d8a7cbefb05a0d60203994f5c1df7c784","tests/filter_caching_is_lexically_scoped.rs":"5487a37db5fbdf3d57020ab1f01185d928c45d967d99d723ffc434540459d8dc","tests/filters_are_not_reevaluated_for_the_same_span.rs":"251abbc000dddd298448958a1f0e5be71da527ac6c1a368d57837c83a5467329","tests/filters_are_reevaluated_for_different_call_sites.rs":"e0fdd8e930c043674702831b4d96f331e63aba824576bbac50b3f53bb0241cc7","tests/filters_dont_leak.rs":"d594266818a3461886da33bfcc76937d89a433ed6980226fc428706b216c093c","tests/future_send.rs":"3e9c9193219d12e342c18bbedb2f6ec940334202feb3cffba91601d6001b8575","tests/macro_imports.rs":"d5de857162185d4a2384f3cb644bfcf76c7f5c1a3b5f72bfa0d2620ac6e3873c","tests/macros.rs":"fa83397181d73d2cae09c16d9647a63d1e3bad0f2dbc5b3280f69f3d0180c488","tests/macros_incompatible_concat.rs":"5f3bcbb65e4ae39db1cfc2def62fc913c20bab0fb769c8f731504e2615585ee5","tests/macros_redefined_core.rs":"a6eac60522f71fe6c9a040b8b869d596f7eb9e907f5b49f4be4413a40c387676","tests/max_level_hint.rs":"9b366591d947ca0202fa0bdf797e1bb14534d3c896cf8b9674660cd2807c32ef","tests/multiple_max_level_hints.rs":"4d9ef0de9cccc787da8f5e3f6c233ac9db42a2a99cfe5e39997e1f4aa9df0c00","tests/no_subscriber.rs":"2f8f2ada5089d8e2e503394dfe8206598a11895907c53bf940b892f1e6afdd2f","tests/scoped_clobbers_default.rs":"806480a74c15e4d68bb7576050662b1e53ee765fd583d003f8b349f17ea63a4b","tests/span.rs":"f84ead5b1dad9b91e5cec9d8378ab932a942936374ba928fb381e67fab52cda0","tests/subscriber.rs":"1617c098f4fa6abed174fe062111444c7b67fa0f377d2b342176998e572480e3"},"package":"5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09"}
{"files":{"CHANGELOG.md":"7d5517e1ac705d5d8574915b59a37bbd0ba5aa6e663fc272b75e5792eca572a9","Cargo.toml":"f6290faffd0bf079845dbd6c3c1ddb6c728bcf7225e3b56a4ba5a9478dc72a8b","LICENSE":"898b1ae9821e98daf8964c8d6c7f61641f5f5aa78ad500020771c0939ee0dea1","README.md":"a83e1a8287e3eca752383ae849872707dddfbd07b918806cc7c027a0824872c6","benches/global_subscriber.rs":"271213baed0e02054e506c1ec9c47b58696c78aaa46f0969a147f4c369f80e3d","benches/no_subscriber.rs":"495c9a91fb972ec61ced31ef8e19d2cca02ec8ffae4e98e3316e55f6a0074578","benches/subscriber.rs":"c609be119ed6e4d3fb79df77f15aa14effbd3e2f77c627a49229a50091d3ee6a","src/dispatcher.rs":"a8158e1901c50dc83d2f15b1773e6b9e31985d9af65e460be52dbf8be6874cd2","src/field.rs":"55c7a2798b9ad0269e7c738c3f15a5d0281bf34ac3a6196a3f0b15801e5278bd","src/instrument.rs":"1fe4de5c13b5ba048e9872d78d1fa4e85655f9f2ed10f79b72b5da881c9b8b45","src/level_filters.rs":"baae8e797897bae9cdd9ec64b8e9a3d71156e9c03261be17b5b18acba034e154","src/lib.rs":"a8ab6b578f93b5fb833942fc59642e67caca8d343670d64fb52d47d5507a67e4","src/macros.rs":"f1a83930cea322f1f2000548d91800c22a9e28d2daf3f178c7c7c3ac8da5a02d","src/span.rs":"96b6c86be09c97b15b2ab5c607013abc5b388c2870eb648bee2cfc07837fa6e9","src/stdlib.rs":"248514a9bae6106e436358aee44c92abf8e7f79022895c4a25136ddef211d198","src/subscriber.rs":"ae879c373be7ee4935f7b02a345f92ccbeb7879d61c5d37e3cc1277b3d51ddb2","tests/enabled.rs":"1333339aace87ea9d701f2f76a1985820cc513a75013a7ed89669f7a2c635479","tests/event.rs":"c4ec3ac338475e9e61675551eb99df1d8a7cbefb05a0d60203994f5c1df7c784","tests/filter_caching_is_lexically_scoped.rs":"5487a37db5fbdf3d57020ab1f01185d928c45d967d99d723ffc434540459d8dc","tests/filters_are_not_reevaluated_for_the_same_span.rs":"251abbc000dddd298448958a1f0e5be71da527ac6c1a368d57837c83a5467329","tests/filters_are_reevaluated_for_different_call_sites.rs":"e0fdd8e930c043674702831b4d96f331e63aba824576bbac50b3f53bb0241cc7","tests/filters_dont_leak.rs":"d594266818a3461886da33bfcc76937d89a433ed6980226fc428706b216c093c","tests/future_send.rs":"3e9c9193219d12e342c18bbedb2f6ec940334202feb3cffba91601d6001b8575","tests/macro_imports.rs":"d5de857162185d4a2384f3cb644bfcf76c7f5c1a3b5f72bfa0d2620ac6e3873c","tests/macros.rs":"fa83397181d73d2cae09c16d9647a63d1e3bad0f2dbc5b3280f69f3d0180c488","tests/macros_incompatible_concat.rs":"5f3bcbb65e4ae39db1cfc2def62fc913c20bab0fb769c8f731504e2615585ee5","tests/macros_redefined_core.rs":"a6eac60522f71fe6c9a040b8b869d596f7eb9e907f5b49f4be4413a40c387676","tests/max_level_hint.rs":"9b366591d947ca0202fa0bdf797e1bb14534d3c896cf8b9674660cd2807c32ef","tests/multiple_max_level_hints.rs":"4d9ef0de9cccc787da8f5e3f6c233ac9db42a2a99cfe5e39997e1f4aa9df0c00","tests/no_subscriber.rs":"2f8f2ada5089d8e2e503394dfe8206598a11895907c53bf940b892f1e6afdd2f","tests/register_callsite_deadlock.rs":"c0b3142543e7a10065c7583a8ee0b6bc978ea4f3979599651101c5a28966e7c8","tests/scoped_clobbers_default.rs":"806480a74c15e4d68bb7576050662b1e53ee765fd583d003f8b349f17ea63a4b","tests/span.rs":"f84ead5b1dad9b91e5cec9d8378ab932a942936374ba928fb381e67fab52cda0","tests/subscriber.rs":"1617c098f4fa6abed174fe062111444c7b67fa0f377d2b342176998e572480e3"},"package":"a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160"}

View File

@ -1,3 +1,19 @@
# 0.1.35 (June 8, 2022)
This release reduces the overhead of callsite registration by using new
`tracing-core` APIs.
### Added
- Use `DefaultCallsite` to reduce callsite registration overhead ([#2083])
### Changed
- `tracing-core`: updated to [0.1.27][core-0.1.27]
[core-0.1.27]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.27
[#2088]: https://github.com/tokio-rs/tracing/pull/2083
# 0.1.34 (April 14, 2022)
This release includes bug fixes for the "log" support feature and for the use of

View File

@ -13,7 +13,7 @@
edition = "2018"
rust-version = "1.49.0"
name = "tracing"
version = "0.1.34"
version = "0.1.35"
authors = [
"Eliza Weisman <eliza@buoyant.io>",
"Tokio Contributors <team@tokio.rs>",
@ -74,7 +74,7 @@ version = "0.1.20"
optional = true
[dependencies.tracing-core]
version = "0.1.22"
version = "0.1.27"
default-features = false
[dev-dependencies.criterion]

View File

@ -16,9 +16,9 @@ Application-level tracing for Rust.
[Documentation][docs-url] | [Chat][discord-url]
[crates-badge]: https://img.shields.io/crates/v/tracing.svg
[crates-url]: https://crates.io/crates/tracing/0.1.34
[crates-url]: https://crates.io/crates/tracing/0.1.35
[docs-badge]: https://docs.rs/tracing/badge.svg
[docs-url]: https://docs.rs/tracing/0.1.34
[docs-url]: https://docs.rs/tracing/0.1.35
[docs-master-badge]: https://img.shields.io/badge/docs-master-blue
[docs-master-url]: https://tracing-rs.netlify.com/tracing
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
@ -250,7 +250,7 @@ my_future
is as long as the future's.
The second, and preferred, option is through the
[`#[instrument]`](https://docs.rs/tracing/0.1.34/tracing/attr.instrument.html)
[`#[instrument]`](https://docs.rs/tracing/0.1.35/tracing/attr.instrument.html)
attribute:
```rust
@ -297,7 +297,7 @@ span.in_scope(|| {
// Dropping the span will close it, indicating that it has ended.
```
The [`#[instrument]`](https://docs.rs/tracing/0.1.34/tracing/attr.instrument.html) attribute macro
The [`#[instrument]`](https://docs.rs/tracing/0.1.35/tracing/attr.instrument.html) attribute macro
can reduce some of this boilerplate:
```rust

View File

@ -123,10 +123,6 @@
//! instrumentation.
//!
//! [`Subscriber`]: crate::Subscriber
//! [`with_default`]: with_default
//! [`set_global_default`]: set_global_default
//! [`get_default`]: get_default
//! [`Dispatch`]: Dispatch
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub use tracing_core::dispatcher::set_default;

View File

@ -119,8 +119,6 @@
//! tracing = "0.1"
//! ```
//!
//! *Compiler support: [requires `rustc` 1.42+][msrv]*
//!
//! ## Recording Spans and Events
//!
//! Spans and events are recorded using macros.
@ -437,9 +435,9 @@
//! [target]: Metadata::target
//! [parent span]: span::Attributes::parent
//! [determined contextually]: span::Attributes::is_contextual
//! [`fmt::Debug`]: https://doc.rust-lang.org/std/fmt/trait.Debug.html
//! [`fmt::Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html
//! [fmt]: https://doc.rust-lang.org/std/fmt/#usage
//! [`fmt::Debug`]: std::fmt::Debug
//! [`fmt::Display`]: std::fmt::Display
//! [fmt]: std::fmt#usage
//! [`Empty`]: field::Empty
//!
//! ### Shorthand Macros
@ -466,7 +464,6 @@
//! [`info_span!`]: info_span!
//! [`warn_span!`]: warn_span!
//! [`error_span!`]: error_span!
//! [`Level`]: Level
//!
//! ### For `log` Users
//!
@ -812,7 +809,7 @@
//!
//! ```toml
//! [dependencies]
//! tracing = { version = "0.1.34", default-features = false }
//! tracing = { version = "0.1.35", default-features = false }
//! ```
//!
//! <pre class="ignore" style="white-space:normal;font:inherit;">
@ -895,7 +892,7 @@
//! [flags]: #crate-feature-flags
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg), deny(rustdoc::broken_intra_doc_links))]
#![doc(html_root_url = "https://docs.rs/tracing/0.1.34")]
#![doc(html_root_url = "https://docs.rs/tracing/0.1.35")]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
@ -968,13 +965,8 @@ pub mod subscriber;
#[doc(hidden)]
pub mod __macro_support {
pub use crate::callsite::Callsite;
use crate::stdlib::{
fmt,
sync::atomic::{AtomicUsize, Ordering},
};
use crate::{subscriber::Interest, Metadata};
pub use core::concat;
use tracing_core::Once;
/// Callsite implementation used by macro-generated code.
///
@ -984,138 +976,70 @@ pub mod __macro_support {
/// by the `tracing` macros, but it is not part of the stable versioned API.
/// Breaking changes to this module may occur in small-numbered versions
/// without warning.
pub struct MacroCallsite {
interest: AtomicUsize,
meta: &'static Metadata<'static>,
registration: Once,
pub use tracing_core::callsite::DefaultCallsite as MacroCallsite;
/// /!\ WARNING: This is *not* a stable API! /!\
/// This function, and all code contained in the `__macro_support` module, is
/// a *private* API of `tracing`. It is exposed publicly because it is used
/// by the `tracing` macros, but it is not part of the stable versioned API.
/// Breaking changes to this module may occur in small-numbered versions
/// without warning.
pub fn __is_enabled(meta: &Metadata<'static>, interest: Interest) -> bool {
interest.is_always() || crate::dispatcher::get_default(|default| default.enabled(meta))
}
impl MacroCallsite {
/// Returns a new `MacroCallsite` with the specified `Metadata`.
///
/// /!\ WARNING: This is *not* a stable API! /!\
/// This method, and all code contained in the `__macro_support` module, is
/// a *private* API of `tracing`. It is exposed publicly because it is used
/// by the `tracing` macros, but it is not part of the stable versioned API.
/// Breaking changes to this module may occur in small-numbered versions
/// without warning.
pub const fn new(meta: &'static Metadata<'static>) -> Self {
Self {
interest: AtomicUsize::new(0xDEAD),
meta,
registration: Once::new(),
}
}
/// Registers this callsite with the global callsite registry.
///
/// If the callsite is already registered, this does nothing.
///
/// /!\ WARNING: This is *not* a stable API! /!\
/// This method, and all code contained in the `__macro_support` module, is
/// a *private* API of `tracing`. It is exposed publicly because it is used
/// by the `tracing` macros, but it is not part of the stable versioned API.
/// Breaking changes to this module may occur in small-numbered versions
/// without warning.
#[inline(never)]
// This only happens once (or if the cached interest value was corrupted).
#[cold]
pub fn register(&'static self) -> Interest {
self.registration
.call_once(|| crate::callsite::register(self));
match self.interest.load(Ordering::Relaxed) {
0 => Interest::never(),
2 => Interest::always(),
_ => Interest::sometimes(),
}
}
/// Returns the callsite's cached Interest, or registers it for the
/// first time if it has not yet been registered.
///
/// /!\ WARNING: This is *not* a stable API! /!\
/// This method, and all code contained in the `__macro_support` module, is
/// a *private* API of `tracing`. It is exposed publicly because it is used
/// by the `tracing` macros, but it is not part of the stable versioned API.
/// Breaking changes to this module may occur in small-numbered versions
/// without warning.
#[inline]
pub fn interest(&'static self) -> Interest {
match self.interest.load(Ordering::Relaxed) {
0 => Interest::never(),
1 => Interest::sometimes(),
2 => Interest::always(),
_ => self.register(),
}
}
pub fn is_enabled(&self, interest: Interest) -> bool {
interest.is_always()
|| crate::dispatcher::get_default(|default| default.enabled(self.meta))
}
#[inline]
#[cfg(feature = "log")]
pub fn disabled_span(&self) -> crate::Span {
crate::Span::new_disabled(self.meta)
}
#[inline]
#[cfg(not(feature = "log"))]
pub fn disabled_span(&self) -> crate::Span {
crate::Span::none()
}
#[cfg(feature = "log")]
pub fn log(
&self,
logger: &'static dyn log::Log,
log_meta: log::Metadata<'_>,
values: &tracing_core::field::ValueSet<'_>,
) {
let meta = self.metadata();
logger.log(
&crate::log::Record::builder()
.file(meta.file())
.module_path(meta.module_path())
.line(meta.line())
.metadata(log_meta)
.args(format_args!(
"{}",
crate::log::LogValueSet {
values,
is_first: true
}
))
.build(),
);
}
/// /!\ WARNING: This is *not* a stable API! /!\
/// This function, and all code contained in the `__macro_support` module, is
/// a *private* API of `tracing`. It is exposed publicly because it is used
/// by the `tracing` macros, but it is not part of the stable versioned API.
/// Breaking changes to this module may occur in small-numbered versions
/// without warning.
#[inline]
#[cfg(feature = "log")]
pub fn __disabled_span(meta: &'static Metadata<'static>) -> crate::Span {
crate::Span::new_disabled(meta)
}
impl Callsite for MacroCallsite {
fn set_interest(&self, interest: Interest) {
let interest = match () {
_ if interest.is_never() => 0,
_ if interest.is_always() => 2,
_ => 1,
};
self.interest.store(interest, Ordering::SeqCst);
}
#[inline(always)]
fn metadata(&self) -> &Metadata<'static> {
self.meta
}
/// /!\ WARNING: This is *not* a stable API! /!\
/// This function, and all code contained in the `__macro_support` module, is
/// a *private* API of `tracing`. It is exposed publicly because it is used
/// by the `tracing` macros, but it is not part of the stable versioned API.
/// Breaking changes to this module may occur in small-numbered versions
/// without warning.
#[inline]
#[cfg(not(feature = "log"))]
pub fn __disabled_span(_: &'static Metadata<'static>) -> crate::Span {
crate::Span::none()
}
impl fmt::Debug for MacroCallsite {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("MacroCallsite")
.field("interest", &self.interest)
.field("meta", &self.meta)
.field("registration", &self.registration)
.finish()
}
/// /!\ WARNING: This is *not* a stable API! /!\
/// This function, and all code contained in the `__macro_support` module, is
/// a *private* API of `tracing`. It is exposed publicly because it is used
/// by the `tracing` macros, but it is not part of the stable versioned API.
/// Breaking changes to this module may occur in small-numbered versions
/// without warning.
#[cfg(feature = "log")]
pub fn __tracing_log(
meta: &Metadata<'static>,
logger: &'static dyn log::Log,
log_meta: log::Metadata<'_>,
values: &tracing_core::field::ValueSet<'_>,
) {
logger.log(
&crate::log::Record::builder()
.file(meta.file())
.module_path(meta.module_path())
.line(meta.line())
.metadata(log_meta)
.args(format_args!(
"{}",
crate::log::LogValueSet {
values,
is_first: true
}
))
.build(),
);
}
}

View File

@ -24,7 +24,7 @@ macro_rules! span {
(target: $target:expr, parent: $parent:expr, $lvl:expr, $name:expr, $($fields:tt)*) => {
{
use $crate::__macro_support::Callsite as _;
static CALLSITE: $crate::__macro_support::MacroCallsite = $crate::callsite2! {
static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
name: $name,
kind: $crate::metadata::Kind::SPAN,
target: $target,
@ -34,7 +34,7 @@ macro_rules! span {
let mut interest = $crate::subscriber::Interest::never();
if $crate::level_enabled!($lvl)
&& { interest = CALLSITE.interest(); !interest.is_never() }
&& CALLSITE.is_enabled(interest)
&& $crate::__macro_support::__is_enabled(CALLSITE.metadata(), interest)
{
let meta = CALLSITE.metadata();
// span with explicit parent
@ -44,7 +44,7 @@ macro_rules! span {
&$crate::valueset!(meta.fields(), $($fields)*),
)
} else {
let span = CALLSITE.disabled_span();
let span = $crate::__macro_support::__disabled_span(CALLSITE.metadata());
$crate::if_log_enabled! { $lvl, {
span.record_all(&$crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
}};
@ -55,7 +55,7 @@ macro_rules! span {
(target: $target:expr, $lvl:expr, $name:expr, $($fields:tt)*) => {
{
use $crate::__macro_support::Callsite as _;
static CALLSITE: $crate::__macro_support::MacroCallsite = $crate::callsite2! {
static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
name: $name,
kind: $crate::metadata::Kind::SPAN,
target: $target,
@ -65,7 +65,7 @@ macro_rules! span {
let mut interest = $crate::subscriber::Interest::never();
if $crate::level_enabled!($lvl)
&& { interest = CALLSITE.interest(); !interest.is_never() }
&& CALLSITE.is_enabled(interest)
&& $crate::__macro_support::__is_enabled(CALLSITE.metadata(), interest)
{
let meta = CALLSITE.metadata();
// span with contextual parent
@ -74,7 +74,7 @@ macro_rules! span {
&$crate::valueset!(meta.fields(), $($fields)*),
)
} else {
let span = CALLSITE.disabled_span();
let span = $crate::__macro_support::__disabled_span(CALLSITE.metadata());
$crate::if_log_enabled! { $lvl, {
span.record_all(&$crate::valueset!(CALLSITE.metadata().fields(), $($fields)*));
}};
@ -584,7 +584,7 @@ macro_rules! error_span {
macro_rules! event {
(target: $target:expr, parent: $parent:expr, $lvl:expr, { $($fields:tt)* } )=> ({
use $crate::__macro_support::Callsite as _;
static CALLSITE: $crate::__macro_support::MacroCallsite = $crate::callsite2! {
static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
name: $crate::__macro_support::concat!(
"event ",
file!(),
@ -599,7 +599,7 @@ macro_rules! event {
let enabled = $crate::level_enabled!($lvl) && {
let interest = CALLSITE.interest();
!interest.is_never() && CALLSITE.is_enabled(interest)
!interest.is_never() && $crate::__macro_support::__is_enabled(CALLSITE.metadata(), interest)
};
if enabled {
(|value_set: $crate::field::ValueSet| {
@ -641,7 +641,7 @@ macro_rules! event {
);
(target: $target:expr, $lvl:expr, { $($fields:tt)* } )=> ({
use $crate::__macro_support::Callsite as _;
static CALLSITE: $crate::__macro_support::MacroCallsite = $crate::callsite2! {
static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
name: $crate::__macro_support::concat!(
"event ",
file!(),
@ -655,7 +655,7 @@ macro_rules! event {
};
let enabled = $crate::level_enabled!($lvl) && {
let interest = CALLSITE.interest();
!interest.is_never() && CALLSITE.is_enabled(interest)
!interest.is_never() && $crate::__macro_support::__is_enabled(CALLSITE.metadata(), interest)
};
if enabled {
(|value_set: $crate::field::ValueSet| {
@ -832,6 +832,8 @@ macro_rules! event {
/// }
/// ```
///
/// [`enabled!`]: crate::enabled
/// [`span_enabled!`]: crate::span_enabled
#[macro_export]
macro_rules! event_enabled {
($($rest:tt)*)=> (
@ -864,6 +866,8 @@ macro_rules! event_enabled {
/// }
/// ```
///
/// [`enabled!`]: crate::enabled
/// [`span_enabled!`]: crate::span_enabled
#[macro_export]
macro_rules! span_enabled {
($($rest:tt)*)=> (
@ -959,13 +963,14 @@ macro_rules! span_enabled {
/// [`Metadata`]: crate::Metadata
/// [`is_event`]: crate::Metadata::is_event
/// [`is_span`]: crate::Metadata::is_span
///
/// [`enabled!`]: crate::enabled
/// [`span_enabled!`]: crate::span_enabled
#[macro_export]
macro_rules! enabled {
(kind: $kind:expr, target: $target:expr, $lvl:expr, { $($fields:tt)* } )=> ({
if $crate::level_enabled!($lvl) {
use $crate::__macro_support::Callsite as _;
static CALLSITE: $crate::__macro_support::MacroCallsite = $crate::callsite2! {
static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite2! {
name: $crate::__macro_support::concat!(
"enabled ",
file!(),
@ -978,7 +983,7 @@ macro_rules! enabled {
fields: $($fields)*
};
let interest = CALLSITE.interest();
if !interest.is_never() && CALLSITE.is_enabled(interest) {
if !interest.is_never() && $crate::__macro_support::__is_enabled(CALLSITE.metadata(), interest) {
let meta = CALLSITE.metadata();
$crate::dispatcher::get_default(|current| current.enabled(meta))
} else {
@ -2096,7 +2101,6 @@ macro_rules! callsite {
level: $lvl:expr,
fields: $($fields:tt)*
) => {{
use $crate::__macro_support::MacroCallsite;
static META: $crate::Metadata<'static> = {
$crate::metadata! {
name: $name,
@ -2107,7 +2111,7 @@ macro_rules! callsite {
kind: $kind,
}
};
static CALLSITE: MacroCallsite = MacroCallsite::new(&META);
static CALLSITE: $crate::callsite::DefaultCallsite = $crate::callsite::DefaultCallsite::new(&META);
CALLSITE.register();
&CALLSITE
}};
@ -2147,7 +2151,6 @@ macro_rules! callsite2 {
level: $lvl:expr,
fields: $($fields:tt)*
) => {{
use $crate::__macro_support::MacroCallsite;
static META: $crate::Metadata<'static> = {
$crate::metadata! {
name: $name,
@ -2158,7 +2161,7 @@ macro_rules! callsite2 {
kind: $kind,
}
};
MacroCallsite::new(&META)
$crate::callsite::DefaultCallsite::new(&META)
}};
}
@ -2428,13 +2431,14 @@ macro_rules! __tracing_log {
use $crate::log;
let level = $crate::level_to_log!($level);
if level <= log::max_level() {
let meta = $callsite.metadata();
let log_meta = log::Metadata::builder()
.level(level)
.target(CALLSITE.metadata().target())
.target(meta.target())
.build();
let logger = log::logger();
if logger.enabled(&log_meta) {
$callsite.log(logger, log_meta, $value_set)
$crate::__macro_support::__tracing_log(meta, logger, log_meta, $value_set)
}
}
}}

View File

@ -718,8 +718,8 @@ impl Span {
/// ```
///
/// [syntax]: https://rust-lang.github.io/async-book/01_getting_started/04_async_await_primer.html
/// [`Span::in_scope`]: #method.in_scope
/// [instrument]: https://docs.rs/tracing/latest/tracing/trait.Instrument.html
/// [`Span::in_scope`]: Span::in_scope()
/// [instrument]: crate::Instrument
/// [attr]: macro@crate::instrument
///
/// # Examples
@ -1239,7 +1239,7 @@ impl Span {
///
/// See also [`is_none`].
///
/// [`is_none`]: #method.is_none
/// [`is_none`]: Span::is_none()
#[inline]
pub fn is_disabled(&self) -> bool {
self.inner.is_none()
@ -1253,8 +1253,8 @@ impl Span {
/// rather than constructed by `Span::none`, this method will return
/// `false`, while `is_disabled` will return `true`.
///
/// [`Span::none`]: #method.none
/// [`is_disabled`]: #method.is_disabled
/// [`Span::none`]: Span::none()
/// [`is_disabled`]: Span::is_disabled()
#[inline]
pub fn is_none(&self) -> bool {
self.is_disabled() && self.meta.is_none()

View File

@ -0,0 +1,47 @@
use std::{sync::mpsc, thread, time::Duration};
use tracing::{
metadata::Metadata,
span,
subscriber::{self, Interest, Subscriber},
Event,
};
#[test]
fn register_callsite_doesnt_deadlock() {
pub struct EvilSubscriber;
impl Subscriber for EvilSubscriber {
fn register_callsite(&self, meta: &'static Metadata<'static>) -> Interest {
tracing::info!(?meta, "registered a callsite");
Interest::always()
}
fn enabled(&self, _: &Metadata<'_>) -> bool {
true
}
fn new_span(&self, _: &span::Attributes<'_>) -> span::Id {
span::Id::from_u64(1)
}
fn record(&self, _: &span::Id, _: &span::Record<'_>) {}
fn record_follows_from(&self, _: &span::Id, _: &span::Id) {}
fn event(&self, _: &Event<'_>) {}
fn enter(&self, _: &span::Id) {}
fn exit(&self, _: &span::Id) {}
}
subscriber::set_global_default(EvilSubscriber).unwrap();
// spawn a thread, and assert it doesn't hang...
let (tx, didnt_hang) = mpsc::channel();
let th = thread::spawn(move || {
tracing::info!("hello world!");
tx.send(()).unwrap();
});
didnt_hang
// Note: 60 seconds is *way* more than enough, but let's be generous in
// case of e.g. slow CI machines.
.recv_timeout(Duration::from_secs(60))
.expect("the thread must not have hung!");
th.join().expect("thread should join successfully");
}

186
zeroidc/vendor/typenum/build/main.rs vendored Normal file
View File

@ -0,0 +1,186 @@
use std::env;
use std::fmt;
use std::fs::File;
use std::io::Write;
use std::path::Path;
mod op;
mod tests;
pub enum UIntCode {
Term,
Zero(Box<UIntCode>),
One(Box<UIntCode>),
}
pub enum IntCode {
Zero,
Pos(Box<UIntCode>),
Neg(Box<UIntCode>),
}
impl fmt::Display for UIntCode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
UIntCode::Term => write!(f, "UTerm"),
UIntCode::Zero(ref inner) => write!(f, "UInt<{}, B0>", inner),
UIntCode::One(ref inner) => write!(f, "UInt<{}, B1>", inner),
}
}
}
impl fmt::Display for IntCode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
IntCode::Zero => write!(f, "Z0"),
IntCode::Pos(ref inner) => write!(f, "PInt<{}>", inner),
IntCode::Neg(ref inner) => write!(f, "NInt<{}>", inner),
}
}
}
pub fn gen_uint(u: u64) -> UIntCode {
let mut result = UIntCode::Term;
let mut x = 1u64 << 63;
while x > u {
x >>= 1
}
while x > 0 {
result = if x & u > 0 {
UIntCode::One(Box::new(result))
} else {
UIntCode::Zero(Box::new(result))
};
x >>= 1;
}
result
}
pub fn gen_int(i: i64) -> IntCode {
use std::cmp::Ordering::{Equal, Greater, Less};
match i.cmp(&0) {
Greater => IntCode::Pos(Box::new(gen_uint(i as u64))),
Less => IntCode::Neg(Box::new(gen_uint(i.abs() as u64))),
Equal => IntCode::Zero,
}
}
#[cfg_attr(
feature = "no_std",
deprecated(
since = "1.3.0",
note = "the `no_std` flag is no longer necessary and will be removed in the future"
)
)]
pub fn no_std() {}
// fixme: get a warning when testing without this
#[allow(dead_code)]
fn main() {
let highest: u64 = 1024;
// Use hardcoded values to avoid issues with cross-compilation.
// See https://github.com/paholg/typenum/issues/162
let first2: u32 = 11; // (highest as f64).log(2.0).round() as u32 + 1;
let first10: u32 = 4; // (highest as f64).log(10.0) as u32 + 1;
let uints = (0..(highest + 1))
.chain((first2..64).map(|i| 2u64.pow(i)))
.chain((first10..20).map(|i| 10u64.pow(i)));
let out_dir = env::var("OUT_DIR").unwrap();
let dest = Path::new(&out_dir).join("consts.rs");
println!("cargo:rustc-env=TYPENUM_BUILD_CONSTS={}", dest.display());
let mut f = File::create(&dest).unwrap();
no_std();
// Header stuff here!
write!(
f,
"
/**
Type aliases for many constants.
This file is generated by typenum's build script.
For unsigned integers, the format is `U` followed by the number. We define aliases for
- Numbers 0 through {highest}
- Powers of 2 below `u64::MAX`
- Powers of 10 below `u64::MAX`
These alias definitions look like this:
```rust
use typenum::{{B0, B1, UInt, UTerm}};
# #[allow(dead_code)]
type U6 = UInt<UInt<UInt<UTerm, B1>, B1>, B0>;
```
For positive signed integers, the format is `P` followed by the number and for negative
signed integers it is `N` followed by the number. For the signed integer zero, we use
`Z0`. We define aliases for
- Numbers -{highest} through {highest}
- Powers of 2 between `i64::MIN` and `i64::MAX`
- Powers of 10 between `i64::MIN` and `i64::MAX`
These alias definitions look like this:
```rust
use typenum::{{B0, B1, UInt, UTerm, PInt, NInt}};
# #[allow(dead_code)]
type P6 = PInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>;
# #[allow(dead_code)]
type N6 = NInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>>;
```
# Example
```rust
# #[allow(unused_imports)]
use typenum::{{U0, U1, U2, U3, U4, U5, U6}};
# #[allow(unused_imports)]
use typenum::{{N3, N2, N1, Z0, P1, P2, P3}};
# #[allow(unused_imports)]
use typenum::{{U774, N17, N10000, P1024, P4096}};
```
We also define the aliases `False` and `True` for `B0` and `B1`, respectively.
*/
#[allow(missing_docs)]
pub mod consts {{
use crate::uint::{{UInt, UTerm}};
use crate::int::{{PInt, NInt}};
pub use crate::bit::{{B0, B1}};
pub use crate::int::Z0;
pub type True = B1;
pub type False = B0;
",
highest = highest
)
.unwrap();
for u in uints {
writeln!(f, " pub type U{} = {};", u, gen_uint(u)).unwrap();
if u <= ::std::i64::MAX as u64 && u != 0 {
let i = u as i64;
writeln!(
f,
" pub type P{i} = PInt<U{i}>; pub type N{i} = NInt<U{i}>;",
i = i
)
.unwrap();
}
}
write!(f, "}}").unwrap();
tests::build_tests().unwrap();
op::write_op_macro().unwrap();
}

559
zeroidc/vendor/typenum/build/op.rs vendored Normal file
View File

@ -0,0 +1,559 @@
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
enum OpType {
Operator,
Function,
}
use self::OpType::*;
struct Op {
token: &'static str,
operator: &'static str,
example: (&'static str, &'static str),
precedence: u8,
n_args: u8,
op_type: OpType,
}
pub fn write_op_macro() -> ::std::io::Result<()> {
let out_dir = ::std::env::var("OUT_DIR").unwrap();
let dest = ::std::path::Path::new(&out_dir).join("op.rs");
println!("cargo:rustc-env=TYPENUM_BUILD_OP={}", dest.display());
let mut f = ::std::fs::File::create(&dest).unwrap();
// Operator precedence is taken from
// https://doc.rust-lang.org/reference.html#operator-precedence
//
// We choose 16 as the highest precedence (functions are set to 255 but it doesn't matter
// for them). We also only use operators that are left associative so we don't have to worry
// about that.
let ops = &[
Op {
token: "*",
operator: "Prod",
example: ("P2 * P3", "P6"),
precedence: 16,
n_args: 2,
op_type: Operator,
},
Op {
token: "/",
operator: "Quot",
example: ("P6 / P2", "P3"),
precedence: 16,
n_args: 2,
op_type: Operator,
},
Op {
token: "%",
operator: "Mod",
example: ("P5 % P3", "P2"),
precedence: 16,
n_args: 2,
op_type: Operator,
},
Op {
token: "+",
operator: "Sum",
example: ("P2 + P3", "P5"),
precedence: 15,
n_args: 2,
op_type: Operator,
},
Op {
token: "-",
operator: "Diff",
example: ("P2 - P3", "N1"),
precedence: 15,
n_args: 2,
op_type: Operator,
},
Op {
token: "<<",
operator: "Shleft",
example: ("U1 << U5", "U32"),
precedence: 14,
n_args: 2,
op_type: Operator,
},
Op {
token: ">>",
operator: "Shright",
example: ("U32 >> U5", "U1"),
precedence: 14,
n_args: 2,
op_type: Operator,
},
Op {
token: "&",
operator: "And",
example: ("U5 & U3", "U1"),
precedence: 13,
n_args: 2,
op_type: Operator,
},
Op {
token: "^",
operator: "Xor",
example: ("U5 ^ U3", "U6"),
precedence: 12,
n_args: 2,
op_type: Operator,
},
Op {
token: "|",
operator: "Or",
example: ("U5 | U3", "U7"),
precedence: 11,
n_args: 2,
op_type: Operator,
},
Op {
token: "==",
operator: "Eq",
example: ("P5 == P3 + P2", "True"),
precedence: 10,
n_args: 2,
op_type: Operator,
},
Op {
token: "!=",
operator: "NotEq",
example: ("P5 != P3 + P2", "False"),
precedence: 10,
n_args: 2,
op_type: Operator,
},
Op {
token: "<=",
operator: "LeEq",
example: ("P6 <= P3 + P2", "False"),
precedence: 10,
n_args: 2,
op_type: Operator,
},
Op {
token: ">=",
operator: "GrEq",
example: ("P6 >= P3 + P2", "True"),
precedence: 10,
n_args: 2,
op_type: Operator,
},
Op {
token: "<",
operator: "Le",
example: ("P4 < P3 + P2", "True"),
precedence: 10,
n_args: 2,
op_type: Operator,
},
Op {
token: ">",
operator: "Gr",
example: ("P5 < P3 + P2", "False"),
precedence: 10,
n_args: 2,
op_type: Operator,
},
Op {
token: "cmp",
operator: "Compare",
example: ("cmp(P2, P3)", "Less"),
precedence: !0,
n_args: 2,
op_type: Function,
},
Op {
token: "sqr",
operator: "Square",
example: ("sqr(P2)", "P4"),
precedence: !0,
n_args: 1,
op_type: Function,
},
Op {
token: "sqrt",
operator: "Sqrt",
example: ("sqrt(U9)", "U3"),
precedence: !0,
n_args: 1,
op_type: Function,
},
Op {
token: "abs",
operator: "AbsVal",
example: ("abs(N2)", "P2"),
precedence: !0,
n_args: 1,
op_type: Function,
},
Op {
token: "cube",
operator: "Cube",
example: ("cube(P2)", "P8"),
precedence: !0,
n_args: 1,
op_type: Function,
},
Op {
token: "pow",
operator: "Exp",
example: ("pow(P2, P3)", "P8"),
precedence: !0,
n_args: 2,
op_type: Function,
},
Op {
token: "min",
operator: "Minimum",
example: ("min(P2, P3)", "P2"),
precedence: !0,
n_args: 2,
op_type: Function,
},
Op {
token: "max",
operator: "Maximum",
example: ("max(P2, P3)", "P3"),
precedence: !0,
n_args: 2,
op_type: Function,
},
Op {
token: "log2",
operator: "Log2",
example: ("log2(U9)", "U3"),
precedence: !0,
n_args: 1,
op_type: Function,
},
Op {
token: "gcd",
operator: "Gcf",
example: ("gcd(U9, U21)", "U3"),
precedence: !0,
n_args: 2,
op_type: Function,
},
];
use std::io::Write;
write!(
f,
"
/**
Convenient type operations.
Any types representing values must be able to be expressed as `ident`s. That means they need to be
in scope.
For example, `P5` is okay, but `typenum::P5` is not.
You may combine operators arbitrarily, although doing so excessively may require raising the
recursion limit.
# Example
```rust
#![recursion_limit=\"128\"]
#[macro_use] extern crate typenum;
use typenum::consts::*;
fn main() {{
assert_type!(
op!(min((P1 - P2) * (N3 + N7), P5 * (P3 + P4)) == P10)
);
}}
```
Operators are evaluated based on the operator precedence outlined
[here](https://doc.rust-lang.org/reference.html#operator-precedence).
The full list of supported operators and functions is as follows:
{}
They all expand to type aliases defined in the `operator_aliases` module. Here is an expanded list,
including examples:
",
ops.iter()
.map(|op| format!("`{}`", op.token))
.collect::<Vec<_>>()
.join(", ")
)?;
//write!(f, "Token | Alias | Example\n ===|===|===\n")?;
for op in ops.iter() {
write!(
f,
"---\nOperator `{token}`. Expands to `{operator}`.
```rust
# #[macro_use] extern crate typenum;
# use typenum::*;
# fn main() {{
assert_type_eq!(op!({ex0}), {ex1});
# }}
```\n
",
token = op.token,
operator = op.operator,
ex0 = op.example.0,
ex1 = op.example.1
)?;
}
write!(
f,
"*/
#[macro_export(local_inner_macros)]
macro_rules! op {{
($($tail:tt)*) => ( __op_internal__!($($tail)*) );
}}
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! __op_internal__ {{
"
)?;
// We first us the shunting-yard algorithm to produce our tokens in Polish notation.
// See: https://en.wikipedia.org/wiki/Shunting-yard_algorithm
// Note: Due to macro asymmetry, "the top of the stack" refers to the first element, not the
// last
// -----------------------------------------------------------------------------------------
// Stage 1: There are tokens to be read:
// -------
// Case 1: Token is a function => Push it onto the stack:
for fun in ops.iter().filter(|f| f.op_type == Function) {
write!(
f,
"
(@stack[$($stack:ident,)*] @queue[$($queue:ident,)*] @tail: {f_token} $($tail:tt)*) => (
__op_internal__!(@stack[{f_op}, $($stack,)*] @queue[$($queue,)*] @tail: $($tail)*)
);",
f_token = fun.token,
f_op = fun.operator
)?;
}
// -------
// Case 2: Token is a comma => Until the top of the stack is a LParen,
// Pop operators from stack to queue
// Base case: Top of stack is LParen, ditch comma and continue
write!(
f,
"
(@stack[LParen, $($stack:ident,)*] @queue[$($queue:ident,)*] @tail: , $($tail:tt)*) => (
__op_internal__!(@stack[LParen, $($stack,)*] @queue[$($queue,)*] @tail: $($tail)*)
);"
)?;
// Recursive case: Not LParen, pop from stack to queue
write!(
f,
"
(@stack[$stack_top:ident, $($stack:ident,)*] @queue[$($queue:ident,)*] @tail: , $($tail:tt)*) => (
__op_internal__!(@stack[$($stack,)*] @queue[$stack_top, $($queue,)*] @tail: , $($tail)*)
);"
)?;
// -------
// Case 3: Token is an operator, o1:
for o1 in ops.iter().filter(|op| op.op_type == Operator) {
// If top of stack is operator o2 with o1.precedence <= o2.precedence,
// Then pop o2 off stack onto queue:
for o2 in ops
.iter()
.filter(|op| op.op_type == Operator)
.filter(|o2| o1.precedence <= o2.precedence)
{
write!(
f,
"
(@stack[{o2_op}, $($stack:ident,)*] @queue[$($queue:ident,)*] @tail: {o1_token} $($tail:tt)*) => (
__op_internal__!(@stack[$($stack,)*] @queue[{o2_op}, $($queue,)*] @tail: {o1_token} $($tail)*)
);",
o2_op = o2.operator,
o1_token = o1.token
)?;
}
// Base case: push o1 onto stack
write!(
f,
"
(@stack[$($stack:ident,)*] @queue[$($queue:ident,)*] @tail: {o1_token} $($tail:tt)*) => (
__op_internal__!(@stack[{o1_op}, $($stack,)*] @queue[$($queue,)*] @tail: $($tail)*)
);",
o1_op = o1.operator,
o1_token = o1.token
)?;
}
// -------
// Case 4: Token is "(": push it onto stack as "LParen". Also convert the ")" to "RParen" to
// appease the macro gods:
write!(
f,
"
(@stack[$($stack:ident,)*] @queue[$($queue:ident,)*] @tail: ( $($stuff:tt)* ) $($tail:tt)* )
=> (
__op_internal__!(@stack[LParen, $($stack,)*] @queue[$($queue,)*]
@tail: $($stuff)* RParen $($tail)*)
);"
)?;
// -------
// Case 5: Token is "RParen":
// 1. Pop from stack to queue until we see an "LParen",
// 2. Kill the "LParen",
// 3. If the top of the stack is a function, pop it onto the queue
// 2. Base case:
write!(
f,
"
(@stack[LParen, $($stack:ident,)*] @queue[$($queue:ident,)*] @tail: RParen $($tail:tt)*) => (
__op_internal__!(@rp3 @stack[$($stack,)*] @queue[$($queue,)*] @tail: $($tail)*)
);"
)?;
// 1. Recursive case:
write!(
f,
"
(@stack[$stack_top:ident, $($stack:ident,)*] @queue[$($queue:ident,)*] @tail: RParen $($tail:tt)*)
=> (
__op_internal__!(@stack[$($stack,)*] @queue[$stack_top, $($queue,)*] @tail: RParen $($tail)*)
);"
)?;
// 3. Check for function:
for fun in ops.iter().filter(|f| f.op_type == Function) {
write!(
f,
"
(@rp3 @stack[{fun_op}, $($stack:ident,)*] @queue[$($queue:ident,)*] @tail: $($tail:tt)*) => (
__op_internal__!(@stack[$($stack,)*] @queue[{fun_op}, $($queue,)*] @tail: $($tail)*)
);",
fun_op = fun.operator
)?;
}
// 3. If no function found:
write!(
f,
"
(@rp3 @stack[$($stack:ident,)*] @queue[$($queue:ident,)*] @tail: $($tail:tt)*) => (
__op_internal__!(@stack[$($stack,)*] @queue[$($queue,)*] @tail: $($tail)*)
);"
)?;
// -------
// Case 6: Token is a number: Push it onto the queue
write!(
f,
"
(@stack[$($stack:ident,)*] @queue[$($queue:ident,)*] @tail: $num:ident $($tail:tt)*) => (
__op_internal__!(@stack[$($stack,)*] @queue[$num, $($queue,)*] @tail: $($tail)*)
);"
)?;
// -------
// Case 7: Out of tokens:
// Base case: Stack empty: Start evaluating
write!(
f,
"
(@stack[] @queue[$($queue:ident,)*] @tail: ) => (
__op_internal__!(@reverse[] @input: $($queue,)*)
);"
)?;
// Recursive case: Pop stack to queue
write!(
f,
"
(@stack[$stack_top:ident, $($stack:ident,)*] @queue[$($queue:ident,)*] @tail:) => (
__op_internal__!(@stack[$($stack,)*] @queue[$stack_top, $($queue,)*] @tail: )
);"
)?;
// -----------------------------------------------------------------------------------------
// Stage 2: Reverse so we have RPN
write!(
f,
"
(@reverse[$($revved:ident,)*] @input: $head:ident, $($tail:ident,)* ) => (
__op_internal__!(@reverse[$head, $($revved,)*] @input: $($tail,)*)
);"
)?;
write!(
f,
"
(@reverse[$($revved:ident,)*] @input: ) => (
__op_internal__!(@eval @stack[] @input[$($revved,)*])
);"
)?;
// -----------------------------------------------------------------------------------------
// Stage 3: Evaluate in Reverse Polish Notation
// Operators / Operators with 2 args:
for op in ops.iter().filter(|op| op.n_args == 2) {
// Note: We have to switch $a and $b here, otherwise non-commutative functions are backwards
write!(
f,
"
(@eval @stack[$a:ty, $b:ty, $($stack:ty,)*] @input[{op}, $($tail:ident,)*]) => (
__op_internal__!(@eval @stack[$crate::{op}<$b, $a>, $($stack,)*] @input[$($tail,)*])
);",
op = op.operator
)?;
}
// Operators with 1 arg:
for op in ops.iter().filter(|op| op.n_args == 1) {
write!(
f,
"
(@eval @stack[$a:ty, $($stack:ty,)*] @input[{op}, $($tail:ident,)*]) => (
__op_internal__!(@eval @stack[$crate::{op}<$a>, $($stack,)*] @input[$($tail,)*])
);",
op = op.operator
)?;
}
// Wasn't a function or operator, so must be a value => push onto stack
write!(
f,
"
(@eval @stack[$($stack:ty,)*] @input[$head:ident, $($tail:ident,)*]) => (
__op_internal__!(@eval @stack[$head, $($stack,)*] @input[$($tail,)*])
);"
)?;
// No input left:
write!(
f,
"
(@eval @stack[$stack:ty,] @input[]) => (
$stack
);"
)?;
// -----------------------------------------------------------------------------------------
// Stage 0: Get it started
write!(
f,
"
($($tail:tt)* ) => (
__op_internal__!(@stack[] @queue[] @tail: $($tail)*)
);"
)?;
write!(
f,
"
}}"
)?;
Ok(())
}

328
zeroidc/vendor/typenum/build/tests.rs vendored Normal file
View File

@ -0,0 +1,328 @@
use std::{env, fmt, fs, io, path};
use super::{gen_int, gen_uint};
/// Computes the greatest common divisor of two integers.
fn gcdi(mut a: i64, mut b: i64) -> i64 {
a = a.abs();
b = b.abs();
while a != 0 {
let tmp = b % a;
b = a;
a = tmp;
}
b
}
fn gcdu(mut a: u64, mut b: u64) -> u64 {
while a != 0 {
let tmp = b % a;
b = a;
a = tmp;
}
b
}
fn sign(i: i64) -> char {
use std::cmp::Ordering::*;
match i.cmp(&0) {
Greater => 'P',
Less => 'N',
Equal => '_',
}
}
struct UIntTest {
a: u64,
op: &'static str,
b: Option<u64>,
r: u64,
}
impl fmt::Display for UIntTest {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.b {
Some(b) => write!(
f,
"
#[test]
#[allow(non_snake_case)]
fn test_{a}_{op}_{b}() {{
type A = {gen_a};
type B = {gen_b};
type U{r} = {result};
#[allow(non_camel_case_types)]
type U{a}{op}U{b} = <<A as {op}<B>>::Output as Same<U{r}>>::Output;
assert_eq!(<U{a}{op}U{b} as Unsigned>::to_u64(), <U{r} as Unsigned>::to_u64());
}}",
gen_a = gen_uint(self.a),
gen_b = gen_uint(b),
r = self.r,
result = gen_uint(self.r),
a = self.a,
b = b,
op = self.op
),
None => write!(
f,
"
#[test]
#[allow(non_snake_case)]
fn test_{a}_{op}() {{
type A = {gen_a};
type U{r} = {result};
#[allow(non_camel_case_types)]
type {op}U{a} = <<A as {op}>::Output as Same<U{r}>>::Output;
assert_eq!(<{op}U{a} as Unsigned>::to_u64(), <U{r} as Unsigned>::to_u64());
}}",
gen_a = gen_uint(self.a),
r = self.r,
result = gen_uint(self.r),
a = self.a,
op = self.op
),
}
}
}
fn uint_binary_test(left: u64, operator: &'static str, right: u64, result: u64) -> UIntTest {
UIntTest {
a: left,
op: operator,
b: Option::Some(right),
r: result,
}
}
// fn uint_unary_test(op: &'static str, a: u64, result: u64) -> UIntTest {
// UIntTest { a: a, op: op, b: Option::None, r: result }
// }
struct IntBinaryTest {
a: i64,
op: &'static str,
b: i64,
r: i64,
}
impl fmt::Display for IntBinaryTest {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"
#[test]
#[allow(non_snake_case)]
fn test_{sa}{a}_{op}_{sb}{b}() {{
type A = {gen_a};
type B = {gen_b};
type {sr}{r} = {result};
#[allow(non_camel_case_types)]
type {sa}{a}{op}{sb}{b} = <<A as {op}<B>>::Output as Same<{sr}{r}>>::Output;
assert_eq!(<{sa}{a}{op}{sb}{b} as Integer>::to_i64(), <{sr}{r} as Integer>::to_i64());
}}",
gen_a = gen_int(self.a),
gen_b = gen_int(self.b),
r = self.r.abs(),
sr = sign(self.r),
result = gen_int(self.r),
a = self.a.abs(),
b = self.b.abs(),
sa = sign(self.a),
sb = sign(self.b),
op = self.op
)
}
}
fn int_binary_test(left: i64, operator: &'static str, right: i64, result: i64) -> IntBinaryTest {
IntBinaryTest {
a: left,
op: operator,
b: right,
r: result,
}
}
struct IntUnaryTest {
op: &'static str,
a: i64,
r: i64,
}
impl fmt::Display for IntUnaryTest {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"
#[test]
#[allow(non_snake_case)]
fn test_{sa}{a}_{op}() {{
type A = {gen_a};
type {sr}{r} = {result};
#[allow(non_camel_case_types)]
type {op}{sa}{a} = <<A as {op}>::Output as Same<{sr}{r}>>::Output;
assert_eq!(<{op}{sa}{a} as Integer>::to_i64(), <{sr}{r} as Integer>::to_i64());
}}",
gen_a = gen_int(self.a),
r = self.r.abs(),
sr = sign(self.r),
result = gen_int(self.r),
a = self.a.abs(),
sa = sign(self.a),
op = self.op
)
}
}
fn int_unary_test(operator: &'static str, num: i64, result: i64) -> IntUnaryTest {
IntUnaryTest {
op: operator,
a: num,
r: result,
}
}
fn uint_cmp_test(a: u64, b: u64) -> String {
format!(
"
#[test]
#[allow(non_snake_case)]
fn test_{a}_Cmp_{b}() {{
type A = {gen_a};
type B = {gen_b};
#[allow(non_camel_case_types)]
type U{a}CmpU{b} = <A as Cmp<B>>::Output;
assert_eq!(<U{a}CmpU{b} as Ord>::to_ordering(), Ordering::{result:?});
}}",
a = a,
b = b,
gen_a = gen_uint(a),
gen_b = gen_uint(b),
result = a.cmp(&b)
)
}
fn int_cmp_test(a: i64, b: i64) -> String {
format!(
"
#[test]
#[allow(non_snake_case)]
fn test_{sa}{a}_Cmp_{sb}{b}() {{
type A = {gen_a};
type B = {gen_b};
#[allow(non_camel_case_types)]
type {sa}{a}Cmp{sb}{b} = <A as Cmp<B>>::Output;
assert_eq!(<{sa}{a}Cmp{sb}{b} as Ord>::to_ordering(), Ordering::{result:?});
}}",
a = a.abs(),
b = b.abs(),
sa = sign(a),
sb = sign(b),
gen_a = gen_int(a),
gen_b = gen_int(b),
result = a.cmp(&b)
)
}
// Allow for rustc 1.22 compatibility.
#[allow(bare_trait_objects)]
pub fn build_tests() -> Result<(), Box<::std::error::Error>> {
// will test all permutations of number pairs up to this (and down to its opposite for ints)
let high: i64 = 5;
let uints = (0u64..high as u64 + 1).flat_map(|a| (a..a + 1).cycle().zip(0..high as u64 + 1));
let ints = (-high..high + 1).flat_map(|a| (a..a + 1).cycle().zip(-high..high + 1));
let out_dir = env::var("OUT_DIR")?;
let dest = path::Path::new(&out_dir).join("tests.rs");
let f = fs::File::create(&dest)?;
let mut writer = io::BufWriter::new(&f);
use std::io::Write;
writer.write_all(
b"
extern crate typenum;
use std::ops::*;
use std::cmp::Ordering;
use typenum::*;
",
)?;
use std::cmp;
// uint operators:
for (a, b) in uints {
write!(writer, "{}", uint_binary_test(a, "BitAnd", b, a & b))?;
write!(writer, "{}", uint_binary_test(a, "BitOr", b, a | b))?;
write!(writer, "{}", uint_binary_test(a, "BitXor", b, a ^ b))?;
write!(writer, "{}", uint_binary_test(a, "Shl", b, a << b))?;
write!(writer, "{}", uint_binary_test(a, "Shr", b, a >> b))?;
write!(writer, "{}", uint_binary_test(a, "Add", b, a + b))?;
write!(writer, "{}", uint_binary_test(a, "Min", b, cmp::min(a, b)))?;
write!(writer, "{}", uint_binary_test(a, "Max", b, cmp::max(a, b)))?;
write!(writer, "{}", uint_binary_test(a, "Gcd", b, gcdu(a, b)))?;
if a >= b {
write!(writer, "{}", uint_binary_test(a, "Sub", b, a - b))?;
}
write!(writer, "{}", uint_binary_test(a, "Mul", b, a * b))?;
if b != 0 {
write!(writer, "{}", uint_binary_test(a, "Div", b, a / b))?;
write!(writer, "{}", uint_binary_test(a, "Rem", b, a % b))?;
if a % b == 0 {
write!(writer, "{}", uint_binary_test(a, "PartialDiv", b, a / b))?;
}
}
write!(writer, "{}", uint_binary_test(a, "Pow", b, a.pow(b as u32)))?;
write!(writer, "{}", uint_cmp_test(a, b))?;
}
// int operators:
for (a, b) in ints {
write!(writer, "{}", int_binary_test(a, "Add", b, a + b))?;
write!(writer, "{}", int_binary_test(a, "Sub", b, a - b))?;
write!(writer, "{}", int_binary_test(a, "Mul", b, a * b))?;
write!(writer, "{}", int_binary_test(a, "Min", b, cmp::min(a, b)))?;
write!(writer, "{}", int_binary_test(a, "Max", b, cmp::max(a, b)))?;
write!(writer, "{}", int_binary_test(a, "Gcd", b, gcdi(a, b)))?;
if b != 0 {
write!(writer, "{}", int_binary_test(a, "Div", b, a / b))?;
write!(writer, "{}", int_binary_test(a, "Rem", b, a % b))?;
if a % b == 0 {
write!(writer, "{}", int_binary_test(a, "PartialDiv", b, a / b))?;
}
}
if b >= 0 || a.abs() == 1 {
let result = if b < 0 {
if a == 1 {
a
} else if a == -1 {
a.pow((-b) as u32)
} else {
unreachable!()
}
} else {
a.pow(b as u32)
};
write!(writer, "{}", int_binary_test(a, "Pow", b, result))?;
}
write!(writer, "{}", int_cmp_test(a, b))?;
}
// int unary operators:
for n in -high..high + 1 {
write!(writer, "{}", int_unary_test("Neg", n, -n))?;
write!(writer, "{}", int_unary_test("Abs", n, n.abs()))?;
}
writer.flush()?;
Ok(())
}