NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-mips/57680: printf("%.1f") shows wrong results on R3000mipseb



The following reply was made to PR port-mips/57680; it has been noted by GNATS.

From: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
To: rvp%SDF.ORG@localhost
Cc: gnats-bugs%netbsd.org@localhost, tsutsui%ceres.dti.ne.jp@localhost
Subject: Re: port-mips/57680: printf("%.1f") shows wrong results on R3000mipseb
Date: Fri, 3 Nov 2023 20:25:27 +0900

 > Can you show the output of this program? (Instructions in source)
 > 
 > ```
 > /**
 >   * Little-Endian 32-bit:
 >   * cc -I/usr/src/lib/libc/gdtoa/ -I/usr/src/lib/libc/arch/i386/gdtoa/ \
 >   *   -DDEBUG -DHonor_FLT_ROUNDS -DNO_LONG_LONG -o m \
 >   *   m.c /usr/src/lib/libc/gdtoa/dtoa.c /usr/src/lib/libc/gdtoa/dmisc.c
 >   *
 >   * Big-Endian 32-bit:
 >   * cc -I/usr/src/lib/libc/gdtoa/ -I/usr/src/lib/libc/arch/mips/gdtoa/ \
 >   *   -DDEBUG -DHonor_FLT_ROUNDS -DNO_LONG_LONG -o m \
 >   *   m.c /usr/src/lib/libc/gdtoa/dtoa.c /usr/src/lib/libc/gdtoa/dmisc.c
 >   */
 
 I have not tried this yet, but git bisect shows
 the following pullup [netbsd-9 #506] caused this problem:
 
  https://mail-index.netbsd.org/source-changes/2019/12/08/msg111698.html
  https://github.com/NetBSD/src/commit/87f7bda
 ---
 diff --git a/lib/libc/gdtoa/Makefile.inc b/lib/libc/gdtoa/Makefile.inc
 index 19268daa9148..b8bb0a51d464 100644
 --- a/lib/libc/gdtoa/Makefile.inc
 +++ b/lib/libc/gdtoa/Makefile.inc
 @@ -1,10 +1,14 @@
 -#	$NetBSD: Makefile.inc,v 1.10 2014/01/16 20:31:42 christos Exp $
 +#	$NetBSD: Makefile.inc,v 1.10.28.1 2019/12/08 13:35:51 martin Exp $
  
  # gdtoa sources
  .PATH: ${.CURDIR}/gdtoa
  CPPFLAGS+=-I${.CURDIR}/gdtoa -I${.CURDIR}/locale
  
 +.if ${MACHINE_ARCH} == "vax"
  CPPFLAGS+=-DNO_FENV_H
 +.else
 +CPPFLAGS+=-DHonor_FLT_ROUNDS
 +.endif
  
  # machine-dependent directory must provide the following:
  # 	arith.h gd_qnan.h
 diff --git a/lib/libc/gdtoa/gdtoa_fltrnds.h b/lib/libc/gdtoa/gdtoa_fltrnds.h
 index 33e5f9e5342c..f170de5fd158 100644
 --- a/lib/libc/gdtoa/gdtoa_fltrnds.h
 +++ b/lib/libc/gdtoa/gdtoa_fltrnds.h
 @@ -1,4 +1,5 @@
 -	FPI *fpi, fpi1;
 +	CONST FPI *fpi;
 +	FPI fpi1;
  	int Rounding;
  #ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */
  	Rounding = Flt_Rounds;
 diff --git a/lib/libc/gdtoa/gdtoaimp.h b/lib/libc/gdtoa/gdtoaimp.h
 index 32a1bad59be0..f1d1de0f24b3 100644
 --- a/lib/libc/gdtoa/gdtoaimp.h
 +++ b/lib/libc/gdtoa/gdtoaimp.h
 @@ -1,4 +1,4 @@
 -/* $NetBSD: gdtoaimp.h,v 1.14 2013/04/19 10:41:53 joerg Exp $ */
 +/* $NetBSD: gdtoaimp.h,v 1.14.30.1 2019/12/08 13:35:51 martin Exp $ */
  
  /****************************************************************
  
 @@ -200,6 +200,10 @@ THIS SOFTWARE.
  #include "gd_qnan.h"
  #ifdef Honor_FLT_ROUNDS
  #include <fenv.h>
 +__unused __weakref_visible int __libc_fegetround_ref(void)
 +  __weak_reference(fegetround);
 +#define fegetround()							\
 +	(__libc_fegetround_ref ? __libc_fegetround_ref() : FE_TONEAREST)
  #endif
  
  #ifdef DEBUG
 ---
 
 Actually disabling "-DHonor_FLT_ROUNDS" on mips (especially on R3010?)
 works around.
 
 ---
 diff --git a/lib/libc/gdtoa/Makefile.inc b/lib/libc/gdtoa/Makefile.inc
 index b8bb0a51d464..a4c42d0ef269 100644
 --- a/lib/libc/gdtoa/Makefile.inc
 +++ b/lib/libc/gdtoa/Makefile.inc
 @@ -4,7 +4,8 @@
  .PATH: ${.CURDIR}/gdtoa
  CPPFLAGS+=-I${.CURDIR}/gdtoa -I${.CURDIR}/locale
  
 -.if ${MACHINE_ARCH} == "vax"
 +.if ${MACHINE_ARCH} == "vax" || \
 +    ${MACHINE_CPU} == "mips"
  CPPFLAGS+=-DNO_FENV_H
  .else
  CPPFLAGS+=-DHonor_FLT_ROUNDS
 
 ---
 Izumi Tsutsui
 


Home | Main Index | Thread Index | Old Index