diff options
author | Ayke van Laethem <[email protected]> | 2021-08-05 15:53:29 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-08-10 20:08:27 +0200 |
commit | 6c1301688b9b16d2b9d3aa23534592ed87640b01 (patch) | |
tree | e73dcab708d0aa645d139681d1f142d22604996f /src/runtime/math.go | |
parent | d05103668f207f8d33d82d1c306692557cc81025 (diff) | |
download | tinygo-6c1301688b9b16d2b9d3aa23534592ed87640b01.tar.gz tinygo-6c1301688b9b16d2b9d3aa23534592ed87640b01.zip |
math: fix math.Max and math.Min
The math package failed the package tests on arm64 and wasm:
GOARCH=arm64 tinygo test math
Apparently the builtins llvm.maximum.f64 and llvm.minimum.f64 have
slightly different behavior on arm64 and wasm compared to what Go
expects.
Diffstat (limited to 'src/runtime/math.go')
-rw-r--r-- | src/runtime/math.go | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/runtime/math.go b/src/runtime/math.go index 25a48d4f2..5498da6f4 100644 --- a/src/runtime/math.go +++ b/src/runtime/math.go @@ -168,29 +168,13 @@ func math_Log2(x float64) float64 { return math_log2(x) } func math_log2(x float64) float64 //go:linkname math_Max math.Max -func math_Max(x, y float64) float64 { - if GOARCH == "arm64" || GOARCH == "wasm" { - return llvm_maximum(x, y) - } - return math_max(x, y) -} - -//export llvm.maximum.f64 -func llvm_maximum(x, y float64) float64 +func math_Max(x, y float64) float64 { return math_max(x, y) } //go:linkname math_max math.max func math_max(x, y float64) float64 //go:linkname math_Min math.Min -func math_Min(x, y float64) float64 { - if GOARCH == "arm64" || GOARCH == "wasm" { - return llvm_minimum(x, y) - } - return math_min(x, y) -} - -//export llvm.minimum.f64 -func llvm_minimum(x, y float64) float64 +func math_Min(x, y float64) float64 { return math_min(x, y) } //go:linkname math_min math.min func math_min(x, y float64) float64 |