RFA: Fix __signbitf() and __signbitd() for 16-bit targets
Nick Clifton
nickc@redhat.com
Wed Dec 18 09:15:00 GMT 2013
Hi Guys,
I ran across a couple of bugs in the implementations of __signbitf()
and __signbitd() should the target happen to use 16-bit integers:
Firstly the functions pass the "unsigned int" type to the
GET_FLOAT_WORD and GET_HIGH_WORD macros, but these macros are
expecting a "__uint32_t" type.
Secondly they assume that the "int" return type is wide enough to hold
bit 31 of the extracted word.
The patch below fixes both of these problems and results in fixed gcc
testcase (gcc.dg/pr43419.c) when run on a 16-bit target. (With no
regressions for 32-bit and 64-bit targets).
OK to apply ?
Cheers
Nick
newlib/ChangeLog
2013-12-18 Nick Clifton <nickc@redhat.com>
* libm/common/s_signbit.c (__signbitf): Pass __uint32_t to
GET_FLOAT_WORD. Convert return value into a boolean.
(__signbitd): Pass __uint32_t to GET_HIGH_WORD. Convert return
value into a boolean.
Index: newlib/libm/common/s_signbit.c
===================================================================
RCS file: /cvs/cvsfiles/devo/newlib/libm/common/s_signbit.c,v
retrieving revision 1.2
diff -u -3 -p -r1.2 s_signbit.c
--- newlib/libm/common/s_signbit.c 6 Apr 2009 17:07:23 -0000 1.2
+++ newlib/libm/common/s_signbit.c 18 Dec 2013 08:44:31 -0000
@@ -41,19 +41,19 @@ int __signbitd (double x);
int
__signbitf (float x)
{
- unsigned int w;
+ __uint32_t w;
GET_FLOAT_WORD(w,x);
- return (w & 0x80000000);
+ return (w & 0x80000000) != 0;
}
int
__signbitd (double x)
{
- unsigned int msw;
+ __uint32_t msw;
GET_HIGH_WORD(msw, x);
- return (msw & 0x80000000);
+ return (msw & 0x80000000) != 0;
}
More information about the Newlib
mailing list