Explorar o código

riscv64: fix fesetenv(FE_DFL_ENV) crash

When FE_DFL_ENV is passed to fesetenv(), the very first instruction
lw t1, 0(a0) will fail since a0 is -1.
Ruinland ChuanTzu Tsai %!s(int64=5) %!d(string=hai) anos
pai
achega
c0b4a7b254
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      src/fenv/riscv64/fenv.S

+ 4 - 1
src/fenv/riscv64/fenv.S

@@ -45,8 +45,11 @@ fegetenv:
 .global fesetenv
 .type fesetenv, %function
 fesetenv:
+	li t2, -1
+	li t1, 0
+	beq a0, t2, 1f
 	lw t1, 0(a0)
-	fscsr t0, t1
+1:	fscsr t1
 	li a0, 0
 	ret