forked from mthom/scryer-prolog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modularize special-math code HT @adri326
- Loading branch information
Showing
2 changed files
with
24 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,7 @@ use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512}; | |
use crrl::{ed25519, secp256k1, x25519}; | ||
|
||
#[cfg(feature = "special-math")] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dcnorris
Author
Owner
|
||
use puruspe::error::erf; | ||
pub(crate) mod special_math; | ||
|
||
#[cfg(feature = "tls")] | ||
use native_tls::{Identity, TlsAcceptor, TlsConnector}; | ||
|
@@ -7751,23 +7751,6 @@ impl Machine { | |
); | ||
} | ||
|
||
#[cfg(feature = "special-math")] | ||
#[inline(always)] | ||
pub(crate) fn erf(&mut self) { | ||
let x = self.deref_register(1); | ||
let x = match Number::try_from(x) { | ||
Ok(Number::Float(n)) => n.into_inner(), | ||
Ok(Number::Fixnum(n)) => n.get_num() as f64, | ||
Ok(Number::Integer(n)) => n.to_f64().value(), | ||
_ => { | ||
unreachable!() | ||
} | ||
}; | ||
let erf_x = float_alloc!(erf(x), self.machine_st.arena); | ||
let return_value = self.deref_register(2); | ||
self.machine_st.unify_f64(erf_x, return_value); | ||
} | ||
|
||
#[inline(always)] | ||
pub(crate) fn crypto_curve_scalar_mult(&mut self) { | ||
let stub_gen = || functor_stub(atom!("crypto_curve_scalar_mult"), 4); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use crate::machine::Number; | ||
use crate::Machine; | ||
use puruspe::error::*; | ||
|
||
impl Machine { | ||
|
||
#[inline(always)] | ||
pub(crate) fn erf(&mut self) { | ||
let x = self.deref_register(1); | ||
let x = match Number::try_from(x) { | ||
Ok(Number::Float(n)) => n.into_inner(), | ||
Ok(Number::Fixnum(n)) => n.get_num() as f64, | ||
Ok(Number::Integer(n)) => n.to_f64().value(), | ||
_ => { | ||
unreachable!() | ||
} | ||
}; | ||
let erf_x = float_alloc!(erf(x), self.machine_st.arena); | ||
let return_value = self.deref_register(2); | ||
self.machine_st.unify_f64(erf_x, return_value); | ||
} | ||
|
||
} |
Is there any reason to make this contingent on a flag? The reason we did this in some cases is that compilation with certain features is not supported on all targets, notably WASM. For pure Rust crates, compilation should work on all targets.