aboutsummaryrefslogtreecommitdiff
path: root/core/math.odin
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-06-12 21:21:18 +0100
committerGinger Bill <bill@gingerbill.org>2017-06-12 21:21:18 +0100
commitccda456c0a96f849e408bd707eca0a3baf9202b1 (patch)
tree57abf5f3bbb1e103165bbb90d78f6a14d3a9e27f /core/math.odin
parent83bad13e9e1bebd474768edf1a30e0682013149b (diff)
`foreign` blocks for procedures
Diffstat (limited to 'core/math.odin')
-rw-r--r--core/math.odin25
1 files changed, 14 insertions, 11 deletions
diff --git a/core/math.odin b/core/math.odin
index 1090e6ebe..8a6c492ee 100644
--- a/core/math.odin
+++ b/core/math.odin
@@ -30,21 +30,26 @@ type (
Complex complex64;
)
-proc sqrt(x: f32) -> f32 #foreign __llvm_core "llvm.sqrt.f32";
-proc sqrt(x: f64) -> f64 #foreign __llvm_core "llvm.sqrt.f64";
+foreign __llvm_core {
+ proc sqrt(x: f32) -> f32 #link_name "llvm.sqrt.f32";
+ proc sqrt(x: f64) -> f64 #link_name "llvm.sqrt.f64";
-proc sin (θ: f32) -> f32 #foreign __llvm_core "llvm.sin.f32";
-proc sin (θ: f64) -> f64 #foreign __llvm_core "llvm.sin.f64";
+ proc sin (θ: f32) -> f32 #link_name "llvm.sin.f32";
+ proc sin (θ: f64) -> f64 #link_name "llvm.sin.f64";
-proc cos (θ: f32) -> f32 #foreign __llvm_core "llvm.cos.f32";
-proc cos (θ: f64) -> f64 #foreign __llvm_core "llvm.cos.f64";
+ proc cos (θ: f32) -> f32 #link_name "llvm.cos.f32";
+ proc cos (θ: f64) -> f64 #link_name "llvm.cos.f64";
+
+ proc pow (x, power: f32) -> f32 #link_name "llvm.pow.f32";
+ proc pow (x, power: f64) -> f64 #link_name "llvm.pow.f64";
+
+ proc fmuladd(a, b, c: f32) -> f32 #link_name "llvm.fmuladd.f32";
+ proc fmuladd(a, b, c: f64) -> f64 #link_name "llvm.fmuladd.f64";
+}
proc tan (θ: f32) -> f32 #inline { return sin(θ)/cos(θ); }
proc tan (θ: f64) -> f64 #inline { return sin(θ)/cos(θ); }
-proc pow (x, power: f32) -> f32 #foreign __llvm_core "llvm.pow.f32";
-proc pow (x, power: f64) -> f64 #foreign __llvm_core "llvm.pow.f64";
-
proc lerp (a, b, t: f32) -> (x: f32) { return a*(1-t) + b*t; }
proc lerp (a, b, t: f64) -> (x: f64) { return a*(1-t) + b*t; }
@@ -55,8 +60,6 @@ proc unlerp(a, b, x: f64) -> (t: f64) { return (x-a)/(b-a); }
proc sign(x: f32) -> f32 { return x >= 0 ? +1 : -1; }
proc sign(x: f64) -> f64 { return x >= 0 ? +1 : -1; }
-proc fmuladd(a, b, c: f32) -> f32 #foreign __llvm_core "llvm.fmuladd.f32";
-proc fmuladd(a, b, c: f64) -> f64 #foreign __llvm_core "llvm.fmuladd.f64";
proc copy_sign(x, y: f32) -> f32 {