Ver código fonte

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 5 anos atrás
pai
commit
c0b4a7b254
1 arquivos alterados com 4 adições e 1 exclusões
  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