Sha256: 9cbfb6e245764949077f4491068a0d0b7fa53a2d38f0f79403fe802eb80a7975

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

use target_lexicon::{Architecture, Triple};

/// Extension methods for `target_lexicon::Triple`.
pub trait TripleExt {
    /// Helper for returning whether this target is for pulley, wasmtime's
    /// interpreter.
    fn is_pulley(&self) -> bool;

    /// Returns the target triple for pulley to run on this host.
    fn pulley_host() -> Self;
}

impl TripleExt for Triple {
    fn is_pulley(&self) -> bool {
        match self.architecture {
            Architecture::Pulley32 | Architecture::Pulley32be => true,
            Architecture::Pulley64 | Architecture::Pulley64be => true,
            _ => false,
        }
    }

    fn pulley_host() -> Self {
        if cfg!(target_endian = "little") {
            if cfg!(target_pointer_width = "32") {
                return "pulley32".parse().unwrap();
            } else if cfg!(target_pointer_width = "64") {
                return "pulley64".parse().unwrap();
            }
        }
        if cfg!(target_endian = "big") {
            if cfg!(target_pointer_width = "32") {
                return "pulley32be".parse().unwrap();
            } else if cfg!(target_pointer_width = "64") {
                return "pulley64be".parse().unwrap();
            }
        }

        unreachable!()
    }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/wasmtime-environ-29.0.0/src/ext.rs