summaryrefslogtreecommitdiff
path: root/chapter31/src/main/smp/sys/math.smp
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-11-15 11:20:40 -0800
committerCliff Click <cliffc@acm.org>2026-11-15 11:20:40 -0800
commitf0a6c6757a795b8e186de0076836a87acef59fa7 (patch)
treeef45c1b58093420bbd2de6647274139e46539bfe /chapter31/src/main/smp/sys/math.smp
parent7e66b7ae6b00a2e1652db32f01f0bf480508ef05 (diff)
downloadSimple-main.tar.gz
Simple-main.zip
Graphics now allow resizemain
Reorganize docs. Fix bugs X86 LOad+cmp scheduling. Math intrinsics
Diffstat (limited to 'chapter31/src/main/smp/sys/math.smp')
-rw-r--r--chapter31/src/main/smp/sys/math.smp12
1 files changed, 12 insertions, 0 deletions
diff --git a/chapter31/src/main/smp/sys/math.smp b/chapter31/src/main/smp/sys/math.smp
index a5e1887c..33bb0e5f 100644
--- a/chapter31/src/main/smp/sys/math.smp
+++ b/chapter31/src/main/smp/sys/math.smp
@@ -2,7 +2,19 @@
val PI = 3.141592653589793;
val E = 2.718281828459045;
+// Native libm functions, all f64 -> f64. sin/cos take radians; exp is e^x,
+// log is the natural logarithm, and sqrt is the nonnegative square root.
+// These are ordinary C calls: results and domain/range errors (including
+// errno) follow the host libm. They are not folded or treated as pure intrinsics.
+// The standard linker already includes -lm.
+{ f64 -> f64 } sin = "C";
+{ f64 -> f64 } cos = "C";
+{ f64 -> f64 } exp = "C";
+{ f64 -> f64 } log = "C";
+{ f64 -> f64 } sqrt = "C";
+
// Fixed-semantics C bindings recognized by the compiler's intrinsic inliner.
+// See chapter31/README.md, "Math support and intrinsics", for the compiler contract.
// These preserve all 64 bits, including signed zero and NaN payloads.
// They are NOT numeric conversions (ordinary typed assignments still are).
{ f64 -> i64 } simple_f64_bits = "C";