mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 12:03:41 +00:00
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.
This commit is contained in:
committed by
Ron Evans
parent
d05103668f
commit
6c1301688b
+2
-18
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user