[uClibc]problems with isinf()/isnan()
Axel Barnitzke
barney at xkontor.com
Mon Apr 15 14:59:46 UTC 2002
Hi, I got the same problem and here is my solution for it:
Index: libm/fpmacros.c
===================================================================
RCS file: /var/cvs/uClibc/libm/fpmacros.c,v
retrieving revision 1.1
diff -u -p -b -r1.1 fpmacros.c
--- libm/fpmacros.c 22 Nov 2001 14:01:05 -0000 1.1
+++ libm/fpmacros.c 15 Apr 2002 14:55:06 -0000
@@ -167,6 +167,32 @@ long int __isfinite ( double x )
/***********************************************************************
+ long int __isinff(float x) returns -1 if value represents negative
+ infinity, 1 if value represents positive infinity,
+ and 0 otherwise.
+
+ Calls: __signbit
+***********************************************************************/
+
+long int __isinff ( float x )
+{
+ long int class = __fpclassifyf(x);
+ if ( class == FP_INFINITE ) {
+ return ( (__signbitf(x)) ? -1 : 1);
+ }
+ return 0;
+}
+
+long int __isinf ( double x )
+{
+ long int class = __fpclassify(x);
+ if ( class == FP_INFINITE ) {
+ return ( (__signbit(x)) ? -1 : 1);
+ }
+ return 0;
+}
+
+/***********************************************************************
long int __isnanf(float x) returns nonzero if and only if x is a
NaN and zero otherwise.
trevor wrote:
> hi everyone,
>
> using uClibc-0.9.11 configured with:
> HAS_MMU = true
> HAS_FLOATING_POINT = true
> DO_C99_MATH = true
> HAS_LONG_LONG = true
>
> i'm having trouble getting isinf() and isnan() to behave. while trying to
> compile xinetd i came across this little gem. to isolate the problem i
> created the following piece of code:
>
> 1 #define _ISOC99_SOURCE
> 2
> 3 #include <stdio.h>
> 4 #include <math.h>
> 5
> 6 int main( void )
> 7 {
> 8 float a=24.56;
> 9
> 10 printf( "%f is %sa number\n", a, isnan(a)? "not " : "" );
> 11 printf( "%f is %sinfinite\n", a, isinf(a)? "" : "not " );
> 12 return 0;
> 13 }
>
> when compiled, the code as above gives me:
> cc -c -o main.o main.c
> cc -o main main.o -lm
> main.o: In function `main':
> main.o(.text+0x58): undefined reference to `__isinff'
> collect2: ld returned 1 exit status
> make: *** [main] Error 1
>
> if i comment out line 1, compiling gives:
> cc -c -o main.o main.c
> cc -o main main.o -lm
> main.o: In function `main':
> main.o(.text+0x1e): undefined reference to `isnan'
> main.o(.text+0x61): undefined reference to `isinf'
> collect2: ld returned 1 exit status
> make: *** [main] Error 1
>
> if i leave in line 1 and comment out line 11 i get:
> cc -c -o main.o main.c
> cc -o main main.o -lm
> $ ./main
> 24.559999 is a number
>
> which i assume is fine. does anyone have any ideas? i searched through the
> mbox archives and didn't find anything that appeared to be relevant.
>
> best regards,
> trevor
>
--
-- Barney
--------------------------------------
++ axel (barney) barnitzke
++ it consultant
++ xkontor IT solutions
fon :: +49 40 4100959-0
email :: mailto:barney at xkontor.com
More information about the uClibc
mailing list