Nuclei-Software / nuclei-sdk

Nuclei RISC-V Software Development Kit
https://doc.nucleisys.com/nuclei_sdk
Apache License 2.0
117 stars 50 forks source link

Fix -Wundef warnings for __riscv_flen #30

Closed KarlK90 closed 3 years ago

KarlK90 commented 3 years ago

This guards the floating point defines in riscv_bits.h, because __riscv_flen is undefined for archs that don't have them.

I ran into trouble in a project that has -Werror and -Wundef defined, defining __riscv_flen as 0 has the side effect that a non existent csr is accessed in the startup code which results in a runtime exception.

fanghuaqi commented 3 years ago

Hi @KarlK90 , thanks for your contribution, the riscv_flen should not be defined when no FPU present as described here https://github.com/riscv/riscv-toolchain-conventions#cc-preprocessor-definitions, your PR is correct, I should check the riscv_flen is defined first,then check value.

Thanks Huaqi