From bbfbc439f2aa6d4e4e47bb478c7182b2841286e3 Mon Sep 17 00:00:00 2001 From: Mitchell Horne Date: Mon, 29 Jun 2020 19:30:35 +0000 Subject: [PATCH] Fix printf(3) output of long doubles on RISC-V When the RISC-V port was initially committed to FreeBSD, GCC would generate 64-bit long doubles, and the definitions in _fpmath.h reflected that. This was changed to 128-bit in GCC later that year [1], but the definitions were never updated, despite the documented workaround. This causes printf(3) and friends to interpret only the low 64-bits of a long double in ldtoa, thereby printing incorrect values. Update the definitions now that both clang and GCC generate 128-bit long doubles. [1] https://github.com/riscv/riscv-gcc/commit/54b21fc5ae83cefec44bc2caed4a8c664c274ba0 PR: 242067 Reported by: Dennis Clarke MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25420 --- lib/libc/riscv/_fpmath.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib/libc/riscv/_fpmath.h b/lib/libc/riscv/_fpmath.h index 5c4077cb90c..be5be56acaa 100644 --- a/lib/libc/riscv/_fpmath.h +++ b/lib/libc/riscv/_fpmath.h @@ -46,19 +46,6 @@ union IEEEl2bits { #define LDBL_IMPLICIT_NBIT #define mask_nbit_l(u) ((void)0) -#define LDBL_MANH_SIZE 20 -#define LDBL_MANL_SIZE 32 - -#define LDBL_TO_ARRAY32(u, a) do { \ - (a)[0] = (uint32_t)(u).bits.manl; \ - (a)[1] = (uint32_t)(u).bits.manh; \ -} while(0) - -/* - * TODO: Due to compiler problem we are temporary using - * LDBL_PREC == 53. Use code below for LDBL_PREC == 113 - */ -#if 0 #define LDBL_MANH_SIZE 48 #define LDBL_MANL_SIZE 64 @@ -68,4 +55,3 @@ union IEEEl2bits { (a)[2] = (uint32_t)(u).bits.manh; \ (a)[3] = (uint32_t)((u).bits.manh >> 32); \ } while(0) -#endif