#include #if __riscv_flen >= 32 float roundf(float x) { if (isnan(x)) return x; if (x == INFINITY || x == -INFINITY) return x; float tmp; long n; __asm__ ("fcvt.w.s %0, %1, rmm" : "=r"(n) : "f"(x)); __asm__ ("fcvt.s.w %0, %1" : "=f"(tmp) : "r"(n)); x = copysign(tmp, x); return x; } #else #include "../roundf.c" #endif