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 resultsonR3000mipseb



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

From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
To: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
Cc: gnats-bugs%netbsd.org@localhost, tsutsui%ceres.dti.ne.jp@localhost
Subject: Re: port-mips/57680: printf("%.1f") shows wrong resultsonR3000mipseb
Date: Mon, 6 Nov 2023 17:04:08 +0000

 This is a multi-part message in MIME format.
 --=_eoavAYPm/lvdxE8JbrWxVr5OLxSgiJLT
 
 > Date: Tue, 7 Nov 2023 01:49:34 +0900
 > From: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
 > 
 > ---
 > news3470-% rm -f test1 && make test1 && ./test1
 > cc -O2   -o test1 test1.c 
 > FLT_ROUNDS=1
 > fegetround()=0
 > news3470-% rm -f test1 && make test1 LDLIBS=-lm && ./test1
 > cc -O2   -o test1 test1.c -lm
 > FLT_ROUNDS=1
 > fegetround()=0
 > news3470-% 
 > ---
 > 
 > As I wrote an other mail, <mips/fenv.h> always has fegetround()
 > (and other fe*() functions) as static inline functions:
 > https://github.com/NetBSD/src/blob/trunk/sys/arch/mips/include/fenv.h 
 > so I'm afraid __weak_reference(fegetround) will never referred on mips.
 > (I'm not sure how __weak_reference() works in such static inline cases)
 
 I was assuming the weak reference wouldn't pick up the static inline,
 but I guess I was wrong.
 
 Try the attached test2 instead, with and without -lm as with test1?
 test2 doesn't include fenv.h, so it shouldn't get the static inline
 fegetround from there -- it should only get the library symbols.
 
 Can you also share the output of these commands?
 
 nm -gD /lib/libc.so | grep f.getround
 nm -gD /lib/libm.so | grep f.getround
 objdump -dr /lib/libc.so | grep -A15 'f.getround>:'
 objdump -dr /lib/libm.so | grep -A15 'f.getround>:'
 objdump -dr $OBJDIR/lib/libc/dtoa.o | grep -A40 'dtoa>:'
 
 (You can do these with the cross-build toolchain instead, of course,
 if that's more convenient.)
 
 --=_eoavAYPm/lvdxE8JbrWxVr5OLxSgiJLT
 Content-Type: text/plain; charset="ISO-8859-1"; name="test2"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="test2.c"
 
 #include <float.h>
 #include <stdio.h>
 
 #define	FE_TONEAREST	0
 
 __weakref_visible int fegetround_weak(void) __weak_reference(fegetround);
 
 int
 main(void)
 {
 	printf("FLT_ROUNDS=3D%d\n", FLT_ROUNDS);
 	if (fegetround_weak)
 		printf("fegetround()=3D%d\n", fegetround_weak());
 	else
 		printf("FE_TONEAREST=3D%d\n", FE_TONEAREST);
 
 	fflush(stdout);
 	return ferror(stdout);
 }
 
 --=_eoavAYPm/lvdxE8JbrWxVr5OLxSgiJLT--
 


Home | Main Index | Thread Index | Old Index