Skip to content

Commit

Permalink
Merge #265
Browse files Browse the repository at this point in the history
265: Use `u64_digit` for 128-bit targets r=cuviper a=icedrocket

This PR adds detection for 128-bit targets and cleans up the code a bit.

#263

Co-authored-by: icedrocket <114203630+icedrocket@users.noreply.github.com>
Co-authored-by: Josh Stone <cuviper@gmail.com>
  • Loading branch information
3 people committed Feb 11, 2023
2 parents fc8c1f5 + 6959608 commit 5da950d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,32 @@ use std::io::Write;
use std::path::Path;

fn main() {
let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH");
let u64_digit = pointer_width.as_ref().map(String::as_str) == Ok("64");
let ptr_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH");
let u64_digit = ptr_width
.as_ref()
.map(|x| x == "64" || x == "128")
.unwrap_or(false);

if u64_digit {
autocfg::emit("u64_digit");
}

let ac = autocfg::new();
let std = if ac.probe_sysroot_crate("std") {
"std"
} else {
"core"
};

if ac.probe_path(&format!("{}::convert::TryFrom", std)) {
autocfg::emit("has_try_from");
}

if let Ok(target_arch) = env::var("CARGO_CFG_TARGET_ARCH") {
if target_arch == "x86_64" || target_arch == "x86" {
if let Ok(arch) = env::var("CARGO_CFG_TARGET_ARCH") {
if arch == "x86_64" || arch == "x86" {
let digit = if u64_digit { "u64" } else { "u32" };

let addcarry = format!("{}::arch::{}::_addcarry_{}", std, target_arch, digit);
let addcarry = format!("{}::arch::{}::_addcarry_{}", std, arch, digit);
if ac.probe_path(&addcarry) {
autocfg::emit("use_addcarry");
}
Expand Down

0 comments on commit 5da950d

Please sign in to comment.