[PATCH v2] riscv: Add macros for FPUCW/fcsr in fpu_control.h

Richard Henderson richard.henderson@linaro.org
Sun Feb 12 19:36:57 GMT 2023


On 2/11/23 20:52, Shiqi Zhang wrote:
> Add macros for rounding modes and accrued exception flags in order to
> make controlling fcsr easier for users.
> 
> Reference: RISC-V Unprivileged Spec v20191213, Section 11.2: Figure 11.2, Table 11.1 & 11.2
> ---
> Fixed careless mistakes in v1 and removed invalid rounding mode DYN.
> 
> Still, I think these macros should be documented somewhere but I'm
> not sure where should I doc them. I'll appreciate it if you could give
> some suggestions.

Honestly, no one should be using <fpu_control.h> at all.  It was originally an x86 
specific thing.  The only reason to fill in this header at all is to match the original 
x86 API.  Therefore the symbol names should match ./sysdeps/x86/fpu_control.h.

When porting applications to work on RISC-V, it would be much better to update them to use 
<fenv.h>, which is what ISO C standardized.  I assume there would be more than a few 
ifdefs removed in the process.


r~


More information about the Libc-alpha mailing list